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 struct rte_security_session *sec_session;
77 enum rte_security_session_action_type type;
78 struct rte_crypto_op *op;
80 struct rte_mbuf *obuf, *ibuf;
85 #define ALIGN_POW2_ROUNDUP(num, align) \
86 (((num) + (align) - 1) & ~((align) - 1))
89 * Forward declarations.
92 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
93 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
97 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
98 struct crypto_unittest_params *ut_params,
99 struct crypto_testsuite_params *ts_param,
100 const uint8_t *cipher,
101 const uint8_t *digest,
104 static struct rte_mbuf *
105 setup_test_string(struct rte_mempool *mpool,
106 const char *string, size_t len, uint8_t blocksize)
108 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
109 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
111 memset(m->buf_addr, 0, m->buf_len);
113 char *dst = rte_pktmbuf_append(m, t_len);
120 rte_memcpy(dst, string, t_len);
122 memset(dst, 0, t_len);
128 /* Get number of bytes in X bits (rounding up) */
130 ceil_byte_length(uint32_t num_bits)
133 return ((num_bits >> 3) + 1);
135 return (num_bits >> 3);
138 static struct rte_crypto_op *
139 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
141 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
142 printf("Error sending packet for encryption");
148 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
154 static struct crypto_testsuite_params testsuite_params = { NULL };
155 static struct crypto_unittest_params unittest_params;
158 testsuite_setup(void)
160 struct crypto_testsuite_params *ts_params = &testsuite_params;
161 struct rte_cryptodev_info info;
162 uint32_t i = 0, nb_devs, dev_id;
166 memset(ts_params, 0, sizeof(*ts_params));
168 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
169 if (ts_params->mbuf_pool == NULL) {
170 /* Not already created so create */
171 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
173 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
175 if (ts_params->mbuf_pool == NULL) {
176 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
181 ts_params->large_mbuf_pool = rte_mempool_lookup(
182 "CRYPTO_LARGE_MBUFPOOL");
183 if (ts_params->large_mbuf_pool == NULL) {
184 /* Not already created so create */
185 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
186 "CRYPTO_LARGE_MBUFPOOL",
189 if (ts_params->large_mbuf_pool == NULL) {
191 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
196 ts_params->op_mpool = rte_crypto_op_pool_create(
197 "MBUF_CRYPTO_SYM_OP_POOL",
198 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199 NUM_MBUFS, MBUF_CACHE_SIZE,
201 sizeof(struct rte_crypto_sym_xform) +
204 if (ts_params->op_mpool == NULL) {
205 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
209 /* Create an AESNI MB device if required */
210 if (gbl_driver_id == rte_cryptodev_driver_id_get(
211 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
212 nb_devs = rte_cryptodev_device_count_by_driver(
213 rte_cryptodev_driver_id_get(
214 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
217 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
219 TEST_ASSERT(ret == 0,
220 "Failed to create instance of"
222 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
226 /* Create an AESNI GCM device if required */
227 if (gbl_driver_id == rte_cryptodev_driver_id_get(
228 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
229 nb_devs = rte_cryptodev_device_count_by_driver(
230 rte_cryptodev_driver_id_get(
231 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
233 TEST_ASSERT_SUCCESS(rte_vdev_init(
234 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
235 "Failed to create instance of"
237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
241 /* Create a SNOW 3G device if required */
242 if (gbl_driver_id == rte_cryptodev_driver_id_get(
243 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
244 nb_devs = rte_cryptodev_device_count_by_driver(
245 rte_cryptodev_driver_id_get(
246 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
248 TEST_ASSERT_SUCCESS(rte_vdev_init(
249 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
250 "Failed to create instance of"
252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
256 /* Create a KASUMI device if required */
257 if (gbl_driver_id == rte_cryptodev_driver_id_get(
258 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
259 nb_devs = rte_cryptodev_device_count_by_driver(
260 rte_cryptodev_driver_id_get(
261 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
263 TEST_ASSERT_SUCCESS(rte_vdev_init(
264 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
265 "Failed to create instance of"
267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
271 /* Create a ZUC device if required */
272 if (gbl_driver_id == rte_cryptodev_driver_id_get(
273 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
274 nb_devs = rte_cryptodev_device_count_by_driver(
275 rte_cryptodev_driver_id_get(
276 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
278 TEST_ASSERT_SUCCESS(rte_vdev_init(
279 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
280 "Failed to create instance of"
282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
286 /* Create a NULL device if required */
287 if (gbl_driver_id == rte_cryptodev_driver_id_get(
288 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
289 nb_devs = rte_cryptodev_device_count_by_driver(
290 rte_cryptodev_driver_id_get(
291 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
294 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
296 TEST_ASSERT(ret == 0,
297 "Failed to create instance of"
299 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
303 /* Create an OPENSSL device if required */
304 if (gbl_driver_id == rte_cryptodev_driver_id_get(
305 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
306 nb_devs = rte_cryptodev_device_count_by_driver(
307 rte_cryptodev_driver_id_get(
308 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
311 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
314 TEST_ASSERT(ret == 0, "Failed to create "
315 "instance of pmd : %s",
316 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
320 /* Create a ARMv8 device if required */
321 if (gbl_driver_id == rte_cryptodev_driver_id_get(
322 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
323 nb_devs = rte_cryptodev_device_count_by_driver(
324 rte_cryptodev_driver_id_get(
325 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
328 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
331 TEST_ASSERT(ret == 0, "Failed to create "
332 "instance of pmd : %s",
333 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
337 /* Create a MVSAM device if required */
338 if (gbl_driver_id == rte_cryptodev_driver_id_get(
339 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
340 nb_devs = rte_cryptodev_device_count_by_driver(
341 rte_cryptodev_driver_id_get(
342 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
345 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
348 TEST_ASSERT(ret == 0, "Failed to create "
349 "instance of pmd : %s",
350 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
354 /* Create an CCP device if required */
355 if (gbl_driver_id == rte_cryptodev_driver_id_get(
356 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
357 nb_devs = rte_cryptodev_device_count_by_driver(
358 rte_cryptodev_driver_id_get(
359 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
362 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
365 TEST_ASSERT(ret == 0, "Failed to create "
366 "instance of pmd : %s",
367 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
371 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
372 char vdev_args[VDEV_ARGS_SIZE] = {""};
373 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
374 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
375 uint16_t slave_core_count = 0;
376 uint16_t socket_id = 0;
378 if (gbl_driver_id == rte_cryptodev_driver_id_get(
379 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
381 /* Identify the Slave Cores
382 * Use 2 slave cores for the device args
384 RTE_LCORE_FOREACH_SLAVE(i) {
385 if (slave_core_count > 1)
387 snprintf(vdev_args, sizeof(vdev_args),
388 "%s%d", temp_str, i);
389 strcpy(temp_str, vdev_args);
390 strlcat(temp_str, ";", sizeof(temp_str));
392 socket_id = rte_lcore_to_socket_id(i);
394 if (slave_core_count != 2) {
396 "Cryptodev scheduler test require at least "
397 "two slave cores to run. "
398 "Please use the correct coremask.\n");
401 strcpy(temp_str, vdev_args);
402 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
403 temp_str, socket_id);
404 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
405 nb_devs = rte_cryptodev_device_count_by_driver(
406 rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
410 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
412 TEST_ASSERT(ret == 0,
413 "Failed to create instance %u of"
415 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
418 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
420 nb_devs = rte_cryptodev_count();
422 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
426 /* Create list of valid crypto devs */
427 for (i = 0; i < nb_devs; i++) {
428 rte_cryptodev_info_get(i, &info);
429 if (info.driver_id == gbl_driver_id)
430 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
433 if (ts_params->valid_dev_count < 1)
436 /* Set up all the qps on the first of the valid devices found */
438 dev_id = ts_params->valid_devs[0];
440 rte_cryptodev_info_get(dev_id, &info);
442 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
443 ts_params->conf.socket_id = SOCKET_ID_ANY;
444 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
446 unsigned int session_size =
447 rte_cryptodev_sym_get_private_session_size(dev_id);
450 * Create mempool with maximum number of sessions * 2,
451 * to include the session headers
453 if (info.sym.max_nb_sessions != 0 &&
454 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
455 RTE_LOG(ERR, USER1, "Device does not support "
456 "at least %u sessions\n",
461 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
462 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
464 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
465 "session mempool allocation failed");
467 ts_params->session_priv_mpool = rte_mempool_create(
471 0, 0, NULL, NULL, NULL,
474 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
475 "session mempool allocation failed");
479 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
481 "Failed to configure cryptodev %u with %u qps",
482 dev_id, ts_params->conf.nb_queue_pairs);
484 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
485 ts_params->qp_conf.mp_session = ts_params->session_mpool;
486 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
488 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
489 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
490 dev_id, qp_id, &ts_params->qp_conf,
491 rte_cryptodev_socket_id(dev_id)),
492 "Failed to setup queue pair %u on cryptodev %u",
500 testsuite_teardown(void)
502 struct crypto_testsuite_params *ts_params = &testsuite_params;
504 if (ts_params->mbuf_pool != NULL) {
505 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
506 rte_mempool_avail_count(ts_params->mbuf_pool));
509 if (ts_params->op_mpool != NULL) {
510 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
511 rte_mempool_avail_count(ts_params->op_mpool));
514 /* Free session mempools */
515 if (ts_params->session_priv_mpool != NULL) {
516 rte_mempool_free(ts_params->session_priv_mpool);
517 ts_params->session_priv_mpool = NULL;
520 if (ts_params->session_mpool != NULL) {
521 rte_mempool_free(ts_params->session_mpool);
522 ts_params->session_mpool = NULL;
529 struct crypto_testsuite_params *ts_params = &testsuite_params;
530 struct crypto_unittest_params *ut_params = &unittest_params;
534 /* Clear unit test parameters before running test */
535 memset(ut_params, 0, sizeof(*ut_params));
537 /* Reconfigure device to default parameters */
538 ts_params->conf.socket_id = SOCKET_ID_ANY;
539 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
540 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
541 ts_params->qp_conf.mp_session = ts_params->session_mpool;
542 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
544 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
546 "Failed to configure cryptodev %u",
547 ts_params->valid_devs[0]);
549 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
550 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
551 ts_params->valid_devs[0], qp_id,
553 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
554 "Failed to setup queue pair %u on cryptodev %u",
555 qp_id, ts_params->valid_devs[0]);
559 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
561 /* Start the device */
562 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
563 "Failed to start cryptodev %u",
564 ts_params->valid_devs[0]);
572 struct crypto_testsuite_params *ts_params = &testsuite_params;
573 struct crypto_unittest_params *ut_params = &unittest_params;
574 struct rte_cryptodev_stats stats;
576 /* free crypto session structure */
577 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
578 if (ut_params->sec_session) {
579 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
580 (ts_params->valid_devs[0]),
581 ut_params->sec_session);
582 ut_params->sec_session = NULL;
585 if (ut_params->sess) {
586 rte_cryptodev_sym_session_clear(
587 ts_params->valid_devs[0],
589 rte_cryptodev_sym_session_free(ut_params->sess);
590 ut_params->sess = NULL;
594 /* free crypto operation structure */
596 rte_crypto_op_free(ut_params->op);
599 * free mbuf - both obuf and ibuf are usually the same,
600 * so check if they point at the same address is necessary,
601 * to avoid freeing the mbuf twice.
603 if (ut_params->obuf) {
604 rte_pktmbuf_free(ut_params->obuf);
605 if (ut_params->ibuf == ut_params->obuf)
609 if (ut_params->ibuf) {
610 rte_pktmbuf_free(ut_params->ibuf);
614 if (ts_params->mbuf_pool != NULL)
615 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
616 rte_mempool_avail_count(ts_params->mbuf_pool));
618 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
620 /* Stop the device */
621 rte_cryptodev_stop(ts_params->valid_devs[0]);
625 test_device_configure_invalid_dev_id(void)
627 struct crypto_testsuite_params *ts_params = &testsuite_params;
628 uint16_t dev_id, num_devs = 0;
630 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
631 "Need at least %d devices for test", 1);
633 /* valid dev_id values */
634 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
636 /* Stop the device in case it's started so it can be configured */
637 rte_cryptodev_stop(dev_id);
639 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
640 "Failed test for rte_cryptodev_configure: "
641 "invalid dev_num %u", dev_id);
643 /* invalid dev_id values */
646 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
647 "Failed test for rte_cryptodev_configure: "
648 "invalid dev_num %u", dev_id);
652 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
653 "Failed test for rte_cryptodev_configure:"
654 "invalid dev_num %u", dev_id);
660 test_device_configure_invalid_queue_pair_ids(void)
662 struct crypto_testsuite_params *ts_params = &testsuite_params;
663 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
665 /* Stop the device in case it's started so it can be configured */
666 rte_cryptodev_stop(ts_params->valid_devs[0]);
668 /* valid - one queue pairs */
669 ts_params->conf.nb_queue_pairs = 1;
671 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
673 "Failed to configure cryptodev: dev_id %u, qp_id %u",
674 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
677 /* valid - max value queue pairs */
678 ts_params->conf.nb_queue_pairs = orig_nb_qps;
680 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
682 "Failed to configure cryptodev: dev_id %u, qp_id %u",
683 ts_params->valid_devs[0],
684 ts_params->conf.nb_queue_pairs);
687 /* invalid - zero queue pairs */
688 ts_params->conf.nb_queue_pairs = 0;
690 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
692 "Failed test for rte_cryptodev_configure, dev_id %u,"
694 ts_params->valid_devs[0],
695 ts_params->conf.nb_queue_pairs);
698 /* invalid - max value supported by field queue pairs */
699 ts_params->conf.nb_queue_pairs = UINT16_MAX;
701 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
703 "Failed test for rte_cryptodev_configure, dev_id %u,"
705 ts_params->valid_devs[0],
706 ts_params->conf.nb_queue_pairs);
709 /* invalid - max value + 1 queue pairs */
710 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
712 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
714 "Failed test for rte_cryptodev_configure, dev_id %u,"
716 ts_params->valid_devs[0],
717 ts_params->conf.nb_queue_pairs);
719 /* revert to original testsuite value */
720 ts_params->conf.nb_queue_pairs = orig_nb_qps;
726 test_queue_pair_descriptor_setup(void)
728 struct crypto_testsuite_params *ts_params = &testsuite_params;
729 struct rte_cryptodev_info dev_info;
730 struct rte_cryptodev_qp_conf qp_conf = {
731 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
736 /* Stop the device in case it's started so it can be configured */
737 rte_cryptodev_stop(ts_params->valid_devs[0]);
740 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
742 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
744 "Failed to configure cryptodev %u",
745 ts_params->valid_devs[0]);
748 * Test various ring sizes on this device. memzones can't be
749 * freed so are re-used if ring is released and re-created.
751 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
752 qp_conf.mp_session = ts_params->session_mpool;
753 qp_conf.mp_session_private = ts_params->session_priv_mpool;
755 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
756 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
757 ts_params->valid_devs[0], qp_id, &qp_conf,
758 rte_cryptodev_socket_id(
759 ts_params->valid_devs[0])),
761 "rte_cryptodev_queue_pair_setup: num_inflights "
762 "%u on qp %u on cryptodev %u",
763 qp_conf.nb_descriptors, qp_id,
764 ts_params->valid_devs[0]);
767 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
769 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
770 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
771 ts_params->valid_devs[0], qp_id, &qp_conf,
772 rte_cryptodev_socket_id(
773 ts_params->valid_devs[0])),
775 " rte_cryptodev_queue_pair_setup: num_inflights"
776 " %u on qp %u on cryptodev %u",
777 qp_conf.nb_descriptors, qp_id,
778 ts_params->valid_devs[0]);
781 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
783 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
784 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
785 ts_params->valid_devs[0], qp_id, &qp_conf,
786 rte_cryptodev_socket_id(
787 ts_params->valid_devs[0])),
789 "rte_cryptodev_queue_pair_setup: num_inflights"
790 " %u on qp %u on cryptodev %u",
791 qp_conf.nb_descriptors, qp_id,
792 ts_params->valid_devs[0]);
795 /* invalid number of descriptors - max supported + 2 */
796 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
798 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
799 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
800 ts_params->valid_devs[0], qp_id, &qp_conf,
801 rte_cryptodev_socket_id(
802 ts_params->valid_devs[0])),
803 "Unexpectedly passed test for "
804 "rte_cryptodev_queue_pair_setup:"
805 "num_inflights %u on qp %u on cryptodev %u",
806 qp_conf.nb_descriptors, qp_id,
807 ts_params->valid_devs[0]);
810 /* invalid number of descriptors - max value of parameter */
811 qp_conf.nb_descriptors = UINT32_MAX-1;
813 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
814 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
815 ts_params->valid_devs[0], qp_id, &qp_conf,
816 rte_cryptodev_socket_id(
817 ts_params->valid_devs[0])),
818 "Unexpectedly passed test for "
819 "rte_cryptodev_queue_pair_setup:"
820 "num_inflights %u on qp %u on cryptodev %u",
821 qp_conf.nb_descriptors, qp_id,
822 ts_params->valid_devs[0]);
825 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
827 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
828 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
829 ts_params->valid_devs[0], qp_id, &qp_conf,
830 rte_cryptodev_socket_id(
831 ts_params->valid_devs[0])),
833 " rte_cryptodev_queue_pair_setup:"
834 "num_inflights %u on qp %u on cryptodev %u",
835 qp_conf.nb_descriptors, qp_id,
836 ts_params->valid_devs[0]);
839 /* invalid number of descriptors - max supported + 1 */
840 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
842 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
843 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
844 ts_params->valid_devs[0], qp_id, &qp_conf,
845 rte_cryptodev_socket_id(
846 ts_params->valid_devs[0])),
847 "Unexpectedly passed test for "
848 "rte_cryptodev_queue_pair_setup:"
849 "num_inflights %u on qp %u on cryptodev %u",
850 qp_conf.nb_descriptors, qp_id,
851 ts_params->valid_devs[0]);
854 /* test invalid queue pair id */
855 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
857 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
859 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
860 ts_params->valid_devs[0],
862 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
863 "Failed test for rte_cryptodev_queue_pair_setup:"
864 "invalid qp %u on cryptodev %u",
865 qp_id, ts_params->valid_devs[0]);
867 qp_id = 0xffff; /*invalid*/
869 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
870 ts_params->valid_devs[0],
872 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
873 "Failed test for rte_cryptodev_queue_pair_setup:"
874 "invalid qp %u on cryptodev %u",
875 qp_id, ts_params->valid_devs[0]);
880 /* ***** Plaintext data for tests ***** */
882 const char catch_22_quote_1[] =
883 "There was only one catch and that was Catch-22, which "
884 "specified that a concern for one's safety in the face of "
885 "dangers that were real and immediate was the process of a "
886 "rational mind. Orr was crazy and could be grounded. All he "
887 "had to do was ask; and as soon as he did, he would no longer "
888 "be crazy and would have to fly more missions. Orr would be "
889 "crazy to fly more missions and sane if he didn't, but if he "
890 "was sane he had to fly them. If he flew them he was crazy "
891 "and didn't have to; but if he didn't want to he was sane and "
892 "had to. Yossarian was moved very deeply by the absolute "
893 "simplicity of this clause of Catch-22 and let out a "
894 "respectful whistle. \"That's some catch, that Catch-22\", he "
895 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
897 const char catch_22_quote[] =
898 "What a lousy earth! He wondered how many people were "
899 "destitute that same night even in his own prosperous country, "
900 "how many homes were shanties, how many husbands were drunk "
901 "and wives socked, and how many children were bullied, abused, "
902 "or abandoned. How many families hungered for food they could "
903 "not afford to buy? How many hearts were broken? How many "
904 "suicides would take place that same night, how many people "
905 "would go insane? How many cockroaches and landlords would "
906 "triumph? How many winners were losers, successes failures, "
907 "and rich men poor men? How many wise guys were stupid? How "
908 "many happy endings were unhappy endings? How many honest men "
909 "were liars, brave men cowards, loyal men traitors, how many "
910 "sainted men were corrupt, how many people in positions of "
911 "trust had sold their souls to bodyguards, how many had never "
912 "had souls? How many straight-and-narrow paths were crooked "
913 "paths? How many best families were worst families and how "
914 "many good people were bad people? When you added them all up "
915 "and then subtracted, you might be left with only the children, "
916 "and perhaps with Albert Einstein and an old violinist or "
917 "sculptor somewhere.";
919 #define QUOTE_480_BYTES (480)
920 #define QUOTE_512_BYTES (512)
921 #define QUOTE_768_BYTES (768)
922 #define QUOTE_1024_BYTES (1024)
926 /* ***** SHA1 Hash Tests ***** */
928 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
930 static uint8_t hmac_sha1_key[] = {
931 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
932 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
933 0xDE, 0xF4, 0xDE, 0xAD };
935 /* ***** SHA224 Hash Tests ***** */
937 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
940 /* ***** AES-CBC Cipher Tests ***** */
942 #define CIPHER_KEY_LENGTH_AES_CBC (16)
943 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
945 static uint8_t aes_cbc_key[] = {
946 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
947 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
949 static uint8_t aes_cbc_iv[] = {
950 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
951 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
954 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
956 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
957 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
958 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
959 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
960 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
961 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
962 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
963 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
964 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
965 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
966 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
967 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
968 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
969 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
970 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
971 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
972 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
973 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
974 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
975 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
976 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
977 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
978 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
979 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
980 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
981 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
982 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
983 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
984 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
985 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
986 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
987 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
988 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
989 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
990 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
991 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
992 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
993 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
994 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
995 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
996 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
997 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
998 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
999 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1000 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1001 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1002 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1003 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1004 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1005 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1006 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1007 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1008 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1009 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1010 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1011 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1012 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1013 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1014 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1015 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1016 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1017 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1018 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1019 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1020 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1023 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1024 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1025 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1026 0x18, 0x8c, 0x1d, 0x32
1030 /* Multisession Vector context Test */
1031 /*Begin Session 0 */
1032 static uint8_t ms_aes_cbc_key0[] = {
1033 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1034 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1037 static uint8_t ms_aes_cbc_iv0[] = {
1038 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1039 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1042 static const uint8_t ms_aes_cbc_cipher0[] = {
1043 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1044 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1045 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1046 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1047 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1048 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1049 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1050 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1051 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1052 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1053 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1054 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1055 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1056 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1057 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1058 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1059 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1060 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1061 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1062 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1063 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1064 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1065 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1066 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1067 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1068 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1069 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1070 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1071 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1072 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1073 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1074 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1075 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1076 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1077 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1078 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1079 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1080 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1081 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1082 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1083 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1084 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1085 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1086 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1087 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1088 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1089 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1090 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1091 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1092 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1093 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1094 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1095 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1096 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1097 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1098 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1099 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1100 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1101 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1102 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1103 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1104 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1105 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1106 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1110 static uint8_t ms_hmac_key0[] = {
1111 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1112 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1113 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1114 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1115 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1116 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1117 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1118 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1121 static const uint8_t ms_hmac_digest0[] = {
1122 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1123 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1124 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1125 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1126 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1127 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1128 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1129 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1133 /* Begin session 1 */
1135 static uint8_t ms_aes_cbc_key1[] = {
1136 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1137 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1140 static uint8_t ms_aes_cbc_iv1[] = {
1141 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1142 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1145 static const uint8_t ms_aes_cbc_cipher1[] = {
1146 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1147 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1148 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1149 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1150 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1151 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1152 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1153 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1154 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1155 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1156 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1157 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1158 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1159 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1160 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1161 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1162 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1163 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1164 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1165 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1166 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1167 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1168 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1169 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1170 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1171 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1172 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1173 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1174 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1175 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1176 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1177 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1178 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1179 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1180 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1181 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1182 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1183 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1184 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1185 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1186 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1187 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1188 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1189 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1190 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1191 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1192 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1193 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1194 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1195 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1196 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1197 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1198 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1199 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1200 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1201 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1202 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1203 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1204 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1205 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1206 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1207 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1208 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1209 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1213 static uint8_t ms_hmac_key1[] = {
1214 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1215 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1216 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1217 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1218 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1219 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1220 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1221 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1224 static const uint8_t ms_hmac_digest1[] = {
1225 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1226 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1227 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1228 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1229 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1230 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1231 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1232 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1235 /* Begin Session 2 */
1236 static uint8_t ms_aes_cbc_key2[] = {
1237 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1238 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1241 static uint8_t ms_aes_cbc_iv2[] = {
1242 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1243 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1246 static const uint8_t ms_aes_cbc_cipher2[] = {
1247 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1248 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1249 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1250 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1251 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1252 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1253 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1254 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1255 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1256 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1257 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1258 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1259 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1260 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1261 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1262 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1263 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1264 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1265 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1266 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1267 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1268 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1269 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1270 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1271 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1272 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1273 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1274 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1275 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1276 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1277 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1278 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1279 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1280 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1281 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1282 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1283 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1284 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1285 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1286 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1287 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1288 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1289 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1290 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1291 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1292 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1293 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1294 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1295 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1296 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1297 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1298 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1299 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1300 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1301 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1302 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1303 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1304 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1305 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1306 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1307 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1308 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1309 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1310 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1313 static uint8_t ms_hmac_key2[] = {
1314 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1315 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1316 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1317 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1318 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1319 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1320 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1321 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1324 static const uint8_t ms_hmac_digest2[] = {
1325 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1326 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1327 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1328 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1329 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1330 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1331 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1332 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1339 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1341 struct crypto_testsuite_params *ts_params = &testsuite_params;
1342 struct crypto_unittest_params *ut_params = &unittest_params;
1344 /* Generate test mbuf data and space for digest */
1345 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1346 catch_22_quote, QUOTE_512_BYTES, 0);
1348 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1349 DIGEST_BYTE_LENGTH_SHA1);
1350 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1352 /* Setup Cipher Parameters */
1353 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1354 ut_params->cipher_xform.next = &ut_params->auth_xform;
1356 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1357 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1358 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1359 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1360 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1361 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1363 /* Setup HMAC Parameters */
1364 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1366 ut_params->auth_xform.next = NULL;
1368 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1369 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1370 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1371 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1372 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1374 ut_params->sess = rte_cryptodev_sym_session_create(
1375 ts_params->session_mpool);
1377 /* Create crypto session*/
1378 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1379 ut_params->sess, &ut_params->cipher_xform,
1380 ts_params->session_priv_mpool);
1381 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1383 /* Generate crypto op data structure */
1384 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1385 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1386 TEST_ASSERT_NOT_NULL(ut_params->op,
1387 "Failed to allocate symmetric crypto operation struct");
1389 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1391 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1393 /* set crypto operation source mbuf */
1394 sym_op->m_src = ut_params->ibuf;
1396 /* Set crypto operation authentication parameters */
1397 sym_op->auth.digest.data = ut_params->digest;
1398 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1399 ut_params->ibuf, QUOTE_512_BYTES);
1401 sym_op->auth.data.offset = 0;
1402 sym_op->auth.data.length = QUOTE_512_BYTES;
1404 /* Copy IV at the end of the crypto operation */
1405 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1406 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1408 /* Set crypto operation cipher parameters */
1409 sym_op->cipher.data.offset = 0;
1410 sym_op->cipher.data.length = QUOTE_512_BYTES;
1412 /* Process crypto operation */
1413 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1414 ut_params->op), "failed to process sym crypto op");
1416 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1417 "crypto op processing failed");
1420 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1423 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1424 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1426 "ciphertext data not as expected");
1428 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1430 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1431 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1432 gbl_driver_id == rte_cryptodev_driver_id_get(
1433 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1434 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1435 DIGEST_BYTE_LENGTH_SHA1,
1436 "Generated digest data not as expected");
1438 return TEST_SUCCESS;
1441 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1443 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1445 static uint8_t hmac_sha512_key[] = {
1446 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1447 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1448 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1449 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1450 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1451 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1452 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1453 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1455 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1456 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1457 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1458 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1459 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1460 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1461 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1462 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1463 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1468 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1469 struct crypto_unittest_params *ut_params,
1470 uint8_t *cipher_key,
1474 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1475 struct crypto_unittest_params *ut_params,
1476 struct crypto_testsuite_params *ts_params,
1477 const uint8_t *cipher,
1478 const uint8_t *digest,
1483 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1484 struct crypto_unittest_params *ut_params,
1485 uint8_t *cipher_key,
1489 /* Setup Cipher Parameters */
1490 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1491 ut_params->cipher_xform.next = NULL;
1493 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1494 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1495 ut_params->cipher_xform.cipher.key.data = cipher_key;
1496 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1497 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1498 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1500 /* Setup HMAC Parameters */
1501 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1502 ut_params->auth_xform.next = &ut_params->cipher_xform;
1504 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1505 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1506 ut_params->auth_xform.auth.key.data = hmac_key;
1507 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1508 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1510 return TEST_SUCCESS;
1515 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1516 struct crypto_unittest_params *ut_params,
1517 struct crypto_testsuite_params *ts_params,
1518 const uint8_t *cipher,
1519 const uint8_t *digest,
1522 /* Generate test mbuf data and digest */
1523 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1526 QUOTE_512_BYTES, 0);
1528 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1529 DIGEST_BYTE_LENGTH_SHA512);
1530 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1532 rte_memcpy(ut_params->digest,
1534 DIGEST_BYTE_LENGTH_SHA512);
1536 /* Generate Crypto op data structure */
1537 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1538 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1539 TEST_ASSERT_NOT_NULL(ut_params->op,
1540 "Failed to allocate symmetric crypto operation struct");
1542 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1544 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1546 /* set crypto operation source mbuf */
1547 sym_op->m_src = ut_params->ibuf;
1549 sym_op->auth.digest.data = ut_params->digest;
1550 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1551 ut_params->ibuf, QUOTE_512_BYTES);
1553 sym_op->auth.data.offset = 0;
1554 sym_op->auth.data.length = QUOTE_512_BYTES;
1556 /* Copy IV at the end of the crypto operation */
1557 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1558 iv, CIPHER_IV_LENGTH_AES_CBC);
1560 sym_op->cipher.data.offset = 0;
1561 sym_op->cipher.data.length = QUOTE_512_BYTES;
1563 /* Process crypto operation */
1564 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1565 ut_params->op), "failed to process sym crypto op");
1567 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1568 "crypto op processing failed");
1570 ut_params->obuf = ut_params->op->sym->m_src;
1573 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1574 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1577 "Plaintext data not as expected");
1580 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1581 "Digest verification failed");
1583 return TEST_SUCCESS;
1587 test_AES_cipheronly_mb_all(void)
1589 struct crypto_testsuite_params *ts_params = &testsuite_params;
1592 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1593 ts_params->op_mpool,
1594 ts_params->session_mpool, ts_params->session_priv_mpool,
1595 ts_params->valid_devs[0],
1596 rte_cryptodev_driver_id_get(
1597 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1598 BLKCIPHER_AES_CIPHERONLY_TYPE);
1600 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1602 return TEST_SUCCESS;
1606 test_AES_docsis_mb_all(void)
1608 struct crypto_testsuite_params *ts_params = &testsuite_params;
1611 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1612 ts_params->op_mpool,
1613 ts_params->session_mpool, ts_params->session_priv_mpool,
1614 ts_params->valid_devs[0],
1615 rte_cryptodev_driver_id_get(
1616 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1617 BLKCIPHER_AES_DOCSIS_TYPE);
1619 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1621 return TEST_SUCCESS;
1625 test_AES_docsis_qat_all(void)
1627 struct crypto_testsuite_params *ts_params = &testsuite_params;
1630 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1631 ts_params->op_mpool,
1632 ts_params->session_mpool, ts_params->session_priv_mpool,
1633 ts_params->valid_devs[0],
1634 rte_cryptodev_driver_id_get(
1635 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1636 BLKCIPHER_AES_DOCSIS_TYPE);
1638 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1640 return TEST_SUCCESS;
1644 test_DES_docsis_qat_all(void)
1646 struct crypto_testsuite_params *ts_params = &testsuite_params;
1649 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1650 ts_params->op_mpool,
1651 ts_params->session_mpool, ts_params->session_priv_mpool,
1652 ts_params->valid_devs[0],
1653 rte_cryptodev_driver_id_get(
1654 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1655 BLKCIPHER_DES_DOCSIS_TYPE);
1657 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1659 return TEST_SUCCESS;
1663 test_authonly_mb_all(void)
1665 struct crypto_testsuite_params *ts_params = &testsuite_params;
1668 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1669 ts_params->op_mpool,
1670 ts_params->session_mpool, ts_params->session_priv_mpool,
1671 ts_params->valid_devs[0],
1672 rte_cryptodev_driver_id_get(
1673 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1674 BLKCIPHER_AUTHONLY_TYPE);
1676 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1678 return TEST_SUCCESS;
1682 test_authonly_qat_all(void)
1684 struct crypto_testsuite_params *ts_params = &testsuite_params;
1687 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1688 ts_params->op_mpool,
1689 ts_params->session_mpool, ts_params->session_priv_mpool,
1690 ts_params->valid_devs[0],
1691 rte_cryptodev_driver_id_get(
1692 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1693 BLKCIPHER_AUTHONLY_TYPE);
1695 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1697 return TEST_SUCCESS;
1701 test_AES_chain_null_all(void)
1703 struct crypto_testsuite_params *ts_params = &testsuite_params;
1706 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1707 ts_params->op_mpool,
1708 ts_params->session_mpool, ts_params->session_priv_mpool,
1709 ts_params->valid_devs[0],
1710 rte_cryptodev_driver_id_get(
1711 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1712 BLKCIPHER_AES_CHAIN_TYPE);
1714 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1716 return TEST_SUCCESS;
1720 test_AES_cipheronly_null_all(void)
1722 struct crypto_testsuite_params *ts_params = &testsuite_params;
1725 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1726 ts_params->op_mpool,
1727 ts_params->session_mpool, ts_params->session_priv_mpool,
1728 ts_params->valid_devs[0],
1729 rte_cryptodev_driver_id_get(
1730 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1731 BLKCIPHER_AES_CIPHERONLY_TYPE);
1733 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1735 return TEST_SUCCESS;
1739 test_authonly_null_all(void)
1741 struct crypto_testsuite_params *ts_params = &testsuite_params;
1744 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1745 ts_params->op_mpool,
1746 ts_params->session_mpool, ts_params->session_priv_mpool,
1747 ts_params->valid_devs[0],
1748 rte_cryptodev_driver_id_get(
1749 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1750 BLKCIPHER_AUTHONLY_TYPE);
1752 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1754 return TEST_SUCCESS;
1758 test_AES_chain_mb_all(void)
1760 struct crypto_testsuite_params *ts_params = &testsuite_params;
1763 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764 ts_params->op_mpool,
1765 ts_params->session_mpool, ts_params->session_priv_mpool,
1766 ts_params->valid_devs[0],
1767 rte_cryptodev_driver_id_get(
1768 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1769 BLKCIPHER_AES_CHAIN_TYPE);
1771 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1773 return TEST_SUCCESS;
1776 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1779 test_AES_cipheronly_scheduler_all(void)
1781 struct crypto_testsuite_params *ts_params = &testsuite_params;
1784 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1785 ts_params->op_mpool,
1786 ts_params->session_mpool, ts_params->session_priv_mpool,
1787 ts_params->valid_devs[0],
1788 rte_cryptodev_driver_id_get(
1789 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1790 BLKCIPHER_AES_CIPHERONLY_TYPE);
1792 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1794 return TEST_SUCCESS;
1798 test_AES_chain_scheduler_all(void)
1800 struct crypto_testsuite_params *ts_params = &testsuite_params;
1803 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1804 ts_params->op_mpool,
1805 ts_params->session_mpool, ts_params->session_priv_mpool,
1806 ts_params->valid_devs[0],
1807 rte_cryptodev_driver_id_get(
1808 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1809 BLKCIPHER_AES_CHAIN_TYPE);
1811 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1813 return TEST_SUCCESS;
1817 test_authonly_scheduler_all(void)
1819 struct crypto_testsuite_params *ts_params = &testsuite_params;
1822 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1823 ts_params->op_mpool,
1824 ts_params->session_mpool, ts_params->session_priv_mpool,
1825 ts_params->valid_devs[0],
1826 rte_cryptodev_driver_id_get(
1827 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1828 BLKCIPHER_AUTHONLY_TYPE);
1830 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1832 return TEST_SUCCESS;
1835 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1838 test_AES_chain_openssl_all(void)
1840 struct crypto_testsuite_params *ts_params = &testsuite_params;
1843 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1844 ts_params->op_mpool,
1845 ts_params->session_mpool, ts_params->session_priv_mpool,
1846 ts_params->valid_devs[0],
1847 rte_cryptodev_driver_id_get(
1848 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1849 BLKCIPHER_AES_CHAIN_TYPE);
1851 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1853 return TEST_SUCCESS;
1857 test_AES_cipheronly_openssl_all(void)
1859 struct crypto_testsuite_params *ts_params = &testsuite_params;
1862 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1863 ts_params->op_mpool,
1864 ts_params->session_mpool, ts_params->session_priv_mpool,
1865 ts_params->valid_devs[0],
1866 rte_cryptodev_driver_id_get(
1867 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1868 BLKCIPHER_AES_CIPHERONLY_TYPE);
1870 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1872 return TEST_SUCCESS;
1876 test_AES_chain_ccp_all(void)
1878 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1882 ts_params->op_mpool,
1883 ts_params->session_mpool, ts_params->session_priv_mpool,
1884 ts_params->valid_devs[0],
1885 rte_cryptodev_driver_id_get(
1886 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1887 BLKCIPHER_AES_CHAIN_TYPE);
1889 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1891 return TEST_SUCCESS;
1895 test_AES_cipheronly_ccp_all(void)
1897 struct crypto_testsuite_params *ts_params = &testsuite_params;
1900 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1901 ts_params->op_mpool,
1902 ts_params->session_mpool, ts_params->session_priv_mpool,
1903 ts_params->valid_devs[0],
1904 rte_cryptodev_driver_id_get(
1905 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1906 BLKCIPHER_AES_CIPHERONLY_TYPE);
1908 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1910 return TEST_SUCCESS;
1914 test_AES_chain_qat_all(void)
1916 struct crypto_testsuite_params *ts_params = &testsuite_params;
1919 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1920 ts_params->op_mpool,
1921 ts_params->session_mpool, ts_params->session_priv_mpool,
1922 ts_params->valid_devs[0],
1923 rte_cryptodev_driver_id_get(
1924 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1925 BLKCIPHER_AES_CHAIN_TYPE);
1927 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1929 return TEST_SUCCESS;
1933 test_AES_cipheronly_qat_all(void)
1935 struct crypto_testsuite_params *ts_params = &testsuite_params;
1938 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1939 ts_params->op_mpool,
1940 ts_params->session_mpool, ts_params->session_priv_mpool,
1941 ts_params->valid_devs[0],
1942 rte_cryptodev_driver_id_get(
1943 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1944 BLKCIPHER_AES_CIPHERONLY_TYPE);
1946 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1948 return TEST_SUCCESS;
1952 test_AES_cipheronly_virtio_all(void)
1954 struct crypto_testsuite_params *ts_params = &testsuite_params;
1957 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1958 ts_params->op_mpool,
1959 ts_params->session_mpool, ts_params->session_priv_mpool,
1960 ts_params->valid_devs[0],
1961 rte_cryptodev_driver_id_get(
1962 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1963 BLKCIPHER_AES_CIPHERONLY_TYPE);
1965 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1967 return TEST_SUCCESS;
1971 test_AES_chain_caam_jr_all(void)
1973 struct crypto_testsuite_params *ts_params = &testsuite_params;
1976 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1977 ts_params->op_mpool,
1978 ts_params->session_mpool, ts_params->session_priv_mpool,
1979 ts_params->valid_devs[0],
1980 rte_cryptodev_driver_id_get(
1981 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1982 BLKCIPHER_AES_CHAIN_TYPE);
1984 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1986 return TEST_SUCCESS;
1990 test_AES_cipheronly_caam_jr_all(void)
1992 struct crypto_testsuite_params *ts_params = &testsuite_params;
1995 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1996 ts_params->op_mpool,
1997 ts_params->session_mpool, ts_params->session_priv_mpool,
1998 ts_params->valid_devs[0],
1999 rte_cryptodev_driver_id_get(
2000 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2001 BLKCIPHER_AES_CIPHERONLY_TYPE);
2003 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2005 return TEST_SUCCESS;
2009 test_authonly_caam_jr_all(void)
2011 struct crypto_testsuite_params *ts_params = &testsuite_params;
2014 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2015 ts_params->op_mpool,
2016 ts_params->session_mpool, ts_params->session_priv_mpool,
2017 ts_params->valid_devs[0],
2018 rte_cryptodev_driver_id_get(
2019 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2020 BLKCIPHER_AUTHONLY_TYPE);
2022 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2024 return TEST_SUCCESS;
2029 test_AES_chain_dpaa_sec_all(void)
2031 struct crypto_testsuite_params *ts_params = &testsuite_params;
2034 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2035 ts_params->op_mpool,
2036 ts_params->session_mpool, ts_params->session_priv_mpool,
2037 ts_params->valid_devs[0],
2038 rte_cryptodev_driver_id_get(
2039 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2040 BLKCIPHER_AES_CHAIN_TYPE);
2042 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2044 return TEST_SUCCESS;
2048 test_AES_cipheronly_dpaa_sec_all(void)
2050 struct crypto_testsuite_params *ts_params = &testsuite_params;
2053 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2054 ts_params->op_mpool,
2055 ts_params->session_mpool, ts_params->session_priv_mpool,
2056 ts_params->valid_devs[0],
2057 rte_cryptodev_driver_id_get(
2058 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2059 BLKCIPHER_AES_CIPHERONLY_TYPE);
2061 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2063 return TEST_SUCCESS;
2067 test_authonly_dpaa_sec_all(void)
2069 struct crypto_testsuite_params *ts_params = &testsuite_params;
2072 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2073 ts_params->op_mpool,
2074 ts_params->session_mpool, ts_params->session_priv_mpool,
2075 ts_params->valid_devs[0],
2076 rte_cryptodev_driver_id_get(
2077 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2078 BLKCIPHER_AUTHONLY_TYPE);
2080 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2082 return TEST_SUCCESS;
2086 test_AES_chain_dpaa2_sec_all(void)
2088 struct crypto_testsuite_params *ts_params = &testsuite_params;
2091 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2092 ts_params->op_mpool,
2093 ts_params->session_mpool, ts_params->session_priv_mpool,
2094 ts_params->valid_devs[0],
2095 rte_cryptodev_driver_id_get(
2096 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2097 BLKCIPHER_AES_CHAIN_TYPE);
2099 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2101 return TEST_SUCCESS;
2105 test_AES_cipheronly_dpaa2_sec_all(void)
2107 struct crypto_testsuite_params *ts_params = &testsuite_params;
2110 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2111 ts_params->op_mpool,
2112 ts_params->session_mpool, ts_params->session_priv_mpool,
2113 ts_params->valid_devs[0],
2114 rte_cryptodev_driver_id_get(
2115 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2116 BLKCIPHER_AES_CIPHERONLY_TYPE);
2118 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2120 return TEST_SUCCESS;
2124 test_authonly_dpaa2_sec_all(void)
2126 struct crypto_testsuite_params *ts_params = &testsuite_params;
2129 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2130 ts_params->op_mpool,
2131 ts_params->session_mpool, ts_params->session_priv_mpool,
2132 ts_params->valid_devs[0],
2133 rte_cryptodev_driver_id_get(
2134 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2135 BLKCIPHER_AUTHONLY_TYPE);
2137 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2139 return TEST_SUCCESS;
2143 test_authonly_openssl_all(void)
2145 struct crypto_testsuite_params *ts_params = &testsuite_params;
2148 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2149 ts_params->op_mpool,
2150 ts_params->session_mpool, ts_params->session_priv_mpool,
2151 ts_params->valid_devs[0],
2152 rte_cryptodev_driver_id_get(
2153 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2154 BLKCIPHER_AUTHONLY_TYPE);
2156 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2158 return TEST_SUCCESS;
2162 test_authonly_ccp_all(void)
2164 struct crypto_testsuite_params *ts_params = &testsuite_params;
2167 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2168 ts_params->op_mpool,
2169 ts_params->session_mpool, ts_params->session_priv_mpool,
2170 ts_params->valid_devs[0],
2171 rte_cryptodev_driver_id_get(
2172 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2173 BLKCIPHER_AUTHONLY_TYPE);
2175 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2177 return TEST_SUCCESS;
2181 test_AES_chain_armv8_all(void)
2183 struct crypto_testsuite_params *ts_params = &testsuite_params;
2186 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2187 ts_params->op_mpool,
2188 ts_params->session_mpool, ts_params->session_priv_mpool,
2189 ts_params->valid_devs[0],
2190 rte_cryptodev_driver_id_get(
2191 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2192 BLKCIPHER_AES_CHAIN_TYPE);
2194 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2196 return TEST_SUCCESS;
2200 test_AES_chain_mrvl_all(void)
2202 struct crypto_testsuite_params *ts_params = &testsuite_params;
2205 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2206 ts_params->op_mpool,
2207 ts_params->session_mpool, ts_params->session_priv_mpool,
2208 ts_params->valid_devs[0],
2209 rte_cryptodev_driver_id_get(
2210 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2211 BLKCIPHER_AES_CHAIN_TYPE);
2213 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2215 return TEST_SUCCESS;
2219 test_AES_cipheronly_mrvl_all(void)
2221 struct crypto_testsuite_params *ts_params = &testsuite_params;
2224 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2225 ts_params->op_mpool,
2226 ts_params->session_mpool, ts_params->session_priv_mpool,
2227 ts_params->valid_devs[0],
2228 rte_cryptodev_driver_id_get(
2229 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2230 BLKCIPHER_AES_CIPHERONLY_TYPE);
2232 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2234 return TEST_SUCCESS;
2238 test_authonly_mrvl_all(void)
2240 struct crypto_testsuite_params *ts_params = &testsuite_params;
2243 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2244 ts_params->op_mpool,
2245 ts_params->session_mpool, ts_params->session_priv_mpool,
2246 ts_params->valid_devs[0],
2247 rte_cryptodev_driver_id_get(
2248 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2249 BLKCIPHER_AUTHONLY_TYPE);
2251 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2253 return TEST_SUCCESS;
2257 test_3DES_chain_mrvl_all(void)
2259 struct crypto_testsuite_params *ts_params = &testsuite_params;
2262 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2263 ts_params->op_mpool,
2264 ts_params->session_mpool, ts_params->session_priv_mpool,
2265 ts_params->valid_devs[0],
2266 rte_cryptodev_driver_id_get(
2267 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2268 BLKCIPHER_3DES_CHAIN_TYPE);
2270 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2272 return TEST_SUCCESS;
2276 test_3DES_cipheronly_mrvl_all(void)
2278 struct crypto_testsuite_params *ts_params = &testsuite_params;
2281 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2282 ts_params->op_mpool,
2283 ts_params->session_mpool, ts_params->session_priv_mpool,
2284 ts_params->valid_devs[0],
2285 rte_cryptodev_driver_id_get(
2286 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2287 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2289 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2291 return TEST_SUCCESS;
2295 test_AES_chain_octeontx_all(void)
2297 struct crypto_testsuite_params *ts_params = &testsuite_params;
2300 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2301 ts_params->op_mpool, ts_params->session_mpool,
2302 ts_params->session_priv_mpool,
2303 ts_params->valid_devs[0],
2304 rte_cryptodev_driver_id_get(
2305 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2306 BLKCIPHER_AES_CHAIN_TYPE);
2308 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2310 return TEST_SUCCESS;
2314 test_AES_cipheronly_octeontx_all(void)
2316 struct crypto_testsuite_params *ts_params = &testsuite_params;
2319 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2320 ts_params->op_mpool, ts_params->session_mpool,
2321 ts_params->session_priv_mpool,
2322 ts_params->valid_devs[0],
2323 rte_cryptodev_driver_id_get(
2324 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2325 BLKCIPHER_AES_CIPHERONLY_TYPE);
2327 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2329 return TEST_SUCCESS;
2333 test_3DES_chain_octeontx_all(void)
2335 struct crypto_testsuite_params *ts_params = &testsuite_params;
2338 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2339 ts_params->op_mpool, ts_params->session_mpool,
2340 ts_params->session_priv_mpool,
2341 ts_params->valid_devs[0],
2342 rte_cryptodev_driver_id_get(
2343 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2344 BLKCIPHER_3DES_CHAIN_TYPE);
2346 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2348 return TEST_SUCCESS;
2352 test_AES_chain_nitrox_all(void)
2354 struct crypto_testsuite_params *ts_params = &testsuite_params;
2357 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2358 ts_params->op_mpool,
2359 ts_params->session_mpool, ts_params->session_priv_mpool,
2360 ts_params->valid_devs[0],
2361 rte_cryptodev_driver_id_get(
2362 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2363 BLKCIPHER_AES_CHAIN_TYPE);
2365 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2367 return TEST_SUCCESS;
2371 test_3DES_cipheronly_octeontx_all(void)
2373 struct crypto_testsuite_params *ts_params = &testsuite_params;
2376 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2377 ts_params->op_mpool, ts_params->session_mpool,
2378 ts_params->session_priv_mpool,
2379 ts_params->valid_devs[0],
2380 rte_cryptodev_driver_id_get(
2381 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2382 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2384 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2386 return TEST_SUCCESS;
2390 test_authonly_octeontx_all(void)
2392 struct crypto_testsuite_params *ts_params = &testsuite_params;
2395 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2396 ts_params->op_mpool, ts_params->session_mpool,
2397 ts_params->session_priv_mpool,
2398 ts_params->valid_devs[0],
2399 rte_cryptodev_driver_id_get(
2400 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2401 BLKCIPHER_AUTHONLY_TYPE);
2403 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2405 return TEST_SUCCESS;
2409 test_AES_chain_octeontx2_all(void)
2411 struct crypto_testsuite_params *ts_params = &testsuite_params;
2414 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2415 ts_params->op_mpool, ts_params->session_mpool,
2416 ts_params->session_priv_mpool,
2417 ts_params->valid_devs[0],
2418 rte_cryptodev_driver_id_get(
2419 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2420 BLKCIPHER_AES_CHAIN_TYPE);
2422 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2424 return TEST_SUCCESS;
2428 test_AES_cipheronly_octeontx2_all(void)
2430 struct crypto_testsuite_params *ts_params = &testsuite_params;
2433 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2434 ts_params->op_mpool, ts_params->session_mpool,
2435 ts_params->session_priv_mpool,
2436 ts_params->valid_devs[0],
2437 rte_cryptodev_driver_id_get(
2438 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2439 BLKCIPHER_AES_CIPHERONLY_TYPE);
2441 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2443 return TEST_SUCCESS;
2447 test_3DES_chain_octeontx2_all(void)
2449 struct crypto_testsuite_params *ts_params = &testsuite_params;
2452 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2453 ts_params->op_mpool, ts_params->session_mpool,
2454 ts_params->session_priv_mpool,
2455 ts_params->valid_devs[0],
2456 rte_cryptodev_driver_id_get(
2457 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2458 BLKCIPHER_3DES_CHAIN_TYPE);
2460 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2462 return TEST_SUCCESS;
2466 test_3DES_cipheronly_octeontx2_all(void)
2468 struct crypto_testsuite_params *ts_params = &testsuite_params;
2471 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2472 ts_params->op_mpool, ts_params->session_mpool,
2473 ts_params->session_priv_mpool,
2474 ts_params->valid_devs[0],
2475 rte_cryptodev_driver_id_get(
2476 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2477 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2479 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2481 return TEST_SUCCESS;
2485 test_authonly_octeontx2_all(void)
2487 struct crypto_testsuite_params *ts_params = &testsuite_params;
2490 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2491 ts_params->op_mpool, ts_params->session_mpool,
2492 ts_params->session_priv_mpool,
2493 ts_params->valid_devs[0],
2494 rte_cryptodev_driver_id_get(
2495 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2496 BLKCIPHER_AUTHONLY_TYPE);
2498 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2500 return TEST_SUCCESS;
2503 /* ***** SNOW 3G Tests ***** */
2505 create_wireless_algo_hash_session(uint8_t dev_id,
2506 const uint8_t *key, const uint8_t key_len,
2507 const uint8_t iv_len, const uint8_t auth_len,
2508 enum rte_crypto_auth_operation op,
2509 enum rte_crypto_auth_algorithm algo)
2511 uint8_t hash_key[key_len];
2514 struct crypto_testsuite_params *ts_params = &testsuite_params;
2515 struct crypto_unittest_params *ut_params = &unittest_params;
2517 memcpy(hash_key, key, key_len);
2519 debug_hexdump(stdout, "key:", key, key_len);
2521 /* Setup Authentication Parameters */
2522 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2523 ut_params->auth_xform.next = NULL;
2525 ut_params->auth_xform.auth.op = op;
2526 ut_params->auth_xform.auth.algo = algo;
2527 ut_params->auth_xform.auth.key.length = key_len;
2528 ut_params->auth_xform.auth.key.data = hash_key;
2529 ut_params->auth_xform.auth.digest_length = auth_len;
2530 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2531 ut_params->auth_xform.auth.iv.length = iv_len;
2532 ut_params->sess = rte_cryptodev_sym_session_create(
2533 ts_params->session_mpool);
2535 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2536 &ut_params->auth_xform,
2537 ts_params->session_priv_mpool);
2538 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2539 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2544 create_wireless_algo_cipher_session(uint8_t dev_id,
2545 enum rte_crypto_cipher_operation op,
2546 enum rte_crypto_cipher_algorithm algo,
2547 const uint8_t *key, const uint8_t key_len,
2550 uint8_t cipher_key[key_len];
2552 struct crypto_testsuite_params *ts_params = &testsuite_params;
2553 struct crypto_unittest_params *ut_params = &unittest_params;
2555 memcpy(cipher_key, key, key_len);
2557 /* Setup Cipher Parameters */
2558 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2559 ut_params->cipher_xform.next = NULL;
2561 ut_params->cipher_xform.cipher.algo = algo;
2562 ut_params->cipher_xform.cipher.op = op;
2563 ut_params->cipher_xform.cipher.key.data = cipher_key;
2564 ut_params->cipher_xform.cipher.key.length = key_len;
2565 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2566 ut_params->cipher_xform.cipher.iv.length = iv_len;
2568 debug_hexdump(stdout, "key:", key, key_len);
2570 /* Create Crypto session */
2571 ut_params->sess = rte_cryptodev_sym_session_create(
2572 ts_params->session_mpool);
2574 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2575 &ut_params->cipher_xform,
2576 ts_params->session_priv_mpool);
2577 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2578 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2583 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2584 unsigned int cipher_len,
2585 unsigned int cipher_offset)
2587 struct crypto_testsuite_params *ts_params = &testsuite_params;
2588 struct crypto_unittest_params *ut_params = &unittest_params;
2590 /* Generate Crypto op data structure */
2591 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2592 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2593 TEST_ASSERT_NOT_NULL(ut_params->op,
2594 "Failed to allocate pktmbuf offload");
2596 /* Set crypto operation data parameters */
2597 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2599 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2601 /* set crypto operation source mbuf */
2602 sym_op->m_src = ut_params->ibuf;
2605 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2607 sym_op->cipher.data.length = cipher_len;
2608 sym_op->cipher.data.offset = cipher_offset;
2613 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2614 unsigned int cipher_len,
2615 unsigned int cipher_offset)
2617 struct crypto_testsuite_params *ts_params = &testsuite_params;
2618 struct crypto_unittest_params *ut_params = &unittest_params;
2620 /* Generate Crypto op data structure */
2621 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2622 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2623 TEST_ASSERT_NOT_NULL(ut_params->op,
2624 "Failed to allocate pktmbuf offload");
2626 /* Set crypto operation data parameters */
2627 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2629 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2631 /* set crypto operation source mbuf */
2632 sym_op->m_src = ut_params->ibuf;
2633 sym_op->m_dst = ut_params->obuf;
2636 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2638 sym_op->cipher.data.length = cipher_len;
2639 sym_op->cipher.data.offset = cipher_offset;
2644 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2645 enum rte_crypto_cipher_operation cipher_op,
2646 enum rte_crypto_auth_operation auth_op,
2647 enum rte_crypto_auth_algorithm auth_algo,
2648 enum rte_crypto_cipher_algorithm cipher_algo,
2649 const uint8_t *key, uint8_t key_len,
2650 uint8_t auth_iv_len, uint8_t auth_len,
2651 uint8_t cipher_iv_len)
2654 uint8_t cipher_auth_key[key_len];
2657 struct crypto_testsuite_params *ts_params = &testsuite_params;
2658 struct crypto_unittest_params *ut_params = &unittest_params;
2660 memcpy(cipher_auth_key, key, key_len);
2662 /* Setup Authentication Parameters */
2663 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2664 ut_params->auth_xform.next = NULL;
2666 ut_params->auth_xform.auth.op = auth_op;
2667 ut_params->auth_xform.auth.algo = auth_algo;
2668 ut_params->auth_xform.auth.key.length = key_len;
2669 /* Hash key = cipher key */
2670 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2671 ut_params->auth_xform.auth.digest_length = auth_len;
2672 /* Auth IV will be after cipher IV */
2673 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2674 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2676 /* Setup Cipher Parameters */
2677 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2678 ut_params->cipher_xform.next = &ut_params->auth_xform;
2680 ut_params->cipher_xform.cipher.algo = cipher_algo;
2681 ut_params->cipher_xform.cipher.op = cipher_op;
2682 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2683 ut_params->cipher_xform.cipher.key.length = key_len;
2684 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2685 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2687 debug_hexdump(stdout, "key:", key, key_len);
2689 /* Create Crypto session*/
2690 ut_params->sess = rte_cryptodev_sym_session_create(
2691 ts_params->session_mpool);
2693 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2694 &ut_params->cipher_xform,
2695 ts_params->session_priv_mpool);
2697 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2698 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2703 create_wireless_cipher_auth_session(uint8_t dev_id,
2704 enum rte_crypto_cipher_operation cipher_op,
2705 enum rte_crypto_auth_operation auth_op,
2706 enum rte_crypto_auth_algorithm auth_algo,
2707 enum rte_crypto_cipher_algorithm cipher_algo,
2708 const struct wireless_test_data *tdata)
2710 const uint8_t key_len = tdata->key.len;
2711 uint8_t cipher_auth_key[key_len];
2714 struct crypto_testsuite_params *ts_params = &testsuite_params;
2715 struct crypto_unittest_params *ut_params = &unittest_params;
2716 const uint8_t *key = tdata->key.data;
2717 const uint8_t auth_len = tdata->digest.len;
2718 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2719 uint8_t auth_iv_len = tdata->auth_iv.len;
2721 memcpy(cipher_auth_key, key, key_len);
2723 /* Setup Authentication Parameters */
2724 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2725 ut_params->auth_xform.next = NULL;
2727 ut_params->auth_xform.auth.op = auth_op;
2728 ut_params->auth_xform.auth.algo = auth_algo;
2729 ut_params->auth_xform.auth.key.length = key_len;
2730 /* Hash key = cipher key */
2731 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2732 ut_params->auth_xform.auth.digest_length = auth_len;
2733 /* Auth IV will be after cipher IV */
2734 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2735 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2737 /* Setup Cipher Parameters */
2738 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2739 ut_params->cipher_xform.next = &ut_params->auth_xform;
2741 ut_params->cipher_xform.cipher.algo = cipher_algo;
2742 ut_params->cipher_xform.cipher.op = cipher_op;
2743 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2744 ut_params->cipher_xform.cipher.key.length = key_len;
2745 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2746 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2749 debug_hexdump(stdout, "key:", key, key_len);
2751 /* Create Crypto session*/
2752 ut_params->sess = rte_cryptodev_sym_session_create(
2753 ts_params->session_mpool);
2755 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2756 &ut_params->cipher_xform,
2757 ts_params->session_priv_mpool);
2759 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2760 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2765 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2766 const struct wireless_test_data *tdata)
2768 return create_wireless_cipher_auth_session(dev_id,
2769 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2770 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2771 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2775 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2776 enum rte_crypto_cipher_operation cipher_op,
2777 enum rte_crypto_auth_operation auth_op,
2778 enum rte_crypto_auth_algorithm auth_algo,
2779 enum rte_crypto_cipher_algorithm cipher_algo,
2780 const uint8_t *key, const uint8_t key_len,
2781 uint8_t auth_iv_len, uint8_t auth_len,
2782 uint8_t cipher_iv_len)
2784 uint8_t auth_cipher_key[key_len];
2786 struct crypto_testsuite_params *ts_params = &testsuite_params;
2787 struct crypto_unittest_params *ut_params = &unittest_params;
2789 memcpy(auth_cipher_key, key, key_len);
2791 /* Setup Authentication Parameters */
2792 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2793 ut_params->auth_xform.auth.op = auth_op;
2794 ut_params->auth_xform.next = &ut_params->cipher_xform;
2795 ut_params->auth_xform.auth.algo = auth_algo;
2796 ut_params->auth_xform.auth.key.length = key_len;
2797 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2798 ut_params->auth_xform.auth.digest_length = auth_len;
2799 /* Auth IV will be after cipher IV */
2800 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2801 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2803 /* Setup Cipher Parameters */
2804 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2805 ut_params->cipher_xform.next = NULL;
2806 ut_params->cipher_xform.cipher.algo = cipher_algo;
2807 ut_params->cipher_xform.cipher.op = cipher_op;
2808 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2809 ut_params->cipher_xform.cipher.key.length = key_len;
2810 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2811 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2813 debug_hexdump(stdout, "key:", key, key_len);
2815 /* Create Crypto session*/
2816 ut_params->sess = rte_cryptodev_sym_session_create(
2817 ts_params->session_mpool);
2819 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2820 &ut_params->auth_xform,
2821 ts_params->session_priv_mpool);
2822 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2823 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2829 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2830 unsigned int auth_tag_len,
2831 const uint8_t *iv, unsigned int iv_len,
2832 unsigned int data_pad_len,
2833 enum rte_crypto_auth_operation op,
2834 unsigned int auth_len, unsigned int auth_offset)
2836 struct crypto_testsuite_params *ts_params = &testsuite_params;
2838 struct crypto_unittest_params *ut_params = &unittest_params;
2840 /* Generate Crypto op data structure */
2841 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2842 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2843 TEST_ASSERT_NOT_NULL(ut_params->op,
2844 "Failed to allocate pktmbuf offload");
2846 /* Set crypto operation data parameters */
2847 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2849 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2851 /* set crypto operation source mbuf */
2852 sym_op->m_src = ut_params->ibuf;
2855 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2858 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2859 ut_params->ibuf, auth_tag_len);
2861 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2862 "no room to append auth tag");
2863 ut_params->digest = sym_op->auth.digest.data;
2864 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2865 ut_params->ibuf, data_pad_len);
2866 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2867 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2869 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2871 debug_hexdump(stdout, "digest:",
2872 sym_op->auth.digest.data,
2875 sym_op->auth.data.length = auth_len;
2876 sym_op->auth.data.offset = auth_offset;
2882 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2883 enum rte_crypto_auth_operation op)
2885 struct crypto_testsuite_params *ts_params = &testsuite_params;
2886 struct crypto_unittest_params *ut_params = &unittest_params;
2888 const uint8_t *auth_tag = tdata->digest.data;
2889 const unsigned int auth_tag_len = tdata->digest.len;
2890 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2891 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2893 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2894 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2895 const uint8_t *auth_iv = tdata->auth_iv.data;
2896 const uint8_t auth_iv_len = tdata->auth_iv.len;
2897 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2898 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2900 /* Generate Crypto op data structure */
2901 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2902 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2903 TEST_ASSERT_NOT_NULL(ut_params->op,
2904 "Failed to allocate pktmbuf offload");
2905 /* Set crypto operation data parameters */
2906 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2908 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2910 /* set crypto operation source mbuf */
2911 sym_op->m_src = ut_params->ibuf;
2914 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2915 ut_params->ibuf, auth_tag_len);
2917 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2918 "no room to append auth tag");
2919 ut_params->digest = sym_op->auth.digest.data;
2920 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2921 ut_params->ibuf, data_pad_len);
2922 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2923 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2925 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2927 debug_hexdump(stdout, "digest:",
2928 sym_op->auth.digest.data,
2931 /* Copy cipher and auth IVs at the end of the crypto operation */
2932 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2934 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2935 iv_ptr += cipher_iv_len;
2936 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2938 sym_op->cipher.data.length = cipher_len;
2939 sym_op->cipher.data.offset = 0;
2940 sym_op->auth.data.length = auth_len;
2941 sym_op->auth.data.offset = 0;
2947 create_zuc_cipher_hash_generate_operation(
2948 const struct wireless_test_data *tdata)
2950 return create_wireless_cipher_hash_operation(tdata,
2951 RTE_CRYPTO_AUTH_OP_GENERATE);
2955 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2956 const unsigned auth_tag_len,
2957 const uint8_t *auth_iv, uint8_t auth_iv_len,
2958 unsigned data_pad_len,
2959 enum rte_crypto_auth_operation op,
2960 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2961 const unsigned cipher_len, const unsigned cipher_offset,
2962 const unsigned auth_len, const unsigned auth_offset)
2964 struct crypto_testsuite_params *ts_params = &testsuite_params;
2965 struct crypto_unittest_params *ut_params = &unittest_params;
2967 /* Generate Crypto op data structure */
2968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2970 TEST_ASSERT_NOT_NULL(ut_params->op,
2971 "Failed to allocate pktmbuf offload");
2972 /* Set crypto operation data parameters */
2973 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2975 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2977 /* set crypto operation source mbuf */
2978 sym_op->m_src = ut_params->ibuf;
2981 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2982 ut_params->ibuf, auth_tag_len);
2984 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2985 "no room to append auth tag");
2986 ut_params->digest = sym_op->auth.digest.data;
2987 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2988 ut_params->ibuf, data_pad_len);
2989 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2990 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2992 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2994 debug_hexdump(stdout, "digest:",
2995 sym_op->auth.digest.data,
2998 /* Copy cipher and auth IVs at the end of the crypto operation */
2999 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3001 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3002 iv_ptr += cipher_iv_len;
3003 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3005 sym_op->cipher.data.length = cipher_len;
3006 sym_op->cipher.data.offset = cipher_offset;
3007 sym_op->auth.data.length = auth_len;
3008 sym_op->auth.data.offset = auth_offset;
3014 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
3015 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3016 const uint8_t *auth_iv, uint8_t auth_iv_len,
3017 unsigned int data_pad_len,
3018 unsigned int cipher_len, unsigned int cipher_offset,
3019 unsigned int auth_len, unsigned int auth_offset,
3020 uint8_t op_mode, uint8_t do_sgl)
3022 struct crypto_testsuite_params *ts_params = &testsuite_params;
3023 struct crypto_unittest_params *ut_params = &unittest_params;
3025 enum rte_crypto_cipher_algorithm cipher_algo =
3026 ut_params->cipher_xform.cipher.algo;
3027 enum rte_crypto_auth_algorithm auth_algo =
3028 ut_params->auth_xform.auth.algo;
3030 /* Generate Crypto op data structure */
3031 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3032 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3033 TEST_ASSERT_NOT_NULL(ut_params->op,
3034 "Failed to allocate pktmbuf offload");
3036 /* Set crypto operation data parameters */
3037 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3039 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3041 /* set crypto operation mbufs */
3042 sym_op->m_src = ut_params->ibuf;
3043 if (op_mode == OUT_OF_PLACE)
3044 sym_op->m_dst = ut_params->obuf;
3048 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3049 (op_mode == IN_PLACE ?
3050 ut_params->ibuf : ut_params->obuf),
3051 uint8_t *, data_pad_len);
3052 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3053 (op_mode == IN_PLACE ?
3054 ut_params->ibuf : ut_params->obuf),
3056 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3058 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3059 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3060 sym_op->m_src : sym_op->m_dst);
3061 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3062 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3063 sgl_buf = sgl_buf->next;
3065 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3066 uint8_t *, remaining_off);
3067 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3069 memset(sym_op->auth.digest.data, 0, remaining_off);
3070 while (sgl_buf->next != NULL) {
3071 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3072 0, rte_pktmbuf_data_len(sgl_buf));
3073 sgl_buf = sgl_buf->next;
3077 /* Copy cipher and auth IVs at the end of the crypto operation */
3078 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3079 ut_params->op, uint8_t *, IV_OFFSET);
3081 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3082 iv_ptr += cipher_iv_len;
3083 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3085 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3086 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3087 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3088 sym_op->cipher.data.length = cipher_len;
3089 sym_op->cipher.data.offset = cipher_offset;
3091 sym_op->cipher.data.length = cipher_len >> 3;
3092 sym_op->cipher.data.offset = cipher_offset >> 3;
3095 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3096 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3097 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3098 sym_op->auth.data.length = auth_len;
3099 sym_op->auth.data.offset = auth_offset;
3101 sym_op->auth.data.length = auth_len >> 3;
3102 sym_op->auth.data.offset = auth_offset >> 3;
3109 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3111 struct crypto_testsuite_params *ts_params = &testsuite_params;
3112 struct crypto_unittest_params *ut_params = &unittest_params;
3115 unsigned plaintext_pad_len;
3116 unsigned plaintext_len;
3119 /* Create SNOW 3G session */
3120 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3121 tdata->key.data, tdata->key.len,
3122 tdata->auth_iv.len, tdata->digest.len,
3123 RTE_CRYPTO_AUTH_OP_GENERATE,
3124 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3128 /* alloc mbuf and set payload */
3129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3131 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3132 rte_pktmbuf_tailroom(ut_params->ibuf));
3134 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3135 /* Append data which is padded to a multiple of */
3136 /* the algorithms block size */
3137 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3138 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3140 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3142 /* Create SNOW 3G operation */
3143 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3144 tdata->auth_iv.data, tdata->auth_iv.len,
3145 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3146 tdata->validAuthLenInBits.len,
3151 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3153 ut_params->obuf = ut_params->op->sym->m_src;
3154 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3155 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3156 + plaintext_pad_len;
3159 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3162 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3163 "SNOW 3G Generated auth tag not as expected");
3169 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3171 struct crypto_testsuite_params *ts_params = &testsuite_params;
3172 struct crypto_unittest_params *ut_params = &unittest_params;
3175 unsigned plaintext_pad_len;
3176 unsigned plaintext_len;
3179 /* Create SNOW 3G session */
3180 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3181 tdata->key.data, tdata->key.len,
3182 tdata->auth_iv.len, tdata->digest.len,
3183 RTE_CRYPTO_AUTH_OP_VERIFY,
3184 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3187 /* alloc mbuf and set payload */
3188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3191 rte_pktmbuf_tailroom(ut_params->ibuf));
3193 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3194 /* Append data which is padded to a multiple of */
3195 /* the algorithms block size */
3196 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3197 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3199 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3201 /* Create SNOW 3G operation */
3202 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3204 tdata->auth_iv.data, tdata->auth_iv.len,
3206 RTE_CRYPTO_AUTH_OP_VERIFY,
3207 tdata->validAuthLenInBits.len,
3212 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3214 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3215 ut_params->obuf = ut_params->op->sym->m_src;
3216 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3217 + plaintext_pad_len;
3220 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3229 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3231 struct crypto_testsuite_params *ts_params = &testsuite_params;
3232 struct crypto_unittest_params *ut_params = &unittest_params;
3235 unsigned plaintext_pad_len;
3236 unsigned plaintext_len;
3239 /* Create KASUMI session */
3240 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3241 tdata->key.data, tdata->key.len,
3242 0, tdata->digest.len,
3243 RTE_CRYPTO_AUTH_OP_GENERATE,
3244 RTE_CRYPTO_AUTH_KASUMI_F9);
3248 /* alloc mbuf and set payload */
3249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3251 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3252 rte_pktmbuf_tailroom(ut_params->ibuf));
3254 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3255 /* Append data which is padded to a multiple of */
3256 /* the algorithms block size */
3257 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3262 /* Create KASUMI operation */
3263 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3265 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3266 tdata->plaintext.len,
3271 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3273 ut_params->obuf = ut_params->op->sym->m_src;
3274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3275 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3276 + plaintext_pad_len;
3279 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3282 DIGEST_BYTE_LENGTH_KASUMI_F9,
3283 "KASUMI Generated auth tag not as expected");
3289 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3291 struct crypto_testsuite_params *ts_params = &testsuite_params;
3292 struct crypto_unittest_params *ut_params = &unittest_params;
3295 unsigned plaintext_pad_len;
3296 unsigned plaintext_len;
3299 /* Create KASUMI session */
3300 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3301 tdata->key.data, tdata->key.len,
3302 0, tdata->digest.len,
3303 RTE_CRYPTO_AUTH_OP_VERIFY,
3304 RTE_CRYPTO_AUTH_KASUMI_F9);
3307 /* alloc mbuf and set payload */
3308 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3311 rte_pktmbuf_tailroom(ut_params->ibuf));
3313 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3314 /* Append data which is padded to a multiple */
3315 /* of the algorithms block size */
3316 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3317 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3319 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3321 /* Create KASUMI operation */
3322 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3326 RTE_CRYPTO_AUTH_OP_VERIFY,
3327 tdata->plaintext.len,
3332 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3334 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3335 ut_params->obuf = ut_params->op->sym->m_src;
3336 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3337 + plaintext_pad_len;
3340 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3349 test_snow3g_hash_generate_test_case_1(void)
3351 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3355 test_snow3g_hash_generate_test_case_2(void)
3357 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3361 test_snow3g_hash_generate_test_case_3(void)
3363 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3367 test_snow3g_hash_generate_test_case_4(void)
3369 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3373 test_snow3g_hash_generate_test_case_5(void)
3375 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3379 test_snow3g_hash_generate_test_case_6(void)
3381 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3385 test_snow3g_hash_verify_test_case_1(void)
3387 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3392 test_snow3g_hash_verify_test_case_2(void)
3394 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3398 test_snow3g_hash_verify_test_case_3(void)
3400 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3404 test_snow3g_hash_verify_test_case_4(void)
3406 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3410 test_snow3g_hash_verify_test_case_5(void)
3412 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3416 test_snow3g_hash_verify_test_case_6(void)
3418 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3422 test_kasumi_hash_generate_test_case_1(void)
3424 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3428 test_kasumi_hash_generate_test_case_2(void)
3430 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3434 test_kasumi_hash_generate_test_case_3(void)
3436 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3440 test_kasumi_hash_generate_test_case_4(void)
3442 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3446 test_kasumi_hash_generate_test_case_5(void)
3448 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3452 test_kasumi_hash_generate_test_case_6(void)
3454 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3458 test_kasumi_hash_verify_test_case_1(void)
3460 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3464 test_kasumi_hash_verify_test_case_2(void)
3466 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3470 test_kasumi_hash_verify_test_case_3(void)
3472 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3476 test_kasumi_hash_verify_test_case_4(void)
3478 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3482 test_kasumi_hash_verify_test_case_5(void)
3484 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3488 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3490 struct crypto_testsuite_params *ts_params = &testsuite_params;
3491 struct crypto_unittest_params *ut_params = &unittest_params;
3494 uint8_t *plaintext, *ciphertext;
3495 unsigned plaintext_pad_len;
3496 unsigned plaintext_len;
3498 /* Create KASUMI session */
3499 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3500 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3501 RTE_CRYPTO_CIPHER_KASUMI_F8,
3502 tdata->key.data, tdata->key.len,
3503 tdata->cipher_iv.len);
3507 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3509 /* Clear mbuf payload */
3510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3511 rte_pktmbuf_tailroom(ut_params->ibuf));
3513 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3514 /* Append data which is padded to a multiple */
3515 /* of the algorithms block size */
3516 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3517 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3519 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3521 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3523 /* Create KASUMI operation */
3524 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3525 tdata->cipher_iv.len,
3526 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3527 tdata->validCipherOffsetInBits.len);
3531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3533 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3535 ut_params->obuf = ut_params->op->sym->m_dst;
3536 if (ut_params->obuf)
3537 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3539 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3541 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3543 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3544 (tdata->validCipherOffsetInBits.len >> 3);
3546 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3548 reference_ciphertext,
3549 tdata->validCipherLenInBits.len,
3550 "KASUMI Ciphertext data not as expected");
3555 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3557 struct crypto_testsuite_params *ts_params = &testsuite_params;
3558 struct crypto_unittest_params *ut_params = &unittest_params;
3562 unsigned int plaintext_pad_len;
3563 unsigned int plaintext_len;
3565 uint8_t buffer[10000];
3566 const uint8_t *ciphertext;
3568 struct rte_cryptodev_info dev_info;
3570 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3572 uint64_t feat_flags = dev_info.feature_flags;
3574 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3575 printf("Device doesn't support in-place scatter-gather. "
3580 /* Create KASUMI session */
3581 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3582 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3583 RTE_CRYPTO_CIPHER_KASUMI_F8,
3584 tdata->key.data, tdata->key.len,
3585 tdata->cipher_iv.len);
3589 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3592 /* Append data which is padded to a multiple */
3593 /* of the algorithms block size */
3594 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3596 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3597 plaintext_pad_len, 10, 0);
3599 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3601 /* Create KASUMI operation */
3602 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3603 tdata->cipher_iv.len,
3604 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3605 tdata->validCipherOffsetInBits.len);
3609 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3611 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3613 ut_params->obuf = ut_params->op->sym->m_dst;
3615 if (ut_params->obuf)
3616 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3617 plaintext_len, buffer);
3619 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3620 tdata->validCipherOffsetInBits.len >> 3,
3621 plaintext_len, buffer);
3624 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3626 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3627 (tdata->validCipherOffsetInBits.len >> 3);
3629 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3631 reference_ciphertext,
3632 tdata->validCipherLenInBits.len,
3633 "KASUMI Ciphertext data not as expected");
3638 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3640 struct crypto_testsuite_params *ts_params = &testsuite_params;
3641 struct crypto_unittest_params *ut_params = &unittest_params;
3644 uint8_t *plaintext, *ciphertext;
3645 unsigned plaintext_pad_len;
3646 unsigned plaintext_len;
3648 /* Create KASUMI session */
3649 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3650 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3651 RTE_CRYPTO_CIPHER_KASUMI_F8,
3652 tdata->key.data, tdata->key.len,
3653 tdata->cipher_iv.len);
3657 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3658 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3660 /* Clear mbuf payload */
3661 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3662 rte_pktmbuf_tailroom(ut_params->ibuf));
3664 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3665 /* Append data which is padded to a multiple */
3666 /* of the algorithms block size */
3667 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3668 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3670 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3671 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3673 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3675 /* Create KASUMI operation */
3676 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3677 tdata->cipher_iv.len,
3678 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3679 tdata->validCipherOffsetInBits.len);
3683 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3685 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3687 ut_params->obuf = ut_params->op->sym->m_dst;
3688 if (ut_params->obuf)
3689 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3691 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3693 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3695 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3696 (tdata->validCipherOffsetInBits.len >> 3);
3698 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3700 reference_ciphertext,
3701 tdata->validCipherLenInBits.len,
3702 "KASUMI Ciphertext data not as expected");
3707 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3709 struct crypto_testsuite_params *ts_params = &testsuite_params;
3710 struct crypto_unittest_params *ut_params = &unittest_params;
3713 unsigned int plaintext_pad_len;
3714 unsigned int plaintext_len;
3716 const uint8_t *ciphertext;
3717 uint8_t buffer[2048];
3719 struct rte_cryptodev_info dev_info;
3721 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3723 uint64_t feat_flags = dev_info.feature_flags;
3724 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3725 printf("Device doesn't support out-of-place scatter-gather "
3726 "in both input and output mbufs. "
3731 /* Create KASUMI session */
3732 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3733 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3734 RTE_CRYPTO_CIPHER_KASUMI_F8,
3735 tdata->key.data, tdata->key.len,
3736 tdata->cipher_iv.len);
3740 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3741 /* Append data which is padded to a multiple */
3742 /* of the algorithms block size */
3743 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3745 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3746 plaintext_pad_len, 10, 0);
3747 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3748 plaintext_pad_len, 3, 0);
3750 /* Append data which is padded to a multiple */
3751 /* of the algorithms block size */
3752 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3754 /* Create KASUMI operation */
3755 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3756 tdata->cipher_iv.len,
3757 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3758 tdata->validCipherOffsetInBits.len);
3762 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3764 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3766 ut_params->obuf = ut_params->op->sym->m_dst;
3767 if (ut_params->obuf)
3768 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3769 plaintext_pad_len, buffer);
3771 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3772 tdata->validCipherOffsetInBits.len >> 3,
3773 plaintext_pad_len, buffer);
3775 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3776 (tdata->validCipherOffsetInBits.len >> 3);
3778 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3780 reference_ciphertext,
3781 tdata->validCipherLenInBits.len,
3782 "KASUMI Ciphertext data not as expected");
3788 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3790 struct crypto_testsuite_params *ts_params = &testsuite_params;
3791 struct crypto_unittest_params *ut_params = &unittest_params;
3794 uint8_t *ciphertext, *plaintext;
3795 unsigned ciphertext_pad_len;
3796 unsigned ciphertext_len;
3798 /* Create KASUMI session */
3799 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3800 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3801 RTE_CRYPTO_CIPHER_KASUMI_F8,
3802 tdata->key.data, tdata->key.len,
3803 tdata->cipher_iv.len);
3807 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3808 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3810 /* Clear mbuf payload */
3811 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3812 rte_pktmbuf_tailroom(ut_params->ibuf));
3814 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3815 /* Append data which is padded to a multiple */
3816 /* of the algorithms block size */
3817 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3818 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3819 ciphertext_pad_len);
3820 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3821 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3823 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3825 /* Create KASUMI operation */
3826 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3827 tdata->cipher_iv.len,
3828 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3829 tdata->validCipherOffsetInBits.len);
3833 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3835 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3837 ut_params->obuf = ut_params->op->sym->m_dst;
3838 if (ut_params->obuf)
3839 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3841 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3843 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3845 const uint8_t *reference_plaintext = tdata->plaintext.data +
3846 (tdata->validCipherOffsetInBits.len >> 3);
3848 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3850 reference_plaintext,
3851 tdata->validCipherLenInBits.len,
3852 "KASUMI Plaintext data not as expected");
3857 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3859 struct crypto_testsuite_params *ts_params = &testsuite_params;
3860 struct crypto_unittest_params *ut_params = &unittest_params;
3863 uint8_t *ciphertext, *plaintext;
3864 unsigned ciphertext_pad_len;
3865 unsigned ciphertext_len;
3867 /* Create KASUMI session */
3868 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3869 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3870 RTE_CRYPTO_CIPHER_KASUMI_F8,
3871 tdata->key.data, tdata->key.len,
3872 tdata->cipher_iv.len);
3876 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3878 /* Clear mbuf payload */
3879 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3880 rte_pktmbuf_tailroom(ut_params->ibuf));
3882 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3883 /* Append data which is padded to a multiple */
3884 /* of the algorithms block size */
3885 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3886 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3887 ciphertext_pad_len);
3888 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3890 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3892 /* Create KASUMI operation */
3893 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3894 tdata->cipher_iv.len,
3895 tdata->ciphertext.len,
3896 tdata->validCipherOffsetInBits.len);
3900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3902 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3904 ut_params->obuf = ut_params->op->sym->m_dst;
3905 if (ut_params->obuf)
3906 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3908 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3910 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3912 const uint8_t *reference_plaintext = tdata->plaintext.data +
3913 (tdata->validCipherOffsetInBits.len >> 3);
3915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3917 reference_plaintext,
3918 tdata->validCipherLenInBits.len,
3919 "KASUMI Plaintext data not as expected");
3924 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3926 struct crypto_testsuite_params *ts_params = &testsuite_params;
3927 struct crypto_unittest_params *ut_params = &unittest_params;
3930 uint8_t *plaintext, *ciphertext;
3931 unsigned plaintext_pad_len;
3932 unsigned plaintext_len;
3934 /* Create SNOW 3G session */
3935 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3936 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3937 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3938 tdata->key.data, tdata->key.len,
3939 tdata->cipher_iv.len);
3943 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3945 /* Clear mbuf payload */
3946 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3947 rte_pktmbuf_tailroom(ut_params->ibuf));
3949 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3950 /* Append data which is padded to a multiple of */
3951 /* the algorithms block size */
3952 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3955 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3957 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3959 /* Create SNOW 3G operation */
3960 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3961 tdata->cipher_iv.len,
3962 tdata->validCipherLenInBits.len,
3967 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3969 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3971 ut_params->obuf = ut_params->op->sym->m_dst;
3972 if (ut_params->obuf)
3973 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3975 ciphertext = plaintext;
3977 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 tdata->ciphertext.data,
3983 tdata->validDataLenInBits.len,
3984 "SNOW 3G Ciphertext data not as expected");
3990 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3992 struct crypto_testsuite_params *ts_params = &testsuite_params;
3993 struct crypto_unittest_params *ut_params = &unittest_params;
3994 uint8_t *plaintext, *ciphertext;
3997 unsigned plaintext_pad_len;
3998 unsigned plaintext_len;
4000 /* Create SNOW 3G session */
4001 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4002 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4003 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4004 tdata->key.data, tdata->key.len,
4005 tdata->cipher_iv.len);
4009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4010 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4012 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4013 "Failed to allocate input buffer in mempool");
4014 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4015 "Failed to allocate output buffer in mempool");
4017 /* Clear mbuf payload */
4018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4019 rte_pktmbuf_tailroom(ut_params->ibuf));
4021 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4022 /* Append data which is padded to a multiple of */
4023 /* the algorithms block size */
4024 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4025 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4027 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4028 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4030 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4032 /* Create SNOW 3G operation */
4033 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4034 tdata->cipher_iv.len,
4035 tdata->validCipherLenInBits.len,
4040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4042 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_dst;
4045 if (ut_params->obuf)
4046 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 ciphertext = plaintext;
4050 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4055 tdata->ciphertext.data,
4056 tdata->validDataLenInBits.len,
4057 "SNOW 3G Ciphertext data not as expected");
4062 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4064 struct crypto_testsuite_params *ts_params = &testsuite_params;
4065 struct crypto_unittest_params *ut_params = &unittest_params;
4068 unsigned int plaintext_pad_len;
4069 unsigned int plaintext_len;
4070 uint8_t buffer[10000];
4071 const uint8_t *ciphertext;
4073 struct rte_cryptodev_info dev_info;
4075 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4077 uint64_t feat_flags = dev_info.feature_flags;
4079 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4080 printf("Device doesn't support out-of-place scatter-gather "
4081 "in both input and output mbufs. "
4086 /* Create SNOW 3G session */
4087 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4088 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4089 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4090 tdata->key.data, tdata->key.len,
4091 tdata->cipher_iv.len);
4095 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4096 /* Append data which is padded to a multiple of */
4097 /* the algorithms block size */
4098 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4100 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4101 plaintext_pad_len, 10, 0);
4102 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4103 plaintext_pad_len, 3, 0);
4105 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4106 "Failed to allocate input buffer in mempool");
4107 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4108 "Failed to allocate output buffer in mempool");
4110 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4112 /* Create SNOW 3G operation */
4113 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4114 tdata->cipher_iv.len,
4115 tdata->validCipherLenInBits.len,
4120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4122 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4124 ut_params->obuf = ut_params->op->sym->m_dst;
4125 if (ut_params->obuf)
4126 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4127 plaintext_len, buffer);
4129 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4130 plaintext_len, buffer);
4132 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4135 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4137 tdata->ciphertext.data,
4138 tdata->validDataLenInBits.len,
4139 "SNOW 3G Ciphertext data not as expected");
4144 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4146 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4148 uint8_t curr_byte, prev_byte;
4149 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4150 uint8_t lower_byte_mask = (1 << offset) - 1;
4153 prev_byte = buffer[0];
4154 buffer[0] >>= offset;
4156 for (i = 1; i < length_in_bytes; i++) {
4157 curr_byte = buffer[i];
4158 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4159 (curr_byte >> offset);
4160 prev_byte = curr_byte;
4165 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4167 struct crypto_testsuite_params *ts_params = &testsuite_params;
4168 struct crypto_unittest_params *ut_params = &unittest_params;
4169 uint8_t *plaintext, *ciphertext;
4171 uint32_t plaintext_len;
4172 uint32_t plaintext_pad_len;
4173 uint8_t extra_offset = 4;
4174 uint8_t *expected_ciphertext_shifted;
4176 /* Create SNOW 3G session */
4177 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4178 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4179 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4180 tdata->key.data, tdata->key.len,
4181 tdata->cipher_iv.len);
4185 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4189 "Failed to allocate input buffer in mempool");
4190 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4191 "Failed to allocate output buffer in mempool");
4193 /* Clear mbuf payload */
4194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4195 rte_pktmbuf_tailroom(ut_params->ibuf));
4197 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4199 * Append data which is padded to a
4200 * multiple of the algorithms block size
4202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4204 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4207 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4209 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4210 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4212 #ifdef RTE_APP_TEST_DEBUG
4213 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4215 /* Create SNOW 3G operation */
4216 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4217 tdata->cipher_iv.len,
4218 tdata->validCipherLenInBits.len,
4223 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4225 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4227 ut_params->obuf = ut_params->op->sym->m_dst;
4228 if (ut_params->obuf)
4229 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4231 ciphertext = plaintext;
4233 #ifdef RTE_APP_TEST_DEBUG
4234 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4237 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4239 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4240 "failed to reserve memory for ciphertext shifted\n");
4242 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4243 ceil_byte_length(tdata->ciphertext.len));
4244 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4247 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4249 expected_ciphertext_shifted,
4250 tdata->validDataLenInBits.len,
4252 "SNOW 3G Ciphertext data not as expected");
4256 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4258 struct crypto_testsuite_params *ts_params = &testsuite_params;
4259 struct crypto_unittest_params *ut_params = &unittest_params;
4263 uint8_t *plaintext, *ciphertext;
4264 unsigned ciphertext_pad_len;
4265 unsigned ciphertext_len;
4267 /* Create SNOW 3G session */
4268 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4269 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4270 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4271 tdata->key.data, tdata->key.len,
4272 tdata->cipher_iv.len);
4276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4278 /* Clear mbuf payload */
4279 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4280 rte_pktmbuf_tailroom(ut_params->ibuf));
4282 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4283 /* Append data which is padded to a multiple of */
4284 /* the algorithms block size */
4285 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4286 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4287 ciphertext_pad_len);
4288 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4290 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4292 /* Create SNOW 3G operation */
4293 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4294 tdata->cipher_iv.len,
4295 tdata->validCipherLenInBits.len,
4296 tdata->cipher.offset_bits);
4300 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4302 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4303 ut_params->obuf = ut_params->op->sym->m_dst;
4304 if (ut_params->obuf)
4305 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4307 plaintext = ciphertext;
4309 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4313 tdata->plaintext.data,
4314 tdata->validDataLenInBits.len,
4315 "SNOW 3G Plaintext data not as expected");
4319 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4321 struct crypto_testsuite_params *ts_params = &testsuite_params;
4322 struct crypto_unittest_params *ut_params = &unittest_params;
4326 uint8_t *plaintext, *ciphertext;
4327 unsigned ciphertext_pad_len;
4328 unsigned ciphertext_len;
4330 /* Create SNOW 3G session */
4331 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4332 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4333 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4334 tdata->key.data, tdata->key.len,
4335 tdata->cipher_iv.len);
4339 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4340 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4342 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4343 "Failed to allocate input buffer");
4344 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4345 "Failed to allocate output buffer");
4347 /* Clear mbuf payload */
4348 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4349 rte_pktmbuf_tailroom(ut_params->ibuf));
4351 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4352 rte_pktmbuf_tailroom(ut_params->obuf));
4354 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4355 /* Append data which is padded to a multiple of */
4356 /* the algorithms block size */
4357 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4358 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4359 ciphertext_pad_len);
4360 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4361 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4363 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4365 /* Create SNOW 3G operation */
4366 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4367 tdata->cipher_iv.len,
4368 tdata->validCipherLenInBits.len,
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4376 ut_params->obuf = ut_params->op->sym->m_dst;
4377 if (ut_params->obuf)
4378 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4380 plaintext = ciphertext;
4382 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4385 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4386 tdata->plaintext.data,
4387 tdata->validDataLenInBits.len,
4388 "SNOW 3G Plaintext data not as expected");
4393 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4395 struct crypto_testsuite_params *ts_params = &testsuite_params;
4396 struct crypto_unittest_params *ut_params = &unittest_params;
4400 uint8_t *plaintext, *ciphertext;
4401 unsigned int plaintext_pad_len;
4402 unsigned int plaintext_len;
4404 struct rte_cryptodev_sym_capability_idx cap_idx;
4406 /* Check if device supports ZUC EEA3 */
4407 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4408 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4410 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4414 /* Check if device supports ZUC EIA3 */
4415 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4416 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4422 /* Create ZUC session */
4423 retval = create_zuc_cipher_auth_encrypt_generate_session(
4424 ts_params->valid_devs[0],
4428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4430 /* clear mbuf payload */
4431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4432 rte_pktmbuf_tailroom(ut_params->ibuf));
4434 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4435 /* Append data which is padded to a multiple of */
4436 /* the algorithms block size */
4437 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4438 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4440 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4442 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4444 /* Create ZUC operation */
4445 retval = create_zuc_cipher_hash_generate_operation(tdata);
4449 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4451 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4452 ut_params->obuf = ut_params->op->sym->m_src;
4453 if (ut_params->obuf)
4454 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4456 ciphertext = plaintext;
4458 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4460 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4462 tdata->ciphertext.data,
4463 tdata->validDataLenInBits.len,
4464 "ZUC Ciphertext data not as expected");
4466 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4467 + plaintext_pad_len;
4470 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4474 "ZUC Generated auth tag not as expected");
4479 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4481 struct crypto_testsuite_params *ts_params = &testsuite_params;
4482 struct crypto_unittest_params *ut_params = &unittest_params;
4486 uint8_t *plaintext, *ciphertext;
4487 unsigned plaintext_pad_len;
4488 unsigned plaintext_len;
4490 /* Create SNOW 3G session */
4491 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4492 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4493 RTE_CRYPTO_AUTH_OP_GENERATE,
4494 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4495 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4496 tdata->key.data, tdata->key.len,
4497 tdata->auth_iv.len, tdata->digest.len,
4498 tdata->cipher_iv.len);
4501 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4503 /* clear mbuf payload */
4504 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4505 rte_pktmbuf_tailroom(ut_params->ibuf));
4507 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4508 /* Append data which is padded to a multiple of */
4509 /* the algorithms block size */
4510 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4511 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4513 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4515 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4517 /* Create SNOW 3G operation */
4518 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4519 tdata->digest.len, tdata->auth_iv.data,
4521 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4522 tdata->cipher_iv.data, tdata->cipher_iv.len,
4523 tdata->validCipherLenInBits.len,
4525 tdata->validAuthLenInBits.len,
4531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4533 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4534 ut_params->obuf = ut_params->op->sym->m_src;
4535 if (ut_params->obuf)
4536 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4538 ciphertext = plaintext;
4540 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4542 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4544 tdata->ciphertext.data,
4545 tdata->validDataLenInBits.len,
4546 "SNOW 3G Ciphertext data not as expected");
4548 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4549 + plaintext_pad_len;
4552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4555 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4556 "SNOW 3G Generated auth tag not as expected");
4561 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4562 uint8_t op_mode, uint8_t verify)
4564 struct crypto_testsuite_params *ts_params = &testsuite_params;
4565 struct crypto_unittest_params *ut_params = &unittest_params;
4569 uint8_t *plaintext = NULL, *ciphertext = NULL;
4570 unsigned int plaintext_pad_len;
4571 unsigned int plaintext_len;
4572 unsigned int ciphertext_pad_len;
4573 unsigned int ciphertext_len;
4575 struct rte_cryptodev_info dev_info;
4577 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4579 uint64_t feat_flags = dev_info.feature_flags;
4581 if (op_mode == OUT_OF_PLACE) {
4582 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4583 printf("Device doesn't support digest encrypted.\n");
4588 /* Create SNOW 3G session */
4589 retval = create_wireless_algo_auth_cipher_session(
4590 ts_params->valid_devs[0],
4591 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4592 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4593 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4594 : RTE_CRYPTO_AUTH_OP_GENERATE),
4595 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4596 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4597 tdata->key.data, tdata->key.len,
4598 tdata->auth_iv.len, tdata->digest.len,
4599 tdata->cipher_iv.len);
4604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605 if (op_mode == OUT_OF_PLACE)
4606 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4608 /* clear mbuf payload */
4609 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4610 rte_pktmbuf_tailroom(ut_params->ibuf));
4611 if (op_mode == OUT_OF_PLACE)
4612 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4613 rte_pktmbuf_tailroom(ut_params->obuf));
4615 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4616 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4617 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4618 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4621 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4622 ciphertext_pad_len);
4623 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4624 if (op_mode == OUT_OF_PLACE)
4625 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4626 debug_hexdump(stdout, "ciphertext:", ciphertext,
4629 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4631 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4632 if (op_mode == OUT_OF_PLACE)
4633 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4634 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4637 /* Create SNOW 3G operation */
4638 retval = create_wireless_algo_auth_cipher_operation(
4640 tdata->cipher_iv.data, tdata->cipher_iv.len,
4641 tdata->auth_iv.data, tdata->auth_iv.len,
4642 (tdata->digest.offset_bytes == 0 ?
4643 (verify ? ciphertext_pad_len : plaintext_pad_len)
4644 : tdata->digest.offset_bytes),
4645 tdata->validCipherLenInBits.len,
4646 tdata->cipher.offset_bits,
4647 tdata->validAuthLenInBits.len,
4648 tdata->auth.offset_bits,
4654 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4659 ut_params->obuf = (op_mode == IN_PLACE ?
4660 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4663 if (ut_params->obuf)
4664 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4667 plaintext = ciphertext +
4668 (tdata->cipher.offset_bits >> 3);
4670 debug_hexdump(stdout, "plaintext:", plaintext,
4671 (tdata->plaintext.len >> 3) - tdata->digest.len);
4672 debug_hexdump(stdout, "plaintext expected:",
4673 tdata->plaintext.data,
4674 (tdata->plaintext.len >> 3) - tdata->digest.len);
4676 if (ut_params->obuf)
4677 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4680 ciphertext = plaintext;
4682 debug_hexdump(stdout, "ciphertext:", ciphertext,
4684 debug_hexdump(stdout, "ciphertext expected:",
4685 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4687 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4688 + (tdata->digest.offset_bytes == 0 ?
4689 plaintext_pad_len : tdata->digest.offset_bytes);
4691 debug_hexdump(stdout, "digest:", ut_params->digest,
4693 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4699 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4701 tdata->plaintext.data,
4702 tdata->plaintext.len >> 3,
4703 "SNOW 3G Plaintext data not as expected");
4705 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4707 tdata->ciphertext.data,
4708 tdata->validDataLenInBits.len,
4709 "SNOW 3G Ciphertext data not as expected");
4711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4714 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4715 "SNOW 3G Generated auth tag not as expected");
4721 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4722 uint8_t op_mode, uint8_t verify)
4724 struct crypto_testsuite_params *ts_params = &testsuite_params;
4725 struct crypto_unittest_params *ut_params = &unittest_params;
4729 const uint8_t *plaintext = NULL;
4730 const uint8_t *ciphertext = NULL;
4731 const uint8_t *digest = NULL;
4732 unsigned int plaintext_pad_len;
4733 unsigned int plaintext_len;
4734 unsigned int ciphertext_pad_len;
4735 unsigned int ciphertext_len;
4736 uint8_t buffer[10000];
4737 uint8_t digest_buffer[10000];
4739 struct rte_cryptodev_info dev_info;
4741 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4743 uint64_t feat_flags = dev_info.feature_flags;
4745 if (op_mode == IN_PLACE) {
4746 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4747 printf("Device doesn't support in-place scatter-gather "
4748 "in both input and output mbufs.\n");
4752 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4753 printf("Device doesn't support out-of-place scatter-gather "
4754 "in both input and output mbufs.\n");
4757 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4758 printf("Device doesn't support digest encrypted.\n");
4763 /* Create SNOW 3G session */
4764 retval = create_wireless_algo_auth_cipher_session(
4765 ts_params->valid_devs[0],
4766 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4767 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4768 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4769 : RTE_CRYPTO_AUTH_OP_GENERATE),
4770 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4772 tdata->key.data, tdata->key.len,
4773 tdata->auth_iv.len, tdata->digest.len,
4774 tdata->cipher_iv.len);
4779 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4780 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4781 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4782 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4784 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4785 plaintext_pad_len, 15, 0);
4786 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4787 "Failed to allocate input buffer in mempool");
4789 if (op_mode == OUT_OF_PLACE) {
4790 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4791 plaintext_pad_len, 15, 0);
4792 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4793 "Failed to allocate output buffer in mempool");
4797 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4798 tdata->ciphertext.data);
4799 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4800 ciphertext_len, buffer);
4801 debug_hexdump(stdout, "ciphertext:", ciphertext,
4804 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4805 tdata->plaintext.data);
4806 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4807 plaintext_len, buffer);
4808 debug_hexdump(stdout, "plaintext:", plaintext,
4811 memset(buffer, 0, sizeof(buffer));
4813 /* Create SNOW 3G operation */
4814 retval = create_wireless_algo_auth_cipher_operation(
4816 tdata->cipher_iv.data, tdata->cipher_iv.len,
4817 tdata->auth_iv.data, tdata->auth_iv.len,
4818 (tdata->digest.offset_bytes == 0 ?
4819 (verify ? ciphertext_pad_len : plaintext_pad_len)
4820 : tdata->digest.offset_bytes),
4821 tdata->validCipherLenInBits.len,
4822 tdata->cipher.offset_bits,
4823 tdata->validAuthLenInBits.len,
4824 tdata->auth.offset_bits,
4830 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4833 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4835 ut_params->obuf = (op_mode == IN_PLACE ?
4836 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4839 if (ut_params->obuf)
4840 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4841 plaintext_len, buffer);
4843 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4844 plaintext_len, buffer);
4846 debug_hexdump(stdout, "plaintext:", plaintext,
4847 (tdata->plaintext.len >> 3) - tdata->digest.len);
4848 debug_hexdump(stdout, "plaintext expected:",
4849 tdata->plaintext.data,
4850 (tdata->plaintext.len >> 3) - tdata->digest.len);
4852 if (ut_params->obuf)
4853 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4854 ciphertext_len, buffer);
4856 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4857 ciphertext_len, buffer);
4859 debug_hexdump(stdout, "ciphertext:", ciphertext,
4861 debug_hexdump(stdout, "ciphertext expected:",
4862 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4864 if (ut_params->obuf)
4865 digest = rte_pktmbuf_read(ut_params->obuf,
4866 (tdata->digest.offset_bytes == 0 ?
4867 plaintext_pad_len : tdata->digest.offset_bytes),
4868 tdata->digest.len, digest_buffer);
4870 digest = rte_pktmbuf_read(ut_params->ibuf,
4871 (tdata->digest.offset_bytes == 0 ?
4872 plaintext_pad_len : tdata->digest.offset_bytes),
4873 tdata->digest.len, digest_buffer);
4875 debug_hexdump(stdout, "digest:", digest,
4877 debug_hexdump(stdout, "digest expected:",
4878 tdata->digest.data, tdata->digest.len);
4883 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4885 tdata->plaintext.data,
4886 tdata->plaintext.len >> 3,
4887 "SNOW 3G Plaintext data not as expected");
4889 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4891 tdata->ciphertext.data,
4892 tdata->validDataLenInBits.len,
4893 "SNOW 3G Ciphertext data not as expected");
4895 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4898 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4899 "SNOW 3G Generated auth tag not as expected");
4905 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4906 uint8_t op_mode, uint8_t verify)
4908 struct crypto_testsuite_params *ts_params = &testsuite_params;
4909 struct crypto_unittest_params *ut_params = &unittest_params;
4913 uint8_t *plaintext = NULL, *ciphertext = NULL;
4914 unsigned int plaintext_pad_len;
4915 unsigned int plaintext_len;
4916 unsigned int ciphertext_pad_len;
4917 unsigned int ciphertext_len;
4919 struct rte_cryptodev_info dev_info;
4921 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4923 uint64_t feat_flags = dev_info.feature_flags;
4925 if (op_mode == OUT_OF_PLACE) {
4926 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4927 printf("Device doesn't support digest encrypted.\n");
4932 /* Create KASUMI session */
4933 retval = create_wireless_algo_auth_cipher_session(
4934 ts_params->valid_devs[0],
4935 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4936 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4937 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4938 : RTE_CRYPTO_AUTH_OP_GENERATE),
4939 RTE_CRYPTO_AUTH_KASUMI_F9,
4940 RTE_CRYPTO_CIPHER_KASUMI_F8,
4941 tdata->key.data, tdata->key.len,
4942 0, tdata->digest.len,
4943 tdata->cipher_iv.len);
4948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4949 if (op_mode == OUT_OF_PLACE)
4950 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4952 /* clear mbuf payload */
4953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4954 rte_pktmbuf_tailroom(ut_params->ibuf));
4955 if (op_mode == OUT_OF_PLACE)
4956 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4957 rte_pktmbuf_tailroom(ut_params->obuf));
4959 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4960 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4961 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4962 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4965 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4966 ciphertext_pad_len);
4967 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4968 if (op_mode == OUT_OF_PLACE)
4969 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4970 debug_hexdump(stdout, "ciphertext:", ciphertext,
4973 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4975 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4976 if (op_mode == OUT_OF_PLACE)
4977 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4978 debug_hexdump(stdout, "plaintext:", plaintext,
4982 /* Create KASUMI operation */
4983 retval = create_wireless_algo_auth_cipher_operation(
4985 tdata->cipher_iv.data, tdata->cipher_iv.len,
4987 (tdata->digest.offset_bytes == 0 ?
4988 (verify ? ciphertext_pad_len : plaintext_pad_len)
4989 : tdata->digest.offset_bytes),
4990 tdata->validCipherLenInBits.len,
4991 tdata->validCipherOffsetInBits.len,
4992 tdata->validAuthLenInBits.len,
4999 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5002 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5004 ut_params->obuf = (op_mode == IN_PLACE ?
5005 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5009 if (ut_params->obuf)
5010 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5013 plaintext = ciphertext;
5015 debug_hexdump(stdout, "plaintext:", plaintext,
5016 (tdata->plaintext.len >> 3) - tdata->digest.len);
5017 debug_hexdump(stdout, "plaintext expected:",
5018 tdata->plaintext.data,
5019 (tdata->plaintext.len >> 3) - tdata->digest.len);
5021 if (ut_params->obuf)
5022 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5025 ciphertext = plaintext;
5027 debug_hexdump(stdout, "ciphertext:", ciphertext,
5029 debug_hexdump(stdout, "ciphertext expected:",
5030 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5032 ut_params->digest = rte_pktmbuf_mtod(
5033 ut_params->obuf, uint8_t *) +
5034 (tdata->digest.offset_bytes == 0 ?
5035 plaintext_pad_len : tdata->digest.offset_bytes);
5037 debug_hexdump(stdout, "digest:", ut_params->digest,
5039 debug_hexdump(stdout, "digest expected:",
5040 tdata->digest.data, tdata->digest.len);
5045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5047 tdata->plaintext.data,
5048 tdata->plaintext.len >> 3,
5049 "KASUMI Plaintext data not as expected");
5051 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5053 tdata->ciphertext.data,
5054 tdata->ciphertext.len >> 3,
5055 "KASUMI Ciphertext data not as expected");
5057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5060 DIGEST_BYTE_LENGTH_KASUMI_F9,
5061 "KASUMI Generated auth tag not as expected");
5067 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5068 uint8_t op_mode, uint8_t verify)
5070 struct crypto_testsuite_params *ts_params = &testsuite_params;
5071 struct crypto_unittest_params *ut_params = &unittest_params;
5075 const uint8_t *plaintext = NULL;
5076 const uint8_t *ciphertext = NULL;
5077 const uint8_t *digest = NULL;
5078 unsigned int plaintext_pad_len;
5079 unsigned int plaintext_len;
5080 unsigned int ciphertext_pad_len;
5081 unsigned int ciphertext_len;
5082 uint8_t buffer[10000];
5083 uint8_t digest_buffer[10000];
5085 struct rte_cryptodev_info dev_info;
5087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5089 uint64_t feat_flags = dev_info.feature_flags;
5091 if (op_mode == IN_PLACE) {
5092 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5093 printf("Device doesn't support in-place scatter-gather "
5094 "in both input and output mbufs.\n");
5098 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5099 printf("Device doesn't support out-of-place scatter-gather "
5100 "in both input and output mbufs.\n");
5103 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5104 printf("Device doesn't support digest encrypted.\n");
5109 /* Create KASUMI session */
5110 retval = create_wireless_algo_auth_cipher_session(
5111 ts_params->valid_devs[0],
5112 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5113 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5114 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5115 : RTE_CRYPTO_AUTH_OP_GENERATE),
5116 RTE_CRYPTO_AUTH_KASUMI_F9,
5117 RTE_CRYPTO_CIPHER_KASUMI_F8,
5118 tdata->key.data, tdata->key.len,
5119 0, tdata->digest.len,
5120 tdata->cipher_iv.len);
5125 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5126 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5127 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5128 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5130 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5131 plaintext_pad_len, 15, 0);
5132 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5133 "Failed to allocate input buffer in mempool");
5135 if (op_mode == OUT_OF_PLACE) {
5136 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5137 plaintext_pad_len, 15, 0);
5138 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5139 "Failed to allocate output buffer in mempool");
5143 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5144 tdata->ciphertext.data);
5145 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5146 ciphertext_len, buffer);
5147 debug_hexdump(stdout, "ciphertext:", ciphertext,
5150 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5151 tdata->plaintext.data);
5152 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5153 plaintext_len, buffer);
5154 debug_hexdump(stdout, "plaintext:", plaintext,
5157 memset(buffer, 0, sizeof(buffer));
5159 /* Create KASUMI operation */
5160 retval = create_wireless_algo_auth_cipher_operation(
5162 tdata->cipher_iv.data, tdata->cipher_iv.len,
5164 (tdata->digest.offset_bytes == 0 ?
5165 (verify ? ciphertext_pad_len : plaintext_pad_len)
5166 : tdata->digest.offset_bytes),
5167 tdata->validCipherLenInBits.len,
5168 tdata->validCipherOffsetInBits.len,
5169 tdata->validAuthLenInBits.len,
5176 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5179 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5181 ut_params->obuf = (op_mode == IN_PLACE ?
5182 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5185 if (ut_params->obuf)
5186 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5187 plaintext_len, buffer);
5189 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5190 plaintext_len, buffer);
5192 debug_hexdump(stdout, "plaintext:", plaintext,
5193 (tdata->plaintext.len >> 3) - tdata->digest.len);
5194 debug_hexdump(stdout, "plaintext expected:",
5195 tdata->plaintext.data,
5196 (tdata->plaintext.len >> 3) - tdata->digest.len);
5198 if (ut_params->obuf)
5199 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5200 ciphertext_len, buffer);
5202 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5203 ciphertext_len, buffer);
5205 debug_hexdump(stdout, "ciphertext:", ciphertext,
5207 debug_hexdump(stdout, "ciphertext expected:",
5208 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5210 if (ut_params->obuf)
5211 digest = rte_pktmbuf_read(ut_params->obuf,
5212 (tdata->digest.offset_bytes == 0 ?
5213 plaintext_pad_len : tdata->digest.offset_bytes),
5214 tdata->digest.len, digest_buffer);
5216 digest = rte_pktmbuf_read(ut_params->ibuf,
5217 (tdata->digest.offset_bytes == 0 ?
5218 plaintext_pad_len : tdata->digest.offset_bytes),
5219 tdata->digest.len, digest_buffer);
5221 debug_hexdump(stdout, "digest:", digest,
5223 debug_hexdump(stdout, "digest expected:",
5224 tdata->digest.data, tdata->digest.len);
5229 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5231 tdata->plaintext.data,
5232 tdata->plaintext.len >> 3,
5233 "KASUMI Plaintext data not as expected");
5235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5237 tdata->ciphertext.data,
5238 tdata->validDataLenInBits.len,
5239 "KASUMI Ciphertext data not as expected");
5241 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5244 DIGEST_BYTE_LENGTH_KASUMI_F9,
5245 "KASUMI Generated auth tag not as expected");
5251 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5253 struct crypto_testsuite_params *ts_params = &testsuite_params;
5254 struct crypto_unittest_params *ut_params = &unittest_params;
5258 uint8_t *plaintext, *ciphertext;
5259 unsigned plaintext_pad_len;
5260 unsigned plaintext_len;
5262 /* Create KASUMI session */
5263 retval = create_wireless_algo_cipher_auth_session(
5264 ts_params->valid_devs[0],
5265 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5266 RTE_CRYPTO_AUTH_OP_GENERATE,
5267 RTE_CRYPTO_AUTH_KASUMI_F9,
5268 RTE_CRYPTO_CIPHER_KASUMI_F8,
5269 tdata->key.data, tdata->key.len,
5270 0, tdata->digest.len,
5271 tdata->cipher_iv.len);
5275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5277 /* clear mbuf payload */
5278 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5279 rte_pktmbuf_tailroom(ut_params->ibuf));
5281 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5282 /* Append data which is padded to a multiple of */
5283 /* the algorithms block size */
5284 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5285 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5287 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5289 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5291 /* Create KASUMI operation */
5292 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5293 tdata->digest.len, NULL, 0,
5294 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5295 tdata->cipher_iv.data, tdata->cipher_iv.len,
5296 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5297 tdata->validCipherOffsetInBits.len,
5298 tdata->validAuthLenInBits.len,
5304 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5306 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5308 if (ut_params->op->sym->m_dst)
5309 ut_params->obuf = ut_params->op->sym->m_dst;
5311 ut_params->obuf = ut_params->op->sym->m_src;
5313 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5314 tdata->validCipherOffsetInBits.len >> 3);
5316 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5317 + plaintext_pad_len;
5319 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5320 (tdata->validCipherOffsetInBits.len >> 3);
5322 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5324 reference_ciphertext,
5325 tdata->validCipherLenInBits.len,
5326 "KASUMI Ciphertext data not as expected");
5329 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5332 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5333 "KASUMI Generated auth tag not as expected");
5338 test_zuc_encryption(const struct wireless_test_data *tdata)
5340 struct crypto_testsuite_params *ts_params = &testsuite_params;
5341 struct crypto_unittest_params *ut_params = &unittest_params;
5344 uint8_t *plaintext, *ciphertext;
5345 unsigned plaintext_pad_len;
5346 unsigned plaintext_len;
5348 struct rte_cryptodev_sym_capability_idx cap_idx;
5350 /* Check if device supports ZUC EEA3 */
5351 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5352 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5354 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5358 /* Create ZUC session */
5359 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5360 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5361 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5362 tdata->key.data, tdata->key.len,
5363 tdata->cipher_iv.len);
5367 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5369 /* Clear mbuf payload */
5370 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5371 rte_pktmbuf_tailroom(ut_params->ibuf));
5373 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5374 /* Append data which is padded to a multiple */
5375 /* of the algorithms block size */
5376 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5377 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5379 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5381 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5383 /* Create ZUC operation */
5384 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5385 tdata->cipher_iv.len,
5386 tdata->plaintext.len,
5391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5395 ut_params->obuf = ut_params->op->sym->m_dst;
5396 if (ut_params->obuf)
5397 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5399 ciphertext = plaintext;
5401 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5404 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5406 tdata->ciphertext.data,
5407 tdata->validCipherLenInBits.len,
5408 "ZUC Ciphertext data not as expected");
5413 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5415 struct crypto_testsuite_params *ts_params = &testsuite_params;
5416 struct crypto_unittest_params *ut_params = &unittest_params;
5420 unsigned int plaintext_pad_len;
5421 unsigned int plaintext_len;
5422 const uint8_t *ciphertext;
5423 uint8_t ciphertext_buffer[2048];
5424 struct rte_cryptodev_info dev_info;
5426 struct rte_cryptodev_sym_capability_idx cap_idx;
5428 /* Check if device supports ZUC EEA3 */
5429 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5430 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5438 uint64_t feat_flags = dev_info.feature_flags;
5440 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5441 printf("Device doesn't support in-place scatter-gather. "
5446 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5448 /* Append data which is padded to a multiple */
5449 /* of the algorithms block size */
5450 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5452 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5453 plaintext_pad_len, 10, 0);
5455 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5456 tdata->plaintext.data);
5458 /* Create ZUC session */
5459 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5460 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5461 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5462 tdata->key.data, tdata->key.len,
5463 tdata->cipher_iv.len);
5467 /* Clear mbuf payload */
5469 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5471 /* Create ZUC operation */
5472 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5473 tdata->cipher_iv.len, tdata->plaintext.len,
5478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5482 ut_params->obuf = ut_params->op->sym->m_dst;
5483 if (ut_params->obuf)
5484 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5485 0, plaintext_len, ciphertext_buffer);
5487 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5488 0, plaintext_len, ciphertext_buffer);
5491 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5496 tdata->ciphertext.data,
5497 tdata->validCipherLenInBits.len,
5498 "ZUC Ciphertext data not as expected");
5504 test_zuc_authentication(const struct wireless_test_data *tdata)
5506 struct crypto_testsuite_params *ts_params = &testsuite_params;
5507 struct crypto_unittest_params *ut_params = &unittest_params;
5510 unsigned plaintext_pad_len;
5511 unsigned plaintext_len;
5514 struct rte_cryptodev_sym_capability_idx cap_idx;
5516 /* Check if device supports ZUC EIA3 */
5517 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5518 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5524 /* Create ZUC session */
5525 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5526 tdata->key.data, tdata->key.len,
5527 tdata->auth_iv.len, tdata->digest.len,
5528 RTE_CRYPTO_AUTH_OP_GENERATE,
5529 RTE_CRYPTO_AUTH_ZUC_EIA3);
5533 /* alloc mbuf and set payload */
5534 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5536 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5537 rte_pktmbuf_tailroom(ut_params->ibuf));
5539 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5540 /* Append data which is padded to a multiple of */
5541 /* the algorithms block size */
5542 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5543 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5545 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5547 /* Create ZUC operation */
5548 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5549 tdata->auth_iv.data, tdata->auth_iv.len,
5550 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5551 tdata->validAuthLenInBits.len,
5556 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5558 ut_params->obuf = ut_params->op->sym->m_src;
5559 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5560 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5561 + plaintext_pad_len;
5564 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5567 DIGEST_BYTE_LENGTH_KASUMI_F9,
5568 "ZUC Generated auth tag not as expected");
5574 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5575 uint8_t op_mode, uint8_t verify)
5577 struct crypto_testsuite_params *ts_params = &testsuite_params;
5578 struct crypto_unittest_params *ut_params = &unittest_params;
5582 uint8_t *plaintext = NULL, *ciphertext = NULL;
5583 unsigned int plaintext_pad_len;
5584 unsigned int plaintext_len;
5585 unsigned int ciphertext_pad_len;
5586 unsigned int ciphertext_len;
5588 struct rte_cryptodev_info dev_info;
5589 struct rte_cryptodev_sym_capability_idx cap_idx;
5591 /* Check if device supports ZUC EIA3 */
5592 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5593 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5595 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5599 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5601 uint64_t feat_flags = dev_info.feature_flags;
5603 if (op_mode == OUT_OF_PLACE) {
5604 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5605 printf("Device doesn't support digest encrypted.\n");
5610 /* Create ZUC session */
5611 retval = create_wireless_algo_auth_cipher_session(
5612 ts_params->valid_devs[0],
5613 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5614 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5615 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5616 : RTE_CRYPTO_AUTH_OP_GENERATE),
5617 RTE_CRYPTO_AUTH_ZUC_EIA3,
5618 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5619 tdata->key.data, tdata->key.len,
5620 tdata->auth_iv.len, tdata->digest.len,
5621 tdata->cipher_iv.len);
5626 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5627 if (op_mode == OUT_OF_PLACE)
5628 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5630 /* clear mbuf payload */
5631 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5632 rte_pktmbuf_tailroom(ut_params->ibuf));
5633 if (op_mode == OUT_OF_PLACE)
5634 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5635 rte_pktmbuf_tailroom(ut_params->obuf));
5637 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5638 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5639 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5640 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5643 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5644 ciphertext_pad_len);
5645 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5646 if (op_mode == OUT_OF_PLACE)
5647 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5648 debug_hexdump(stdout, "ciphertext:", ciphertext,
5651 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5653 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5654 if (op_mode == OUT_OF_PLACE)
5655 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5656 debug_hexdump(stdout, "plaintext:", plaintext,
5660 /* Create ZUC operation */
5661 retval = create_wireless_algo_auth_cipher_operation(
5663 tdata->cipher_iv.data, tdata->cipher_iv.len,
5664 tdata->auth_iv.data, tdata->auth_iv.len,
5665 (tdata->digest.offset_bytes == 0 ?
5666 (verify ? ciphertext_pad_len : plaintext_pad_len)
5667 : tdata->digest.offset_bytes),
5668 tdata->validCipherLenInBits.len,
5669 tdata->validCipherOffsetInBits.len,
5670 tdata->validAuthLenInBits.len,
5677 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5680 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5682 ut_params->obuf = (op_mode == IN_PLACE ?
5683 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5687 if (ut_params->obuf)
5688 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5691 plaintext = ciphertext;
5693 debug_hexdump(stdout, "plaintext:", plaintext,
5694 (tdata->plaintext.len >> 3) - tdata->digest.len);
5695 debug_hexdump(stdout, "plaintext expected:",
5696 tdata->plaintext.data,
5697 (tdata->plaintext.len >> 3) - tdata->digest.len);
5699 if (ut_params->obuf)
5700 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5703 ciphertext = plaintext;
5705 debug_hexdump(stdout, "ciphertext:", ciphertext,
5707 debug_hexdump(stdout, "ciphertext expected:",
5708 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5710 ut_params->digest = rte_pktmbuf_mtod(
5711 ut_params->obuf, uint8_t *) +
5712 (tdata->digest.offset_bytes == 0 ?
5713 plaintext_pad_len : tdata->digest.offset_bytes);
5715 debug_hexdump(stdout, "digest:", ut_params->digest,
5717 debug_hexdump(stdout, "digest expected:",
5718 tdata->digest.data, tdata->digest.len);
5723 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5725 tdata->plaintext.data,
5726 tdata->plaintext.len >> 3,
5727 "ZUC Plaintext data not as expected");
5729 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5731 tdata->ciphertext.data,
5732 tdata->ciphertext.len >> 3,
5733 "ZUC Ciphertext data not as expected");
5735 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5738 DIGEST_BYTE_LENGTH_KASUMI_F9,
5739 "ZUC Generated auth tag not as expected");
5745 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5746 uint8_t op_mode, uint8_t verify)
5748 struct crypto_testsuite_params *ts_params = &testsuite_params;
5749 struct crypto_unittest_params *ut_params = &unittest_params;
5753 const uint8_t *plaintext = NULL;
5754 const uint8_t *ciphertext = NULL;
5755 const uint8_t *digest = NULL;
5756 unsigned int plaintext_pad_len;
5757 unsigned int plaintext_len;
5758 unsigned int ciphertext_pad_len;
5759 unsigned int ciphertext_len;
5760 uint8_t buffer[10000];
5761 uint8_t digest_buffer[10000];
5763 struct rte_cryptodev_info dev_info;
5764 struct rte_cryptodev_sym_capability_idx cap_idx;
5766 /* Check if device supports ZUC EIA3 */
5767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5768 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5770 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5776 uint64_t feat_flags = dev_info.feature_flags;
5778 if (op_mode == IN_PLACE) {
5779 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5780 printf("Device doesn't support in-place scatter-gather "
5781 "in both input and output mbufs.\n");
5785 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5786 printf("Device doesn't support out-of-place scatter-gather "
5787 "in both input and output mbufs.\n");
5790 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5791 printf("Device doesn't support digest encrypted.\n");
5796 /* Create ZUC session */
5797 retval = create_wireless_algo_auth_cipher_session(
5798 ts_params->valid_devs[0],
5799 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5800 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5801 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5802 : RTE_CRYPTO_AUTH_OP_GENERATE),
5803 RTE_CRYPTO_AUTH_ZUC_EIA3,
5804 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5805 tdata->key.data, tdata->key.len,
5806 tdata->auth_iv.len, tdata->digest.len,
5807 tdata->cipher_iv.len);
5812 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5813 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5814 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5815 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5817 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5818 plaintext_pad_len, 15, 0);
5819 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5820 "Failed to allocate input buffer in mempool");
5822 if (op_mode == OUT_OF_PLACE) {
5823 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5824 plaintext_pad_len, 15, 0);
5825 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5826 "Failed to allocate output buffer in mempool");
5830 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5831 tdata->ciphertext.data);
5832 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5833 ciphertext_len, buffer);
5834 debug_hexdump(stdout, "ciphertext:", ciphertext,
5837 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5838 tdata->plaintext.data);
5839 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5840 plaintext_len, buffer);
5841 debug_hexdump(stdout, "plaintext:", plaintext,
5844 memset(buffer, 0, sizeof(buffer));
5846 /* Create ZUC operation */
5847 retval = create_wireless_algo_auth_cipher_operation(
5849 tdata->cipher_iv.data, tdata->cipher_iv.len,
5851 (tdata->digest.offset_bytes == 0 ?
5852 (verify ? ciphertext_pad_len : plaintext_pad_len)
5853 : tdata->digest.offset_bytes),
5854 tdata->validCipherLenInBits.len,
5855 tdata->validCipherOffsetInBits.len,
5856 tdata->validAuthLenInBits.len,
5863 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5866 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5868 ut_params->obuf = (op_mode == IN_PLACE ?
5869 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5872 if (ut_params->obuf)
5873 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5874 plaintext_len, buffer);
5876 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5877 plaintext_len, buffer);
5879 debug_hexdump(stdout, "plaintext:", plaintext,
5880 (tdata->plaintext.len >> 3) - tdata->digest.len);
5881 debug_hexdump(stdout, "plaintext expected:",
5882 tdata->plaintext.data,
5883 (tdata->plaintext.len >> 3) - tdata->digest.len);
5885 if (ut_params->obuf)
5886 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5887 ciphertext_len, buffer);
5889 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5890 ciphertext_len, buffer);
5892 debug_hexdump(stdout, "ciphertext:", ciphertext,
5894 debug_hexdump(stdout, "ciphertext expected:",
5895 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5897 if (ut_params->obuf)
5898 digest = rte_pktmbuf_read(ut_params->obuf,
5899 (tdata->digest.offset_bytes == 0 ?
5900 plaintext_pad_len : tdata->digest.offset_bytes),
5901 tdata->digest.len, digest_buffer);
5903 digest = rte_pktmbuf_read(ut_params->ibuf,
5904 (tdata->digest.offset_bytes == 0 ?
5905 plaintext_pad_len : tdata->digest.offset_bytes),
5906 tdata->digest.len, digest_buffer);
5908 debug_hexdump(stdout, "digest:", digest,
5910 debug_hexdump(stdout, "digest expected:",
5911 tdata->digest.data, tdata->digest.len);
5916 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5918 tdata->plaintext.data,
5919 tdata->plaintext.len >> 3,
5920 "ZUC Plaintext data not as expected");
5922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5924 tdata->ciphertext.data,
5925 tdata->validDataLenInBits.len,
5926 "ZUC Ciphertext data not as expected");
5928 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5931 DIGEST_BYTE_LENGTH_KASUMI_F9,
5932 "ZUC Generated auth tag not as expected");
5938 test_kasumi_encryption_test_case_1(void)
5940 return test_kasumi_encryption(&kasumi_test_case_1);
5944 test_kasumi_encryption_test_case_1_sgl(void)
5946 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5950 test_kasumi_encryption_test_case_1_oop(void)
5952 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5956 test_kasumi_encryption_test_case_1_oop_sgl(void)
5958 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5962 test_kasumi_encryption_test_case_2(void)
5964 return test_kasumi_encryption(&kasumi_test_case_2);
5968 test_kasumi_encryption_test_case_3(void)
5970 return test_kasumi_encryption(&kasumi_test_case_3);
5974 test_kasumi_encryption_test_case_4(void)
5976 return test_kasumi_encryption(&kasumi_test_case_4);
5980 test_kasumi_encryption_test_case_5(void)
5982 return test_kasumi_encryption(&kasumi_test_case_5);
5986 test_kasumi_decryption_test_case_1(void)
5988 return test_kasumi_decryption(&kasumi_test_case_1);
5992 test_kasumi_decryption_test_case_1_oop(void)
5994 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5998 test_kasumi_decryption_test_case_2(void)
6000 return test_kasumi_decryption(&kasumi_test_case_2);
6004 test_kasumi_decryption_test_case_3(void)
6006 return test_kasumi_decryption(&kasumi_test_case_3);
6010 test_kasumi_decryption_test_case_4(void)
6012 return test_kasumi_decryption(&kasumi_test_case_4);
6016 test_kasumi_decryption_test_case_5(void)
6018 return test_kasumi_decryption(&kasumi_test_case_5);
6021 test_snow3g_encryption_test_case_1(void)
6023 return test_snow3g_encryption(&snow3g_test_case_1);
6027 test_snow3g_encryption_test_case_1_oop(void)
6029 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6033 test_snow3g_encryption_test_case_1_oop_sgl(void)
6035 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6040 test_snow3g_encryption_test_case_1_offset_oop(void)
6042 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6046 test_snow3g_encryption_test_case_2(void)
6048 return test_snow3g_encryption(&snow3g_test_case_2);
6052 test_snow3g_encryption_test_case_3(void)
6054 return test_snow3g_encryption(&snow3g_test_case_3);
6058 test_snow3g_encryption_test_case_4(void)
6060 return test_snow3g_encryption(&snow3g_test_case_4);
6064 test_snow3g_encryption_test_case_5(void)
6066 return test_snow3g_encryption(&snow3g_test_case_5);
6070 test_snow3g_decryption_test_case_1(void)
6072 return test_snow3g_decryption(&snow3g_test_case_1);
6076 test_snow3g_decryption_test_case_1_oop(void)
6078 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6082 test_snow3g_decryption_test_case_2(void)
6084 return test_snow3g_decryption(&snow3g_test_case_2);
6088 test_snow3g_decryption_test_case_3(void)
6090 return test_snow3g_decryption(&snow3g_test_case_3);
6094 test_snow3g_decryption_test_case_4(void)
6096 return test_snow3g_decryption(&snow3g_test_case_4);
6100 test_snow3g_decryption_test_case_5(void)
6102 return test_snow3g_decryption(&snow3g_test_case_5);
6106 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6107 * Pattern digest from snow3g_test_data must be allocated as
6108 * 4 last bytes in plaintext.
6111 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6112 struct snow3g_hash_test_data *output)
6114 if ((pattern != NULL) && (output != NULL)) {
6115 output->key.len = pattern->key.len;
6117 memcpy(output->key.data,
6118 pattern->key.data, pattern->key.len);
6120 output->auth_iv.len = pattern->auth_iv.len;
6122 memcpy(output->auth_iv.data,
6123 pattern->auth_iv.data, pattern->auth_iv.len);
6125 output->plaintext.len = pattern->plaintext.len;
6127 memcpy(output->plaintext.data,
6128 pattern->plaintext.data, pattern->plaintext.len >> 3);
6130 output->digest.len = pattern->digest.len;
6132 memcpy(output->digest.data,
6133 &pattern->plaintext.data[pattern->digest.offset_bytes],
6134 pattern->digest.len);
6136 output->validAuthLenInBits.len =
6137 pattern->validAuthLenInBits.len;
6142 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6145 test_snow3g_decryption_with_digest_test_case_1(void)
6147 struct snow3g_hash_test_data snow3g_hash_data;
6150 * Function prepare data for hash veryfication test case.
6151 * Digest is allocated in 4 last bytes in plaintext, pattern.
6153 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6155 return test_snow3g_decryption(&snow3g_test_case_7) &
6156 test_snow3g_authentication_verify(&snow3g_hash_data);
6160 test_snow3g_cipher_auth_test_case_1(void)
6162 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6166 test_snow3g_auth_cipher_test_case_1(void)
6168 return test_snow3g_auth_cipher(
6169 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6173 test_snow3g_auth_cipher_test_case_2(void)
6175 return test_snow3g_auth_cipher(
6176 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6180 test_snow3g_auth_cipher_test_case_2_oop(void)
6182 return test_snow3g_auth_cipher(
6183 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6187 test_snow3g_auth_cipher_part_digest_enc(void)
6189 return test_snow3g_auth_cipher(
6190 &snow3g_auth_cipher_partial_digest_encryption,
6195 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6197 return test_snow3g_auth_cipher(
6198 &snow3g_auth_cipher_partial_digest_encryption,
6203 test_snow3g_auth_cipher_test_case_3_sgl(void)
6205 return test_snow3g_auth_cipher_sgl(
6206 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6210 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6212 return test_snow3g_auth_cipher_sgl(
6213 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6217 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6219 return test_snow3g_auth_cipher_sgl(
6220 &snow3g_auth_cipher_partial_digest_encryption,
6225 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6227 return test_snow3g_auth_cipher_sgl(
6228 &snow3g_auth_cipher_partial_digest_encryption,
6233 test_snow3g_auth_cipher_verify_test_case_1(void)
6235 return test_snow3g_auth_cipher(
6236 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6240 test_snow3g_auth_cipher_verify_test_case_2(void)
6242 return test_snow3g_auth_cipher(
6243 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6247 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6249 return test_snow3g_auth_cipher(
6250 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6254 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6256 return test_snow3g_auth_cipher(
6257 &snow3g_auth_cipher_partial_digest_encryption,
6262 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6264 return test_snow3g_auth_cipher(
6265 &snow3g_auth_cipher_partial_digest_encryption,
6270 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6272 return test_snow3g_auth_cipher_sgl(
6273 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6277 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6279 return test_snow3g_auth_cipher_sgl(
6280 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6284 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6286 return test_snow3g_auth_cipher_sgl(
6287 &snow3g_auth_cipher_partial_digest_encryption,
6292 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6294 return test_snow3g_auth_cipher_sgl(
6295 &snow3g_auth_cipher_partial_digest_encryption,
6300 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6302 return test_snow3g_auth_cipher(
6303 &snow3g_test_case_7, IN_PLACE, 0);
6307 test_kasumi_auth_cipher_test_case_1(void)
6309 return test_kasumi_auth_cipher(
6310 &kasumi_test_case_3, IN_PLACE, 0);
6314 test_kasumi_auth_cipher_test_case_2(void)
6316 return test_kasumi_auth_cipher(
6317 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6321 test_kasumi_auth_cipher_test_case_2_oop(void)
6323 return test_kasumi_auth_cipher(
6324 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6328 test_kasumi_auth_cipher_test_case_2_sgl(void)
6330 return test_kasumi_auth_cipher_sgl(
6331 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6335 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6337 return test_kasumi_auth_cipher_sgl(
6338 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6342 test_kasumi_auth_cipher_verify_test_case_1(void)
6344 return test_kasumi_auth_cipher(
6345 &kasumi_test_case_3, IN_PLACE, 1);
6349 test_kasumi_auth_cipher_verify_test_case_2(void)
6351 return test_kasumi_auth_cipher(
6352 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6356 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6358 return test_kasumi_auth_cipher(
6359 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6363 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6365 return test_kasumi_auth_cipher_sgl(
6366 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6370 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6372 return test_kasumi_auth_cipher_sgl(
6373 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6377 test_kasumi_cipher_auth_test_case_1(void)
6379 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6383 test_zuc_encryption_test_case_1(void)
6385 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6389 test_zuc_encryption_test_case_2(void)
6391 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6395 test_zuc_encryption_test_case_3(void)
6397 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6401 test_zuc_encryption_test_case_4(void)
6403 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6407 test_zuc_encryption_test_case_5(void)
6409 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6413 test_zuc_encryption_test_case_6_sgl(void)
6415 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6419 test_zuc_hash_generate_test_case_1(void)
6421 return test_zuc_authentication(&zuc_test_case_auth_1b);
6425 test_zuc_hash_generate_test_case_2(void)
6427 return test_zuc_authentication(&zuc_test_case_auth_90b);
6431 test_zuc_hash_generate_test_case_3(void)
6433 return test_zuc_authentication(&zuc_test_case_auth_577b);
6437 test_zuc_hash_generate_test_case_4(void)
6439 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6443 test_zuc_hash_generate_test_case_5(void)
6445 return test_zuc_authentication(&zuc_test_auth_5670b);
6449 test_zuc_hash_generate_test_case_6(void)
6451 return test_zuc_authentication(&zuc_test_case_auth_128b);
6455 test_zuc_hash_generate_test_case_7(void)
6457 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6461 test_zuc_hash_generate_test_case_8(void)
6463 return test_zuc_authentication(&zuc_test_case_auth_584b);
6467 test_zuc_cipher_auth_test_case_1(void)
6469 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6473 test_zuc_cipher_auth_test_case_2(void)
6475 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6479 test_zuc_auth_cipher_test_case_1(void)
6481 return test_zuc_auth_cipher(
6482 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6486 test_zuc_auth_cipher_test_case_1_oop(void)
6488 return test_zuc_auth_cipher(
6489 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6493 test_zuc_auth_cipher_test_case_1_sgl(void)
6495 return test_zuc_auth_cipher_sgl(
6496 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6500 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6502 return test_zuc_auth_cipher_sgl(
6503 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6507 test_zuc_auth_cipher_verify_test_case_1(void)
6509 return test_zuc_auth_cipher(
6510 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6514 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6516 return test_zuc_auth_cipher(
6517 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6521 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6523 return test_zuc_auth_cipher_sgl(
6524 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6528 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6530 return test_zuc_auth_cipher_sgl(
6531 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6535 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6537 uint8_t dev_id = testsuite_params.valid_devs[0];
6539 struct rte_cryptodev_sym_capability_idx cap_idx;
6541 /* Check if device supports particular cipher algorithm */
6542 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6543 cap_idx.algo.cipher = tdata->cipher_algo;
6544 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6547 /* Check if device supports particular hash algorithm */
6548 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6549 cap_idx.algo.auth = tdata->auth_algo;
6550 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6557 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6558 uint8_t op_mode, uint8_t verify)
6560 struct crypto_testsuite_params *ts_params = &testsuite_params;
6561 struct crypto_unittest_params *ut_params = &unittest_params;
6565 uint8_t *plaintext = NULL, *ciphertext = NULL;
6566 unsigned int plaintext_pad_len;
6567 unsigned int plaintext_len;
6568 unsigned int ciphertext_pad_len;
6569 unsigned int ciphertext_len;
6571 struct rte_cryptodev_info dev_info;
6573 /* Check if device supports particular algorithms */
6574 if (test_mixed_check_if_unsupported(tdata))
6577 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6579 uint64_t feat_flags = dev_info.feature_flags;
6581 if (op_mode == OUT_OF_PLACE) {
6582 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6583 printf("Device doesn't support digest encrypted.\n");
6588 /* Create the session */
6589 retval = create_wireless_algo_auth_cipher_session(
6590 ts_params->valid_devs[0],
6591 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6592 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6593 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6594 : RTE_CRYPTO_AUTH_OP_GENERATE),
6597 tdata->auth_key.data, tdata->auth_key.len,
6598 tdata->auth_iv.len, tdata->digest_enc.len,
6599 tdata->cipher_iv.len);
6604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6605 if (op_mode == OUT_OF_PLACE)
6606 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6608 /* clear mbuf payload */
6609 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6610 rte_pktmbuf_tailroom(ut_params->ibuf));
6611 if (op_mode == OUT_OF_PLACE)
6612 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6613 rte_pktmbuf_tailroom(ut_params->obuf));
6615 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6616 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6617 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6618 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6621 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6622 ciphertext_pad_len);
6623 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6624 if (op_mode == OUT_OF_PLACE)
6625 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6626 debug_hexdump(stdout, "ciphertext:", ciphertext,
6629 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6631 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6632 if (op_mode == OUT_OF_PLACE)
6633 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6634 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6637 /* Create the operation */
6638 retval = create_wireless_algo_auth_cipher_operation(
6639 tdata->digest_enc.len,
6640 tdata->cipher_iv.data, tdata->cipher_iv.len,
6641 tdata->auth_iv.data, tdata->auth_iv.len,
6642 (tdata->digest_enc.offset == 0 ?
6643 (verify ? ciphertext_pad_len : plaintext_pad_len)
6644 : tdata->digest_enc.offset),
6645 tdata->validCipherLen.len_bits,
6646 tdata->cipher.offset_bits,
6647 tdata->validAuthLen.len_bits,
6648 tdata->auth.offset_bits,
6654 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6659 ut_params->obuf = (op_mode == IN_PLACE ?
6660 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6663 if (ut_params->obuf)
6664 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6667 plaintext = ciphertext +
6668 (tdata->cipher.offset_bits >> 3);
6670 debug_hexdump(stdout, "plaintext:", plaintext,
6671 (tdata->plaintext.len_bits >> 3) -
6672 tdata->digest_enc.len);
6673 debug_hexdump(stdout, "plaintext expected:",
6674 tdata->plaintext.data,
6675 (tdata->plaintext.len_bits >> 3) -
6676 tdata->digest_enc.len);
6678 if (ut_params->obuf)
6679 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6682 ciphertext = plaintext;
6684 debug_hexdump(stdout, "ciphertext:", ciphertext,
6686 debug_hexdump(stdout, "ciphertext expected:",
6687 tdata->ciphertext.data,
6688 tdata->ciphertext.len_bits >> 3);
6690 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6691 + (tdata->digest_enc.offset == 0 ?
6692 plaintext_pad_len : tdata->digest_enc.offset);
6694 debug_hexdump(stdout, "digest:", ut_params->digest,
6695 tdata->digest_enc.len);
6696 debug_hexdump(stdout, "digest expected:",
6697 tdata->digest_enc.data,
6698 tdata->digest_enc.len);
6703 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6705 tdata->plaintext.data,
6706 tdata->plaintext.len_bits >> 3,
6707 "Plaintext data not as expected");
6709 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6711 tdata->ciphertext.data,
6712 tdata->validDataLen.len_bits,
6713 "Ciphertext data not as expected");
6715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6717 tdata->digest_enc.data,
6718 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6719 "Generated auth tag not as expected");
6725 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6726 uint8_t op_mode, uint8_t verify)
6728 struct crypto_testsuite_params *ts_params = &testsuite_params;
6729 struct crypto_unittest_params *ut_params = &unittest_params;
6733 const uint8_t *plaintext = NULL;
6734 const uint8_t *ciphertext = NULL;
6735 const uint8_t *digest = NULL;
6736 unsigned int plaintext_pad_len;
6737 unsigned int plaintext_len;
6738 unsigned int ciphertext_pad_len;
6739 unsigned int ciphertext_len;
6740 uint8_t buffer[10000];
6741 uint8_t digest_buffer[10000];
6743 struct rte_cryptodev_info dev_info;
6745 /* Check if device supports particular algorithms */
6746 if (test_mixed_check_if_unsupported(tdata))
6749 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6751 uint64_t feat_flags = dev_info.feature_flags;
6753 if (op_mode == IN_PLACE) {
6754 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6755 printf("Device doesn't support in-place scatter-gather "
6756 "in both input and output mbufs.\n");
6760 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6761 printf("Device doesn't support out-of-place scatter-gather "
6762 "in both input and output mbufs.\n");
6765 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6766 printf("Device doesn't support digest encrypted.\n");
6771 /* Create the session */
6772 retval = create_wireless_algo_auth_cipher_session(
6773 ts_params->valid_devs[0],
6774 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6775 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6776 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6777 : RTE_CRYPTO_AUTH_OP_GENERATE),
6780 tdata->auth_key.data, tdata->auth_key.len,
6781 tdata->auth_iv.len, tdata->digest_enc.len,
6782 tdata->cipher_iv.len);
6787 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6788 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6789 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6792 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6793 plaintext_pad_len, 15, 0);
6794 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6795 "Failed to allocate input buffer in mempool");
6797 if (op_mode == OUT_OF_PLACE) {
6798 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6799 plaintext_pad_len, 15, 0);
6800 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6801 "Failed to allocate output buffer in mempool");
6805 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6806 tdata->ciphertext.data);
6807 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6808 ciphertext_len, buffer);
6809 debug_hexdump(stdout, "ciphertext:", ciphertext,
6812 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6813 tdata->plaintext.data);
6814 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6815 plaintext_len, buffer);
6816 debug_hexdump(stdout, "plaintext:", plaintext,
6819 memset(buffer, 0, sizeof(buffer));
6821 /* Create the operation */
6822 retval = create_wireless_algo_auth_cipher_operation(
6823 tdata->digest_enc.len,
6824 tdata->cipher_iv.data, tdata->cipher_iv.len,
6825 tdata->auth_iv.data, tdata->auth_iv.len,
6826 (tdata->digest_enc.offset == 0 ?
6827 (verify ? ciphertext_pad_len : plaintext_pad_len)
6828 : tdata->digest_enc.offset),
6829 tdata->validCipherLen.len_bits,
6830 tdata->cipher.offset_bits,
6831 tdata->validAuthLen.len_bits,
6832 tdata->auth.offset_bits,
6838 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6841 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6843 ut_params->obuf = (op_mode == IN_PLACE ?
6844 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6847 if (ut_params->obuf)
6848 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6849 plaintext_len, buffer);
6851 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6852 plaintext_len, buffer);
6854 debug_hexdump(stdout, "plaintext:", plaintext,
6855 (tdata->plaintext.len_bits >> 3) -
6856 tdata->digest_enc.len);
6857 debug_hexdump(stdout, "plaintext expected:",
6858 tdata->plaintext.data,
6859 (tdata->plaintext.len_bits >> 3) -
6860 tdata->digest_enc.len);
6862 if (ut_params->obuf)
6863 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6864 ciphertext_len, buffer);
6866 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6867 ciphertext_len, buffer);
6869 debug_hexdump(stdout, "ciphertext:", ciphertext,
6871 debug_hexdump(stdout, "ciphertext expected:",
6872 tdata->ciphertext.data,
6873 tdata->ciphertext.len_bits >> 3);
6875 if (ut_params->obuf)
6876 digest = rte_pktmbuf_read(ut_params->obuf,
6877 (tdata->digest_enc.offset == 0 ?
6879 tdata->digest_enc.offset),
6880 tdata->digest_enc.len, digest_buffer);
6882 digest = rte_pktmbuf_read(ut_params->ibuf,
6883 (tdata->digest_enc.offset == 0 ?
6885 tdata->digest_enc.offset),
6886 tdata->digest_enc.len, digest_buffer);
6888 debug_hexdump(stdout, "digest:", digest,
6889 tdata->digest_enc.len);
6890 debug_hexdump(stdout, "digest expected:",
6891 tdata->digest_enc.data, tdata->digest_enc.len);
6896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6898 tdata->plaintext.data,
6899 tdata->plaintext.len_bits >> 3,
6900 "Plaintext data not as expected");
6902 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6904 tdata->ciphertext.data,
6905 tdata->validDataLen.len_bits,
6906 "Ciphertext data not as expected");
6907 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6909 tdata->digest_enc.data,
6910 tdata->digest_enc.len,
6911 "Generated auth tag not as expected");
6916 /** AUTH AES CMAC + CIPHER AES CTR */
6919 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6921 return test_mixed_auth_cipher(
6922 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6926 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6928 return test_mixed_auth_cipher(
6929 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6933 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6935 return test_mixed_auth_cipher_sgl(
6936 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6940 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6942 return test_mixed_auth_cipher_sgl(
6943 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6947 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6949 return test_mixed_auth_cipher(
6950 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6954 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6956 return test_mixed_auth_cipher(
6957 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6961 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6963 return test_mixed_auth_cipher_sgl(
6964 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6968 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6970 return test_mixed_auth_cipher_sgl(
6971 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6975 test_3DES_chain_qat_all(void)
6977 struct crypto_testsuite_params *ts_params = &testsuite_params;
6980 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6981 ts_params->op_mpool,
6982 ts_params->session_mpool, ts_params->session_priv_mpool,
6983 ts_params->valid_devs[0],
6984 rte_cryptodev_driver_id_get(
6985 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6986 BLKCIPHER_3DES_CHAIN_TYPE);
6988 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6990 return TEST_SUCCESS;
6994 test_DES_cipheronly_qat_all(void)
6996 struct crypto_testsuite_params *ts_params = &testsuite_params;
6999 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7000 ts_params->op_mpool,
7001 ts_params->session_mpool, ts_params->session_priv_mpool,
7002 ts_params->valid_devs[0],
7003 rte_cryptodev_driver_id_get(
7004 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7005 BLKCIPHER_DES_CIPHERONLY_TYPE);
7007 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7009 return TEST_SUCCESS;
7013 test_DES_cipheronly_openssl_all(void)
7015 struct crypto_testsuite_params *ts_params = &testsuite_params;
7018 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7019 ts_params->op_mpool,
7020 ts_params->session_mpool, ts_params->session_priv_mpool,
7021 ts_params->valid_devs[0],
7022 rte_cryptodev_driver_id_get(
7023 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7024 BLKCIPHER_DES_CIPHERONLY_TYPE);
7026 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7028 return TEST_SUCCESS;
7032 test_DES_docsis_openssl_all(void)
7034 struct crypto_testsuite_params *ts_params = &testsuite_params;
7037 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7038 ts_params->op_mpool,
7039 ts_params->session_mpool, ts_params->session_priv_mpool,
7040 ts_params->valid_devs[0],
7041 rte_cryptodev_driver_id_get(
7042 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7043 BLKCIPHER_DES_DOCSIS_TYPE);
7045 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7047 return TEST_SUCCESS;
7051 test_DES_cipheronly_mb_all(void)
7053 struct crypto_testsuite_params *ts_params = &testsuite_params;
7056 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7057 ts_params->op_mpool,
7058 ts_params->session_mpool, ts_params->session_priv_mpool,
7059 ts_params->valid_devs[0],
7060 rte_cryptodev_driver_id_get(
7061 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7062 BLKCIPHER_DES_CIPHERONLY_TYPE);
7064 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7066 return TEST_SUCCESS;
7069 test_3DES_cipheronly_mb_all(void)
7071 struct crypto_testsuite_params *ts_params = &testsuite_params;
7074 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7075 ts_params->op_mpool,
7076 ts_params->session_mpool, ts_params->session_priv_mpool,
7077 ts_params->valid_devs[0],
7078 rte_cryptodev_driver_id_get(
7079 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7080 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7082 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7084 return TEST_SUCCESS;
7088 test_DES_docsis_mb_all(void)
7090 struct crypto_testsuite_params *ts_params = &testsuite_params;
7093 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7094 ts_params->op_mpool,
7095 ts_params->session_mpool, ts_params->session_priv_mpool,
7096 ts_params->valid_devs[0],
7097 rte_cryptodev_driver_id_get(
7098 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7099 BLKCIPHER_DES_DOCSIS_TYPE);
7101 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7103 return TEST_SUCCESS;
7107 test_3DES_chain_caam_jr_all(void)
7109 struct crypto_testsuite_params *ts_params = &testsuite_params;
7112 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7113 ts_params->op_mpool,
7114 ts_params->session_mpool, ts_params->session_priv_mpool,
7115 ts_params->valid_devs[0],
7116 rte_cryptodev_driver_id_get(
7117 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7118 BLKCIPHER_3DES_CHAIN_TYPE);
7120 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7122 return TEST_SUCCESS;
7126 test_3DES_cipheronly_caam_jr_all(void)
7128 struct crypto_testsuite_params *ts_params = &testsuite_params;
7131 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7132 ts_params->op_mpool,
7133 ts_params->session_mpool, ts_params->session_priv_mpool,
7134 ts_params->valid_devs[0],
7135 rte_cryptodev_driver_id_get(
7136 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7137 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7139 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7141 return TEST_SUCCESS;
7145 test_3DES_chain_dpaa_sec_all(void)
7147 struct crypto_testsuite_params *ts_params = &testsuite_params;
7150 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7151 ts_params->op_mpool,
7152 ts_params->session_mpool, ts_params->session_priv_mpool,
7153 ts_params->valid_devs[0],
7154 rte_cryptodev_driver_id_get(
7155 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7156 BLKCIPHER_3DES_CHAIN_TYPE);
7158 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7160 return TEST_SUCCESS;
7164 test_3DES_cipheronly_dpaa_sec_all(void)
7166 struct crypto_testsuite_params *ts_params = &testsuite_params;
7169 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7170 ts_params->op_mpool,
7171 ts_params->session_mpool, ts_params->session_priv_mpool,
7172 ts_params->valid_devs[0],
7173 rte_cryptodev_driver_id_get(
7174 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7175 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7177 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7179 return TEST_SUCCESS;
7183 test_3DES_chain_dpaa2_sec_all(void)
7185 struct crypto_testsuite_params *ts_params = &testsuite_params;
7188 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7189 ts_params->op_mpool,
7190 ts_params->session_mpool, ts_params->session_priv_mpool,
7191 ts_params->valid_devs[0],
7192 rte_cryptodev_driver_id_get(
7193 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7194 BLKCIPHER_3DES_CHAIN_TYPE);
7196 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7198 return TEST_SUCCESS;
7202 test_3DES_cipheronly_dpaa2_sec_all(void)
7204 struct crypto_testsuite_params *ts_params = &testsuite_params;
7207 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7208 ts_params->op_mpool,
7209 ts_params->session_mpool, ts_params->session_priv_mpool,
7210 ts_params->valid_devs[0],
7211 rte_cryptodev_driver_id_get(
7212 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7213 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7215 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7217 return TEST_SUCCESS;
7221 test_3DES_chain_ccp_all(void)
7223 struct crypto_testsuite_params *ts_params = &testsuite_params;
7226 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7227 ts_params->op_mpool,
7228 ts_params->session_mpool, ts_params->session_priv_mpool,
7229 ts_params->valid_devs[0],
7230 rte_cryptodev_driver_id_get(
7231 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7232 BLKCIPHER_3DES_CHAIN_TYPE);
7234 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7236 return TEST_SUCCESS;
7240 test_3DES_cipheronly_ccp_all(void)
7242 struct crypto_testsuite_params *ts_params = &testsuite_params;
7245 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7246 ts_params->op_mpool,
7247 ts_params->session_mpool, ts_params->session_priv_mpool,
7248 ts_params->valid_devs[0],
7249 rte_cryptodev_driver_id_get(
7250 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7251 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7253 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7255 return TEST_SUCCESS;
7259 test_3DES_cipheronly_qat_all(void)
7261 struct crypto_testsuite_params *ts_params = &testsuite_params;
7264 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7265 ts_params->op_mpool,
7266 ts_params->session_mpool, ts_params->session_priv_mpool,
7267 ts_params->valid_devs[0],
7268 rte_cryptodev_driver_id_get(
7269 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7270 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7272 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7274 return TEST_SUCCESS;
7278 test_3DES_chain_openssl_all(void)
7280 struct crypto_testsuite_params *ts_params = &testsuite_params;
7283 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7284 ts_params->op_mpool,
7285 ts_params->session_mpool, ts_params->session_priv_mpool,
7286 ts_params->valid_devs[0],
7287 rte_cryptodev_driver_id_get(
7288 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7289 BLKCIPHER_3DES_CHAIN_TYPE);
7291 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7293 return TEST_SUCCESS;
7297 test_3DES_cipheronly_openssl_all(void)
7299 struct crypto_testsuite_params *ts_params = &testsuite_params;
7302 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7303 ts_params->op_mpool,
7304 ts_params->session_mpool, ts_params->session_priv_mpool,
7305 ts_params->valid_devs[0],
7306 rte_cryptodev_driver_id_get(
7307 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7308 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7310 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7312 return TEST_SUCCESS;
7315 /* ***** AEAD algorithm Tests ***** */
7318 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7319 enum rte_crypto_aead_operation op,
7320 const uint8_t *key, const uint8_t key_len,
7321 const uint16_t aad_len, const uint8_t auth_len,
7324 uint8_t aead_key[key_len];
7326 struct crypto_testsuite_params *ts_params = &testsuite_params;
7327 struct crypto_unittest_params *ut_params = &unittest_params;
7329 memcpy(aead_key, key, key_len);
7331 /* Setup AEAD Parameters */
7332 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7333 ut_params->aead_xform.next = NULL;
7334 ut_params->aead_xform.aead.algo = algo;
7335 ut_params->aead_xform.aead.op = op;
7336 ut_params->aead_xform.aead.key.data = aead_key;
7337 ut_params->aead_xform.aead.key.length = key_len;
7338 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7339 ut_params->aead_xform.aead.iv.length = iv_len;
7340 ut_params->aead_xform.aead.digest_length = auth_len;
7341 ut_params->aead_xform.aead.aad_length = aad_len;
7343 debug_hexdump(stdout, "key:", key, key_len);
7345 /* Create Crypto session*/
7346 ut_params->sess = rte_cryptodev_sym_session_create(
7347 ts_params->session_mpool);
7349 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7350 &ut_params->aead_xform,
7351 ts_params->session_priv_mpool);
7353 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7359 create_aead_xform(struct rte_crypto_op *op,
7360 enum rte_crypto_aead_algorithm algo,
7361 enum rte_crypto_aead_operation aead_op,
7362 uint8_t *key, const uint8_t key_len,
7363 const uint8_t aad_len, const uint8_t auth_len,
7366 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7367 "failed to allocate space for crypto transform");
7369 struct rte_crypto_sym_op *sym_op = op->sym;
7371 /* Setup AEAD Parameters */
7372 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7373 sym_op->xform->next = NULL;
7374 sym_op->xform->aead.algo = algo;
7375 sym_op->xform->aead.op = aead_op;
7376 sym_op->xform->aead.key.data = key;
7377 sym_op->xform->aead.key.length = key_len;
7378 sym_op->xform->aead.iv.offset = IV_OFFSET;
7379 sym_op->xform->aead.iv.length = iv_len;
7380 sym_op->xform->aead.digest_length = auth_len;
7381 sym_op->xform->aead.aad_length = aad_len;
7383 debug_hexdump(stdout, "key:", key, key_len);
7389 create_aead_operation(enum rte_crypto_aead_operation op,
7390 const struct aead_test_data *tdata)
7392 struct crypto_testsuite_params *ts_params = &testsuite_params;
7393 struct crypto_unittest_params *ut_params = &unittest_params;
7395 uint8_t *plaintext, *ciphertext;
7396 unsigned int aad_pad_len, plaintext_pad_len;
7398 /* Generate Crypto op data structure */
7399 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7400 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7401 TEST_ASSERT_NOT_NULL(ut_params->op,
7402 "Failed to allocate symmetric crypto operation struct");
7404 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7406 /* Append aad data */
7407 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7408 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7409 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7411 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7412 "no room to append aad");
7414 sym_op->aead.aad.phys_addr =
7415 rte_pktmbuf_iova(ut_params->ibuf);
7416 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7417 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7418 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7421 /* Append IV at the end of the crypto operation*/
7422 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7423 uint8_t *, IV_OFFSET);
7425 /* Copy IV 1 byte after the IV pointer, according to the API */
7426 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7427 debug_hexdump(stdout, "iv:", iv_ptr,
7430 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7431 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7433 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7434 "no room to append aad");
7436 sym_op->aead.aad.phys_addr =
7437 rte_pktmbuf_iova(ut_params->ibuf);
7438 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7439 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7442 /* Append IV at the end of the crypto operation*/
7443 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7444 uint8_t *, IV_OFFSET);
7446 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7447 debug_hexdump(stdout, "iv:", iv_ptr,
7451 /* Append plaintext/ciphertext */
7452 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7453 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7456 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7458 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7459 debug_hexdump(stdout, "plaintext:", plaintext,
7460 tdata->plaintext.len);
7462 if (ut_params->obuf) {
7463 ciphertext = (uint8_t *)rte_pktmbuf_append(
7465 plaintext_pad_len + aad_pad_len);
7466 TEST_ASSERT_NOT_NULL(ciphertext,
7467 "no room to append ciphertext");
7469 memset(ciphertext + aad_pad_len, 0,
7470 tdata->ciphertext.len);
7473 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7474 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7476 TEST_ASSERT_NOT_NULL(ciphertext,
7477 "no room to append ciphertext");
7479 memcpy(ciphertext, tdata->ciphertext.data,
7480 tdata->ciphertext.len);
7481 debug_hexdump(stdout, "ciphertext:", ciphertext,
7482 tdata->ciphertext.len);
7484 if (ut_params->obuf) {
7485 plaintext = (uint8_t *)rte_pktmbuf_append(
7487 plaintext_pad_len + aad_pad_len);
7488 TEST_ASSERT_NOT_NULL(plaintext,
7489 "no room to append plaintext");
7491 memset(plaintext + aad_pad_len, 0,
7492 tdata->plaintext.len);
7496 /* Append digest data */
7497 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7498 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7499 ut_params->obuf ? ut_params->obuf :
7501 tdata->auth_tag.len);
7502 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7503 "no room to append digest");
7504 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7505 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7506 ut_params->obuf ? ut_params->obuf :
7511 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7512 ut_params->ibuf, tdata->auth_tag.len);
7513 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7514 "no room to append digest");
7515 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7517 plaintext_pad_len + aad_pad_len);
7519 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7520 tdata->auth_tag.len);
7521 debug_hexdump(stdout, "digest:",
7522 sym_op->aead.digest.data,
7523 tdata->auth_tag.len);
7526 sym_op->aead.data.length = tdata->plaintext.len;
7527 sym_op->aead.data.offset = aad_pad_len;
7533 test_authenticated_encryption(const struct aead_test_data *tdata)
7535 struct crypto_testsuite_params *ts_params = &testsuite_params;
7536 struct crypto_unittest_params *ut_params = &unittest_params;
7539 uint8_t *ciphertext, *auth_tag;
7540 uint16_t plaintext_pad_len;
7543 /* Create AEAD session */
7544 retval = create_aead_session(ts_params->valid_devs[0],
7546 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7547 tdata->key.data, tdata->key.len,
7548 tdata->aad.len, tdata->auth_tag.len,
7553 if (tdata->aad.len > MBUF_SIZE) {
7554 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7555 /* Populate full size of add data */
7556 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7557 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7561 /* clear mbuf payload */
7562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7563 rte_pktmbuf_tailroom(ut_params->ibuf));
7565 /* Create AEAD operation */
7566 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7570 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7572 ut_params->op->sym->m_src = ut_params->ibuf;
7574 /* Process crypto operation */
7575 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7576 ut_params->op), "failed to process sym crypto op");
7578 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7579 "crypto op processing failed");
7581 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7583 if (ut_params->op->sym->m_dst) {
7584 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7586 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7587 uint8_t *, plaintext_pad_len);
7589 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7591 ut_params->op->sym->cipher.data.offset);
7592 auth_tag = ciphertext + plaintext_pad_len;
7595 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7596 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7599 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7601 tdata->ciphertext.data,
7602 tdata->ciphertext.len,
7603 "Ciphertext data not as expected");
7605 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7607 tdata->auth_tag.data,
7608 tdata->auth_tag.len,
7609 "Generated auth tag not as expected");
7615 #ifdef RTE_LIBRTE_SECURITY
7616 /* Basic algorithm run function for async inplace mode.
7617 * Creates a session from input parameters and runs one operation
7618 * on input_vec. Checks the output of the crypto operation against
7622 test_pdcp_proto(int i, int oop,
7623 enum rte_crypto_cipher_operation opc,
7624 enum rte_crypto_auth_operation opa,
7626 unsigned int input_vec_len,
7627 uint8_t *output_vec,
7628 unsigned int output_vec_len)
7630 struct crypto_testsuite_params *ts_params = &testsuite_params;
7631 struct crypto_unittest_params *ut_params = &unittest_params;
7633 int ret = TEST_SUCCESS;
7635 /* Generate test mbuf data */
7636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7638 /* clear mbuf payload */
7639 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7640 rte_pktmbuf_tailroom(ut_params->ibuf));
7642 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7644 memcpy(plaintext, input_vec, input_vec_len);
7646 /* Out of place support */
7649 * For out-op-place we need to alloc another mbuf
7651 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7652 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7655 /* Set crypto type as IPSEC */
7656 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7658 /* Setup Cipher Parameters */
7659 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7660 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7661 ut_params->cipher_xform.cipher.op = opc;
7662 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7663 ut_params->cipher_xform.cipher.key.length =
7664 pdcp_test_params[i].cipher_key_len;
7665 ut_params->cipher_xform.cipher.iv.length = 0;
7667 /* Setup HMAC Parameters if ICV header is required */
7668 if (pdcp_test_params[i].auth_alg != 0) {
7669 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7670 ut_params->auth_xform.next = NULL;
7671 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7672 ut_params->auth_xform.auth.op = opa;
7673 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7674 ut_params->auth_xform.auth.key.length =
7675 pdcp_test_params[i].auth_key_len;
7677 ut_params->cipher_xform.next = &ut_params->auth_xform;
7679 ut_params->cipher_xform.next = NULL;
7682 struct rte_security_session_conf sess_conf = {
7683 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7684 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7686 .bearer = pdcp_test_bearer[i],
7687 .domain = pdcp_test_params[i].domain,
7688 .pkt_dir = pdcp_test_packet_direction[i],
7689 .sn_size = pdcp_test_data_sn_size[i],
7690 .hfn = pdcp_test_hfn[i],
7691 .hfn_threshold = pdcp_test_hfn_threshold[i],
7693 .crypto_xform = &ut_params->cipher_xform
7696 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7697 rte_cryptodev_get_sec_ctx(
7698 ts_params->valid_devs[0]);
7700 /* Create security session */
7701 ut_params->sec_session = rte_security_session_create(ctx,
7702 &sess_conf, ts_params->session_priv_mpool);
7704 if (!ut_params->sec_session) {
7705 printf("TestCase %s()-%d line %d failed %s: ",
7706 __func__, i, __LINE__, "Failed to allocate session");
7711 /* Generate crypto op data structure */
7712 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7713 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7714 if (!ut_params->op) {
7715 printf("TestCase %s()-%d line %d failed %s: ",
7716 __func__, i, __LINE__,
7717 "Failed to allocate symmetric crypto operation struct");
7722 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7724 /* set crypto operation source mbuf */
7725 ut_params->op->sym->m_src = ut_params->ibuf;
7727 ut_params->op->sym->m_dst = ut_params->obuf;
7729 /* Process crypto operation */
7730 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7732 printf("TestCase %s()-%d line %d failed %s: ",
7733 __func__, i, __LINE__,
7734 "failed to process sym crypto op");
7739 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7740 printf("TestCase %s()-%d line %d failed %s: ",
7741 __func__, i, __LINE__, "crypto op processing failed");
7747 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7750 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7754 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7755 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7756 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7757 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7763 rte_crypto_op_free(ut_params->op);
7764 ut_params->op = NULL;
7766 if (ut_params->sec_session)
7767 rte_security_session_destroy(ctx, ut_params->sec_session);
7768 ut_params->sec_session = NULL;
7770 rte_pktmbuf_free(ut_params->ibuf);
7771 ut_params->ibuf = NULL;
7773 rte_pktmbuf_free(ut_params->obuf);
7774 ut_params->obuf = NULL;
7781 test_pdcp_proto_SGL(int i, int oop,
7782 enum rte_crypto_cipher_operation opc,
7783 enum rte_crypto_auth_operation opa,
7785 unsigned int input_vec_len,
7786 uint8_t *output_vec,
7787 unsigned int output_vec_len,
7789 uint32_t fragsz_oop)
7791 struct crypto_testsuite_params *ts_params = &testsuite_params;
7792 struct crypto_unittest_params *ut_params = &unittest_params;
7794 struct rte_mbuf *buf, *buf_oop = NULL;
7795 int ret = TEST_SUCCESS;
7799 unsigned int trn_data = 0;
7801 if (fragsz > input_vec_len)
7802 fragsz = input_vec_len;
7804 uint16_t plaintext_len = fragsz;
7805 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7807 if (fragsz_oop > output_vec_len)
7808 frag_size_oop = output_vec_len;
7811 if (input_vec_len % fragsz != 0) {
7812 if (input_vec_len / fragsz + 1 > 16)
7814 } else if (input_vec_len / fragsz > 16)
7817 /* Out of place support */
7820 * For out-op-place we need to alloc another mbuf
7822 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7823 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7824 buf_oop = ut_params->obuf;
7827 /* Generate test mbuf data */
7828 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7830 /* clear mbuf payload */
7831 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7832 rte_pktmbuf_tailroom(ut_params->ibuf));
7834 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7836 memcpy(plaintext, input_vec, plaintext_len);
7837 trn_data += plaintext_len;
7839 buf = ut_params->ibuf;
7842 * Loop until no more fragments
7845 while (trn_data < input_vec_len) {
7847 to_trn = (input_vec_len - trn_data < fragsz) ?
7848 (input_vec_len - trn_data) : fragsz;
7850 to_trn_tbl[ecx++] = to_trn;
7852 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7855 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7856 rte_pktmbuf_tailroom(buf));
7859 if (oop && !fragsz_oop) {
7861 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7862 buf_oop = buf_oop->next;
7863 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7864 0, rte_pktmbuf_tailroom(buf_oop));
7865 rte_pktmbuf_append(buf_oop, to_trn);
7868 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7871 memcpy(plaintext, input_vec + trn_data, to_trn);
7875 ut_params->ibuf->nb_segs = segs;
7878 if (fragsz_oop && oop) {
7882 trn_data = frag_size_oop;
7883 while (trn_data < output_vec_len) {
7886 (output_vec_len - trn_data <
7888 (output_vec_len - trn_data) :
7891 to_trn_tbl[ecx++] = to_trn;
7894 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7895 buf_oop = buf_oop->next;
7896 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7897 0, rte_pktmbuf_tailroom(buf_oop));
7898 rte_pktmbuf_append(buf_oop, to_trn);
7902 ut_params->obuf->nb_segs = segs;
7905 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7907 /* Setup Cipher Parameters */
7908 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7909 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7910 ut_params->cipher_xform.cipher.op = opc;
7911 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7912 ut_params->cipher_xform.cipher.key.length =
7913 pdcp_test_params[i].cipher_key_len;
7914 ut_params->cipher_xform.cipher.iv.length = 0;
7916 /* Setup HMAC Parameters if ICV header is required */
7917 if (pdcp_test_params[i].auth_alg != 0) {
7918 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7919 ut_params->auth_xform.next = NULL;
7920 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7921 ut_params->auth_xform.auth.op = opa;
7922 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7923 ut_params->auth_xform.auth.key.length =
7924 pdcp_test_params[i].auth_key_len;
7926 ut_params->cipher_xform.next = &ut_params->auth_xform;
7928 ut_params->cipher_xform.next = NULL;
7931 struct rte_security_session_conf sess_conf = {
7932 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7933 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7935 .bearer = pdcp_test_bearer[i],
7936 .domain = pdcp_test_params[i].domain,
7937 .pkt_dir = pdcp_test_packet_direction[i],
7938 .sn_size = pdcp_test_data_sn_size[i],
7939 .hfn = pdcp_test_hfn[i],
7940 .hfn_threshold = pdcp_test_hfn_threshold[i],
7942 .crypto_xform = &ut_params->cipher_xform
7945 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7946 rte_cryptodev_get_sec_ctx(
7947 ts_params->valid_devs[0]);
7949 /* Create security session */
7950 ut_params->sec_session = rte_security_session_create(ctx,
7951 &sess_conf, ts_params->session_priv_mpool);
7953 if (!ut_params->sec_session) {
7954 printf("TestCase %s()-%d line %d failed %s: ",
7955 __func__, i, __LINE__, "Failed to allocate session");
7960 /* Generate crypto op data structure */
7961 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7962 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7963 if (!ut_params->op) {
7964 printf("TestCase %s()-%d line %d failed %s: ",
7965 __func__, i, __LINE__,
7966 "Failed to allocate symmetric crypto operation struct");
7971 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7973 /* set crypto operation source mbuf */
7974 ut_params->op->sym->m_src = ut_params->ibuf;
7976 ut_params->op->sym->m_dst = ut_params->obuf;
7978 /* Process crypto operation */
7979 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7981 printf("TestCase %s()-%d line %d failed %s: ",
7982 __func__, i, __LINE__,
7983 "failed to process sym crypto op");
7988 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7989 printf("TestCase %s()-%d line %d failed %s: ",
7990 __func__, i, __LINE__, "crypto op processing failed");
7996 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7999 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8003 fragsz = frag_size_oop;
8004 if (memcmp(ciphertext, output_vec, fragsz)) {
8005 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8006 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8007 rte_hexdump(stdout, "reference", output_vec, fragsz);
8012 buf = ut_params->op->sym->m_src->next;
8014 buf = ut_params->op->sym->m_dst->next;
8016 unsigned int off = fragsz;
8020 ciphertext = rte_pktmbuf_mtod(buf,
8022 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8023 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8024 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8025 rte_hexdump(stdout, "reference", output_vec + off,
8030 off += to_trn_tbl[ecx++];
8034 rte_crypto_op_free(ut_params->op);
8035 ut_params->op = NULL;
8037 if (ut_params->sec_session)
8038 rte_security_session_destroy(ctx, ut_params->sec_session);
8039 ut_params->sec_session = NULL;
8041 rte_pktmbuf_free(ut_params->ibuf);
8042 ut_params->ibuf = NULL;
8044 rte_pktmbuf_free(ut_params->obuf);
8045 ut_params->obuf = NULL;
8052 test_pdcp_proto_cplane_encap(int i)
8054 return test_pdcp_proto(i, 0,
8055 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8056 RTE_CRYPTO_AUTH_OP_GENERATE,
8057 pdcp_test_data_in[i],
8058 pdcp_test_data_in_len[i],
8059 pdcp_test_data_out[i],
8060 pdcp_test_data_in_len[i]+4);
8064 test_pdcp_proto_uplane_encap(int i)
8066 return test_pdcp_proto(i, 0,
8067 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8068 RTE_CRYPTO_AUTH_OP_GENERATE,
8069 pdcp_test_data_in[i],
8070 pdcp_test_data_in_len[i],
8071 pdcp_test_data_out[i],
8072 pdcp_test_data_in_len[i]);
8077 test_pdcp_proto_uplane_encap_with_int(int i)
8079 return test_pdcp_proto(i, 0,
8080 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8081 RTE_CRYPTO_AUTH_OP_GENERATE,
8082 pdcp_test_data_in[i],
8083 pdcp_test_data_in_len[i],
8084 pdcp_test_data_out[i],
8085 pdcp_test_data_in_len[i] + 4);
8089 test_pdcp_proto_cplane_decap(int i)
8091 return test_pdcp_proto(i, 0,
8092 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8093 RTE_CRYPTO_AUTH_OP_VERIFY,
8094 pdcp_test_data_out[i],
8095 pdcp_test_data_in_len[i] + 4,
8096 pdcp_test_data_in[i],
8097 pdcp_test_data_in_len[i]);
8101 test_pdcp_proto_uplane_decap(int i)
8103 return test_pdcp_proto(i, 0,
8104 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8105 RTE_CRYPTO_AUTH_OP_VERIFY,
8106 pdcp_test_data_out[i],
8107 pdcp_test_data_in_len[i],
8108 pdcp_test_data_in[i],
8109 pdcp_test_data_in_len[i]);
8113 test_pdcp_proto_uplane_decap_with_int(int i)
8115 return test_pdcp_proto(i, 0,
8116 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8117 RTE_CRYPTO_AUTH_OP_VERIFY,
8118 pdcp_test_data_out[i],
8119 pdcp_test_data_in_len[i] + 4,
8120 pdcp_test_data_in[i],
8121 pdcp_test_data_in_len[i]);
8125 test_PDCP_PROTO_SGL_in_place_32B(void)
8127 /* i can be used for running any PDCP case
8128 * In this case it is uplane 12-bit AES-SNOW DL encap
8130 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8131 return test_pdcp_proto_SGL(i, IN_PLACE,
8132 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8133 RTE_CRYPTO_AUTH_OP_GENERATE,
8134 pdcp_test_data_in[i],
8135 pdcp_test_data_in_len[i],
8136 pdcp_test_data_out[i],
8137 pdcp_test_data_in_len[i]+4,
8141 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8143 /* i can be used for running any PDCP case
8144 * In this case it is uplane 18-bit NULL-NULL DL encap
8146 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8147 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8148 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8149 RTE_CRYPTO_AUTH_OP_GENERATE,
8150 pdcp_test_data_in[i],
8151 pdcp_test_data_in_len[i],
8152 pdcp_test_data_out[i],
8153 pdcp_test_data_in_len[i]+4,
8157 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8159 /* i can be used for running any PDCP case
8160 * In this case it is uplane 18-bit AES DL encap
8162 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8164 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8165 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8166 RTE_CRYPTO_AUTH_OP_GENERATE,
8167 pdcp_test_data_in[i],
8168 pdcp_test_data_in_len[i],
8169 pdcp_test_data_out[i],
8170 pdcp_test_data_in_len[i],
8174 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8176 /* i can be used for running any PDCP case
8177 * In this case it is cplane 12-bit AES-ZUC DL encap
8179 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8180 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8181 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8182 RTE_CRYPTO_AUTH_OP_GENERATE,
8183 pdcp_test_data_in[i],
8184 pdcp_test_data_in_len[i],
8185 pdcp_test_data_out[i],
8186 pdcp_test_data_in_len[i]+4,
8192 test_AES_GCM_authenticated_encryption_test_case_1(void)
8194 return test_authenticated_encryption(&gcm_test_case_1);
8198 test_AES_GCM_authenticated_encryption_test_case_2(void)
8200 return test_authenticated_encryption(&gcm_test_case_2);
8204 test_AES_GCM_authenticated_encryption_test_case_3(void)
8206 return test_authenticated_encryption(&gcm_test_case_3);
8210 test_AES_GCM_authenticated_encryption_test_case_4(void)
8212 return test_authenticated_encryption(&gcm_test_case_4);
8216 test_AES_GCM_authenticated_encryption_test_case_5(void)
8218 return test_authenticated_encryption(&gcm_test_case_5);
8222 test_AES_GCM_authenticated_encryption_test_case_6(void)
8224 return test_authenticated_encryption(&gcm_test_case_6);
8228 test_AES_GCM_authenticated_encryption_test_case_7(void)
8230 return test_authenticated_encryption(&gcm_test_case_7);
8234 test_AES_GCM_authenticated_encryption_test_case_8(void)
8236 return test_authenticated_encryption(&gcm_test_case_8);
8240 test_AES_GCM_auth_encryption_test_case_192_1(void)
8242 return test_authenticated_encryption(&gcm_test_case_192_1);
8246 test_AES_GCM_auth_encryption_test_case_192_2(void)
8248 return test_authenticated_encryption(&gcm_test_case_192_2);
8252 test_AES_GCM_auth_encryption_test_case_192_3(void)
8254 return test_authenticated_encryption(&gcm_test_case_192_3);
8258 test_AES_GCM_auth_encryption_test_case_192_4(void)
8260 return test_authenticated_encryption(&gcm_test_case_192_4);
8264 test_AES_GCM_auth_encryption_test_case_192_5(void)
8266 return test_authenticated_encryption(&gcm_test_case_192_5);
8270 test_AES_GCM_auth_encryption_test_case_192_6(void)
8272 return test_authenticated_encryption(&gcm_test_case_192_6);
8276 test_AES_GCM_auth_encryption_test_case_192_7(void)
8278 return test_authenticated_encryption(&gcm_test_case_192_7);
8282 test_AES_GCM_auth_encryption_test_case_256_1(void)
8284 return test_authenticated_encryption(&gcm_test_case_256_1);
8288 test_AES_GCM_auth_encryption_test_case_256_2(void)
8290 return test_authenticated_encryption(&gcm_test_case_256_2);
8294 test_AES_GCM_auth_encryption_test_case_256_3(void)
8296 return test_authenticated_encryption(&gcm_test_case_256_3);
8300 test_AES_GCM_auth_encryption_test_case_256_4(void)
8302 return test_authenticated_encryption(&gcm_test_case_256_4);
8306 test_AES_GCM_auth_encryption_test_case_256_5(void)
8308 return test_authenticated_encryption(&gcm_test_case_256_5);
8312 test_AES_GCM_auth_encryption_test_case_256_6(void)
8314 return test_authenticated_encryption(&gcm_test_case_256_6);
8318 test_AES_GCM_auth_encryption_test_case_256_7(void)
8320 return test_authenticated_encryption(&gcm_test_case_256_7);
8324 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8326 return test_authenticated_encryption(&gcm_test_case_aad_1);
8330 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8332 return test_authenticated_encryption(&gcm_test_case_aad_2);
8336 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8338 struct aead_test_data tdata;
8341 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8342 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8343 tdata.iv.data[0] += 1;
8344 res = test_authenticated_encryption(&tdata);
8345 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8346 return TEST_SUCCESS;
8350 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8352 struct aead_test_data tdata;
8355 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8356 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8357 tdata.plaintext.data[0] += 1;
8358 res = test_authenticated_encryption(&tdata);
8359 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8360 return TEST_SUCCESS;
8364 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8366 struct aead_test_data tdata;
8369 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8370 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8371 tdata.ciphertext.data[0] += 1;
8372 res = test_authenticated_encryption(&tdata);
8373 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8374 return TEST_SUCCESS;
8378 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8380 struct aead_test_data tdata;
8383 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8384 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8386 res = test_authenticated_encryption(&tdata);
8387 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8388 return TEST_SUCCESS;
8392 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8394 struct aead_test_data tdata;
8395 uint8_t aad[gcm_test_case_7.aad.len];
8398 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8399 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8400 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8402 tdata.aad.data = aad;
8403 res = test_authenticated_encryption(&tdata);
8404 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8405 return TEST_SUCCESS;
8409 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8411 struct aead_test_data tdata;
8414 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8415 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8416 tdata.auth_tag.data[0] += 1;
8417 res = test_authenticated_encryption(&tdata);
8418 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8419 return TEST_SUCCESS;
8423 test_authenticated_decryption(const struct aead_test_data *tdata)
8425 struct crypto_testsuite_params *ts_params = &testsuite_params;
8426 struct crypto_unittest_params *ut_params = &unittest_params;
8432 /* Create AEAD session */
8433 retval = create_aead_session(ts_params->valid_devs[0],
8435 RTE_CRYPTO_AEAD_OP_DECRYPT,
8436 tdata->key.data, tdata->key.len,
8437 tdata->aad.len, tdata->auth_tag.len,
8442 /* alloc mbuf and set payload */
8443 if (tdata->aad.len > MBUF_SIZE) {
8444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8445 /* Populate full size of add data */
8446 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8447 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8449 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8451 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8452 rte_pktmbuf_tailroom(ut_params->ibuf));
8454 /* Create AEAD operation */
8455 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8459 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8461 ut_params->op->sym->m_src = ut_params->ibuf;
8463 /* Process crypto operation */
8464 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8465 ut_params->op), "failed to process sym crypto op");
8467 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8468 "crypto op processing failed");
8470 if (ut_params->op->sym->m_dst)
8471 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8474 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8476 ut_params->op->sym->cipher.data.offset);
8478 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8483 tdata->plaintext.data,
8484 tdata->plaintext.len,
8485 "Plaintext data not as expected");
8487 TEST_ASSERT_EQUAL(ut_params->op->status,
8488 RTE_CRYPTO_OP_STATUS_SUCCESS,
8489 "Authentication failed");
8495 test_AES_GCM_authenticated_decryption_test_case_1(void)
8497 return test_authenticated_decryption(&gcm_test_case_1);
8501 test_AES_GCM_authenticated_decryption_test_case_2(void)
8503 return test_authenticated_decryption(&gcm_test_case_2);
8507 test_AES_GCM_authenticated_decryption_test_case_3(void)
8509 return test_authenticated_decryption(&gcm_test_case_3);
8513 test_AES_GCM_authenticated_decryption_test_case_4(void)
8515 return test_authenticated_decryption(&gcm_test_case_4);
8519 test_AES_GCM_authenticated_decryption_test_case_5(void)
8521 return test_authenticated_decryption(&gcm_test_case_5);
8525 test_AES_GCM_authenticated_decryption_test_case_6(void)
8527 return test_authenticated_decryption(&gcm_test_case_6);
8531 test_AES_GCM_authenticated_decryption_test_case_7(void)
8533 return test_authenticated_decryption(&gcm_test_case_7);
8537 test_AES_GCM_authenticated_decryption_test_case_8(void)
8539 return test_authenticated_decryption(&gcm_test_case_8);
8543 test_AES_GCM_auth_decryption_test_case_192_1(void)
8545 return test_authenticated_decryption(&gcm_test_case_192_1);
8549 test_AES_GCM_auth_decryption_test_case_192_2(void)
8551 return test_authenticated_decryption(&gcm_test_case_192_2);
8555 test_AES_GCM_auth_decryption_test_case_192_3(void)
8557 return test_authenticated_decryption(&gcm_test_case_192_3);
8561 test_AES_GCM_auth_decryption_test_case_192_4(void)
8563 return test_authenticated_decryption(&gcm_test_case_192_4);
8567 test_AES_GCM_auth_decryption_test_case_192_5(void)
8569 return test_authenticated_decryption(&gcm_test_case_192_5);
8573 test_AES_GCM_auth_decryption_test_case_192_6(void)
8575 return test_authenticated_decryption(&gcm_test_case_192_6);
8579 test_AES_GCM_auth_decryption_test_case_192_7(void)
8581 return test_authenticated_decryption(&gcm_test_case_192_7);
8585 test_AES_GCM_auth_decryption_test_case_256_1(void)
8587 return test_authenticated_decryption(&gcm_test_case_256_1);
8591 test_AES_GCM_auth_decryption_test_case_256_2(void)
8593 return test_authenticated_decryption(&gcm_test_case_256_2);
8597 test_AES_GCM_auth_decryption_test_case_256_3(void)
8599 return test_authenticated_decryption(&gcm_test_case_256_3);
8603 test_AES_GCM_auth_decryption_test_case_256_4(void)
8605 return test_authenticated_decryption(&gcm_test_case_256_4);
8609 test_AES_GCM_auth_decryption_test_case_256_5(void)
8611 return test_authenticated_decryption(&gcm_test_case_256_5);
8615 test_AES_GCM_auth_decryption_test_case_256_6(void)
8617 return test_authenticated_decryption(&gcm_test_case_256_6);
8621 test_AES_GCM_auth_decryption_test_case_256_7(void)
8623 return test_authenticated_decryption(&gcm_test_case_256_7);
8627 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8629 return test_authenticated_decryption(&gcm_test_case_aad_1);
8633 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8635 return test_authenticated_decryption(&gcm_test_case_aad_2);
8639 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8641 struct aead_test_data tdata;
8644 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8645 tdata.iv.data[0] += 1;
8646 res = test_authenticated_decryption(&tdata);
8647 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8648 return TEST_SUCCESS;
8652 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8654 struct aead_test_data tdata;
8657 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8658 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8659 tdata.plaintext.data[0] += 1;
8660 res = test_authenticated_decryption(&tdata);
8661 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8662 return TEST_SUCCESS;
8666 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8668 struct aead_test_data tdata;
8671 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8672 tdata.ciphertext.data[0] += 1;
8673 res = test_authenticated_decryption(&tdata);
8674 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8675 return TEST_SUCCESS;
8679 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8681 struct aead_test_data tdata;
8684 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8686 res = test_authenticated_decryption(&tdata);
8687 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8688 return TEST_SUCCESS;
8692 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8694 struct aead_test_data tdata;
8695 uint8_t aad[gcm_test_case_7.aad.len];
8698 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8699 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8701 tdata.aad.data = aad;
8702 res = test_authenticated_decryption(&tdata);
8703 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8704 return TEST_SUCCESS;
8708 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8710 struct aead_test_data tdata;
8713 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8714 tdata.auth_tag.data[0] += 1;
8715 res = test_authenticated_decryption(&tdata);
8716 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8717 return TEST_SUCCESS;
8721 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8723 struct crypto_testsuite_params *ts_params = &testsuite_params;
8724 struct crypto_unittest_params *ut_params = &unittest_params;
8727 uint8_t *ciphertext, *auth_tag;
8728 uint16_t plaintext_pad_len;
8730 /* Create AEAD session */
8731 retval = create_aead_session(ts_params->valid_devs[0],
8733 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8734 tdata->key.data, tdata->key.len,
8735 tdata->aad.len, tdata->auth_tag.len,
8740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8741 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8743 /* clear mbuf payload */
8744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8745 rte_pktmbuf_tailroom(ut_params->ibuf));
8746 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8747 rte_pktmbuf_tailroom(ut_params->obuf));
8749 /* Create AEAD operation */
8750 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8754 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8756 ut_params->op->sym->m_src = ut_params->ibuf;
8757 ut_params->op->sym->m_dst = ut_params->obuf;
8759 /* Process crypto operation */
8760 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8761 ut_params->op), "failed to process sym crypto op");
8763 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8764 "crypto op processing failed");
8766 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8768 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8769 ut_params->op->sym->cipher.data.offset);
8770 auth_tag = ciphertext + plaintext_pad_len;
8772 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8773 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8776 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8778 tdata->ciphertext.data,
8779 tdata->ciphertext.len,
8780 "Ciphertext data not as expected");
8782 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8784 tdata->auth_tag.data,
8785 tdata->auth_tag.len,
8786 "Generated auth tag not as expected");
8793 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8795 return test_authenticated_encryption_oop(&gcm_test_case_5);
8799 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8801 struct crypto_testsuite_params *ts_params = &testsuite_params;
8802 struct crypto_unittest_params *ut_params = &unittest_params;
8807 /* Create AEAD session */
8808 retval = create_aead_session(ts_params->valid_devs[0],
8810 RTE_CRYPTO_AEAD_OP_DECRYPT,
8811 tdata->key.data, tdata->key.len,
8812 tdata->aad.len, tdata->auth_tag.len,
8817 /* alloc mbuf and set payload */
8818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8819 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8821 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8822 rte_pktmbuf_tailroom(ut_params->ibuf));
8823 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8824 rte_pktmbuf_tailroom(ut_params->obuf));
8826 /* Create AEAD operation */
8827 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8831 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8833 ut_params->op->sym->m_src = ut_params->ibuf;
8834 ut_params->op->sym->m_dst = ut_params->obuf;
8836 /* Process crypto operation */
8837 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8838 ut_params->op), "failed to process sym crypto op");
8840 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8841 "crypto op processing failed");
8843 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8844 ut_params->op->sym->cipher.data.offset);
8846 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8849 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8851 tdata->plaintext.data,
8852 tdata->plaintext.len,
8853 "Plaintext data not as expected");
8855 TEST_ASSERT_EQUAL(ut_params->op->status,
8856 RTE_CRYPTO_OP_STATUS_SUCCESS,
8857 "Authentication failed");
8862 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8864 return test_authenticated_decryption_oop(&gcm_test_case_5);
8868 test_authenticated_encryption_sessionless(
8869 const struct aead_test_data *tdata)
8871 struct crypto_testsuite_params *ts_params = &testsuite_params;
8872 struct crypto_unittest_params *ut_params = &unittest_params;
8875 uint8_t *ciphertext, *auth_tag;
8876 uint16_t plaintext_pad_len;
8877 uint8_t key[tdata->key.len + 1];
8879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8881 /* clear mbuf payload */
8882 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8883 rte_pktmbuf_tailroom(ut_params->ibuf));
8885 /* Create AEAD operation */
8886 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8890 /* Create GCM xform */
8891 memcpy(key, tdata->key.data, tdata->key.len);
8892 retval = create_aead_xform(ut_params->op,
8894 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8895 key, tdata->key.len,
8896 tdata->aad.len, tdata->auth_tag.len,
8901 ut_params->op->sym->m_src = ut_params->ibuf;
8903 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8904 RTE_CRYPTO_OP_SESSIONLESS,
8905 "crypto op session type not sessionless");
8907 /* Process crypto operation */
8908 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8909 ut_params->op), "failed to process sym crypto op");
8911 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8913 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8914 "crypto op status not success");
8916 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8918 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8919 ut_params->op->sym->cipher.data.offset);
8920 auth_tag = ciphertext + plaintext_pad_len;
8922 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8923 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8926 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8928 tdata->ciphertext.data,
8929 tdata->ciphertext.len,
8930 "Ciphertext data not as expected");
8932 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8934 tdata->auth_tag.data,
8935 tdata->auth_tag.len,
8936 "Generated auth tag not as expected");
8943 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8945 return test_authenticated_encryption_sessionless(
8950 test_authenticated_decryption_sessionless(
8951 const struct aead_test_data *tdata)
8953 struct crypto_testsuite_params *ts_params = &testsuite_params;
8954 struct crypto_unittest_params *ut_params = &unittest_params;
8958 uint8_t key[tdata->key.len + 1];
8960 /* alloc mbuf and set payload */
8961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8963 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8964 rte_pktmbuf_tailroom(ut_params->ibuf));
8966 /* Create AEAD operation */
8967 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8971 /* Create AEAD xform */
8972 memcpy(key, tdata->key.data, tdata->key.len);
8973 retval = create_aead_xform(ut_params->op,
8975 RTE_CRYPTO_AEAD_OP_DECRYPT,
8976 key, tdata->key.len,
8977 tdata->aad.len, tdata->auth_tag.len,
8982 ut_params->op->sym->m_src = ut_params->ibuf;
8984 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8985 RTE_CRYPTO_OP_SESSIONLESS,
8986 "crypto op session type not sessionless");
8988 /* Process crypto operation */
8989 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8990 ut_params->op), "failed to process sym crypto op");
8992 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8994 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8995 "crypto op status not success");
8997 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8998 ut_params->op->sym->cipher.data.offset);
9000 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9003 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9005 tdata->plaintext.data,
9006 tdata->plaintext.len,
9007 "Plaintext data not as expected");
9009 TEST_ASSERT_EQUAL(ut_params->op->status,
9010 RTE_CRYPTO_OP_STATUS_SUCCESS,
9011 "Authentication failed");
9016 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9018 return test_authenticated_decryption_sessionless(
9023 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9025 return test_authenticated_encryption(&ccm_test_case_128_1);
9029 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9031 return test_authenticated_encryption(&ccm_test_case_128_2);
9035 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9037 return test_authenticated_encryption(&ccm_test_case_128_3);
9041 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9043 return test_authenticated_decryption(&ccm_test_case_128_1);
9047 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9049 return test_authenticated_decryption(&ccm_test_case_128_2);
9053 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9055 return test_authenticated_decryption(&ccm_test_case_128_3);
9059 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9061 return test_authenticated_encryption(&ccm_test_case_192_1);
9065 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9067 return test_authenticated_encryption(&ccm_test_case_192_2);
9071 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9073 return test_authenticated_encryption(&ccm_test_case_192_3);
9077 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9079 return test_authenticated_decryption(&ccm_test_case_192_1);
9083 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9085 return test_authenticated_decryption(&ccm_test_case_192_2);
9089 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9091 return test_authenticated_decryption(&ccm_test_case_192_3);
9095 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9097 return test_authenticated_encryption(&ccm_test_case_256_1);
9101 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9103 return test_authenticated_encryption(&ccm_test_case_256_2);
9107 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9109 return test_authenticated_encryption(&ccm_test_case_256_3);
9113 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9115 return test_authenticated_decryption(&ccm_test_case_256_1);
9119 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9121 return test_authenticated_decryption(&ccm_test_case_256_2);
9125 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9127 return test_authenticated_decryption(&ccm_test_case_256_3);
9133 struct crypto_testsuite_params *ts_params = &testsuite_params;
9134 struct rte_cryptodev_stats stats;
9135 struct rte_cryptodev *dev;
9136 cryptodev_stats_get_t temp_pfn;
9138 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9139 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9140 &stats) == -ENODEV),
9141 "rte_cryptodev_stats_get invalid dev failed");
9142 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9143 "rte_cryptodev_stats_get invalid Param failed");
9144 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9145 temp_pfn = dev->dev_ops->stats_get;
9146 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9147 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9149 "rte_cryptodev_stats_get invalid Param failed");
9150 dev->dev_ops->stats_get = temp_pfn;
9152 /* Test expected values */
9154 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9156 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9158 "rte_cryptodev_stats_get failed");
9159 TEST_ASSERT((stats.enqueued_count == 1),
9160 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9161 TEST_ASSERT((stats.dequeued_count == 1),
9162 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9163 TEST_ASSERT((stats.enqueue_err_count == 0),
9164 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9165 TEST_ASSERT((stats.dequeue_err_count == 0),
9166 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9168 /* invalid device but should ignore and not reset device stats*/
9169 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9170 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9172 "rte_cryptodev_stats_get failed");
9173 TEST_ASSERT((stats.enqueued_count == 1),
9174 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9176 /* check that a valid reset clears stats */
9177 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9178 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9180 "rte_cryptodev_stats_get failed");
9181 TEST_ASSERT((stats.enqueued_count == 0),
9182 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9183 TEST_ASSERT((stats.dequeued_count == 0),
9184 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9186 return TEST_SUCCESS;
9189 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9190 struct crypto_unittest_params *ut_params,
9191 enum rte_crypto_auth_operation op,
9192 const struct HMAC_MD5_vector *test_case)
9196 memcpy(key, test_case->key.data, test_case->key.len);
9198 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9199 ut_params->auth_xform.next = NULL;
9200 ut_params->auth_xform.auth.op = op;
9202 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9204 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9205 ut_params->auth_xform.auth.key.length = test_case->key.len;
9206 ut_params->auth_xform.auth.key.data = key;
9208 ut_params->sess = rte_cryptodev_sym_session_create(
9209 ts_params->session_mpool);
9211 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9212 ut_params->sess, &ut_params->auth_xform,
9213 ts_params->session_priv_mpool);
9215 if (ut_params->sess == NULL)
9218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9220 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9221 rte_pktmbuf_tailroom(ut_params->ibuf));
9226 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9227 const struct HMAC_MD5_vector *test_case,
9228 uint8_t **plaintext)
9230 uint16_t plaintext_pad_len;
9232 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9234 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9237 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9239 memcpy(*plaintext, test_case->plaintext.data,
9240 test_case->plaintext.len);
9242 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9243 ut_params->ibuf, MD5_DIGEST_LEN);
9244 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9245 "no room to append digest");
9246 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9247 ut_params->ibuf, plaintext_pad_len);
9249 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9250 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9251 test_case->auth_tag.len);
9254 sym_op->auth.data.offset = 0;
9255 sym_op->auth.data.length = test_case->plaintext.len;
9257 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9258 ut_params->op->sym->m_src = ut_params->ibuf;
9264 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9266 uint16_t plaintext_pad_len;
9267 uint8_t *plaintext, *auth_tag;
9269 struct crypto_testsuite_params *ts_params = &testsuite_params;
9270 struct crypto_unittest_params *ut_params = &unittest_params;
9272 if (MD5_HMAC_create_session(ts_params, ut_params,
9273 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9276 /* Generate Crypto op data structure */
9277 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9278 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9279 TEST_ASSERT_NOT_NULL(ut_params->op,
9280 "Failed to allocate symmetric crypto operation struct");
9282 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9285 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9288 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9289 ut_params->op), "failed to process sym crypto op");
9291 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9292 "crypto op processing failed");
9294 if (ut_params->op->sym->m_dst) {
9295 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9296 uint8_t *, plaintext_pad_len);
9298 auth_tag = plaintext + plaintext_pad_len;
9301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9303 test_case->auth_tag.data,
9304 test_case->auth_tag.len,
9305 "HMAC_MD5 generated tag not as expected");
9307 return TEST_SUCCESS;
9311 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9315 struct crypto_testsuite_params *ts_params = &testsuite_params;
9316 struct crypto_unittest_params *ut_params = &unittest_params;
9318 if (MD5_HMAC_create_session(ts_params, ut_params,
9319 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9323 /* Generate Crypto op data structure */
9324 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9325 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9326 TEST_ASSERT_NOT_NULL(ut_params->op,
9327 "Failed to allocate symmetric crypto operation struct");
9329 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9332 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9333 ut_params->op), "failed to process sym crypto op");
9335 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9336 "HMAC_MD5 crypto op processing failed");
9338 return TEST_SUCCESS;
9342 test_MD5_HMAC_generate_case_1(void)
9344 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9348 test_MD5_HMAC_verify_case_1(void)
9350 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9354 test_MD5_HMAC_generate_case_2(void)
9356 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9360 test_MD5_HMAC_verify_case_2(void)
9362 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9366 test_multi_session(void)
9368 struct crypto_testsuite_params *ts_params = &testsuite_params;
9369 struct crypto_unittest_params *ut_params = &unittest_params;
9371 struct rte_cryptodev_info dev_info;
9372 struct rte_cryptodev_sym_session **sessions;
9376 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9377 aes_cbc_key, hmac_sha512_key);
9380 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9382 sessions = rte_malloc(NULL,
9383 (sizeof(struct rte_cryptodev_sym_session *) *
9384 MAX_NB_SESSIONS) + 1, 0);
9386 /* Create multiple crypto sessions*/
9387 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9389 sessions[i] = rte_cryptodev_sym_session_create(
9390 ts_params->session_mpool);
9392 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9393 sessions[i], &ut_params->auth_xform,
9394 ts_params->session_priv_mpool);
9395 TEST_ASSERT_NOT_NULL(sessions[i],
9396 "Session creation failed at session number %u",
9399 /* Attempt to send a request on each session */
9400 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9404 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9405 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9407 "Failed to perform decrypt on request number %u.", i);
9408 /* free crypto operation structure */
9410 rte_crypto_op_free(ut_params->op);
9413 * free mbuf - both obuf and ibuf are usually the same,
9414 * so check if they point at the same address is necessary,
9415 * to avoid freeing the mbuf twice.
9417 if (ut_params->obuf) {
9418 rte_pktmbuf_free(ut_params->obuf);
9419 if (ut_params->ibuf == ut_params->obuf)
9420 ut_params->ibuf = 0;
9421 ut_params->obuf = 0;
9423 if (ut_params->ibuf) {
9424 rte_pktmbuf_free(ut_params->ibuf);
9425 ut_params->ibuf = 0;
9429 /* Next session create should fail */
9430 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9431 sessions[i], &ut_params->auth_xform,
9432 ts_params->session_priv_mpool);
9433 TEST_ASSERT_NULL(sessions[i],
9434 "Session creation succeeded unexpectedly!");
9436 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9437 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9439 rte_cryptodev_sym_session_free(sessions[i]);
9444 return TEST_SUCCESS;
9447 struct multi_session_params {
9448 struct crypto_unittest_params ut_params;
9449 uint8_t *cipher_key;
9451 const uint8_t *cipher;
9452 const uint8_t *digest;
9456 #define MB_SESSION_NUMBER 3
9459 test_multi_session_random_usage(void)
9461 struct crypto_testsuite_params *ts_params = &testsuite_params;
9462 struct rte_cryptodev_info dev_info;
9463 struct rte_cryptodev_sym_session **sessions;
9465 struct multi_session_params ut_paramz[] = {
9468 .cipher_key = ms_aes_cbc_key0,
9469 .hmac_key = ms_hmac_key0,
9470 .cipher = ms_aes_cbc_cipher0,
9471 .digest = ms_hmac_digest0,
9472 .iv = ms_aes_cbc_iv0
9475 .cipher_key = ms_aes_cbc_key1,
9476 .hmac_key = ms_hmac_key1,
9477 .cipher = ms_aes_cbc_cipher1,
9478 .digest = ms_hmac_digest1,
9479 .iv = ms_aes_cbc_iv1
9482 .cipher_key = ms_aes_cbc_key2,
9483 .hmac_key = ms_hmac_key2,
9484 .cipher = ms_aes_cbc_cipher2,
9485 .digest = ms_hmac_digest2,
9486 .iv = ms_aes_cbc_iv2
9491 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9493 sessions = rte_malloc(NULL,
9494 (sizeof(struct rte_cryptodev_sym_session *)
9495 * MAX_NB_SESSIONS) + 1, 0);
9497 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9498 sessions[i] = rte_cryptodev_sym_session_create(
9499 ts_params->session_mpool);
9501 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9502 sizeof(struct crypto_unittest_params));
9504 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9505 &ut_paramz[i].ut_params,
9506 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9508 /* Create multiple crypto sessions*/
9509 rte_cryptodev_sym_session_init(
9510 ts_params->valid_devs[0],
9512 &ut_paramz[i].ut_params.auth_xform,
9513 ts_params->session_priv_mpool);
9515 TEST_ASSERT_NOT_NULL(sessions[i],
9516 "Session creation failed at session number %u",
9522 for (i = 0; i < 40000; i++) {
9524 j = rand() % MB_SESSION_NUMBER;
9526 TEST_ASSERT_SUCCESS(
9527 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9529 &ut_paramz[j].ut_params,
9530 ts_params, ut_paramz[j].cipher,
9531 ut_paramz[j].digest,
9533 "Failed to perform decrypt on request number %u.", i);
9535 if (ut_paramz[j].ut_params.op)
9536 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9539 * free mbuf - both obuf and ibuf are usually the same,
9540 * so check if they point at the same address is necessary,
9541 * to avoid freeing the mbuf twice.
9543 if (ut_paramz[j].ut_params.obuf) {
9544 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9545 if (ut_paramz[j].ut_params.ibuf
9546 == ut_paramz[j].ut_params.obuf)
9547 ut_paramz[j].ut_params.ibuf = 0;
9548 ut_paramz[j].ut_params.obuf = 0;
9550 if (ut_paramz[j].ut_params.ibuf) {
9551 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9552 ut_paramz[j].ut_params.ibuf = 0;
9556 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9557 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9559 rte_cryptodev_sym_session_free(sessions[i]);
9564 return TEST_SUCCESS;
9568 test_null_cipher_only_operation(void)
9570 struct crypto_testsuite_params *ts_params = &testsuite_params;
9571 struct crypto_unittest_params *ut_params = &unittest_params;
9573 /* Generate test mbuf data and space for digest */
9574 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9575 catch_22_quote, QUOTE_512_BYTES, 0);
9577 /* Setup Cipher Parameters */
9578 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9579 ut_params->cipher_xform.next = NULL;
9581 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9582 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9584 ut_params->sess = rte_cryptodev_sym_session_create(
9585 ts_params->session_mpool);
9587 /* Create Crypto session*/
9588 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9590 &ut_params->cipher_xform,
9591 ts_params->session_priv_mpool);
9592 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9594 /* Generate Crypto op data structure */
9595 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9596 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9597 TEST_ASSERT_NOT_NULL(ut_params->op,
9598 "Failed to allocate symmetric crypto operation struct");
9600 /* Set crypto operation data parameters */
9601 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9603 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9605 /* set crypto operation source mbuf */
9606 sym_op->m_src = ut_params->ibuf;
9608 sym_op->cipher.data.offset = 0;
9609 sym_op->cipher.data.length = QUOTE_512_BYTES;
9611 /* Process crypto operation */
9612 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9614 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9616 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9617 "crypto operation processing failed");
9620 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9621 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9624 "Ciphertext data not as expected");
9626 return TEST_SUCCESS;
9628 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9629 0xab, 0xab, 0xab, 0xab,
9630 0xab, 0xab, 0xab, 0xab,
9631 0xab, 0xab, 0xab, 0xab};
9633 test_null_auth_only_operation(void)
9635 struct crypto_testsuite_params *ts_params = &testsuite_params;
9636 struct crypto_unittest_params *ut_params = &unittest_params;
9639 /* Generate test mbuf data and space for digest */
9640 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9641 catch_22_quote, QUOTE_512_BYTES, 0);
9643 /* create a pointer for digest, but don't expect anything to be written
9644 * here in a NULL auth algo so no mbuf append done.
9646 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9648 /* prefill the memory pointed to by digest */
9649 memcpy(digest, orig_data, sizeof(orig_data));
9651 /* Setup HMAC Parameters */
9652 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9653 ut_params->auth_xform.next = NULL;
9655 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9656 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9658 ut_params->sess = rte_cryptodev_sym_session_create(
9659 ts_params->session_mpool);
9661 /* Create Crypto session*/
9662 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9663 ut_params->sess, &ut_params->auth_xform,
9664 ts_params->session_priv_mpool);
9665 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9667 /* Generate Crypto op data structure */
9668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9670 TEST_ASSERT_NOT_NULL(ut_params->op,
9671 "Failed to allocate symmetric crypto operation struct");
9673 /* Set crypto operation data parameters */
9674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9676 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9678 sym_op->m_src = ut_params->ibuf;
9680 sym_op->auth.data.offset = 0;
9681 sym_op->auth.data.length = QUOTE_512_BYTES;
9682 sym_op->auth.digest.data = digest;
9683 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9686 /* Process crypto operation */
9687 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9689 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9691 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9692 "crypto operation processing failed");
9693 /* Make sure memory pointed to by digest hasn't been overwritten */
9694 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9698 "Memory at digest ptr overwritten unexpectedly");
9700 return TEST_SUCCESS;
9705 test_null_cipher_auth_operation(void)
9707 struct crypto_testsuite_params *ts_params = &testsuite_params;
9708 struct crypto_unittest_params *ut_params = &unittest_params;
9711 /* Generate test mbuf data and space for digest */
9712 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9713 catch_22_quote, QUOTE_512_BYTES, 0);
9715 /* create a pointer for digest, but don't expect anything to be written
9716 * here in a NULL auth algo so no mbuf append done.
9718 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9720 /* prefill the memory pointed to by digest */
9721 memcpy(digest, orig_data, sizeof(orig_data));
9723 /* Setup Cipher Parameters */
9724 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9725 ut_params->cipher_xform.next = &ut_params->auth_xform;
9727 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9728 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9730 /* Setup HMAC Parameters */
9731 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9732 ut_params->auth_xform.next = NULL;
9734 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9735 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9737 ut_params->sess = rte_cryptodev_sym_session_create(
9738 ts_params->session_mpool);
9740 /* Create Crypto session*/
9741 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9742 ut_params->sess, &ut_params->cipher_xform,
9743 ts_params->session_priv_mpool);
9744 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9746 /* Generate Crypto op data structure */
9747 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9748 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9749 TEST_ASSERT_NOT_NULL(ut_params->op,
9750 "Failed to allocate symmetric crypto operation struct");
9752 /* Set crypto operation data parameters */
9753 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9755 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9757 sym_op->m_src = ut_params->ibuf;
9759 sym_op->cipher.data.offset = 0;
9760 sym_op->cipher.data.length = QUOTE_512_BYTES;
9762 sym_op->auth.data.offset = 0;
9763 sym_op->auth.data.length = QUOTE_512_BYTES;
9764 sym_op->auth.digest.data = digest;
9765 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9768 /* Process crypto operation */
9769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9771 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9773 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9774 "crypto operation processing failed");
9777 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9778 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9781 "Ciphertext data not as expected");
9782 /* Make sure memory pointed to by digest hasn't been overwritten */
9783 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9787 "Memory at digest ptr overwritten unexpectedly");
9789 return TEST_SUCCESS;
9793 test_null_auth_cipher_operation(void)
9795 struct crypto_testsuite_params *ts_params = &testsuite_params;
9796 struct crypto_unittest_params *ut_params = &unittest_params;
9799 /* Generate test mbuf data */
9800 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9801 catch_22_quote, QUOTE_512_BYTES, 0);
9803 /* create a pointer for digest, but don't expect anything to be written
9804 * here in a NULL auth algo so no mbuf append done.
9806 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9808 /* prefill the memory pointed to by digest */
9809 memcpy(digest, orig_data, sizeof(orig_data));
9811 /* Setup Cipher Parameters */
9812 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9813 ut_params->cipher_xform.next = NULL;
9815 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9816 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9818 /* Setup HMAC Parameters */
9819 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9820 ut_params->auth_xform.next = &ut_params->cipher_xform;
9822 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9823 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9825 ut_params->sess = rte_cryptodev_sym_session_create(
9826 ts_params->session_mpool);
9828 /* Create Crypto session*/
9829 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9830 ut_params->sess, &ut_params->cipher_xform,
9831 ts_params->session_priv_mpool);
9832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9834 /* Generate Crypto op data structure */
9835 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9836 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9837 TEST_ASSERT_NOT_NULL(ut_params->op,
9838 "Failed to allocate symmetric crypto operation struct");
9840 /* Set crypto operation data parameters */
9841 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9843 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9845 sym_op->m_src = ut_params->ibuf;
9847 sym_op->cipher.data.offset = 0;
9848 sym_op->cipher.data.length = QUOTE_512_BYTES;
9850 sym_op->auth.data.offset = 0;
9851 sym_op->auth.data.length = QUOTE_512_BYTES;
9852 sym_op->auth.digest.data = digest;
9853 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9856 /* Process crypto operation */
9857 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9859 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9861 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9862 "crypto operation processing failed");
9865 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9866 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9869 "Ciphertext data not as expected");
9870 /* Make sure memory pointed to by digest hasn't been overwritten */
9871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9875 "Memory at digest ptr overwritten unexpectedly");
9877 return TEST_SUCCESS;
9882 test_null_invalid_operation(void)
9884 struct crypto_testsuite_params *ts_params = &testsuite_params;
9885 struct crypto_unittest_params *ut_params = &unittest_params;
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_AES_CBC;
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 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9900 ut_params->sess, &ut_params->cipher_xform,
9901 ts_params->session_priv_mpool);
9902 TEST_ASSERT(ret < 0,
9903 "Session creation succeeded unexpectedly");
9906 /* Setup HMAC Parameters */
9907 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9908 ut_params->auth_xform.next = NULL;
9910 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9911 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9913 ut_params->sess = rte_cryptodev_sym_session_create(
9914 ts_params->session_mpool);
9916 /* Create Crypto session*/
9917 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9918 ut_params->sess, &ut_params->auth_xform,
9919 ts_params->session_priv_mpool);
9920 TEST_ASSERT(ret < 0,
9921 "Session creation succeeded unexpectedly");
9923 return TEST_SUCCESS;
9927 #define NULL_BURST_LENGTH (32)
9930 test_null_burst_operation(void)
9932 struct crypto_testsuite_params *ts_params = &testsuite_params;
9933 struct crypto_unittest_params *ut_params = &unittest_params;
9935 unsigned i, burst_len = NULL_BURST_LENGTH;
9937 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9938 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9940 /* Setup Cipher Parameters */
9941 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9942 ut_params->cipher_xform.next = &ut_params->auth_xform;
9944 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9945 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9947 /* Setup HMAC Parameters */
9948 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9949 ut_params->auth_xform.next = NULL;
9951 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9952 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9954 ut_params->sess = rte_cryptodev_sym_session_create(
9955 ts_params->session_mpool);
9957 /* Create Crypto session*/
9958 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9959 ut_params->sess, &ut_params->cipher_xform,
9960 ts_params->session_priv_mpool);
9961 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9963 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9964 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9965 burst_len, "failed to generate burst of crypto ops");
9967 /* Generate an operation for each mbuf in burst */
9968 for (i = 0; i < burst_len; i++) {
9969 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9971 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9973 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9977 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9979 burst[i]->sym->m_src = m;
9982 /* Process crypto operation */
9983 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9984 0, burst, burst_len),
9986 "Error enqueuing burst");
9988 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9989 0, burst_dequeued, burst_len),
9991 "Error dequeuing burst");
9994 for (i = 0; i < burst_len; i++) {
9996 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9997 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9999 "data not as expected");
10001 rte_pktmbuf_free(burst[i]->sym->m_src);
10002 rte_crypto_op_free(burst[i]);
10005 return TEST_SUCCESS;
10009 generate_gmac_large_plaintext(uint8_t *data)
10013 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10014 memcpy(&data[i], &data[0], 32);
10018 create_gmac_operation(enum rte_crypto_auth_operation op,
10019 const struct gmac_test_data *tdata)
10021 struct crypto_testsuite_params *ts_params = &testsuite_params;
10022 struct crypto_unittest_params *ut_params = &unittest_params;
10023 struct rte_crypto_sym_op *sym_op;
10025 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10027 /* Generate Crypto op data structure */
10028 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10029 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10030 TEST_ASSERT_NOT_NULL(ut_params->op,
10031 "Failed to allocate symmetric crypto operation struct");
10033 sym_op = ut_params->op->sym;
10035 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10036 ut_params->ibuf, tdata->gmac_tag.len);
10037 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10038 "no room to append digest");
10040 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10041 ut_params->ibuf, plaintext_pad_len);
10043 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10044 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10045 tdata->gmac_tag.len);
10046 debug_hexdump(stdout, "digest:",
10047 sym_op->auth.digest.data,
10048 tdata->gmac_tag.len);
10051 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10052 uint8_t *, IV_OFFSET);
10054 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10056 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10058 sym_op->cipher.data.length = 0;
10059 sym_op->cipher.data.offset = 0;
10061 sym_op->auth.data.offset = 0;
10062 sym_op->auth.data.length = tdata->plaintext.len;
10067 static int create_gmac_session(uint8_t dev_id,
10068 const struct gmac_test_data *tdata,
10069 enum rte_crypto_auth_operation auth_op)
10071 uint8_t auth_key[tdata->key.len];
10073 struct crypto_testsuite_params *ts_params = &testsuite_params;
10074 struct crypto_unittest_params *ut_params = &unittest_params;
10076 memcpy(auth_key, tdata->key.data, tdata->key.len);
10078 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10079 ut_params->auth_xform.next = NULL;
10081 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10082 ut_params->auth_xform.auth.op = auth_op;
10083 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10084 ut_params->auth_xform.auth.key.length = tdata->key.len;
10085 ut_params->auth_xform.auth.key.data = auth_key;
10086 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10087 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10090 ut_params->sess = rte_cryptodev_sym_session_create(
10091 ts_params->session_mpool);
10093 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10094 &ut_params->auth_xform,
10095 ts_params->session_priv_mpool);
10097 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10103 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10105 struct crypto_testsuite_params *ts_params = &testsuite_params;
10106 struct crypto_unittest_params *ut_params = &unittest_params;
10110 uint8_t *auth_tag, *plaintext;
10111 uint16_t plaintext_pad_len;
10113 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10114 "No GMAC length in the source data");
10116 retval = create_gmac_session(ts_params->valid_devs[0],
10117 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10122 if (tdata->plaintext.len > MBUF_SIZE)
10123 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10125 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10126 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10127 "Failed to allocate input buffer in mempool");
10129 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10130 rte_pktmbuf_tailroom(ut_params->ibuf));
10132 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10134 * Runtime generate the large plain text instead of use hard code
10135 * plain text vector. It is done to avoid create huge source file
10136 * with the test vector.
10138 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10139 generate_gmac_large_plaintext(tdata->plaintext.data);
10141 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10142 plaintext_pad_len);
10143 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10145 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10146 debug_hexdump(stdout, "plaintext:", plaintext,
10147 tdata->plaintext.len);
10149 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10155 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10157 ut_params->op->sym->m_src = ut_params->ibuf;
10159 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10160 ut_params->op), "failed to process sym crypto op");
10162 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10163 "crypto op processing failed");
10165 if (ut_params->op->sym->m_dst) {
10166 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10167 uint8_t *, plaintext_pad_len);
10169 auth_tag = plaintext + plaintext_pad_len;
10172 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10174 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10176 tdata->gmac_tag.data,
10177 tdata->gmac_tag.len,
10178 "GMAC Generated auth tag not as expected");
10184 test_AES_GMAC_authentication_test_case_1(void)
10186 return test_AES_GMAC_authentication(&gmac_test_case_1);
10190 test_AES_GMAC_authentication_test_case_2(void)
10192 return test_AES_GMAC_authentication(&gmac_test_case_2);
10196 test_AES_GMAC_authentication_test_case_3(void)
10198 return test_AES_GMAC_authentication(&gmac_test_case_3);
10202 test_AES_GMAC_authentication_test_case_4(void)
10204 return test_AES_GMAC_authentication(&gmac_test_case_4);
10208 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10210 struct crypto_testsuite_params *ts_params = &testsuite_params;
10211 struct crypto_unittest_params *ut_params = &unittest_params;
10213 uint32_t plaintext_pad_len;
10214 uint8_t *plaintext;
10216 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10217 "No GMAC length in the source data");
10219 retval = create_gmac_session(ts_params->valid_devs[0],
10220 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10225 if (tdata->plaintext.len > MBUF_SIZE)
10226 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10228 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10229 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10230 "Failed to allocate input buffer in mempool");
10232 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10233 rte_pktmbuf_tailroom(ut_params->ibuf));
10235 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10238 * Runtime generate the large plain text instead of use hard code
10239 * plain text vector. It is done to avoid create huge source file
10240 * with the test vector.
10242 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10243 generate_gmac_large_plaintext(tdata->plaintext.data);
10245 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10246 plaintext_pad_len);
10247 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10249 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10250 debug_hexdump(stdout, "plaintext:", plaintext,
10251 tdata->plaintext.len);
10253 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10261 ut_params->op->sym->m_src = ut_params->ibuf;
10263 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10264 ut_params->op), "failed to process sym crypto op");
10266 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10267 "crypto op processing failed");
10274 test_AES_GMAC_authentication_verify_test_case_1(void)
10276 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10280 test_AES_GMAC_authentication_verify_test_case_2(void)
10282 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10286 test_AES_GMAC_authentication_verify_test_case_3(void)
10288 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10292 test_AES_GMAC_authentication_verify_test_case_4(void)
10294 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10297 struct test_crypto_vector {
10298 enum rte_crypto_cipher_algorithm crypto_algo;
10299 unsigned int cipher_offset;
10300 unsigned int cipher_len;
10313 const uint8_t *data;
10318 const uint8_t *data;
10322 enum rte_crypto_auth_algorithm auth_algo;
10323 unsigned int auth_offset;
10331 const uint8_t *data;
10341 static const struct test_crypto_vector
10342 hmac_sha1_test_crypto_vector = {
10343 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10345 .data = plaintext_hash,
10350 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10351 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10352 0xDE, 0xF4, 0xDE, 0xAD
10358 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10359 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10360 0x3F, 0x91, 0x64, 0x59
10366 static const struct test_crypto_vector
10367 aes128_gmac_test_vector = {
10368 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10370 .data = plaintext_hash,
10375 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10376 0x08, 0x09, 0x0A, 0x0B
10382 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10383 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10389 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10390 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10396 static const struct test_crypto_vector
10397 aes128cbc_hmac_sha1_test_vector = {
10398 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10399 .cipher_offset = 0,
10403 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10404 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10410 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10411 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10416 .data = plaintext_hash,
10420 .data = ciphertext512_aes128cbc,
10423 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10427 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10428 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10429 0xDE, 0xF4, 0xDE, 0xAD
10435 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10436 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10437 0x18, 0x8C, 0x1D, 0x32
10443 static const struct test_crypto_vector
10444 aes128cbc_hmac_sha1_aad_test_vector = {
10445 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10446 .cipher_offset = 12,
10450 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10451 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10457 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10458 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10463 .data = plaintext_hash,
10467 .data = ciphertext512_aes128cbc_aad,
10470 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10474 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10475 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10476 0xDE, 0xF4, 0xDE, 0xAD
10482 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10483 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10484 0x62, 0x8D, 0x62, 0x65
10491 data_corruption(uint8_t *data)
10497 tag_corruption(uint8_t *data, unsigned int tag_offset)
10499 data[tag_offset] += 1;
10503 create_auth_session(struct crypto_unittest_params *ut_params,
10505 const struct test_crypto_vector *reference,
10506 enum rte_crypto_auth_operation auth_op)
10508 struct crypto_testsuite_params *ts_params = &testsuite_params;
10509 uint8_t auth_key[reference->auth_key.len + 1];
10511 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10513 /* Setup Authentication Parameters */
10514 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10515 ut_params->auth_xform.auth.op = auth_op;
10516 ut_params->auth_xform.next = NULL;
10517 ut_params->auth_xform.auth.algo = reference->auth_algo;
10518 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10519 ut_params->auth_xform.auth.key.data = auth_key;
10520 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10522 /* Create Crypto session*/
10523 ut_params->sess = rte_cryptodev_sym_session_create(
10524 ts_params->session_mpool);
10526 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10527 &ut_params->auth_xform,
10528 ts_params->session_priv_mpool);
10530 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10536 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10538 const struct test_crypto_vector *reference,
10539 enum rte_crypto_auth_operation auth_op,
10540 enum rte_crypto_cipher_operation cipher_op)
10542 struct crypto_testsuite_params *ts_params = &testsuite_params;
10543 uint8_t cipher_key[reference->cipher_key.len + 1];
10544 uint8_t auth_key[reference->auth_key.len + 1];
10546 memcpy(cipher_key, reference->cipher_key.data,
10547 reference->cipher_key.len);
10548 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10550 /* Setup Authentication Parameters */
10551 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10552 ut_params->auth_xform.auth.op = auth_op;
10553 ut_params->auth_xform.auth.algo = reference->auth_algo;
10554 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10555 ut_params->auth_xform.auth.key.data = auth_key;
10556 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10558 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10559 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10560 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10562 ut_params->auth_xform.next = &ut_params->cipher_xform;
10564 /* Setup Cipher Parameters */
10565 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10566 ut_params->cipher_xform.next = NULL;
10567 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10568 ut_params->cipher_xform.cipher.op = cipher_op;
10569 ut_params->cipher_xform.cipher.key.data = cipher_key;
10570 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10571 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10572 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10575 /* Create Crypto session*/
10576 ut_params->sess = rte_cryptodev_sym_session_create(
10577 ts_params->session_mpool);
10579 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10580 &ut_params->auth_xform,
10581 ts_params->session_priv_mpool);
10583 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10589 create_auth_operation(struct crypto_testsuite_params *ts_params,
10590 struct crypto_unittest_params *ut_params,
10591 const struct test_crypto_vector *reference,
10592 unsigned int auth_generate)
10594 /* Generate Crypto op data structure */
10595 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10596 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10597 TEST_ASSERT_NOT_NULL(ut_params->op,
10598 "Failed to allocate pktmbuf offload");
10600 /* Set crypto operation data parameters */
10601 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10603 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10605 /* set crypto operation source mbuf */
10606 sym_op->m_src = ut_params->ibuf;
10609 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10610 ut_params->ibuf, reference->digest.len);
10612 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10613 "no room to append auth tag");
10615 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10616 ut_params->ibuf, reference->plaintext.len);
10619 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10621 memcpy(sym_op->auth.digest.data,
10622 reference->digest.data,
10623 reference->digest.len);
10625 debug_hexdump(stdout, "digest:",
10626 sym_op->auth.digest.data,
10627 reference->digest.len);
10629 sym_op->auth.data.length = reference->plaintext.len;
10630 sym_op->auth.data.offset = 0;
10636 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10637 struct crypto_unittest_params *ut_params,
10638 const struct test_crypto_vector *reference,
10639 unsigned int auth_generate)
10641 /* Generate Crypto op data structure */
10642 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10643 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10644 TEST_ASSERT_NOT_NULL(ut_params->op,
10645 "Failed to allocate pktmbuf offload");
10647 /* Set crypto operation data parameters */
10648 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10650 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10652 /* set crypto operation source mbuf */
10653 sym_op->m_src = ut_params->ibuf;
10656 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10657 ut_params->ibuf, reference->digest.len);
10659 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10660 "no room to append auth tag");
10662 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10663 ut_params->ibuf, reference->ciphertext.len);
10666 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10668 memcpy(sym_op->auth.digest.data,
10669 reference->digest.data,
10670 reference->digest.len);
10672 debug_hexdump(stdout, "digest:",
10673 sym_op->auth.digest.data,
10674 reference->digest.len);
10676 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10677 reference->iv.data, reference->iv.len);
10679 sym_op->cipher.data.length = 0;
10680 sym_op->cipher.data.offset = 0;
10682 sym_op->auth.data.length = reference->plaintext.len;
10683 sym_op->auth.data.offset = 0;
10689 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10690 struct crypto_unittest_params *ut_params,
10691 const struct test_crypto_vector *reference,
10692 unsigned int auth_generate)
10694 /* Generate Crypto op data structure */
10695 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10696 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10697 TEST_ASSERT_NOT_NULL(ut_params->op,
10698 "Failed to allocate pktmbuf offload");
10700 /* Set crypto operation data parameters */
10701 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10703 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10705 /* set crypto operation source mbuf */
10706 sym_op->m_src = ut_params->ibuf;
10709 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10710 ut_params->ibuf, reference->digest.len);
10712 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10713 "no room to append auth tag");
10715 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10716 ut_params->ibuf, reference->ciphertext.len);
10719 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10721 memcpy(sym_op->auth.digest.data,
10722 reference->digest.data,
10723 reference->digest.len);
10725 debug_hexdump(stdout, "digest:",
10726 sym_op->auth.digest.data,
10727 reference->digest.len);
10729 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10730 reference->iv.data, reference->iv.len);
10732 sym_op->cipher.data.length = reference->cipher_len;
10733 sym_op->cipher.data.offset = reference->cipher_offset;
10735 sym_op->auth.data.length = reference->plaintext.len;
10736 sym_op->auth.data.offset = reference->auth_offset;
10742 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10743 struct crypto_unittest_params *ut_params,
10744 const struct test_crypto_vector *reference)
10746 return create_auth_operation(ts_params, ut_params, reference, 0);
10750 create_auth_verify_GMAC_operation(
10751 struct crypto_testsuite_params *ts_params,
10752 struct crypto_unittest_params *ut_params,
10753 const struct test_crypto_vector *reference)
10755 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10759 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10760 struct crypto_unittest_params *ut_params,
10761 const struct test_crypto_vector *reference)
10763 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10767 test_authentication_verify_fail_when_data_corruption(
10768 struct crypto_testsuite_params *ts_params,
10769 struct crypto_unittest_params *ut_params,
10770 const struct test_crypto_vector *reference,
10771 unsigned int data_corrupted)
10775 uint8_t *plaintext;
10777 /* Create session */
10778 retval = create_auth_session(ut_params,
10779 ts_params->valid_devs[0],
10781 RTE_CRYPTO_AUTH_OP_VERIFY);
10785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10786 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10787 "Failed to allocate input buffer in mempool");
10789 /* clear mbuf payload */
10790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10791 rte_pktmbuf_tailroom(ut_params->ibuf));
10793 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10794 reference->plaintext.len);
10795 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10796 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10798 debug_hexdump(stdout, "plaintext:", plaintext,
10799 reference->plaintext.len);
10801 /* Create operation */
10802 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10807 if (data_corrupted)
10808 data_corruption(plaintext);
10810 tag_corruption(plaintext, reference->plaintext.len);
10812 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10814 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10815 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10816 RTE_CRYPTO_OP_STATUS_SUCCESS,
10817 "authentication not failed");
10819 ut_params->obuf = ut_params->op->sym->m_src;
10820 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10826 test_authentication_verify_GMAC_fail_when_corruption(
10827 struct crypto_testsuite_params *ts_params,
10828 struct crypto_unittest_params *ut_params,
10829 const struct test_crypto_vector *reference,
10830 unsigned int data_corrupted)
10833 uint8_t *plaintext;
10835 /* Create session */
10836 retval = create_auth_cipher_session(ut_params,
10837 ts_params->valid_devs[0],
10839 RTE_CRYPTO_AUTH_OP_VERIFY,
10840 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10845 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10846 "Failed to allocate input buffer in mempool");
10848 /* clear mbuf payload */
10849 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10850 rte_pktmbuf_tailroom(ut_params->ibuf));
10852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10853 reference->plaintext.len);
10854 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10855 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10857 debug_hexdump(stdout, "plaintext:", plaintext,
10858 reference->plaintext.len);
10860 /* Create operation */
10861 retval = create_auth_verify_GMAC_operation(ts_params,
10868 if (data_corrupted)
10869 data_corruption(plaintext);
10871 tag_corruption(plaintext, reference->aad.len);
10873 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10875 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10876 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10877 RTE_CRYPTO_OP_STATUS_SUCCESS,
10878 "authentication not failed");
10880 ut_params->obuf = ut_params->op->sym->m_src;
10881 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10887 test_authenticated_decryption_fail_when_corruption(
10888 struct crypto_testsuite_params *ts_params,
10889 struct crypto_unittest_params *ut_params,
10890 const struct test_crypto_vector *reference,
10891 unsigned int data_corrupted)
10895 uint8_t *ciphertext;
10897 /* Create session */
10898 retval = create_auth_cipher_session(ut_params,
10899 ts_params->valid_devs[0],
10901 RTE_CRYPTO_AUTH_OP_VERIFY,
10902 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10907 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10908 "Failed to allocate input buffer in mempool");
10910 /* clear mbuf payload */
10911 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10912 rte_pktmbuf_tailroom(ut_params->ibuf));
10914 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10915 reference->ciphertext.len);
10916 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10917 memcpy(ciphertext, reference->ciphertext.data,
10918 reference->ciphertext.len);
10920 /* Create operation */
10921 retval = create_cipher_auth_verify_operation(ts_params,
10928 if (data_corrupted)
10929 data_corruption(ciphertext);
10931 tag_corruption(ciphertext, reference->ciphertext.len);
10933 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10936 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10937 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10938 RTE_CRYPTO_OP_STATUS_SUCCESS,
10939 "authentication not failed");
10941 ut_params->obuf = ut_params->op->sym->m_src;
10942 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10948 test_authenticated_encryt_with_esn(
10949 struct crypto_testsuite_params *ts_params,
10950 struct crypto_unittest_params *ut_params,
10951 const struct test_crypto_vector *reference)
10955 uint8_t *authciphertext, *plaintext, *auth_tag;
10956 uint16_t plaintext_pad_len;
10957 uint8_t cipher_key[reference->cipher_key.len + 1];
10958 uint8_t auth_key[reference->auth_key.len + 1];
10960 /* Create session */
10961 memcpy(cipher_key, reference->cipher_key.data,
10962 reference->cipher_key.len);
10963 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10965 /* Setup Cipher Parameters */
10966 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10967 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10968 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10969 ut_params->cipher_xform.cipher.key.data = cipher_key;
10970 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10971 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10972 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10974 ut_params->cipher_xform.next = &ut_params->auth_xform;
10976 /* Setup Authentication Parameters */
10977 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10978 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10979 ut_params->auth_xform.auth.algo = reference->auth_algo;
10980 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10981 ut_params->auth_xform.auth.key.data = auth_key;
10982 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10983 ut_params->auth_xform.next = NULL;
10985 /* Create Crypto session*/
10986 ut_params->sess = rte_cryptodev_sym_session_create(
10987 ts_params->session_mpool);
10989 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10991 &ut_params->cipher_xform,
10992 ts_params->session_priv_mpool);
10994 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10996 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10997 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10998 "Failed to allocate input buffer in mempool");
11000 /* clear mbuf payload */
11001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11002 rte_pktmbuf_tailroom(ut_params->ibuf));
11004 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11005 reference->plaintext.len);
11006 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11007 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11009 /* Create operation */
11010 retval = create_cipher_auth_operation(ts_params,
11017 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11020 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11022 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11023 "crypto op processing failed");
11025 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11027 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11028 ut_params->op->sym->auth.data.offset);
11029 auth_tag = authciphertext + plaintext_pad_len;
11030 debug_hexdump(stdout, "ciphertext:", authciphertext,
11031 reference->ciphertext.len);
11032 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11034 /* Validate obuf */
11035 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11037 reference->ciphertext.data,
11038 reference->ciphertext.len,
11039 "Ciphertext data not as expected");
11041 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11043 reference->digest.data,
11044 reference->digest.len,
11045 "Generated digest not as expected");
11047 return TEST_SUCCESS;
11052 test_authenticated_decrypt_with_esn(
11053 struct crypto_testsuite_params *ts_params,
11054 struct crypto_unittest_params *ut_params,
11055 const struct test_crypto_vector *reference)
11059 uint8_t *ciphertext;
11060 uint8_t cipher_key[reference->cipher_key.len + 1];
11061 uint8_t auth_key[reference->auth_key.len + 1];
11063 /* Create session */
11064 memcpy(cipher_key, reference->cipher_key.data,
11065 reference->cipher_key.len);
11066 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11068 /* Setup Authentication Parameters */
11069 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11070 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11071 ut_params->auth_xform.auth.algo = reference->auth_algo;
11072 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11073 ut_params->auth_xform.auth.key.data = auth_key;
11074 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11075 ut_params->auth_xform.next = &ut_params->cipher_xform;
11077 /* Setup Cipher Parameters */
11078 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11079 ut_params->cipher_xform.next = NULL;
11080 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11081 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11082 ut_params->cipher_xform.cipher.key.data = cipher_key;
11083 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11084 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11085 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11087 /* Create Crypto session*/
11088 ut_params->sess = rte_cryptodev_sym_session_create(
11089 ts_params->session_mpool);
11091 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11093 &ut_params->auth_xform,
11094 ts_params->session_priv_mpool);
11096 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11099 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11100 "Failed to allocate input buffer in mempool");
11102 /* clear mbuf payload */
11103 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11104 rte_pktmbuf_tailroom(ut_params->ibuf));
11106 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11107 reference->ciphertext.len);
11108 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11109 memcpy(ciphertext, reference->ciphertext.data,
11110 reference->ciphertext.len);
11112 /* Create operation */
11113 retval = create_cipher_auth_verify_operation(ts_params,
11120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11124 TEST_ASSERT_EQUAL(ut_params->op->status,
11125 RTE_CRYPTO_OP_STATUS_SUCCESS,
11126 "crypto op processing passed");
11128 ut_params->obuf = ut_params->op->sym->m_src;
11129 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11135 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11136 const struct aead_test_data *tdata,
11137 void *digest_mem, uint64_t digest_phys)
11139 struct crypto_testsuite_params *ts_params = &testsuite_params;
11140 struct crypto_unittest_params *ut_params = &unittest_params;
11142 const unsigned int auth_tag_len = tdata->auth_tag.len;
11143 const unsigned int iv_len = tdata->iv.len;
11144 unsigned int aad_len = tdata->aad.len;
11146 /* Generate Crypto op data structure */
11147 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11148 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11149 TEST_ASSERT_NOT_NULL(ut_params->op,
11150 "Failed to allocate symmetric crypto operation struct");
11152 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11154 sym_op->aead.digest.data = digest_mem;
11156 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11157 "no room to append digest");
11159 sym_op->aead.digest.phys_addr = digest_phys;
11161 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11162 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11164 debug_hexdump(stdout, "digest:",
11165 sym_op->aead.digest.data,
11169 /* Append aad data */
11170 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11171 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11172 uint8_t *, IV_OFFSET);
11174 /* Copy IV 1 byte after the IV pointer, according to the API */
11175 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11177 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11179 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11180 ut_params->ibuf, aad_len);
11181 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11182 "no room to prepend aad");
11183 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11186 memset(sym_op->aead.aad.data, 0, aad_len);
11187 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11188 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11190 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11191 debug_hexdump(stdout, "aad:",
11192 sym_op->aead.aad.data, aad_len);
11194 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11195 uint8_t *, IV_OFFSET);
11197 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11199 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11200 ut_params->ibuf, aad_len);
11201 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11202 "no room to prepend aad");
11203 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11206 memset(sym_op->aead.aad.data, 0, aad_len);
11207 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11209 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11210 debug_hexdump(stdout, "aad:",
11211 sym_op->aead.aad.data, aad_len);
11214 sym_op->aead.data.length = tdata->plaintext.len;
11215 sym_op->aead.data.offset = aad_len;
11220 #define SGL_MAX_NO 16
11223 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11224 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11226 struct crypto_testsuite_params *ts_params = &testsuite_params;
11227 struct crypto_unittest_params *ut_params = &unittest_params;
11228 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11231 int to_trn_tbl[SGL_MAX_NO];
11233 unsigned int trn_data = 0;
11234 uint8_t *plaintext, *ciphertext, *auth_tag;
11236 if (fragsz > tdata->plaintext.len)
11237 fragsz = tdata->plaintext.len;
11239 uint16_t plaintext_len = fragsz;
11240 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11242 if (fragsz_oop > tdata->plaintext.len)
11243 frag_size_oop = tdata->plaintext.len;
11246 void *digest_mem = NULL;
11248 uint32_t prepend_len = tdata->aad.len;
11250 if (tdata->plaintext.len % fragsz != 0) {
11251 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11254 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11259 * For out-op-place we need to alloc another mbuf
11262 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11263 rte_pktmbuf_append(ut_params->obuf,
11264 frag_size_oop + prepend_len);
11265 buf_oop = ut_params->obuf;
11268 /* Create AEAD session */
11269 retval = create_aead_session(ts_params->valid_devs[0],
11271 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11272 tdata->key.data, tdata->key.len,
11273 tdata->aad.len, tdata->auth_tag.len,
11278 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11280 /* clear mbuf payload */
11281 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11282 rte_pktmbuf_tailroom(ut_params->ibuf));
11284 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11287 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11289 trn_data += plaintext_len;
11291 buf = ut_params->ibuf;
11294 * Loop until no more fragments
11297 while (trn_data < tdata->plaintext.len) {
11299 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11300 (tdata->plaintext.len - trn_data) : fragsz;
11302 to_trn_tbl[ecx++] = to_trn;
11304 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11307 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11308 rte_pktmbuf_tailroom(buf));
11311 if (oop && !fragsz_oop) {
11312 buf_last_oop = buf_oop->next =
11313 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11314 buf_oop = buf_oop->next;
11315 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11316 0, rte_pktmbuf_tailroom(buf_oop));
11317 rte_pktmbuf_append(buf_oop, to_trn);
11320 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11323 memcpy(plaintext, tdata->plaintext.data + trn_data,
11325 trn_data += to_trn;
11326 if (trn_data == tdata->plaintext.len) {
11329 digest_mem = rte_pktmbuf_append(buf_oop,
11330 tdata->auth_tag.len);
11332 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11333 tdata->auth_tag.len);
11337 uint64_t digest_phys = 0;
11339 ut_params->ibuf->nb_segs = segs;
11342 if (fragsz_oop && oop) {
11346 if (frag_size_oop == tdata->plaintext.len) {
11347 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11348 tdata->auth_tag.len);
11350 digest_phys = rte_pktmbuf_iova_offset(
11352 tdata->plaintext.len + prepend_len);
11355 trn_data = frag_size_oop;
11356 while (trn_data < tdata->plaintext.len) {
11359 (tdata->plaintext.len - trn_data <
11361 (tdata->plaintext.len - trn_data) :
11364 to_trn_tbl[ecx++] = to_trn;
11366 buf_last_oop = buf_oop->next =
11367 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11368 buf_oop = buf_oop->next;
11369 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11370 0, rte_pktmbuf_tailroom(buf_oop));
11371 rte_pktmbuf_append(buf_oop, to_trn);
11373 trn_data += to_trn;
11375 if (trn_data == tdata->plaintext.len) {
11376 digest_mem = rte_pktmbuf_append(buf_oop,
11377 tdata->auth_tag.len);
11381 ut_params->obuf->nb_segs = segs;
11385 * Place digest at the end of the last buffer
11388 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11389 if (oop && buf_last_oop)
11390 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11392 if (!digest_mem && !oop) {
11393 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11394 + tdata->auth_tag.len);
11395 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11396 tdata->plaintext.len);
11399 /* Create AEAD operation */
11400 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11401 tdata, digest_mem, digest_phys);
11406 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11408 ut_params->op->sym->m_src = ut_params->ibuf;
11410 ut_params->op->sym->m_dst = ut_params->obuf;
11412 /* Process crypto operation */
11413 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11414 ut_params->op), "failed to process sym crypto op");
11416 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11417 "crypto op processing failed");
11420 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11421 uint8_t *, prepend_len);
11423 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11424 uint8_t *, prepend_len);
11428 fragsz = fragsz_oop;
11430 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11432 tdata->ciphertext.data,
11434 "Ciphertext data not as expected");
11436 buf = ut_params->op->sym->m_src->next;
11438 buf = ut_params->op->sym->m_dst->next;
11440 unsigned int off = fragsz;
11444 ciphertext = rte_pktmbuf_mtod(buf,
11447 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11449 tdata->ciphertext.data + off,
11451 "Ciphertext data not as expected");
11453 off += to_trn_tbl[ecx++];
11457 auth_tag = digest_mem;
11458 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11460 tdata->auth_tag.data,
11461 tdata->auth_tag.len,
11462 "Generated auth tag not as expected");
11468 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11470 return test_authenticated_encryption_SGL(
11471 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11475 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11477 return test_authenticated_encryption_SGL(
11478 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11482 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11484 return test_authenticated_encryption_SGL(
11485 &gcm_test_case_8, OUT_OF_PLACE, 400,
11486 gcm_test_case_8.plaintext.len);
11490 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11493 return test_authenticated_encryption_SGL(
11494 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11498 test_authentication_verify_fail_when_data_corrupted(
11499 struct crypto_testsuite_params *ts_params,
11500 struct crypto_unittest_params *ut_params,
11501 const struct test_crypto_vector *reference)
11503 return test_authentication_verify_fail_when_data_corruption(
11504 ts_params, ut_params, reference, 1);
11508 test_authentication_verify_fail_when_tag_corrupted(
11509 struct crypto_testsuite_params *ts_params,
11510 struct crypto_unittest_params *ut_params,
11511 const struct test_crypto_vector *reference)
11513 return test_authentication_verify_fail_when_data_corruption(
11514 ts_params, ut_params, reference, 0);
11518 test_authentication_verify_GMAC_fail_when_data_corrupted(
11519 struct crypto_testsuite_params *ts_params,
11520 struct crypto_unittest_params *ut_params,
11521 const struct test_crypto_vector *reference)
11523 return test_authentication_verify_GMAC_fail_when_corruption(
11524 ts_params, ut_params, reference, 1);
11528 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11529 struct crypto_testsuite_params *ts_params,
11530 struct crypto_unittest_params *ut_params,
11531 const struct test_crypto_vector *reference)
11533 return test_authentication_verify_GMAC_fail_when_corruption(
11534 ts_params, ut_params, reference, 0);
11538 test_authenticated_decryption_fail_when_data_corrupted(
11539 struct crypto_testsuite_params *ts_params,
11540 struct crypto_unittest_params *ut_params,
11541 const struct test_crypto_vector *reference)
11543 return test_authenticated_decryption_fail_when_corruption(
11544 ts_params, ut_params, reference, 1);
11548 test_authenticated_decryption_fail_when_tag_corrupted(
11549 struct crypto_testsuite_params *ts_params,
11550 struct crypto_unittest_params *ut_params,
11551 const struct test_crypto_vector *reference)
11553 return test_authenticated_decryption_fail_when_corruption(
11554 ts_params, ut_params, reference, 0);
11558 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11560 return test_authentication_verify_fail_when_data_corrupted(
11561 &testsuite_params, &unittest_params,
11562 &hmac_sha1_test_crypto_vector);
11566 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11568 return test_authentication_verify_fail_when_tag_corrupted(
11569 &testsuite_params, &unittest_params,
11570 &hmac_sha1_test_crypto_vector);
11574 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11576 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11577 &testsuite_params, &unittest_params,
11578 &aes128_gmac_test_vector);
11582 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11584 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11585 &testsuite_params, &unittest_params,
11586 &aes128_gmac_test_vector);
11590 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11592 return test_authenticated_decryption_fail_when_data_corrupted(
11595 &aes128cbc_hmac_sha1_test_vector);
11599 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11601 return test_authenticated_decryption_fail_when_tag_corrupted(
11604 &aes128cbc_hmac_sha1_test_vector);
11608 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11610 return test_authenticated_encryt_with_esn(
11613 &aes128cbc_hmac_sha1_aad_test_vector);
11617 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11619 return test_authenticated_decrypt_with_esn(
11622 &aes128cbc_hmac_sha1_aad_test_vector);
11625 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11627 /* global AESNI slave IDs for the scheduler test */
11628 uint8_t aesni_ids[2];
11631 test_scheduler_attach_slave_op(void)
11633 struct crypto_testsuite_params *ts_params = &testsuite_params;
11634 uint8_t sched_id = ts_params->valid_devs[0];
11635 uint32_t nb_devs, i, nb_devs_attached = 0;
11637 char vdev_name[32];
11639 /* create 2 AESNI_MB if necessary */
11640 nb_devs = rte_cryptodev_device_count_by_driver(
11641 rte_cryptodev_driver_id_get(
11642 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11644 for (i = nb_devs; i < 2; i++) {
11645 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11646 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11648 ret = rte_vdev_init(vdev_name, NULL);
11650 TEST_ASSERT(ret == 0,
11651 "Failed to create instance %u of"
11653 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11657 /* attach 2 AESNI_MB cdevs */
11658 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11660 struct rte_cryptodev_info info;
11661 unsigned int session_size;
11663 rte_cryptodev_info_get(i, &info);
11664 if (info.driver_id != rte_cryptodev_driver_id_get(
11665 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11668 session_size = rte_cryptodev_sym_get_private_session_size(i);
11670 * Create the session mempool again, since now there are new devices
11671 * to use the mempool.
11673 if (ts_params->session_mpool) {
11674 rte_mempool_free(ts_params->session_mpool);
11675 ts_params->session_mpool = NULL;
11677 if (ts_params->session_priv_mpool) {
11678 rte_mempool_free(ts_params->session_priv_mpool);
11679 ts_params->session_priv_mpool = NULL;
11682 if (info.sym.max_nb_sessions != 0 &&
11683 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11684 RTE_LOG(ERR, USER1,
11685 "Device does not support "
11686 "at least %u sessions\n",
11688 return TEST_FAILED;
11691 * Create mempool with maximum number of sessions,
11692 * to include the session headers
11694 if (ts_params->session_mpool == NULL) {
11695 ts_params->session_mpool =
11696 rte_cryptodev_sym_session_pool_create(
11698 MAX_NB_SESSIONS, 0, 0, 0,
11700 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11701 "session mempool allocation failed");
11705 * Create mempool with maximum number of sessions,
11706 * to include device specific session private data
11708 if (ts_params->session_priv_mpool == NULL) {
11709 ts_params->session_priv_mpool = rte_mempool_create(
11710 "test_sess_mp_priv",
11713 0, 0, NULL, NULL, NULL,
11714 NULL, SOCKET_ID_ANY,
11717 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11718 "session mempool allocation failed");
11721 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11722 ts_params->qp_conf.mp_session_private =
11723 ts_params->session_priv_mpool;
11725 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11728 TEST_ASSERT(ret == 0,
11729 "Failed to attach device %u of pmd : %s", i,
11730 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11732 aesni_ids[nb_devs_attached] = (uint8_t)i;
11734 nb_devs_attached++;
11741 test_scheduler_detach_slave_op(void)
11743 struct crypto_testsuite_params *ts_params = &testsuite_params;
11744 uint8_t sched_id = ts_params->valid_devs[0];
11748 for (i = 0; i < 2; i++) {
11749 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11751 TEST_ASSERT(ret == 0,
11752 "Failed to detach device %u", aesni_ids[i]);
11759 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11761 struct crypto_testsuite_params *ts_params = &testsuite_params;
11762 uint8_t sched_id = ts_params->valid_devs[0];
11764 return rte_cryptodev_scheduler_mode_set(sched_id,
11769 test_scheduler_mode_roundrobin_op(void)
11771 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11772 0, "Failed to set roundrobin mode");
11778 test_scheduler_mode_multicore_op(void)
11780 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11781 0, "Failed to set multicore mode");
11787 test_scheduler_mode_failover_op(void)
11789 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11790 0, "Failed to set failover mode");
11796 test_scheduler_mode_pkt_size_distr_op(void)
11798 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11799 0, "Failed to set pktsize mode");
11804 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11805 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11806 .setup = testsuite_setup,
11807 .teardown = testsuite_teardown,
11808 .unit_test_cases = {
11810 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11811 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_chain_scheduler_all),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_cipheronly_scheduler_all),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_authonly_scheduler_all),
11818 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11821 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11822 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_AES_chain_scheduler_all),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_cipheronly_scheduler_all),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_authonly_scheduler_all),
11829 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11832 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11833 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_chain_scheduler_all),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_cipheronly_scheduler_all),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_authonly_scheduler_all),
11840 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11843 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11844 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_chain_scheduler_all),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_cipheronly_scheduler_all),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_authonly_scheduler_all),
11851 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11853 TEST_CASES_END() /**< NULL terminate unit test array */
11857 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11859 static struct unit_test_suite cryptodev_qat_testsuite = {
11860 .suite_name = "Crypto QAT Unit Test Suite",
11861 .setup = testsuite_setup,
11862 .teardown = testsuite_teardown,
11863 .unit_test_cases = {
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_device_configure_invalid_dev_id),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_device_configure_invalid_queue_pair_ids),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_queue_pair_descriptor_setup),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_multi_session),
11873 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_AES_cipheronly_qat_all),
11876 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_3DES_cipheronly_qat_all),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_DES_cipheronly_qat_all),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_docsis_qat_all),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_DES_docsis_qat_all),
11885 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11886 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11888 /** AES CCM Authenticated Encryption 128 bits key */
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_CCM_authenticated_encryption_test_case_128_1),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_CCM_authenticated_encryption_test_case_128_2),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_CCM_authenticated_encryption_test_case_128_3),
11896 /** AES CCM Authenticated Decryption 128 bits key*/
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_CCM_authenticated_decryption_test_case_128_1),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_CCM_authenticated_decryption_test_case_128_2),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_CCM_authenticated_decryption_test_case_128_3),
11904 /** AES GCM Authenticated Encryption */
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_authenticated_encryption_test_case_1),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_authenticated_encryption_test_case_2),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_authenticated_encryption_test_case_3),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_authenticated_encryption_test_case_4),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_authenticated_encryption_test_case_5),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_authenticated_encryption_test_case_6),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_authenticated_encryption_test_case_7),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_authenticated_encryption_test_case_8),
11928 /** AES GCM Authenticated Decryption */
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_authenticated_decryption_test_case_1),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_authenticated_decryption_test_case_2),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_authenticated_decryption_test_case_3),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_authenticated_decryption_test_case_4),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_authenticated_decryption_test_case_5),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_authenticated_decryption_test_case_6),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_authenticated_decryption_test_case_7),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_authenticated_decryption_test_case_8),
11946 /** AES GCM Authenticated Encryption 192 bits key */
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_encryption_test_case_192_1),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_encryption_test_case_192_2),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GCM_auth_encryption_test_case_192_3),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_encryption_test_case_192_4),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GCM_auth_encryption_test_case_192_5),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GCM_auth_encryption_test_case_192_6),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_encryption_test_case_192_7),
11962 /** AES GCM Authenticated Decryption 192 bits key */
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_AES_GCM_auth_decryption_test_case_192_1),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_decryption_test_case_192_2),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_GCM_auth_decryption_test_case_192_3),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_GCM_auth_decryption_test_case_192_4),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_auth_decryption_test_case_192_5),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_GCM_auth_decryption_test_case_192_6),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_GCM_auth_decryption_test_case_192_7),
11978 /** AES GCM Authenticated Encryption 256 bits key */
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_AES_GCM_auth_encryption_test_case_256_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GCM_auth_encryption_test_case_256_2),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GCM_auth_encryption_test_case_256_3),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_GCM_auth_encryption_test_case_256_4),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GCM_auth_encryption_test_case_256_5),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GCM_auth_encryption_test_case_256_6),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_GCM_auth_encryption_test_case_256_7),
11994 /** AES GCM Authenticated Decryption 256 bits key */
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_AES_GCM_auth_decryption_test_case_256_1),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_AES_GCM_auth_decryption_test_case_256_2),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_AES_GCM_auth_decryption_test_case_256_3),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_AES_GCM_auth_decryption_test_case_256_4),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_AES_GCM_auth_decryption_test_case_256_5),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_AES_GCM_auth_decryption_test_case_256_6),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_AES_GCM_auth_decryption_test_case_256_7),
12010 /** AES GMAC Authentication */
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_AES_GMAC_authentication_test_case_1),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_AES_GMAC_authentication_verify_test_case_1),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_AES_GMAC_authentication_test_case_2),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_AES_GMAC_authentication_verify_test_case_2),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_AES_GMAC_authentication_test_case_3),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_AES_GMAC_authentication_verify_test_case_3),
12024 /** SNOW 3G encrypt only (UEA2) */
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_snow3g_encryption_test_case_1),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_snow3g_encryption_test_case_2),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_snow3g_encryption_test_case_3),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_snow3g_encryption_test_case_4),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_snow3g_encryption_test_case_5),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_encryption_test_case_1_oop),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_decryption_test_case_1_oop),
12041 /** SNOW 3G generate auth, then encrypt (UEA2) */
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_test_case_1),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_test_case_2),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_test_case_2_oop),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_part_digest_enc),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_part_digest_enc_oop),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_test_case_3_sgl),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_part_digest_enc_sgl),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12061 /** SNOW 3G decrypt (UEA2), then verify auth */
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_auth_cipher_verify_test_case_1),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_auth_cipher_verify_test_case_2),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_auth_cipher_verify_test_case_2_oop),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_auth_cipher_verify_part_digest_enc),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12081 /** SNOW 3G decrypt only (UEA2) */
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_snow3g_decryption_test_case_1),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_snow3g_decryption_test_case_2),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_snow3g_decryption_test_case_3),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_snow3g_decryption_test_case_4),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_snow3g_decryption_test_case_5),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_snow3g_decryption_with_digest_test_case_1),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_snow3g_hash_generate_test_case_1),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_snow3g_hash_generate_test_case_2),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_snow3g_hash_generate_test_case_3),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_snow3g_hash_verify_test_case_1),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_snow3g_hash_verify_test_case_2),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_snow3g_hash_verify_test_case_3),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_snow3g_cipher_auth_test_case_1),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_snow3g_auth_cipher_with_digest_test_case_1),
12111 /** ZUC encrypt only (EEA3) */
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_zuc_encryption_test_case_1),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_zuc_encryption_test_case_2),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_zuc_encryption_test_case_3),
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_zuc_encryption_test_case_4),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_encryption_test_case_5),
12123 /** ZUC authenticate (EIA3) */
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_hash_generate_test_case_6),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_hash_generate_test_case_7),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_zuc_hash_generate_test_case_8),
12131 /** ZUC alg-chain (EEA3/EIA3) */
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_zuc_cipher_auth_test_case_1),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_cipher_auth_test_case_2),
12137 /** ZUC generate auth, then encrypt (EEA3) */
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_auth_cipher_test_case_1),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_auth_cipher_test_case_1_oop),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_auth_cipher_test_case_1_sgl),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_auth_cipher_test_case_1_oop_sgl),
12147 /** ZUC decrypt (EEA3), then verify auth */
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_auth_cipher_verify_test_case_1),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_zuc_auth_cipher_verify_test_case_1_oop),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_zuc_auth_cipher_verify_test_case_1_sgl),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12157 /** HMAC_MD5 Authentication */
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_MD5_HMAC_generate_case_1),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_MD5_HMAC_verify_case_1),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_MD5_HMAC_generate_case_2),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_MD5_HMAC_verify_case_2),
12167 /** NULL algo tests done in chain_all,
12168 * cipheronly and authonly suites
12171 /** KASUMI tests */
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_hash_generate_test_case_1),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_hash_generate_test_case_2),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_hash_generate_test_case_3),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_kasumi_hash_generate_test_case_4),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_kasumi_hash_generate_test_case_5),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_hash_generate_test_case_6),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_kasumi_hash_verify_test_case_1),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_verify_test_case_2),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_verify_test_case_3),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_kasumi_hash_verify_test_case_4),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_hash_verify_test_case_5),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_kasumi_encryption_test_case_1),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_kasumi_encryption_test_case_3),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_kasumi_cipher_auth_test_case_1),
12203 /** KASUMI generate auth, then encrypt (F8) */
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_kasumi_auth_cipher_test_case_1),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_kasumi_auth_cipher_test_case_2),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_kasumi_auth_cipher_test_case_2_oop),
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_kasumi_auth_cipher_test_case_2_sgl),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12215 /** KASUMI decrypt (F8), then verify auth */
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_kasumi_auth_cipher_verify_test_case_1),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_kasumi_auth_cipher_verify_test_case_2),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_kasumi_auth_cipher_verify_test_case_2_oop),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12227 /** Negative tests */
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12230 TEST_CASE_ST(ut_setup, ut_teardown,
12231 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 authentication_verify_AES128_GMAC_fail_data_corrupt),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12265 /** Mixed CIPHER + HASH algorithms */
12266 /** AUTH AES CMAC + CIPHER AES CTR */
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12284 TEST_CASES_END() /**< NULL terminate unit test array */
12288 static struct unit_test_suite cryptodev_virtio_testsuite = {
12289 .suite_name = "Crypto VIRTIO Unit Test Suite",
12290 .setup = testsuite_setup,
12291 .teardown = testsuite_teardown,
12292 .unit_test_cases = {
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_cipheronly_virtio_all),
12296 TEST_CASES_END() /**< NULL terminate unit test array */
12300 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12301 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12302 .setup = testsuite_setup,
12303 .teardown = testsuite_teardown,
12304 .unit_test_cases = {
12305 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 test_AES_GCM_authenticated_encryption_test_case_1),
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 test_AES_GCM_authenticated_encryption_test_case_2),
12310 TEST_CASE_ST(ut_setup, ut_teardown,
12311 test_AES_GCM_authenticated_encryption_test_case_3),
12312 TEST_CASE_ST(ut_setup, ut_teardown,
12313 test_AES_GCM_authenticated_encryption_test_case_4),
12314 TEST_CASE_ST(ut_setup, ut_teardown,
12315 test_AES_GCM_authenticated_encryption_test_case_5),
12316 TEST_CASE_ST(ut_setup, ut_teardown,
12317 test_AES_GCM_authenticated_encryption_test_case_6),
12318 TEST_CASE_ST(ut_setup, ut_teardown,
12319 test_AES_GCM_authenticated_encryption_test_case_7),
12321 /** AES GCM Authenticated Decryption */
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 test_AES_GCM_authenticated_decryption_test_case_1),
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 test_AES_GCM_authenticated_decryption_test_case_2),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_AES_GCM_authenticated_decryption_test_case_3),
12328 TEST_CASE_ST(ut_setup, ut_teardown,
12329 test_AES_GCM_authenticated_decryption_test_case_4),
12330 TEST_CASE_ST(ut_setup, ut_teardown,
12331 test_AES_GCM_authenticated_decryption_test_case_5),
12332 TEST_CASE_ST(ut_setup, ut_teardown,
12333 test_AES_GCM_authenticated_decryption_test_case_6),
12334 TEST_CASE_ST(ut_setup, ut_teardown,
12335 test_AES_GCM_authenticated_decryption_test_case_7),
12337 /** AES GCM Authenticated Encryption 192 bits key */
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_AES_GCM_auth_encryption_test_case_192_1),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_AES_GCM_auth_encryption_test_case_192_2),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_AES_GCM_auth_encryption_test_case_192_3),
12344 TEST_CASE_ST(ut_setup, ut_teardown,
12345 test_AES_GCM_auth_encryption_test_case_192_4),
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_AES_GCM_auth_encryption_test_case_192_5),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_AES_GCM_auth_encryption_test_case_192_6),
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_AES_GCM_auth_encryption_test_case_192_7),
12353 /** AES GCM Authenticated Decryption 192 bits key */
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_AES_GCM_auth_decryption_test_case_192_1),
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_AES_GCM_auth_decryption_test_case_192_2),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_AES_GCM_auth_decryption_test_case_192_3),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_AES_GCM_auth_decryption_test_case_192_4),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_AES_GCM_auth_decryption_test_case_192_5),
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_AES_GCM_auth_decryption_test_case_192_6),
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_AES_GCM_auth_decryption_test_case_192_7),
12369 /** AES GCM Authenticated Encryption 256 bits key */
12370 TEST_CASE_ST(ut_setup, ut_teardown,
12371 test_AES_GCM_auth_encryption_test_case_256_1),
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_AES_GCM_auth_encryption_test_case_256_2),
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_AES_GCM_auth_encryption_test_case_256_3),
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_AES_GCM_auth_encryption_test_case_256_4),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 test_AES_GCM_auth_encryption_test_case_256_5),
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_AES_GCM_auth_encryption_test_case_256_6),
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_AES_GCM_auth_encryption_test_case_256_7),
12385 /** AES GCM Authenticated Decryption 256 bits key */
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_AES_GCM_auth_decryption_test_case_256_1),
12388 TEST_CASE_ST(ut_setup, ut_teardown,
12389 test_AES_GCM_auth_decryption_test_case_256_2),
12390 TEST_CASE_ST(ut_setup, ut_teardown,
12391 test_AES_GCM_auth_decryption_test_case_256_3),
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_AES_GCM_auth_decryption_test_case_256_4),
12394 TEST_CASE_ST(ut_setup, ut_teardown,
12395 test_AES_GCM_auth_decryption_test_case_256_5),
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 test_AES_GCM_auth_decryption_test_case_256_6),
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_AES_GCM_auth_decryption_test_case_256_7),
12401 /** AES GCM Authenticated Encryption big aad size */
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_AES_GCM_auth_encryption_test_case_aad_1),
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_AES_GCM_auth_encryption_test_case_aad_2),
12407 /** AES GCM Authenticated Decryption big aad size */
12408 TEST_CASE_ST(ut_setup, ut_teardown,
12409 test_AES_GCM_auth_decryption_test_case_aad_1),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_AES_GCM_auth_decryption_test_case_aad_2),
12413 /** Session-less tests */
12414 TEST_CASE_ST(ut_setup, ut_teardown,
12415 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12419 /** AES GMAC Authentication */
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_AES_GMAC_authentication_test_case_1),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_AES_GMAC_authentication_verify_test_case_1),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_AES_GMAC_authentication_test_case_2),
12426 TEST_CASE_ST(ut_setup, ut_teardown,
12427 test_AES_GMAC_authentication_verify_test_case_2),
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_AES_GMAC_authentication_test_case_3),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 test_AES_GMAC_authentication_verify_test_case_3),
12432 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12434 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12435 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12436 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12437 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_DES_cipheronly_mb_all),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_DES_docsis_mb_all),
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_3DES_cipheronly_mb_all),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_AES_CCM_authenticated_encryption_test_case_128_1),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_AES_CCM_authenticated_decryption_test_case_128_1),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_AES_CCM_authenticated_encryption_test_case_128_2),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_AES_CCM_authenticated_decryption_test_case_128_2),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_AES_CCM_authenticated_encryption_test_case_128_3),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_AES_CCM_authenticated_decryption_test_case_128_3),
12457 TEST_CASES_END() /**< NULL terminate unit test array */
12461 static struct unit_test_suite cryptodev_openssl_testsuite = {
12462 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12463 .setup = testsuite_setup,
12464 .teardown = testsuite_teardown,
12465 .unit_test_cases = {
12466 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_multi_session_random_usage),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_AES_chain_openssl_all),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_cipheronly_openssl_all),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_3DES_chain_openssl_all),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_3DES_cipheronly_openssl_all),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_DES_cipheronly_openssl_all),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_DES_docsis_openssl_all),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_authonly_openssl_all),
12484 /** AES GCM Authenticated Encryption */
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_AES_GCM_authenticated_encryption_test_case_1),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_AES_GCM_authenticated_encryption_test_case_2),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_AES_GCM_authenticated_encryption_test_case_3),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_AES_GCM_authenticated_encryption_test_case_4),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_AES_GCM_authenticated_encryption_test_case_5),
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 test_AES_GCM_authenticated_encryption_test_case_6),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_AES_GCM_authenticated_encryption_test_case_7),
12500 /** AES GCM Authenticated Decryption */
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_AES_GCM_authenticated_decryption_test_case_1),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_GCM_authenticated_decryption_test_case_2),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_AES_GCM_authenticated_decryption_test_case_3),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_GCM_authenticated_decryption_test_case_4),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_AES_GCM_authenticated_decryption_test_case_5),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_AES_GCM_authenticated_decryption_test_case_6),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_AES_GCM_authenticated_decryption_test_case_7),
12517 /** AES GCM Authenticated Encryption 192 bits key */
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_auth_encryption_test_case_192_1),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_encryption_test_case_192_2),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_encryption_test_case_192_3),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_auth_encryption_test_case_192_4),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_auth_encryption_test_case_192_5),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_auth_encryption_test_case_192_6),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_auth_encryption_test_case_192_7),
12533 /** AES GCM Authenticated Decryption 192 bits key */
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_auth_decryption_test_case_192_1),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_decryption_test_case_192_2),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_decryption_test_case_192_3),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_auth_decryption_test_case_192_4),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_decryption_test_case_192_5),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_auth_decryption_test_case_192_6),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_auth_decryption_test_case_192_7),
12549 /** AES GCM Authenticated Encryption 256 bits key */
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_auth_encryption_test_case_256_1),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_encryption_test_case_256_2),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_encryption_test_case_256_3),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_auth_encryption_test_case_256_4),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_auth_encryption_test_case_256_5),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_AES_GCM_auth_encryption_test_case_256_6),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_AES_GCM_auth_encryption_test_case_256_7),
12565 /** AES GCM Authenticated Decryption 256 bits key */
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_AES_GCM_auth_decryption_test_case_256_1),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_AES_GCM_auth_decryption_test_case_256_2),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_AES_GCM_auth_decryption_test_case_256_3),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_AES_GCM_auth_decryption_test_case_256_4),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_AES_GCM_auth_decryption_test_case_256_5),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_AES_GCM_auth_decryption_test_case_256_6),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_AES_GCM_auth_decryption_test_case_256_7),
12581 /** AES GMAC Authentication */
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_AES_GMAC_authentication_test_case_1),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_AES_GMAC_authentication_verify_test_case_1),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_AES_GMAC_authentication_test_case_2),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_AES_GMAC_authentication_verify_test_case_2),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_AES_GMAC_authentication_test_case_3),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_AES_GMAC_authentication_verify_test_case_3),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_AES_GMAC_authentication_test_case_4),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_AES_GMAC_authentication_verify_test_case_4),
12599 /** AES CCM Authenticated Encryption 128 bits key */
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_AES_CCM_authenticated_encryption_test_case_128_1),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_AES_CCM_authenticated_encryption_test_case_128_2),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_AES_CCM_authenticated_encryption_test_case_128_3),
12607 /** AES CCM Authenticated Decryption 128 bits key*/
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_AES_CCM_authenticated_decryption_test_case_128_1),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_AES_CCM_authenticated_decryption_test_case_128_2),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_AES_CCM_authenticated_decryption_test_case_128_3),
12615 /** AES CCM Authenticated Encryption 192 bits key */
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_AES_CCM_authenticated_encryption_test_case_192_1),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_AES_CCM_authenticated_encryption_test_case_192_2),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_AES_CCM_authenticated_encryption_test_case_192_3),
12623 /** AES CCM Authenticated Decryption 192 bits key*/
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_AES_CCM_authenticated_decryption_test_case_192_1),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_AES_CCM_authenticated_decryption_test_case_192_2),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_AES_CCM_authenticated_decryption_test_case_192_3),
12631 /** AES CCM Authenticated Encryption 256 bits key */
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_CCM_authenticated_encryption_test_case_256_1),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_CCM_authenticated_encryption_test_case_256_2),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_CCM_authenticated_encryption_test_case_256_3),
12639 /** AES CCM Authenticated Decryption 256 bits key*/
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_CCM_authenticated_decryption_test_case_256_1),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_CCM_authenticated_decryption_test_case_256_2),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_CCM_authenticated_decryption_test_case_256_3),
12647 /** Scatter-Gather */
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12651 /** Negative tests */
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 authentication_verify_AES128_GMAC_fail_data_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12672 TEST_CASES_END() /**< NULL terminate unit test array */
12676 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12677 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12678 .setup = testsuite_setup,
12679 .teardown = testsuite_teardown,
12680 .unit_test_cases = {
12681 /** AES GCM Authenticated Encryption */
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_AES_GCM_authenticated_encryption_test_case_1),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_AES_GCM_authenticated_encryption_test_case_2),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_AES_GCM_authenticated_encryption_test_case_3),
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_AES_GCM_authenticated_encryption_test_case_4),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_AES_GCM_authenticated_encryption_test_case_5),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_AES_GCM_authenticated_encryption_test_case_6),
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_AES_GCM_authenticated_encryption_test_case_7),
12697 /** AES GCM Authenticated Decryption */
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_authenticated_decryption_test_case_1),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_authenticated_decryption_test_case_2),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_AES_GCM_authenticated_decryption_test_case_3),
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_authenticated_decryption_test_case_4),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_authenticated_decryption_test_case_5),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_authenticated_decryption_test_case_6),
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_AES_GCM_authenticated_decryption_test_case_7),
12713 /** AES GCM Authenticated Encryption 192 bits key */
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_auth_encryption_test_case_192_1),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_auth_encryption_test_case_192_2),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_AES_GCM_auth_encryption_test_case_192_3),
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_AES_GCM_auth_encryption_test_case_192_4),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_auth_encryption_test_case_192_5),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_AES_GCM_auth_encryption_test_case_192_6),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 test_AES_GCM_auth_encryption_test_case_192_7),
12729 /** AES GCM Authenticated Decryption 192 bits key */
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 test_AES_GCM_auth_decryption_test_case_192_1),
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_AES_GCM_auth_decryption_test_case_192_2),
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_AES_GCM_auth_decryption_test_case_192_3),
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_AES_GCM_auth_decryption_test_case_192_4),
12738 TEST_CASE_ST(ut_setup, ut_teardown,
12739 test_AES_GCM_auth_decryption_test_case_192_5),
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_AES_GCM_auth_decryption_test_case_192_6),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_AES_GCM_auth_decryption_test_case_192_7),
12745 /** AES GCM Authenticated Encryption 256 bits key */
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_AES_GCM_auth_encryption_test_case_256_1),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_AES_GCM_auth_encryption_test_case_256_2),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_AES_GCM_auth_encryption_test_case_256_3),
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_AES_GCM_auth_encryption_test_case_256_4),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_AES_GCM_auth_encryption_test_case_256_5),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_AES_GCM_auth_encryption_test_case_256_6),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_AES_GCM_auth_encryption_test_case_256_7),
12761 /** AES GCM Authenticated Decryption 256 bits key */
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_AES_GCM_auth_decryption_test_case_256_1),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_AES_GCM_auth_decryption_test_case_256_2),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_AES_GCM_auth_decryption_test_case_256_3),
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_AES_GCM_auth_decryption_test_case_256_4),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_AES_GCM_auth_decryption_test_case_256_5),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_AES_GCM_auth_decryption_test_case_256_6),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GCM_auth_decryption_test_case_256_7),
12777 /** AES GCM Authenticated Encryption big aad size */
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_AES_GCM_auth_encryption_test_case_aad_1),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GCM_auth_encryption_test_case_aad_2),
12783 /** AES GCM Authenticated Decryption big aad size */
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_AES_GCM_auth_decryption_test_case_aad_1),
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_AES_GCM_auth_decryption_test_case_aad_2),
12789 /** AES GMAC Authentication */
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_AES_GMAC_authentication_test_case_1),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_GMAC_authentication_verify_test_case_1),
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 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_AES_GMAC_authentication_test_case_4),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_AES_GMAC_authentication_verify_test_case_4),
12803 /** Negative tests */
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 authentication_verify_AES128_GMAC_fail_data_corrupt),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12809 /** Out of place tests */
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12815 /** Session-less tests */
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12821 /** Scatter-Gather */
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12825 TEST_CASES_END() /**< NULL terminate unit test array */
12829 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12830 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12831 .setup = testsuite_setup,
12832 .teardown = testsuite_teardown,
12833 .unit_test_cases = {
12834 /** KASUMI encrypt only (UEA1) */
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_kasumi_encryption_test_case_1),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_kasumi_encryption_test_case_1_sgl),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_kasumi_encryption_test_case_2),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_kasumi_encryption_test_case_3),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_kasumi_encryption_test_case_4),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_kasumi_encryption_test_case_5),
12847 /** KASUMI decrypt only (UEA1) */
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_kasumi_decryption_test_case_1),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_kasumi_decryption_test_case_2),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_kasumi_decryption_test_case_3),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_kasumi_decryption_test_case_4),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_kasumi_decryption_test_case_5),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_kasumi_encryption_test_case_1_oop),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_kasumi_encryption_test_case_1_oop_sgl),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_kasumi_decryption_test_case_1_oop),
12868 /** KASUMI hash only (UIA1) */
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_kasumi_hash_generate_test_case_1),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_kasumi_hash_generate_test_case_2),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_kasumi_hash_generate_test_case_3),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_kasumi_hash_generate_test_case_4),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_kasumi_hash_generate_test_case_5),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_kasumi_hash_generate_test_case_6),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_kasumi_hash_verify_test_case_1),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_kasumi_hash_verify_test_case_2),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_kasumi_hash_verify_test_case_3),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_kasumi_hash_verify_test_case_4),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_kasumi_hash_verify_test_case_5),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_kasumi_cipher_auth_test_case_1),
12894 /** KASUMI generate auth, then encrypt (F8) */
12895 TEST_CASE_ST(ut_setup, ut_teardown,
12896 test_kasumi_auth_cipher_test_case_1),
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_kasumi_auth_cipher_test_case_2),
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_kasumi_auth_cipher_test_case_2_oop),
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 test_kasumi_auth_cipher_test_case_2_sgl),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12906 /** KASUMI decrypt (F8), then verify auth */
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_kasumi_auth_cipher_verify_test_case_1),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_kasumi_auth_cipher_verify_test_case_2),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_kasumi_auth_cipher_verify_test_case_2_oop),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12917 TEST_CASES_END() /**< NULL terminate unit test array */
12920 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12921 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12922 .setup = testsuite_setup,
12923 .teardown = testsuite_teardown,
12924 .unit_test_cases = {
12925 /** SNOW 3G encrypt only (UEA2) */
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_snow3g_encryption_test_case_1),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_snow3g_encryption_test_case_2),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_snow3g_encryption_test_case_3),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_snow3g_encryption_test_case_4),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_snow3g_encryption_test_case_5),
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 test_snow3g_auth_cipher_with_digest_test_case_1),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_snow3g_encryption_test_case_1_oop),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_snow3g_encryption_test_case_1_oop_sgl),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_snow3g_decryption_test_case_1_oop),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_snow3g_encryption_test_case_1_offset_oop),
12949 /** SNOW 3G decrypt only (UEA2) */
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_snow3g_decryption_test_case_1),
12952 TEST_CASE_ST(ut_setup, ut_teardown,
12953 test_snow3g_decryption_test_case_2),
12954 TEST_CASE_ST(ut_setup, ut_teardown,
12955 test_snow3g_decryption_test_case_3),
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 test_snow3g_decryption_test_case_4),
12958 TEST_CASE_ST(ut_setup, ut_teardown,
12959 test_snow3g_decryption_test_case_5),
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 test_snow3g_decryption_with_digest_test_case_1),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_snow3g_hash_generate_test_case_1),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_snow3g_hash_generate_test_case_2),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_snow3g_hash_generate_test_case_3),
12968 /* Tests with buffers which length is not byte-aligned */
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_snow3g_hash_generate_test_case_4),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_snow3g_hash_generate_test_case_5),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_snow3g_hash_generate_test_case_6),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 test_snow3g_hash_verify_test_case_1),
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 test_snow3g_hash_verify_test_case_2),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_snow3g_hash_verify_test_case_3),
12981 /* Tests with buffers which length is not byte-aligned */
12982 TEST_CASE_ST(ut_setup, ut_teardown,
12983 test_snow3g_hash_verify_test_case_4),
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_snow3g_hash_verify_test_case_5),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_snow3g_hash_verify_test_case_6),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_snow3g_cipher_auth_test_case_1),
12991 /** SNOW 3G generate auth, then encrypt (UEA2) */
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_snow3g_auth_cipher_test_case_1),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_snow3g_auth_cipher_test_case_2),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_snow3g_auth_cipher_test_case_2_oop),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_snow3g_auth_cipher_part_digest_enc),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_snow3g_auth_cipher_part_digest_enc_oop),
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_snow3g_auth_cipher_test_case_3_sgl),
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_snow3g_auth_cipher_part_digest_enc_sgl),
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13011 /** SNOW 3G decrypt (UEA2), then verify auth */
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_snow3g_auth_cipher_verify_test_case_1),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_snow3g_auth_cipher_verify_test_case_2),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_snow3g_auth_cipher_verify_test_case_2_oop),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_snow3g_auth_cipher_verify_part_digest_enc),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13031 TEST_CASES_END() /**< NULL terminate unit test array */
13035 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
13036 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13037 .setup = testsuite_setup,
13038 .teardown = testsuite_teardown,
13039 .unit_test_cases = {
13040 /** ZUC encrypt only (EEA3) */
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_zuc_encryption_test_case_1),
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 test_zuc_encryption_test_case_2),
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 test_zuc_encryption_test_case_3),
13047 TEST_CASE_ST(ut_setup, ut_teardown,
13048 test_zuc_encryption_test_case_4),
13049 TEST_CASE_ST(ut_setup, ut_teardown,
13050 test_zuc_encryption_test_case_5),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 test_zuc_hash_generate_test_case_1),
13053 TEST_CASE_ST(ut_setup, ut_teardown,
13054 test_zuc_hash_generate_test_case_2),
13055 TEST_CASE_ST(ut_setup, ut_teardown,
13056 test_zuc_hash_generate_test_case_3),
13057 TEST_CASE_ST(ut_setup, ut_teardown,
13058 test_zuc_hash_generate_test_case_4),
13059 TEST_CASE_ST(ut_setup, ut_teardown,
13060 test_zuc_hash_generate_test_case_5),
13061 TEST_CASE_ST(ut_setup, ut_teardown,
13062 test_zuc_encryption_test_case_6_sgl),
13063 TEST_CASES_END() /**< NULL terminate unit test array */
13067 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13068 .suite_name = "Crypto CAAM JR Unit Test Suite",
13069 .setup = testsuite_setup,
13070 .teardown = testsuite_teardown,
13071 .unit_test_cases = {
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_device_configure_invalid_dev_id),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_multi_session),
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_AES_chain_caam_jr_all),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_3DES_chain_caam_jr_all),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_AES_cipheronly_caam_jr_all),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_3DES_cipheronly_caam_jr_all),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_authonly_caam_jr_all),
13088 TEST_CASES_END() /**< NULL terminate unit test array */
13092 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
13093 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13094 .setup = testsuite_setup,
13095 .teardown = testsuite_teardown,
13096 .unit_test_cases = {
13097 TEST_CASE_ST(ut_setup, ut_teardown,
13098 test_device_configure_invalid_dev_id),
13099 TEST_CASE_ST(ut_setup, ut_teardown,
13100 test_multi_session),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_AES_chain_dpaa_sec_all),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_3DES_chain_dpaa_sec_all),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_AES_cipheronly_dpaa_sec_all),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_3DES_cipheronly_dpaa_sec_all),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_authonly_dpaa_sec_all),
13113 #ifdef RTE_LIBRTE_SECURITY
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_PDCP_PROTO_cplane_encap_all),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_PDCP_PROTO_cplane_decap_all),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_PDCP_PROTO_uplane_encap_all),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_PDCP_PROTO_uplane_decap_all),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_PDCP_PROTO_SGL_in_place_32B),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_PDCP_PROTO_SGL_oop_32B_128B),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_PDCP_PROTO_SGL_oop_32B_40B),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_PDCP_PROTO_SGL_oop_128B_32B),
13135 /** AES GCM Authenticated Encryption */
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_AES_GCM_authenticated_encryption_test_case_1),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_AES_GCM_authenticated_encryption_test_case_2),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_AES_GCM_authenticated_encryption_test_case_3),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_AES_GCM_authenticated_encryption_test_case_4),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_AES_GCM_authenticated_encryption_test_case_5),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_AES_GCM_authenticated_encryption_test_case_6),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_AES_GCM_authenticated_encryption_test_case_7),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_AES_GCM_authenticated_encryption_test_case_8),
13161 /** AES GCM Authenticated Decryption */
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GCM_authenticated_decryption_test_case_1),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_GCM_authenticated_decryption_test_case_2),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_GCM_authenticated_decryption_test_case_3),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GCM_authenticated_decryption_test_case_4),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_AES_GCM_authenticated_decryption_test_case_5),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GCM_authenticated_decryption_test_case_6),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_AES_GCM_authenticated_decryption_test_case_7),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GCM_authenticated_decryption_test_case_8),
13179 /** AES GCM Authenticated Encryption 192 bits key */
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GCM_auth_encryption_test_case_192_1),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GCM_auth_encryption_test_case_192_2),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GCM_auth_encryption_test_case_192_3),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_AES_GCM_auth_encryption_test_case_192_4),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GCM_auth_encryption_test_case_192_5),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GCM_auth_encryption_test_case_192_6),
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 test_AES_GCM_auth_encryption_test_case_192_7),
13195 /** AES GCM Authenticated Decryption 192 bits key */
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_AES_GCM_auth_decryption_test_case_192_1),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_AES_GCM_auth_decryption_test_case_192_2),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_AES_GCM_auth_decryption_test_case_192_3),
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 test_AES_GCM_auth_decryption_test_case_192_4),
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_AES_GCM_auth_decryption_test_case_192_5),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_AES_GCM_auth_decryption_test_case_192_6),
13208 TEST_CASE_ST(ut_setup, ut_teardown,
13209 test_AES_GCM_auth_decryption_test_case_192_7),
13211 /** AES GCM Authenticated Encryption 256 bits key */
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_AES_GCM_auth_encryption_test_case_256_1),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 test_AES_GCM_auth_encryption_test_case_256_2),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_AES_GCM_auth_encryption_test_case_256_3),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_AES_GCM_auth_encryption_test_case_256_4),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_AES_GCM_auth_encryption_test_case_256_5),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_AES_GCM_auth_encryption_test_case_256_6),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_AES_GCM_auth_encryption_test_case_256_7),
13227 /** AES GCM Authenticated Decryption 256 bits key */
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_AES_GCM_auth_decryption_test_case_256_1),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_AES_GCM_auth_decryption_test_case_256_2),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_AES_GCM_auth_decryption_test_case_256_3),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_AES_GCM_auth_decryption_test_case_256_4),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_AES_GCM_auth_decryption_test_case_256_5),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_AES_GCM_auth_decryption_test_case_256_6),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_AES_GCM_auth_decryption_test_case_256_7),
13243 /** Out of place tests */
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13249 /** SNOW 3G encrypt only (UEA2) */
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_snow3g_encryption_test_case_1),
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_snow3g_encryption_test_case_2),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_snow3g_encryption_test_case_3),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_snow3g_encryption_test_case_4),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_snow3g_encryption_test_case_5),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_snow3g_encryption_test_case_1_oop),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_snow3g_encryption_test_case_1_oop_sgl),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_snow3g_decryption_test_case_1_oop),
13268 /** SNOW 3G decrypt only (UEA2) */
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_snow3g_decryption_test_case_1),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_snow3g_decryption_test_case_2),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_snow3g_decryption_test_case_3),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_snow3g_decryption_test_case_4),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_snow3g_decryption_test_case_5),
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_snow3g_hash_generate_test_case_1),
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_snow3g_hash_generate_test_case_2),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_snow3g_hash_generate_test_case_3),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_snow3g_hash_verify_test_case_1),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_snow3g_hash_verify_test_case_2),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_snow3g_hash_verify_test_case_3),
13293 /** ZUC encrypt only (EEA3) */
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_zuc_encryption_test_case_1),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_zuc_encryption_test_case_2),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_zuc_encryption_test_case_3),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_zuc_encryption_test_case_4),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_zuc_encryption_test_case_5),
13305 /** ZUC authenticate (EIA3) */
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_zuc_hash_generate_test_case_6),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_zuc_hash_generate_test_case_7),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_zuc_hash_generate_test_case_8),
13313 /** Negative tests */
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13353 TEST_CASES_END() /**< NULL terminate unit test array */
13357 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13358 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13359 .setup = testsuite_setup,
13360 .teardown = testsuite_teardown,
13361 .unit_test_cases = {
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_device_configure_invalid_dev_id),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_multi_session),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_AES_chain_dpaa2_sec_all),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_3DES_chain_dpaa2_sec_all),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_AES_cipheronly_dpaa2_sec_all),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_3DES_cipheronly_dpaa2_sec_all),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_authonly_dpaa2_sec_all),
13377 #ifdef RTE_LIBRTE_SECURITY
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_PDCP_PROTO_cplane_encap_all),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_PDCP_PROTO_cplane_decap_all),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_PDCP_PROTO_uplane_encap_all),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_PDCP_PROTO_uplane_decap_all),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_PDCP_PROTO_SGL_in_place_32B),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_PDCP_PROTO_SGL_oop_32B_128B),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_PDCP_PROTO_SGL_oop_32B_40B),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_PDCP_PROTO_SGL_oop_128B_32B),
13399 /** AES GCM Authenticated Encryption */
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_AES_GCM_authenticated_encryption_test_case_1),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_AES_GCM_authenticated_encryption_test_case_2),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_AES_GCM_authenticated_encryption_test_case_3),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_AES_GCM_authenticated_encryption_test_case_4),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_AES_GCM_authenticated_encryption_test_case_5),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_AES_GCM_authenticated_encryption_test_case_6),
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_AES_GCM_authenticated_encryption_test_case_7),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_AES_GCM_authenticated_encryption_test_case_8),
13425 /** AES GCM Authenticated Decryption */
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_AES_GCM_authenticated_decryption_test_case_1),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_AES_GCM_authenticated_decryption_test_case_2),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_AES_GCM_authenticated_decryption_test_case_3),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_AES_GCM_authenticated_decryption_test_case_4),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_AES_GCM_authenticated_decryption_test_case_5),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_AES_GCM_authenticated_decryption_test_case_6),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_AES_GCM_authenticated_decryption_test_case_7),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_AES_GCM_authenticated_decryption_test_case_8),
13443 /** AES GCM Authenticated Encryption 192 bits key */
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_AES_GCM_auth_encryption_test_case_192_1),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_AES_GCM_auth_encryption_test_case_192_2),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_AES_GCM_auth_encryption_test_case_192_3),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_AES_GCM_auth_encryption_test_case_192_4),
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_AES_GCM_auth_encryption_test_case_192_5),
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_AES_GCM_auth_encryption_test_case_192_6),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_AES_GCM_auth_encryption_test_case_192_7),
13459 /** AES GCM Authenticated Decryption 192 bits key */
13460 TEST_CASE_ST(ut_setup, ut_teardown,
13461 test_AES_GCM_auth_decryption_test_case_192_1),
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 test_AES_GCM_auth_decryption_test_case_192_2),
13464 TEST_CASE_ST(ut_setup, ut_teardown,
13465 test_AES_GCM_auth_decryption_test_case_192_3),
13466 TEST_CASE_ST(ut_setup, ut_teardown,
13467 test_AES_GCM_auth_decryption_test_case_192_4),
13468 TEST_CASE_ST(ut_setup, ut_teardown,
13469 test_AES_GCM_auth_decryption_test_case_192_5),
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_GCM_auth_decryption_test_case_192_6),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_AES_GCM_auth_decryption_test_case_192_7),
13475 /** AES GCM Authenticated Encryption 256 bits key */
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_AES_GCM_auth_encryption_test_case_256_1),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_encryption_test_case_256_2),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_encryption_test_case_256_3),
13482 TEST_CASE_ST(ut_setup, ut_teardown,
13483 test_AES_GCM_auth_encryption_test_case_256_4),
13484 TEST_CASE_ST(ut_setup, ut_teardown,
13485 test_AES_GCM_auth_encryption_test_case_256_5),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_encryption_test_case_256_6),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_AES_GCM_auth_encryption_test_case_256_7),
13491 /** AES GCM Authenticated Decryption 256 bits key */
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 test_AES_GCM_auth_decryption_test_case_256_1),
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 test_AES_GCM_auth_decryption_test_case_256_2),
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_AES_GCM_auth_decryption_test_case_256_3),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_AES_GCM_auth_decryption_test_case_256_4),
13500 TEST_CASE_ST(ut_setup, ut_teardown,
13501 test_AES_GCM_auth_decryption_test_case_256_5),
13502 TEST_CASE_ST(ut_setup, ut_teardown,
13503 test_AES_GCM_auth_decryption_test_case_256_6),
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 test_AES_GCM_auth_decryption_test_case_256_7),
13507 /** Out of place tests */
13508 TEST_CASE_ST(ut_setup, ut_teardown,
13509 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13510 TEST_CASE_ST(ut_setup, ut_teardown,
13511 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13513 /** SNOW 3G encrypt only (UEA2) */
13514 TEST_CASE_ST(ut_setup, ut_teardown,
13515 test_snow3g_encryption_test_case_1),
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 test_snow3g_encryption_test_case_2),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 test_snow3g_encryption_test_case_3),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 test_snow3g_encryption_test_case_4),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 test_snow3g_encryption_test_case_5),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_snow3g_encryption_test_case_1_oop),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_snow3g_encryption_test_case_1_oop_sgl),
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_snow3g_decryption_test_case_1_oop),
13532 /** SNOW 3G decrypt only (UEA2) */
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_snow3g_decryption_test_case_1),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_snow3g_decryption_test_case_2),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_snow3g_decryption_test_case_3),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_snow3g_decryption_test_case_4),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_snow3g_decryption_test_case_5),
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_snow3g_hash_generate_test_case_1),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_snow3g_hash_generate_test_case_2),
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 test_snow3g_hash_generate_test_case_3),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_snow3g_hash_verify_test_case_1),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_snow3g_hash_verify_test_case_2),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_hash_verify_test_case_3),
13557 /** ZUC encrypt only (EEA3) */
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_zuc_encryption_test_case_1),
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_zuc_encryption_test_case_2),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_zuc_encryption_test_case_3),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_zuc_encryption_test_case_4),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_zuc_encryption_test_case_5),
13569 /** ZUC authenticate (EIA3) */
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_zuc_hash_generate_test_case_6),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_zuc_hash_generate_test_case_7),
13574 TEST_CASE_ST(ut_setup, ut_teardown,
13575 test_zuc_hash_generate_test_case_8),
13577 /** HMAC_MD5 Authentication */
13578 TEST_CASE_ST(ut_setup, ut_teardown,
13579 test_MD5_HMAC_generate_case_1),
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_MD5_HMAC_verify_case_1),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_MD5_HMAC_generate_case_2),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_MD5_HMAC_verify_case_2),
13587 /** Negative tests */
13588 TEST_CASE_ST(ut_setup, ut_teardown,
13589 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13592 TEST_CASE_ST(ut_setup, ut_teardown,
13593 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13600 TEST_CASE_ST(ut_setup, ut_teardown,
13601 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13612 TEST_CASE_ST(ut_setup, ut_teardown,
13613 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13622 TEST_CASE_ST(ut_setup, ut_teardown,
13623 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13628 TEST_CASES_END() /**< NULL terminate unit test array */
13632 static struct unit_test_suite cryptodev_null_testsuite = {
13633 .suite_name = "Crypto Device NULL Unit Test Suite",
13634 .setup = testsuite_setup,
13635 .teardown = testsuite_teardown,
13636 .unit_test_cases = {
13637 TEST_CASE_ST(ut_setup, ut_teardown,
13638 test_null_invalid_operation),
13639 TEST_CASE_ST(ut_setup, ut_teardown,
13640 test_null_burst_operation),
13641 TEST_CASE_ST(ut_setup, ut_teardown,
13642 test_AES_chain_null_all),
13643 TEST_CASE_ST(ut_setup, ut_teardown,
13644 test_AES_cipheronly_null_all),
13645 TEST_CASE_ST(ut_setup, ut_teardown,
13646 test_authonly_null_all),
13648 TEST_CASES_END() /**< NULL terminate unit test array */
13652 static struct unit_test_suite cryptodev_armv8_testsuite = {
13653 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13654 .setup = testsuite_setup,
13655 .teardown = testsuite_teardown,
13656 .unit_test_cases = {
13657 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13659 /** Negative tests */
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13665 TEST_CASES_END() /**< NULL terminate unit test array */
13669 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13670 .suite_name = "Crypto Device Marvell Component Test Suite",
13671 .setup = testsuite_setup,
13672 .teardown = testsuite_teardown,
13673 .unit_test_cases = {
13674 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13675 TEST_CASE_ST(ut_setup, ut_teardown,
13676 test_multi_session_random_usage),
13677 TEST_CASE_ST(ut_setup, ut_teardown,
13678 test_AES_chain_mrvl_all),
13679 TEST_CASE_ST(ut_setup, ut_teardown,
13680 test_AES_cipheronly_mrvl_all),
13681 TEST_CASE_ST(ut_setup, ut_teardown,
13682 test_authonly_mrvl_all),
13683 TEST_CASE_ST(ut_setup, ut_teardown,
13684 test_3DES_chain_mrvl_all),
13685 TEST_CASE_ST(ut_setup, ut_teardown,
13686 test_3DES_cipheronly_mrvl_all),
13688 /** Negative tests */
13689 TEST_CASE_ST(ut_setup, ut_teardown,
13690 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13691 TEST_CASE_ST(ut_setup, ut_teardown,
13692 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13693 TEST_CASE_ST(ut_setup, ut_teardown,
13694 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13695 TEST_CASE_ST(ut_setup, ut_teardown,
13696 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13698 TEST_CASES_END() /**< NULL terminate unit test array */
13702 static struct unit_test_suite cryptodev_ccp_testsuite = {
13703 .suite_name = "Crypto Device CCP Unit Test Suite",
13704 .setup = testsuite_setup,
13705 .teardown = testsuite_teardown,
13706 .unit_test_cases = {
13707 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 test_multi_session_random_usage),
13710 TEST_CASE_ST(ut_setup, ut_teardown,
13711 test_AES_chain_ccp_all),
13712 TEST_CASE_ST(ut_setup, ut_teardown,
13713 test_AES_cipheronly_ccp_all),
13714 TEST_CASE_ST(ut_setup, ut_teardown,
13715 test_3DES_chain_ccp_all),
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 test_3DES_cipheronly_ccp_all),
13718 TEST_CASE_ST(ut_setup, ut_teardown,
13719 test_authonly_ccp_all),
13721 /** Negative tests */
13722 TEST_CASE_ST(ut_setup, ut_teardown,
13723 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13724 TEST_CASE_ST(ut_setup, ut_teardown,
13725 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13726 TEST_CASE_ST(ut_setup, ut_teardown,
13727 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13728 TEST_CASE_ST(ut_setup, ut_teardown,
13729 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13731 TEST_CASES_END() /**< NULL terminate unit test array */
13735 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13736 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13737 .setup = testsuite_setup,
13738 .teardown = testsuite_teardown,
13739 .unit_test_cases = {
13740 TEST_CASE_ST(ut_setup, ut_teardown,
13741 test_AES_chain_octeontx_all),
13742 TEST_CASE_ST(ut_setup, ut_teardown,
13743 test_AES_cipheronly_octeontx_all),
13744 TEST_CASE_ST(ut_setup, ut_teardown,
13745 test_3DES_chain_octeontx_all),
13746 TEST_CASE_ST(ut_setup, ut_teardown,
13747 test_3DES_cipheronly_octeontx_all),
13748 TEST_CASE_ST(ut_setup, ut_teardown,
13749 test_authonly_octeontx_all),
13751 /** AES GCM Authenticated Encryption */
13752 TEST_CASE_ST(ut_setup, ut_teardown,
13753 test_AES_GCM_authenticated_encryption_test_case_1),
13754 TEST_CASE_ST(ut_setup, ut_teardown,
13755 test_AES_GCM_authenticated_encryption_test_case_2),
13756 TEST_CASE_ST(ut_setup, ut_teardown,
13757 test_AES_GCM_authenticated_encryption_test_case_3),
13758 TEST_CASE_ST(ut_setup, ut_teardown,
13759 test_AES_GCM_authenticated_encryption_test_case_4),
13760 TEST_CASE_ST(ut_setup, ut_teardown,
13761 test_AES_GCM_authenticated_encryption_test_case_5),
13762 TEST_CASE_ST(ut_setup, ut_teardown,
13763 test_AES_GCM_authenticated_encryption_test_case_6),
13764 TEST_CASE_ST(ut_setup, ut_teardown,
13765 test_AES_GCM_authenticated_encryption_test_case_7),
13767 /** AES GCM Authenticated Decryption */
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_AES_GCM_authenticated_decryption_test_case_1),
13770 TEST_CASE_ST(ut_setup, ut_teardown,
13771 test_AES_GCM_authenticated_decryption_test_case_2),
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_AES_GCM_authenticated_decryption_test_case_3),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_AES_GCM_authenticated_decryption_test_case_4),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_AES_GCM_authenticated_decryption_test_case_5),
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_AES_GCM_authenticated_decryption_test_case_6),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_AES_GCM_authenticated_decryption_test_case_7),
13782 /** AES GMAC Authentication */
13783 TEST_CASE_ST(ut_setup, ut_teardown,
13784 test_AES_GMAC_authentication_test_case_1),
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_AES_GMAC_authentication_verify_test_case_1),
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_AES_GMAC_authentication_test_case_2),
13789 TEST_CASE_ST(ut_setup, ut_teardown,
13790 test_AES_GMAC_authentication_verify_test_case_2),
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_AES_GMAC_authentication_test_case_3),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_AES_GMAC_authentication_verify_test_case_3),
13796 /** SNOW 3G encrypt only (UEA2) */
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_snow3g_encryption_test_case_1),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_snow3g_encryption_test_case_2),
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_snow3g_encryption_test_case_3),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_snow3g_encryption_test_case_4),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_snow3g_encryption_test_case_5),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_snow3g_encryption_test_case_1_oop),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_snow3g_decryption_test_case_1_oop),
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_snow3g_encryption_test_case_1_oop_sgl),
13815 /** SNOW 3G decrypt only (UEA2) */
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_snow3g_decryption_test_case_1),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_snow3g_decryption_test_case_2),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_snow3g_decryption_test_case_3),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_snow3g_decryption_test_case_4),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 test_snow3g_decryption_test_case_5),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_snow3g_hash_generate_test_case_1),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_snow3g_hash_generate_test_case_2),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_snow3g_hash_generate_test_case_3),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_snow3g_hash_verify_test_case_1),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_snow3g_hash_verify_test_case_2),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 test_snow3g_hash_verify_test_case_3),
13840 /** ZUC encrypt only (EEA3) */
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_zuc_encryption_test_case_1),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_zuc_encryption_test_case_2),
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_zuc_encryption_test_case_3),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_zuc_encryption_test_case_4),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_zuc_encryption_test_case_5),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_zuc_hash_generate_test_case_1),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_zuc_hash_generate_test_case_2),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_zuc_hash_generate_test_case_3),
13857 TEST_CASE_ST(ut_setup, ut_teardown,
13858 test_zuc_hash_generate_test_case_4),
13859 TEST_CASE_ST(ut_setup, ut_teardown,
13860 test_zuc_hash_generate_test_case_5),
13861 TEST_CASE_ST(ut_setup, ut_teardown,
13862 test_zuc_encryption_test_case_6_sgl),
13864 /** KASUMI encrypt only (UEA1) */
13865 TEST_CASE_ST(ut_setup, ut_teardown,
13866 test_kasumi_encryption_test_case_1),
13867 TEST_CASE_ST(ut_setup, ut_teardown,
13868 test_kasumi_encryption_test_case_2),
13869 TEST_CASE_ST(ut_setup, ut_teardown,
13870 test_kasumi_encryption_test_case_3),
13871 TEST_CASE_ST(ut_setup, ut_teardown,
13872 test_kasumi_encryption_test_case_4),
13873 TEST_CASE_ST(ut_setup, ut_teardown,
13874 test_kasumi_encryption_test_case_5),
13875 TEST_CASE_ST(ut_setup, ut_teardown,
13876 test_kasumi_encryption_test_case_1_sgl),
13877 TEST_CASE_ST(ut_setup, ut_teardown,
13878 test_kasumi_encryption_test_case_1_oop_sgl),
13879 /** KASUMI decrypt only (UEA1) */
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_kasumi_decryption_test_case_1),
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_kasumi_decryption_test_case_2),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_kasumi_decryption_test_case_3),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_kasumi_decryption_test_case_4),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_kasumi_decryption_test_case_5),
13891 TEST_CASE_ST(ut_setup, ut_teardown,
13892 test_kasumi_encryption_test_case_1_oop),
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_kasumi_decryption_test_case_1_oop),
13896 /** KASUMI hash only (UIA1) */
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_kasumi_hash_generate_test_case_1),
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_kasumi_hash_generate_test_case_2),
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_kasumi_hash_generate_test_case_3),
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_kasumi_hash_generate_test_case_4),
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_kasumi_hash_generate_test_case_5),
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_kasumi_hash_generate_test_case_6),
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_kasumi_hash_verify_test_case_1),
13911 TEST_CASE_ST(ut_setup, ut_teardown,
13912 test_kasumi_hash_verify_test_case_2),
13913 TEST_CASE_ST(ut_setup, ut_teardown,
13914 test_kasumi_hash_verify_test_case_3),
13915 TEST_CASE_ST(ut_setup, ut_teardown,
13916 test_kasumi_hash_verify_test_case_4),
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_kasumi_hash_verify_test_case_5),
13921 TEST_CASE_ST(ut_setup, ut_teardown,
13922 test_null_cipher_only_operation),
13923 TEST_CASE_ST(ut_setup, ut_teardown,
13924 test_null_auth_only_operation),
13925 TEST_CASE_ST(ut_setup, ut_teardown,
13926 test_null_cipher_auth_operation),
13927 TEST_CASE_ST(ut_setup, ut_teardown,
13928 test_null_auth_cipher_operation),
13930 /** Negative tests */
13931 TEST_CASE_ST(ut_setup, ut_teardown,
13932 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13933 TEST_CASE_ST(ut_setup, ut_teardown,
13934 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13935 TEST_CASE_ST(ut_setup, ut_teardown,
13936 authentication_verify_AES128_GMAC_fail_data_corrupt),
13937 TEST_CASE_ST(ut_setup, ut_teardown,
13938 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13939 TEST_CASE_ST(ut_setup, ut_teardown,
13940 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13941 TEST_CASE_ST(ut_setup, ut_teardown,
13942 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13943 TEST_CASES_END() /**< NULL terminate unit test array */
13947 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13948 .suite_name = "Crypto NITROX Unit Test Suite",
13949 .setup = testsuite_setup,
13950 .teardown = testsuite_teardown,
13951 .unit_test_cases = {
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 test_device_configure_invalid_dev_id),
13954 TEST_CASE_ST(ut_setup, ut_teardown,
13955 test_device_configure_invalid_queue_pair_ids),
13956 TEST_CASE_ST(ut_setup, ut_teardown,
13957 test_AES_chain_nitrox_all),
13959 TEST_CASES_END() /**< NULL terminate unit test array */
13963 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13964 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13965 .setup = testsuite_setup,
13966 .teardown = testsuite_teardown,
13967 .unit_test_cases = {
13968 TEST_CASE_ST(ut_setup, ut_teardown,
13969 test_AES_chain_octeontx2_all),
13970 TEST_CASE_ST(ut_setup, ut_teardown,
13971 test_AES_cipheronly_octeontx2_all),
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_3DES_chain_octeontx2_all),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 test_3DES_cipheronly_octeontx2_all),
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 test_authonly_octeontx2_all),
13979 /** AES GCM Authenticated Encryption */
13980 TEST_CASE_ST(ut_setup, ut_teardown,
13981 test_AES_GCM_authenticated_encryption_test_case_1),
13982 TEST_CASE_ST(ut_setup, ut_teardown,
13983 test_AES_GCM_authenticated_encryption_test_case_2),
13984 TEST_CASE_ST(ut_setup, ut_teardown,
13985 test_AES_GCM_authenticated_encryption_test_case_3),
13986 TEST_CASE_ST(ut_setup, ut_teardown,
13987 test_AES_GCM_authenticated_encryption_test_case_4),
13988 TEST_CASE_ST(ut_setup, ut_teardown,
13989 test_AES_GCM_authenticated_encryption_test_case_5),
13990 TEST_CASE_ST(ut_setup, ut_teardown,
13991 test_AES_GCM_authenticated_encryption_test_case_6),
13992 TEST_CASE_ST(ut_setup, ut_teardown,
13993 test_AES_GCM_authenticated_encryption_test_case_7),
13995 /** AES GCM Authenticated Decryption */
13996 TEST_CASE_ST(ut_setup, ut_teardown,
13997 test_AES_GCM_authenticated_decryption_test_case_1),
13998 TEST_CASE_ST(ut_setup, ut_teardown,
13999 test_AES_GCM_authenticated_decryption_test_case_2),
14000 TEST_CASE_ST(ut_setup, ut_teardown,
14001 test_AES_GCM_authenticated_decryption_test_case_3),
14002 TEST_CASE_ST(ut_setup, ut_teardown,
14003 test_AES_GCM_authenticated_decryption_test_case_4),
14004 TEST_CASE_ST(ut_setup, ut_teardown,
14005 test_AES_GCM_authenticated_decryption_test_case_5),
14006 TEST_CASE_ST(ut_setup, ut_teardown,
14007 test_AES_GCM_authenticated_decryption_test_case_6),
14008 TEST_CASE_ST(ut_setup, ut_teardown,
14009 test_AES_GCM_authenticated_decryption_test_case_7),
14010 /** AES GMAC Authentication */
14011 TEST_CASE_ST(ut_setup, ut_teardown,
14012 test_AES_GMAC_authentication_test_case_1),
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_AES_GMAC_authentication_verify_test_case_1),
14015 TEST_CASE_ST(ut_setup, ut_teardown,
14016 test_AES_GMAC_authentication_test_case_2),
14017 TEST_CASE_ST(ut_setup, ut_teardown,
14018 test_AES_GMAC_authentication_verify_test_case_2),
14019 TEST_CASE_ST(ut_setup, ut_teardown,
14020 test_AES_GMAC_authentication_test_case_3),
14021 TEST_CASE_ST(ut_setup, ut_teardown,
14022 test_AES_GMAC_authentication_verify_test_case_3),
14024 /** SNOW 3G encrypt only (UEA2) */
14025 TEST_CASE_ST(ut_setup, ut_teardown,
14026 test_snow3g_encryption_test_case_1),
14027 TEST_CASE_ST(ut_setup, ut_teardown,
14028 test_snow3g_encryption_test_case_2),
14029 TEST_CASE_ST(ut_setup, ut_teardown,
14030 test_snow3g_encryption_test_case_3),
14031 TEST_CASE_ST(ut_setup, ut_teardown,
14032 test_snow3g_encryption_test_case_4),
14033 TEST_CASE_ST(ut_setup, ut_teardown,
14034 test_snow3g_encryption_test_case_5),
14036 TEST_CASE_ST(ut_setup, ut_teardown,
14037 test_snow3g_encryption_test_case_1_oop),
14038 TEST_CASE_ST(ut_setup, ut_teardown,
14039 test_snow3g_decryption_test_case_1_oop),
14040 TEST_CASE_ST(ut_setup, ut_teardown,
14041 test_snow3g_encryption_test_case_1_oop_sgl),
14043 /** SNOW 3G decrypt only (UEA2) */
14044 TEST_CASE_ST(ut_setup, ut_teardown,
14045 test_snow3g_decryption_test_case_1),
14046 TEST_CASE_ST(ut_setup, ut_teardown,
14047 test_snow3g_decryption_test_case_2),
14048 TEST_CASE_ST(ut_setup, ut_teardown,
14049 test_snow3g_decryption_test_case_3),
14050 TEST_CASE_ST(ut_setup, ut_teardown,
14051 test_snow3g_decryption_test_case_4),
14052 TEST_CASE_ST(ut_setup, ut_teardown,
14053 test_snow3g_decryption_test_case_5),
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 test_snow3g_hash_generate_test_case_1),
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 test_snow3g_hash_generate_test_case_2),
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 test_snow3g_hash_generate_test_case_3),
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 test_snow3g_hash_verify_test_case_1),
14063 TEST_CASE_ST(ut_setup, ut_teardown,
14064 test_snow3g_hash_verify_test_case_2),
14065 TEST_CASE_ST(ut_setup, ut_teardown,
14066 test_snow3g_hash_verify_test_case_3),
14068 /** ZUC encrypt only (EEA3) */
14069 TEST_CASE_ST(ut_setup, ut_teardown,
14070 test_zuc_encryption_test_case_1),
14071 TEST_CASE_ST(ut_setup, ut_teardown,
14072 test_zuc_encryption_test_case_2),
14073 TEST_CASE_ST(ut_setup, ut_teardown,
14074 test_zuc_encryption_test_case_3),
14075 TEST_CASE_ST(ut_setup, ut_teardown,
14076 test_zuc_encryption_test_case_4),
14077 TEST_CASE_ST(ut_setup, ut_teardown,
14078 test_zuc_encryption_test_case_5),
14079 TEST_CASE_ST(ut_setup, ut_teardown,
14080 test_zuc_hash_generate_test_case_1),
14081 TEST_CASE_ST(ut_setup, ut_teardown,
14082 test_zuc_hash_generate_test_case_2),
14083 TEST_CASE_ST(ut_setup, ut_teardown,
14084 test_zuc_hash_generate_test_case_3),
14085 TEST_CASE_ST(ut_setup, ut_teardown,
14086 test_zuc_hash_generate_test_case_4),
14087 TEST_CASE_ST(ut_setup, ut_teardown,
14088 test_zuc_hash_generate_test_case_5),
14089 TEST_CASE_ST(ut_setup, ut_teardown,
14090 test_zuc_encryption_test_case_6_sgl),
14092 /** KASUMI encrypt only (UEA1) */
14093 TEST_CASE_ST(ut_setup, ut_teardown,
14094 test_kasumi_encryption_test_case_1),
14095 TEST_CASE_ST(ut_setup, ut_teardown,
14096 test_kasumi_encryption_test_case_2),
14097 TEST_CASE_ST(ut_setup, ut_teardown,
14098 test_kasumi_encryption_test_case_3),
14099 TEST_CASE_ST(ut_setup, ut_teardown,
14100 test_kasumi_encryption_test_case_4),
14101 TEST_CASE_ST(ut_setup, ut_teardown,
14102 test_kasumi_encryption_test_case_5),
14103 TEST_CASE_ST(ut_setup, ut_teardown,
14104 test_kasumi_encryption_test_case_1_sgl),
14105 TEST_CASE_ST(ut_setup, ut_teardown,
14106 test_kasumi_encryption_test_case_1_oop_sgl),
14107 /** KASUMI decrypt only (UEA1) */
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_kasumi_decryption_test_case_1),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_kasumi_decryption_test_case_2),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_kasumi_decryption_test_case_3),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_kasumi_decryption_test_case_4),
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_kasumi_decryption_test_case_5),
14119 TEST_CASE_ST(ut_setup, ut_teardown,
14120 test_kasumi_encryption_test_case_1_oop),
14121 TEST_CASE_ST(ut_setup, ut_teardown,
14122 test_kasumi_decryption_test_case_1_oop),
14124 /** KASUMI hash only (UIA1) */
14125 TEST_CASE_ST(ut_setup, ut_teardown,
14126 test_kasumi_hash_generate_test_case_1),
14127 TEST_CASE_ST(ut_setup, ut_teardown,
14128 test_kasumi_hash_generate_test_case_2),
14129 TEST_CASE_ST(ut_setup, ut_teardown,
14130 test_kasumi_hash_generate_test_case_3),
14131 TEST_CASE_ST(ut_setup, ut_teardown,
14132 test_kasumi_hash_generate_test_case_4),
14133 TEST_CASE_ST(ut_setup, ut_teardown,
14134 test_kasumi_hash_generate_test_case_5),
14135 TEST_CASE_ST(ut_setup, ut_teardown,
14136 test_kasumi_hash_generate_test_case_6),
14137 TEST_CASE_ST(ut_setup, ut_teardown,
14138 test_kasumi_hash_verify_test_case_1),
14139 TEST_CASE_ST(ut_setup, ut_teardown,
14140 test_kasumi_hash_verify_test_case_2),
14141 TEST_CASE_ST(ut_setup, ut_teardown,
14142 test_kasumi_hash_verify_test_case_3),
14143 TEST_CASE_ST(ut_setup, ut_teardown,
14144 test_kasumi_hash_verify_test_case_4),
14145 TEST_CASE_ST(ut_setup, ut_teardown,
14146 test_kasumi_hash_verify_test_case_5),
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_null_cipher_only_operation),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_null_auth_only_operation),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_null_cipher_auth_operation),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_null_auth_cipher_operation),
14158 /** Negative tests */
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14161 TEST_CASE_ST(ut_setup, ut_teardown,
14162 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14163 TEST_CASE_ST(ut_setup, ut_teardown,
14164 authentication_verify_AES128_GMAC_fail_data_corrupt),
14165 TEST_CASE_ST(ut_setup, ut_teardown,
14166 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14171 TEST_CASES_END() /**< NULL terminate unit test array */
14176 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14178 gbl_driver_id = rte_cryptodev_driver_id_get(
14179 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14181 if (gbl_driver_id == -1) {
14182 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14183 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14184 "are enabled in config file to run this testsuite.\n");
14185 return TEST_SKIPPED;
14188 return unit_test_suite_runner(&cryptodev_qat_testsuite);
14192 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14194 gbl_driver_id = rte_cryptodev_driver_id_get(
14195 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14197 if (gbl_driver_id == -1) {
14198 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14199 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14200 "in config file to run this testsuite.\n");
14201 return TEST_FAILED;
14204 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14208 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14210 gbl_driver_id = rte_cryptodev_driver_id_get(
14211 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14213 if (gbl_driver_id == -1) {
14214 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14215 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14216 "in config file to run this testsuite.\n");
14217 return TEST_SKIPPED;
14220 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14224 test_cryptodev_openssl(void)
14226 gbl_driver_id = rte_cryptodev_driver_id_get(
14227 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14229 if (gbl_driver_id == -1) {
14230 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14231 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14232 "in config file to run this testsuite.\n");
14233 return TEST_SKIPPED;
14236 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14240 test_cryptodev_aesni_gcm(void)
14242 gbl_driver_id = rte_cryptodev_driver_id_get(
14243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14245 if (gbl_driver_id == -1) {
14246 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14247 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14248 "in config file to run this testsuite.\n");
14249 return TEST_SKIPPED;
14252 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14256 test_cryptodev_null(void)
14258 gbl_driver_id = rte_cryptodev_driver_id_get(
14259 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14261 if (gbl_driver_id == -1) {
14262 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14263 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14264 "in config file to run this testsuite.\n");
14265 return TEST_SKIPPED;
14268 return unit_test_suite_runner(&cryptodev_null_testsuite);
14272 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14274 gbl_driver_id = rte_cryptodev_driver_id_get(
14275 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14277 if (gbl_driver_id == -1) {
14278 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14279 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14280 "in config file to run this testsuite.\n");
14281 return TEST_SKIPPED;
14284 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14288 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14290 gbl_driver_id = rte_cryptodev_driver_id_get(
14291 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14293 if (gbl_driver_id == -1) {
14294 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14295 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14296 "in config file to run this testsuite.\n");
14297 return TEST_SKIPPED;
14300 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14304 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14306 gbl_driver_id = rte_cryptodev_driver_id_get(
14307 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14309 if (gbl_driver_id == -1) {
14310 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14311 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14312 "in config file to run this testsuite.\n");
14313 return TEST_SKIPPED;
14316 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14320 test_cryptodev_armv8(void)
14322 gbl_driver_id = rte_cryptodev_driver_id_get(
14323 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14325 if (gbl_driver_id == -1) {
14326 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14327 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14328 "in config file to run this testsuite.\n");
14329 return TEST_SKIPPED;
14332 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14336 test_cryptodev_mrvl(void)
14338 gbl_driver_id = rte_cryptodev_driver_id_get(
14339 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14341 if (gbl_driver_id == -1) {
14342 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14343 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14344 "in config file to run this testsuite.\n");
14345 return TEST_SKIPPED;
14348 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14351 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14354 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14356 gbl_driver_id = rte_cryptodev_driver_id_get(
14357 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14359 if (gbl_driver_id == -1) {
14360 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14361 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14362 "in config file to run this testsuite.\n");
14363 return TEST_SKIPPED;
14366 if (rte_cryptodev_driver_id_get(
14367 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14368 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14369 " enabled in config file to run this testsuite.\n");
14370 return TEST_SKIPPED;
14372 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14375 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14380 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14382 gbl_driver_id = rte_cryptodev_driver_id_get(
14383 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14385 if (gbl_driver_id == -1) {
14386 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14387 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14388 "in config file to run this testsuite.\n");
14389 return TEST_SKIPPED;
14392 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14396 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14398 gbl_driver_id = rte_cryptodev_driver_id_get(
14399 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14401 if (gbl_driver_id == -1) {
14402 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14403 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14404 "in config file to run this testsuite.\n");
14405 return TEST_SKIPPED;
14408 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14412 test_cryptodev_ccp(void)
14414 gbl_driver_id = rte_cryptodev_driver_id_get(
14415 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14417 if (gbl_driver_id == -1) {
14418 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14419 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14420 "in config file to run this testsuite.\n");
14421 return TEST_FAILED;
14424 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14428 test_cryptodev_octeontx(void)
14430 gbl_driver_id = rte_cryptodev_driver_id_get(
14431 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14432 if (gbl_driver_id == -1) {
14433 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14434 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14435 "enabled in config file to run this "
14437 return TEST_FAILED;
14439 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14443 test_cryptodev_octeontx2(void)
14445 gbl_driver_id = rte_cryptodev_driver_id_get(
14446 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14447 if (gbl_driver_id == -1) {
14448 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14449 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14450 "enabled in config file to run this "
14452 return TEST_FAILED;
14454 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14458 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14460 gbl_driver_id = rte_cryptodev_driver_id_get(
14461 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14463 if (gbl_driver_id == -1) {
14464 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14465 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14466 "in config file to run this testsuite.\n");
14467 return TEST_FAILED;
14470 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14474 test_cryptodev_nitrox(void)
14476 gbl_driver_id = rte_cryptodev_driver_id_get(
14477 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14479 if (gbl_driver_id == -1) {
14480 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14481 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14482 "in config file to run this testsuite.\n");
14483 return TEST_FAILED;
14486 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14489 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14490 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14491 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14492 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14493 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14494 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14495 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14496 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14497 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14498 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14499 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14500 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14501 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14502 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14503 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14504 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14505 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14506 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);