1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 struct crypto_testsuite_params {
56 struct rte_mempool *mbuf_pool;
57 struct rte_mempool *large_mbuf_pool;
58 struct rte_mempool *op_mpool;
59 struct rte_mempool *session_mpool;
60 struct rte_mempool *session_priv_mpool;
61 struct rte_cryptodev_config conf;
62 struct rte_cryptodev_qp_conf qp_conf;
64 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65 uint8_t valid_dev_count;
68 struct crypto_unittest_params {
69 struct rte_crypto_sym_xform cipher_xform;
70 struct rte_crypto_sym_xform auth_xform;
71 struct rte_crypto_sym_xform aead_xform;
74 struct rte_cryptodev_sym_session *sess;
75 #ifdef RTE_LIBRTE_SECURITY
76 struct rte_security_session *sec_session;
79 #ifdef RTE_LIBRTE_SECURITY
80 enum rte_security_session_action_type type;
82 struct rte_crypto_op *op;
84 struct rte_mbuf *obuf, *ibuf;
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 (((num) + (align) - 1) & ~((align) - 1))
93 * Forward declarations.
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 struct crypto_unittest_params *ut_params,
103 struct crypto_testsuite_params *ts_param,
104 const uint8_t *cipher,
105 const uint8_t *digest,
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 const char *string, size_t len, uint8_t blocksize)
112 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
115 memset(m->buf_addr, 0, m->buf_len);
117 char *dst = rte_pktmbuf_append(m, t_len);
124 rte_memcpy(dst, string, t_len);
126 memset(dst, 0, t_len);
132 /* Get number of bytes in X bits (rounding up) */
134 ceil_byte_length(uint32_t num_bits)
137 return ((num_bits >> 3) + 1);
139 return (num_bits >> 3);
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
145 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
155 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
156 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
163 static struct crypto_testsuite_params testsuite_params = { NULL };
164 static struct crypto_unittest_params unittest_params;
167 testsuite_setup(void)
169 struct crypto_testsuite_params *ts_params = &testsuite_params;
170 struct rte_cryptodev_info info;
171 uint32_t i = 0, nb_devs, dev_id;
175 memset(ts_params, 0, sizeof(*ts_params));
177 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
178 if (ts_params->mbuf_pool == NULL) {
179 /* Not already created so create */
180 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
182 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
184 if (ts_params->mbuf_pool == NULL) {
185 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
190 ts_params->large_mbuf_pool = rte_mempool_lookup(
191 "CRYPTO_LARGE_MBUFPOOL");
192 if (ts_params->large_mbuf_pool == NULL) {
193 /* Not already created so create */
194 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
195 "CRYPTO_LARGE_MBUFPOOL",
198 if (ts_params->large_mbuf_pool == NULL) {
200 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
205 ts_params->op_mpool = rte_crypto_op_pool_create(
206 "MBUF_CRYPTO_SYM_OP_POOL",
207 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
208 NUM_MBUFS, MBUF_CACHE_SIZE,
210 sizeof(struct rte_crypto_sym_xform) +
213 if (ts_params->op_mpool == NULL) {
214 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
218 /* Create an AESNI MB device if required */
219 if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
221 nb_devs = rte_cryptodev_device_count_by_driver(
222 rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
228 TEST_ASSERT(ret == 0,
229 "Failed to create instance of"
231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create an AESNI GCM device if required */
236 if (gbl_driver_id == rte_cryptodev_driver_id_get(
237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
238 nb_devs = rte_cryptodev_device_count_by_driver(
239 rte_cryptodev_driver_id_get(
240 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
242 TEST_ASSERT_SUCCESS(rte_vdev_init(
243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 "Failed to create instance of"
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create a SNOW 3G device if required */
251 if (gbl_driver_id == rte_cryptodev_driver_id_get(
252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
253 nb_devs = rte_cryptodev_device_count_by_driver(
254 rte_cryptodev_driver_id_get(
255 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
257 TEST_ASSERT_SUCCESS(rte_vdev_init(
258 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
259 "Failed to create instance of"
261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
265 /* Create a KASUMI device if required */
266 if (gbl_driver_id == rte_cryptodev_driver_id_get(
267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
268 nb_devs = rte_cryptodev_device_count_by_driver(
269 rte_cryptodev_driver_id_get(
270 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
272 TEST_ASSERT_SUCCESS(rte_vdev_init(
273 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
274 "Failed to create instance of"
276 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
280 /* Create a ZUC device if required */
281 if (gbl_driver_id == rte_cryptodev_driver_id_get(
282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
283 nb_devs = rte_cryptodev_device_count_by_driver(
284 rte_cryptodev_driver_id_get(
285 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
287 TEST_ASSERT_SUCCESS(rte_vdev_init(
288 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
289 "Failed to create instance of"
291 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
295 /* Create a NULL device if required */
296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
298 nb_devs = rte_cryptodev_device_count_by_driver(
299 rte_cryptodev_driver_id_get(
300 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
305 TEST_ASSERT(ret == 0,
306 "Failed to create instance of"
308 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
312 /* Create an OPENSSL device if required */
313 if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
315 nb_devs = rte_cryptodev_device_count_by_driver(
316 rte_cryptodev_driver_id_get(
317 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
320 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
323 TEST_ASSERT(ret == 0, "Failed to create "
324 "instance of pmd : %s",
325 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
329 /* Create a ARMv8 device if required */
330 if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
332 nb_devs = rte_cryptodev_device_count_by_driver(
333 rte_cryptodev_driver_id_get(
334 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
337 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
340 TEST_ASSERT(ret == 0, "Failed to create "
341 "instance of pmd : %s",
342 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
346 /* Create a MVSAM device if required */
347 if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
354 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
363 /* Create an CCP device if required */
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
366 nb_devs = rte_cryptodev_device_count_by_driver(
367 rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
371 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
374 TEST_ASSERT(ret == 0, "Failed to create "
375 "instance of pmd : %s",
376 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
381 char vdev_args[VDEV_ARGS_SIZE] = {""};
382 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
383 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
384 uint16_t slave_core_count = 0;
385 uint16_t socket_id = 0;
387 if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
390 /* Identify the Slave Cores
391 * Use 2 slave cores for the device args
393 RTE_LCORE_FOREACH_SLAVE(i) {
394 if (slave_core_count > 1)
396 snprintf(vdev_args, sizeof(vdev_args),
397 "%s%d", temp_str, i);
398 strcpy(temp_str, vdev_args);
399 strlcat(temp_str, ";", sizeof(temp_str));
401 socket_id = rte_lcore_to_socket_id(i);
403 if (slave_core_count != 2) {
405 "Cryptodev scheduler test require at least "
406 "two slave cores to run. "
407 "Please use the correct coremask.\n");
410 strcpy(temp_str, vdev_args);
411 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
412 temp_str, socket_id);
413 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
414 nb_devs = rte_cryptodev_device_count_by_driver(
415 rte_cryptodev_driver_id_get(
416 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
419 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
421 TEST_ASSERT(ret == 0,
422 "Failed to create instance %u of"
424 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
429 nb_devs = rte_cryptodev_count();
431 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
435 /* Create list of valid crypto devs */
436 for (i = 0; i < nb_devs; i++) {
437 rte_cryptodev_info_get(i, &info);
438 if (info.driver_id == gbl_driver_id)
439 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
442 if (ts_params->valid_dev_count < 1)
445 /* Set up all the qps on the first of the valid devices found */
447 dev_id = ts_params->valid_devs[0];
449 rte_cryptodev_info_get(dev_id, &info);
451 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
452 ts_params->conf.socket_id = SOCKET_ID_ANY;
453 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
455 unsigned int session_size =
456 rte_cryptodev_sym_get_private_session_size(dev_id);
459 * Create mempool with maximum number of sessions * 2,
460 * to include the session headers
462 if (info.sym.max_nb_sessions != 0 &&
463 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
464 RTE_LOG(ERR, USER1, "Device does not support "
465 "at least %u sessions\n",
470 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
471 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
473 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
474 "session mempool allocation failed");
476 ts_params->session_priv_mpool = rte_mempool_create(
480 0, 0, NULL, NULL, NULL,
483 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
484 "session mempool allocation failed");
488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
490 "Failed to configure cryptodev %u with %u qps",
491 dev_id, ts_params->conf.nb_queue_pairs);
493 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
494 ts_params->qp_conf.mp_session = ts_params->session_mpool;
495 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
497 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
498 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
499 dev_id, qp_id, &ts_params->qp_conf,
500 rte_cryptodev_socket_id(dev_id)),
501 "Failed to setup queue pair %u on cryptodev %u",
509 testsuite_teardown(void)
511 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 if (ts_params->mbuf_pool != NULL) {
514 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
515 rte_mempool_avail_count(ts_params->mbuf_pool));
518 if (ts_params->op_mpool != NULL) {
519 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
520 rte_mempool_avail_count(ts_params->op_mpool));
523 /* Free session mempools */
524 if (ts_params->session_priv_mpool != NULL) {
525 rte_mempool_free(ts_params->session_priv_mpool);
526 ts_params->session_priv_mpool = NULL;
529 if (ts_params->session_mpool != NULL) {
530 rte_mempool_free(ts_params->session_mpool);
531 ts_params->session_mpool = NULL;
538 struct crypto_testsuite_params *ts_params = &testsuite_params;
539 struct crypto_unittest_params *ut_params = &unittest_params;
543 /* Clear unit test parameters before running test */
544 memset(ut_params, 0, sizeof(*ut_params));
546 /* Reconfigure device to default parameters */
547 ts_params->conf.socket_id = SOCKET_ID_ANY;
548 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
549 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
550 ts_params->qp_conf.mp_session = ts_params->session_mpool;
551 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
553 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
555 "Failed to configure cryptodev %u",
556 ts_params->valid_devs[0]);
558 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
559 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
560 ts_params->valid_devs[0], qp_id,
562 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
563 "Failed to setup queue pair %u on cryptodev %u",
564 qp_id, ts_params->valid_devs[0]);
568 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
570 /* Start the device */
571 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
572 "Failed to start cryptodev %u",
573 ts_params->valid_devs[0]);
581 struct crypto_testsuite_params *ts_params = &testsuite_params;
582 struct crypto_unittest_params *ut_params = &unittest_params;
583 struct rte_cryptodev_stats stats;
585 /* free crypto session structure */
586 #ifdef RTE_LIBRTE_SECURITY
587 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
588 if (ut_params->sec_session) {
589 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
590 (ts_params->valid_devs[0]),
591 ut_params->sec_session);
592 ut_params->sec_session = NULL;
597 if (ut_params->sess) {
598 rte_cryptodev_sym_session_clear(
599 ts_params->valid_devs[0],
601 rte_cryptodev_sym_session_free(ut_params->sess);
602 ut_params->sess = NULL;
606 /* free crypto operation structure */
608 rte_crypto_op_free(ut_params->op);
611 * free mbuf - both obuf and ibuf are usually the same,
612 * so check if they point at the same address is necessary,
613 * to avoid freeing the mbuf twice.
615 if (ut_params->obuf) {
616 rte_pktmbuf_free(ut_params->obuf);
617 if (ut_params->ibuf == ut_params->obuf)
621 if (ut_params->ibuf) {
622 rte_pktmbuf_free(ut_params->ibuf);
626 if (ts_params->mbuf_pool != NULL)
627 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
628 rte_mempool_avail_count(ts_params->mbuf_pool));
630 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
632 /* Stop the device */
633 rte_cryptodev_stop(ts_params->valid_devs[0]);
637 test_device_configure_invalid_dev_id(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
640 uint16_t dev_id, num_devs = 0;
642 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
643 "Need at least %d devices for test", 1);
645 /* valid dev_id values */
646 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
648 /* Stop the device in case it's started so it can be configured */
649 rte_cryptodev_stop(dev_id);
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 "Failed test for rte_cryptodev_configure: "
653 "invalid dev_num %u", dev_id);
655 /* invalid dev_id values */
658 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
659 "Failed test for rte_cryptodev_configure: "
660 "invalid dev_num %u", dev_id);
664 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
665 "Failed test for rte_cryptodev_configure:"
666 "invalid dev_num %u", dev_id);
672 test_device_configure_invalid_queue_pair_ids(void)
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
677 /* This test is for QAT and NITROX PMDs only */
678 if (gbl_driver_id != rte_cryptodev_driver_id_get(
679 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
680 gbl_driver_id != rte_cryptodev_driver_id_get(
681 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
684 /* Stop the device in case it's started so it can be configured */
685 rte_cryptodev_stop(ts_params->valid_devs[0]);
687 /* valid - one queue pairs */
688 ts_params->conf.nb_queue_pairs = 1;
690 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
692 "Failed to configure cryptodev: dev_id %u, qp_id %u",
693 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
696 /* valid - max value queue pairs */
697 ts_params->conf.nb_queue_pairs = orig_nb_qps;
699 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
701 "Failed to configure cryptodev: dev_id %u, qp_id %u",
702 ts_params->valid_devs[0],
703 ts_params->conf.nb_queue_pairs);
706 /* invalid - zero queue pairs */
707 ts_params->conf.nb_queue_pairs = 0;
709 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
711 "Failed test for rte_cryptodev_configure, dev_id %u,"
713 ts_params->valid_devs[0],
714 ts_params->conf.nb_queue_pairs);
717 /* invalid - max value supported by field queue pairs */
718 ts_params->conf.nb_queue_pairs = UINT16_MAX;
720 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
722 "Failed test for rte_cryptodev_configure, dev_id %u,"
724 ts_params->valid_devs[0],
725 ts_params->conf.nb_queue_pairs);
728 /* invalid - max value + 1 queue pairs */
729 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
731 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
733 "Failed test for rte_cryptodev_configure, dev_id %u,"
735 ts_params->valid_devs[0],
736 ts_params->conf.nb_queue_pairs);
738 /* revert to original testsuite value */
739 ts_params->conf.nb_queue_pairs = orig_nb_qps;
745 test_queue_pair_descriptor_setup(void)
747 struct crypto_testsuite_params *ts_params = &testsuite_params;
748 struct rte_cryptodev_info dev_info;
749 struct rte_cryptodev_qp_conf qp_conf = {
750 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
755 /* This test is for QAT PMD only */
756 if (gbl_driver_id != rte_cryptodev_driver_id_get(
757 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
760 /* Stop the device in case it's started so it can be configured */
761 rte_cryptodev_stop(ts_params->valid_devs[0]);
764 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
766 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
768 "Failed to configure cryptodev %u",
769 ts_params->valid_devs[0]);
772 * Test various ring sizes on this device. memzones can't be
773 * freed so are re-used if ring is released and re-created.
775 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
776 qp_conf.mp_session = ts_params->session_mpool;
777 qp_conf.mp_session_private = ts_params->session_priv_mpool;
779 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
780 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
781 ts_params->valid_devs[0], qp_id, &qp_conf,
782 rte_cryptodev_socket_id(
783 ts_params->valid_devs[0])),
785 "rte_cryptodev_queue_pair_setup: num_inflights "
786 "%u on qp %u on cryptodev %u",
787 qp_conf.nb_descriptors, qp_id,
788 ts_params->valid_devs[0]);
791 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
793 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
794 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
795 ts_params->valid_devs[0], qp_id, &qp_conf,
796 rte_cryptodev_socket_id(
797 ts_params->valid_devs[0])),
799 " rte_cryptodev_queue_pair_setup: num_inflights"
800 " %u on qp %u on cryptodev %u",
801 qp_conf.nb_descriptors, qp_id,
802 ts_params->valid_devs[0]);
805 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
807 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
808 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
809 ts_params->valid_devs[0], qp_id, &qp_conf,
810 rte_cryptodev_socket_id(
811 ts_params->valid_devs[0])),
813 "rte_cryptodev_queue_pair_setup: num_inflights"
814 " %u on qp %u on cryptodev %u",
815 qp_conf.nb_descriptors, qp_id,
816 ts_params->valid_devs[0]);
819 /* invalid number of descriptors - max supported + 2 */
820 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
822 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
823 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
824 ts_params->valid_devs[0], qp_id, &qp_conf,
825 rte_cryptodev_socket_id(
826 ts_params->valid_devs[0])),
827 "Unexpectedly passed test for "
828 "rte_cryptodev_queue_pair_setup:"
829 "num_inflights %u on qp %u on cryptodev %u",
830 qp_conf.nb_descriptors, qp_id,
831 ts_params->valid_devs[0]);
834 /* invalid number of descriptors - max value of parameter */
835 qp_conf.nb_descriptors = UINT32_MAX-1;
837 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
838 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
839 ts_params->valid_devs[0], qp_id, &qp_conf,
840 rte_cryptodev_socket_id(
841 ts_params->valid_devs[0])),
842 "Unexpectedly passed test for "
843 "rte_cryptodev_queue_pair_setup:"
844 "num_inflights %u on qp %u on cryptodev %u",
845 qp_conf.nb_descriptors, qp_id,
846 ts_params->valid_devs[0]);
849 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
851 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
852 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
853 ts_params->valid_devs[0], qp_id, &qp_conf,
854 rte_cryptodev_socket_id(
855 ts_params->valid_devs[0])),
857 " rte_cryptodev_queue_pair_setup:"
858 "num_inflights %u on qp %u on cryptodev %u",
859 qp_conf.nb_descriptors, qp_id,
860 ts_params->valid_devs[0]);
863 /* invalid number of descriptors - max supported + 1 */
864 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
866 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
867 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
868 ts_params->valid_devs[0], qp_id, &qp_conf,
869 rte_cryptodev_socket_id(
870 ts_params->valid_devs[0])),
871 "Unexpectedly passed test for "
872 "rte_cryptodev_queue_pair_setup:"
873 "num_inflights %u on qp %u on cryptodev %u",
874 qp_conf.nb_descriptors, qp_id,
875 ts_params->valid_devs[0]);
878 /* test invalid queue pair id */
879 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
881 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
883 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
884 ts_params->valid_devs[0],
886 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
887 "Failed test for rte_cryptodev_queue_pair_setup:"
888 "invalid qp %u on cryptodev %u",
889 qp_id, ts_params->valid_devs[0]);
891 qp_id = 0xffff; /*invalid*/
893 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
894 ts_params->valid_devs[0],
896 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
897 "Failed test for rte_cryptodev_queue_pair_setup:"
898 "invalid qp %u on cryptodev %u",
899 qp_id, ts_params->valid_devs[0]);
904 /* ***** Plaintext data for tests ***** */
906 const char catch_22_quote_1[] =
907 "There was only one catch and that was Catch-22, which "
908 "specified that a concern for one's safety in the face of "
909 "dangers that were real and immediate was the process of a "
910 "rational mind. Orr was crazy and could be grounded. All he "
911 "had to do was ask; and as soon as he did, he would no longer "
912 "be crazy and would have to fly more missions. Orr would be "
913 "crazy to fly more missions and sane if he didn't, but if he "
914 "was sane he had to fly them. If he flew them he was crazy "
915 "and didn't have to; but if he didn't want to he was sane and "
916 "had to. Yossarian was moved very deeply by the absolute "
917 "simplicity of this clause of Catch-22 and let out a "
918 "respectful whistle. \"That's some catch, that Catch-22\", he "
919 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
921 const char catch_22_quote[] =
922 "What a lousy earth! He wondered how many people were "
923 "destitute that same night even in his own prosperous country, "
924 "how many homes were shanties, how many husbands were drunk "
925 "and wives socked, and how many children were bullied, abused, "
926 "or abandoned. How many families hungered for food they could "
927 "not afford to buy? How many hearts were broken? How many "
928 "suicides would take place that same night, how many people "
929 "would go insane? How many cockroaches and landlords would "
930 "triumph? How many winners were losers, successes failures, "
931 "and rich men poor men? How many wise guys were stupid? How "
932 "many happy endings were unhappy endings? How many honest men "
933 "were liars, brave men cowards, loyal men traitors, how many "
934 "sainted men were corrupt, how many people in positions of "
935 "trust had sold their souls to bodyguards, how many had never "
936 "had souls? How many straight-and-narrow paths were crooked "
937 "paths? How many best families were worst families and how "
938 "many good people were bad people? When you added them all up "
939 "and then subtracted, you might be left with only the children, "
940 "and perhaps with Albert Einstein and an old violinist or "
941 "sculptor somewhere.";
943 #define QUOTE_480_BYTES (480)
944 #define QUOTE_512_BYTES (512)
945 #define QUOTE_768_BYTES (768)
946 #define QUOTE_1024_BYTES (1024)
950 /* ***** SHA1 Hash Tests ***** */
952 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
954 static uint8_t hmac_sha1_key[] = {
955 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
956 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
957 0xDE, 0xF4, 0xDE, 0xAD };
959 /* ***** SHA224 Hash Tests ***** */
961 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
964 /* ***** AES-CBC Cipher Tests ***** */
966 #define CIPHER_KEY_LENGTH_AES_CBC (16)
967 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
969 static uint8_t aes_cbc_key[] = {
970 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
971 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
973 static uint8_t aes_cbc_iv[] = {
974 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
975 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
978 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
980 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
981 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
982 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
983 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
984 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
985 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
986 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
987 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
988 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
989 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
990 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
991 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
992 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
993 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
994 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
995 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
996 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
997 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
998 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
999 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1000 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1001 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1002 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1003 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1004 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1005 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1006 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1007 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1008 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1009 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1010 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1011 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1012 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1013 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1014 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1015 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1016 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1017 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1018 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1019 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1020 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1021 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1022 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1023 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1024 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1025 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1026 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1027 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1028 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1029 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1030 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1031 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1032 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1033 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1034 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1035 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1036 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1037 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1038 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1039 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1040 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1041 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1042 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1043 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1044 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1047 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1048 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1049 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1050 0x18, 0x8c, 0x1d, 0x32
1054 /* Multisession Vector context Test */
1055 /*Begin Session 0 */
1056 static uint8_t ms_aes_cbc_key0[] = {
1057 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1058 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1061 static uint8_t ms_aes_cbc_iv0[] = {
1062 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1063 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1066 static const uint8_t ms_aes_cbc_cipher0[] = {
1067 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1068 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1069 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1070 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1071 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1072 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1073 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1074 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1075 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1076 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1077 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1078 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1079 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1080 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1081 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1082 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1083 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1084 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1085 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1086 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1087 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1088 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1089 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1090 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1091 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1092 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1093 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1094 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1095 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1096 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1097 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1098 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1099 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1100 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1101 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1102 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1103 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1104 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1105 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1106 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1107 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1108 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1109 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1110 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1111 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1112 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1113 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1114 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1115 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1116 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1117 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1118 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1119 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1120 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1121 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1122 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1123 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1124 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1125 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1126 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1127 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1128 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1129 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1130 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1134 static uint8_t ms_hmac_key0[] = {
1135 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1136 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1137 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1138 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1139 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1140 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1141 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1142 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1145 static const uint8_t ms_hmac_digest0[] = {
1146 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1147 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1148 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1149 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1150 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1151 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1152 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1153 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1157 /* Begin session 1 */
1159 static uint8_t ms_aes_cbc_key1[] = {
1160 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1161 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1164 static uint8_t ms_aes_cbc_iv1[] = {
1165 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1166 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1169 static const uint8_t ms_aes_cbc_cipher1[] = {
1170 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1171 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1172 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1173 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1174 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1175 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1176 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1177 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1178 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1179 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1180 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1181 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1182 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1183 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1184 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1185 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1186 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1187 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1188 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1189 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1190 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1191 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1192 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1193 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1194 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1195 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1196 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1197 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1198 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1199 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1200 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1201 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1202 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1203 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1204 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1205 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1206 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1207 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1208 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1209 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1210 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1211 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1212 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1213 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1214 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1215 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1216 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1217 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1218 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1219 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1220 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1221 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1222 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1223 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1224 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1225 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1226 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1227 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1228 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1229 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1230 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1231 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1232 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1233 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1237 static uint8_t ms_hmac_key1[] = {
1238 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1239 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1240 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1241 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1242 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1243 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1244 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1245 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1248 static const uint8_t ms_hmac_digest1[] = {
1249 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1250 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1251 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1252 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1253 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1254 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1255 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1256 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1259 /* Begin Session 2 */
1260 static uint8_t ms_aes_cbc_key2[] = {
1261 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1262 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1265 static uint8_t ms_aes_cbc_iv2[] = {
1266 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1267 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1270 static const uint8_t ms_aes_cbc_cipher2[] = {
1271 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1272 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1273 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1274 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1275 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1276 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1277 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1278 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1279 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1280 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1281 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1282 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1283 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1284 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1285 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1286 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1287 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1288 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1289 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1290 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1291 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1292 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1293 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1294 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1295 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1296 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1297 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1298 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1299 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1300 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1301 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1302 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1303 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1304 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1305 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1306 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1307 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1308 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1309 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1310 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1311 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1312 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1313 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1314 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1315 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1316 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1317 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1318 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1319 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1320 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1321 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1322 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1323 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1324 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1325 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1326 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1327 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1328 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1329 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1330 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1331 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1332 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1333 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1334 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1337 static uint8_t ms_hmac_key2[] = {
1338 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1339 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1340 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1341 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1342 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1343 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1344 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1345 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1348 static const uint8_t ms_hmac_digest2[] = {
1349 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1350 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1351 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1352 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1353 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1354 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1355 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1356 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1363 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1365 struct crypto_testsuite_params *ts_params = &testsuite_params;
1366 struct crypto_unittest_params *ut_params = &unittest_params;
1368 /* Verify the capabilities */
1369 struct rte_cryptodev_sym_capability_idx cap_idx;
1370 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1371 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1372 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1375 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1376 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1381 /* Generate test mbuf data and space for digest */
1382 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1383 catch_22_quote, QUOTE_512_BYTES, 0);
1385 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1386 DIGEST_BYTE_LENGTH_SHA1);
1387 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1389 /* Setup Cipher Parameters */
1390 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1391 ut_params->cipher_xform.next = &ut_params->auth_xform;
1393 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1394 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1395 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1396 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1397 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1398 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1400 /* Setup HMAC Parameters */
1401 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1403 ut_params->auth_xform.next = NULL;
1405 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1406 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1407 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1408 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1409 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1411 ut_params->sess = rte_cryptodev_sym_session_create(
1412 ts_params->session_mpool);
1414 /* Create crypto session*/
1415 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1416 ut_params->sess, &ut_params->cipher_xform,
1417 ts_params->session_priv_mpool);
1418 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1420 /* Generate crypto op data structure */
1421 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1422 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1423 TEST_ASSERT_NOT_NULL(ut_params->op,
1424 "Failed to allocate symmetric crypto operation struct");
1426 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1428 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1430 /* set crypto operation source mbuf */
1431 sym_op->m_src = ut_params->ibuf;
1433 /* Set crypto operation authentication parameters */
1434 sym_op->auth.digest.data = ut_params->digest;
1435 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1436 ut_params->ibuf, QUOTE_512_BYTES);
1438 sym_op->auth.data.offset = 0;
1439 sym_op->auth.data.length = QUOTE_512_BYTES;
1441 /* Copy IV at the end of the crypto operation */
1442 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1443 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1445 /* Set crypto operation cipher parameters */
1446 sym_op->cipher.data.offset = 0;
1447 sym_op->cipher.data.length = QUOTE_512_BYTES;
1449 /* Process crypto operation */
1450 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1451 ut_params->op), "failed to process sym crypto op");
1453 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1454 "crypto op processing failed");
1457 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1460 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1461 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1463 "ciphertext data not as expected");
1465 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1467 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1468 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1469 gbl_driver_id == rte_cryptodev_driver_id_get(
1470 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1471 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1472 DIGEST_BYTE_LENGTH_SHA1,
1473 "Generated digest data not as expected");
1475 return TEST_SUCCESS;
1478 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1480 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1482 static uint8_t hmac_sha512_key[] = {
1483 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1484 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1485 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1486 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1487 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1488 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1489 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1490 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1492 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1493 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1494 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1495 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1496 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1497 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1498 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1499 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1500 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1505 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1506 struct crypto_unittest_params *ut_params,
1507 uint8_t *cipher_key,
1511 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1512 struct crypto_unittest_params *ut_params,
1513 struct crypto_testsuite_params *ts_params,
1514 const uint8_t *cipher,
1515 const uint8_t *digest,
1520 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1521 struct crypto_unittest_params *ut_params,
1522 uint8_t *cipher_key,
1526 /* Setup Cipher Parameters */
1527 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1528 ut_params->cipher_xform.next = NULL;
1530 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1531 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1532 ut_params->cipher_xform.cipher.key.data = cipher_key;
1533 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1534 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1535 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1537 /* Setup HMAC Parameters */
1538 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1539 ut_params->auth_xform.next = &ut_params->cipher_xform;
1541 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1542 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1543 ut_params->auth_xform.auth.key.data = hmac_key;
1544 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1545 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1547 return TEST_SUCCESS;
1552 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1553 struct crypto_unittest_params *ut_params,
1554 struct crypto_testsuite_params *ts_params,
1555 const uint8_t *cipher,
1556 const uint8_t *digest,
1559 /* Generate test mbuf data and digest */
1560 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1563 QUOTE_512_BYTES, 0);
1565 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1566 DIGEST_BYTE_LENGTH_SHA512);
1567 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1569 rte_memcpy(ut_params->digest,
1571 DIGEST_BYTE_LENGTH_SHA512);
1573 /* Generate Crypto op data structure */
1574 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1575 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1576 TEST_ASSERT_NOT_NULL(ut_params->op,
1577 "Failed to allocate symmetric crypto operation struct");
1579 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1581 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1583 /* set crypto operation source mbuf */
1584 sym_op->m_src = ut_params->ibuf;
1586 sym_op->auth.digest.data = ut_params->digest;
1587 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1588 ut_params->ibuf, QUOTE_512_BYTES);
1590 sym_op->auth.data.offset = 0;
1591 sym_op->auth.data.length = QUOTE_512_BYTES;
1593 /* Copy IV at the end of the crypto operation */
1594 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1595 iv, CIPHER_IV_LENGTH_AES_CBC);
1597 sym_op->cipher.data.offset = 0;
1598 sym_op->cipher.data.length = QUOTE_512_BYTES;
1600 /* Process crypto operation */
1601 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1602 ut_params->op), "failed to process sym crypto op");
1604 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1605 "crypto op processing failed");
1607 ut_params->obuf = ut_params->op->sym->m_src;
1610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1611 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1614 "Plaintext data not as expected");
1617 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1618 "Digest verification failed");
1620 return TEST_SUCCESS;
1624 test_blockcipher(enum blockcipher_test_type test_type)
1626 struct crypto_testsuite_params *ts_params = &testsuite_params;
1629 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1630 ts_params->op_mpool,
1631 ts_params->session_mpool, ts_params->session_priv_mpool,
1632 ts_params->valid_devs[0],
1636 if (status == -ENOTSUP)
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1645 test_AES_cipheronly_all(void)
1647 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1651 test_AES_docsis_all(void)
1653 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1657 test_DES_docsis_all(void)
1659 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1663 test_DES_cipheronly_all(void)
1665 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1669 test_authonly_all(void)
1671 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1675 test_AES_chain_all(void)
1677 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1681 test_3DES_chain_all(void)
1683 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1687 test_3DES_cipheronly_all(void)
1689 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1692 /* ***** SNOW 3G Tests ***** */
1694 create_wireless_algo_hash_session(uint8_t dev_id,
1695 const uint8_t *key, const uint8_t key_len,
1696 const uint8_t iv_len, const uint8_t auth_len,
1697 enum rte_crypto_auth_operation op,
1698 enum rte_crypto_auth_algorithm algo)
1700 uint8_t hash_key[key_len];
1703 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 struct crypto_unittest_params *ut_params = &unittest_params;
1706 memcpy(hash_key, key, key_len);
1708 debug_hexdump(stdout, "key:", key, key_len);
1710 /* Setup Authentication Parameters */
1711 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1712 ut_params->auth_xform.next = NULL;
1714 ut_params->auth_xform.auth.op = op;
1715 ut_params->auth_xform.auth.algo = algo;
1716 ut_params->auth_xform.auth.key.length = key_len;
1717 ut_params->auth_xform.auth.key.data = hash_key;
1718 ut_params->auth_xform.auth.digest_length = auth_len;
1719 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1720 ut_params->auth_xform.auth.iv.length = iv_len;
1721 ut_params->sess = rte_cryptodev_sym_session_create(
1722 ts_params->session_mpool);
1724 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1725 &ut_params->auth_xform,
1726 ts_params->session_priv_mpool);
1727 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1728 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1733 create_wireless_algo_cipher_session(uint8_t dev_id,
1734 enum rte_crypto_cipher_operation op,
1735 enum rte_crypto_cipher_algorithm algo,
1736 const uint8_t *key, const uint8_t key_len,
1739 uint8_t cipher_key[key_len];
1741 struct crypto_testsuite_params *ts_params = &testsuite_params;
1742 struct crypto_unittest_params *ut_params = &unittest_params;
1744 memcpy(cipher_key, key, key_len);
1746 /* Setup Cipher Parameters */
1747 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1748 ut_params->cipher_xform.next = NULL;
1750 ut_params->cipher_xform.cipher.algo = algo;
1751 ut_params->cipher_xform.cipher.op = op;
1752 ut_params->cipher_xform.cipher.key.data = cipher_key;
1753 ut_params->cipher_xform.cipher.key.length = key_len;
1754 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1755 ut_params->cipher_xform.cipher.iv.length = iv_len;
1757 debug_hexdump(stdout, "key:", key, key_len);
1759 /* Create Crypto session */
1760 ut_params->sess = rte_cryptodev_sym_session_create(
1761 ts_params->session_mpool);
1763 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1764 &ut_params->cipher_xform,
1765 ts_params->session_priv_mpool);
1766 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1767 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1772 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1773 unsigned int cipher_len,
1774 unsigned int cipher_offset)
1776 struct crypto_testsuite_params *ts_params = &testsuite_params;
1777 struct crypto_unittest_params *ut_params = &unittest_params;
1779 /* Generate Crypto op data structure */
1780 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1781 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1782 TEST_ASSERT_NOT_NULL(ut_params->op,
1783 "Failed to allocate pktmbuf offload");
1785 /* Set crypto operation data parameters */
1786 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1788 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1790 /* set crypto operation source mbuf */
1791 sym_op->m_src = ut_params->ibuf;
1794 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1796 sym_op->cipher.data.length = cipher_len;
1797 sym_op->cipher.data.offset = cipher_offset;
1802 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1803 unsigned int cipher_len,
1804 unsigned int cipher_offset)
1806 struct crypto_testsuite_params *ts_params = &testsuite_params;
1807 struct crypto_unittest_params *ut_params = &unittest_params;
1809 /* Generate Crypto op data structure */
1810 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1811 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1812 TEST_ASSERT_NOT_NULL(ut_params->op,
1813 "Failed to allocate pktmbuf offload");
1815 /* Set crypto operation data parameters */
1816 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1818 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1820 /* set crypto operation source mbuf */
1821 sym_op->m_src = ut_params->ibuf;
1822 sym_op->m_dst = ut_params->obuf;
1825 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1827 sym_op->cipher.data.length = cipher_len;
1828 sym_op->cipher.data.offset = cipher_offset;
1833 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1834 enum rte_crypto_cipher_operation cipher_op,
1835 enum rte_crypto_auth_operation auth_op,
1836 enum rte_crypto_auth_algorithm auth_algo,
1837 enum rte_crypto_cipher_algorithm cipher_algo,
1838 const uint8_t *key, uint8_t key_len,
1839 uint8_t auth_iv_len, uint8_t auth_len,
1840 uint8_t cipher_iv_len)
1843 uint8_t cipher_auth_key[key_len];
1846 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 struct crypto_unittest_params *ut_params = &unittest_params;
1849 memcpy(cipher_auth_key, key, key_len);
1851 /* Setup Authentication Parameters */
1852 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1853 ut_params->auth_xform.next = NULL;
1855 ut_params->auth_xform.auth.op = auth_op;
1856 ut_params->auth_xform.auth.algo = auth_algo;
1857 ut_params->auth_xform.auth.key.length = key_len;
1858 /* Hash key = cipher key */
1859 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1860 ut_params->auth_xform.auth.digest_length = auth_len;
1861 /* Auth IV will be after cipher IV */
1862 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1863 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1865 /* Setup Cipher Parameters */
1866 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1867 ut_params->cipher_xform.next = &ut_params->auth_xform;
1869 ut_params->cipher_xform.cipher.algo = cipher_algo;
1870 ut_params->cipher_xform.cipher.op = cipher_op;
1871 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1872 ut_params->cipher_xform.cipher.key.length = key_len;
1873 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1874 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1876 debug_hexdump(stdout, "key:", key, key_len);
1878 /* Create Crypto session*/
1879 ut_params->sess = rte_cryptodev_sym_session_create(
1880 ts_params->session_mpool);
1881 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1883 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1884 &ut_params->cipher_xform,
1885 ts_params->session_priv_mpool);
1886 if (status == -ENOTSUP)
1889 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1894 create_wireless_cipher_auth_session(uint8_t dev_id,
1895 enum rte_crypto_cipher_operation cipher_op,
1896 enum rte_crypto_auth_operation auth_op,
1897 enum rte_crypto_auth_algorithm auth_algo,
1898 enum rte_crypto_cipher_algorithm cipher_algo,
1899 const struct wireless_test_data *tdata)
1901 const uint8_t key_len = tdata->key.len;
1902 uint8_t cipher_auth_key[key_len];
1905 struct crypto_testsuite_params *ts_params = &testsuite_params;
1906 struct crypto_unittest_params *ut_params = &unittest_params;
1907 const uint8_t *key = tdata->key.data;
1908 const uint8_t auth_len = tdata->digest.len;
1909 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1910 uint8_t auth_iv_len = tdata->auth_iv.len;
1912 memcpy(cipher_auth_key, key, key_len);
1914 /* Setup Authentication Parameters */
1915 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1916 ut_params->auth_xform.next = NULL;
1918 ut_params->auth_xform.auth.op = auth_op;
1919 ut_params->auth_xform.auth.algo = auth_algo;
1920 ut_params->auth_xform.auth.key.length = key_len;
1921 /* Hash key = cipher key */
1922 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1923 ut_params->auth_xform.auth.digest_length = auth_len;
1924 /* Auth IV will be after cipher IV */
1925 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1926 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1928 /* Setup Cipher Parameters */
1929 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1930 ut_params->cipher_xform.next = &ut_params->auth_xform;
1932 ut_params->cipher_xform.cipher.algo = cipher_algo;
1933 ut_params->cipher_xform.cipher.op = cipher_op;
1934 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1935 ut_params->cipher_xform.cipher.key.length = key_len;
1936 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1937 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1940 debug_hexdump(stdout, "key:", key, key_len);
1942 /* Create Crypto session*/
1943 ut_params->sess = rte_cryptodev_sym_session_create(
1944 ts_params->session_mpool);
1946 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1947 &ut_params->cipher_xform,
1948 ts_params->session_priv_mpool);
1950 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1951 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1956 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
1957 const struct wireless_test_data *tdata)
1959 return create_wireless_cipher_auth_session(dev_id,
1960 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
1961 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
1962 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
1966 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1967 enum rte_crypto_cipher_operation cipher_op,
1968 enum rte_crypto_auth_operation auth_op,
1969 enum rte_crypto_auth_algorithm auth_algo,
1970 enum rte_crypto_cipher_algorithm cipher_algo,
1971 const uint8_t *key, const uint8_t key_len,
1972 uint8_t auth_iv_len, uint8_t auth_len,
1973 uint8_t cipher_iv_len)
1975 uint8_t auth_cipher_key[key_len];
1977 struct crypto_testsuite_params *ts_params = &testsuite_params;
1978 struct crypto_unittest_params *ut_params = &unittest_params;
1980 memcpy(auth_cipher_key, key, key_len);
1982 /* Setup Authentication Parameters */
1983 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1984 ut_params->auth_xform.auth.op = auth_op;
1985 ut_params->auth_xform.next = &ut_params->cipher_xform;
1986 ut_params->auth_xform.auth.algo = auth_algo;
1987 ut_params->auth_xform.auth.key.length = key_len;
1988 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1989 ut_params->auth_xform.auth.digest_length = auth_len;
1990 /* Auth IV will be after cipher IV */
1991 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1992 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1994 /* Setup Cipher Parameters */
1995 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1996 ut_params->cipher_xform.next = NULL;
1997 ut_params->cipher_xform.cipher.algo = cipher_algo;
1998 ut_params->cipher_xform.cipher.op = cipher_op;
1999 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2000 ut_params->cipher_xform.cipher.key.length = key_len;
2001 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2002 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2004 debug_hexdump(stdout, "key:", key, key_len);
2006 /* Create Crypto session*/
2007 ut_params->sess = rte_cryptodev_sym_session_create(
2008 ts_params->session_mpool);
2009 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2011 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2012 ut_params->auth_xform.next = NULL;
2013 ut_params->cipher_xform.next = &ut_params->auth_xform;
2014 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2015 &ut_params->cipher_xform,
2016 ts_params->session_priv_mpool);
2019 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2020 &ut_params->auth_xform,
2021 ts_params->session_priv_mpool);
2023 if (status == -ENOTSUP)
2026 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2032 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2033 unsigned int auth_tag_len,
2034 const uint8_t *iv, unsigned int iv_len,
2035 unsigned int data_pad_len,
2036 enum rte_crypto_auth_operation op,
2037 unsigned int auth_len, unsigned int auth_offset)
2039 struct crypto_testsuite_params *ts_params = &testsuite_params;
2041 struct crypto_unittest_params *ut_params = &unittest_params;
2043 /* Generate Crypto op data structure */
2044 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2045 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2046 TEST_ASSERT_NOT_NULL(ut_params->op,
2047 "Failed to allocate pktmbuf offload");
2049 /* Set crypto operation data parameters */
2050 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2052 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2054 /* set crypto operation source mbuf */
2055 sym_op->m_src = ut_params->ibuf;
2058 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2061 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2062 ut_params->ibuf, auth_tag_len);
2064 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2065 "no room to append auth tag");
2066 ut_params->digest = sym_op->auth.digest.data;
2067 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2068 ut_params->ibuf, data_pad_len);
2069 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2070 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2072 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2074 debug_hexdump(stdout, "digest:",
2075 sym_op->auth.digest.data,
2078 sym_op->auth.data.length = auth_len;
2079 sym_op->auth.data.offset = auth_offset;
2085 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2086 enum rte_crypto_auth_operation op)
2088 struct crypto_testsuite_params *ts_params = &testsuite_params;
2089 struct crypto_unittest_params *ut_params = &unittest_params;
2091 const uint8_t *auth_tag = tdata->digest.data;
2092 const unsigned int auth_tag_len = tdata->digest.len;
2093 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2094 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2096 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2097 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2098 const uint8_t *auth_iv = tdata->auth_iv.data;
2099 const uint8_t auth_iv_len = tdata->auth_iv.len;
2100 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2101 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2103 /* Generate Crypto op data structure */
2104 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2105 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2106 TEST_ASSERT_NOT_NULL(ut_params->op,
2107 "Failed to allocate pktmbuf offload");
2108 /* Set crypto operation data parameters */
2109 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2111 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2113 /* set crypto operation source mbuf */
2114 sym_op->m_src = ut_params->ibuf;
2117 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2118 ut_params->ibuf, auth_tag_len);
2120 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2121 "no room to append auth tag");
2122 ut_params->digest = sym_op->auth.digest.data;
2123 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2124 ut_params->ibuf, data_pad_len);
2125 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2126 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2128 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2130 debug_hexdump(stdout, "digest:",
2131 sym_op->auth.digest.data,
2134 /* Copy cipher and auth IVs at the end of the crypto operation */
2135 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2137 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2138 iv_ptr += cipher_iv_len;
2139 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2141 sym_op->cipher.data.length = cipher_len;
2142 sym_op->cipher.data.offset = 0;
2143 sym_op->auth.data.length = auth_len;
2144 sym_op->auth.data.offset = 0;
2150 create_zuc_cipher_hash_generate_operation(
2151 const struct wireless_test_data *tdata)
2153 return create_wireless_cipher_hash_operation(tdata,
2154 RTE_CRYPTO_AUTH_OP_GENERATE);
2158 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2159 const unsigned auth_tag_len,
2160 const uint8_t *auth_iv, uint8_t auth_iv_len,
2161 unsigned data_pad_len,
2162 enum rte_crypto_auth_operation op,
2163 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2164 const unsigned cipher_len, const unsigned cipher_offset,
2165 const unsigned auth_len, const unsigned auth_offset)
2167 struct crypto_testsuite_params *ts_params = &testsuite_params;
2168 struct crypto_unittest_params *ut_params = &unittest_params;
2170 enum rte_crypto_cipher_algorithm cipher_algo =
2171 ut_params->cipher_xform.cipher.algo;
2172 enum rte_crypto_auth_algorithm auth_algo =
2173 ut_params->auth_xform.auth.algo;
2175 /* Generate Crypto op data structure */
2176 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2177 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2178 TEST_ASSERT_NOT_NULL(ut_params->op,
2179 "Failed to allocate pktmbuf offload");
2180 /* Set crypto operation data parameters */
2181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2183 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2185 /* set crypto operation source mbuf */
2186 sym_op->m_src = ut_params->ibuf;
2189 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2190 ut_params->ibuf, auth_tag_len);
2192 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2193 "no room to append auth tag");
2194 ut_params->digest = sym_op->auth.digest.data;
2196 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2197 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2198 ut_params->ibuf, data_pad_len);
2200 struct rte_mbuf *m = ut_params->ibuf;
2201 unsigned int offset = data_pad_len;
2203 while (offset > m->data_len && m->next != NULL) {
2204 offset -= m->data_len;
2207 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2211 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2212 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2214 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2216 debug_hexdump(stdout, "digest:",
2217 sym_op->auth.digest.data,
2220 /* Copy cipher and auth IVs at the end of the crypto operation */
2221 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2223 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2224 iv_ptr += cipher_iv_len;
2225 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2227 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2228 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2229 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2230 sym_op->cipher.data.length = cipher_len;
2231 sym_op->cipher.data.offset = cipher_offset;
2233 sym_op->cipher.data.length = cipher_len >> 3;
2234 sym_op->cipher.data.offset = cipher_offset >> 3;
2237 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2238 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2239 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2240 sym_op->auth.data.length = auth_len;
2241 sym_op->auth.data.offset = auth_offset;
2243 sym_op->auth.data.length = auth_len >> 3;
2244 sym_op->auth.data.offset = auth_offset >> 3;
2251 create_wireless_algo_auth_cipher_operation(
2252 const uint8_t *auth_tag, unsigned int auth_tag_len,
2253 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2254 const uint8_t *auth_iv, uint8_t auth_iv_len,
2255 unsigned int data_pad_len,
2256 unsigned int cipher_len, unsigned int cipher_offset,
2257 unsigned int auth_len, unsigned int auth_offset,
2258 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2260 struct crypto_testsuite_params *ts_params = &testsuite_params;
2261 struct crypto_unittest_params *ut_params = &unittest_params;
2263 enum rte_crypto_cipher_algorithm cipher_algo =
2264 ut_params->cipher_xform.cipher.algo;
2265 enum rte_crypto_auth_algorithm auth_algo =
2266 ut_params->auth_xform.auth.algo;
2268 /* Generate Crypto op data structure */
2269 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2270 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2271 TEST_ASSERT_NOT_NULL(ut_params->op,
2272 "Failed to allocate pktmbuf offload");
2274 /* Set crypto operation data parameters */
2275 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2277 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2279 /* set crypto operation mbufs */
2280 sym_op->m_src = ut_params->ibuf;
2281 if (op_mode == OUT_OF_PLACE)
2282 sym_op->m_dst = ut_params->obuf;
2286 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2287 (op_mode == IN_PLACE ?
2288 ut_params->ibuf : ut_params->obuf),
2289 uint8_t *, data_pad_len);
2290 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2291 (op_mode == IN_PLACE ?
2292 ut_params->ibuf : ut_params->obuf),
2294 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2296 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2297 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2298 sym_op->m_src : sym_op->m_dst);
2299 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2300 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2301 sgl_buf = sgl_buf->next;
2303 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2304 uint8_t *, remaining_off);
2305 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2307 memset(sym_op->auth.digest.data, 0, remaining_off);
2308 while (sgl_buf->next != NULL) {
2309 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2310 0, rte_pktmbuf_data_len(sgl_buf));
2311 sgl_buf = sgl_buf->next;
2315 /* Copy digest for the verification */
2317 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2319 /* Copy cipher and auth IVs at the end of the crypto operation */
2320 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2321 ut_params->op, uint8_t *, IV_OFFSET);
2323 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2324 iv_ptr += cipher_iv_len;
2325 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2327 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2328 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2329 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2330 sym_op->cipher.data.length = cipher_len;
2331 sym_op->cipher.data.offset = cipher_offset;
2333 sym_op->cipher.data.length = cipher_len >> 3;
2334 sym_op->cipher.data.offset = cipher_offset >> 3;
2337 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2338 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2339 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2340 sym_op->auth.data.length = auth_len;
2341 sym_op->auth.data.offset = auth_offset;
2343 sym_op->auth.data.length = auth_len >> 3;
2344 sym_op->auth.data.offset = auth_offset >> 3;
2351 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2353 struct crypto_testsuite_params *ts_params = &testsuite_params;
2354 struct crypto_unittest_params *ut_params = &unittest_params;
2357 unsigned plaintext_pad_len;
2358 unsigned plaintext_len;
2361 /* QAT PMD supports byte-aligned data only */
2362 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2363 (gbl_driver_id == rte_cryptodev_driver_id_get(
2364 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2367 /* Verify the capabilities */
2368 struct rte_cryptodev_sym_capability_idx cap_idx;
2369 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2370 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2371 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2375 /* Create SNOW 3G session */
2376 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2377 tdata->key.data, tdata->key.len,
2378 tdata->auth_iv.len, tdata->digest.len,
2379 RTE_CRYPTO_AUTH_OP_GENERATE,
2380 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2384 /* alloc mbuf and set payload */
2385 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2388 rte_pktmbuf_tailroom(ut_params->ibuf));
2390 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2391 /* Append data which is padded to a multiple of */
2392 /* the algorithms block size */
2393 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2394 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2396 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2398 /* Create SNOW 3G operation */
2399 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2400 tdata->auth_iv.data, tdata->auth_iv.len,
2401 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2402 tdata->validAuthLenInBits.len,
2407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2409 ut_params->obuf = ut_params->op->sym->m_src;
2410 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2411 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2412 + plaintext_pad_len;
2415 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2418 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2419 "SNOW 3G Generated auth tag not as expected");
2425 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2427 struct crypto_testsuite_params *ts_params = &testsuite_params;
2428 struct crypto_unittest_params *ut_params = &unittest_params;
2431 unsigned plaintext_pad_len;
2432 unsigned plaintext_len;
2435 /* QAT PMD supports byte-aligned data only */
2436 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2437 (gbl_driver_id == rte_cryptodev_driver_id_get(
2438 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2441 /* Verify the capabilities */
2442 struct rte_cryptodev_sym_capability_idx cap_idx;
2443 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2444 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2445 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2449 /* Create SNOW 3G session */
2450 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2451 tdata->key.data, tdata->key.len,
2452 tdata->auth_iv.len, tdata->digest.len,
2453 RTE_CRYPTO_AUTH_OP_VERIFY,
2454 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2457 /* alloc mbuf and set payload */
2458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2461 rte_pktmbuf_tailroom(ut_params->ibuf));
2463 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2464 /* Append data which is padded to a multiple of */
2465 /* the algorithms block size */
2466 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2467 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2469 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2471 /* Create SNOW 3G operation */
2472 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2474 tdata->auth_iv.data, tdata->auth_iv.len,
2476 RTE_CRYPTO_AUTH_OP_VERIFY,
2477 tdata->validAuthLenInBits.len,
2482 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2485 ut_params->obuf = ut_params->op->sym->m_src;
2486 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2487 + plaintext_pad_len;
2490 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2499 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2501 struct crypto_testsuite_params *ts_params = &testsuite_params;
2502 struct crypto_unittest_params *ut_params = &unittest_params;
2505 unsigned plaintext_pad_len;
2506 unsigned plaintext_len;
2509 /* Verify the capabilities */
2510 struct rte_cryptodev_sym_capability_idx cap_idx;
2511 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2512 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2513 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2517 /* Create KASUMI session */
2518 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2519 tdata->key.data, tdata->key.len,
2520 0, tdata->digest.len,
2521 RTE_CRYPTO_AUTH_OP_GENERATE,
2522 RTE_CRYPTO_AUTH_KASUMI_F9);
2526 /* alloc mbuf and set payload */
2527 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2529 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2530 rte_pktmbuf_tailroom(ut_params->ibuf));
2532 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2533 /* Append data which is padded to a multiple of */
2534 /* the algorithms block size */
2535 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2536 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2538 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2540 /* Create KASUMI operation */
2541 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2543 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2544 tdata->plaintext.len,
2549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2551 ut_params->obuf = ut_params->op->sym->m_src;
2552 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2553 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2554 + plaintext_pad_len;
2557 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2560 DIGEST_BYTE_LENGTH_KASUMI_F9,
2561 "KASUMI Generated auth tag not as expected");
2567 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2569 struct crypto_testsuite_params *ts_params = &testsuite_params;
2570 struct crypto_unittest_params *ut_params = &unittest_params;
2573 unsigned plaintext_pad_len;
2574 unsigned plaintext_len;
2577 /* Verify the capabilities */
2578 struct rte_cryptodev_sym_capability_idx cap_idx;
2579 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2580 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2581 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2585 /* Create KASUMI session */
2586 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2587 tdata->key.data, tdata->key.len,
2588 0, tdata->digest.len,
2589 RTE_CRYPTO_AUTH_OP_VERIFY,
2590 RTE_CRYPTO_AUTH_KASUMI_F9);
2593 /* alloc mbuf and set payload */
2594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2596 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2597 rte_pktmbuf_tailroom(ut_params->ibuf));
2599 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2600 /* Append data which is padded to a multiple */
2601 /* of the algorithms block size */
2602 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2603 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2605 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2607 /* Create KASUMI operation */
2608 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2612 RTE_CRYPTO_AUTH_OP_VERIFY,
2613 tdata->plaintext.len,
2618 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2620 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2621 ut_params->obuf = ut_params->op->sym->m_src;
2622 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2623 + plaintext_pad_len;
2626 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2635 test_snow3g_hash_generate_test_case_1(void)
2637 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2641 test_snow3g_hash_generate_test_case_2(void)
2643 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2647 test_snow3g_hash_generate_test_case_3(void)
2649 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2653 test_snow3g_hash_generate_test_case_4(void)
2655 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2659 test_snow3g_hash_generate_test_case_5(void)
2661 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2665 test_snow3g_hash_generate_test_case_6(void)
2667 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2671 test_snow3g_hash_verify_test_case_1(void)
2673 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2678 test_snow3g_hash_verify_test_case_2(void)
2680 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2684 test_snow3g_hash_verify_test_case_3(void)
2686 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2690 test_snow3g_hash_verify_test_case_4(void)
2692 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2696 test_snow3g_hash_verify_test_case_5(void)
2698 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2702 test_snow3g_hash_verify_test_case_6(void)
2704 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2708 test_kasumi_hash_generate_test_case_1(void)
2710 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2714 test_kasumi_hash_generate_test_case_2(void)
2716 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2720 test_kasumi_hash_generate_test_case_3(void)
2722 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2726 test_kasumi_hash_generate_test_case_4(void)
2728 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2732 test_kasumi_hash_generate_test_case_5(void)
2734 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2738 test_kasumi_hash_generate_test_case_6(void)
2740 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2744 test_kasumi_hash_verify_test_case_1(void)
2746 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2750 test_kasumi_hash_verify_test_case_2(void)
2752 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2756 test_kasumi_hash_verify_test_case_3(void)
2758 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2762 test_kasumi_hash_verify_test_case_4(void)
2764 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2768 test_kasumi_hash_verify_test_case_5(void)
2770 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2774 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2776 struct crypto_testsuite_params *ts_params = &testsuite_params;
2777 struct crypto_unittest_params *ut_params = &unittest_params;
2780 uint8_t *plaintext, *ciphertext;
2781 unsigned plaintext_pad_len;
2782 unsigned plaintext_len;
2784 /* Verify the capabilities */
2785 struct rte_cryptodev_sym_capability_idx cap_idx;
2786 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2787 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2788 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2792 /* Create KASUMI session */
2793 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2795 RTE_CRYPTO_CIPHER_KASUMI_F8,
2796 tdata->key.data, tdata->key.len,
2797 tdata->cipher_iv.len);
2801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2803 /* Clear mbuf payload */
2804 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2805 rte_pktmbuf_tailroom(ut_params->ibuf));
2807 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2808 /* Append data which is padded to a multiple */
2809 /* of the algorithms block size */
2810 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2811 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2813 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2815 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2817 /* Create KASUMI operation */
2818 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2819 tdata->cipher_iv.len,
2820 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2821 tdata->validCipherOffsetInBits.len);
2825 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2827 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2829 ut_params->obuf = ut_params->op->sym->m_dst;
2830 if (ut_params->obuf)
2831 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2833 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2835 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2837 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2838 (tdata->validCipherOffsetInBits.len >> 3);
2840 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2842 reference_ciphertext,
2843 tdata->validCipherLenInBits.len,
2844 "KASUMI Ciphertext data not as expected");
2849 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2851 struct crypto_testsuite_params *ts_params = &testsuite_params;
2852 struct crypto_unittest_params *ut_params = &unittest_params;
2856 unsigned int plaintext_pad_len;
2857 unsigned int plaintext_len;
2859 uint8_t buffer[10000];
2860 const uint8_t *ciphertext;
2862 struct rte_cryptodev_info dev_info;
2864 /* Verify the capabilities */
2865 struct rte_cryptodev_sym_capability_idx cap_idx;
2866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2867 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2868 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2872 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2874 uint64_t feat_flags = dev_info.feature_flags;
2876 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2877 printf("Device doesn't support in-place scatter-gather. "
2882 /* Create KASUMI session */
2883 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2884 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2885 RTE_CRYPTO_CIPHER_KASUMI_F8,
2886 tdata->key.data, tdata->key.len,
2887 tdata->cipher_iv.len);
2891 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2894 /* Append data which is padded to a multiple */
2895 /* of the algorithms block size */
2896 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2898 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2899 plaintext_pad_len, 10, 0);
2901 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2903 /* Create KASUMI operation */
2904 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2905 tdata->cipher_iv.len,
2906 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2907 tdata->validCipherOffsetInBits.len);
2911 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2913 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2915 ut_params->obuf = ut_params->op->sym->m_dst;
2917 if (ut_params->obuf)
2918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2919 plaintext_len, buffer);
2921 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2922 tdata->validCipherOffsetInBits.len >> 3,
2923 plaintext_len, buffer);
2926 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2928 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2929 (tdata->validCipherOffsetInBits.len >> 3);
2931 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2933 reference_ciphertext,
2934 tdata->validCipherLenInBits.len,
2935 "KASUMI Ciphertext data not as expected");
2940 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2942 struct crypto_testsuite_params *ts_params = &testsuite_params;
2943 struct crypto_unittest_params *ut_params = &unittest_params;
2946 uint8_t *plaintext, *ciphertext;
2947 unsigned plaintext_pad_len;
2948 unsigned plaintext_len;
2950 /* Verify the capabilities */
2951 struct rte_cryptodev_sym_capability_idx cap_idx;
2952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2953 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2958 /* Create KASUMI session */
2959 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2960 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2961 RTE_CRYPTO_CIPHER_KASUMI_F8,
2962 tdata->key.data, tdata->key.len,
2963 tdata->cipher_iv.len);
2967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2968 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2970 /* Clear mbuf payload */
2971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2972 rte_pktmbuf_tailroom(ut_params->ibuf));
2974 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2975 /* Append data which is padded to a multiple */
2976 /* of the algorithms block size */
2977 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2978 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2980 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2981 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2983 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2985 /* Create KASUMI operation */
2986 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2987 tdata->cipher_iv.len,
2988 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2989 tdata->validCipherOffsetInBits.len);
2993 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2995 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2997 ut_params->obuf = ut_params->op->sym->m_dst;
2998 if (ut_params->obuf)
2999 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3001 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3003 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3005 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3006 (tdata->validCipherOffsetInBits.len >> 3);
3008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3010 reference_ciphertext,
3011 tdata->validCipherLenInBits.len,
3012 "KASUMI Ciphertext data not as expected");
3017 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3019 struct crypto_testsuite_params *ts_params = &testsuite_params;
3020 struct crypto_unittest_params *ut_params = &unittest_params;
3023 unsigned int plaintext_pad_len;
3024 unsigned int plaintext_len;
3026 const uint8_t *ciphertext;
3027 uint8_t buffer[2048];
3029 struct rte_cryptodev_info dev_info;
3031 /* Verify the capabilities */
3032 struct rte_cryptodev_sym_capability_idx cap_idx;
3033 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3034 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3035 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3039 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3041 uint64_t feat_flags = dev_info.feature_flags;
3042 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3043 printf("Device doesn't support out-of-place scatter-gather "
3044 "in both input and output mbufs. "
3049 /* Create KASUMI session */
3050 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3051 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3052 RTE_CRYPTO_CIPHER_KASUMI_F8,
3053 tdata->key.data, tdata->key.len,
3054 tdata->cipher_iv.len);
3058 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3059 /* Append data which is padded to a multiple */
3060 /* of the algorithms block size */
3061 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3063 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3064 plaintext_pad_len, 10, 0);
3065 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3066 plaintext_pad_len, 3, 0);
3068 /* Append data which is padded to a multiple */
3069 /* of the algorithms block size */
3070 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3072 /* Create KASUMI operation */
3073 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3074 tdata->cipher_iv.len,
3075 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3076 tdata->validCipherOffsetInBits.len);
3080 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3082 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3084 ut_params->obuf = ut_params->op->sym->m_dst;
3085 if (ut_params->obuf)
3086 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3087 plaintext_pad_len, buffer);
3089 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3090 tdata->validCipherOffsetInBits.len >> 3,
3091 plaintext_pad_len, buffer);
3093 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3094 (tdata->validCipherOffsetInBits.len >> 3);
3096 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3098 reference_ciphertext,
3099 tdata->validCipherLenInBits.len,
3100 "KASUMI Ciphertext data not as expected");
3106 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3108 struct crypto_testsuite_params *ts_params = &testsuite_params;
3109 struct crypto_unittest_params *ut_params = &unittest_params;
3112 uint8_t *ciphertext, *plaintext;
3113 unsigned ciphertext_pad_len;
3114 unsigned ciphertext_len;
3116 /* Verify the capabilities */
3117 struct rte_cryptodev_sym_capability_idx cap_idx;
3118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3119 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3124 /* Create KASUMI session */
3125 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3126 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3127 RTE_CRYPTO_CIPHER_KASUMI_F8,
3128 tdata->key.data, tdata->key.len,
3129 tdata->cipher_iv.len);
3133 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3134 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3136 /* Clear mbuf payload */
3137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3138 rte_pktmbuf_tailroom(ut_params->ibuf));
3140 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3141 /* Append data which is padded to a multiple */
3142 /* of the algorithms block size */
3143 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3144 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3145 ciphertext_pad_len);
3146 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3147 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3149 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3151 /* Create KASUMI operation */
3152 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3153 tdata->cipher_iv.len,
3154 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3155 tdata->validCipherOffsetInBits.len);
3159 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3163 ut_params->obuf = ut_params->op->sym->m_dst;
3164 if (ut_params->obuf)
3165 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3167 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3169 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3171 const uint8_t *reference_plaintext = tdata->plaintext.data +
3172 (tdata->validCipherOffsetInBits.len >> 3);
3174 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3176 reference_plaintext,
3177 tdata->validCipherLenInBits.len,
3178 "KASUMI Plaintext data not as expected");
3183 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3185 struct crypto_testsuite_params *ts_params = &testsuite_params;
3186 struct crypto_unittest_params *ut_params = &unittest_params;
3189 uint8_t *ciphertext, *plaintext;
3190 unsigned ciphertext_pad_len;
3191 unsigned ciphertext_len;
3193 /* Verify the capabilities */
3194 struct rte_cryptodev_sym_capability_idx cap_idx;
3195 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3196 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3197 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3201 /* Create KASUMI session */
3202 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3203 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3204 RTE_CRYPTO_CIPHER_KASUMI_F8,
3205 tdata->key.data, tdata->key.len,
3206 tdata->cipher_iv.len);
3210 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3212 /* Clear mbuf payload */
3213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3214 rte_pktmbuf_tailroom(ut_params->ibuf));
3216 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3217 /* Append data which is padded to a multiple */
3218 /* of the algorithms block size */
3219 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3220 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3221 ciphertext_pad_len);
3222 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3224 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3226 /* Create KASUMI operation */
3227 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3228 tdata->cipher_iv.len,
3229 tdata->ciphertext.len,
3230 tdata->validCipherOffsetInBits.len);
3234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3238 ut_params->obuf = ut_params->op->sym->m_dst;
3239 if (ut_params->obuf)
3240 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3242 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3244 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3246 const uint8_t *reference_plaintext = tdata->plaintext.data +
3247 (tdata->validCipherOffsetInBits.len >> 3);
3249 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3251 reference_plaintext,
3252 tdata->validCipherLenInBits.len,
3253 "KASUMI Plaintext data not as expected");
3258 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3264 uint8_t *plaintext, *ciphertext;
3265 unsigned plaintext_pad_len;
3266 unsigned plaintext_len;
3268 /* Verify the capabilities */
3269 struct rte_cryptodev_sym_capability_idx cap_idx;
3270 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3271 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3272 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3276 /* Create SNOW 3G session */
3277 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3278 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3279 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3280 tdata->key.data, tdata->key.len,
3281 tdata->cipher_iv.len);
3285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3287 /* Clear mbuf payload */
3288 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3289 rte_pktmbuf_tailroom(ut_params->ibuf));
3291 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3292 /* Append data which is padded to a multiple of */
3293 /* the algorithms block size */
3294 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3295 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3297 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3299 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3301 /* Create SNOW 3G operation */
3302 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3303 tdata->cipher_iv.len,
3304 tdata->validCipherLenInBits.len,
3309 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3313 ut_params->obuf = ut_params->op->sym->m_dst;
3314 if (ut_params->obuf)
3315 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3317 ciphertext = plaintext;
3319 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3322 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3324 tdata->ciphertext.data,
3325 tdata->validDataLenInBits.len,
3326 "SNOW 3G Ciphertext data not as expected");
3332 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3334 struct crypto_testsuite_params *ts_params = &testsuite_params;
3335 struct crypto_unittest_params *ut_params = &unittest_params;
3336 uint8_t *plaintext, *ciphertext;
3339 unsigned plaintext_pad_len;
3340 unsigned plaintext_len;
3342 /* Verify the capabilities */
3343 struct rte_cryptodev_sym_capability_idx cap_idx;
3344 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3345 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3346 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3350 /* Create SNOW 3G session */
3351 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3352 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3353 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3354 tdata->key.data, tdata->key.len,
3355 tdata->cipher_iv.len);
3359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3360 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3362 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3363 "Failed to allocate input buffer in mempool");
3364 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3365 "Failed to allocate output buffer in mempool");
3367 /* Clear mbuf payload */
3368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3369 rte_pktmbuf_tailroom(ut_params->ibuf));
3371 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3372 /* Append data which is padded to a multiple of */
3373 /* the algorithms block size */
3374 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3377 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3378 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3380 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3382 /* Create SNOW 3G operation */
3383 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3384 tdata->cipher_iv.len,
3385 tdata->validCipherLenInBits.len,
3390 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3394 ut_params->obuf = ut_params->op->sym->m_dst;
3395 if (ut_params->obuf)
3396 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3398 ciphertext = plaintext;
3400 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3403 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3405 tdata->ciphertext.data,
3406 tdata->validDataLenInBits.len,
3407 "SNOW 3G Ciphertext data not as expected");
3412 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3414 struct crypto_testsuite_params *ts_params = &testsuite_params;
3415 struct crypto_unittest_params *ut_params = &unittest_params;
3418 unsigned int plaintext_pad_len;
3419 unsigned int plaintext_len;
3420 uint8_t buffer[10000];
3421 const uint8_t *ciphertext;
3423 struct rte_cryptodev_info dev_info;
3425 /* Verify the capabilities */
3426 struct rte_cryptodev_sym_capability_idx cap_idx;
3427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3428 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3433 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3435 uint64_t feat_flags = dev_info.feature_flags;
3437 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3438 printf("Device doesn't support out-of-place scatter-gather "
3439 "in both input and output mbufs. "
3444 /* Create SNOW 3G session */
3445 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3446 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3447 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3448 tdata->key.data, tdata->key.len,
3449 tdata->cipher_iv.len);
3453 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3454 /* Append data which is padded to a multiple of */
3455 /* the algorithms block size */
3456 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3458 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3459 plaintext_pad_len, 10, 0);
3460 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3461 plaintext_pad_len, 3, 0);
3463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3464 "Failed to allocate input buffer in mempool");
3465 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3466 "Failed to allocate output buffer in mempool");
3468 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3470 /* Create SNOW 3G operation */
3471 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3472 tdata->cipher_iv.len,
3473 tdata->validCipherLenInBits.len,
3478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3482 ut_params->obuf = ut_params->op->sym->m_dst;
3483 if (ut_params->obuf)
3484 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3485 plaintext_len, buffer);
3487 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3488 plaintext_len, buffer);
3490 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3493 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3495 tdata->ciphertext.data,
3496 tdata->validDataLenInBits.len,
3497 "SNOW 3G Ciphertext data not as expected");
3502 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3504 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3506 uint8_t curr_byte, prev_byte;
3507 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3508 uint8_t lower_byte_mask = (1 << offset) - 1;
3511 prev_byte = buffer[0];
3512 buffer[0] >>= offset;
3514 for (i = 1; i < length_in_bytes; i++) {
3515 curr_byte = buffer[i];
3516 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3517 (curr_byte >> offset);
3518 prev_byte = curr_byte;
3523 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3525 struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 struct crypto_unittest_params *ut_params = &unittest_params;
3527 uint8_t *plaintext, *ciphertext;
3529 uint32_t plaintext_len;
3530 uint32_t plaintext_pad_len;
3531 uint8_t extra_offset = 4;
3532 uint8_t *expected_ciphertext_shifted;
3534 /* QAT PMD supports byte-aligned data only */
3535 if (gbl_driver_id == rte_cryptodev_driver_id_get(
3536 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
3539 /* Verify the capabilities */
3540 struct rte_cryptodev_sym_capability_idx cap_idx;
3541 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3542 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3543 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3547 /* Create SNOW 3G session */
3548 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3549 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3550 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3551 tdata->key.data, tdata->key.len,
3552 tdata->cipher_iv.len);
3556 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3557 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3559 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3560 "Failed to allocate input buffer in mempool");
3561 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3562 "Failed to allocate output buffer in mempool");
3564 /* Clear mbuf payload */
3565 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3566 rte_pktmbuf_tailroom(ut_params->ibuf));
3568 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3570 * Append data which is padded to a
3571 * multiple of the algorithms block size
3573 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3575 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3578 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3580 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3581 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3583 #ifdef RTE_APP_TEST_DEBUG
3584 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3586 /* Create SNOW 3G operation */
3587 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3588 tdata->cipher_iv.len,
3589 tdata->validCipherLenInBits.len,
3594 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3596 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3598 ut_params->obuf = ut_params->op->sym->m_dst;
3599 if (ut_params->obuf)
3600 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3602 ciphertext = plaintext;
3604 #ifdef RTE_APP_TEST_DEBUG
3605 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3608 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3610 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3611 "failed to reserve memory for ciphertext shifted\n");
3613 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3614 ceil_byte_length(tdata->ciphertext.len));
3615 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3618 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3620 expected_ciphertext_shifted,
3621 tdata->validDataLenInBits.len,
3623 "SNOW 3G Ciphertext data not as expected");
3627 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3629 struct crypto_testsuite_params *ts_params = &testsuite_params;
3630 struct crypto_unittest_params *ut_params = &unittest_params;
3634 uint8_t *plaintext, *ciphertext;
3635 unsigned ciphertext_pad_len;
3636 unsigned ciphertext_len;
3638 /* Verify the capabilities */
3639 struct rte_cryptodev_sym_capability_idx cap_idx;
3640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3641 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3642 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3646 /* Create SNOW 3G session */
3647 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3648 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3649 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3650 tdata->key.data, tdata->key.len,
3651 tdata->cipher_iv.len);
3655 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3657 /* Clear mbuf payload */
3658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3659 rte_pktmbuf_tailroom(ut_params->ibuf));
3661 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3662 /* Append data which is padded to a multiple of */
3663 /* the algorithms block size */
3664 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3665 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3666 ciphertext_pad_len);
3667 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3669 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3671 /* Create SNOW 3G operation */
3672 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3673 tdata->cipher_iv.len,
3674 tdata->validCipherLenInBits.len,
3675 tdata->cipher.offset_bits);
3679 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3681 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3682 ut_params->obuf = ut_params->op->sym->m_dst;
3683 if (ut_params->obuf)
3684 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3686 plaintext = ciphertext;
3688 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3691 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3692 tdata->plaintext.data,
3693 tdata->validDataLenInBits.len,
3694 "SNOW 3G Plaintext data not as expected");
3698 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3700 struct crypto_testsuite_params *ts_params = &testsuite_params;
3701 struct crypto_unittest_params *ut_params = &unittest_params;
3705 uint8_t *plaintext, *ciphertext;
3706 unsigned ciphertext_pad_len;
3707 unsigned ciphertext_len;
3709 /* Verify the capabilities */
3710 struct rte_cryptodev_sym_capability_idx cap_idx;
3711 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3712 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3713 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3717 /* Create SNOW 3G session */
3718 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3719 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3720 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3721 tdata->key.data, tdata->key.len,
3722 tdata->cipher_iv.len);
3726 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3729 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3730 "Failed to allocate input buffer");
3731 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3732 "Failed to allocate output buffer");
3734 /* Clear mbuf payload */
3735 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3736 rte_pktmbuf_tailroom(ut_params->ibuf));
3738 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3739 rte_pktmbuf_tailroom(ut_params->obuf));
3741 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3742 /* Append data which is padded to a multiple of */
3743 /* the algorithms block size */
3744 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3745 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3746 ciphertext_pad_len);
3747 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3748 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3750 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3752 /* Create SNOW 3G operation */
3753 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3754 tdata->cipher_iv.len,
3755 tdata->validCipherLenInBits.len,
3760 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3762 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3763 ut_params->obuf = ut_params->op->sym->m_dst;
3764 if (ut_params->obuf)
3765 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3767 plaintext = ciphertext;
3769 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3773 tdata->plaintext.data,
3774 tdata->validDataLenInBits.len,
3775 "SNOW 3G Plaintext data not as expected");
3780 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3782 struct crypto_testsuite_params *ts_params = &testsuite_params;
3783 struct crypto_unittest_params *ut_params = &unittest_params;
3787 uint8_t *plaintext, *ciphertext;
3788 unsigned int plaintext_pad_len;
3789 unsigned int plaintext_len;
3791 struct rte_cryptodev_sym_capability_idx cap_idx;
3793 /* Check if device supports ZUC EEA3 */
3794 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3795 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3797 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3801 /* Check if device supports ZUC EIA3 */
3802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3803 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3805 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3809 /* Create ZUC session */
3810 retval = create_zuc_cipher_auth_encrypt_generate_session(
3811 ts_params->valid_devs[0],
3815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3817 /* clear mbuf payload */
3818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3819 rte_pktmbuf_tailroom(ut_params->ibuf));
3821 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3822 /* Append data which is padded to a multiple of */
3823 /* the algorithms block size */
3824 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3825 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3827 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3829 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3831 /* Create ZUC operation */
3832 retval = create_zuc_cipher_hash_generate_operation(tdata);
3836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3838 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3839 ut_params->obuf = ut_params->op->sym->m_src;
3840 if (ut_params->obuf)
3841 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3843 ciphertext = plaintext;
3845 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3847 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3849 tdata->ciphertext.data,
3850 tdata->validDataLenInBits.len,
3851 "ZUC Ciphertext data not as expected");
3853 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3854 + plaintext_pad_len;
3857 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3861 "ZUC Generated auth tag not as expected");
3866 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3868 struct crypto_testsuite_params *ts_params = &testsuite_params;
3869 struct crypto_unittest_params *ut_params = &unittest_params;
3873 uint8_t *plaintext, *ciphertext;
3874 unsigned plaintext_pad_len;
3875 unsigned plaintext_len;
3877 /* Verify the capabilities */
3878 struct rte_cryptodev_sym_capability_idx cap_idx;
3879 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3880 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3881 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3884 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3885 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3886 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3890 /* Create SNOW 3G session */
3891 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3892 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3893 RTE_CRYPTO_AUTH_OP_GENERATE,
3894 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3895 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3896 tdata->key.data, tdata->key.len,
3897 tdata->auth_iv.len, tdata->digest.len,
3898 tdata->cipher_iv.len);
3901 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3903 /* clear mbuf payload */
3904 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3905 rte_pktmbuf_tailroom(ut_params->ibuf));
3907 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3908 /* Append data which is padded to a multiple of */
3909 /* the algorithms block size */
3910 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3911 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3913 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3915 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3917 /* Create SNOW 3G operation */
3918 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3919 tdata->digest.len, tdata->auth_iv.data,
3921 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3922 tdata->cipher_iv.data, tdata->cipher_iv.len,
3923 tdata->validCipherLenInBits.len,
3925 tdata->validAuthLenInBits.len,
3931 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3933 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3934 ut_params->obuf = ut_params->op->sym->m_src;
3935 if (ut_params->obuf)
3936 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3938 ciphertext = plaintext;
3940 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3942 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3944 tdata->ciphertext.data,
3945 tdata->validDataLenInBits.len,
3946 "SNOW 3G Ciphertext data not as expected");
3948 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3949 + plaintext_pad_len;
3952 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3955 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3956 "SNOW 3G Generated auth tag not as expected");
3961 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
3962 uint8_t op_mode, uint8_t verify)
3964 struct crypto_testsuite_params *ts_params = &testsuite_params;
3965 struct crypto_unittest_params *ut_params = &unittest_params;
3969 uint8_t *plaintext = NULL, *ciphertext = NULL;
3970 unsigned int plaintext_pad_len;
3971 unsigned int plaintext_len;
3972 unsigned int ciphertext_pad_len;
3973 unsigned int ciphertext_len;
3975 struct rte_cryptodev_info dev_info;
3977 /* Verify the capabilities */
3978 struct rte_cryptodev_sym_capability_idx cap_idx;
3979 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3980 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3981 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3984 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3985 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3986 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3990 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3992 uint64_t feat_flags = dev_info.feature_flags;
3994 if (op_mode == OUT_OF_PLACE) {
3995 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
3996 printf("Device doesn't support digest encrypted.\n");
4001 /* Create SNOW 3G session */
4002 retval = create_wireless_algo_auth_cipher_session(
4003 ts_params->valid_devs[0],
4004 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4005 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4006 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4007 : RTE_CRYPTO_AUTH_OP_GENERATE),
4008 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4009 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4010 tdata->key.data, tdata->key.len,
4011 tdata->auth_iv.len, tdata->digest.len,
4012 tdata->cipher_iv.len);
4017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4018 if (op_mode == OUT_OF_PLACE)
4019 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4021 /* clear mbuf payload */
4022 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4023 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 if (op_mode == OUT_OF_PLACE)
4025 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4026 rte_pktmbuf_tailroom(ut_params->obuf));
4028 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4029 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4030 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4031 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4034 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4035 ciphertext_pad_len);
4036 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4037 if (op_mode == OUT_OF_PLACE)
4038 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4039 debug_hexdump(stdout, "ciphertext:", ciphertext,
4042 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4044 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4045 if (op_mode == OUT_OF_PLACE)
4046 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4047 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_auth_cipher_operation(
4052 tdata->digest.data, tdata->digest.len,
4053 tdata->cipher_iv.data, tdata->cipher_iv.len,
4054 tdata->auth_iv.data, tdata->auth_iv.len,
4055 (tdata->digest.offset_bytes == 0 ?
4056 (verify ? ciphertext_pad_len : plaintext_pad_len)
4057 : tdata->digest.offset_bytes),
4058 tdata->validCipherLenInBits.len,
4059 tdata->cipher.offset_bits,
4060 tdata->validAuthLenInBits.len,
4061 tdata->auth.offset_bits,
4062 op_mode, 0, verify);
4067 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4070 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4072 ut_params->obuf = (op_mode == IN_PLACE ?
4073 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4076 if (ut_params->obuf)
4077 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4080 plaintext = ciphertext +
4081 (tdata->cipher.offset_bits >> 3);
4083 debug_hexdump(stdout, "plaintext:", plaintext,
4084 (tdata->plaintext.len >> 3) - tdata->digest.len);
4085 debug_hexdump(stdout, "plaintext expected:",
4086 tdata->plaintext.data,
4087 (tdata->plaintext.len >> 3) - tdata->digest.len);
4089 if (ut_params->obuf)
4090 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4093 ciphertext = plaintext;
4095 debug_hexdump(stdout, "ciphertext:", ciphertext,
4097 debug_hexdump(stdout, "ciphertext expected:",
4098 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4100 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4101 + (tdata->digest.offset_bytes == 0 ?
4102 plaintext_pad_len : tdata->digest.offset_bytes);
4104 debug_hexdump(stdout, "digest:", ut_params->digest,
4106 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4112 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4114 tdata->plaintext.data,
4115 tdata->plaintext.len >> 3,
4116 "SNOW 3G Plaintext data not as expected");
4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4120 tdata->ciphertext.data,
4121 tdata->validDataLenInBits.len,
4122 "SNOW 3G Ciphertext data not as expected");
4124 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4127 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4128 "SNOW 3G Generated auth tag not as expected");
4134 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4135 uint8_t op_mode, uint8_t verify)
4137 struct crypto_testsuite_params *ts_params = &testsuite_params;
4138 struct crypto_unittest_params *ut_params = &unittest_params;
4142 const uint8_t *plaintext = NULL;
4143 const uint8_t *ciphertext = NULL;
4144 const uint8_t *digest = NULL;
4145 unsigned int plaintext_pad_len;
4146 unsigned int plaintext_len;
4147 unsigned int ciphertext_pad_len;
4148 unsigned int ciphertext_len;
4149 uint8_t buffer[10000];
4150 uint8_t digest_buffer[10000];
4152 struct rte_cryptodev_info dev_info;
4154 /* Verify the capabilities */
4155 struct rte_cryptodev_sym_capability_idx cap_idx;
4156 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4157 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4158 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4161 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4162 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4169 uint64_t feat_flags = dev_info.feature_flags;
4171 if (op_mode == IN_PLACE) {
4172 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4173 printf("Device doesn't support in-place scatter-gather "
4174 "in both input and output mbufs.\n");
4178 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4179 printf("Device doesn't support out-of-place scatter-gather "
4180 "in both input and output mbufs.\n");
4183 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4184 printf("Device doesn't support digest encrypted.\n");
4189 /* Create SNOW 3G session */
4190 retval = create_wireless_algo_auth_cipher_session(
4191 ts_params->valid_devs[0],
4192 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4193 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4194 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4195 : RTE_CRYPTO_AUTH_OP_GENERATE),
4196 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4197 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4198 tdata->key.data, tdata->key.len,
4199 tdata->auth_iv.len, tdata->digest.len,
4200 tdata->cipher_iv.len);
4205 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4206 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4207 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4208 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4210 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4211 plaintext_pad_len, 15, 0);
4212 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4213 "Failed to allocate input buffer in mempool");
4215 if (op_mode == OUT_OF_PLACE) {
4216 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4217 plaintext_pad_len, 15, 0);
4218 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4219 "Failed to allocate output buffer in mempool");
4223 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4224 tdata->ciphertext.data);
4225 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4226 ciphertext_len, buffer);
4227 debug_hexdump(stdout, "ciphertext:", ciphertext,
4230 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4231 tdata->plaintext.data);
4232 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4233 plaintext_len, buffer);
4234 debug_hexdump(stdout, "plaintext:", plaintext,
4237 memset(buffer, 0, sizeof(buffer));
4239 /* Create SNOW 3G operation */
4240 retval = create_wireless_algo_auth_cipher_operation(
4241 tdata->digest.data, tdata->digest.len,
4242 tdata->cipher_iv.data, tdata->cipher_iv.len,
4243 tdata->auth_iv.data, tdata->auth_iv.len,
4244 (tdata->digest.offset_bytes == 0 ?
4245 (verify ? ciphertext_pad_len : plaintext_pad_len)
4246 : tdata->digest.offset_bytes),
4247 tdata->validCipherLenInBits.len,
4248 tdata->cipher.offset_bits,
4249 tdata->validAuthLenInBits.len,
4250 tdata->auth.offset_bits,
4251 op_mode, 1, verify);
4256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4261 ut_params->obuf = (op_mode == IN_PLACE ?
4262 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4265 if (ut_params->obuf)
4266 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4267 plaintext_len, buffer);
4269 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4270 plaintext_len, buffer);
4272 debug_hexdump(stdout, "plaintext:", plaintext,
4273 (tdata->plaintext.len >> 3) - tdata->digest.len);
4274 debug_hexdump(stdout, "plaintext expected:",
4275 tdata->plaintext.data,
4276 (tdata->plaintext.len >> 3) - tdata->digest.len);
4278 if (ut_params->obuf)
4279 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4280 ciphertext_len, buffer);
4282 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4283 ciphertext_len, buffer);
4285 debug_hexdump(stdout, "ciphertext:", ciphertext,
4287 debug_hexdump(stdout, "ciphertext expected:",
4288 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4290 if (ut_params->obuf)
4291 digest = rte_pktmbuf_read(ut_params->obuf,
4292 (tdata->digest.offset_bytes == 0 ?
4293 plaintext_pad_len : tdata->digest.offset_bytes),
4294 tdata->digest.len, digest_buffer);
4296 digest = rte_pktmbuf_read(ut_params->ibuf,
4297 (tdata->digest.offset_bytes == 0 ?
4298 plaintext_pad_len : tdata->digest.offset_bytes),
4299 tdata->digest.len, digest_buffer);
4301 debug_hexdump(stdout, "digest:", digest,
4303 debug_hexdump(stdout, "digest expected:",
4304 tdata->digest.data, tdata->digest.len);
4309 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4311 tdata->plaintext.data,
4312 tdata->plaintext.len >> 3,
4313 "SNOW 3G Plaintext data not as expected");
4315 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4317 tdata->ciphertext.data,
4318 tdata->validDataLenInBits.len,
4319 "SNOW 3G Ciphertext data not as expected");
4321 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4324 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4325 "SNOW 3G Generated auth tag not as expected");
4331 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4332 uint8_t op_mode, uint8_t verify)
4334 struct crypto_testsuite_params *ts_params = &testsuite_params;
4335 struct crypto_unittest_params *ut_params = &unittest_params;
4339 uint8_t *plaintext = NULL, *ciphertext = NULL;
4340 unsigned int plaintext_pad_len;
4341 unsigned int plaintext_len;
4342 unsigned int ciphertext_pad_len;
4343 unsigned int ciphertext_len;
4345 struct rte_cryptodev_info dev_info;
4347 /* Verify the capabilities */
4348 struct rte_cryptodev_sym_capability_idx cap_idx;
4349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4350 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4351 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4354 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4355 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4356 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4360 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4362 uint64_t feat_flags = dev_info.feature_flags;
4364 if (op_mode == OUT_OF_PLACE) {
4365 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4366 printf("Device doesn't support digest encrypted.\n");
4371 /* Create KASUMI session */
4372 retval = create_wireless_algo_auth_cipher_session(
4373 ts_params->valid_devs[0],
4374 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4375 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4376 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4377 : RTE_CRYPTO_AUTH_OP_GENERATE),
4378 RTE_CRYPTO_AUTH_KASUMI_F9,
4379 RTE_CRYPTO_CIPHER_KASUMI_F8,
4380 tdata->key.data, tdata->key.len,
4381 0, tdata->digest.len,
4382 tdata->cipher_iv.len);
4387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4388 if (op_mode == OUT_OF_PLACE)
4389 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4391 /* clear mbuf payload */
4392 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4393 rte_pktmbuf_tailroom(ut_params->ibuf));
4394 if (op_mode == OUT_OF_PLACE)
4395 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4396 rte_pktmbuf_tailroom(ut_params->obuf));
4398 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4399 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4400 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4401 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4404 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4405 ciphertext_pad_len);
4406 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4407 if (op_mode == OUT_OF_PLACE)
4408 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4409 debug_hexdump(stdout, "ciphertext:", ciphertext,
4412 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4414 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4415 if (op_mode == OUT_OF_PLACE)
4416 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4417 debug_hexdump(stdout, "plaintext:", plaintext,
4421 /* Create KASUMI operation */
4422 retval = create_wireless_algo_auth_cipher_operation(
4423 tdata->digest.data, tdata->digest.len,
4424 tdata->cipher_iv.data, tdata->cipher_iv.len,
4426 (tdata->digest.offset_bytes == 0 ?
4427 (verify ? ciphertext_pad_len : plaintext_pad_len)
4428 : tdata->digest.offset_bytes),
4429 tdata->validCipherLenInBits.len,
4430 tdata->validCipherOffsetInBits.len,
4431 tdata->validAuthLenInBits.len,
4433 op_mode, 0, verify);
4438 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4441 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4443 ut_params->obuf = (op_mode == IN_PLACE ?
4444 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4448 if (ut_params->obuf)
4449 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4452 plaintext = ciphertext;
4454 debug_hexdump(stdout, "plaintext:", plaintext,
4455 (tdata->plaintext.len >> 3) - tdata->digest.len);
4456 debug_hexdump(stdout, "plaintext expected:",
4457 tdata->plaintext.data,
4458 (tdata->plaintext.len >> 3) - tdata->digest.len);
4460 if (ut_params->obuf)
4461 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4464 ciphertext = plaintext;
4466 debug_hexdump(stdout, "ciphertext:", ciphertext,
4468 debug_hexdump(stdout, "ciphertext expected:",
4469 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4471 ut_params->digest = rte_pktmbuf_mtod(
4472 ut_params->obuf, uint8_t *) +
4473 (tdata->digest.offset_bytes == 0 ?
4474 plaintext_pad_len : tdata->digest.offset_bytes);
4476 debug_hexdump(stdout, "digest:", ut_params->digest,
4478 debug_hexdump(stdout, "digest expected:",
4479 tdata->digest.data, tdata->digest.len);
4484 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4486 tdata->plaintext.data,
4487 tdata->plaintext.len >> 3,
4488 "KASUMI Plaintext data not as expected");
4490 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4492 tdata->ciphertext.data,
4493 tdata->ciphertext.len >> 3,
4494 "KASUMI Ciphertext data not as expected");
4496 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4499 DIGEST_BYTE_LENGTH_KASUMI_F9,
4500 "KASUMI Generated auth tag not as expected");
4506 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4507 uint8_t op_mode, uint8_t verify)
4509 struct crypto_testsuite_params *ts_params = &testsuite_params;
4510 struct crypto_unittest_params *ut_params = &unittest_params;
4514 const uint8_t *plaintext = NULL;
4515 const uint8_t *ciphertext = NULL;
4516 const uint8_t *digest = NULL;
4517 unsigned int plaintext_pad_len;
4518 unsigned int plaintext_len;
4519 unsigned int ciphertext_pad_len;
4520 unsigned int ciphertext_len;
4521 uint8_t buffer[10000];
4522 uint8_t digest_buffer[10000];
4524 struct rte_cryptodev_info dev_info;
4526 /* Verify the capabilities */
4527 struct rte_cryptodev_sym_capability_idx cap_idx;
4528 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4529 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4530 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4534 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4535 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4539 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4541 uint64_t feat_flags = dev_info.feature_flags;
4543 if (op_mode == IN_PLACE) {
4544 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4545 printf("Device doesn't support in-place scatter-gather "
4546 "in both input and output mbufs.\n");
4550 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4551 printf("Device doesn't support out-of-place scatter-gather "
4552 "in both input and output mbufs.\n");
4555 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4556 printf("Device doesn't support digest encrypted.\n");
4561 /* Create KASUMI session */
4562 retval = create_wireless_algo_auth_cipher_session(
4563 ts_params->valid_devs[0],
4564 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4565 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4566 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4567 : RTE_CRYPTO_AUTH_OP_GENERATE),
4568 RTE_CRYPTO_AUTH_KASUMI_F9,
4569 RTE_CRYPTO_CIPHER_KASUMI_F8,
4570 tdata->key.data, tdata->key.len,
4571 0, tdata->digest.len,
4572 tdata->cipher_iv.len);
4577 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4578 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4579 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4580 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4582 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4583 plaintext_pad_len, 15, 0);
4584 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4585 "Failed to allocate input buffer in mempool");
4587 if (op_mode == OUT_OF_PLACE) {
4588 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4589 plaintext_pad_len, 15, 0);
4590 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4591 "Failed to allocate output buffer in mempool");
4595 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4596 tdata->ciphertext.data);
4597 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4598 ciphertext_len, buffer);
4599 debug_hexdump(stdout, "ciphertext:", ciphertext,
4602 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4603 tdata->plaintext.data);
4604 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4605 plaintext_len, buffer);
4606 debug_hexdump(stdout, "plaintext:", plaintext,
4609 memset(buffer, 0, sizeof(buffer));
4611 /* Create KASUMI operation */
4612 retval = create_wireless_algo_auth_cipher_operation(
4613 tdata->digest.data, tdata->digest.len,
4614 tdata->cipher_iv.data, tdata->cipher_iv.len,
4616 (tdata->digest.offset_bytes == 0 ?
4617 (verify ? ciphertext_pad_len : plaintext_pad_len)
4618 : tdata->digest.offset_bytes),
4619 tdata->validCipherLenInBits.len,
4620 tdata->validCipherOffsetInBits.len,
4621 tdata->validAuthLenInBits.len,
4623 op_mode, 1, verify);
4628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4631 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4633 ut_params->obuf = (op_mode == IN_PLACE ?
4634 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4637 if (ut_params->obuf)
4638 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4639 plaintext_len, buffer);
4641 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4642 plaintext_len, buffer);
4644 debug_hexdump(stdout, "plaintext:", plaintext,
4645 (tdata->plaintext.len >> 3) - tdata->digest.len);
4646 debug_hexdump(stdout, "plaintext expected:",
4647 tdata->plaintext.data,
4648 (tdata->plaintext.len >> 3) - tdata->digest.len);
4650 if (ut_params->obuf)
4651 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4652 ciphertext_len, buffer);
4654 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4655 ciphertext_len, buffer);
4657 debug_hexdump(stdout, "ciphertext:", ciphertext,
4659 debug_hexdump(stdout, "ciphertext expected:",
4660 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4662 if (ut_params->obuf)
4663 digest = rte_pktmbuf_read(ut_params->obuf,
4664 (tdata->digest.offset_bytes == 0 ?
4665 plaintext_pad_len : tdata->digest.offset_bytes),
4666 tdata->digest.len, digest_buffer);
4668 digest = rte_pktmbuf_read(ut_params->ibuf,
4669 (tdata->digest.offset_bytes == 0 ?
4670 plaintext_pad_len : tdata->digest.offset_bytes),
4671 tdata->digest.len, digest_buffer);
4673 debug_hexdump(stdout, "digest:", digest,
4675 debug_hexdump(stdout, "digest expected:",
4676 tdata->digest.data, tdata->digest.len);
4681 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4683 tdata->plaintext.data,
4684 tdata->plaintext.len >> 3,
4685 "KASUMI Plaintext data not as expected");
4687 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4689 tdata->ciphertext.data,
4690 tdata->validDataLenInBits.len,
4691 "KASUMI Ciphertext data not as expected");
4693 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4696 DIGEST_BYTE_LENGTH_KASUMI_F9,
4697 "KASUMI Generated auth tag not as expected");
4703 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4705 struct crypto_testsuite_params *ts_params = &testsuite_params;
4706 struct crypto_unittest_params *ut_params = &unittest_params;
4710 uint8_t *plaintext, *ciphertext;
4711 unsigned plaintext_pad_len;
4712 unsigned plaintext_len;
4714 /* Verify the capabilities */
4715 struct rte_cryptodev_sym_capability_idx cap_idx;
4716 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4717 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4718 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4721 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4722 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4723 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4727 /* Create KASUMI session */
4728 retval = create_wireless_algo_cipher_auth_session(
4729 ts_params->valid_devs[0],
4730 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4731 RTE_CRYPTO_AUTH_OP_GENERATE,
4732 RTE_CRYPTO_AUTH_KASUMI_F9,
4733 RTE_CRYPTO_CIPHER_KASUMI_F8,
4734 tdata->key.data, tdata->key.len,
4735 0, tdata->digest.len,
4736 tdata->cipher_iv.len);
4740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4742 /* clear mbuf payload */
4743 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4744 rte_pktmbuf_tailroom(ut_params->ibuf));
4746 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4747 /* Append data which is padded to a multiple of */
4748 /* the algorithms block size */
4749 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4750 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4752 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4754 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4756 /* Create KASUMI operation */
4757 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4758 tdata->digest.len, NULL, 0,
4759 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4760 tdata->cipher_iv.data, tdata->cipher_iv.len,
4761 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4762 tdata->validCipherOffsetInBits.len,
4763 tdata->validAuthLenInBits.len,
4769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4773 if (ut_params->op->sym->m_dst)
4774 ut_params->obuf = ut_params->op->sym->m_dst;
4776 ut_params->obuf = ut_params->op->sym->m_src;
4778 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4779 tdata->validCipherOffsetInBits.len >> 3);
4781 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4782 + plaintext_pad_len;
4784 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4785 (tdata->validCipherOffsetInBits.len >> 3);
4787 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4789 reference_ciphertext,
4790 tdata->validCipherLenInBits.len,
4791 "KASUMI Ciphertext data not as expected");
4794 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4797 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4798 "KASUMI Generated auth tag not as expected");
4803 test_zuc_encryption(const struct wireless_test_data *tdata)
4805 struct crypto_testsuite_params *ts_params = &testsuite_params;
4806 struct crypto_unittest_params *ut_params = &unittest_params;
4809 uint8_t *plaintext, *ciphertext;
4810 unsigned plaintext_pad_len;
4811 unsigned plaintext_len;
4813 struct rte_cryptodev_sym_capability_idx cap_idx;
4815 /* Check if device supports ZUC EEA3 */
4816 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4817 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4819 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4823 /* Create ZUC session */
4824 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4825 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4826 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4827 tdata->key.data, tdata->key.len,
4828 tdata->cipher_iv.len);
4832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4834 /* Clear mbuf payload */
4835 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4836 rte_pktmbuf_tailroom(ut_params->ibuf));
4838 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4839 /* Append data which is padded to a multiple */
4840 /* of the algorithms block size */
4841 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4842 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4844 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4846 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4848 /* Create ZUC operation */
4849 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4850 tdata->cipher_iv.len,
4851 tdata->plaintext.len,
4856 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4858 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4860 ut_params->obuf = ut_params->op->sym->m_dst;
4861 if (ut_params->obuf)
4862 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4864 ciphertext = plaintext;
4866 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4871 tdata->ciphertext.data,
4872 tdata->validCipherLenInBits.len,
4873 "ZUC Ciphertext data not as expected");
4878 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4880 struct crypto_testsuite_params *ts_params = &testsuite_params;
4881 struct crypto_unittest_params *ut_params = &unittest_params;
4885 unsigned int plaintext_pad_len;
4886 unsigned int plaintext_len;
4887 const uint8_t *ciphertext;
4888 uint8_t ciphertext_buffer[2048];
4889 struct rte_cryptodev_info dev_info;
4891 struct rte_cryptodev_sym_capability_idx cap_idx;
4893 /* Check if device supports ZUC EEA3 */
4894 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4895 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4897 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4901 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4903 uint64_t feat_flags = dev_info.feature_flags;
4905 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4906 printf("Device doesn't support in-place scatter-gather. "
4911 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4913 /* Append data which is padded to a multiple */
4914 /* of the algorithms block size */
4915 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4917 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4918 plaintext_pad_len, 10, 0);
4920 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4921 tdata->plaintext.data);
4923 /* Create ZUC session */
4924 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4925 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4926 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4927 tdata->key.data, tdata->key.len,
4928 tdata->cipher_iv.len);
4932 /* Clear mbuf payload */
4934 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4936 /* Create ZUC operation */
4937 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4938 tdata->cipher_iv.len, tdata->plaintext.len,
4943 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4945 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4947 ut_params->obuf = ut_params->op->sym->m_dst;
4948 if (ut_params->obuf)
4949 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4950 0, plaintext_len, ciphertext_buffer);
4952 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4953 0, plaintext_len, ciphertext_buffer);
4956 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4959 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4961 tdata->ciphertext.data,
4962 tdata->validCipherLenInBits.len,
4963 "ZUC Ciphertext data not as expected");
4969 test_zuc_authentication(const struct wireless_test_data *tdata)
4971 struct crypto_testsuite_params *ts_params = &testsuite_params;
4972 struct crypto_unittest_params *ut_params = &unittest_params;
4975 unsigned plaintext_pad_len;
4976 unsigned plaintext_len;
4979 struct rte_cryptodev_sym_capability_idx cap_idx;
4981 /* QAT PMD supports byte-aligned data only */
4982 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
4983 (gbl_driver_id == rte_cryptodev_driver_id_get(
4984 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
4987 /* Check if device supports ZUC EIA3 */
4988 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4989 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4991 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4995 /* Create ZUC session */
4996 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4997 tdata->key.data, tdata->key.len,
4998 tdata->auth_iv.len, tdata->digest.len,
4999 RTE_CRYPTO_AUTH_OP_GENERATE,
5000 RTE_CRYPTO_AUTH_ZUC_EIA3);
5004 /* alloc mbuf and set payload */
5005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5008 rte_pktmbuf_tailroom(ut_params->ibuf));
5010 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5011 /* Append data which is padded to a multiple of */
5012 /* the algorithms block size */
5013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5014 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5016 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5018 /* Create ZUC operation */
5019 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5020 tdata->auth_iv.data, tdata->auth_iv.len,
5021 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5022 tdata->validAuthLenInBits.len,
5027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5029 ut_params->obuf = ut_params->op->sym->m_src;
5030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5031 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5032 + plaintext_pad_len;
5035 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5039 "ZUC Generated auth tag not as expected");
5045 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5046 uint8_t op_mode, uint8_t verify)
5048 struct crypto_testsuite_params *ts_params = &testsuite_params;
5049 struct crypto_unittest_params *ut_params = &unittest_params;
5053 uint8_t *plaintext = NULL, *ciphertext = NULL;
5054 unsigned int plaintext_pad_len;
5055 unsigned int plaintext_len;
5056 unsigned int ciphertext_pad_len;
5057 unsigned int ciphertext_len;
5059 struct rte_cryptodev_info dev_info;
5060 struct rte_cryptodev_sym_capability_idx cap_idx;
5062 /* Check if device supports ZUC EIA3 */
5063 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5064 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5066 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5070 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5072 uint64_t feat_flags = dev_info.feature_flags;
5074 if (op_mode == OUT_OF_PLACE) {
5075 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5076 printf("Device doesn't support digest encrypted.\n");
5081 /* Create ZUC session */
5082 retval = create_wireless_algo_auth_cipher_session(
5083 ts_params->valid_devs[0],
5084 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5085 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5086 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5087 : RTE_CRYPTO_AUTH_OP_GENERATE),
5088 RTE_CRYPTO_AUTH_ZUC_EIA3,
5089 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5090 tdata->key.data, tdata->key.len,
5091 tdata->auth_iv.len, tdata->digest.len,
5092 tdata->cipher_iv.len);
5097 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5098 if (op_mode == OUT_OF_PLACE)
5099 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5101 /* clear mbuf payload */
5102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5103 rte_pktmbuf_tailroom(ut_params->ibuf));
5104 if (op_mode == OUT_OF_PLACE)
5105 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5106 rte_pktmbuf_tailroom(ut_params->obuf));
5108 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5109 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5110 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5111 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5114 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5115 ciphertext_pad_len);
5116 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5117 if (op_mode == OUT_OF_PLACE)
5118 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5119 debug_hexdump(stdout, "ciphertext:", ciphertext,
5122 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5124 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5125 if (op_mode == OUT_OF_PLACE)
5126 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5127 debug_hexdump(stdout, "plaintext:", plaintext,
5131 /* Create ZUC operation */
5132 retval = create_wireless_algo_auth_cipher_operation(
5133 tdata->digest.data, tdata->digest.len,
5134 tdata->cipher_iv.data, tdata->cipher_iv.len,
5135 tdata->auth_iv.data, tdata->auth_iv.len,
5136 (tdata->digest.offset_bytes == 0 ?
5137 (verify ? ciphertext_pad_len : plaintext_pad_len)
5138 : tdata->digest.offset_bytes),
5139 tdata->validCipherLenInBits.len,
5140 tdata->validCipherOffsetInBits.len,
5141 tdata->validAuthLenInBits.len,
5143 op_mode, 0, verify);
5148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5153 ut_params->obuf = (op_mode == IN_PLACE ?
5154 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5158 if (ut_params->obuf)
5159 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5162 plaintext = ciphertext;
5164 debug_hexdump(stdout, "plaintext:", plaintext,
5165 (tdata->plaintext.len >> 3) - tdata->digest.len);
5166 debug_hexdump(stdout, "plaintext expected:",
5167 tdata->plaintext.data,
5168 (tdata->plaintext.len >> 3) - tdata->digest.len);
5170 if (ut_params->obuf)
5171 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5174 ciphertext = plaintext;
5176 debug_hexdump(stdout, "ciphertext:", ciphertext,
5178 debug_hexdump(stdout, "ciphertext expected:",
5179 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5181 ut_params->digest = rte_pktmbuf_mtod(
5182 ut_params->obuf, uint8_t *) +
5183 (tdata->digest.offset_bytes == 0 ?
5184 plaintext_pad_len : tdata->digest.offset_bytes);
5186 debug_hexdump(stdout, "digest:", ut_params->digest,
5188 debug_hexdump(stdout, "digest expected:",
5189 tdata->digest.data, tdata->digest.len);
5194 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5196 tdata->plaintext.data,
5197 tdata->plaintext.len >> 3,
5198 "ZUC Plaintext data not as expected");
5200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5202 tdata->ciphertext.data,
5203 tdata->ciphertext.len >> 3,
5204 "ZUC Ciphertext data not as expected");
5206 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5209 DIGEST_BYTE_LENGTH_KASUMI_F9,
5210 "ZUC Generated auth tag not as expected");
5216 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5217 uint8_t op_mode, uint8_t verify)
5219 struct crypto_testsuite_params *ts_params = &testsuite_params;
5220 struct crypto_unittest_params *ut_params = &unittest_params;
5224 const uint8_t *plaintext = NULL;
5225 const uint8_t *ciphertext = NULL;
5226 const uint8_t *digest = NULL;
5227 unsigned int plaintext_pad_len;
5228 unsigned int plaintext_len;
5229 unsigned int ciphertext_pad_len;
5230 unsigned int ciphertext_len;
5231 uint8_t buffer[10000];
5232 uint8_t digest_buffer[10000];
5234 struct rte_cryptodev_info dev_info;
5235 struct rte_cryptodev_sym_capability_idx cap_idx;
5237 /* Check if device supports ZUC EIA3 */
5238 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5239 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5241 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5245 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5247 uint64_t feat_flags = dev_info.feature_flags;
5249 if (op_mode == IN_PLACE) {
5250 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5251 printf("Device doesn't support in-place scatter-gather "
5252 "in both input and output mbufs.\n");
5256 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5257 printf("Device doesn't support out-of-place scatter-gather "
5258 "in both input and output mbufs.\n");
5261 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5262 printf("Device doesn't support digest encrypted.\n");
5267 /* Create ZUC session */
5268 retval = create_wireless_algo_auth_cipher_session(
5269 ts_params->valid_devs[0],
5270 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5271 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5272 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5273 : RTE_CRYPTO_AUTH_OP_GENERATE),
5274 RTE_CRYPTO_AUTH_ZUC_EIA3,
5275 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5276 tdata->key.data, tdata->key.len,
5277 tdata->auth_iv.len, tdata->digest.len,
5278 tdata->cipher_iv.len);
5283 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5284 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5285 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5288 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5289 plaintext_pad_len, 15, 0);
5290 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5291 "Failed to allocate input buffer in mempool");
5293 if (op_mode == OUT_OF_PLACE) {
5294 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5295 plaintext_pad_len, 15, 0);
5296 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5297 "Failed to allocate output buffer in mempool");
5301 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5302 tdata->ciphertext.data);
5303 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5304 ciphertext_len, buffer);
5305 debug_hexdump(stdout, "ciphertext:", ciphertext,
5308 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5309 tdata->plaintext.data);
5310 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5311 plaintext_len, buffer);
5312 debug_hexdump(stdout, "plaintext:", plaintext,
5315 memset(buffer, 0, sizeof(buffer));
5317 /* Create ZUC operation */
5318 retval = create_wireless_algo_auth_cipher_operation(
5319 tdata->digest.data, tdata->digest.len,
5320 tdata->cipher_iv.data, tdata->cipher_iv.len,
5322 (tdata->digest.offset_bytes == 0 ?
5323 (verify ? ciphertext_pad_len : plaintext_pad_len)
5324 : tdata->digest.offset_bytes),
5325 tdata->validCipherLenInBits.len,
5326 tdata->validCipherOffsetInBits.len,
5327 tdata->validAuthLenInBits.len,
5329 op_mode, 1, verify);
5334 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5337 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5339 ut_params->obuf = (op_mode == IN_PLACE ?
5340 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5343 if (ut_params->obuf)
5344 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5345 plaintext_len, buffer);
5347 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5348 plaintext_len, buffer);
5350 debug_hexdump(stdout, "plaintext:", plaintext,
5351 (tdata->plaintext.len >> 3) - tdata->digest.len);
5352 debug_hexdump(stdout, "plaintext expected:",
5353 tdata->plaintext.data,
5354 (tdata->plaintext.len >> 3) - tdata->digest.len);
5356 if (ut_params->obuf)
5357 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5358 ciphertext_len, buffer);
5360 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5361 ciphertext_len, buffer);
5363 debug_hexdump(stdout, "ciphertext:", ciphertext,
5365 debug_hexdump(stdout, "ciphertext expected:",
5366 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5368 if (ut_params->obuf)
5369 digest = rte_pktmbuf_read(ut_params->obuf,
5370 (tdata->digest.offset_bytes == 0 ?
5371 plaintext_pad_len : tdata->digest.offset_bytes),
5372 tdata->digest.len, digest_buffer);
5374 digest = rte_pktmbuf_read(ut_params->ibuf,
5375 (tdata->digest.offset_bytes == 0 ?
5376 plaintext_pad_len : tdata->digest.offset_bytes),
5377 tdata->digest.len, digest_buffer);
5379 debug_hexdump(stdout, "digest:", digest,
5381 debug_hexdump(stdout, "digest expected:",
5382 tdata->digest.data, tdata->digest.len);
5387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5389 tdata->plaintext.data,
5390 tdata->plaintext.len >> 3,
5391 "ZUC Plaintext data not as expected");
5393 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5395 tdata->ciphertext.data,
5396 tdata->validDataLenInBits.len,
5397 "ZUC Ciphertext data not as expected");
5399 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5402 DIGEST_BYTE_LENGTH_KASUMI_F9,
5403 "ZUC Generated auth tag not as expected");
5409 test_kasumi_encryption_test_case_1(void)
5411 return test_kasumi_encryption(&kasumi_test_case_1);
5415 test_kasumi_encryption_test_case_1_sgl(void)
5417 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5421 test_kasumi_encryption_test_case_1_oop(void)
5423 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5427 test_kasumi_encryption_test_case_1_oop_sgl(void)
5429 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5433 test_kasumi_encryption_test_case_2(void)
5435 return test_kasumi_encryption(&kasumi_test_case_2);
5439 test_kasumi_encryption_test_case_3(void)
5441 return test_kasumi_encryption(&kasumi_test_case_3);
5445 test_kasumi_encryption_test_case_4(void)
5447 return test_kasumi_encryption(&kasumi_test_case_4);
5451 test_kasumi_encryption_test_case_5(void)
5453 return test_kasumi_encryption(&kasumi_test_case_5);
5457 test_kasumi_decryption_test_case_1(void)
5459 return test_kasumi_decryption(&kasumi_test_case_1);
5463 test_kasumi_decryption_test_case_1_oop(void)
5465 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5469 test_kasumi_decryption_test_case_2(void)
5471 return test_kasumi_decryption(&kasumi_test_case_2);
5475 test_kasumi_decryption_test_case_3(void)
5477 return test_kasumi_decryption(&kasumi_test_case_3);
5481 test_kasumi_decryption_test_case_4(void)
5483 return test_kasumi_decryption(&kasumi_test_case_4);
5487 test_kasumi_decryption_test_case_5(void)
5489 return test_kasumi_decryption(&kasumi_test_case_5);
5492 test_snow3g_encryption_test_case_1(void)
5494 return test_snow3g_encryption(&snow3g_test_case_1);
5498 test_snow3g_encryption_test_case_1_oop(void)
5500 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5504 test_snow3g_encryption_test_case_1_oop_sgl(void)
5506 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5511 test_snow3g_encryption_test_case_1_offset_oop(void)
5513 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5517 test_snow3g_encryption_test_case_2(void)
5519 return test_snow3g_encryption(&snow3g_test_case_2);
5523 test_snow3g_encryption_test_case_3(void)
5525 return test_snow3g_encryption(&snow3g_test_case_3);
5529 test_snow3g_encryption_test_case_4(void)
5531 return test_snow3g_encryption(&snow3g_test_case_4);
5535 test_snow3g_encryption_test_case_5(void)
5537 return test_snow3g_encryption(&snow3g_test_case_5);
5541 test_snow3g_decryption_test_case_1(void)
5543 return test_snow3g_decryption(&snow3g_test_case_1);
5547 test_snow3g_decryption_test_case_1_oop(void)
5549 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5553 test_snow3g_decryption_test_case_2(void)
5555 return test_snow3g_decryption(&snow3g_test_case_2);
5559 test_snow3g_decryption_test_case_3(void)
5561 return test_snow3g_decryption(&snow3g_test_case_3);
5565 test_snow3g_decryption_test_case_4(void)
5567 return test_snow3g_decryption(&snow3g_test_case_4);
5571 test_snow3g_decryption_test_case_5(void)
5573 return test_snow3g_decryption(&snow3g_test_case_5);
5577 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5578 * Pattern digest from snow3g_test_data must be allocated as
5579 * 4 last bytes in plaintext.
5582 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5583 struct snow3g_hash_test_data *output)
5585 if ((pattern != NULL) && (output != NULL)) {
5586 output->key.len = pattern->key.len;
5588 memcpy(output->key.data,
5589 pattern->key.data, pattern->key.len);
5591 output->auth_iv.len = pattern->auth_iv.len;
5593 memcpy(output->auth_iv.data,
5594 pattern->auth_iv.data, pattern->auth_iv.len);
5596 output->plaintext.len = pattern->plaintext.len;
5598 memcpy(output->plaintext.data,
5599 pattern->plaintext.data, pattern->plaintext.len >> 3);
5601 output->digest.len = pattern->digest.len;
5603 memcpy(output->digest.data,
5604 &pattern->plaintext.data[pattern->digest.offset_bytes],
5605 pattern->digest.len);
5607 output->validAuthLenInBits.len =
5608 pattern->validAuthLenInBits.len;
5613 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5616 test_snow3g_decryption_with_digest_test_case_1(void)
5618 struct snow3g_hash_test_data snow3g_hash_data;
5621 * Function prepare data for hash veryfication test case.
5622 * Digest is allocated in 4 last bytes in plaintext, pattern.
5624 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5626 return test_snow3g_decryption(&snow3g_test_case_7) &
5627 test_snow3g_authentication_verify(&snow3g_hash_data);
5631 test_snow3g_cipher_auth_test_case_1(void)
5633 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5637 test_snow3g_auth_cipher_test_case_1(void)
5639 return test_snow3g_auth_cipher(
5640 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5644 test_snow3g_auth_cipher_test_case_2(void)
5646 return test_snow3g_auth_cipher(
5647 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5651 test_snow3g_auth_cipher_test_case_2_oop(void)
5653 return test_snow3g_auth_cipher(
5654 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5658 test_snow3g_auth_cipher_part_digest_enc(void)
5660 return test_snow3g_auth_cipher(
5661 &snow3g_auth_cipher_partial_digest_encryption,
5666 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5668 return test_snow3g_auth_cipher(
5669 &snow3g_auth_cipher_partial_digest_encryption,
5674 test_snow3g_auth_cipher_test_case_3_sgl(void)
5676 return test_snow3g_auth_cipher_sgl(
5677 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5681 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5683 return test_snow3g_auth_cipher_sgl(
5684 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5688 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5690 return test_snow3g_auth_cipher_sgl(
5691 &snow3g_auth_cipher_partial_digest_encryption,
5696 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5698 return test_snow3g_auth_cipher_sgl(
5699 &snow3g_auth_cipher_partial_digest_encryption,
5704 test_snow3g_auth_cipher_verify_test_case_1(void)
5706 return test_snow3g_auth_cipher(
5707 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5711 test_snow3g_auth_cipher_verify_test_case_2(void)
5713 return test_snow3g_auth_cipher(
5714 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5718 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5720 return test_snow3g_auth_cipher(
5721 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5725 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5727 return test_snow3g_auth_cipher(
5728 &snow3g_auth_cipher_partial_digest_encryption,
5733 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5735 return test_snow3g_auth_cipher(
5736 &snow3g_auth_cipher_partial_digest_encryption,
5741 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5743 return test_snow3g_auth_cipher_sgl(
5744 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5748 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5750 return test_snow3g_auth_cipher_sgl(
5751 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5755 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5757 return test_snow3g_auth_cipher_sgl(
5758 &snow3g_auth_cipher_partial_digest_encryption,
5763 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5765 return test_snow3g_auth_cipher_sgl(
5766 &snow3g_auth_cipher_partial_digest_encryption,
5771 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5773 return test_snow3g_auth_cipher(
5774 &snow3g_test_case_7, IN_PLACE, 0);
5778 test_kasumi_auth_cipher_test_case_1(void)
5780 return test_kasumi_auth_cipher(
5781 &kasumi_test_case_3, IN_PLACE, 0);
5785 test_kasumi_auth_cipher_test_case_2(void)
5787 return test_kasumi_auth_cipher(
5788 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5792 test_kasumi_auth_cipher_test_case_2_oop(void)
5794 return test_kasumi_auth_cipher(
5795 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5799 test_kasumi_auth_cipher_test_case_2_sgl(void)
5801 return test_kasumi_auth_cipher_sgl(
5802 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5806 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5808 return test_kasumi_auth_cipher_sgl(
5809 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5813 test_kasumi_auth_cipher_verify_test_case_1(void)
5815 return test_kasumi_auth_cipher(
5816 &kasumi_test_case_3, IN_PLACE, 1);
5820 test_kasumi_auth_cipher_verify_test_case_2(void)
5822 return test_kasumi_auth_cipher(
5823 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5827 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5829 return test_kasumi_auth_cipher(
5830 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5834 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5836 return test_kasumi_auth_cipher_sgl(
5837 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5841 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5843 return test_kasumi_auth_cipher_sgl(
5844 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5848 test_kasumi_cipher_auth_test_case_1(void)
5850 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5854 test_zuc_encryption_test_case_1(void)
5856 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5860 test_zuc_encryption_test_case_2(void)
5862 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5866 test_zuc_encryption_test_case_3(void)
5868 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5872 test_zuc_encryption_test_case_4(void)
5874 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5878 test_zuc_encryption_test_case_5(void)
5880 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5884 test_zuc_encryption_test_case_6_sgl(void)
5886 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5890 test_zuc_hash_generate_test_case_1(void)
5892 return test_zuc_authentication(&zuc_test_case_auth_1b);
5896 test_zuc_hash_generate_test_case_2(void)
5898 return test_zuc_authentication(&zuc_test_case_auth_90b);
5902 test_zuc_hash_generate_test_case_3(void)
5904 return test_zuc_authentication(&zuc_test_case_auth_577b);
5908 test_zuc_hash_generate_test_case_4(void)
5910 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5914 test_zuc_hash_generate_test_case_5(void)
5916 return test_zuc_authentication(&zuc_test_auth_5670b);
5920 test_zuc_hash_generate_test_case_6(void)
5922 return test_zuc_authentication(&zuc_test_case_auth_128b);
5926 test_zuc_hash_generate_test_case_7(void)
5928 /* This test is not for SW ZUC PMD */
5929 if (gbl_driver_id == rte_cryptodev_driver_id_get(
5930 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
5933 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5937 test_zuc_hash_generate_test_case_8(void)
5939 return test_zuc_authentication(&zuc_test_case_auth_584b);
5943 test_zuc_cipher_auth_test_case_1(void)
5945 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5949 test_zuc_cipher_auth_test_case_2(void)
5951 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5955 test_zuc_auth_cipher_test_case_1(void)
5957 /* This test is not for SW ZUC PMD */
5958 if (gbl_driver_id == rte_cryptodev_driver_id_get(
5959 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
5962 return test_zuc_auth_cipher(
5963 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5967 test_zuc_auth_cipher_test_case_1_oop(void)
5969 return test_zuc_auth_cipher(
5970 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5974 test_zuc_auth_cipher_test_case_1_sgl(void)
5976 return test_zuc_auth_cipher_sgl(
5977 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5981 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
5983 return test_zuc_auth_cipher_sgl(
5984 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5988 test_zuc_auth_cipher_verify_test_case_1(void)
5990 return test_zuc_auth_cipher(
5991 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
5995 test_zuc_auth_cipher_verify_test_case_1_oop(void)
5997 return test_zuc_auth_cipher(
5998 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6002 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6004 return test_zuc_auth_cipher_sgl(
6005 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6009 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6011 return test_zuc_auth_cipher_sgl(
6012 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6016 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6018 uint8_t dev_id = testsuite_params.valid_devs[0];
6020 struct rte_cryptodev_sym_capability_idx cap_idx;
6022 /* Check if device supports particular cipher algorithm */
6023 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6024 cap_idx.algo.cipher = tdata->cipher_algo;
6025 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6028 /* Check if device supports particular hash algorithm */
6029 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6030 cap_idx.algo.auth = tdata->auth_algo;
6031 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6038 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6039 uint8_t op_mode, uint8_t verify)
6041 struct crypto_testsuite_params *ts_params = &testsuite_params;
6042 struct crypto_unittest_params *ut_params = &unittest_params;
6046 uint8_t *plaintext = NULL, *ciphertext = NULL;
6047 unsigned int plaintext_pad_len;
6048 unsigned int plaintext_len;
6049 unsigned int ciphertext_pad_len;
6050 unsigned int ciphertext_len;
6052 struct rte_cryptodev_info dev_info;
6053 struct rte_crypto_op *op;
6055 /* Check if device supports particular algorithms separately */
6056 if (test_mixed_check_if_unsupported(tdata))
6059 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6061 uint64_t feat_flags = dev_info.feature_flags;
6063 if (op_mode == OUT_OF_PLACE) {
6064 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6065 printf("Device doesn't support digest encrypted.\n");
6070 /* Create the session */
6072 retval = create_wireless_algo_cipher_auth_session(
6073 ts_params->valid_devs[0],
6074 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6075 RTE_CRYPTO_AUTH_OP_VERIFY,
6078 tdata->auth_key.data, tdata->auth_key.len,
6079 tdata->auth_iv.len, tdata->digest_enc.len,
6080 tdata->cipher_iv.len);
6082 retval = create_wireless_algo_auth_cipher_session(
6083 ts_params->valid_devs[0],
6084 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6085 RTE_CRYPTO_AUTH_OP_GENERATE,
6088 tdata->auth_key.data, tdata->auth_key.len,
6089 tdata->auth_iv.len, tdata->digest_enc.len,
6090 tdata->cipher_iv.len);
6094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6095 if (op_mode == OUT_OF_PLACE)
6096 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6098 /* clear mbuf payload */
6099 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6100 rte_pktmbuf_tailroom(ut_params->ibuf));
6101 if (op_mode == OUT_OF_PLACE)
6102 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6103 rte_pktmbuf_tailroom(ut_params->obuf));
6105 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6106 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6107 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6111 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6112 ciphertext_pad_len);
6113 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6114 if (op_mode == OUT_OF_PLACE)
6115 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6116 debug_hexdump(stdout, "ciphertext:", ciphertext,
6119 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6121 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6122 if (op_mode == OUT_OF_PLACE)
6123 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6124 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6127 /* Create the operation */
6128 retval = create_wireless_algo_auth_cipher_operation(
6129 tdata->digest_enc.data, tdata->digest_enc.len,
6130 tdata->cipher_iv.data, tdata->cipher_iv.len,
6131 tdata->auth_iv.data, tdata->auth_iv.len,
6132 (tdata->digest_enc.offset == 0 ?
6134 : tdata->digest_enc.offset),
6135 tdata->validCipherLen.len_bits,
6136 tdata->cipher.offset_bits,
6137 tdata->validAuthLen.len_bits,
6138 tdata->auth.offset_bits,
6139 op_mode, 0, verify);
6144 op = process_crypto_request(ts_params->valid_devs[0],
6147 /* Check if the op failed because the device doesn't */
6148 /* support this particular combination of algorithms */
6149 if (op == NULL && ut_params->op->status ==
6150 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6151 printf("Device doesn't support this mixed combination. "
6157 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6159 ut_params->obuf = (op_mode == IN_PLACE ?
6160 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6163 if (ut_params->obuf)
6164 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6167 plaintext = ciphertext +
6168 (tdata->cipher.offset_bits >> 3);
6170 debug_hexdump(stdout, "plaintext:", plaintext,
6171 tdata->plaintext.len_bits >> 3);
6172 debug_hexdump(stdout, "plaintext expected:",
6173 tdata->plaintext.data,
6174 tdata->plaintext.len_bits >> 3);
6176 if (ut_params->obuf)
6177 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6180 ciphertext = plaintext;
6182 debug_hexdump(stdout, "ciphertext:", ciphertext,
6184 debug_hexdump(stdout, "ciphertext expected:",
6185 tdata->ciphertext.data,
6186 tdata->ciphertext.len_bits >> 3);
6188 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6189 + (tdata->digest_enc.offset == 0 ?
6190 plaintext_pad_len : tdata->digest_enc.offset);
6192 debug_hexdump(stdout, "digest:", ut_params->digest,
6193 tdata->digest_enc.len);
6194 debug_hexdump(stdout, "digest expected:",
6195 tdata->digest_enc.data,
6196 tdata->digest_enc.len);
6201 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6203 tdata->plaintext.data,
6204 tdata->plaintext.len_bits >> 3,
6205 "Plaintext data not as expected");
6207 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6209 tdata->ciphertext.data,
6210 tdata->validDataLen.len_bits,
6211 "Ciphertext data not as expected");
6213 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6215 tdata->digest_enc.data,
6216 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6217 "Generated auth tag not as expected");
6220 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6221 "crypto op processing failed");
6227 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6228 uint8_t op_mode, uint8_t verify)
6230 struct crypto_testsuite_params *ts_params = &testsuite_params;
6231 struct crypto_unittest_params *ut_params = &unittest_params;
6235 const uint8_t *plaintext = NULL;
6236 const uint8_t *ciphertext = NULL;
6237 const uint8_t *digest = NULL;
6238 unsigned int plaintext_pad_len;
6239 unsigned int plaintext_len;
6240 unsigned int ciphertext_pad_len;
6241 unsigned int ciphertext_len;
6242 uint8_t buffer[10000];
6243 uint8_t digest_buffer[10000];
6245 struct rte_cryptodev_info dev_info;
6246 struct rte_crypto_op *op;
6248 /* Check if device supports particular algorithms */
6249 if (test_mixed_check_if_unsupported(tdata))
6252 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6254 uint64_t feat_flags = dev_info.feature_flags;
6256 if (op_mode == IN_PLACE) {
6257 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6258 printf("Device doesn't support in-place scatter-gather "
6259 "in both input and output mbufs.\n");
6263 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6264 printf("Device doesn't support out-of-place scatter-gather "
6265 "in both input and output mbufs.\n");
6268 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6269 printf("Device doesn't support digest encrypted.\n");
6274 /* Create the session */
6276 retval = create_wireless_algo_cipher_auth_session(
6277 ts_params->valid_devs[0],
6278 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6279 RTE_CRYPTO_AUTH_OP_VERIFY,
6282 tdata->auth_key.data, tdata->auth_key.len,
6283 tdata->auth_iv.len, tdata->digest_enc.len,
6284 tdata->cipher_iv.len);
6286 retval = create_wireless_algo_auth_cipher_session(
6287 ts_params->valid_devs[0],
6288 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6289 RTE_CRYPTO_AUTH_OP_GENERATE,
6292 tdata->auth_key.data, tdata->auth_key.len,
6293 tdata->auth_iv.len, tdata->digest_enc.len,
6294 tdata->cipher_iv.len);
6298 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6299 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6300 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6301 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6303 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6304 ciphertext_pad_len, 15, 0);
6305 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6306 "Failed to allocate input buffer in mempool");
6308 if (op_mode == OUT_OF_PLACE) {
6309 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6310 plaintext_pad_len, 15, 0);
6311 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6312 "Failed to allocate output buffer in mempool");
6316 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6317 tdata->ciphertext.data);
6318 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6319 ciphertext_len, buffer);
6320 debug_hexdump(stdout, "ciphertext:", ciphertext,
6323 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6324 tdata->plaintext.data);
6325 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6326 plaintext_len, buffer);
6327 debug_hexdump(stdout, "plaintext:", plaintext,
6330 memset(buffer, 0, sizeof(buffer));
6332 /* Create the operation */
6333 retval = create_wireless_algo_auth_cipher_operation(
6334 tdata->digest_enc.data, tdata->digest_enc.len,
6335 tdata->cipher_iv.data, tdata->cipher_iv.len,
6336 tdata->auth_iv.data, tdata->auth_iv.len,
6337 (tdata->digest_enc.offset == 0 ?
6339 : tdata->digest_enc.offset),
6340 tdata->validCipherLen.len_bits,
6341 tdata->cipher.offset_bits,
6342 tdata->validAuthLen.len_bits,
6343 tdata->auth.offset_bits,
6344 op_mode, 1, verify);
6349 op = process_crypto_request(ts_params->valid_devs[0],
6352 /* Check if the op failed because the device doesn't */
6353 /* support this particular combination of algorithms */
6354 if (op == NULL && ut_params->op->status ==
6355 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6356 printf("Device doesn't support this mixed combination. "
6363 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6365 ut_params->obuf = (op_mode == IN_PLACE ?
6366 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6369 if (ut_params->obuf)
6370 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6371 plaintext_len, buffer);
6373 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6374 plaintext_len, buffer);
6376 debug_hexdump(stdout, "plaintext:", plaintext,
6377 (tdata->plaintext.len_bits >> 3) -
6378 tdata->digest_enc.len);
6379 debug_hexdump(stdout, "plaintext expected:",
6380 tdata->plaintext.data,
6381 (tdata->plaintext.len_bits >> 3) -
6382 tdata->digest_enc.len);
6384 if (ut_params->obuf)
6385 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6386 ciphertext_len, buffer);
6388 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6389 ciphertext_len, buffer);
6391 debug_hexdump(stdout, "ciphertext:", ciphertext,
6393 debug_hexdump(stdout, "ciphertext expected:",
6394 tdata->ciphertext.data,
6395 tdata->ciphertext.len_bits >> 3);
6397 if (ut_params->obuf)
6398 digest = rte_pktmbuf_read(ut_params->obuf,
6399 (tdata->digest_enc.offset == 0 ?
6401 tdata->digest_enc.offset),
6402 tdata->digest_enc.len, digest_buffer);
6404 digest = rte_pktmbuf_read(ut_params->ibuf,
6405 (tdata->digest_enc.offset == 0 ?
6407 tdata->digest_enc.offset),
6408 tdata->digest_enc.len, digest_buffer);
6410 debug_hexdump(stdout, "digest:", digest,
6411 tdata->digest_enc.len);
6412 debug_hexdump(stdout, "digest expected:",
6413 tdata->digest_enc.data, tdata->digest_enc.len);
6418 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6420 tdata->plaintext.data,
6421 tdata->plaintext.len_bits >> 3,
6422 "Plaintext data not as expected");
6424 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6426 tdata->ciphertext.data,
6427 tdata->validDataLen.len_bits,
6428 "Ciphertext data not as expected");
6429 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6431 tdata->digest_enc.data,
6432 tdata->digest_enc.len,
6433 "Generated auth tag not as expected");
6436 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6437 "crypto op processing failed");
6442 /** AUTH AES CMAC + CIPHER AES CTR */
6445 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6447 return test_mixed_auth_cipher(
6448 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6452 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6454 return test_mixed_auth_cipher(
6455 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6459 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6461 return test_mixed_auth_cipher_sgl(
6462 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6466 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6468 return test_mixed_auth_cipher_sgl(
6469 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6473 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6475 return test_mixed_auth_cipher(
6476 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6480 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6482 return test_mixed_auth_cipher(
6483 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6487 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6489 return test_mixed_auth_cipher_sgl(
6490 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6494 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6496 return test_mixed_auth_cipher_sgl(
6497 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6500 /** MIXED AUTH + CIPHER */
6503 test_auth_zuc_cipher_snow_test_case_1(void)
6505 return test_mixed_auth_cipher(
6506 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6510 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6512 return test_mixed_auth_cipher(
6513 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6517 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6519 return test_mixed_auth_cipher(
6520 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6524 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6526 return test_mixed_auth_cipher(
6527 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6531 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6533 return test_mixed_auth_cipher(
6534 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6538 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6540 return test_mixed_auth_cipher(
6541 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6545 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6547 return test_mixed_auth_cipher(
6548 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6552 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6554 return test_mixed_auth_cipher(
6555 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6559 test_auth_snow_cipher_zuc_test_case_1(void)
6561 return test_mixed_auth_cipher(
6562 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6566 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6568 return test_mixed_auth_cipher(
6569 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6573 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6575 return test_mixed_auth_cipher(
6576 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6580 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6582 return test_mixed_auth_cipher(
6583 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6587 test_auth_null_cipher_snow_test_case_1(void)
6589 return test_mixed_auth_cipher(
6590 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6594 test_verify_auth_null_cipher_snow_test_case_1(void)
6596 return test_mixed_auth_cipher(
6597 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6601 test_auth_null_cipher_zuc_test_case_1(void)
6603 return test_mixed_auth_cipher(
6604 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6608 test_verify_auth_null_cipher_zuc_test_case_1(void)
6610 return test_mixed_auth_cipher(
6611 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6615 test_auth_snow_cipher_null_test_case_1(void)
6617 return test_mixed_auth_cipher(
6618 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6622 test_verify_auth_snow_cipher_null_test_case_1(void)
6624 return test_mixed_auth_cipher(
6625 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6629 test_auth_zuc_cipher_null_test_case_1(void)
6631 return test_mixed_auth_cipher(
6632 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6636 test_verify_auth_zuc_cipher_null_test_case_1(void)
6638 return test_mixed_auth_cipher(
6639 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6643 test_auth_null_cipher_aes_ctr_test_case_1(void)
6645 return test_mixed_auth_cipher(
6646 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6650 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6652 return test_mixed_auth_cipher(
6653 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6657 test_auth_aes_cmac_cipher_null_test_case_1(void)
6659 return test_mixed_auth_cipher(
6660 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6664 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6666 return test_mixed_auth_cipher(
6667 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6670 /* ***** AEAD algorithm Tests ***** */
6673 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6674 enum rte_crypto_aead_operation op,
6675 const uint8_t *key, const uint8_t key_len,
6676 const uint16_t aad_len, const uint8_t auth_len,
6679 uint8_t aead_key[key_len];
6681 struct crypto_testsuite_params *ts_params = &testsuite_params;
6682 struct crypto_unittest_params *ut_params = &unittest_params;
6684 memcpy(aead_key, key, key_len);
6686 /* Setup AEAD Parameters */
6687 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6688 ut_params->aead_xform.next = NULL;
6689 ut_params->aead_xform.aead.algo = algo;
6690 ut_params->aead_xform.aead.op = op;
6691 ut_params->aead_xform.aead.key.data = aead_key;
6692 ut_params->aead_xform.aead.key.length = key_len;
6693 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6694 ut_params->aead_xform.aead.iv.length = iv_len;
6695 ut_params->aead_xform.aead.digest_length = auth_len;
6696 ut_params->aead_xform.aead.aad_length = aad_len;
6698 debug_hexdump(stdout, "key:", key, key_len);
6700 /* Create Crypto session*/
6701 ut_params->sess = rte_cryptodev_sym_session_create(
6702 ts_params->session_mpool);
6704 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6705 &ut_params->aead_xform,
6706 ts_params->session_priv_mpool);
6708 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6714 create_aead_xform(struct rte_crypto_op *op,
6715 enum rte_crypto_aead_algorithm algo,
6716 enum rte_crypto_aead_operation aead_op,
6717 uint8_t *key, const uint8_t key_len,
6718 const uint8_t aad_len, const uint8_t auth_len,
6721 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6722 "failed to allocate space for crypto transform");
6724 struct rte_crypto_sym_op *sym_op = op->sym;
6726 /* Setup AEAD Parameters */
6727 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6728 sym_op->xform->next = NULL;
6729 sym_op->xform->aead.algo = algo;
6730 sym_op->xform->aead.op = aead_op;
6731 sym_op->xform->aead.key.data = key;
6732 sym_op->xform->aead.key.length = key_len;
6733 sym_op->xform->aead.iv.offset = IV_OFFSET;
6734 sym_op->xform->aead.iv.length = iv_len;
6735 sym_op->xform->aead.digest_length = auth_len;
6736 sym_op->xform->aead.aad_length = aad_len;
6738 debug_hexdump(stdout, "key:", key, key_len);
6744 create_aead_operation(enum rte_crypto_aead_operation op,
6745 const struct aead_test_data *tdata)
6747 struct crypto_testsuite_params *ts_params = &testsuite_params;
6748 struct crypto_unittest_params *ut_params = &unittest_params;
6750 uint8_t *plaintext, *ciphertext;
6751 unsigned int aad_pad_len, plaintext_pad_len;
6753 /* Generate Crypto op data structure */
6754 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6755 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6756 TEST_ASSERT_NOT_NULL(ut_params->op,
6757 "Failed to allocate symmetric crypto operation struct");
6759 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6761 /* Append aad data */
6762 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6763 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6764 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6766 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6767 "no room to append aad");
6769 sym_op->aead.aad.phys_addr =
6770 rte_pktmbuf_iova(ut_params->ibuf);
6771 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6772 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6773 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6776 /* Append IV at the end of the crypto operation*/
6777 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6778 uint8_t *, IV_OFFSET);
6780 /* Copy IV 1 byte after the IV pointer, according to the API */
6781 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6782 debug_hexdump(stdout, "iv:", iv_ptr,
6785 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6786 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6788 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6789 "no room to append aad");
6791 sym_op->aead.aad.phys_addr =
6792 rte_pktmbuf_iova(ut_params->ibuf);
6793 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6794 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6797 /* Append IV at the end of the crypto operation*/
6798 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6799 uint8_t *, IV_OFFSET);
6801 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6802 debug_hexdump(stdout, "iv:", iv_ptr,
6806 /* Append plaintext/ciphertext */
6807 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6808 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6809 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6811 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6813 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6814 debug_hexdump(stdout, "plaintext:", plaintext,
6815 tdata->plaintext.len);
6817 if (ut_params->obuf) {
6818 ciphertext = (uint8_t *)rte_pktmbuf_append(
6820 plaintext_pad_len + aad_pad_len);
6821 TEST_ASSERT_NOT_NULL(ciphertext,
6822 "no room to append ciphertext");
6824 memset(ciphertext + aad_pad_len, 0,
6825 tdata->ciphertext.len);
6828 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6829 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6831 TEST_ASSERT_NOT_NULL(ciphertext,
6832 "no room to append ciphertext");
6834 memcpy(ciphertext, tdata->ciphertext.data,
6835 tdata->ciphertext.len);
6836 debug_hexdump(stdout, "ciphertext:", ciphertext,
6837 tdata->ciphertext.len);
6839 if (ut_params->obuf) {
6840 plaintext = (uint8_t *)rte_pktmbuf_append(
6842 plaintext_pad_len + aad_pad_len);
6843 TEST_ASSERT_NOT_NULL(plaintext,
6844 "no room to append plaintext");
6846 memset(plaintext + aad_pad_len, 0,
6847 tdata->plaintext.len);
6851 /* Append digest data */
6852 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6853 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6854 ut_params->obuf ? ut_params->obuf :
6856 tdata->auth_tag.len);
6857 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6858 "no room to append digest");
6859 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6860 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6861 ut_params->obuf ? ut_params->obuf :
6866 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6867 ut_params->ibuf, tdata->auth_tag.len);
6868 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6869 "no room to append digest");
6870 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6872 plaintext_pad_len + aad_pad_len);
6874 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6875 tdata->auth_tag.len);
6876 debug_hexdump(stdout, "digest:",
6877 sym_op->aead.digest.data,
6878 tdata->auth_tag.len);
6881 sym_op->aead.data.length = tdata->plaintext.len;
6882 sym_op->aead.data.offset = aad_pad_len;
6888 test_authenticated_encryption(const struct aead_test_data *tdata)
6890 struct crypto_testsuite_params *ts_params = &testsuite_params;
6891 struct crypto_unittest_params *ut_params = &unittest_params;
6894 uint8_t *ciphertext, *auth_tag;
6895 uint16_t plaintext_pad_len;
6898 /* Verify the capabilities */
6899 struct rte_cryptodev_sym_capability_idx cap_idx;
6900 const struct rte_cryptodev_symmetric_capability *capability;
6901 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6902 cap_idx.algo.aead = tdata->algo;
6903 capability = rte_cryptodev_sym_capability_get(
6904 ts_params->valid_devs[0], &cap_idx);
6905 if (capability == NULL)
6907 if (rte_cryptodev_sym_capability_check_aead(
6908 capability, tdata->key.len, tdata->auth_tag.len,
6909 tdata->aad.len, tdata->iv.len))
6912 /* Create AEAD session */
6913 retval = create_aead_session(ts_params->valid_devs[0],
6915 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6916 tdata->key.data, tdata->key.len,
6917 tdata->aad.len, tdata->auth_tag.len,
6922 if (tdata->aad.len > MBUF_SIZE) {
6923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6924 /* Populate full size of add data */
6925 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6926 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6930 /* clear mbuf payload */
6931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6932 rte_pktmbuf_tailroom(ut_params->ibuf));
6934 /* Create AEAD operation */
6935 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6939 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6941 ut_params->op->sym->m_src = ut_params->ibuf;
6943 /* Process crypto operation */
6944 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6945 ut_params->op), "failed to process sym crypto op");
6947 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6948 "crypto op processing failed");
6950 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6952 if (ut_params->op->sym->m_dst) {
6953 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6955 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6956 uint8_t *, plaintext_pad_len);
6958 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6960 ut_params->op->sym->cipher.data.offset);
6961 auth_tag = ciphertext + plaintext_pad_len;
6964 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6965 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6968 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6970 tdata->ciphertext.data,
6971 tdata->ciphertext.len,
6972 "Ciphertext data not as expected");
6974 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6976 tdata->auth_tag.data,
6977 tdata->auth_tag.len,
6978 "Generated auth tag not as expected");
6984 #ifdef RTE_LIBRTE_SECURITY
6985 /* Basic algorithm run function for async inplace mode.
6986 * Creates a session from input parameters and runs one operation
6987 * on input_vec. Checks the output of the crypto operation against
6991 test_pdcp_proto(int i, int oop,
6992 enum rte_crypto_cipher_operation opc,
6993 enum rte_crypto_auth_operation opa,
6995 unsigned int input_vec_len,
6996 uint8_t *output_vec,
6997 unsigned int output_vec_len)
6999 struct crypto_testsuite_params *ts_params = &testsuite_params;
7000 struct crypto_unittest_params *ut_params = &unittest_params;
7002 int ret = TEST_SUCCESS;
7003 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7004 rte_cryptodev_get_sec_ctx(
7005 ts_params->valid_devs[0]);
7007 /* Verify the capabilities */
7008 struct rte_security_capability_idx sec_cap_idx;
7010 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7011 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7012 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7013 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7016 /* Generate test mbuf data */
7017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7019 /* clear mbuf payload */
7020 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7021 rte_pktmbuf_tailroom(ut_params->ibuf));
7023 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7025 memcpy(plaintext, input_vec, input_vec_len);
7027 /* Out of place support */
7030 * For out-op-place we need to alloc another mbuf
7032 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7033 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7036 /* Set crypto type as IPSEC */
7037 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7039 /* Setup Cipher Parameters */
7040 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7041 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7042 ut_params->cipher_xform.cipher.op = opc;
7043 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7044 ut_params->cipher_xform.cipher.key.length =
7045 pdcp_test_params[i].cipher_key_len;
7046 ut_params->cipher_xform.cipher.iv.length = 0;
7048 /* Setup HMAC Parameters if ICV header is required */
7049 if (pdcp_test_params[i].auth_alg != 0) {
7050 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7051 ut_params->auth_xform.next = NULL;
7052 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7053 ut_params->auth_xform.auth.op = opa;
7054 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7055 ut_params->auth_xform.auth.key.length =
7056 pdcp_test_params[i].auth_key_len;
7058 ut_params->cipher_xform.next = &ut_params->auth_xform;
7060 ut_params->cipher_xform.next = NULL;
7063 struct rte_security_session_conf sess_conf = {
7064 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7065 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7067 .bearer = pdcp_test_bearer[i],
7068 .domain = pdcp_test_params[i].domain,
7069 .pkt_dir = pdcp_test_packet_direction[i],
7070 .sn_size = pdcp_test_data_sn_size[i],
7071 .hfn = pdcp_test_hfn[i],
7072 .hfn_threshold = pdcp_test_hfn_threshold[i],
7074 .crypto_xform = &ut_params->cipher_xform
7077 /* Create security session */
7078 ut_params->sec_session = rte_security_session_create(ctx,
7079 &sess_conf, ts_params->session_priv_mpool);
7081 if (!ut_params->sec_session) {
7082 printf("TestCase %s()-%d line %d failed %s: ",
7083 __func__, i, __LINE__, "Failed to allocate session");
7088 /* Generate crypto op data structure */
7089 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7090 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7091 if (!ut_params->op) {
7092 printf("TestCase %s()-%d line %d failed %s: ",
7093 __func__, i, __LINE__,
7094 "Failed to allocate symmetric crypto operation struct");
7099 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7101 /* set crypto operation source mbuf */
7102 ut_params->op->sym->m_src = ut_params->ibuf;
7104 ut_params->op->sym->m_dst = ut_params->obuf;
7106 /* Process crypto operation */
7107 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7109 printf("TestCase %s()-%d line %d failed %s: ",
7110 __func__, i, __LINE__,
7111 "failed to process sym crypto op");
7116 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7117 printf("TestCase %s()-%d line %d failed %s: ",
7118 __func__, i, __LINE__, "crypto op processing failed");
7124 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7127 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7131 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7132 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7133 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7134 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7140 rte_crypto_op_free(ut_params->op);
7141 ut_params->op = NULL;
7143 if (ut_params->sec_session)
7144 rte_security_session_destroy(ctx, ut_params->sec_session);
7145 ut_params->sec_session = NULL;
7147 rte_pktmbuf_free(ut_params->ibuf);
7148 ut_params->ibuf = NULL;
7150 rte_pktmbuf_free(ut_params->obuf);
7151 ut_params->obuf = NULL;
7158 test_pdcp_proto_SGL(int i, int oop,
7159 enum rte_crypto_cipher_operation opc,
7160 enum rte_crypto_auth_operation opa,
7162 unsigned int input_vec_len,
7163 uint8_t *output_vec,
7164 unsigned int output_vec_len,
7166 uint32_t fragsz_oop)
7168 struct crypto_testsuite_params *ts_params = &testsuite_params;
7169 struct crypto_unittest_params *ut_params = &unittest_params;
7171 struct rte_mbuf *buf, *buf_oop = NULL;
7172 int ret = TEST_SUCCESS;
7176 unsigned int trn_data = 0;
7177 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7178 rte_cryptodev_get_sec_ctx(
7179 ts_params->valid_devs[0]);
7181 /* Verify the capabilities */
7182 struct rte_security_capability_idx sec_cap_idx;
7184 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7185 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7186 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7187 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7190 if (fragsz > input_vec_len)
7191 fragsz = input_vec_len;
7193 uint16_t plaintext_len = fragsz;
7194 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7196 if (fragsz_oop > output_vec_len)
7197 frag_size_oop = output_vec_len;
7200 if (input_vec_len % fragsz != 0) {
7201 if (input_vec_len / fragsz + 1 > 16)
7203 } else if (input_vec_len / fragsz > 16)
7206 /* Out of place support */
7209 * For out-op-place we need to alloc another mbuf
7211 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7212 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7213 buf_oop = ut_params->obuf;
7216 /* Generate test mbuf data */
7217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7219 /* clear mbuf payload */
7220 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7221 rte_pktmbuf_tailroom(ut_params->ibuf));
7223 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7225 memcpy(plaintext, input_vec, plaintext_len);
7226 trn_data += plaintext_len;
7228 buf = ut_params->ibuf;
7231 * Loop until no more fragments
7234 while (trn_data < input_vec_len) {
7236 to_trn = (input_vec_len - trn_data < fragsz) ?
7237 (input_vec_len - trn_data) : fragsz;
7239 to_trn_tbl[ecx++] = to_trn;
7241 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7244 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7245 rte_pktmbuf_tailroom(buf));
7248 if (oop && !fragsz_oop) {
7250 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7251 buf_oop = buf_oop->next;
7252 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7253 0, rte_pktmbuf_tailroom(buf_oop));
7254 rte_pktmbuf_append(buf_oop, to_trn);
7257 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7260 memcpy(plaintext, input_vec + trn_data, to_trn);
7264 ut_params->ibuf->nb_segs = segs;
7267 if (fragsz_oop && oop) {
7271 trn_data = frag_size_oop;
7272 while (trn_data < output_vec_len) {
7275 (output_vec_len - trn_data <
7277 (output_vec_len - trn_data) :
7280 to_trn_tbl[ecx++] = to_trn;
7283 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7284 buf_oop = buf_oop->next;
7285 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7286 0, rte_pktmbuf_tailroom(buf_oop));
7287 rte_pktmbuf_append(buf_oop, to_trn);
7291 ut_params->obuf->nb_segs = segs;
7294 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7296 /* Setup Cipher Parameters */
7297 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7298 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7299 ut_params->cipher_xform.cipher.op = opc;
7300 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7301 ut_params->cipher_xform.cipher.key.length =
7302 pdcp_test_params[i].cipher_key_len;
7303 ut_params->cipher_xform.cipher.iv.length = 0;
7305 /* Setup HMAC Parameters if ICV header is required */
7306 if (pdcp_test_params[i].auth_alg != 0) {
7307 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7308 ut_params->auth_xform.next = NULL;
7309 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7310 ut_params->auth_xform.auth.op = opa;
7311 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7312 ut_params->auth_xform.auth.key.length =
7313 pdcp_test_params[i].auth_key_len;
7315 ut_params->cipher_xform.next = &ut_params->auth_xform;
7317 ut_params->cipher_xform.next = NULL;
7320 struct rte_security_session_conf sess_conf = {
7321 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7322 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7324 .bearer = pdcp_test_bearer[i],
7325 .domain = pdcp_test_params[i].domain,
7326 .pkt_dir = pdcp_test_packet_direction[i],
7327 .sn_size = pdcp_test_data_sn_size[i],
7328 .hfn = pdcp_test_hfn[i],
7329 .hfn_threshold = pdcp_test_hfn_threshold[i],
7331 .crypto_xform = &ut_params->cipher_xform
7334 /* Create security session */
7335 ut_params->sec_session = rte_security_session_create(ctx,
7336 &sess_conf, ts_params->session_priv_mpool);
7338 if (!ut_params->sec_session) {
7339 printf("TestCase %s()-%d line %d failed %s: ",
7340 __func__, i, __LINE__, "Failed to allocate session");
7345 /* Generate crypto op data structure */
7346 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7347 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7348 if (!ut_params->op) {
7349 printf("TestCase %s()-%d line %d failed %s: ",
7350 __func__, i, __LINE__,
7351 "Failed to allocate symmetric crypto operation struct");
7356 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7358 /* set crypto operation source mbuf */
7359 ut_params->op->sym->m_src = ut_params->ibuf;
7361 ut_params->op->sym->m_dst = ut_params->obuf;
7363 /* Process crypto operation */
7364 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7366 printf("TestCase %s()-%d line %d failed %s: ",
7367 __func__, i, __LINE__,
7368 "failed to process sym crypto op");
7373 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7374 printf("TestCase %s()-%d line %d failed %s: ",
7375 __func__, i, __LINE__, "crypto op processing failed");
7381 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7384 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7388 fragsz = frag_size_oop;
7389 if (memcmp(ciphertext, output_vec, fragsz)) {
7390 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7391 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7392 rte_hexdump(stdout, "reference", output_vec, fragsz);
7397 buf = ut_params->op->sym->m_src->next;
7399 buf = ut_params->op->sym->m_dst->next;
7401 unsigned int off = fragsz;
7405 ciphertext = rte_pktmbuf_mtod(buf,
7407 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7408 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7409 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7410 rte_hexdump(stdout, "reference", output_vec + off,
7415 off += to_trn_tbl[ecx++];
7419 rte_crypto_op_free(ut_params->op);
7420 ut_params->op = NULL;
7422 if (ut_params->sec_session)
7423 rte_security_session_destroy(ctx, ut_params->sec_session);
7424 ut_params->sec_session = NULL;
7426 rte_pktmbuf_free(ut_params->ibuf);
7427 ut_params->ibuf = NULL;
7429 rte_pktmbuf_free(ut_params->obuf);
7430 ut_params->obuf = NULL;
7437 test_pdcp_proto_cplane_encap(int i)
7439 return test_pdcp_proto(i, 0,
7440 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7441 RTE_CRYPTO_AUTH_OP_GENERATE,
7442 pdcp_test_data_in[i],
7443 pdcp_test_data_in_len[i],
7444 pdcp_test_data_out[i],
7445 pdcp_test_data_in_len[i]+4);
7449 test_pdcp_proto_uplane_encap(int i)
7451 return test_pdcp_proto(i, 0,
7452 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7453 RTE_CRYPTO_AUTH_OP_GENERATE,
7454 pdcp_test_data_in[i],
7455 pdcp_test_data_in_len[i],
7456 pdcp_test_data_out[i],
7457 pdcp_test_data_in_len[i]);
7462 test_pdcp_proto_uplane_encap_with_int(int i)
7464 return test_pdcp_proto(i, 0,
7465 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7466 RTE_CRYPTO_AUTH_OP_GENERATE,
7467 pdcp_test_data_in[i],
7468 pdcp_test_data_in_len[i],
7469 pdcp_test_data_out[i],
7470 pdcp_test_data_in_len[i] + 4);
7474 test_pdcp_proto_cplane_decap(int i)
7476 return test_pdcp_proto(i, 0,
7477 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7478 RTE_CRYPTO_AUTH_OP_VERIFY,
7479 pdcp_test_data_out[i],
7480 pdcp_test_data_in_len[i] + 4,
7481 pdcp_test_data_in[i],
7482 pdcp_test_data_in_len[i]);
7486 test_pdcp_proto_uplane_decap(int i)
7488 return test_pdcp_proto(i, 0,
7489 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7490 RTE_CRYPTO_AUTH_OP_VERIFY,
7491 pdcp_test_data_out[i],
7492 pdcp_test_data_in_len[i],
7493 pdcp_test_data_in[i],
7494 pdcp_test_data_in_len[i]);
7498 test_pdcp_proto_uplane_decap_with_int(int i)
7500 return test_pdcp_proto(i, 0,
7501 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7502 RTE_CRYPTO_AUTH_OP_VERIFY,
7503 pdcp_test_data_out[i],
7504 pdcp_test_data_in_len[i] + 4,
7505 pdcp_test_data_in[i],
7506 pdcp_test_data_in_len[i]);
7510 test_PDCP_PROTO_SGL_in_place_32B(void)
7512 /* i can be used for running any PDCP case
7513 * In this case it is uplane 12-bit AES-SNOW DL encap
7515 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7516 return test_pdcp_proto_SGL(i, IN_PLACE,
7517 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7518 RTE_CRYPTO_AUTH_OP_GENERATE,
7519 pdcp_test_data_in[i],
7520 pdcp_test_data_in_len[i],
7521 pdcp_test_data_out[i],
7522 pdcp_test_data_in_len[i]+4,
7526 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7528 /* i can be used for running any PDCP case
7529 * In this case it is uplane 18-bit NULL-NULL DL encap
7531 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7532 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7533 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7534 RTE_CRYPTO_AUTH_OP_GENERATE,
7535 pdcp_test_data_in[i],
7536 pdcp_test_data_in_len[i],
7537 pdcp_test_data_out[i],
7538 pdcp_test_data_in_len[i]+4,
7542 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7544 /* i can be used for running any PDCP case
7545 * In this case it is uplane 18-bit AES DL encap
7547 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7549 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7550 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7551 RTE_CRYPTO_AUTH_OP_GENERATE,
7552 pdcp_test_data_in[i],
7553 pdcp_test_data_in_len[i],
7554 pdcp_test_data_out[i],
7555 pdcp_test_data_in_len[i],
7559 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7561 /* i can be used for running any PDCP case
7562 * In this case it is cplane 12-bit AES-ZUC DL encap
7564 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7565 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7566 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7567 RTE_CRYPTO_AUTH_OP_GENERATE,
7568 pdcp_test_data_in[i],
7569 pdcp_test_data_in_len[i],
7570 pdcp_test_data_out[i],
7571 pdcp_test_data_in_len[i]+4,
7577 test_AES_GCM_authenticated_encryption_test_case_1(void)
7579 return test_authenticated_encryption(&gcm_test_case_1);
7583 test_AES_GCM_authenticated_encryption_test_case_2(void)
7585 return test_authenticated_encryption(&gcm_test_case_2);
7589 test_AES_GCM_authenticated_encryption_test_case_3(void)
7591 return test_authenticated_encryption(&gcm_test_case_3);
7595 test_AES_GCM_authenticated_encryption_test_case_4(void)
7597 return test_authenticated_encryption(&gcm_test_case_4);
7601 test_AES_GCM_authenticated_encryption_test_case_5(void)
7603 return test_authenticated_encryption(&gcm_test_case_5);
7607 test_AES_GCM_authenticated_encryption_test_case_6(void)
7609 return test_authenticated_encryption(&gcm_test_case_6);
7613 test_AES_GCM_authenticated_encryption_test_case_7(void)
7615 return test_authenticated_encryption(&gcm_test_case_7);
7619 test_AES_GCM_authenticated_encryption_test_case_8(void)
7621 return test_authenticated_encryption(&gcm_test_case_8);
7625 test_AES_GCM_auth_encryption_test_case_192_1(void)
7627 return test_authenticated_encryption(&gcm_test_case_192_1);
7631 test_AES_GCM_auth_encryption_test_case_192_2(void)
7633 return test_authenticated_encryption(&gcm_test_case_192_2);
7637 test_AES_GCM_auth_encryption_test_case_192_3(void)
7639 return test_authenticated_encryption(&gcm_test_case_192_3);
7643 test_AES_GCM_auth_encryption_test_case_192_4(void)
7645 return test_authenticated_encryption(&gcm_test_case_192_4);
7649 test_AES_GCM_auth_encryption_test_case_192_5(void)
7651 return test_authenticated_encryption(&gcm_test_case_192_5);
7655 test_AES_GCM_auth_encryption_test_case_192_6(void)
7657 return test_authenticated_encryption(&gcm_test_case_192_6);
7661 test_AES_GCM_auth_encryption_test_case_192_7(void)
7663 return test_authenticated_encryption(&gcm_test_case_192_7);
7667 test_AES_GCM_auth_encryption_test_case_256_1(void)
7669 return test_authenticated_encryption(&gcm_test_case_256_1);
7673 test_AES_GCM_auth_encryption_test_case_256_2(void)
7675 return test_authenticated_encryption(&gcm_test_case_256_2);
7679 test_AES_GCM_auth_encryption_test_case_256_3(void)
7681 return test_authenticated_encryption(&gcm_test_case_256_3);
7685 test_AES_GCM_auth_encryption_test_case_256_4(void)
7687 return test_authenticated_encryption(&gcm_test_case_256_4);
7691 test_AES_GCM_auth_encryption_test_case_256_5(void)
7693 return test_authenticated_encryption(&gcm_test_case_256_5);
7697 test_AES_GCM_auth_encryption_test_case_256_6(void)
7699 return test_authenticated_encryption(&gcm_test_case_256_6);
7703 test_AES_GCM_auth_encryption_test_case_256_7(void)
7705 return test_authenticated_encryption(&gcm_test_case_256_7);
7709 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7711 return test_authenticated_encryption(&gcm_test_case_aad_1);
7715 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7717 return test_authenticated_encryption(&gcm_test_case_aad_2);
7721 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7723 struct aead_test_data tdata;
7726 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7727 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7728 tdata.iv.data[0] += 1;
7729 res = test_authenticated_encryption(&tdata);
7730 if (res == -ENOTSUP)
7732 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7733 return TEST_SUCCESS;
7737 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7739 struct aead_test_data tdata;
7742 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7743 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7744 tdata.plaintext.data[0] += 1;
7745 res = test_authenticated_encryption(&tdata);
7746 if (res == -ENOTSUP)
7748 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7749 return TEST_SUCCESS;
7753 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7755 struct aead_test_data tdata;
7758 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7759 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7760 tdata.ciphertext.data[0] += 1;
7761 res = test_authenticated_encryption(&tdata);
7762 if (res == -ENOTSUP)
7764 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7765 return TEST_SUCCESS;
7769 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7771 struct aead_test_data tdata;
7774 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7775 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7777 res = test_authenticated_encryption(&tdata);
7778 if (res == -ENOTSUP)
7780 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7781 return TEST_SUCCESS;
7785 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7787 struct aead_test_data tdata;
7788 uint8_t aad[gcm_test_case_7.aad.len];
7791 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7792 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7793 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7795 tdata.aad.data = aad;
7796 res = test_authenticated_encryption(&tdata);
7797 if (res == -ENOTSUP)
7799 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7800 return TEST_SUCCESS;
7804 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7806 struct aead_test_data tdata;
7809 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7810 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7811 tdata.auth_tag.data[0] += 1;
7812 res = test_authenticated_encryption(&tdata);
7813 if (res == -ENOTSUP)
7815 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7816 return TEST_SUCCESS;
7820 test_authenticated_decryption(const struct aead_test_data *tdata)
7822 struct crypto_testsuite_params *ts_params = &testsuite_params;
7823 struct crypto_unittest_params *ut_params = &unittest_params;
7829 /* Verify the capabilities */
7830 struct rte_cryptodev_sym_capability_idx cap_idx;
7831 const struct rte_cryptodev_symmetric_capability *capability;
7832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7833 cap_idx.algo.aead = tdata->algo;
7834 capability = rte_cryptodev_sym_capability_get(
7835 ts_params->valid_devs[0], &cap_idx);
7836 if (capability == NULL)
7838 if (rte_cryptodev_sym_capability_check_aead(
7839 capability, tdata->key.len, tdata->auth_tag.len,
7840 tdata->aad.len, tdata->iv.len))
7843 /* Create AEAD session */
7844 retval = create_aead_session(ts_params->valid_devs[0],
7846 RTE_CRYPTO_AEAD_OP_DECRYPT,
7847 tdata->key.data, tdata->key.len,
7848 tdata->aad.len, tdata->auth_tag.len,
7853 /* alloc mbuf and set payload */
7854 if (tdata->aad.len > MBUF_SIZE) {
7855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7856 /* Populate full size of add data */
7857 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7858 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7860 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7863 rte_pktmbuf_tailroom(ut_params->ibuf));
7865 /* Create AEAD operation */
7866 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7872 ut_params->op->sym->m_src = ut_params->ibuf;
7874 /* Process crypto operation */
7875 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7876 ut_params->op), "failed to process sym crypto op");
7878 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7879 "crypto op processing failed");
7881 if (ut_params->op->sym->m_dst)
7882 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7885 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7887 ut_params->op->sym->cipher.data.offset);
7889 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7894 tdata->plaintext.data,
7895 tdata->plaintext.len,
7896 "Plaintext data not as expected");
7898 TEST_ASSERT_EQUAL(ut_params->op->status,
7899 RTE_CRYPTO_OP_STATUS_SUCCESS,
7900 "Authentication failed");
7906 test_AES_GCM_authenticated_decryption_test_case_1(void)
7908 return test_authenticated_decryption(&gcm_test_case_1);
7912 test_AES_GCM_authenticated_decryption_test_case_2(void)
7914 return test_authenticated_decryption(&gcm_test_case_2);
7918 test_AES_GCM_authenticated_decryption_test_case_3(void)
7920 return test_authenticated_decryption(&gcm_test_case_3);
7924 test_AES_GCM_authenticated_decryption_test_case_4(void)
7926 return test_authenticated_decryption(&gcm_test_case_4);
7930 test_AES_GCM_authenticated_decryption_test_case_5(void)
7932 return test_authenticated_decryption(&gcm_test_case_5);
7936 test_AES_GCM_authenticated_decryption_test_case_6(void)
7938 return test_authenticated_decryption(&gcm_test_case_6);
7942 test_AES_GCM_authenticated_decryption_test_case_7(void)
7944 return test_authenticated_decryption(&gcm_test_case_7);
7948 test_AES_GCM_authenticated_decryption_test_case_8(void)
7950 return test_authenticated_decryption(&gcm_test_case_8);
7954 test_AES_GCM_auth_decryption_test_case_192_1(void)
7956 return test_authenticated_decryption(&gcm_test_case_192_1);
7960 test_AES_GCM_auth_decryption_test_case_192_2(void)
7962 return test_authenticated_decryption(&gcm_test_case_192_2);
7966 test_AES_GCM_auth_decryption_test_case_192_3(void)
7968 return test_authenticated_decryption(&gcm_test_case_192_3);
7972 test_AES_GCM_auth_decryption_test_case_192_4(void)
7974 return test_authenticated_decryption(&gcm_test_case_192_4);
7978 test_AES_GCM_auth_decryption_test_case_192_5(void)
7980 return test_authenticated_decryption(&gcm_test_case_192_5);
7984 test_AES_GCM_auth_decryption_test_case_192_6(void)
7986 return test_authenticated_decryption(&gcm_test_case_192_6);
7990 test_AES_GCM_auth_decryption_test_case_192_7(void)
7992 return test_authenticated_decryption(&gcm_test_case_192_7);
7996 test_AES_GCM_auth_decryption_test_case_256_1(void)
7998 return test_authenticated_decryption(&gcm_test_case_256_1);
8002 test_AES_GCM_auth_decryption_test_case_256_2(void)
8004 return test_authenticated_decryption(&gcm_test_case_256_2);
8008 test_AES_GCM_auth_decryption_test_case_256_3(void)
8010 return test_authenticated_decryption(&gcm_test_case_256_3);
8014 test_AES_GCM_auth_decryption_test_case_256_4(void)
8016 return test_authenticated_decryption(&gcm_test_case_256_4);
8020 test_AES_GCM_auth_decryption_test_case_256_5(void)
8022 return test_authenticated_decryption(&gcm_test_case_256_5);
8026 test_AES_GCM_auth_decryption_test_case_256_6(void)
8028 return test_authenticated_decryption(&gcm_test_case_256_6);
8032 test_AES_GCM_auth_decryption_test_case_256_7(void)
8034 return test_authenticated_decryption(&gcm_test_case_256_7);
8038 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8040 return test_authenticated_decryption(&gcm_test_case_aad_1);
8044 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8046 return test_authenticated_decryption(&gcm_test_case_aad_2);
8050 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8052 struct aead_test_data tdata;
8055 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8056 tdata.iv.data[0] += 1;
8057 res = test_authenticated_decryption(&tdata);
8058 if (res == -ENOTSUP)
8060 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8061 return TEST_SUCCESS;
8065 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8067 struct aead_test_data tdata;
8070 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8071 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8072 tdata.plaintext.data[0] += 1;
8073 res = test_authenticated_decryption(&tdata);
8074 if (res == -ENOTSUP)
8076 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8077 return TEST_SUCCESS;
8081 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8083 struct aead_test_data tdata;
8086 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8087 tdata.ciphertext.data[0] += 1;
8088 res = test_authenticated_decryption(&tdata);
8089 if (res == -ENOTSUP)
8091 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8092 return TEST_SUCCESS;
8096 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8098 struct aead_test_data tdata;
8101 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8103 res = test_authenticated_decryption(&tdata);
8104 if (res == -ENOTSUP)
8106 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8107 return TEST_SUCCESS;
8111 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8113 struct aead_test_data tdata;
8114 uint8_t aad[gcm_test_case_7.aad.len];
8117 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8118 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8120 tdata.aad.data = aad;
8121 res = test_authenticated_decryption(&tdata);
8122 if (res == -ENOTSUP)
8124 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8125 return TEST_SUCCESS;
8129 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8131 struct aead_test_data tdata;
8134 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8135 tdata.auth_tag.data[0] += 1;
8136 res = test_authenticated_decryption(&tdata);
8137 if (res == -ENOTSUP)
8139 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8140 return TEST_SUCCESS;
8144 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8146 struct crypto_testsuite_params *ts_params = &testsuite_params;
8147 struct crypto_unittest_params *ut_params = &unittest_params;
8150 uint8_t *ciphertext, *auth_tag;
8151 uint16_t plaintext_pad_len;
8153 /* Verify the capabilities */
8154 struct rte_cryptodev_sym_capability_idx cap_idx;
8155 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8156 cap_idx.algo.aead = tdata->algo;
8157 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8161 /* Create AEAD session */
8162 retval = create_aead_session(ts_params->valid_devs[0],
8164 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8165 tdata->key.data, tdata->key.len,
8166 tdata->aad.len, tdata->auth_tag.len,
8171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8172 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8174 /* clear mbuf payload */
8175 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8176 rte_pktmbuf_tailroom(ut_params->ibuf));
8177 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8178 rte_pktmbuf_tailroom(ut_params->obuf));
8180 /* Create AEAD operation */
8181 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8185 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8187 ut_params->op->sym->m_src = ut_params->ibuf;
8188 ut_params->op->sym->m_dst = ut_params->obuf;
8190 /* Process crypto operation */
8191 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8192 ut_params->op), "failed to process sym crypto op");
8194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8195 "crypto op processing failed");
8197 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8199 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8200 ut_params->op->sym->cipher.data.offset);
8201 auth_tag = ciphertext + plaintext_pad_len;
8203 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8204 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8209 tdata->ciphertext.data,
8210 tdata->ciphertext.len,
8211 "Ciphertext data not as expected");
8213 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8215 tdata->auth_tag.data,
8216 tdata->auth_tag.len,
8217 "Generated auth tag not as expected");
8224 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8226 return test_authenticated_encryption_oop(&gcm_test_case_5);
8230 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8232 struct crypto_testsuite_params *ts_params = &testsuite_params;
8233 struct crypto_unittest_params *ut_params = &unittest_params;
8238 /* Verify the capabilities */
8239 struct rte_cryptodev_sym_capability_idx cap_idx;
8240 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8241 cap_idx.algo.aead = tdata->algo;
8242 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8246 /* Create AEAD session */
8247 retval = create_aead_session(ts_params->valid_devs[0],
8249 RTE_CRYPTO_AEAD_OP_DECRYPT,
8250 tdata->key.data, tdata->key.len,
8251 tdata->aad.len, tdata->auth_tag.len,
8256 /* alloc mbuf and set payload */
8257 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8258 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8260 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8261 rte_pktmbuf_tailroom(ut_params->ibuf));
8262 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8263 rte_pktmbuf_tailroom(ut_params->obuf));
8265 /* Create AEAD operation */
8266 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8270 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8272 ut_params->op->sym->m_src = ut_params->ibuf;
8273 ut_params->op->sym->m_dst = ut_params->obuf;
8275 /* Process crypto operation */
8276 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8277 ut_params->op), "failed to process sym crypto op");
8279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8280 "crypto op processing failed");
8282 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8283 ut_params->op->sym->cipher.data.offset);
8285 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8290 tdata->plaintext.data,
8291 tdata->plaintext.len,
8292 "Plaintext data not as expected");
8294 TEST_ASSERT_EQUAL(ut_params->op->status,
8295 RTE_CRYPTO_OP_STATUS_SUCCESS,
8296 "Authentication failed");
8301 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8303 return test_authenticated_decryption_oop(&gcm_test_case_5);
8307 test_authenticated_encryption_sessionless(
8308 const struct aead_test_data *tdata)
8310 struct crypto_testsuite_params *ts_params = &testsuite_params;
8311 struct crypto_unittest_params *ut_params = &unittest_params;
8314 uint8_t *ciphertext, *auth_tag;
8315 uint16_t plaintext_pad_len;
8316 uint8_t key[tdata->key.len + 1];
8318 /* This test is for AESNI MB and AESNI GCM PMDs only */
8319 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8320 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8321 (gbl_driver_id != rte_cryptodev_driver_id_get(
8322 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8325 /* Verify the capabilities */
8326 struct rte_cryptodev_sym_capability_idx cap_idx;
8327 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8328 cap_idx.algo.aead = tdata->algo;
8329 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8333 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8335 /* clear mbuf payload */
8336 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8337 rte_pktmbuf_tailroom(ut_params->ibuf));
8339 /* Create AEAD operation */
8340 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8344 /* Create GCM xform */
8345 memcpy(key, tdata->key.data, tdata->key.len);
8346 retval = create_aead_xform(ut_params->op,
8348 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8349 key, tdata->key.len,
8350 tdata->aad.len, tdata->auth_tag.len,
8355 ut_params->op->sym->m_src = ut_params->ibuf;
8357 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8358 RTE_CRYPTO_OP_SESSIONLESS,
8359 "crypto op session type not sessionless");
8361 /* Process crypto operation */
8362 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8363 ut_params->op), "failed to process sym crypto op");
8365 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8367 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8368 "crypto op status not success");
8370 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8372 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8373 ut_params->op->sym->cipher.data.offset);
8374 auth_tag = ciphertext + plaintext_pad_len;
8376 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8377 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8380 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8382 tdata->ciphertext.data,
8383 tdata->ciphertext.len,
8384 "Ciphertext data not as expected");
8386 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8388 tdata->auth_tag.data,
8389 tdata->auth_tag.len,
8390 "Generated auth tag not as expected");
8397 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8399 return test_authenticated_encryption_sessionless(
8404 test_authenticated_decryption_sessionless(
8405 const struct aead_test_data *tdata)
8407 struct crypto_testsuite_params *ts_params = &testsuite_params;
8408 struct crypto_unittest_params *ut_params = &unittest_params;
8412 uint8_t key[tdata->key.len + 1];
8414 /* This test is for AESNI MB and AESNI GCM PMDs only */
8415 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8416 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8417 (gbl_driver_id != rte_cryptodev_driver_id_get(
8418 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8421 /* Verify the capabilities */
8422 struct rte_cryptodev_sym_capability_idx cap_idx;
8423 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8424 cap_idx.algo.aead = tdata->algo;
8425 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8429 /* alloc mbuf and set payload */
8430 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8432 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8433 rte_pktmbuf_tailroom(ut_params->ibuf));
8435 /* Create AEAD operation */
8436 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8440 /* Create AEAD xform */
8441 memcpy(key, tdata->key.data, tdata->key.len);
8442 retval = create_aead_xform(ut_params->op,
8444 RTE_CRYPTO_AEAD_OP_DECRYPT,
8445 key, tdata->key.len,
8446 tdata->aad.len, tdata->auth_tag.len,
8451 ut_params->op->sym->m_src = ut_params->ibuf;
8453 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8454 RTE_CRYPTO_OP_SESSIONLESS,
8455 "crypto op session type not sessionless");
8457 /* Process crypto operation */
8458 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8459 ut_params->op), "failed to process sym crypto op");
8461 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8463 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8464 "crypto op status not success");
8466 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8467 ut_params->op->sym->cipher.data.offset);
8469 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8472 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8474 tdata->plaintext.data,
8475 tdata->plaintext.len,
8476 "Plaintext data not as expected");
8478 TEST_ASSERT_EQUAL(ut_params->op->status,
8479 RTE_CRYPTO_OP_STATUS_SUCCESS,
8480 "Authentication failed");
8485 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8487 return test_authenticated_decryption_sessionless(
8492 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8494 return test_authenticated_encryption(&ccm_test_case_128_1);
8498 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8500 return test_authenticated_encryption(&ccm_test_case_128_2);
8504 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8506 return test_authenticated_encryption(&ccm_test_case_128_3);
8510 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8512 return test_authenticated_decryption(&ccm_test_case_128_1);
8516 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8518 return test_authenticated_decryption(&ccm_test_case_128_2);
8522 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8524 return test_authenticated_decryption(&ccm_test_case_128_3);
8528 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8530 return test_authenticated_encryption(&ccm_test_case_192_1);
8534 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8536 return test_authenticated_encryption(&ccm_test_case_192_2);
8540 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8542 return test_authenticated_encryption(&ccm_test_case_192_3);
8546 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8548 return test_authenticated_decryption(&ccm_test_case_192_1);
8552 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8554 return test_authenticated_decryption(&ccm_test_case_192_2);
8558 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8560 return test_authenticated_decryption(&ccm_test_case_192_3);
8564 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8566 return test_authenticated_encryption(&ccm_test_case_256_1);
8570 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8572 return test_authenticated_encryption(&ccm_test_case_256_2);
8576 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8578 return test_authenticated_encryption(&ccm_test_case_256_3);
8582 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8584 return test_authenticated_decryption(&ccm_test_case_256_1);
8588 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8590 return test_authenticated_decryption(&ccm_test_case_256_2);
8594 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8596 return test_authenticated_decryption(&ccm_test_case_256_3);
8602 struct crypto_testsuite_params *ts_params = &testsuite_params;
8603 struct rte_cryptodev_stats stats;
8604 struct rte_cryptodev *dev;
8605 cryptodev_stats_get_t temp_pfn;
8607 /* Verify the capabilities */
8608 struct rte_cryptodev_sym_capability_idx cap_idx;
8609 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8610 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8611 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8614 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8615 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8616 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8620 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8621 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8622 &stats) == -ENODEV),
8623 "rte_cryptodev_stats_get invalid dev failed");
8624 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8625 "rte_cryptodev_stats_get invalid Param failed");
8626 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8627 temp_pfn = dev->dev_ops->stats_get;
8628 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8629 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8631 "rte_cryptodev_stats_get invalid Param failed");
8632 dev->dev_ops->stats_get = temp_pfn;
8634 /* Test expected values */
8636 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8638 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8640 "rte_cryptodev_stats_get failed");
8641 TEST_ASSERT((stats.enqueued_count == 1),
8642 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8643 TEST_ASSERT((stats.dequeued_count == 1),
8644 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8645 TEST_ASSERT((stats.enqueue_err_count == 0),
8646 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8647 TEST_ASSERT((stats.dequeue_err_count == 0),
8648 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8650 /* invalid device but should ignore and not reset device stats*/
8651 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8652 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8654 "rte_cryptodev_stats_get failed");
8655 TEST_ASSERT((stats.enqueued_count == 1),
8656 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8658 /* check that a valid reset clears stats */
8659 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8660 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8662 "rte_cryptodev_stats_get failed");
8663 TEST_ASSERT((stats.enqueued_count == 0),
8664 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8665 TEST_ASSERT((stats.dequeued_count == 0),
8666 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8668 return TEST_SUCCESS;
8671 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8672 struct crypto_unittest_params *ut_params,
8673 enum rte_crypto_auth_operation op,
8674 const struct HMAC_MD5_vector *test_case)
8678 memcpy(key, test_case->key.data, test_case->key.len);
8680 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8681 ut_params->auth_xform.next = NULL;
8682 ut_params->auth_xform.auth.op = op;
8684 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8686 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8687 ut_params->auth_xform.auth.key.length = test_case->key.len;
8688 ut_params->auth_xform.auth.key.data = key;
8690 ut_params->sess = rte_cryptodev_sym_session_create(
8691 ts_params->session_mpool);
8693 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8694 ut_params->sess, &ut_params->auth_xform,
8695 ts_params->session_priv_mpool);
8697 if (ut_params->sess == NULL)
8700 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8702 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8703 rte_pktmbuf_tailroom(ut_params->ibuf));
8708 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8709 const struct HMAC_MD5_vector *test_case,
8710 uint8_t **plaintext)
8712 uint16_t plaintext_pad_len;
8714 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8716 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8719 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8721 memcpy(*plaintext, test_case->plaintext.data,
8722 test_case->plaintext.len);
8724 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8725 ut_params->ibuf, MD5_DIGEST_LEN);
8726 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8727 "no room to append digest");
8728 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8729 ut_params->ibuf, plaintext_pad_len);
8731 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8732 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8733 test_case->auth_tag.len);
8736 sym_op->auth.data.offset = 0;
8737 sym_op->auth.data.length = test_case->plaintext.len;
8739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8740 ut_params->op->sym->m_src = ut_params->ibuf;
8746 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8748 uint16_t plaintext_pad_len;
8749 uint8_t *plaintext, *auth_tag;
8751 struct crypto_testsuite_params *ts_params = &testsuite_params;
8752 struct crypto_unittest_params *ut_params = &unittest_params;
8754 /* Verify the capabilities */
8755 struct rte_cryptodev_sym_capability_idx cap_idx;
8756 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8757 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8758 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8762 if (MD5_HMAC_create_session(ts_params, ut_params,
8763 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8766 /* Generate Crypto op data structure */
8767 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8768 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8769 TEST_ASSERT_NOT_NULL(ut_params->op,
8770 "Failed to allocate symmetric crypto operation struct");
8772 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8775 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8778 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8779 ut_params->op), "failed to process sym crypto op");
8781 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8782 "crypto op processing failed");
8784 if (ut_params->op->sym->m_dst) {
8785 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8786 uint8_t *, plaintext_pad_len);
8788 auth_tag = plaintext + plaintext_pad_len;
8791 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8793 test_case->auth_tag.data,
8794 test_case->auth_tag.len,
8795 "HMAC_MD5 generated tag not as expected");
8797 return TEST_SUCCESS;
8801 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8805 struct crypto_testsuite_params *ts_params = &testsuite_params;
8806 struct crypto_unittest_params *ut_params = &unittest_params;
8808 /* Verify the capabilities */
8809 struct rte_cryptodev_sym_capability_idx cap_idx;
8810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8811 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8812 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8816 if (MD5_HMAC_create_session(ts_params, ut_params,
8817 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8821 /* Generate Crypto op data structure */
8822 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8823 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8824 TEST_ASSERT_NOT_NULL(ut_params->op,
8825 "Failed to allocate symmetric crypto operation struct");
8827 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8830 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8831 ut_params->op), "failed to process sym crypto op");
8833 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8834 "HMAC_MD5 crypto op processing failed");
8836 return TEST_SUCCESS;
8840 test_MD5_HMAC_generate_case_1(void)
8842 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8846 test_MD5_HMAC_verify_case_1(void)
8848 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8852 test_MD5_HMAC_generate_case_2(void)
8854 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8858 test_MD5_HMAC_verify_case_2(void)
8860 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8864 test_multi_session(void)
8866 struct crypto_testsuite_params *ts_params = &testsuite_params;
8867 struct crypto_unittest_params *ut_params = &unittest_params;
8869 struct rte_cryptodev_info dev_info;
8870 struct rte_cryptodev_sym_session **sessions;
8874 /* Verify the capabilities */
8875 struct rte_cryptodev_sym_capability_idx cap_idx;
8876 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8877 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
8878 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8881 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8882 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8883 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8887 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8888 aes_cbc_key, hmac_sha512_key);
8891 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8893 sessions = rte_malloc(NULL,
8894 (sizeof(struct rte_cryptodev_sym_session *) *
8895 MAX_NB_SESSIONS) + 1, 0);
8897 /* Create multiple crypto sessions*/
8898 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8900 sessions[i] = rte_cryptodev_sym_session_create(
8901 ts_params->session_mpool);
8903 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8904 sessions[i], &ut_params->auth_xform,
8905 ts_params->session_priv_mpool);
8906 TEST_ASSERT_NOT_NULL(sessions[i],
8907 "Session creation failed at session number %u",
8910 /* Attempt to send a request on each session */
8911 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8915 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8916 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8918 "Failed to perform decrypt on request number %u.", i);
8919 /* free crypto operation structure */
8921 rte_crypto_op_free(ut_params->op);
8924 * free mbuf - both obuf and ibuf are usually the same,
8925 * so check if they point at the same address is necessary,
8926 * to avoid freeing the mbuf twice.
8928 if (ut_params->obuf) {
8929 rte_pktmbuf_free(ut_params->obuf);
8930 if (ut_params->ibuf == ut_params->obuf)
8931 ut_params->ibuf = 0;
8932 ut_params->obuf = 0;
8934 if (ut_params->ibuf) {
8935 rte_pktmbuf_free(ut_params->ibuf);
8936 ut_params->ibuf = 0;
8940 /* Next session create should fail */
8941 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8942 sessions[i], &ut_params->auth_xform,
8943 ts_params->session_priv_mpool);
8944 TEST_ASSERT_NULL(sessions[i],
8945 "Session creation succeeded unexpectedly!");
8947 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8948 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8950 rte_cryptodev_sym_session_free(sessions[i]);
8955 return TEST_SUCCESS;
8958 struct multi_session_params {
8959 struct crypto_unittest_params ut_params;
8960 uint8_t *cipher_key;
8962 const uint8_t *cipher;
8963 const uint8_t *digest;
8967 #define MB_SESSION_NUMBER 3
8970 test_multi_session_random_usage(void)
8972 struct crypto_testsuite_params *ts_params = &testsuite_params;
8973 struct rte_cryptodev_info dev_info;
8974 struct rte_cryptodev_sym_session **sessions;
8976 struct multi_session_params ut_paramz[] = {
8979 .cipher_key = ms_aes_cbc_key0,
8980 .hmac_key = ms_hmac_key0,
8981 .cipher = ms_aes_cbc_cipher0,
8982 .digest = ms_hmac_digest0,
8983 .iv = ms_aes_cbc_iv0
8986 .cipher_key = ms_aes_cbc_key1,
8987 .hmac_key = ms_hmac_key1,
8988 .cipher = ms_aes_cbc_cipher1,
8989 .digest = ms_hmac_digest1,
8990 .iv = ms_aes_cbc_iv1
8993 .cipher_key = ms_aes_cbc_key2,
8994 .hmac_key = ms_hmac_key2,
8995 .cipher = ms_aes_cbc_cipher2,
8996 .digest = ms_hmac_digest2,
8997 .iv = ms_aes_cbc_iv2
9002 /* Verify the capabilities */
9003 struct rte_cryptodev_sym_capability_idx cap_idx;
9004 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9005 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9006 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9009 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9010 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9011 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9015 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9017 sessions = rte_malloc(NULL,
9018 (sizeof(struct rte_cryptodev_sym_session *)
9019 * MAX_NB_SESSIONS) + 1, 0);
9021 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9022 sessions[i] = rte_cryptodev_sym_session_create(
9023 ts_params->session_mpool);
9025 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9026 sizeof(struct crypto_unittest_params));
9028 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9029 &ut_paramz[i].ut_params,
9030 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9032 /* Create multiple crypto sessions*/
9033 rte_cryptodev_sym_session_init(
9034 ts_params->valid_devs[0],
9036 &ut_paramz[i].ut_params.auth_xform,
9037 ts_params->session_priv_mpool);
9039 TEST_ASSERT_NOT_NULL(sessions[i],
9040 "Session creation failed at session number %u",
9046 for (i = 0; i < 40000; i++) {
9048 j = rand() % MB_SESSION_NUMBER;
9050 TEST_ASSERT_SUCCESS(
9051 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9053 &ut_paramz[j].ut_params,
9054 ts_params, ut_paramz[j].cipher,
9055 ut_paramz[j].digest,
9057 "Failed to perform decrypt on request number %u.", i);
9059 if (ut_paramz[j].ut_params.op)
9060 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9063 * free mbuf - both obuf and ibuf are usually the same,
9064 * so check if they point at the same address is necessary,
9065 * to avoid freeing the mbuf twice.
9067 if (ut_paramz[j].ut_params.obuf) {
9068 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9069 if (ut_paramz[j].ut_params.ibuf
9070 == ut_paramz[j].ut_params.obuf)
9071 ut_paramz[j].ut_params.ibuf = 0;
9072 ut_paramz[j].ut_params.obuf = 0;
9074 if (ut_paramz[j].ut_params.ibuf) {
9075 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9076 ut_paramz[j].ut_params.ibuf = 0;
9080 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9081 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9083 rte_cryptodev_sym_session_free(sessions[i]);
9088 return TEST_SUCCESS;
9092 test_null_cipher_only_operation(void)
9094 struct crypto_testsuite_params *ts_params = &testsuite_params;
9095 struct crypto_unittest_params *ut_params = &unittest_params;
9097 /* Verify the capabilities */
9098 struct rte_cryptodev_sym_capability_idx cap_idx;
9099 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9100 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9101 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9105 /* Generate test mbuf data and space for digest */
9106 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9107 catch_22_quote, QUOTE_512_BYTES, 0);
9109 /* Setup Cipher Parameters */
9110 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9111 ut_params->cipher_xform.next = NULL;
9113 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9114 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9116 ut_params->sess = rte_cryptodev_sym_session_create(
9117 ts_params->session_mpool);
9119 /* Create Crypto session*/
9120 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9122 &ut_params->cipher_xform,
9123 ts_params->session_priv_mpool);
9124 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9126 /* Generate Crypto op data structure */
9127 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9128 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9129 TEST_ASSERT_NOT_NULL(ut_params->op,
9130 "Failed to allocate symmetric crypto operation struct");
9132 /* Set crypto operation data parameters */
9133 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9135 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9137 /* set crypto operation source mbuf */
9138 sym_op->m_src = ut_params->ibuf;
9140 sym_op->cipher.data.offset = 0;
9141 sym_op->cipher.data.length = QUOTE_512_BYTES;
9143 /* Process crypto operation */
9144 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9146 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9148 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9149 "crypto operation processing failed");
9152 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9153 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9156 "Ciphertext data not as expected");
9158 return TEST_SUCCESS;
9160 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9161 0xab, 0xab, 0xab, 0xab,
9162 0xab, 0xab, 0xab, 0xab,
9163 0xab, 0xab, 0xab, 0xab};
9165 test_null_auth_only_operation(void)
9167 struct crypto_testsuite_params *ts_params = &testsuite_params;
9168 struct crypto_unittest_params *ut_params = &unittest_params;
9171 /* Verify the capabilities */
9172 struct rte_cryptodev_sym_capability_idx cap_idx;
9173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9174 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9175 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9179 /* Generate test mbuf data and space for digest */
9180 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9181 catch_22_quote, QUOTE_512_BYTES, 0);
9183 /* create a pointer for digest, but don't expect anything to be written
9184 * here in a NULL auth algo so no mbuf append done.
9186 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9188 /* prefill the memory pointed to by digest */
9189 memcpy(digest, orig_data, sizeof(orig_data));
9191 /* Setup HMAC Parameters */
9192 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9193 ut_params->auth_xform.next = NULL;
9195 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9196 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9198 ut_params->sess = rte_cryptodev_sym_session_create(
9199 ts_params->session_mpool);
9201 /* Create Crypto session*/
9202 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9203 ut_params->sess, &ut_params->auth_xform,
9204 ts_params->session_priv_mpool);
9205 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9207 /* Generate Crypto op data structure */
9208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9210 TEST_ASSERT_NOT_NULL(ut_params->op,
9211 "Failed to allocate symmetric crypto operation struct");
9213 /* Set crypto operation data parameters */
9214 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9216 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9218 sym_op->m_src = ut_params->ibuf;
9220 sym_op->auth.data.offset = 0;
9221 sym_op->auth.data.length = QUOTE_512_BYTES;
9222 sym_op->auth.digest.data = digest;
9223 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9226 /* Process crypto operation */
9227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9229 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9231 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9232 "crypto operation processing failed");
9233 /* Make sure memory pointed to by digest hasn't been overwritten */
9234 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9238 "Memory at digest ptr overwritten unexpectedly");
9240 return TEST_SUCCESS;
9245 test_null_cipher_auth_operation(void)
9247 struct crypto_testsuite_params *ts_params = &testsuite_params;
9248 struct crypto_unittest_params *ut_params = &unittest_params;
9251 /* Verify the capabilities */
9252 struct rte_cryptodev_sym_capability_idx cap_idx;
9253 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9254 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9255 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9258 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9259 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9260 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9264 /* Generate test mbuf data and space for digest */
9265 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9266 catch_22_quote, QUOTE_512_BYTES, 0);
9268 /* create a pointer for digest, but don't expect anything to be written
9269 * here in a NULL auth algo so no mbuf append done.
9271 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9273 /* prefill the memory pointed to by digest */
9274 memcpy(digest, orig_data, sizeof(orig_data));
9276 /* Setup Cipher Parameters */
9277 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9278 ut_params->cipher_xform.next = &ut_params->auth_xform;
9280 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9281 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9283 /* Setup HMAC Parameters */
9284 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9285 ut_params->auth_xform.next = NULL;
9287 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9288 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9290 ut_params->sess = rte_cryptodev_sym_session_create(
9291 ts_params->session_mpool);
9293 /* Create Crypto session*/
9294 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9295 ut_params->sess, &ut_params->cipher_xform,
9296 ts_params->session_priv_mpool);
9297 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9299 /* Generate Crypto op data structure */
9300 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9301 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9302 TEST_ASSERT_NOT_NULL(ut_params->op,
9303 "Failed to allocate symmetric crypto operation struct");
9305 /* Set crypto operation data parameters */
9306 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9308 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9310 sym_op->m_src = ut_params->ibuf;
9312 sym_op->cipher.data.offset = 0;
9313 sym_op->cipher.data.length = QUOTE_512_BYTES;
9315 sym_op->auth.data.offset = 0;
9316 sym_op->auth.data.length = QUOTE_512_BYTES;
9317 sym_op->auth.digest.data = digest;
9318 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9321 /* Process crypto operation */
9322 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9324 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9327 "crypto operation processing failed");
9330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9331 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9334 "Ciphertext data not as expected");
9335 /* Make sure memory pointed to by digest hasn't been overwritten */
9336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9340 "Memory at digest ptr overwritten unexpectedly");
9342 return TEST_SUCCESS;
9346 test_null_auth_cipher_operation(void)
9348 struct crypto_testsuite_params *ts_params = &testsuite_params;
9349 struct crypto_unittest_params *ut_params = &unittest_params;
9352 /* Verify the capabilities */
9353 struct rte_cryptodev_sym_capability_idx cap_idx;
9354 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9355 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9356 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9365 /* Generate test mbuf data */
9366 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9367 catch_22_quote, QUOTE_512_BYTES, 0);
9369 /* create a pointer for digest, but don't expect anything to be written
9370 * here in a NULL auth algo so no mbuf append done.
9372 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9374 /* prefill the memory pointed to by digest */
9375 memcpy(digest, orig_data, sizeof(orig_data));
9377 /* Setup Cipher Parameters */
9378 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9379 ut_params->cipher_xform.next = NULL;
9381 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9382 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9384 /* Setup HMAC Parameters */
9385 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9386 ut_params->auth_xform.next = &ut_params->cipher_xform;
9388 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9389 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9391 ut_params->sess = rte_cryptodev_sym_session_create(
9392 ts_params->session_mpool);
9394 /* Create Crypto session*/
9395 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9396 ut_params->sess, &ut_params->cipher_xform,
9397 ts_params->session_priv_mpool);
9398 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9400 /* Generate Crypto op data structure */
9401 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9402 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9403 TEST_ASSERT_NOT_NULL(ut_params->op,
9404 "Failed to allocate symmetric crypto operation struct");
9406 /* Set crypto operation data parameters */
9407 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9409 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9411 sym_op->m_src = ut_params->ibuf;
9413 sym_op->cipher.data.offset = 0;
9414 sym_op->cipher.data.length = QUOTE_512_BYTES;
9416 sym_op->auth.data.offset = 0;
9417 sym_op->auth.data.length = QUOTE_512_BYTES;
9418 sym_op->auth.digest.data = digest;
9419 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9422 /* Process crypto operation */
9423 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9425 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9427 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9428 "crypto operation processing failed");
9431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9432 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9435 "Ciphertext data not as expected");
9436 /* Make sure memory pointed to by digest hasn't been overwritten */
9437 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9441 "Memory at digest ptr overwritten unexpectedly");
9443 return TEST_SUCCESS;
9448 test_null_invalid_operation(void)
9450 struct crypto_testsuite_params *ts_params = &testsuite_params;
9451 struct crypto_unittest_params *ut_params = &unittest_params;
9454 /* This test is for NULL PMD only */
9455 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9456 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9459 /* Setup Cipher Parameters */
9460 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9461 ut_params->cipher_xform.next = NULL;
9463 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9464 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9466 ut_params->sess = rte_cryptodev_sym_session_create(
9467 ts_params->session_mpool);
9469 /* Create Crypto session*/
9470 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9471 ut_params->sess, &ut_params->cipher_xform,
9472 ts_params->session_priv_mpool);
9473 TEST_ASSERT(ret < 0,
9474 "Session creation succeeded unexpectedly");
9477 /* Setup HMAC Parameters */
9478 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9479 ut_params->auth_xform.next = NULL;
9481 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9482 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9484 ut_params->sess = rte_cryptodev_sym_session_create(
9485 ts_params->session_mpool);
9487 /* Create Crypto session*/
9488 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9489 ut_params->sess, &ut_params->auth_xform,
9490 ts_params->session_priv_mpool);
9491 TEST_ASSERT(ret < 0,
9492 "Session creation succeeded unexpectedly");
9494 return TEST_SUCCESS;
9498 #define NULL_BURST_LENGTH (32)
9501 test_null_burst_operation(void)
9503 struct crypto_testsuite_params *ts_params = &testsuite_params;
9504 struct crypto_unittest_params *ut_params = &unittest_params;
9506 unsigned i, burst_len = NULL_BURST_LENGTH;
9508 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9509 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9511 /* This test is for NULL PMD only */
9512 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9513 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9516 /* Setup Cipher Parameters */
9517 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9518 ut_params->cipher_xform.next = &ut_params->auth_xform;
9520 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9521 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9523 /* Setup HMAC Parameters */
9524 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9525 ut_params->auth_xform.next = NULL;
9527 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9528 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9530 ut_params->sess = rte_cryptodev_sym_session_create(
9531 ts_params->session_mpool);
9533 /* Create Crypto session*/
9534 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9535 ut_params->sess, &ut_params->cipher_xform,
9536 ts_params->session_priv_mpool);
9537 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9539 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9540 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9541 burst_len, "failed to generate burst of crypto ops");
9543 /* Generate an operation for each mbuf in burst */
9544 for (i = 0; i < burst_len; i++) {
9545 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9547 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9549 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9553 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9555 burst[i]->sym->m_src = m;
9558 /* Process crypto operation */
9559 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9560 0, burst, burst_len),
9562 "Error enqueuing burst");
9564 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9565 0, burst_dequeued, burst_len),
9567 "Error dequeuing burst");
9570 for (i = 0; i < burst_len; i++) {
9572 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9573 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9575 "data not as expected");
9577 rte_pktmbuf_free(burst[i]->sym->m_src);
9578 rte_crypto_op_free(burst[i]);
9581 return TEST_SUCCESS;
9585 generate_gmac_large_plaintext(uint8_t *data)
9589 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9590 memcpy(&data[i], &data[0], 32);
9594 create_gmac_operation(enum rte_crypto_auth_operation op,
9595 const struct gmac_test_data *tdata)
9597 struct crypto_testsuite_params *ts_params = &testsuite_params;
9598 struct crypto_unittest_params *ut_params = &unittest_params;
9599 struct rte_crypto_sym_op *sym_op;
9601 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9603 /* Generate Crypto op data structure */
9604 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9605 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9606 TEST_ASSERT_NOT_NULL(ut_params->op,
9607 "Failed to allocate symmetric crypto operation struct");
9609 sym_op = ut_params->op->sym;
9611 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9612 ut_params->ibuf, tdata->gmac_tag.len);
9613 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9614 "no room to append digest");
9616 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9617 ut_params->ibuf, plaintext_pad_len);
9619 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9620 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9621 tdata->gmac_tag.len);
9622 debug_hexdump(stdout, "digest:",
9623 sym_op->auth.digest.data,
9624 tdata->gmac_tag.len);
9627 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9628 uint8_t *, IV_OFFSET);
9630 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9632 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9634 sym_op->cipher.data.length = 0;
9635 sym_op->cipher.data.offset = 0;
9637 sym_op->auth.data.offset = 0;
9638 sym_op->auth.data.length = tdata->plaintext.len;
9643 static int create_gmac_session(uint8_t dev_id,
9644 const struct gmac_test_data *tdata,
9645 enum rte_crypto_auth_operation auth_op)
9647 uint8_t auth_key[tdata->key.len];
9649 struct crypto_testsuite_params *ts_params = &testsuite_params;
9650 struct crypto_unittest_params *ut_params = &unittest_params;
9652 memcpy(auth_key, tdata->key.data, tdata->key.len);
9654 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9655 ut_params->auth_xform.next = NULL;
9657 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9658 ut_params->auth_xform.auth.op = auth_op;
9659 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9660 ut_params->auth_xform.auth.key.length = tdata->key.len;
9661 ut_params->auth_xform.auth.key.data = auth_key;
9662 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9663 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9666 ut_params->sess = rte_cryptodev_sym_session_create(
9667 ts_params->session_mpool);
9669 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9670 &ut_params->auth_xform,
9671 ts_params->session_priv_mpool);
9673 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9679 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9681 struct crypto_testsuite_params *ts_params = &testsuite_params;
9682 struct crypto_unittest_params *ut_params = &unittest_params;
9686 uint8_t *auth_tag, *plaintext;
9687 uint16_t plaintext_pad_len;
9689 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9690 "No GMAC length in the source data");
9692 /* Verify the capabilities */
9693 struct rte_cryptodev_sym_capability_idx cap_idx;
9694 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9695 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9696 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9700 retval = create_gmac_session(ts_params->valid_devs[0],
9701 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9706 if (tdata->plaintext.len > MBUF_SIZE)
9707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9709 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9710 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9711 "Failed to allocate input buffer in mempool");
9713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9714 rte_pktmbuf_tailroom(ut_params->ibuf));
9716 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9718 * Runtime generate the large plain text instead of use hard code
9719 * plain text vector. It is done to avoid create huge source file
9720 * with the test vector.
9722 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9723 generate_gmac_large_plaintext(tdata->plaintext.data);
9725 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9727 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9729 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9730 debug_hexdump(stdout, "plaintext:", plaintext,
9731 tdata->plaintext.len);
9733 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9741 ut_params->op->sym->m_src = ut_params->ibuf;
9743 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9744 ut_params->op), "failed to process sym crypto op");
9746 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9747 "crypto op processing failed");
9749 if (ut_params->op->sym->m_dst) {
9750 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9751 uint8_t *, plaintext_pad_len);
9753 auth_tag = plaintext + plaintext_pad_len;
9756 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9758 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9760 tdata->gmac_tag.data,
9761 tdata->gmac_tag.len,
9762 "GMAC Generated auth tag not as expected");
9768 test_AES_GMAC_authentication_test_case_1(void)
9770 return test_AES_GMAC_authentication(&gmac_test_case_1);
9774 test_AES_GMAC_authentication_test_case_2(void)
9776 return test_AES_GMAC_authentication(&gmac_test_case_2);
9780 test_AES_GMAC_authentication_test_case_3(void)
9782 return test_AES_GMAC_authentication(&gmac_test_case_3);
9786 test_AES_GMAC_authentication_test_case_4(void)
9788 return test_AES_GMAC_authentication(&gmac_test_case_4);
9792 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9794 struct crypto_testsuite_params *ts_params = &testsuite_params;
9795 struct crypto_unittest_params *ut_params = &unittest_params;
9797 uint32_t plaintext_pad_len;
9800 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9801 "No GMAC length in the source data");
9803 /* Verify the capabilities */
9804 struct rte_cryptodev_sym_capability_idx cap_idx;
9805 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9806 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9811 retval = create_gmac_session(ts_params->valid_devs[0],
9812 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9817 if (tdata->plaintext.len > MBUF_SIZE)
9818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9820 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9821 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9822 "Failed to allocate input buffer in mempool");
9824 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9825 rte_pktmbuf_tailroom(ut_params->ibuf));
9827 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9830 * Runtime generate the large plain text instead of use hard code
9831 * plain text vector. It is done to avoid create huge source file
9832 * with the test vector.
9834 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9835 generate_gmac_large_plaintext(tdata->plaintext.data);
9837 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9839 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9841 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9842 debug_hexdump(stdout, "plaintext:", plaintext,
9843 tdata->plaintext.len);
9845 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9853 ut_params->op->sym->m_src = ut_params->ibuf;
9855 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9856 ut_params->op), "failed to process sym crypto op");
9858 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9859 "crypto op processing failed");
9866 test_AES_GMAC_authentication_verify_test_case_1(void)
9868 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9872 test_AES_GMAC_authentication_verify_test_case_2(void)
9874 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9878 test_AES_GMAC_authentication_verify_test_case_3(void)
9880 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
9884 test_AES_GMAC_authentication_verify_test_case_4(void)
9886 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
9889 struct test_crypto_vector {
9890 enum rte_crypto_cipher_algorithm crypto_algo;
9891 unsigned int cipher_offset;
9892 unsigned int cipher_len;
9905 const uint8_t *data;
9910 const uint8_t *data;
9914 enum rte_crypto_auth_algorithm auth_algo;
9915 unsigned int auth_offset;
9923 const uint8_t *data;
9933 static const struct test_crypto_vector
9934 hmac_sha1_test_crypto_vector = {
9935 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9937 .data = plaintext_hash,
9942 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9943 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9944 0xDE, 0xF4, 0xDE, 0xAD
9950 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9951 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9952 0x3F, 0x91, 0x64, 0x59
9958 static const struct test_crypto_vector
9959 aes128_gmac_test_vector = {
9960 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9962 .data = plaintext_hash,
9967 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9968 0x08, 0x09, 0x0A, 0x0B
9974 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9975 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9981 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9982 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9988 static const struct test_crypto_vector
9989 aes128cbc_hmac_sha1_test_vector = {
9990 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9995 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9996 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10002 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10003 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10008 .data = plaintext_hash,
10012 .data = ciphertext512_aes128cbc,
10015 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10019 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10020 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10021 0xDE, 0xF4, 0xDE, 0xAD
10027 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10028 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10029 0x18, 0x8C, 0x1D, 0x32
10035 static const struct test_crypto_vector
10036 aes128cbc_hmac_sha1_aad_test_vector = {
10037 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10038 .cipher_offset = 12,
10042 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10043 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10049 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10050 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10055 .data = plaintext_hash,
10059 .data = ciphertext512_aes128cbc_aad,
10062 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10066 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10067 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10068 0xDE, 0xF4, 0xDE, 0xAD
10074 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10075 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10076 0x62, 0x8D, 0x62, 0x65
10083 data_corruption(uint8_t *data)
10089 tag_corruption(uint8_t *data, unsigned int tag_offset)
10091 data[tag_offset] += 1;
10095 create_auth_session(struct crypto_unittest_params *ut_params,
10097 const struct test_crypto_vector *reference,
10098 enum rte_crypto_auth_operation auth_op)
10100 struct crypto_testsuite_params *ts_params = &testsuite_params;
10101 uint8_t auth_key[reference->auth_key.len + 1];
10103 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10105 /* Setup Authentication Parameters */
10106 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10107 ut_params->auth_xform.auth.op = auth_op;
10108 ut_params->auth_xform.next = NULL;
10109 ut_params->auth_xform.auth.algo = reference->auth_algo;
10110 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10111 ut_params->auth_xform.auth.key.data = auth_key;
10112 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10114 /* Create Crypto session*/
10115 ut_params->sess = rte_cryptodev_sym_session_create(
10116 ts_params->session_mpool);
10118 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10119 &ut_params->auth_xform,
10120 ts_params->session_priv_mpool);
10122 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10128 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10130 const struct test_crypto_vector *reference,
10131 enum rte_crypto_auth_operation auth_op,
10132 enum rte_crypto_cipher_operation cipher_op)
10134 struct crypto_testsuite_params *ts_params = &testsuite_params;
10135 uint8_t cipher_key[reference->cipher_key.len + 1];
10136 uint8_t auth_key[reference->auth_key.len + 1];
10138 memcpy(cipher_key, reference->cipher_key.data,
10139 reference->cipher_key.len);
10140 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10142 /* Setup Authentication Parameters */
10143 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10144 ut_params->auth_xform.auth.op = auth_op;
10145 ut_params->auth_xform.auth.algo = reference->auth_algo;
10146 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10147 ut_params->auth_xform.auth.key.data = auth_key;
10148 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10150 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10151 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10152 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10154 ut_params->auth_xform.next = &ut_params->cipher_xform;
10156 /* Setup Cipher Parameters */
10157 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10158 ut_params->cipher_xform.next = NULL;
10159 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10160 ut_params->cipher_xform.cipher.op = cipher_op;
10161 ut_params->cipher_xform.cipher.key.data = cipher_key;
10162 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10163 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10164 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10167 /* Create Crypto session*/
10168 ut_params->sess = rte_cryptodev_sym_session_create(
10169 ts_params->session_mpool);
10171 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10172 &ut_params->auth_xform,
10173 ts_params->session_priv_mpool);
10175 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10181 create_auth_operation(struct crypto_testsuite_params *ts_params,
10182 struct crypto_unittest_params *ut_params,
10183 const struct test_crypto_vector *reference,
10184 unsigned int auth_generate)
10186 /* Generate Crypto op data structure */
10187 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10188 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10189 TEST_ASSERT_NOT_NULL(ut_params->op,
10190 "Failed to allocate pktmbuf offload");
10192 /* Set crypto operation data parameters */
10193 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10195 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10197 /* set crypto operation source mbuf */
10198 sym_op->m_src = ut_params->ibuf;
10201 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10202 ut_params->ibuf, reference->digest.len);
10204 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10205 "no room to append auth tag");
10207 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10208 ut_params->ibuf, reference->plaintext.len);
10211 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10213 memcpy(sym_op->auth.digest.data,
10214 reference->digest.data,
10215 reference->digest.len);
10217 debug_hexdump(stdout, "digest:",
10218 sym_op->auth.digest.data,
10219 reference->digest.len);
10221 sym_op->auth.data.length = reference->plaintext.len;
10222 sym_op->auth.data.offset = 0;
10228 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10229 struct crypto_unittest_params *ut_params,
10230 const struct test_crypto_vector *reference,
10231 unsigned int auth_generate)
10233 /* Generate Crypto op data structure */
10234 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10235 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10236 TEST_ASSERT_NOT_NULL(ut_params->op,
10237 "Failed to allocate pktmbuf offload");
10239 /* Set crypto operation data parameters */
10240 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10242 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10244 /* set crypto operation source mbuf */
10245 sym_op->m_src = ut_params->ibuf;
10248 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10249 ut_params->ibuf, reference->digest.len);
10251 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10252 "no room to append auth tag");
10254 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10255 ut_params->ibuf, reference->ciphertext.len);
10258 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10260 memcpy(sym_op->auth.digest.data,
10261 reference->digest.data,
10262 reference->digest.len);
10264 debug_hexdump(stdout, "digest:",
10265 sym_op->auth.digest.data,
10266 reference->digest.len);
10268 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10269 reference->iv.data, reference->iv.len);
10271 sym_op->cipher.data.length = 0;
10272 sym_op->cipher.data.offset = 0;
10274 sym_op->auth.data.length = reference->plaintext.len;
10275 sym_op->auth.data.offset = 0;
10281 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10282 struct crypto_unittest_params *ut_params,
10283 const struct test_crypto_vector *reference,
10284 unsigned int auth_generate)
10286 /* Generate Crypto op data structure */
10287 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10288 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10289 TEST_ASSERT_NOT_NULL(ut_params->op,
10290 "Failed to allocate pktmbuf offload");
10292 /* Set crypto operation data parameters */
10293 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10295 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10297 /* set crypto operation source mbuf */
10298 sym_op->m_src = ut_params->ibuf;
10301 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10302 ut_params->ibuf, reference->digest.len);
10304 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10305 "no room to append auth tag");
10307 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10308 ut_params->ibuf, reference->ciphertext.len);
10311 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10313 memcpy(sym_op->auth.digest.data,
10314 reference->digest.data,
10315 reference->digest.len);
10317 debug_hexdump(stdout, "digest:",
10318 sym_op->auth.digest.data,
10319 reference->digest.len);
10321 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10322 reference->iv.data, reference->iv.len);
10324 sym_op->cipher.data.length = reference->cipher_len;
10325 sym_op->cipher.data.offset = reference->cipher_offset;
10327 sym_op->auth.data.length = reference->plaintext.len;
10328 sym_op->auth.data.offset = reference->auth_offset;
10334 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10335 struct crypto_unittest_params *ut_params,
10336 const struct test_crypto_vector *reference)
10338 return create_auth_operation(ts_params, ut_params, reference, 0);
10342 create_auth_verify_GMAC_operation(
10343 struct crypto_testsuite_params *ts_params,
10344 struct crypto_unittest_params *ut_params,
10345 const struct test_crypto_vector *reference)
10347 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10351 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10352 struct crypto_unittest_params *ut_params,
10353 const struct test_crypto_vector *reference)
10355 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10359 test_authentication_verify_fail_when_data_corruption(
10360 struct crypto_testsuite_params *ts_params,
10361 struct crypto_unittest_params *ut_params,
10362 const struct test_crypto_vector *reference,
10363 unsigned int data_corrupted)
10367 uint8_t *plaintext;
10369 /* Verify the capabilities */
10370 struct rte_cryptodev_sym_capability_idx cap_idx;
10371 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10372 cap_idx.algo.auth = reference->auth_algo;
10373 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10377 /* Create session */
10378 retval = create_auth_session(ut_params,
10379 ts_params->valid_devs[0],
10381 RTE_CRYPTO_AUTH_OP_VERIFY);
10385 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10386 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10387 "Failed to allocate input buffer in mempool");
10389 /* clear mbuf payload */
10390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10391 rte_pktmbuf_tailroom(ut_params->ibuf));
10393 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10394 reference->plaintext.len);
10395 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10396 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10398 debug_hexdump(stdout, "plaintext:", plaintext,
10399 reference->plaintext.len);
10401 /* Create operation */
10402 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10407 if (data_corrupted)
10408 data_corruption(plaintext);
10410 tag_corruption(plaintext, reference->plaintext.len);
10412 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10415 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10421 test_authentication_verify_GMAC_fail_when_corruption(
10422 struct crypto_testsuite_params *ts_params,
10423 struct crypto_unittest_params *ut_params,
10424 const struct test_crypto_vector *reference,
10425 unsigned int data_corrupted)
10428 uint8_t *plaintext;
10430 /* Verify the capabilities */
10431 struct rte_cryptodev_sym_capability_idx cap_idx;
10432 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10433 cap_idx.algo.auth = reference->auth_algo;
10434 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10438 /* Create session */
10439 retval = create_auth_cipher_session(ut_params,
10440 ts_params->valid_devs[0],
10442 RTE_CRYPTO_AUTH_OP_VERIFY,
10443 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10447 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10448 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10449 "Failed to allocate input buffer in mempool");
10451 /* clear mbuf payload */
10452 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10453 rte_pktmbuf_tailroom(ut_params->ibuf));
10455 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10456 reference->plaintext.len);
10457 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10458 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10460 debug_hexdump(stdout, "plaintext:", plaintext,
10461 reference->plaintext.len);
10463 /* Create operation */
10464 retval = create_auth_verify_GMAC_operation(ts_params,
10471 if (data_corrupted)
10472 data_corruption(plaintext);
10474 tag_corruption(plaintext, reference->aad.len);
10476 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10479 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10485 test_authenticated_decryption_fail_when_corruption(
10486 struct crypto_testsuite_params *ts_params,
10487 struct crypto_unittest_params *ut_params,
10488 const struct test_crypto_vector *reference,
10489 unsigned int data_corrupted)
10493 uint8_t *ciphertext;
10495 /* Verify the capabilities */
10496 struct rte_cryptodev_sym_capability_idx cap_idx;
10497 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10498 cap_idx.algo.auth = reference->auth_algo;
10499 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10502 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10503 cap_idx.algo.cipher = reference->crypto_algo;
10504 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10508 /* Create session */
10509 retval = create_auth_cipher_session(ut_params,
10510 ts_params->valid_devs[0],
10512 RTE_CRYPTO_AUTH_OP_VERIFY,
10513 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10517 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10518 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10519 "Failed to allocate input buffer in mempool");
10521 /* clear mbuf payload */
10522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10523 rte_pktmbuf_tailroom(ut_params->ibuf));
10525 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10526 reference->ciphertext.len);
10527 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10528 memcpy(ciphertext, reference->ciphertext.data,
10529 reference->ciphertext.len);
10531 /* Create operation */
10532 retval = create_cipher_auth_verify_operation(ts_params,
10539 if (data_corrupted)
10540 data_corruption(ciphertext);
10542 tag_corruption(ciphertext, reference->ciphertext.len);
10544 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10547 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10553 test_authenticated_encryt_with_esn(
10554 struct crypto_testsuite_params *ts_params,
10555 struct crypto_unittest_params *ut_params,
10556 const struct test_crypto_vector *reference)
10560 uint8_t *authciphertext, *plaintext, *auth_tag;
10561 uint16_t plaintext_pad_len;
10562 uint8_t cipher_key[reference->cipher_key.len + 1];
10563 uint8_t auth_key[reference->auth_key.len + 1];
10565 /* Verify the capabilities */
10566 struct rte_cryptodev_sym_capability_idx cap_idx;
10567 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10568 cap_idx.algo.auth = reference->auth_algo;
10569 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10572 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10573 cap_idx.algo.cipher = reference->crypto_algo;
10574 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10578 /* Create session */
10579 memcpy(cipher_key, reference->cipher_key.data,
10580 reference->cipher_key.len);
10581 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10583 /* Setup Cipher Parameters */
10584 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10585 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10586 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10587 ut_params->cipher_xform.cipher.key.data = cipher_key;
10588 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10589 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10590 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10592 ut_params->cipher_xform.next = &ut_params->auth_xform;
10594 /* Setup Authentication Parameters */
10595 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10596 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10597 ut_params->auth_xform.auth.algo = reference->auth_algo;
10598 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10599 ut_params->auth_xform.auth.key.data = auth_key;
10600 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10601 ut_params->auth_xform.next = NULL;
10603 /* Create Crypto session*/
10604 ut_params->sess = rte_cryptodev_sym_session_create(
10605 ts_params->session_mpool);
10607 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10609 &ut_params->cipher_xform,
10610 ts_params->session_priv_mpool);
10612 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10614 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10615 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10616 "Failed to allocate input buffer in mempool");
10618 /* clear mbuf payload */
10619 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10620 rte_pktmbuf_tailroom(ut_params->ibuf));
10622 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10623 reference->plaintext.len);
10624 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10625 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10627 /* Create operation */
10628 retval = create_cipher_auth_operation(ts_params,
10635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10638 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10640 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10641 "crypto op processing failed");
10643 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10645 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10646 ut_params->op->sym->auth.data.offset);
10647 auth_tag = authciphertext + plaintext_pad_len;
10648 debug_hexdump(stdout, "ciphertext:", authciphertext,
10649 reference->ciphertext.len);
10650 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10652 /* Validate obuf */
10653 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10655 reference->ciphertext.data,
10656 reference->ciphertext.len,
10657 "Ciphertext data not as expected");
10659 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10661 reference->digest.data,
10662 reference->digest.len,
10663 "Generated digest not as expected");
10665 return TEST_SUCCESS;
10670 test_authenticated_decrypt_with_esn(
10671 struct crypto_testsuite_params *ts_params,
10672 struct crypto_unittest_params *ut_params,
10673 const struct test_crypto_vector *reference)
10677 uint8_t *ciphertext;
10678 uint8_t cipher_key[reference->cipher_key.len + 1];
10679 uint8_t auth_key[reference->auth_key.len + 1];
10681 /* Verify the capabilities */
10682 struct rte_cryptodev_sym_capability_idx cap_idx;
10683 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10684 cap_idx.algo.auth = reference->auth_algo;
10685 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10689 cap_idx.algo.cipher = reference->crypto_algo;
10690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10694 /* Create session */
10695 memcpy(cipher_key, reference->cipher_key.data,
10696 reference->cipher_key.len);
10697 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10699 /* Setup Authentication Parameters */
10700 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10701 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10702 ut_params->auth_xform.auth.algo = reference->auth_algo;
10703 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10704 ut_params->auth_xform.auth.key.data = auth_key;
10705 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10706 ut_params->auth_xform.next = &ut_params->cipher_xform;
10708 /* Setup Cipher Parameters */
10709 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10710 ut_params->cipher_xform.next = NULL;
10711 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10712 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10713 ut_params->cipher_xform.cipher.key.data = cipher_key;
10714 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10715 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10716 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10718 /* Create Crypto session*/
10719 ut_params->sess = rte_cryptodev_sym_session_create(
10720 ts_params->session_mpool);
10722 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10724 &ut_params->auth_xform,
10725 ts_params->session_priv_mpool);
10727 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10730 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10731 "Failed to allocate input buffer in mempool");
10733 /* clear mbuf payload */
10734 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10735 rte_pktmbuf_tailroom(ut_params->ibuf));
10737 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10738 reference->ciphertext.len);
10739 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10740 memcpy(ciphertext, reference->ciphertext.data,
10741 reference->ciphertext.len);
10743 /* Create operation */
10744 retval = create_cipher_auth_verify_operation(ts_params,
10751 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10754 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10755 TEST_ASSERT_EQUAL(ut_params->op->status,
10756 RTE_CRYPTO_OP_STATUS_SUCCESS,
10757 "crypto op processing passed");
10759 ut_params->obuf = ut_params->op->sym->m_src;
10760 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10766 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10767 const struct aead_test_data *tdata,
10768 void *digest_mem, uint64_t digest_phys)
10770 struct crypto_testsuite_params *ts_params = &testsuite_params;
10771 struct crypto_unittest_params *ut_params = &unittest_params;
10773 const unsigned int auth_tag_len = tdata->auth_tag.len;
10774 const unsigned int iv_len = tdata->iv.len;
10775 unsigned int aad_len = tdata->aad.len;
10776 unsigned int aad_len_pad = 0;
10778 /* Generate Crypto op data structure */
10779 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10780 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10781 TEST_ASSERT_NOT_NULL(ut_params->op,
10782 "Failed to allocate symmetric crypto operation struct");
10784 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10786 sym_op->aead.digest.data = digest_mem;
10788 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10789 "no room to append digest");
10791 sym_op->aead.digest.phys_addr = digest_phys;
10793 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10794 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10796 debug_hexdump(stdout, "digest:",
10797 sym_op->aead.digest.data,
10801 /* Append aad data */
10802 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10803 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10804 uint8_t *, IV_OFFSET);
10806 /* Copy IV 1 byte after the IV pointer, according to the API */
10807 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10809 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10811 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10812 ut_params->ibuf, aad_len);
10813 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10814 "no room to prepend aad");
10815 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10818 memset(sym_op->aead.aad.data, 0, aad_len);
10819 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10820 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10822 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10823 debug_hexdump(stdout, "aad:",
10824 sym_op->aead.aad.data, aad_len);
10826 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10827 uint8_t *, IV_OFFSET);
10829 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10831 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
10833 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10834 ut_params->ibuf, aad_len_pad);
10835 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10836 "no room to prepend aad");
10837 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10840 memset(sym_op->aead.aad.data, 0, aad_len);
10841 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10843 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10844 debug_hexdump(stdout, "aad:",
10845 sym_op->aead.aad.data, aad_len);
10848 sym_op->aead.data.length = tdata->plaintext.len;
10849 sym_op->aead.data.offset = aad_len_pad;
10854 #define SGL_MAX_NO 16
10857 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10858 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10860 struct crypto_testsuite_params *ts_params = &testsuite_params;
10861 struct crypto_unittest_params *ut_params = &unittest_params;
10862 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10865 int to_trn_tbl[SGL_MAX_NO];
10867 unsigned int trn_data = 0;
10868 uint8_t *plaintext, *ciphertext, *auth_tag;
10869 struct rte_cryptodev_info dev_info;
10871 /* Verify the capabilities */
10872 struct rte_cryptodev_sym_capability_idx cap_idx;
10873 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10874 cap_idx.algo.aead = tdata->algo;
10875 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10879 /* Detailed check for the particular SGL support flag */
10880 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10882 unsigned int sgl_in = fragsz < tdata->plaintext.len;
10883 if (sgl_in && (!(dev_info.feature_flags &
10884 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
10887 unsigned int sgl_in = fragsz < tdata->plaintext.len;
10888 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
10889 tdata->plaintext.len;
10890 if (sgl_in && !sgl_out) {
10891 if (!(dev_info.feature_flags &
10892 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
10894 } else if (!sgl_in && sgl_out) {
10895 if (!(dev_info.feature_flags &
10896 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
10898 } else if (sgl_in && sgl_out) {
10899 if (!(dev_info.feature_flags &
10900 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
10905 if (fragsz > tdata->plaintext.len)
10906 fragsz = tdata->plaintext.len;
10908 uint16_t plaintext_len = fragsz;
10909 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
10911 if (fragsz_oop > tdata->plaintext.len)
10912 frag_size_oop = tdata->plaintext.len;
10915 void *digest_mem = NULL;
10917 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
10919 if (tdata->plaintext.len % fragsz != 0) {
10920 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
10923 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
10928 * For out-op-place we need to alloc another mbuf
10931 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10932 rte_pktmbuf_append(ut_params->obuf,
10933 frag_size_oop + prepend_len);
10934 buf_oop = ut_params->obuf;
10937 /* Create AEAD session */
10938 retval = create_aead_session(ts_params->valid_devs[0],
10940 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10941 tdata->key.data, tdata->key.len,
10942 tdata->aad.len, tdata->auth_tag.len,
10947 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10949 /* clear mbuf payload */
10950 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10951 rte_pktmbuf_tailroom(ut_params->ibuf));
10953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10956 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10958 trn_data += plaintext_len;
10960 buf = ut_params->ibuf;
10963 * Loop until no more fragments
10966 while (trn_data < tdata->plaintext.len) {
10968 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10969 (tdata->plaintext.len - trn_data) : fragsz;
10971 to_trn_tbl[ecx++] = to_trn;
10973 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10976 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10977 rte_pktmbuf_tailroom(buf));
10980 if (oop && !fragsz_oop) {
10981 buf_last_oop = buf_oop->next =
10982 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10983 buf_oop = buf_oop->next;
10984 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10985 0, rte_pktmbuf_tailroom(buf_oop));
10986 rte_pktmbuf_append(buf_oop, to_trn);
10989 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10992 memcpy(plaintext, tdata->plaintext.data + trn_data,
10994 trn_data += to_trn;
10995 if (trn_data == tdata->plaintext.len) {
10998 digest_mem = rte_pktmbuf_append(buf_oop,
10999 tdata->auth_tag.len);
11001 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11002 tdata->auth_tag.len);
11006 uint64_t digest_phys = 0;
11008 ut_params->ibuf->nb_segs = segs;
11011 if (fragsz_oop && oop) {
11015 if (frag_size_oop == tdata->plaintext.len) {
11016 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11017 tdata->auth_tag.len);
11019 digest_phys = rte_pktmbuf_iova_offset(
11021 tdata->plaintext.len + prepend_len);
11024 trn_data = frag_size_oop;
11025 while (trn_data < tdata->plaintext.len) {
11028 (tdata->plaintext.len - trn_data <
11030 (tdata->plaintext.len - trn_data) :
11033 to_trn_tbl[ecx++] = to_trn;
11035 buf_last_oop = buf_oop->next =
11036 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11037 buf_oop = buf_oop->next;
11038 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11039 0, rte_pktmbuf_tailroom(buf_oop));
11040 rte_pktmbuf_append(buf_oop, to_trn);
11042 trn_data += to_trn;
11044 if (trn_data == tdata->plaintext.len) {
11045 digest_mem = rte_pktmbuf_append(buf_oop,
11046 tdata->auth_tag.len);
11050 ut_params->obuf->nb_segs = segs;
11054 * Place digest at the end of the last buffer
11057 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11058 if (oop && buf_last_oop)
11059 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11061 if (!digest_mem && !oop) {
11062 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11063 + tdata->auth_tag.len);
11064 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11065 tdata->plaintext.len);
11068 /* Create AEAD operation */
11069 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11070 tdata, digest_mem, digest_phys);
11075 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11077 ut_params->op->sym->m_src = ut_params->ibuf;
11079 ut_params->op->sym->m_dst = ut_params->obuf;
11081 /* Process crypto operation */
11082 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11083 ut_params->op), "failed to process sym crypto op");
11085 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11086 "crypto op processing failed");
11089 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11090 uint8_t *, prepend_len);
11092 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11093 uint8_t *, prepend_len);
11097 fragsz = fragsz_oop;
11099 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11101 tdata->ciphertext.data,
11103 "Ciphertext data not as expected");
11105 buf = ut_params->op->sym->m_src->next;
11107 buf = ut_params->op->sym->m_dst->next;
11109 unsigned int off = fragsz;
11113 ciphertext = rte_pktmbuf_mtod(buf,
11116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11118 tdata->ciphertext.data + off,
11120 "Ciphertext data not as expected");
11122 off += to_trn_tbl[ecx++];
11126 auth_tag = digest_mem;
11127 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11129 tdata->auth_tag.data,
11130 tdata->auth_tag.len,
11131 "Generated auth tag not as expected");
11137 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11139 return test_authenticated_encryption_SGL(
11140 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11144 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11146 return test_authenticated_encryption_SGL(
11147 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11151 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11153 return test_authenticated_encryption_SGL(
11154 &gcm_test_case_8, OUT_OF_PLACE, 400,
11155 gcm_test_case_8.plaintext.len);
11159 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11161 /* This test is not for OPENSSL PMD */
11162 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11163 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11166 return test_authenticated_encryption_SGL(
11167 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11171 test_authentication_verify_fail_when_data_corrupted(
11172 struct crypto_testsuite_params *ts_params,
11173 struct crypto_unittest_params *ut_params,
11174 const struct test_crypto_vector *reference)
11176 return test_authentication_verify_fail_when_data_corruption(
11177 ts_params, ut_params, reference, 1);
11181 test_authentication_verify_fail_when_tag_corrupted(
11182 struct crypto_testsuite_params *ts_params,
11183 struct crypto_unittest_params *ut_params,
11184 const struct test_crypto_vector *reference)
11186 return test_authentication_verify_fail_when_data_corruption(
11187 ts_params, ut_params, reference, 0);
11191 test_authentication_verify_GMAC_fail_when_data_corrupted(
11192 struct crypto_testsuite_params *ts_params,
11193 struct crypto_unittest_params *ut_params,
11194 const struct test_crypto_vector *reference)
11196 return test_authentication_verify_GMAC_fail_when_corruption(
11197 ts_params, ut_params, reference, 1);
11201 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11202 struct crypto_testsuite_params *ts_params,
11203 struct crypto_unittest_params *ut_params,
11204 const struct test_crypto_vector *reference)
11206 return test_authentication_verify_GMAC_fail_when_corruption(
11207 ts_params, ut_params, reference, 0);
11211 test_authenticated_decryption_fail_when_data_corrupted(
11212 struct crypto_testsuite_params *ts_params,
11213 struct crypto_unittest_params *ut_params,
11214 const struct test_crypto_vector *reference)
11216 return test_authenticated_decryption_fail_when_corruption(
11217 ts_params, ut_params, reference, 1);
11221 test_authenticated_decryption_fail_when_tag_corrupted(
11222 struct crypto_testsuite_params *ts_params,
11223 struct crypto_unittest_params *ut_params,
11224 const struct test_crypto_vector *reference)
11226 return test_authenticated_decryption_fail_when_corruption(
11227 ts_params, ut_params, reference, 0);
11231 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11233 return test_authentication_verify_fail_when_data_corrupted(
11234 &testsuite_params, &unittest_params,
11235 &hmac_sha1_test_crypto_vector);
11239 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11241 return test_authentication_verify_fail_when_tag_corrupted(
11242 &testsuite_params, &unittest_params,
11243 &hmac_sha1_test_crypto_vector);
11247 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11249 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11250 &testsuite_params, &unittest_params,
11251 &aes128_gmac_test_vector);
11255 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11257 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11258 &testsuite_params, &unittest_params,
11259 &aes128_gmac_test_vector);
11263 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11265 return test_authenticated_decryption_fail_when_data_corrupted(
11268 &aes128cbc_hmac_sha1_test_vector);
11272 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11274 return test_authenticated_decryption_fail_when_tag_corrupted(
11277 &aes128cbc_hmac_sha1_test_vector);
11281 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11283 return test_authenticated_encryt_with_esn(
11286 &aes128cbc_hmac_sha1_aad_test_vector);
11290 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11292 return test_authenticated_decrypt_with_esn(
11295 &aes128cbc_hmac_sha1_aad_test_vector);
11298 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11300 /* global AESNI slave IDs for the scheduler test */
11301 uint8_t aesni_ids[2];
11304 test_scheduler_attach_slave_op(void)
11306 struct crypto_testsuite_params *ts_params = &testsuite_params;
11307 uint8_t sched_id = ts_params->valid_devs[0];
11308 uint32_t nb_devs, i, nb_devs_attached = 0;
11310 char vdev_name[32];
11312 /* create 2 AESNI_MB if necessary */
11313 nb_devs = rte_cryptodev_device_count_by_driver(
11314 rte_cryptodev_driver_id_get(
11315 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11317 for (i = nb_devs; i < 2; i++) {
11318 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11321 ret = rte_vdev_init(vdev_name, NULL);
11323 TEST_ASSERT(ret == 0,
11324 "Failed to create instance %u of"
11326 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11330 /* attach 2 AESNI_MB cdevs */
11331 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11333 struct rte_cryptodev_info info;
11334 unsigned int session_size;
11336 rte_cryptodev_info_get(i, &info);
11337 if (info.driver_id != rte_cryptodev_driver_id_get(
11338 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11341 session_size = rte_cryptodev_sym_get_private_session_size(i);
11343 * Create the session mempool again, since now there are new devices
11344 * to use the mempool.
11346 if (ts_params->session_mpool) {
11347 rte_mempool_free(ts_params->session_mpool);
11348 ts_params->session_mpool = NULL;
11350 if (ts_params->session_priv_mpool) {
11351 rte_mempool_free(ts_params->session_priv_mpool);
11352 ts_params->session_priv_mpool = NULL;
11355 if (info.sym.max_nb_sessions != 0 &&
11356 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11357 RTE_LOG(ERR, USER1,
11358 "Device does not support "
11359 "at least %u sessions\n",
11361 return TEST_FAILED;
11364 * Create mempool with maximum number of sessions,
11365 * to include the session headers
11367 if (ts_params->session_mpool == NULL) {
11368 ts_params->session_mpool =
11369 rte_cryptodev_sym_session_pool_create(
11371 MAX_NB_SESSIONS, 0, 0, 0,
11373 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11374 "session mempool allocation failed");
11378 * Create mempool with maximum number of sessions,
11379 * to include device specific session private data
11381 if (ts_params->session_priv_mpool == NULL) {
11382 ts_params->session_priv_mpool = rte_mempool_create(
11383 "test_sess_mp_priv",
11386 0, 0, NULL, NULL, NULL,
11387 NULL, SOCKET_ID_ANY,
11390 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11391 "session mempool allocation failed");
11394 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11395 ts_params->qp_conf.mp_session_private =
11396 ts_params->session_priv_mpool;
11398 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11401 TEST_ASSERT(ret == 0,
11402 "Failed to attach device %u of pmd : %s", i,
11403 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11405 aesni_ids[nb_devs_attached] = (uint8_t)i;
11407 nb_devs_attached++;
11414 test_scheduler_detach_slave_op(void)
11416 struct crypto_testsuite_params *ts_params = &testsuite_params;
11417 uint8_t sched_id = ts_params->valid_devs[0];
11421 for (i = 0; i < 2; i++) {
11422 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11424 TEST_ASSERT(ret == 0,
11425 "Failed to detach device %u", aesni_ids[i]);
11432 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11434 struct crypto_testsuite_params *ts_params = &testsuite_params;
11435 uint8_t sched_id = ts_params->valid_devs[0];
11437 return rte_cryptodev_scheduler_mode_set(sched_id,
11442 test_scheduler_mode_roundrobin_op(void)
11444 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11445 0, "Failed to set roundrobin mode");
11451 test_scheduler_mode_multicore_op(void)
11453 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11454 0, "Failed to set multicore mode");
11460 test_scheduler_mode_failover_op(void)
11462 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11463 0, "Failed to set failover mode");
11469 test_scheduler_mode_pkt_size_distr_op(void)
11471 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11472 0, "Failed to set pktsize mode");
11477 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11478 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11479 .setup = testsuite_setup,
11480 .teardown = testsuite_teardown,
11481 .unit_test_cases = {
11483 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11484 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11485 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11486 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11487 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11488 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11491 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11492 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11493 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11494 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11495 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11496 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11499 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11500 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11501 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11502 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11503 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11504 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11507 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11508 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11509 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11510 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11511 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11512 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11514 TEST_CASES_END() /**< NULL terminate unit test array */
11518 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11520 static struct unit_test_suite cryptodev_qat_testsuite = {
11521 .suite_name = "Crypto QAT Unit Test Suite",
11522 .setup = testsuite_setup,
11523 .teardown = testsuite_teardown,
11524 .unit_test_cases = {
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_device_configure_invalid_dev_id),
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_device_configure_invalid_queue_pair_ids),
11529 TEST_CASE_ST(ut_setup, ut_teardown,
11530 test_queue_pair_descriptor_setup),
11531 TEST_CASE_ST(ut_setup, ut_teardown,
11532 test_multi_session),
11534 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11535 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11536 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11537 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11538 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11539 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11540 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11541 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11542 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11544 /** AES CCM Authenticated Encryption 128 bits key */
11545 TEST_CASE_ST(ut_setup, ut_teardown,
11546 test_AES_CCM_authenticated_encryption_test_case_128_1),
11547 TEST_CASE_ST(ut_setup, ut_teardown,
11548 test_AES_CCM_authenticated_encryption_test_case_128_2),
11549 TEST_CASE_ST(ut_setup, ut_teardown,
11550 test_AES_CCM_authenticated_encryption_test_case_128_3),
11552 /** AES CCM Authenticated Decryption 128 bits key*/
11553 TEST_CASE_ST(ut_setup, ut_teardown,
11554 test_AES_CCM_authenticated_decryption_test_case_128_1),
11555 TEST_CASE_ST(ut_setup, ut_teardown,
11556 test_AES_CCM_authenticated_decryption_test_case_128_2),
11557 TEST_CASE_ST(ut_setup, ut_teardown,
11558 test_AES_CCM_authenticated_decryption_test_case_128_3),
11560 /** AES GCM Authenticated Encryption */
11561 TEST_CASE_ST(ut_setup, ut_teardown,
11562 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11563 TEST_CASE_ST(ut_setup, ut_teardown,
11564 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11565 TEST_CASE_ST(ut_setup, ut_teardown,
11566 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11567 TEST_CASE_ST(ut_setup, ut_teardown,
11568 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11569 TEST_CASE_ST(ut_setup, ut_teardown,
11570 test_AES_GCM_authenticated_encryption_test_case_1),
11571 TEST_CASE_ST(ut_setup, ut_teardown,
11572 test_AES_GCM_authenticated_encryption_test_case_2),
11573 TEST_CASE_ST(ut_setup, ut_teardown,
11574 test_AES_GCM_authenticated_encryption_test_case_3),
11575 TEST_CASE_ST(ut_setup, ut_teardown,
11576 test_AES_GCM_authenticated_encryption_test_case_4),
11577 TEST_CASE_ST(ut_setup, ut_teardown,
11578 test_AES_GCM_authenticated_encryption_test_case_5),
11579 TEST_CASE_ST(ut_setup, ut_teardown,
11580 test_AES_GCM_authenticated_encryption_test_case_6),
11581 TEST_CASE_ST(ut_setup, ut_teardown,
11582 test_AES_GCM_authenticated_encryption_test_case_7),
11583 TEST_CASE_ST(ut_setup, ut_teardown,
11584 test_AES_GCM_authenticated_encryption_test_case_8),
11586 /** AES GCM Authenticated Decryption */
11587 TEST_CASE_ST(ut_setup, ut_teardown,
11588 test_AES_GCM_authenticated_decryption_test_case_1),
11589 TEST_CASE_ST(ut_setup, ut_teardown,
11590 test_AES_GCM_authenticated_decryption_test_case_2),
11591 TEST_CASE_ST(ut_setup, ut_teardown,
11592 test_AES_GCM_authenticated_decryption_test_case_3),
11593 TEST_CASE_ST(ut_setup, ut_teardown,
11594 test_AES_GCM_authenticated_decryption_test_case_4),
11595 TEST_CASE_ST(ut_setup, ut_teardown,
11596 test_AES_GCM_authenticated_decryption_test_case_5),
11597 TEST_CASE_ST(ut_setup, ut_teardown,
11598 test_AES_GCM_authenticated_decryption_test_case_6),
11599 TEST_CASE_ST(ut_setup, ut_teardown,
11600 test_AES_GCM_authenticated_decryption_test_case_7),
11601 TEST_CASE_ST(ut_setup, ut_teardown,
11602 test_AES_GCM_authenticated_decryption_test_case_8),
11604 /** AES GCM Authenticated Encryption 192 bits key */
11605 TEST_CASE_ST(ut_setup, ut_teardown,
11606 test_AES_GCM_auth_encryption_test_case_192_1),
11607 TEST_CASE_ST(ut_setup, ut_teardown,
11608 test_AES_GCM_auth_encryption_test_case_192_2),
11609 TEST_CASE_ST(ut_setup, ut_teardown,
11610 test_AES_GCM_auth_encryption_test_case_192_3),
11611 TEST_CASE_ST(ut_setup, ut_teardown,
11612 test_AES_GCM_auth_encryption_test_case_192_4),
11613 TEST_CASE_ST(ut_setup, ut_teardown,
11614 test_AES_GCM_auth_encryption_test_case_192_5),
11615 TEST_CASE_ST(ut_setup, ut_teardown,
11616 test_AES_GCM_auth_encryption_test_case_192_6),
11617 TEST_CASE_ST(ut_setup, ut_teardown,
11618 test_AES_GCM_auth_encryption_test_case_192_7),
11620 /** AES GCM Authenticated Decryption 192 bits key */
11621 TEST_CASE_ST(ut_setup, ut_teardown,
11622 test_AES_GCM_auth_decryption_test_case_192_1),
11623 TEST_CASE_ST(ut_setup, ut_teardown,
11624 test_AES_GCM_auth_decryption_test_case_192_2),
11625 TEST_CASE_ST(ut_setup, ut_teardown,
11626 test_AES_GCM_auth_decryption_test_case_192_3),
11627 TEST_CASE_ST(ut_setup, ut_teardown,
11628 test_AES_GCM_auth_decryption_test_case_192_4),
11629 TEST_CASE_ST(ut_setup, ut_teardown,
11630 test_AES_GCM_auth_decryption_test_case_192_5),
11631 TEST_CASE_ST(ut_setup, ut_teardown,
11632 test_AES_GCM_auth_decryption_test_case_192_6),
11633 TEST_CASE_ST(ut_setup, ut_teardown,
11634 test_AES_GCM_auth_decryption_test_case_192_7),
11636 /** AES GCM Authenticated Encryption 256 bits key */
11637 TEST_CASE_ST(ut_setup, ut_teardown,
11638 test_AES_GCM_auth_encryption_test_case_256_1),
11639 TEST_CASE_ST(ut_setup, ut_teardown,
11640 test_AES_GCM_auth_encryption_test_case_256_2),
11641 TEST_CASE_ST(ut_setup, ut_teardown,
11642 test_AES_GCM_auth_encryption_test_case_256_3),
11643 TEST_CASE_ST(ut_setup, ut_teardown,
11644 test_AES_GCM_auth_encryption_test_case_256_4),
11645 TEST_CASE_ST(ut_setup, ut_teardown,
11646 test_AES_GCM_auth_encryption_test_case_256_5),
11647 TEST_CASE_ST(ut_setup, ut_teardown,
11648 test_AES_GCM_auth_encryption_test_case_256_6),
11649 TEST_CASE_ST(ut_setup, ut_teardown,
11650 test_AES_GCM_auth_encryption_test_case_256_7),
11652 /** AES GCM Authenticated Decryption 256 bits key */
11653 TEST_CASE_ST(ut_setup, ut_teardown,
11654 test_AES_GCM_auth_decryption_test_case_256_1),
11655 TEST_CASE_ST(ut_setup, ut_teardown,
11656 test_AES_GCM_auth_decryption_test_case_256_2),
11657 TEST_CASE_ST(ut_setup, ut_teardown,
11658 test_AES_GCM_auth_decryption_test_case_256_3),
11659 TEST_CASE_ST(ut_setup, ut_teardown,
11660 test_AES_GCM_auth_decryption_test_case_256_4),
11661 TEST_CASE_ST(ut_setup, ut_teardown,
11662 test_AES_GCM_auth_decryption_test_case_256_5),
11663 TEST_CASE_ST(ut_setup, ut_teardown,
11664 test_AES_GCM_auth_decryption_test_case_256_6),
11665 TEST_CASE_ST(ut_setup, ut_teardown,
11666 test_AES_GCM_auth_decryption_test_case_256_7),
11668 /** AES GMAC Authentication */
11669 TEST_CASE_ST(ut_setup, ut_teardown,
11670 test_AES_GMAC_authentication_test_case_1),
11671 TEST_CASE_ST(ut_setup, ut_teardown,
11672 test_AES_GMAC_authentication_verify_test_case_1),
11673 TEST_CASE_ST(ut_setup, ut_teardown,
11674 test_AES_GMAC_authentication_test_case_2),
11675 TEST_CASE_ST(ut_setup, ut_teardown,
11676 test_AES_GMAC_authentication_verify_test_case_2),
11677 TEST_CASE_ST(ut_setup, ut_teardown,
11678 test_AES_GMAC_authentication_test_case_3),
11679 TEST_CASE_ST(ut_setup, ut_teardown,
11680 test_AES_GMAC_authentication_verify_test_case_3),
11682 /** SNOW 3G encrypt only (UEA2) */
11683 TEST_CASE_ST(ut_setup, ut_teardown,
11684 test_snow3g_encryption_test_case_1),
11685 TEST_CASE_ST(ut_setup, ut_teardown,
11686 test_snow3g_encryption_test_case_2),
11687 TEST_CASE_ST(ut_setup, ut_teardown,
11688 test_snow3g_encryption_test_case_3),
11689 TEST_CASE_ST(ut_setup, ut_teardown,
11690 test_snow3g_encryption_test_case_4),
11691 TEST_CASE_ST(ut_setup, ut_teardown,
11692 test_snow3g_encryption_test_case_5),
11694 TEST_CASE_ST(ut_setup, ut_teardown,
11695 test_snow3g_encryption_test_case_1_oop),
11696 TEST_CASE_ST(ut_setup, ut_teardown,
11697 test_snow3g_decryption_test_case_1_oop),
11699 /** SNOW 3G generate auth, then encrypt (UEA2) */
11700 TEST_CASE_ST(ut_setup, ut_teardown,
11701 test_snow3g_auth_cipher_test_case_1),
11702 TEST_CASE_ST(ut_setup, ut_teardown,
11703 test_snow3g_auth_cipher_test_case_2),
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_snow3g_auth_cipher_test_case_2_oop),
11706 TEST_CASE_ST(ut_setup, ut_teardown,
11707 test_snow3g_auth_cipher_part_digest_enc),
11708 TEST_CASE_ST(ut_setup, ut_teardown,
11709 test_snow3g_auth_cipher_part_digest_enc_oop),
11710 TEST_CASE_ST(ut_setup, ut_teardown,
11711 test_snow3g_auth_cipher_test_case_3_sgl),
11712 TEST_CASE_ST(ut_setup, ut_teardown,
11713 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 test_snow3g_auth_cipher_part_digest_enc_sgl),
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11719 /** SNOW 3G decrypt (UEA2), then verify auth */
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 test_snow3g_auth_cipher_verify_test_case_1),
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_snow3g_auth_cipher_verify_test_case_2),
11724 TEST_CASE_ST(ut_setup, ut_teardown,
11725 test_snow3g_auth_cipher_verify_test_case_2_oop),
11726 TEST_CASE_ST(ut_setup, ut_teardown,
11727 test_snow3g_auth_cipher_verify_part_digest_enc),
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11739 /** SNOW 3G decrypt only (UEA2) */
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_snow3g_decryption_test_case_1),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 test_snow3g_decryption_test_case_2),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_snow3g_decryption_test_case_3),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_snow3g_decryption_test_case_4),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_snow3g_decryption_test_case_5),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_snow3g_decryption_with_digest_test_case_1),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_snow3g_hash_generate_test_case_1),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_snow3g_hash_generate_test_case_2),
11756 TEST_CASE_ST(ut_setup, ut_teardown,
11757 test_snow3g_hash_generate_test_case_3),
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_snow3g_hash_verify_test_case_1),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_snow3g_hash_verify_test_case_2),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_snow3g_hash_verify_test_case_3),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_snow3g_cipher_auth_test_case_1),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_snow3g_auth_cipher_with_digest_test_case_1),
11769 /** ZUC encrypt only (EEA3) */
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_zuc_encryption_test_case_1),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_zuc_encryption_test_case_2),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_zuc_encryption_test_case_3),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_zuc_encryption_test_case_4),
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_zuc_encryption_test_case_5),
11781 /** ZUC authenticate (EIA3) */
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_zuc_hash_generate_test_case_6),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_zuc_hash_generate_test_case_7),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_zuc_hash_generate_test_case_8),
11789 /** ZUC alg-chain (EEA3/EIA3) */
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_zuc_cipher_auth_test_case_1),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_zuc_cipher_auth_test_case_2),
11795 /** ZUC generate auth, then encrypt (EEA3) */
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_zuc_auth_cipher_test_case_1),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_zuc_auth_cipher_test_case_1_oop),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_zuc_auth_cipher_test_case_1_sgl),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_zuc_auth_cipher_test_case_1_oop_sgl),
11805 /** ZUC decrypt (EEA3), then verify auth */
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_zuc_auth_cipher_verify_test_case_1),
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_zuc_auth_cipher_verify_test_case_1_oop),
11810 TEST_CASE_ST(ut_setup, ut_teardown,
11811 test_zuc_auth_cipher_verify_test_case_1_sgl),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
11815 /** HMAC_MD5 Authentication */
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_MD5_HMAC_generate_case_1),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_MD5_HMAC_verify_case_1),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_MD5_HMAC_generate_case_2),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_MD5_HMAC_verify_case_2),
11825 /** NULL algo tests done in chain_all,
11826 * cipheronly and authonly suites
11829 /** KASUMI tests */
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_kasumi_hash_generate_test_case_1),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_kasumi_hash_generate_test_case_2),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_kasumi_hash_generate_test_case_3),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_kasumi_hash_generate_test_case_4),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_kasumi_hash_generate_test_case_5),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_kasumi_hash_generate_test_case_6),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_kasumi_hash_verify_test_case_1),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_kasumi_hash_verify_test_case_2),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_kasumi_hash_verify_test_case_3),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_kasumi_hash_verify_test_case_4),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_kasumi_hash_verify_test_case_5),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_kasumi_encryption_test_case_1),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_kasumi_encryption_test_case_3),
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_kasumi_cipher_auth_test_case_1),
11861 /** KASUMI generate auth, then encrypt (F8) */
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_kasumi_auth_cipher_test_case_1),
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_kasumi_auth_cipher_test_case_2),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_kasumi_auth_cipher_test_case_2_oop),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_kasumi_auth_cipher_test_case_2_sgl),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11873 /** KASUMI decrypt (F8), then verify auth */
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_kasumi_auth_cipher_verify_test_case_1),
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_kasumi_auth_cipher_verify_test_case_2),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_kasumi_auth_cipher_verify_test_case_2_oop),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11885 /** Negative tests */
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_AES_GCM_auth_encryption_fail_iv_corrupt),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_GCM_auth_encryption_fail_aad_corrupt),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_GCM_auth_encryption_fail_tag_corrupt),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_GCM_auth_decryption_fail_iv_corrupt),
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_AES_GCM_auth_decryption_fail_aad_corrupt),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_GCM_auth_decryption_fail_tag_corrupt),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 authentication_verify_AES128_GMAC_fail_data_corrupt),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11920 TEST_CASE_ST(ut_setup, ut_teardown,
11921 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11923 /** Mixed CIPHER + HASH algorithms */
11924 /** AUTH AES CMAC + CIPHER AES CTR */
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
11942 /** AUTH ZUC + CIPHER SNOW3G */
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_auth_zuc_cipher_snow_test_case_1),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_verify_auth_zuc_cipher_snow_test_case_1),
11947 /** AUTH AES CMAC + CIPHER SNOW3G */
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_auth_aes_cmac_cipher_snow_test_case_1),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
11952 /** AUTH ZUC + CIPHER AES CTR */
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_auth_zuc_cipher_aes_ctr_test_case_1),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
11957 /** AUTH SNOW3G + CIPHER AES CTR */
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_auth_snow_cipher_aes_ctr_test_case_1),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
11962 /** AUTH SNOW3G + CIPHER ZUC */
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_auth_snow_cipher_zuc_test_case_1),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_verify_auth_snow_cipher_zuc_test_case_1),
11967 /** AUTH AES CMAC + CIPHER ZUC */
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_auth_aes_cmac_cipher_zuc_test_case_1),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
11973 /** AUTH NULL + CIPHER SNOW3G */
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_auth_null_cipher_snow_test_case_1),
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_verify_auth_null_cipher_snow_test_case_1),
11978 /** AUTH NULL + CIPHER ZUC */
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_auth_null_cipher_zuc_test_case_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_verify_auth_null_cipher_zuc_test_case_1),
11983 /** AUTH SNOW3G + CIPHER NULL */
11984 TEST_CASE_ST(ut_setup, ut_teardown,
11985 test_auth_snow_cipher_null_test_case_1),
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_verify_auth_snow_cipher_null_test_case_1),
11988 /** AUTH ZUC + CIPHER NULL */
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_auth_zuc_cipher_null_test_case_1),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_verify_auth_zuc_cipher_null_test_case_1),
11993 /** AUTH NULL + CIPHER AES CTR */
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_auth_null_cipher_aes_ctr_test_case_1),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_verify_auth_null_cipher_aes_ctr_test_case_1),
11998 /** AUTH AES CMAC + CIPHER NULL */
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_auth_aes_cmac_cipher_null_test_case_1),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12004 TEST_CASES_END() /**< NULL terminate unit test array */
12008 static struct unit_test_suite cryptodev_virtio_testsuite = {
12009 .suite_name = "Crypto VIRTIO Unit Test Suite",
12010 .setup = testsuite_setup,
12011 .teardown = testsuite_teardown,
12012 .unit_test_cases = {
12013 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12015 TEST_CASES_END() /**< NULL terminate unit test array */
12019 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12020 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12021 .setup = testsuite_setup,
12022 .teardown = testsuite_teardown,
12023 .unit_test_cases = {
12024 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_AES_GCM_authenticated_encryption_test_case_1),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_AES_GCM_authenticated_encryption_test_case_2),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_AES_GCM_authenticated_encryption_test_case_3),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_AES_GCM_authenticated_encryption_test_case_4),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_AES_GCM_authenticated_encryption_test_case_5),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_AES_GCM_authenticated_encryption_test_case_6),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_AES_GCM_authenticated_encryption_test_case_7),
12040 /** AES GCM Authenticated Decryption */
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_AES_GCM_authenticated_decryption_test_case_1),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_AES_GCM_authenticated_decryption_test_case_2),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_AES_GCM_authenticated_decryption_test_case_3),
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_AES_GCM_authenticated_decryption_test_case_4),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_AES_GCM_authenticated_decryption_test_case_5),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_AES_GCM_authenticated_decryption_test_case_6),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_AES_GCM_authenticated_decryption_test_case_7),
12056 /** AES GCM Authenticated Encryption 192 bits key */
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_AES_GCM_auth_encryption_test_case_192_1),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_AES_GCM_auth_encryption_test_case_192_2),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_AES_GCM_auth_encryption_test_case_192_3),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_AES_GCM_auth_encryption_test_case_192_4),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_AES_GCM_auth_encryption_test_case_192_5),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_AES_GCM_auth_encryption_test_case_192_6),
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_AES_GCM_auth_encryption_test_case_192_7),
12072 /** AES GCM Authenticated Decryption 192 bits key */
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_AES_GCM_auth_decryption_test_case_192_1),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_AES_GCM_auth_decryption_test_case_192_2),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_AES_GCM_auth_decryption_test_case_192_3),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_AES_GCM_auth_decryption_test_case_192_4),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_AES_GCM_auth_decryption_test_case_192_5),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_AES_GCM_auth_decryption_test_case_192_6),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_AES_GCM_auth_decryption_test_case_192_7),
12088 /** AES GCM Authenticated Encryption 256 bits key */
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_AES_GCM_auth_encryption_test_case_256_1),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_AES_GCM_auth_encryption_test_case_256_2),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_AES_GCM_auth_encryption_test_case_256_3),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_AES_GCM_auth_encryption_test_case_256_4),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_AES_GCM_auth_encryption_test_case_256_5),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_AES_GCM_auth_encryption_test_case_256_6),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_AES_GCM_auth_encryption_test_case_256_7),
12104 /** AES GCM Authenticated Decryption 256 bits key */
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_AES_GCM_auth_decryption_test_case_256_1),
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_AES_GCM_auth_decryption_test_case_256_2),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_AES_GCM_auth_decryption_test_case_256_3),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_AES_GCM_auth_decryption_test_case_256_4),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_AES_GCM_auth_decryption_test_case_256_5),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_AES_GCM_auth_decryption_test_case_256_6),
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_AES_GCM_auth_decryption_test_case_256_7),
12120 /** AES GCM Authenticated Encryption big aad size */
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_AES_GCM_auth_encryption_test_case_aad_1),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_AES_GCM_auth_encryption_test_case_aad_2),
12126 /** AES GCM Authenticated Decryption big aad size */
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_AES_GCM_auth_decryption_test_case_aad_1),
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_AES_GCM_auth_decryption_test_case_aad_2),
12132 /** Session-less tests */
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12138 /** AES GMAC Authentication */
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_AES_GMAC_authentication_test_case_1),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_AES_GMAC_authentication_verify_test_case_1),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_AES_GMAC_authentication_test_case_2),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_AES_GMAC_authentication_verify_test_case_2),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_AES_GMAC_authentication_test_case_3),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_AES_GMAC_authentication_verify_test_case_3),
12151 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12153 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12154 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12155 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
12156 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12157 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12158 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12159 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_AES_CCM_authenticated_encryption_test_case_128_1),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_AES_CCM_authenticated_decryption_test_case_128_1),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_AES_CCM_authenticated_encryption_test_case_128_2),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_AES_CCM_authenticated_decryption_test_case_128_2),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_AES_CCM_authenticated_encryption_test_case_128_3),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_AES_CCM_authenticated_decryption_test_case_128_3),
12173 TEST_CASES_END() /**< NULL terminate unit test array */
12177 static struct unit_test_suite cryptodev_openssl_testsuite = {
12178 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12179 .setup = testsuite_setup,
12180 .teardown = testsuite_teardown,
12181 .unit_test_cases = {
12182 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_multi_session_random_usage),
12185 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12186 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12187 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12188 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12189 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12190 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12191 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12193 /** AES GCM Authenticated Encryption */
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_AES_GCM_authenticated_encryption_test_case_1),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_AES_GCM_authenticated_encryption_test_case_2),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_AES_GCM_authenticated_encryption_test_case_3),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_AES_GCM_authenticated_encryption_test_case_4),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_AES_GCM_authenticated_encryption_test_case_5),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_AES_GCM_authenticated_encryption_test_case_6),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_AES_GCM_authenticated_encryption_test_case_7),
12209 /** AES GCM Authenticated Decryption */
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_AES_GCM_authenticated_decryption_test_case_1),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_AES_GCM_authenticated_decryption_test_case_2),
12214 TEST_CASE_ST(ut_setup, ut_teardown,
12215 test_AES_GCM_authenticated_decryption_test_case_3),
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_AES_GCM_authenticated_decryption_test_case_4),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_AES_GCM_authenticated_decryption_test_case_5),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_AES_GCM_authenticated_decryption_test_case_6),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_AES_GCM_authenticated_decryption_test_case_7),
12226 /** AES GCM Authenticated Encryption 192 bits key */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_AES_GCM_auth_encryption_test_case_192_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_AES_GCM_auth_encryption_test_case_192_2),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_AES_GCM_auth_encryption_test_case_192_3),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_auth_encryption_test_case_192_4),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_auth_encryption_test_case_192_5),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_auth_encryption_test_case_192_6),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_auth_encryption_test_case_192_7),
12242 /** AES GCM Authenticated Decryption 192 bits key */
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_auth_decryption_test_case_192_1),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_decryption_test_case_192_2),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_decryption_test_case_192_3),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_decryption_test_case_192_4),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_decryption_test_case_192_5),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_decryption_test_case_192_6),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_decryption_test_case_192_7),
12258 /** AES GCM Authenticated Encryption 256 bits key */
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_encryption_test_case_256_1),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_encryption_test_case_256_2),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_encryption_test_case_256_3),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_AES_GCM_auth_encryption_test_case_256_4),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_encryption_test_case_256_5),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_encryption_test_case_256_6),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_AES_GCM_auth_encryption_test_case_256_7),
12274 /** AES GCM Authenticated Decryption 256 bits key */
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_AES_GCM_auth_decryption_test_case_256_1),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_AES_GCM_auth_decryption_test_case_256_2),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_AES_GCM_auth_decryption_test_case_256_3),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_AES_GCM_auth_decryption_test_case_256_4),
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_AES_GCM_auth_decryption_test_case_256_5),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_AES_GCM_auth_decryption_test_case_256_6),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_AES_GCM_auth_decryption_test_case_256_7),
12290 /** AES GMAC Authentication */
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_AES_GMAC_authentication_test_case_1),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_GMAC_authentication_verify_test_case_1),
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_AES_GMAC_authentication_test_case_2),
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_AES_GMAC_authentication_verify_test_case_2),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_AES_GMAC_authentication_test_case_3),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_AES_GMAC_authentication_verify_test_case_3),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_AES_GMAC_authentication_test_case_4),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_AES_GMAC_authentication_verify_test_case_4),
12308 /** AES CCM Authenticated Encryption 128 bits key */
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_AES_CCM_authenticated_encryption_test_case_128_1),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_AES_CCM_authenticated_encryption_test_case_128_2),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_AES_CCM_authenticated_encryption_test_case_128_3),
12316 /** AES CCM Authenticated Decryption 128 bits key*/
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_AES_CCM_authenticated_decryption_test_case_128_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_AES_CCM_authenticated_decryption_test_case_128_2),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_CCM_authenticated_decryption_test_case_128_3),
12324 /** AES CCM Authenticated Encryption 192 bits key */
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_AES_CCM_authenticated_encryption_test_case_192_1),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_AES_CCM_authenticated_encryption_test_case_192_2),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_AES_CCM_authenticated_encryption_test_case_192_3),
12332 /** AES CCM Authenticated Decryption 192 bits key*/
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_AES_CCM_authenticated_decryption_test_case_192_1),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_AES_CCM_authenticated_decryption_test_case_192_2),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_AES_CCM_authenticated_decryption_test_case_192_3),
12340 /** AES CCM Authenticated Encryption 256 bits key */
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_AES_CCM_authenticated_encryption_test_case_256_1),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_AES_CCM_authenticated_encryption_test_case_256_2),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_AES_CCM_authenticated_encryption_test_case_256_3),
12348 /** AES CCM Authenticated Decryption 256 bits key*/
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_AES_CCM_authenticated_decryption_test_case_256_1),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_AES_CCM_authenticated_decryption_test_case_256_2),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_AES_CCM_authenticated_decryption_test_case_256_3),
12356 /** Scatter-Gather */
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12360 /** Negative tests */
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 authentication_verify_AES128_GMAC_fail_data_corrupt),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12381 TEST_CASES_END() /**< NULL terminate unit test array */
12385 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12386 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12387 .setup = testsuite_setup,
12388 .teardown = testsuite_teardown,
12389 .unit_test_cases = {
12390 /** AES GCM Authenticated Encryption */
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_AES_GCM_authenticated_encryption_test_case_1),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_authenticated_encryption_test_case_2),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_authenticated_encryption_test_case_3),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_AES_GCM_authenticated_encryption_test_case_4),
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_AES_GCM_authenticated_encryption_test_case_5),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_authenticated_encryption_test_case_6),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_AES_GCM_authenticated_encryption_test_case_7),
12406 /** AES GCM Authenticated Decryption */
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_AES_GCM_authenticated_decryption_test_case_1),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_AES_GCM_authenticated_decryption_test_case_2),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_AES_GCM_authenticated_decryption_test_case_3),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_AES_GCM_authenticated_decryption_test_case_4),
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_AES_GCM_authenticated_decryption_test_case_5),
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_AES_GCM_authenticated_decryption_test_case_6),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_AES_GCM_authenticated_decryption_test_case_7),
12422 /** AES GCM Authenticated Encryption 192 bits key */
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_encryption_test_case_192_1),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_encryption_test_case_192_2),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GCM_auth_encryption_test_case_192_3),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GCM_auth_encryption_test_case_192_4),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_auth_encryption_test_case_192_5),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GCM_auth_encryption_test_case_192_6),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GCM_auth_encryption_test_case_192_7),
12438 /** AES GCM Authenticated Decryption 192 bits key */
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_auth_decryption_test_case_192_1),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_auth_decryption_test_case_192_2),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GCM_auth_decryption_test_case_192_3),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_AES_GCM_auth_decryption_test_case_192_4),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_AES_GCM_auth_decryption_test_case_192_5),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_AES_GCM_auth_decryption_test_case_192_6),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_AES_GCM_auth_decryption_test_case_192_7),
12454 /** AES GCM Authenticated Encryption 256 bits key */
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_AES_GCM_auth_encryption_test_case_256_1),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_AES_GCM_auth_encryption_test_case_256_2),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_GCM_auth_encryption_test_case_256_3),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_AES_GCM_auth_encryption_test_case_256_4),
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_AES_GCM_auth_encryption_test_case_256_5),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_AES_GCM_auth_encryption_test_case_256_6),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_AES_GCM_auth_encryption_test_case_256_7),
12470 /** AES GCM Authenticated Decryption 256 bits key */
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_GCM_auth_decryption_test_case_256_1),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_AES_GCM_auth_decryption_test_case_256_2),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_AES_GCM_auth_decryption_test_case_256_3),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_AES_GCM_auth_decryption_test_case_256_4),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_AES_GCM_auth_decryption_test_case_256_5),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_AES_GCM_auth_decryption_test_case_256_6),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_AES_GCM_auth_decryption_test_case_256_7),
12486 /** AES GCM Authenticated Encryption big aad size */
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_AES_GCM_auth_encryption_test_case_aad_1),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_AES_GCM_auth_encryption_test_case_aad_2),
12492 /** AES GCM Authenticated Decryption big aad size */
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_AES_GCM_auth_decryption_test_case_aad_1),
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 test_AES_GCM_auth_decryption_test_case_aad_2),
12498 /** AES GMAC Authentication */
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_AES_GMAC_authentication_test_case_1),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_AES_GMAC_authentication_verify_test_case_1),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_GMAC_authentication_test_case_3),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_AES_GMAC_authentication_verify_test_case_3),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_GMAC_authentication_test_case_4),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_AES_GMAC_authentication_verify_test_case_4),
12512 /** Negative tests */
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 authentication_verify_AES128_GMAC_fail_data_corrupt),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12518 /** Out of place tests */
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12524 /** Session-less tests */
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12530 /** Scatter-Gather */
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12536 TEST_CASES_END() /**< NULL terminate unit test array */
12540 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12541 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12542 .setup = testsuite_setup,
12543 .teardown = testsuite_teardown,
12544 .unit_test_cases = {
12545 /** KASUMI encrypt only (UEA1) */
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_kasumi_encryption_test_case_1),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_kasumi_encryption_test_case_1_sgl),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_kasumi_encryption_test_case_2),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_kasumi_encryption_test_case_3),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_kasumi_encryption_test_case_4),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_kasumi_encryption_test_case_5),
12558 /** KASUMI decrypt only (UEA1) */
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_kasumi_decryption_test_case_1),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_kasumi_decryption_test_case_2),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 test_kasumi_decryption_test_case_3),
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_kasumi_decryption_test_case_4),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_kasumi_decryption_test_case_5),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_kasumi_encryption_test_case_1_oop),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_kasumi_encryption_test_case_1_oop_sgl),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_kasumi_decryption_test_case_1_oop),
12579 /** KASUMI hash only (UIA1) */
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_kasumi_hash_generate_test_case_1),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_kasumi_hash_generate_test_case_2),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_kasumi_hash_generate_test_case_3),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_kasumi_hash_generate_test_case_4),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_kasumi_hash_generate_test_case_5),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_kasumi_hash_generate_test_case_6),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_kasumi_hash_verify_test_case_1),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_kasumi_hash_verify_test_case_2),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_kasumi_hash_verify_test_case_3),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_kasumi_hash_verify_test_case_4),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_kasumi_hash_verify_test_case_5),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_kasumi_cipher_auth_test_case_1),
12605 /** KASUMI generate auth, then encrypt (F8) */
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_kasumi_auth_cipher_test_case_1),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_kasumi_auth_cipher_test_case_2),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_kasumi_auth_cipher_test_case_2_oop),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_kasumi_auth_cipher_test_case_2_sgl),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12617 /** KASUMI decrypt (F8), then verify auth */
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_kasumi_auth_cipher_verify_test_case_1),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_kasumi_auth_cipher_verify_test_case_2),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_kasumi_auth_cipher_verify_test_case_2_oop),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12628 TEST_CASES_END() /**< NULL terminate unit test array */
12631 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12632 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12633 .setup = testsuite_setup,
12634 .teardown = testsuite_teardown,
12635 .unit_test_cases = {
12636 /** SNOW 3G encrypt only (UEA2) */
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_snow3g_encryption_test_case_1),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_snow3g_encryption_test_case_2),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_snow3g_encryption_test_case_3),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_snow3g_encryption_test_case_4),
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_snow3g_encryption_test_case_5),
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_snow3g_auth_cipher_with_digest_test_case_1),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_snow3g_encryption_test_case_1_oop),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_snow3g_encryption_test_case_1_oop_sgl),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_snow3g_decryption_test_case_1_oop),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_snow3g_encryption_test_case_1_offset_oop),
12660 /** SNOW 3G decrypt only (UEA2) */
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_snow3g_decryption_test_case_1),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_snow3g_decryption_test_case_2),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_snow3g_decryption_test_case_3),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 test_snow3g_decryption_test_case_4),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_snow3g_decryption_test_case_5),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_snow3g_decryption_with_digest_test_case_1),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_snow3g_hash_generate_test_case_1),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_snow3g_hash_generate_test_case_2),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_snow3g_hash_generate_test_case_3),
12679 /* Tests with buffers which length is not byte-aligned */
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_snow3g_hash_generate_test_case_4),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_snow3g_hash_generate_test_case_5),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_snow3g_hash_generate_test_case_6),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_snow3g_hash_verify_test_case_1),
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_snow3g_hash_verify_test_case_2),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_snow3g_hash_verify_test_case_3),
12692 /* Tests with buffers which length is not byte-aligned */
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_snow3g_hash_verify_test_case_4),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_snow3g_hash_verify_test_case_5),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_snow3g_hash_verify_test_case_6),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_snow3g_cipher_auth_test_case_1),
12702 /** SNOW 3G generate auth, then encrypt (UEA2) */
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_snow3g_auth_cipher_test_case_1),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_snow3g_auth_cipher_test_case_2),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_snow3g_auth_cipher_test_case_2_oop),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_snow3g_auth_cipher_part_digest_enc),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_snow3g_auth_cipher_part_digest_enc_oop),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_snow3g_auth_cipher_test_case_3_sgl),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_snow3g_auth_cipher_part_digest_enc_sgl),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12722 /** SNOW 3G decrypt (UEA2), then verify auth */
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_snow3g_auth_cipher_verify_test_case_1),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_snow3g_auth_cipher_verify_test_case_2),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_snow3g_auth_cipher_verify_test_case_2_oop),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_snow3g_auth_cipher_verify_part_digest_enc),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12742 TEST_CASES_END() /**< NULL terminate unit test array */
12746 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
12747 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
12748 .setup = testsuite_setup,
12749 .teardown = testsuite_teardown,
12750 .unit_test_cases = {
12751 /** ZUC encrypt only (EEA3) */
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_zuc_encryption_test_case_1),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_zuc_encryption_test_case_2),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_zuc_encryption_test_case_3),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_zuc_encryption_test_case_4),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_zuc_encryption_test_case_5),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_zuc_hash_generate_test_case_1),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_zuc_hash_generate_test_case_2),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_zuc_hash_generate_test_case_3),
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_zuc_hash_generate_test_case_4),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_zuc_hash_generate_test_case_5),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_zuc_encryption_test_case_6_sgl),
12774 TEST_CASES_END() /**< NULL terminate unit test array */
12778 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12779 .suite_name = "Crypto CAAM JR Unit Test Suite",
12780 .setup = testsuite_setup,
12781 .teardown = testsuite_teardown,
12782 .unit_test_cases = {
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_device_configure_invalid_dev_id),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_multi_session),
12788 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12789 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12790 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12791 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12792 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12794 TEST_CASES_END() /**< NULL terminate unit test array */
12798 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12799 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12800 .setup = testsuite_setup,
12801 .teardown = testsuite_teardown,
12802 .unit_test_cases = {
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_device_configure_invalid_dev_id),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_multi_session),
12808 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12809 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12810 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12811 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12812 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12814 #ifdef RTE_LIBRTE_SECURITY
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_PDCP_PROTO_cplane_encap_all),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_PDCP_PROTO_cplane_decap_all),
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 test_PDCP_PROTO_uplane_encap_all),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_PDCP_PROTO_uplane_decap_all),
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_PDCP_PROTO_SGL_in_place_32B),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_PDCP_PROTO_SGL_oop_32B_128B),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_PDCP_PROTO_SGL_oop_32B_40B),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_PDCP_PROTO_SGL_oop_128B_32B),
12836 /** AES GCM Authenticated Encryption */
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_AES_GCM_authenticated_encryption_test_case_1),
12847 TEST_CASE_ST(ut_setup, ut_teardown,
12848 test_AES_GCM_authenticated_encryption_test_case_2),
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_AES_GCM_authenticated_encryption_test_case_3),
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_AES_GCM_authenticated_encryption_test_case_4),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_AES_GCM_authenticated_encryption_test_case_5),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_AES_GCM_authenticated_encryption_test_case_6),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_AES_GCM_authenticated_encryption_test_case_7),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_AES_GCM_authenticated_encryption_test_case_8),
12862 /** AES GCM Authenticated Decryption */
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_AES_GCM_authenticated_decryption_test_case_1),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_AES_GCM_authenticated_decryption_test_case_2),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_AES_GCM_authenticated_decryption_test_case_3),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_AES_GCM_authenticated_decryption_test_case_4),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_AES_GCM_authenticated_decryption_test_case_5),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_AES_GCM_authenticated_decryption_test_case_6),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_AES_GCM_authenticated_decryption_test_case_7),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_AES_GCM_authenticated_decryption_test_case_8),
12880 /** AES GCM Authenticated Encryption 192 bits key */
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_AES_GCM_auth_encryption_test_case_192_1),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_AES_GCM_auth_encryption_test_case_192_2),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_AES_GCM_auth_encryption_test_case_192_3),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_AES_GCM_auth_encryption_test_case_192_4),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_AES_GCM_auth_encryption_test_case_192_5),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_AES_GCM_auth_encryption_test_case_192_6),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_AES_GCM_auth_encryption_test_case_192_7),
12896 /** AES GCM Authenticated Decryption 192 bits key */
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_AES_GCM_auth_decryption_test_case_192_1),
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_AES_GCM_auth_decryption_test_case_192_2),
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 test_AES_GCM_auth_decryption_test_case_192_3),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_AES_GCM_auth_decryption_test_case_192_4),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_AES_GCM_auth_decryption_test_case_192_5),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_AES_GCM_auth_decryption_test_case_192_6),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_AES_GCM_auth_decryption_test_case_192_7),
12912 /** AES GCM Authenticated Encryption 256 bits key */
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_AES_GCM_auth_encryption_test_case_256_1),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GCM_auth_encryption_test_case_256_2),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GCM_auth_encryption_test_case_256_3),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GCM_auth_encryption_test_case_256_4),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GCM_auth_encryption_test_case_256_5),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GCM_auth_encryption_test_case_256_6),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 test_AES_GCM_auth_encryption_test_case_256_7),
12928 /** AES GCM Authenticated Decryption 256 bits key */
12929 TEST_CASE_ST(ut_setup, ut_teardown,
12930 test_AES_GCM_auth_decryption_test_case_256_1),
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 test_AES_GCM_auth_decryption_test_case_256_2),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_AES_GCM_auth_decryption_test_case_256_3),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 test_AES_GCM_auth_decryption_test_case_256_4),
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 test_AES_GCM_auth_decryption_test_case_256_5),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_AES_GCM_auth_decryption_test_case_256_6),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_AES_GCM_auth_decryption_test_case_256_7),
12944 /** Out of place tests */
12945 TEST_CASE_ST(ut_setup, ut_teardown,
12946 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12950 /** SNOW 3G encrypt only (UEA2) */
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_snow3g_encryption_test_case_1),
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_snow3g_encryption_test_case_2),
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 test_snow3g_encryption_test_case_3),
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_snow3g_encryption_test_case_4),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_snow3g_encryption_test_case_5),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_snow3g_encryption_test_case_1_oop),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_snow3g_encryption_test_case_1_oop_sgl),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_snow3g_decryption_test_case_1_oop),
12969 /** SNOW 3G decrypt only (UEA2) */
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_snow3g_decryption_test_case_1),
12972 TEST_CASE_ST(ut_setup, ut_teardown,
12973 test_snow3g_decryption_test_case_2),
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 test_snow3g_decryption_test_case_3),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_snow3g_decryption_test_case_4),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_snow3g_decryption_test_case_5),
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 test_snow3g_hash_generate_test_case_1),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 test_snow3g_hash_generate_test_case_2),
12985 TEST_CASE_ST(ut_setup, ut_teardown,
12986 test_snow3g_hash_generate_test_case_3),
12987 TEST_CASE_ST(ut_setup, ut_teardown,
12988 test_snow3g_hash_verify_test_case_1),
12989 TEST_CASE_ST(ut_setup, ut_teardown,
12990 test_snow3g_hash_verify_test_case_2),
12991 TEST_CASE_ST(ut_setup, ut_teardown,
12992 test_snow3g_hash_verify_test_case_3),
12994 /** ZUC encrypt only (EEA3) */
12995 TEST_CASE_ST(ut_setup, ut_teardown,
12996 test_zuc_encryption_test_case_1),
12997 TEST_CASE_ST(ut_setup, ut_teardown,
12998 test_zuc_encryption_test_case_2),
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_zuc_encryption_test_case_3),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_zuc_encryption_test_case_4),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_zuc_encryption_test_case_5),
13006 /** ZUC authenticate (EIA3) */
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_zuc_hash_generate_test_case_6),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_zuc_hash_generate_test_case_7),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 test_zuc_hash_generate_test_case_8),
13014 /** Negative tests */
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13027 TEST_CASE_ST(ut_setup, ut_teardown,
13028 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13039 TEST_CASE_ST(ut_setup, ut_teardown,
13040 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13049 TEST_CASE_ST(ut_setup, ut_teardown,
13050 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13054 TEST_CASES_END() /**< NULL terminate unit test array */
13058 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13059 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13060 .setup = testsuite_setup,
13061 .teardown = testsuite_teardown,
13062 .unit_test_cases = {
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_device_configure_invalid_dev_id),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_multi_session),
13067 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13068 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13069 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13070 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13071 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13073 #ifdef RTE_LIBRTE_SECURITY
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_PDCP_PROTO_cplane_encap_all),
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_PDCP_PROTO_cplane_decap_all),
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_PDCP_PROTO_uplane_encap_all),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_PDCP_PROTO_uplane_decap_all),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_PDCP_PROTO_SGL_in_place_32B),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_PDCP_PROTO_SGL_oop_32B_128B),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_PDCP_PROTO_SGL_oop_32B_40B),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_PDCP_PROTO_SGL_oop_128B_32B),
13095 /** AES GCM Authenticated Encryption */
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_AES_GCM_authenticated_encryption_test_case_1),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_AES_GCM_authenticated_encryption_test_case_2),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_AES_GCM_authenticated_encryption_test_case_3),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_AES_GCM_authenticated_encryption_test_case_4),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_AES_GCM_authenticated_encryption_test_case_5),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_AES_GCM_authenticated_encryption_test_case_6),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_AES_GCM_authenticated_encryption_test_case_7),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_AES_GCM_authenticated_encryption_test_case_8),
13121 /** AES GCM Authenticated Decryption */
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_AES_GCM_authenticated_decryption_test_case_1),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_AES_GCM_authenticated_decryption_test_case_2),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_AES_GCM_authenticated_decryption_test_case_3),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_AES_GCM_authenticated_decryption_test_case_4),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_AES_GCM_authenticated_decryption_test_case_5),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_AES_GCM_authenticated_decryption_test_case_6),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_AES_GCM_authenticated_decryption_test_case_7),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_AES_GCM_authenticated_decryption_test_case_8),
13139 /** AES GCM Authenticated Encryption 192 bits key */
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_AES_GCM_auth_encryption_test_case_192_1),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_AES_GCM_auth_encryption_test_case_192_2),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_AES_GCM_auth_encryption_test_case_192_3),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_AES_GCM_auth_encryption_test_case_192_4),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_AES_GCM_auth_encryption_test_case_192_5),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_AES_GCM_auth_encryption_test_case_192_6),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_AES_GCM_auth_encryption_test_case_192_7),
13155 /** AES GCM Authenticated Decryption 192 bits key */
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_AES_GCM_auth_decryption_test_case_192_1),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_AES_GCM_auth_decryption_test_case_192_2),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_AES_GCM_auth_decryption_test_case_192_3),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GCM_auth_decryption_test_case_192_4),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_GCM_auth_decryption_test_case_192_5),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_GCM_auth_decryption_test_case_192_6),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GCM_auth_decryption_test_case_192_7),
13171 /** AES GCM Authenticated Encryption 256 bits key */
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GCM_auth_encryption_test_case_256_1),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_AES_GCM_auth_encryption_test_case_256_2),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GCM_auth_encryption_test_case_256_3),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GCM_auth_encryption_test_case_256_4),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GCM_auth_encryption_test_case_256_5),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GCM_auth_encryption_test_case_256_6),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GCM_auth_encryption_test_case_256_7),
13187 /** AES GCM Authenticated Decryption 256 bits key */
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GCM_auth_decryption_test_case_256_1),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GCM_auth_decryption_test_case_256_2),
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 test_AES_GCM_auth_decryption_test_case_256_3),
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_AES_GCM_auth_decryption_test_case_256_4),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_AES_GCM_auth_decryption_test_case_256_5),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_AES_GCM_auth_decryption_test_case_256_6),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_AES_GCM_auth_decryption_test_case_256_7),
13203 /** Out of place tests */
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13209 /** SNOW 3G encrypt only (UEA2) */
13210 TEST_CASE_ST(ut_setup, ut_teardown,
13211 test_snow3g_encryption_test_case_1),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_snow3g_encryption_test_case_2),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 test_snow3g_encryption_test_case_3),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_snow3g_encryption_test_case_4),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_snow3g_encryption_test_case_5),
13221 TEST_CASE_ST(ut_setup, ut_teardown,
13222 test_snow3g_encryption_test_case_1_oop),
13223 TEST_CASE_ST(ut_setup, ut_teardown,
13224 test_snow3g_encryption_test_case_1_oop_sgl),
13225 TEST_CASE_ST(ut_setup, ut_teardown,
13226 test_snow3g_decryption_test_case_1_oop),
13228 /** SNOW 3G decrypt only (UEA2) */
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_snow3g_decryption_test_case_1),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_snow3g_decryption_test_case_2),
13233 TEST_CASE_ST(ut_setup, ut_teardown,
13234 test_snow3g_decryption_test_case_3),
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_snow3g_decryption_test_case_4),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_snow3g_decryption_test_case_5),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_snow3g_hash_generate_test_case_1),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_snow3g_hash_generate_test_case_2),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_snow3g_hash_generate_test_case_3),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_snow3g_hash_verify_test_case_1),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_snow3g_hash_verify_test_case_2),
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_snow3g_hash_verify_test_case_3),
13253 /** ZUC encrypt only (EEA3) */
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_zuc_encryption_test_case_1),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_zuc_encryption_test_case_2),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_zuc_encryption_test_case_3),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_zuc_encryption_test_case_4),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_zuc_encryption_test_case_5),
13265 /** ZUC authenticate (EIA3) */
13266 TEST_CASE_ST(ut_setup, ut_teardown,
13267 test_zuc_hash_generate_test_case_6),
13268 TEST_CASE_ST(ut_setup, ut_teardown,
13269 test_zuc_hash_generate_test_case_7),
13270 TEST_CASE_ST(ut_setup, ut_teardown,
13271 test_zuc_hash_generate_test_case_8),
13273 /** HMAC_MD5 Authentication */
13274 TEST_CASE_ST(ut_setup, ut_teardown,
13275 test_MD5_HMAC_generate_case_1),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_MD5_HMAC_verify_case_1),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_MD5_HMAC_generate_case_2),
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_MD5_HMAC_verify_case_2),
13283 /** Negative tests */
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13324 TEST_CASES_END() /**< NULL terminate unit test array */
13328 static struct unit_test_suite cryptodev_null_testsuite = {
13329 .suite_name = "Crypto Device NULL Unit Test Suite",
13330 .setup = testsuite_setup,
13331 .teardown = testsuite_teardown,
13332 .unit_test_cases = {
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_null_invalid_operation),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_null_burst_operation),
13337 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13338 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13339 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13341 TEST_CASES_END() /**< NULL terminate unit test array */
13345 static struct unit_test_suite cryptodev_armv8_testsuite = {
13346 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13347 .setup = testsuite_setup,
13348 .teardown = testsuite_teardown,
13349 .unit_test_cases = {
13350 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13352 /** Negative tests */
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13358 TEST_CASES_END() /**< NULL terminate unit test array */
13362 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13363 .suite_name = "Crypto Device Marvell Component Test Suite",
13364 .setup = testsuite_setup,
13365 .teardown = testsuite_teardown,
13366 .unit_test_cases = {
13367 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_multi_session_random_usage),
13370 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13371 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13372 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13373 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13374 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13376 /** Negative tests */
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13386 TEST_CASES_END() /**< NULL terminate unit test array */
13390 static struct unit_test_suite cryptodev_ccp_testsuite = {
13391 .suite_name = "Crypto Device CCP Unit Test Suite",
13392 .setup = testsuite_setup,
13393 .teardown = testsuite_teardown,
13394 .unit_test_cases = {
13395 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_multi_session_random_usage),
13398 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13399 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13400 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13401 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13402 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13404 /** Negative tests */
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13414 TEST_CASES_END() /**< NULL terminate unit test array */
13418 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13419 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13420 .setup = testsuite_setup,
13421 .teardown = testsuite_teardown,
13422 .unit_test_cases = {
13423 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13424 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13425 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13426 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13427 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13429 /** AES GCM Authenticated Encryption */
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_AES_GCM_authenticated_encryption_test_case_1),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_AES_GCM_authenticated_encryption_test_case_2),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_AES_GCM_authenticated_encryption_test_case_3),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_AES_GCM_authenticated_encryption_test_case_4),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_AES_GCM_authenticated_encryption_test_case_5),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_AES_GCM_authenticated_encryption_test_case_6),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_AES_GCM_authenticated_encryption_test_case_7),
13445 /** AES GCM Authenticated Decryption */
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_AES_GCM_authenticated_decryption_test_case_1),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_AES_GCM_authenticated_decryption_test_case_2),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_AES_GCM_authenticated_decryption_test_case_3),
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_AES_GCM_authenticated_decryption_test_case_4),
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_AES_GCM_authenticated_decryption_test_case_5),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_AES_GCM_authenticated_decryption_test_case_6),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 test_AES_GCM_authenticated_decryption_test_case_7),
13460 /** AES GMAC Authentication */
13461 TEST_CASE_ST(ut_setup, ut_teardown,
13462 test_AES_GMAC_authentication_test_case_1),
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_AES_GMAC_authentication_verify_test_case_1),
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_AES_GMAC_authentication_test_case_2),
13467 TEST_CASE_ST(ut_setup, ut_teardown,
13468 test_AES_GMAC_authentication_verify_test_case_2),
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GMAC_authentication_test_case_3),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GMAC_authentication_verify_test_case_3),
13474 /** SNOW 3G encrypt only (UEA2) */
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_snow3g_encryption_test_case_1),
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_snow3g_encryption_test_case_2),
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_snow3g_encryption_test_case_3),
13481 TEST_CASE_ST(ut_setup, ut_teardown,
13482 test_snow3g_encryption_test_case_4),
13483 TEST_CASE_ST(ut_setup, ut_teardown,
13484 test_snow3g_encryption_test_case_5),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_snow3g_encryption_test_case_1_oop),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_snow3g_decryption_test_case_1_oop),
13490 TEST_CASE_ST(ut_setup, ut_teardown,
13491 test_snow3g_encryption_test_case_1_oop_sgl),
13493 /** SNOW 3G decrypt only (UEA2) */
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 test_snow3g_decryption_test_case_1),
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_snow3g_decryption_test_case_2),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_snow3g_decryption_test_case_3),
13500 TEST_CASE_ST(ut_setup, ut_teardown,
13501 test_snow3g_decryption_test_case_4),
13502 TEST_CASE_ST(ut_setup, ut_teardown,
13503 test_snow3g_decryption_test_case_5),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_snow3g_hash_generate_test_case_1),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_snow3g_hash_generate_test_case_2),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_snow3g_hash_generate_test_case_3),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_snow3g_hash_verify_test_case_1),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_snow3g_hash_verify_test_case_2),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_snow3g_hash_verify_test_case_3),
13518 /** ZUC encrypt only (EEA3) */
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_zuc_encryption_test_case_1),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_zuc_encryption_test_case_2),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_zuc_encryption_test_case_3),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_zuc_encryption_test_case_4),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_zuc_encryption_test_case_5),
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_zuc_hash_generate_test_case_1),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_zuc_hash_generate_test_case_2),
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_zuc_hash_generate_test_case_3),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_zuc_hash_generate_test_case_4),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_zuc_hash_generate_test_case_5),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_zuc_encryption_test_case_6_sgl),
13542 /** KASUMI encrypt only (UEA1) */
13543 TEST_CASE_ST(ut_setup, ut_teardown,
13544 test_kasumi_encryption_test_case_1),
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_kasumi_encryption_test_case_2),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_kasumi_encryption_test_case_3),
13549 TEST_CASE_ST(ut_setup, ut_teardown,
13550 test_kasumi_encryption_test_case_4),
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_kasumi_encryption_test_case_5),
13553 TEST_CASE_ST(ut_setup, ut_teardown,
13554 test_kasumi_encryption_test_case_1_sgl),
13555 TEST_CASE_ST(ut_setup, ut_teardown,
13556 test_kasumi_encryption_test_case_1_oop_sgl),
13557 /** KASUMI decrypt only (UEA1) */
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_kasumi_decryption_test_case_1),
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_kasumi_decryption_test_case_2),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_kasumi_decryption_test_case_3),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_kasumi_decryption_test_case_4),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_kasumi_decryption_test_case_5),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_kasumi_encryption_test_case_1_oop),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_kasumi_decryption_test_case_1_oop),
13574 /** KASUMI hash only (UIA1) */
13575 TEST_CASE_ST(ut_setup, ut_teardown,
13576 test_kasumi_hash_generate_test_case_1),
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_kasumi_hash_generate_test_case_2),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_kasumi_hash_generate_test_case_3),
13581 TEST_CASE_ST(ut_setup, ut_teardown,
13582 test_kasumi_hash_generate_test_case_4),
13583 TEST_CASE_ST(ut_setup, ut_teardown,
13584 test_kasumi_hash_generate_test_case_5),
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_kasumi_hash_generate_test_case_6),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_kasumi_hash_verify_test_case_1),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_kasumi_hash_verify_test_case_2),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_kasumi_hash_verify_test_case_3),
13593 TEST_CASE_ST(ut_setup, ut_teardown,
13594 test_kasumi_hash_verify_test_case_4),
13595 TEST_CASE_ST(ut_setup, ut_teardown,
13596 test_kasumi_hash_verify_test_case_5),
13599 TEST_CASE_ST(ut_setup, ut_teardown,
13600 test_null_cipher_only_operation),
13601 TEST_CASE_ST(ut_setup, ut_teardown,
13602 test_null_auth_only_operation),
13603 TEST_CASE_ST(ut_setup, ut_teardown,
13604 test_null_cipher_auth_operation),
13605 TEST_CASE_ST(ut_setup, ut_teardown,
13606 test_null_auth_cipher_operation),
13608 /** Negative tests */
13609 TEST_CASE_ST(ut_setup, ut_teardown,
13610 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13611 TEST_CASE_ST(ut_setup, ut_teardown,
13612 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 authentication_verify_AES128_GMAC_fail_data_corrupt),
13615 TEST_CASE_ST(ut_setup, ut_teardown,
13616 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13621 TEST_CASES_END() /**< NULL terminate unit test array */
13625 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13626 .suite_name = "Crypto NITROX Unit Test Suite",
13627 .setup = testsuite_setup,
13628 .teardown = testsuite_teardown,
13629 .unit_test_cases = {
13630 TEST_CASE_ST(ut_setup, ut_teardown,
13631 test_device_configure_invalid_dev_id),
13632 TEST_CASE_ST(ut_setup, ut_teardown,
13633 test_device_configure_invalid_queue_pair_ids),
13634 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13636 TEST_CASES_END() /**< NULL terminate unit test array */
13640 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13641 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13642 .setup = testsuite_setup,
13643 .teardown = testsuite_teardown,
13644 .unit_test_cases = {
13645 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13646 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13647 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13648 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13649 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13651 /** AES GCM Authenticated Encryption */
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_AES_GCM_authenticated_encryption_test_case_1),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_AES_GCM_authenticated_encryption_test_case_2),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_AES_GCM_authenticated_encryption_test_case_3),
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_AES_GCM_authenticated_encryption_test_case_4),
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_AES_GCM_authenticated_encryption_test_case_5),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_AES_GCM_authenticated_encryption_test_case_6),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_AES_GCM_authenticated_encryption_test_case_7),
13667 /** AES GCM Authenticated Decryption */
13668 TEST_CASE_ST(ut_setup, ut_teardown,
13669 test_AES_GCM_authenticated_decryption_test_case_1),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_AES_GCM_authenticated_decryption_test_case_2),
13672 TEST_CASE_ST(ut_setup, ut_teardown,
13673 test_AES_GCM_authenticated_decryption_test_case_3),
13674 TEST_CASE_ST(ut_setup, ut_teardown,
13675 test_AES_GCM_authenticated_decryption_test_case_4),
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 test_AES_GCM_authenticated_decryption_test_case_5),
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 test_AES_GCM_authenticated_decryption_test_case_6),
13680 TEST_CASE_ST(ut_setup, ut_teardown,
13681 test_AES_GCM_authenticated_decryption_test_case_7),
13682 /** AES GMAC Authentication */
13683 TEST_CASE_ST(ut_setup, ut_teardown,
13684 test_AES_GMAC_authentication_test_case_1),
13685 TEST_CASE_ST(ut_setup, ut_teardown,
13686 test_AES_GMAC_authentication_verify_test_case_1),
13687 TEST_CASE_ST(ut_setup, ut_teardown,
13688 test_AES_GMAC_authentication_test_case_2),
13689 TEST_CASE_ST(ut_setup, ut_teardown,
13690 test_AES_GMAC_authentication_verify_test_case_2),
13691 TEST_CASE_ST(ut_setup, ut_teardown,
13692 test_AES_GMAC_authentication_test_case_3),
13693 TEST_CASE_ST(ut_setup, ut_teardown,
13694 test_AES_GMAC_authentication_verify_test_case_3),
13696 /** SNOW 3G encrypt only (UEA2) */
13697 TEST_CASE_ST(ut_setup, ut_teardown,
13698 test_snow3g_encryption_test_case_1),
13699 TEST_CASE_ST(ut_setup, ut_teardown,
13700 test_snow3g_encryption_test_case_2),
13701 TEST_CASE_ST(ut_setup, ut_teardown,
13702 test_snow3g_encryption_test_case_3),
13703 TEST_CASE_ST(ut_setup, ut_teardown,
13704 test_snow3g_encryption_test_case_4),
13705 TEST_CASE_ST(ut_setup, ut_teardown,
13706 test_snow3g_encryption_test_case_5),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 test_snow3g_encryption_test_case_1_oop),
13710 TEST_CASE_ST(ut_setup, ut_teardown,
13711 test_snow3g_decryption_test_case_1_oop),
13712 TEST_CASE_ST(ut_setup, ut_teardown,
13713 test_snow3g_encryption_test_case_1_oop_sgl),
13715 /** SNOW 3G decrypt only (UEA2) */
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 test_snow3g_decryption_test_case_1),
13718 TEST_CASE_ST(ut_setup, ut_teardown,
13719 test_snow3g_decryption_test_case_2),
13720 TEST_CASE_ST(ut_setup, ut_teardown,
13721 test_snow3g_decryption_test_case_3),
13722 TEST_CASE_ST(ut_setup, ut_teardown,
13723 test_snow3g_decryption_test_case_4),
13724 TEST_CASE_ST(ut_setup, ut_teardown,
13725 test_snow3g_decryption_test_case_5),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_snow3g_hash_generate_test_case_1),
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_snow3g_hash_generate_test_case_2),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_snow3g_hash_generate_test_case_3),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_snow3g_hash_verify_test_case_1),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_snow3g_hash_verify_test_case_2),
13737 TEST_CASE_ST(ut_setup, ut_teardown,
13738 test_snow3g_hash_verify_test_case_3),
13740 /** ZUC encrypt only (EEA3) */
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 test_zuc_encryption_test_case_1),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 test_zuc_encryption_test_case_2),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 test_zuc_encryption_test_case_3),
13747 TEST_CASE_ST(ut_setup, ut_teardown,
13748 test_zuc_encryption_test_case_4),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_zuc_encryption_test_case_5),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_zuc_hash_generate_test_case_1),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 test_zuc_hash_generate_test_case_2),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_zuc_hash_generate_test_case_3),
13757 TEST_CASE_ST(ut_setup, ut_teardown,
13758 test_zuc_hash_generate_test_case_4),
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_zuc_hash_generate_test_case_5),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_zuc_encryption_test_case_6_sgl),
13764 /** KASUMI encrypt only (UEA1) */
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_kasumi_encryption_test_case_1),
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_kasumi_encryption_test_case_2),
13769 TEST_CASE_ST(ut_setup, ut_teardown,
13770 test_kasumi_encryption_test_case_3),
13771 TEST_CASE_ST(ut_setup, ut_teardown,
13772 test_kasumi_encryption_test_case_4),
13773 TEST_CASE_ST(ut_setup, ut_teardown,
13774 test_kasumi_encryption_test_case_5),
13775 TEST_CASE_ST(ut_setup, ut_teardown,
13776 test_kasumi_encryption_test_case_1_sgl),
13777 TEST_CASE_ST(ut_setup, ut_teardown,
13778 test_kasumi_encryption_test_case_1_oop_sgl),
13779 /** KASUMI decrypt only (UEA1) */
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_kasumi_decryption_test_case_1),
13782 TEST_CASE_ST(ut_setup, ut_teardown,
13783 test_kasumi_decryption_test_case_2),
13784 TEST_CASE_ST(ut_setup, ut_teardown,
13785 test_kasumi_decryption_test_case_3),
13786 TEST_CASE_ST(ut_setup, ut_teardown,
13787 test_kasumi_decryption_test_case_4),
13788 TEST_CASE_ST(ut_setup, ut_teardown,
13789 test_kasumi_decryption_test_case_5),
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_kasumi_encryption_test_case_1_oop),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_kasumi_decryption_test_case_1_oop),
13796 /** KASUMI hash only (UIA1) */
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_kasumi_hash_generate_test_case_1),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_kasumi_hash_generate_test_case_2),
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_kasumi_hash_generate_test_case_3),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_kasumi_hash_generate_test_case_4),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_kasumi_hash_generate_test_case_5),
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_kasumi_hash_generate_test_case_6),
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_kasumi_hash_verify_test_case_1),
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_kasumi_hash_verify_test_case_2),
13813 TEST_CASE_ST(ut_setup, ut_teardown,
13814 test_kasumi_hash_verify_test_case_3),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_kasumi_hash_verify_test_case_4),
13817 TEST_CASE_ST(ut_setup, ut_teardown,
13818 test_kasumi_hash_verify_test_case_5),
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 test_null_cipher_only_operation),
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_null_auth_only_operation),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_null_cipher_auth_operation),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_null_auth_cipher_operation),
13830 /** Negative tests */
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 authentication_verify_AES128_GMAC_fail_data_corrupt),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13843 TEST_CASES_END() /**< NULL terminate unit test array */
13848 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13850 gbl_driver_id = rte_cryptodev_driver_id_get(
13851 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13853 if (gbl_driver_id == -1) {
13854 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13855 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13856 "are enabled in config file to run this testsuite.\n");
13857 return TEST_SKIPPED;
13860 return unit_test_suite_runner(&cryptodev_qat_testsuite);
13864 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13866 gbl_driver_id = rte_cryptodev_driver_id_get(
13867 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13869 if (gbl_driver_id == -1) {
13870 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13871 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13872 "in config file to run this testsuite.\n");
13873 return TEST_FAILED;
13876 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13880 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13882 gbl_driver_id = rte_cryptodev_driver_id_get(
13883 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13885 if (gbl_driver_id == -1) {
13886 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13887 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13888 "in config file to run this testsuite.\n");
13889 return TEST_SKIPPED;
13892 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
13896 test_cryptodev_openssl(void)
13898 gbl_driver_id = rte_cryptodev_driver_id_get(
13899 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13901 if (gbl_driver_id == -1) {
13902 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13903 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13904 "in config file to run this testsuite.\n");
13905 return TEST_SKIPPED;
13908 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
13912 test_cryptodev_aesni_gcm(void)
13914 gbl_driver_id = rte_cryptodev_driver_id_get(
13915 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13917 if (gbl_driver_id == -1) {
13918 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13919 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13920 "in config file to run this testsuite.\n");
13921 return TEST_SKIPPED;
13924 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
13928 test_cryptodev_null(void)
13930 gbl_driver_id = rte_cryptodev_driver_id_get(
13931 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13933 if (gbl_driver_id == -1) {
13934 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13935 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13936 "in config file to run this testsuite.\n");
13937 return TEST_SKIPPED;
13940 return unit_test_suite_runner(&cryptodev_null_testsuite);
13944 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13946 gbl_driver_id = rte_cryptodev_driver_id_get(
13947 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13949 if (gbl_driver_id == -1) {
13950 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13951 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13952 "in config file to run this testsuite.\n");
13953 return TEST_SKIPPED;
13956 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
13960 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13962 gbl_driver_id = rte_cryptodev_driver_id_get(
13963 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13965 if (gbl_driver_id == -1) {
13966 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13967 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13968 "in config file to run this testsuite.\n");
13969 return TEST_SKIPPED;
13972 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
13976 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13978 gbl_driver_id = rte_cryptodev_driver_id_get(
13979 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13981 if (gbl_driver_id == -1) {
13982 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13983 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13984 "in config file to run this testsuite.\n");
13985 return TEST_SKIPPED;
13988 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
13992 test_cryptodev_armv8(void)
13994 gbl_driver_id = rte_cryptodev_driver_id_get(
13995 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13997 if (gbl_driver_id == -1) {
13998 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13999 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14000 "in config file to run this testsuite.\n");
14001 return TEST_SKIPPED;
14004 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14008 test_cryptodev_mrvl(void)
14010 gbl_driver_id = rte_cryptodev_driver_id_get(
14011 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14013 if (gbl_driver_id == -1) {
14014 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14015 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14016 "in config file to run this testsuite.\n");
14017 return TEST_SKIPPED;
14020 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14023 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14026 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14028 gbl_driver_id = rte_cryptodev_driver_id_get(
14029 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14031 if (gbl_driver_id == -1) {
14032 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14033 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14034 "in config file to run this testsuite.\n");
14035 return TEST_SKIPPED;
14038 if (rte_cryptodev_driver_id_get(
14039 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14040 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14041 " enabled in config file to run this testsuite.\n");
14042 return TEST_SKIPPED;
14044 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14047 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14052 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14054 gbl_driver_id = rte_cryptodev_driver_id_get(
14055 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14057 if (gbl_driver_id == -1) {
14058 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14059 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14060 "in config file to run this testsuite.\n");
14061 return TEST_SKIPPED;
14064 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14068 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14070 gbl_driver_id = rte_cryptodev_driver_id_get(
14071 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14073 if (gbl_driver_id == -1) {
14074 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14075 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14076 "in config file to run this testsuite.\n");
14077 return TEST_SKIPPED;
14080 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14084 test_cryptodev_ccp(void)
14086 gbl_driver_id = rte_cryptodev_driver_id_get(
14087 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14089 if (gbl_driver_id == -1) {
14090 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14091 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14092 "in config file to run this testsuite.\n");
14093 return TEST_FAILED;
14096 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14100 test_cryptodev_octeontx(void)
14102 gbl_driver_id = rte_cryptodev_driver_id_get(
14103 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14104 if (gbl_driver_id == -1) {
14105 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14106 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14107 "enabled in config file to run this "
14109 return TEST_FAILED;
14111 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14115 test_cryptodev_octeontx2(void)
14117 gbl_driver_id = rte_cryptodev_driver_id_get(
14118 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14119 if (gbl_driver_id == -1) {
14120 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14121 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14122 "enabled in config file to run this "
14124 return TEST_FAILED;
14126 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14130 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14132 gbl_driver_id = rte_cryptodev_driver_id_get(
14133 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14135 if (gbl_driver_id == -1) {
14136 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14137 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14138 "in config file to run this testsuite.\n");
14139 return TEST_FAILED;
14142 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14146 test_cryptodev_nitrox(void)
14148 gbl_driver_id = rte_cryptodev_driver_id_get(
14149 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14151 if (gbl_driver_id == -1) {
14152 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14153 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14154 "in config file to run this testsuite.\n");
14155 return TEST_FAILED;
14158 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14161 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14162 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14163 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14164 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14165 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14166 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14167 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14168 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14169 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14170 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14171 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14172 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14173 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14174 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14175 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14176 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14177 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14178 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);