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 (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5075 printf("Device doesn't support digest encrypted.\n");
5079 /* Create ZUC session */
5080 retval = create_wireless_algo_auth_cipher_session(
5081 ts_params->valid_devs[0],
5082 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5083 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5084 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5085 : RTE_CRYPTO_AUTH_OP_GENERATE),
5086 RTE_CRYPTO_AUTH_ZUC_EIA3,
5087 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5088 tdata->key.data, tdata->key.len,
5089 tdata->auth_iv.len, tdata->digest.len,
5090 tdata->cipher_iv.len);
5095 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5096 if (op_mode == OUT_OF_PLACE)
5097 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5099 /* clear mbuf payload */
5100 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5101 rte_pktmbuf_tailroom(ut_params->ibuf));
5102 if (op_mode == OUT_OF_PLACE)
5103 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5104 rte_pktmbuf_tailroom(ut_params->obuf));
5106 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5107 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5108 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5109 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5112 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5113 ciphertext_pad_len);
5114 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5115 if (op_mode == OUT_OF_PLACE)
5116 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5117 debug_hexdump(stdout, "ciphertext:", ciphertext,
5120 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5122 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5123 if (op_mode == OUT_OF_PLACE)
5124 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5125 debug_hexdump(stdout, "plaintext:", plaintext,
5129 /* Create ZUC operation */
5130 retval = create_wireless_algo_auth_cipher_operation(
5131 tdata->digest.data, tdata->digest.len,
5132 tdata->cipher_iv.data, tdata->cipher_iv.len,
5133 tdata->auth_iv.data, tdata->auth_iv.len,
5134 (tdata->digest.offset_bytes == 0 ?
5135 (verify ? ciphertext_pad_len : plaintext_pad_len)
5136 : tdata->digest.offset_bytes),
5137 tdata->validCipherLenInBits.len,
5138 tdata->validCipherOffsetInBits.len,
5139 tdata->validAuthLenInBits.len,
5141 op_mode, 0, verify);
5146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5149 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5151 ut_params->obuf = (op_mode == IN_PLACE ?
5152 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5156 if (ut_params->obuf)
5157 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5160 plaintext = ciphertext;
5162 debug_hexdump(stdout, "plaintext:", plaintext,
5163 (tdata->plaintext.len >> 3) - tdata->digest.len);
5164 debug_hexdump(stdout, "plaintext expected:",
5165 tdata->plaintext.data,
5166 (tdata->plaintext.len >> 3) - tdata->digest.len);
5168 if (ut_params->obuf)
5169 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5172 ciphertext = plaintext;
5174 debug_hexdump(stdout, "ciphertext:", ciphertext,
5176 debug_hexdump(stdout, "ciphertext expected:",
5177 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5179 ut_params->digest = rte_pktmbuf_mtod(
5180 ut_params->obuf, uint8_t *) +
5181 (tdata->digest.offset_bytes == 0 ?
5182 plaintext_pad_len : tdata->digest.offset_bytes);
5184 debug_hexdump(stdout, "digest:", ut_params->digest,
5186 debug_hexdump(stdout, "digest expected:",
5187 tdata->digest.data, tdata->digest.len);
5192 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5194 tdata->plaintext.data,
5195 tdata->plaintext.len >> 3,
5196 "ZUC Plaintext data not as expected");
5198 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5200 tdata->ciphertext.data,
5201 tdata->ciphertext.len >> 3,
5202 "ZUC Ciphertext data not as expected");
5204 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5207 DIGEST_BYTE_LENGTH_KASUMI_F9,
5208 "ZUC Generated auth tag not as expected");
5214 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5215 uint8_t op_mode, uint8_t verify)
5217 struct crypto_testsuite_params *ts_params = &testsuite_params;
5218 struct crypto_unittest_params *ut_params = &unittest_params;
5222 const uint8_t *plaintext = NULL;
5223 const uint8_t *ciphertext = NULL;
5224 const uint8_t *digest = NULL;
5225 unsigned int plaintext_pad_len;
5226 unsigned int plaintext_len;
5227 unsigned int ciphertext_pad_len;
5228 unsigned int ciphertext_len;
5229 uint8_t buffer[10000];
5230 uint8_t digest_buffer[10000];
5232 struct rte_cryptodev_info dev_info;
5233 struct rte_cryptodev_sym_capability_idx cap_idx;
5235 /* Check if device supports ZUC EIA3 */
5236 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5237 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5243 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5245 uint64_t feat_flags = dev_info.feature_flags;
5247 if (op_mode == IN_PLACE) {
5248 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5249 printf("Device doesn't support in-place scatter-gather "
5250 "in both input and output mbufs.\n");
5254 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5255 printf("Device doesn't support out-of-place scatter-gather "
5256 "in both input and output mbufs.\n");
5259 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5260 printf("Device doesn't support digest encrypted.\n");
5265 /* Create ZUC session */
5266 retval = create_wireless_algo_auth_cipher_session(
5267 ts_params->valid_devs[0],
5268 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5269 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5270 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5271 : RTE_CRYPTO_AUTH_OP_GENERATE),
5272 RTE_CRYPTO_AUTH_ZUC_EIA3,
5273 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5274 tdata->key.data, tdata->key.len,
5275 tdata->auth_iv.len, tdata->digest.len,
5276 tdata->cipher_iv.len);
5281 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5282 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5283 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5284 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5286 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5287 plaintext_pad_len, 15, 0);
5288 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5289 "Failed to allocate input buffer in mempool");
5291 if (op_mode == OUT_OF_PLACE) {
5292 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5293 plaintext_pad_len, 15, 0);
5294 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5295 "Failed to allocate output buffer in mempool");
5299 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5300 tdata->ciphertext.data);
5301 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5302 ciphertext_len, buffer);
5303 debug_hexdump(stdout, "ciphertext:", ciphertext,
5306 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5307 tdata->plaintext.data);
5308 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5309 plaintext_len, buffer);
5310 debug_hexdump(stdout, "plaintext:", plaintext,
5313 memset(buffer, 0, sizeof(buffer));
5315 /* Create ZUC operation */
5316 retval = create_wireless_algo_auth_cipher_operation(
5317 tdata->digest.data, tdata->digest.len,
5318 tdata->cipher_iv.data, tdata->cipher_iv.len,
5320 (tdata->digest.offset_bytes == 0 ?
5321 (verify ? ciphertext_pad_len : plaintext_pad_len)
5322 : tdata->digest.offset_bytes),
5323 tdata->validCipherLenInBits.len,
5324 tdata->validCipherOffsetInBits.len,
5325 tdata->validAuthLenInBits.len,
5327 op_mode, 1, verify);
5332 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5335 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5337 ut_params->obuf = (op_mode == IN_PLACE ?
5338 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5341 if (ut_params->obuf)
5342 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5343 plaintext_len, buffer);
5345 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5346 plaintext_len, buffer);
5348 debug_hexdump(stdout, "plaintext:", plaintext,
5349 (tdata->plaintext.len >> 3) - tdata->digest.len);
5350 debug_hexdump(stdout, "plaintext expected:",
5351 tdata->plaintext.data,
5352 (tdata->plaintext.len >> 3) - tdata->digest.len);
5354 if (ut_params->obuf)
5355 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5356 ciphertext_len, buffer);
5358 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5359 ciphertext_len, buffer);
5361 debug_hexdump(stdout, "ciphertext:", ciphertext,
5363 debug_hexdump(stdout, "ciphertext expected:",
5364 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5366 if (ut_params->obuf)
5367 digest = rte_pktmbuf_read(ut_params->obuf,
5368 (tdata->digest.offset_bytes == 0 ?
5369 plaintext_pad_len : tdata->digest.offset_bytes),
5370 tdata->digest.len, digest_buffer);
5372 digest = rte_pktmbuf_read(ut_params->ibuf,
5373 (tdata->digest.offset_bytes == 0 ?
5374 plaintext_pad_len : tdata->digest.offset_bytes),
5375 tdata->digest.len, digest_buffer);
5377 debug_hexdump(stdout, "digest:", digest,
5379 debug_hexdump(stdout, "digest expected:",
5380 tdata->digest.data, tdata->digest.len);
5385 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5387 tdata->plaintext.data,
5388 tdata->plaintext.len >> 3,
5389 "ZUC Plaintext data not as expected");
5391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5393 tdata->ciphertext.data,
5394 tdata->validDataLenInBits.len,
5395 "ZUC Ciphertext data not as expected");
5397 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5400 DIGEST_BYTE_LENGTH_KASUMI_F9,
5401 "ZUC Generated auth tag not as expected");
5407 test_kasumi_encryption_test_case_1(void)
5409 return test_kasumi_encryption(&kasumi_test_case_1);
5413 test_kasumi_encryption_test_case_1_sgl(void)
5415 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5419 test_kasumi_encryption_test_case_1_oop(void)
5421 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5425 test_kasumi_encryption_test_case_1_oop_sgl(void)
5427 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5431 test_kasumi_encryption_test_case_2(void)
5433 return test_kasumi_encryption(&kasumi_test_case_2);
5437 test_kasumi_encryption_test_case_3(void)
5439 return test_kasumi_encryption(&kasumi_test_case_3);
5443 test_kasumi_encryption_test_case_4(void)
5445 return test_kasumi_encryption(&kasumi_test_case_4);
5449 test_kasumi_encryption_test_case_5(void)
5451 return test_kasumi_encryption(&kasumi_test_case_5);
5455 test_kasumi_decryption_test_case_1(void)
5457 return test_kasumi_decryption(&kasumi_test_case_1);
5461 test_kasumi_decryption_test_case_1_oop(void)
5463 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5467 test_kasumi_decryption_test_case_2(void)
5469 return test_kasumi_decryption(&kasumi_test_case_2);
5473 test_kasumi_decryption_test_case_3(void)
5475 return test_kasumi_decryption(&kasumi_test_case_3);
5479 test_kasumi_decryption_test_case_4(void)
5481 return test_kasumi_decryption(&kasumi_test_case_4);
5485 test_kasumi_decryption_test_case_5(void)
5487 return test_kasumi_decryption(&kasumi_test_case_5);
5490 test_snow3g_encryption_test_case_1(void)
5492 return test_snow3g_encryption(&snow3g_test_case_1);
5496 test_snow3g_encryption_test_case_1_oop(void)
5498 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5502 test_snow3g_encryption_test_case_1_oop_sgl(void)
5504 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5509 test_snow3g_encryption_test_case_1_offset_oop(void)
5511 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5515 test_snow3g_encryption_test_case_2(void)
5517 return test_snow3g_encryption(&snow3g_test_case_2);
5521 test_snow3g_encryption_test_case_3(void)
5523 return test_snow3g_encryption(&snow3g_test_case_3);
5527 test_snow3g_encryption_test_case_4(void)
5529 return test_snow3g_encryption(&snow3g_test_case_4);
5533 test_snow3g_encryption_test_case_5(void)
5535 return test_snow3g_encryption(&snow3g_test_case_5);
5539 test_snow3g_decryption_test_case_1(void)
5541 return test_snow3g_decryption(&snow3g_test_case_1);
5545 test_snow3g_decryption_test_case_1_oop(void)
5547 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5551 test_snow3g_decryption_test_case_2(void)
5553 return test_snow3g_decryption(&snow3g_test_case_2);
5557 test_snow3g_decryption_test_case_3(void)
5559 return test_snow3g_decryption(&snow3g_test_case_3);
5563 test_snow3g_decryption_test_case_4(void)
5565 return test_snow3g_decryption(&snow3g_test_case_4);
5569 test_snow3g_decryption_test_case_5(void)
5571 return test_snow3g_decryption(&snow3g_test_case_5);
5575 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5576 * Pattern digest from snow3g_test_data must be allocated as
5577 * 4 last bytes in plaintext.
5580 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5581 struct snow3g_hash_test_data *output)
5583 if ((pattern != NULL) && (output != NULL)) {
5584 output->key.len = pattern->key.len;
5586 memcpy(output->key.data,
5587 pattern->key.data, pattern->key.len);
5589 output->auth_iv.len = pattern->auth_iv.len;
5591 memcpy(output->auth_iv.data,
5592 pattern->auth_iv.data, pattern->auth_iv.len);
5594 output->plaintext.len = pattern->plaintext.len;
5596 memcpy(output->plaintext.data,
5597 pattern->plaintext.data, pattern->plaintext.len >> 3);
5599 output->digest.len = pattern->digest.len;
5601 memcpy(output->digest.data,
5602 &pattern->plaintext.data[pattern->digest.offset_bytes],
5603 pattern->digest.len);
5605 output->validAuthLenInBits.len =
5606 pattern->validAuthLenInBits.len;
5611 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5614 test_snow3g_decryption_with_digest_test_case_1(void)
5616 struct snow3g_hash_test_data snow3g_hash_data;
5619 * Function prepare data for hash veryfication test case.
5620 * Digest is allocated in 4 last bytes in plaintext, pattern.
5622 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5624 return test_snow3g_decryption(&snow3g_test_case_7) &
5625 test_snow3g_authentication_verify(&snow3g_hash_data);
5629 test_snow3g_cipher_auth_test_case_1(void)
5631 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5635 test_snow3g_auth_cipher_test_case_1(void)
5637 return test_snow3g_auth_cipher(
5638 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5642 test_snow3g_auth_cipher_test_case_2(void)
5644 return test_snow3g_auth_cipher(
5645 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5649 test_snow3g_auth_cipher_test_case_2_oop(void)
5651 return test_snow3g_auth_cipher(
5652 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5656 test_snow3g_auth_cipher_part_digest_enc(void)
5658 return test_snow3g_auth_cipher(
5659 &snow3g_auth_cipher_partial_digest_encryption,
5664 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5666 return test_snow3g_auth_cipher(
5667 &snow3g_auth_cipher_partial_digest_encryption,
5672 test_snow3g_auth_cipher_test_case_3_sgl(void)
5674 return test_snow3g_auth_cipher_sgl(
5675 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5679 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5681 return test_snow3g_auth_cipher_sgl(
5682 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5686 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5688 return test_snow3g_auth_cipher_sgl(
5689 &snow3g_auth_cipher_partial_digest_encryption,
5694 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5696 return test_snow3g_auth_cipher_sgl(
5697 &snow3g_auth_cipher_partial_digest_encryption,
5702 test_snow3g_auth_cipher_verify_test_case_1(void)
5704 return test_snow3g_auth_cipher(
5705 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5709 test_snow3g_auth_cipher_verify_test_case_2(void)
5711 return test_snow3g_auth_cipher(
5712 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5716 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5718 return test_snow3g_auth_cipher(
5719 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5723 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5725 return test_snow3g_auth_cipher(
5726 &snow3g_auth_cipher_partial_digest_encryption,
5731 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5733 return test_snow3g_auth_cipher(
5734 &snow3g_auth_cipher_partial_digest_encryption,
5739 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5741 return test_snow3g_auth_cipher_sgl(
5742 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5746 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5748 return test_snow3g_auth_cipher_sgl(
5749 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5753 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5755 return test_snow3g_auth_cipher_sgl(
5756 &snow3g_auth_cipher_partial_digest_encryption,
5761 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5763 return test_snow3g_auth_cipher_sgl(
5764 &snow3g_auth_cipher_partial_digest_encryption,
5769 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5771 return test_snow3g_auth_cipher(
5772 &snow3g_test_case_7, IN_PLACE, 0);
5776 test_kasumi_auth_cipher_test_case_1(void)
5778 return test_kasumi_auth_cipher(
5779 &kasumi_test_case_3, IN_PLACE, 0);
5783 test_kasumi_auth_cipher_test_case_2(void)
5785 return test_kasumi_auth_cipher(
5786 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5790 test_kasumi_auth_cipher_test_case_2_oop(void)
5792 return test_kasumi_auth_cipher(
5793 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5797 test_kasumi_auth_cipher_test_case_2_sgl(void)
5799 return test_kasumi_auth_cipher_sgl(
5800 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5804 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5806 return test_kasumi_auth_cipher_sgl(
5807 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5811 test_kasumi_auth_cipher_verify_test_case_1(void)
5813 return test_kasumi_auth_cipher(
5814 &kasumi_test_case_3, IN_PLACE, 1);
5818 test_kasumi_auth_cipher_verify_test_case_2(void)
5820 return test_kasumi_auth_cipher(
5821 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5825 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5827 return test_kasumi_auth_cipher(
5828 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5832 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5834 return test_kasumi_auth_cipher_sgl(
5835 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5839 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5841 return test_kasumi_auth_cipher_sgl(
5842 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5846 test_kasumi_cipher_auth_test_case_1(void)
5848 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5852 test_zuc_encryption_test_case_1(void)
5854 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5858 test_zuc_encryption_test_case_2(void)
5860 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5864 test_zuc_encryption_test_case_3(void)
5866 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5870 test_zuc_encryption_test_case_4(void)
5872 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5876 test_zuc_encryption_test_case_5(void)
5878 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5882 test_zuc_encryption_test_case_6_sgl(void)
5884 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5888 test_zuc_hash_generate_test_case_1(void)
5890 return test_zuc_authentication(&zuc_test_case_auth_1b);
5894 test_zuc_hash_generate_test_case_2(void)
5896 return test_zuc_authentication(&zuc_test_case_auth_90b);
5900 test_zuc_hash_generate_test_case_3(void)
5902 return test_zuc_authentication(&zuc_test_case_auth_577b);
5906 test_zuc_hash_generate_test_case_4(void)
5908 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5912 test_zuc_hash_generate_test_case_5(void)
5914 return test_zuc_authentication(&zuc_test_auth_5670b);
5918 test_zuc_hash_generate_test_case_6(void)
5920 return test_zuc_authentication(&zuc_test_case_auth_128b);
5924 test_zuc_hash_generate_test_case_7(void)
5926 /* This test is not for SW ZUC PMD */
5927 if (gbl_driver_id == rte_cryptodev_driver_id_get(
5928 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
5931 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5935 test_zuc_hash_generate_test_case_8(void)
5937 return test_zuc_authentication(&zuc_test_case_auth_584b);
5941 test_zuc_cipher_auth_test_case_1(void)
5943 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5947 test_zuc_cipher_auth_test_case_2(void)
5949 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5953 test_zuc_auth_cipher_test_case_1(void)
5955 /* This test is not for SW ZUC PMD */
5956 if (gbl_driver_id == rte_cryptodev_driver_id_get(
5957 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
5960 return test_zuc_auth_cipher(
5961 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5965 test_zuc_auth_cipher_test_case_1_oop(void)
5967 return test_zuc_auth_cipher(
5968 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5972 test_zuc_auth_cipher_test_case_1_sgl(void)
5974 return test_zuc_auth_cipher_sgl(
5975 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5979 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
5981 return test_zuc_auth_cipher_sgl(
5982 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5986 test_zuc_auth_cipher_verify_test_case_1(void)
5988 return test_zuc_auth_cipher(
5989 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
5993 test_zuc_auth_cipher_verify_test_case_1_oop(void)
5995 return test_zuc_auth_cipher(
5996 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6000 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6002 return test_zuc_auth_cipher_sgl(
6003 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6007 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6009 return test_zuc_auth_cipher_sgl(
6010 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6014 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6016 uint8_t dev_id = testsuite_params.valid_devs[0];
6018 struct rte_cryptodev_sym_capability_idx cap_idx;
6020 /* Check if device supports particular cipher algorithm */
6021 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6022 cap_idx.algo.cipher = tdata->cipher_algo;
6023 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6026 /* Check if device supports particular hash algorithm */
6027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6028 cap_idx.algo.auth = tdata->auth_algo;
6029 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6036 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6037 uint8_t op_mode, uint8_t verify)
6039 struct crypto_testsuite_params *ts_params = &testsuite_params;
6040 struct crypto_unittest_params *ut_params = &unittest_params;
6044 uint8_t *plaintext = NULL, *ciphertext = NULL;
6045 unsigned int plaintext_pad_len;
6046 unsigned int plaintext_len;
6047 unsigned int ciphertext_pad_len;
6048 unsigned int ciphertext_len;
6050 struct rte_cryptodev_info dev_info;
6051 struct rte_crypto_op *op;
6053 /* Check if device supports particular algorithms separately */
6054 if (test_mixed_check_if_unsupported(tdata))
6057 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6059 uint64_t feat_flags = dev_info.feature_flags;
6061 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6062 printf("Device doesn't support digest encrypted.\n");
6066 /* Create the session */
6068 retval = create_wireless_algo_cipher_auth_session(
6069 ts_params->valid_devs[0],
6070 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6071 RTE_CRYPTO_AUTH_OP_VERIFY,
6074 tdata->auth_key.data, tdata->auth_key.len,
6075 tdata->auth_iv.len, tdata->digest_enc.len,
6076 tdata->cipher_iv.len);
6078 retval = create_wireless_algo_auth_cipher_session(
6079 ts_params->valid_devs[0],
6080 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6081 RTE_CRYPTO_AUTH_OP_GENERATE,
6084 tdata->auth_key.data, tdata->auth_key.len,
6085 tdata->auth_iv.len, tdata->digest_enc.len,
6086 tdata->cipher_iv.len);
6090 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6091 if (op_mode == OUT_OF_PLACE)
6092 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6094 /* clear mbuf payload */
6095 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6096 rte_pktmbuf_tailroom(ut_params->ibuf));
6097 if (op_mode == OUT_OF_PLACE)
6098 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6099 rte_pktmbuf_tailroom(ut_params->obuf));
6101 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6102 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6103 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6104 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6107 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6108 ciphertext_pad_len);
6109 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6110 if (op_mode == OUT_OF_PLACE)
6111 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6112 debug_hexdump(stdout, "ciphertext:", ciphertext,
6115 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6117 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6118 if (op_mode == OUT_OF_PLACE)
6119 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6120 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6123 /* Create the operation */
6124 retval = create_wireless_algo_auth_cipher_operation(
6125 tdata->digest_enc.data, tdata->digest_enc.len,
6126 tdata->cipher_iv.data, tdata->cipher_iv.len,
6127 tdata->auth_iv.data, tdata->auth_iv.len,
6128 (tdata->digest_enc.offset == 0 ?
6130 : tdata->digest_enc.offset),
6131 tdata->validCipherLen.len_bits,
6132 tdata->cipher.offset_bits,
6133 tdata->validAuthLen.len_bits,
6134 tdata->auth.offset_bits,
6135 op_mode, 0, verify);
6140 op = process_crypto_request(ts_params->valid_devs[0],
6143 /* Check if the op failed because the device doesn't */
6144 /* support this particular combination of algorithms */
6145 if (op == NULL && ut_params->op->status ==
6146 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6147 printf("Device doesn't support this mixed combination. "
6153 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6155 ut_params->obuf = (op_mode == IN_PLACE ?
6156 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6159 if (ut_params->obuf)
6160 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6163 plaintext = ciphertext +
6164 (tdata->cipher.offset_bits >> 3);
6166 debug_hexdump(stdout, "plaintext:", plaintext,
6167 tdata->plaintext.len_bits >> 3);
6168 debug_hexdump(stdout, "plaintext expected:",
6169 tdata->plaintext.data,
6170 tdata->plaintext.len_bits >> 3);
6172 if (ut_params->obuf)
6173 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6176 ciphertext = plaintext;
6178 debug_hexdump(stdout, "ciphertext:", ciphertext,
6180 debug_hexdump(stdout, "ciphertext expected:",
6181 tdata->ciphertext.data,
6182 tdata->ciphertext.len_bits >> 3);
6184 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6185 + (tdata->digest_enc.offset == 0 ?
6186 plaintext_pad_len : tdata->digest_enc.offset);
6188 debug_hexdump(stdout, "digest:", ut_params->digest,
6189 tdata->digest_enc.len);
6190 debug_hexdump(stdout, "digest expected:",
6191 tdata->digest_enc.data,
6192 tdata->digest_enc.len);
6197 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6199 tdata->plaintext.data,
6200 tdata->plaintext.len_bits >> 3,
6201 "Plaintext data not as expected");
6203 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6205 tdata->ciphertext.data,
6206 tdata->validDataLen.len_bits,
6207 "Ciphertext data not as expected");
6209 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6211 tdata->digest_enc.data,
6212 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6213 "Generated auth tag not as expected");
6216 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6217 "crypto op processing failed");
6223 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6224 uint8_t op_mode, uint8_t verify)
6226 struct crypto_testsuite_params *ts_params = &testsuite_params;
6227 struct crypto_unittest_params *ut_params = &unittest_params;
6231 const uint8_t *plaintext = NULL;
6232 const uint8_t *ciphertext = NULL;
6233 const uint8_t *digest = NULL;
6234 unsigned int plaintext_pad_len;
6235 unsigned int plaintext_len;
6236 unsigned int ciphertext_pad_len;
6237 unsigned int ciphertext_len;
6238 uint8_t buffer[10000];
6239 uint8_t digest_buffer[10000];
6241 struct rte_cryptodev_info dev_info;
6242 struct rte_crypto_op *op;
6244 /* Check if device supports particular algorithms */
6245 if (test_mixed_check_if_unsupported(tdata))
6248 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6250 uint64_t feat_flags = dev_info.feature_flags;
6252 if (op_mode == IN_PLACE) {
6253 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6254 printf("Device doesn't support in-place scatter-gather "
6255 "in both input and output mbufs.\n");
6259 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6260 printf("Device doesn't support out-of-place scatter-gather "
6261 "in both input and output mbufs.\n");
6264 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6265 printf("Device doesn't support digest encrypted.\n");
6270 /* Create the session */
6272 retval = create_wireless_algo_cipher_auth_session(
6273 ts_params->valid_devs[0],
6274 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6275 RTE_CRYPTO_AUTH_OP_VERIFY,
6278 tdata->auth_key.data, tdata->auth_key.len,
6279 tdata->auth_iv.len, tdata->digest_enc.len,
6280 tdata->cipher_iv.len);
6282 retval = create_wireless_algo_auth_cipher_session(
6283 ts_params->valid_devs[0],
6284 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6285 RTE_CRYPTO_AUTH_OP_GENERATE,
6288 tdata->auth_key.data, tdata->auth_key.len,
6289 tdata->auth_iv.len, tdata->digest_enc.len,
6290 tdata->cipher_iv.len);
6294 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6295 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6296 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6297 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6299 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6300 ciphertext_pad_len, 15, 0);
6301 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6302 "Failed to allocate input buffer in mempool");
6304 if (op_mode == OUT_OF_PLACE) {
6305 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6306 plaintext_pad_len, 15, 0);
6307 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6308 "Failed to allocate output buffer in mempool");
6312 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6313 tdata->ciphertext.data);
6314 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6315 ciphertext_len, buffer);
6316 debug_hexdump(stdout, "ciphertext:", ciphertext,
6319 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6320 tdata->plaintext.data);
6321 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6322 plaintext_len, buffer);
6323 debug_hexdump(stdout, "plaintext:", plaintext,
6326 memset(buffer, 0, sizeof(buffer));
6328 /* Create the operation */
6329 retval = create_wireless_algo_auth_cipher_operation(
6330 tdata->digest_enc.data, tdata->digest_enc.len,
6331 tdata->cipher_iv.data, tdata->cipher_iv.len,
6332 tdata->auth_iv.data, tdata->auth_iv.len,
6333 (tdata->digest_enc.offset == 0 ?
6335 : tdata->digest_enc.offset),
6336 tdata->validCipherLen.len_bits,
6337 tdata->cipher.offset_bits,
6338 tdata->validAuthLen.len_bits,
6339 tdata->auth.offset_bits,
6340 op_mode, 1, verify);
6345 op = process_crypto_request(ts_params->valid_devs[0],
6348 /* Check if the op failed because the device doesn't */
6349 /* support this particular combination of algorithms */
6350 if (op == NULL && ut_params->op->status ==
6351 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6352 printf("Device doesn't support this mixed combination. "
6359 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6361 ut_params->obuf = (op_mode == IN_PLACE ?
6362 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6365 if (ut_params->obuf)
6366 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6367 plaintext_len, buffer);
6369 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6370 plaintext_len, buffer);
6372 debug_hexdump(stdout, "plaintext:", plaintext,
6373 (tdata->plaintext.len_bits >> 3) -
6374 tdata->digest_enc.len);
6375 debug_hexdump(stdout, "plaintext expected:",
6376 tdata->plaintext.data,
6377 (tdata->plaintext.len_bits >> 3) -
6378 tdata->digest_enc.len);
6380 if (ut_params->obuf)
6381 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6382 ciphertext_len, buffer);
6384 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6385 ciphertext_len, buffer);
6387 debug_hexdump(stdout, "ciphertext:", ciphertext,
6389 debug_hexdump(stdout, "ciphertext expected:",
6390 tdata->ciphertext.data,
6391 tdata->ciphertext.len_bits >> 3);
6393 if (ut_params->obuf)
6394 digest = rte_pktmbuf_read(ut_params->obuf,
6395 (tdata->digest_enc.offset == 0 ?
6397 tdata->digest_enc.offset),
6398 tdata->digest_enc.len, digest_buffer);
6400 digest = rte_pktmbuf_read(ut_params->ibuf,
6401 (tdata->digest_enc.offset == 0 ?
6403 tdata->digest_enc.offset),
6404 tdata->digest_enc.len, digest_buffer);
6406 debug_hexdump(stdout, "digest:", digest,
6407 tdata->digest_enc.len);
6408 debug_hexdump(stdout, "digest expected:",
6409 tdata->digest_enc.data, tdata->digest_enc.len);
6414 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6416 tdata->plaintext.data,
6417 tdata->plaintext.len_bits >> 3,
6418 "Plaintext data not as expected");
6420 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6422 tdata->ciphertext.data,
6423 tdata->validDataLen.len_bits,
6424 "Ciphertext data not as expected");
6425 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6427 tdata->digest_enc.data,
6428 tdata->digest_enc.len,
6429 "Generated auth tag not as expected");
6432 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6433 "crypto op processing failed");
6438 /** AUTH AES CMAC + CIPHER AES CTR */
6441 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6443 return test_mixed_auth_cipher(
6444 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6448 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6450 return test_mixed_auth_cipher(
6451 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6455 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6457 return test_mixed_auth_cipher_sgl(
6458 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6462 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6464 return test_mixed_auth_cipher_sgl(
6465 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6469 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6471 return test_mixed_auth_cipher(
6472 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6476 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6478 return test_mixed_auth_cipher(
6479 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6483 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6485 return test_mixed_auth_cipher_sgl(
6486 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6490 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6492 return test_mixed_auth_cipher_sgl(
6493 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6496 /** MIXED AUTH + CIPHER */
6499 test_auth_zuc_cipher_snow_test_case_1(void)
6501 return test_mixed_auth_cipher(
6502 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6506 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6508 return test_mixed_auth_cipher(
6509 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6513 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6515 return test_mixed_auth_cipher(
6516 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6520 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6522 return test_mixed_auth_cipher(
6523 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6527 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6529 return test_mixed_auth_cipher(
6530 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6534 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6536 return test_mixed_auth_cipher(
6537 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6541 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6543 return test_mixed_auth_cipher(
6544 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6548 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6550 return test_mixed_auth_cipher(
6551 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6555 test_auth_snow_cipher_zuc_test_case_1(void)
6557 return test_mixed_auth_cipher(
6558 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6562 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6564 return test_mixed_auth_cipher(
6565 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6569 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6571 return test_mixed_auth_cipher(
6572 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6576 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6578 return test_mixed_auth_cipher(
6579 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6583 test_auth_null_cipher_snow_test_case_1(void)
6585 return test_mixed_auth_cipher(
6586 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6590 test_verify_auth_null_cipher_snow_test_case_1(void)
6592 return test_mixed_auth_cipher(
6593 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6597 test_auth_null_cipher_zuc_test_case_1(void)
6599 return test_mixed_auth_cipher(
6600 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6604 test_verify_auth_null_cipher_zuc_test_case_1(void)
6606 return test_mixed_auth_cipher(
6607 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6611 test_auth_snow_cipher_null_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6618 test_verify_auth_snow_cipher_null_test_case_1(void)
6620 return test_mixed_auth_cipher(
6621 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6625 test_auth_zuc_cipher_null_test_case_1(void)
6627 return test_mixed_auth_cipher(
6628 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6632 test_verify_auth_zuc_cipher_null_test_case_1(void)
6634 return test_mixed_auth_cipher(
6635 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6639 test_auth_null_cipher_aes_ctr_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6646 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6653 test_auth_aes_cmac_cipher_null_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6660 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6666 /* ***** AEAD algorithm Tests ***** */
6669 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6670 enum rte_crypto_aead_operation op,
6671 const uint8_t *key, const uint8_t key_len,
6672 const uint16_t aad_len, const uint8_t auth_len,
6675 uint8_t aead_key[key_len];
6677 struct crypto_testsuite_params *ts_params = &testsuite_params;
6678 struct crypto_unittest_params *ut_params = &unittest_params;
6680 memcpy(aead_key, key, key_len);
6682 /* Setup AEAD Parameters */
6683 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6684 ut_params->aead_xform.next = NULL;
6685 ut_params->aead_xform.aead.algo = algo;
6686 ut_params->aead_xform.aead.op = op;
6687 ut_params->aead_xform.aead.key.data = aead_key;
6688 ut_params->aead_xform.aead.key.length = key_len;
6689 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6690 ut_params->aead_xform.aead.iv.length = iv_len;
6691 ut_params->aead_xform.aead.digest_length = auth_len;
6692 ut_params->aead_xform.aead.aad_length = aad_len;
6694 debug_hexdump(stdout, "key:", key, key_len);
6696 /* Create Crypto session*/
6697 ut_params->sess = rte_cryptodev_sym_session_create(
6698 ts_params->session_mpool);
6700 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6701 &ut_params->aead_xform,
6702 ts_params->session_priv_mpool);
6704 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6710 create_aead_xform(struct rte_crypto_op *op,
6711 enum rte_crypto_aead_algorithm algo,
6712 enum rte_crypto_aead_operation aead_op,
6713 uint8_t *key, const uint8_t key_len,
6714 const uint8_t aad_len, const uint8_t auth_len,
6717 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6718 "failed to allocate space for crypto transform");
6720 struct rte_crypto_sym_op *sym_op = op->sym;
6722 /* Setup AEAD Parameters */
6723 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6724 sym_op->xform->next = NULL;
6725 sym_op->xform->aead.algo = algo;
6726 sym_op->xform->aead.op = aead_op;
6727 sym_op->xform->aead.key.data = key;
6728 sym_op->xform->aead.key.length = key_len;
6729 sym_op->xform->aead.iv.offset = IV_OFFSET;
6730 sym_op->xform->aead.iv.length = iv_len;
6731 sym_op->xform->aead.digest_length = auth_len;
6732 sym_op->xform->aead.aad_length = aad_len;
6734 debug_hexdump(stdout, "key:", key, key_len);
6740 create_aead_operation(enum rte_crypto_aead_operation op,
6741 const struct aead_test_data *tdata)
6743 struct crypto_testsuite_params *ts_params = &testsuite_params;
6744 struct crypto_unittest_params *ut_params = &unittest_params;
6746 uint8_t *plaintext, *ciphertext;
6747 unsigned int aad_pad_len, plaintext_pad_len;
6749 /* Generate Crypto op data structure */
6750 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6751 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6752 TEST_ASSERT_NOT_NULL(ut_params->op,
6753 "Failed to allocate symmetric crypto operation struct");
6755 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6757 /* Append aad data */
6758 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6759 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6760 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6762 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6763 "no room to append aad");
6765 sym_op->aead.aad.phys_addr =
6766 rte_pktmbuf_iova(ut_params->ibuf);
6767 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6768 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6769 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6772 /* Append IV at the end of the crypto operation*/
6773 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6774 uint8_t *, IV_OFFSET);
6776 /* Copy IV 1 byte after the IV pointer, according to the API */
6777 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6778 debug_hexdump(stdout, "iv:", iv_ptr,
6781 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6782 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6784 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6785 "no room to append aad");
6787 sym_op->aead.aad.phys_addr =
6788 rte_pktmbuf_iova(ut_params->ibuf);
6789 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6790 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6793 /* Append IV at the end of the crypto operation*/
6794 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6795 uint8_t *, IV_OFFSET);
6797 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6798 debug_hexdump(stdout, "iv:", iv_ptr,
6802 /* Append plaintext/ciphertext */
6803 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6804 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6805 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6807 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6809 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6810 debug_hexdump(stdout, "plaintext:", plaintext,
6811 tdata->plaintext.len);
6813 if (ut_params->obuf) {
6814 ciphertext = (uint8_t *)rte_pktmbuf_append(
6816 plaintext_pad_len + aad_pad_len);
6817 TEST_ASSERT_NOT_NULL(ciphertext,
6818 "no room to append ciphertext");
6820 memset(ciphertext + aad_pad_len, 0,
6821 tdata->ciphertext.len);
6824 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6825 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6827 TEST_ASSERT_NOT_NULL(ciphertext,
6828 "no room to append ciphertext");
6830 memcpy(ciphertext, tdata->ciphertext.data,
6831 tdata->ciphertext.len);
6832 debug_hexdump(stdout, "ciphertext:", ciphertext,
6833 tdata->ciphertext.len);
6835 if (ut_params->obuf) {
6836 plaintext = (uint8_t *)rte_pktmbuf_append(
6838 plaintext_pad_len + aad_pad_len);
6839 TEST_ASSERT_NOT_NULL(plaintext,
6840 "no room to append plaintext");
6842 memset(plaintext + aad_pad_len, 0,
6843 tdata->plaintext.len);
6847 /* Append digest data */
6848 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6849 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6850 ut_params->obuf ? ut_params->obuf :
6852 tdata->auth_tag.len);
6853 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6854 "no room to append digest");
6855 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6856 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6857 ut_params->obuf ? ut_params->obuf :
6862 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6863 ut_params->ibuf, tdata->auth_tag.len);
6864 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6865 "no room to append digest");
6866 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6868 plaintext_pad_len + aad_pad_len);
6870 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6871 tdata->auth_tag.len);
6872 debug_hexdump(stdout, "digest:",
6873 sym_op->aead.digest.data,
6874 tdata->auth_tag.len);
6877 sym_op->aead.data.length = tdata->plaintext.len;
6878 sym_op->aead.data.offset = aad_pad_len;
6884 test_authenticated_encryption(const struct aead_test_data *tdata)
6886 struct crypto_testsuite_params *ts_params = &testsuite_params;
6887 struct crypto_unittest_params *ut_params = &unittest_params;
6890 uint8_t *ciphertext, *auth_tag;
6891 uint16_t plaintext_pad_len;
6894 /* Verify the capabilities */
6895 struct rte_cryptodev_sym_capability_idx cap_idx;
6896 const struct rte_cryptodev_symmetric_capability *capability;
6897 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6898 cap_idx.algo.aead = tdata->algo;
6899 capability = rte_cryptodev_sym_capability_get(
6900 ts_params->valid_devs[0], &cap_idx);
6901 if (capability == NULL)
6903 if (rte_cryptodev_sym_capability_check_aead(
6904 capability, tdata->key.len, tdata->auth_tag.len,
6905 tdata->aad.len, tdata->iv.len))
6908 /* Create AEAD session */
6909 retval = create_aead_session(ts_params->valid_devs[0],
6911 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6912 tdata->key.data, tdata->key.len,
6913 tdata->aad.len, tdata->auth_tag.len,
6918 if (tdata->aad.len > MBUF_SIZE) {
6919 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6920 /* Populate full size of add data */
6921 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6922 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6924 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6926 /* clear mbuf payload */
6927 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6928 rte_pktmbuf_tailroom(ut_params->ibuf));
6930 /* Create AEAD operation */
6931 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6935 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6937 ut_params->op->sym->m_src = ut_params->ibuf;
6939 /* Process crypto operation */
6940 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6941 ut_params->op), "failed to process sym crypto op");
6943 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6944 "crypto op processing failed");
6946 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6948 if (ut_params->op->sym->m_dst) {
6949 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6951 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6952 uint8_t *, plaintext_pad_len);
6954 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6956 ut_params->op->sym->cipher.data.offset);
6957 auth_tag = ciphertext + plaintext_pad_len;
6960 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6961 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6964 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6966 tdata->ciphertext.data,
6967 tdata->ciphertext.len,
6968 "Ciphertext data not as expected");
6970 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6972 tdata->auth_tag.data,
6973 tdata->auth_tag.len,
6974 "Generated auth tag not as expected");
6980 #ifdef RTE_LIBRTE_SECURITY
6981 /* Basic algorithm run function for async inplace mode.
6982 * Creates a session from input parameters and runs one operation
6983 * on input_vec. Checks the output of the crypto operation against
6987 test_pdcp_proto(int i, int oop,
6988 enum rte_crypto_cipher_operation opc,
6989 enum rte_crypto_auth_operation opa,
6991 unsigned int input_vec_len,
6992 uint8_t *output_vec,
6993 unsigned int output_vec_len)
6995 struct crypto_testsuite_params *ts_params = &testsuite_params;
6996 struct crypto_unittest_params *ut_params = &unittest_params;
6998 int ret = TEST_SUCCESS;
6999 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7000 rte_cryptodev_get_sec_ctx(
7001 ts_params->valid_devs[0]);
7003 /* Verify the capabilities */
7004 struct rte_security_capability_idx sec_cap_idx;
7006 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7007 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7008 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7009 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7012 /* Generate test mbuf data */
7013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7015 /* clear mbuf payload */
7016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7017 rte_pktmbuf_tailroom(ut_params->ibuf));
7019 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7021 memcpy(plaintext, input_vec, input_vec_len);
7023 /* Out of place support */
7026 * For out-op-place we need to alloc another mbuf
7028 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7029 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7032 /* Set crypto type as IPSEC */
7033 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7035 /* Setup Cipher Parameters */
7036 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7037 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7038 ut_params->cipher_xform.cipher.op = opc;
7039 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7040 ut_params->cipher_xform.cipher.key.length =
7041 pdcp_test_params[i].cipher_key_len;
7042 ut_params->cipher_xform.cipher.iv.length = 0;
7044 /* Setup HMAC Parameters if ICV header is required */
7045 if (pdcp_test_params[i].auth_alg != 0) {
7046 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7047 ut_params->auth_xform.next = NULL;
7048 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7049 ut_params->auth_xform.auth.op = opa;
7050 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7051 ut_params->auth_xform.auth.key.length =
7052 pdcp_test_params[i].auth_key_len;
7054 ut_params->cipher_xform.next = &ut_params->auth_xform;
7056 ut_params->cipher_xform.next = NULL;
7059 struct rte_security_session_conf sess_conf = {
7060 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7061 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7063 .bearer = pdcp_test_bearer[i],
7064 .domain = pdcp_test_params[i].domain,
7065 .pkt_dir = pdcp_test_packet_direction[i],
7066 .sn_size = pdcp_test_data_sn_size[i],
7067 .hfn = pdcp_test_hfn[i],
7068 .hfn_threshold = pdcp_test_hfn_threshold[i],
7070 .crypto_xform = &ut_params->cipher_xform
7073 /* Create security session */
7074 ut_params->sec_session = rte_security_session_create(ctx,
7075 &sess_conf, ts_params->session_priv_mpool);
7077 if (!ut_params->sec_session) {
7078 printf("TestCase %s()-%d line %d failed %s: ",
7079 __func__, i, __LINE__, "Failed to allocate session");
7084 /* Generate crypto op data structure */
7085 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7086 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7087 if (!ut_params->op) {
7088 printf("TestCase %s()-%d line %d failed %s: ",
7089 __func__, i, __LINE__,
7090 "Failed to allocate symmetric crypto operation struct");
7095 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7097 /* set crypto operation source mbuf */
7098 ut_params->op->sym->m_src = ut_params->ibuf;
7100 ut_params->op->sym->m_dst = ut_params->obuf;
7102 /* Process crypto operation */
7103 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7105 printf("TestCase %s()-%d line %d failed %s: ",
7106 __func__, i, __LINE__,
7107 "failed to process sym crypto op");
7112 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7113 printf("TestCase %s()-%d line %d failed %s: ",
7114 __func__, i, __LINE__, "crypto op processing failed");
7120 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7123 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7127 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7128 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7129 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7130 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7136 rte_crypto_op_free(ut_params->op);
7137 ut_params->op = NULL;
7139 if (ut_params->sec_session)
7140 rte_security_session_destroy(ctx, ut_params->sec_session);
7141 ut_params->sec_session = NULL;
7143 rte_pktmbuf_free(ut_params->ibuf);
7144 ut_params->ibuf = NULL;
7146 rte_pktmbuf_free(ut_params->obuf);
7147 ut_params->obuf = NULL;
7154 test_pdcp_proto_SGL(int i, int oop,
7155 enum rte_crypto_cipher_operation opc,
7156 enum rte_crypto_auth_operation opa,
7158 unsigned int input_vec_len,
7159 uint8_t *output_vec,
7160 unsigned int output_vec_len,
7162 uint32_t fragsz_oop)
7164 struct crypto_testsuite_params *ts_params = &testsuite_params;
7165 struct crypto_unittest_params *ut_params = &unittest_params;
7167 struct rte_mbuf *buf, *buf_oop = NULL;
7168 int ret = TEST_SUCCESS;
7172 unsigned int trn_data = 0;
7173 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7174 rte_cryptodev_get_sec_ctx(
7175 ts_params->valid_devs[0]);
7177 /* Verify the capabilities */
7178 struct rte_security_capability_idx sec_cap_idx;
7180 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7181 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7182 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7183 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7186 if (fragsz > input_vec_len)
7187 fragsz = input_vec_len;
7189 uint16_t plaintext_len = fragsz;
7190 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7192 if (fragsz_oop > output_vec_len)
7193 frag_size_oop = output_vec_len;
7196 if (input_vec_len % fragsz != 0) {
7197 if (input_vec_len / fragsz + 1 > 16)
7199 } else if (input_vec_len / fragsz > 16)
7202 /* Out of place support */
7205 * For out-op-place we need to alloc another mbuf
7207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7208 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7209 buf_oop = ut_params->obuf;
7212 /* Generate test mbuf data */
7213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7215 /* clear mbuf payload */
7216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7217 rte_pktmbuf_tailroom(ut_params->ibuf));
7219 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7221 memcpy(plaintext, input_vec, plaintext_len);
7222 trn_data += plaintext_len;
7224 buf = ut_params->ibuf;
7227 * Loop until no more fragments
7230 while (trn_data < input_vec_len) {
7232 to_trn = (input_vec_len - trn_data < fragsz) ?
7233 (input_vec_len - trn_data) : fragsz;
7235 to_trn_tbl[ecx++] = to_trn;
7237 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7240 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7241 rte_pktmbuf_tailroom(buf));
7244 if (oop && !fragsz_oop) {
7246 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7247 buf_oop = buf_oop->next;
7248 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7249 0, rte_pktmbuf_tailroom(buf_oop));
7250 rte_pktmbuf_append(buf_oop, to_trn);
7253 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7256 memcpy(plaintext, input_vec + trn_data, to_trn);
7260 ut_params->ibuf->nb_segs = segs;
7263 if (fragsz_oop && oop) {
7267 trn_data = frag_size_oop;
7268 while (trn_data < output_vec_len) {
7271 (output_vec_len - trn_data <
7273 (output_vec_len - trn_data) :
7276 to_trn_tbl[ecx++] = to_trn;
7279 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7280 buf_oop = buf_oop->next;
7281 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7282 0, rte_pktmbuf_tailroom(buf_oop));
7283 rte_pktmbuf_append(buf_oop, to_trn);
7287 ut_params->obuf->nb_segs = segs;
7290 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7292 /* Setup Cipher Parameters */
7293 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7294 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7295 ut_params->cipher_xform.cipher.op = opc;
7296 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7297 ut_params->cipher_xform.cipher.key.length =
7298 pdcp_test_params[i].cipher_key_len;
7299 ut_params->cipher_xform.cipher.iv.length = 0;
7301 /* Setup HMAC Parameters if ICV header is required */
7302 if (pdcp_test_params[i].auth_alg != 0) {
7303 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7304 ut_params->auth_xform.next = NULL;
7305 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7306 ut_params->auth_xform.auth.op = opa;
7307 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7308 ut_params->auth_xform.auth.key.length =
7309 pdcp_test_params[i].auth_key_len;
7311 ut_params->cipher_xform.next = &ut_params->auth_xform;
7313 ut_params->cipher_xform.next = NULL;
7316 struct rte_security_session_conf sess_conf = {
7317 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7318 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7320 .bearer = pdcp_test_bearer[i],
7321 .domain = pdcp_test_params[i].domain,
7322 .pkt_dir = pdcp_test_packet_direction[i],
7323 .sn_size = pdcp_test_data_sn_size[i],
7324 .hfn = pdcp_test_hfn[i],
7325 .hfn_threshold = pdcp_test_hfn_threshold[i],
7327 .crypto_xform = &ut_params->cipher_xform
7330 /* Create security session */
7331 ut_params->sec_session = rte_security_session_create(ctx,
7332 &sess_conf, ts_params->session_priv_mpool);
7334 if (!ut_params->sec_session) {
7335 printf("TestCase %s()-%d line %d failed %s: ",
7336 __func__, i, __LINE__, "Failed to allocate session");
7341 /* Generate crypto op data structure */
7342 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7343 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7344 if (!ut_params->op) {
7345 printf("TestCase %s()-%d line %d failed %s: ",
7346 __func__, i, __LINE__,
7347 "Failed to allocate symmetric crypto operation struct");
7352 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7354 /* set crypto operation source mbuf */
7355 ut_params->op->sym->m_src = ut_params->ibuf;
7357 ut_params->op->sym->m_dst = ut_params->obuf;
7359 /* Process crypto operation */
7360 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7362 printf("TestCase %s()-%d line %d failed %s: ",
7363 __func__, i, __LINE__,
7364 "failed to process sym crypto op");
7369 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7370 printf("TestCase %s()-%d line %d failed %s: ",
7371 __func__, i, __LINE__, "crypto op processing failed");
7377 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7380 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7384 fragsz = frag_size_oop;
7385 if (memcmp(ciphertext, output_vec, fragsz)) {
7386 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7387 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7388 rte_hexdump(stdout, "reference", output_vec, fragsz);
7393 buf = ut_params->op->sym->m_src->next;
7395 buf = ut_params->op->sym->m_dst->next;
7397 unsigned int off = fragsz;
7401 ciphertext = rte_pktmbuf_mtod(buf,
7403 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7404 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7405 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7406 rte_hexdump(stdout, "reference", output_vec + off,
7411 off += to_trn_tbl[ecx++];
7415 rte_crypto_op_free(ut_params->op);
7416 ut_params->op = NULL;
7418 if (ut_params->sec_session)
7419 rte_security_session_destroy(ctx, ut_params->sec_session);
7420 ut_params->sec_session = NULL;
7422 rte_pktmbuf_free(ut_params->ibuf);
7423 ut_params->ibuf = NULL;
7425 rte_pktmbuf_free(ut_params->obuf);
7426 ut_params->obuf = NULL;
7433 test_pdcp_proto_cplane_encap(int i)
7435 return test_pdcp_proto(i, 0,
7436 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7437 RTE_CRYPTO_AUTH_OP_GENERATE,
7438 pdcp_test_data_in[i],
7439 pdcp_test_data_in_len[i],
7440 pdcp_test_data_out[i],
7441 pdcp_test_data_in_len[i]+4);
7445 test_pdcp_proto_uplane_encap(int i)
7447 return test_pdcp_proto(i, 0,
7448 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7449 RTE_CRYPTO_AUTH_OP_GENERATE,
7450 pdcp_test_data_in[i],
7451 pdcp_test_data_in_len[i],
7452 pdcp_test_data_out[i],
7453 pdcp_test_data_in_len[i]);
7458 test_pdcp_proto_uplane_encap_with_int(int i)
7460 return test_pdcp_proto(i, 0,
7461 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7462 RTE_CRYPTO_AUTH_OP_GENERATE,
7463 pdcp_test_data_in[i],
7464 pdcp_test_data_in_len[i],
7465 pdcp_test_data_out[i],
7466 pdcp_test_data_in_len[i] + 4);
7470 test_pdcp_proto_cplane_decap(int i)
7472 return test_pdcp_proto(i, 0,
7473 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7474 RTE_CRYPTO_AUTH_OP_VERIFY,
7475 pdcp_test_data_out[i],
7476 pdcp_test_data_in_len[i] + 4,
7477 pdcp_test_data_in[i],
7478 pdcp_test_data_in_len[i]);
7482 test_pdcp_proto_uplane_decap(int i)
7484 return test_pdcp_proto(i, 0,
7485 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7486 RTE_CRYPTO_AUTH_OP_VERIFY,
7487 pdcp_test_data_out[i],
7488 pdcp_test_data_in_len[i],
7489 pdcp_test_data_in[i],
7490 pdcp_test_data_in_len[i]);
7494 test_pdcp_proto_uplane_decap_with_int(int i)
7496 return test_pdcp_proto(i, 0,
7497 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7498 RTE_CRYPTO_AUTH_OP_VERIFY,
7499 pdcp_test_data_out[i],
7500 pdcp_test_data_in_len[i] + 4,
7501 pdcp_test_data_in[i],
7502 pdcp_test_data_in_len[i]);
7506 test_PDCP_PROTO_SGL_in_place_32B(void)
7508 /* i can be used for running any PDCP case
7509 * In this case it is uplane 12-bit AES-SNOW DL encap
7511 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7512 return test_pdcp_proto_SGL(i, IN_PLACE,
7513 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7514 RTE_CRYPTO_AUTH_OP_GENERATE,
7515 pdcp_test_data_in[i],
7516 pdcp_test_data_in_len[i],
7517 pdcp_test_data_out[i],
7518 pdcp_test_data_in_len[i]+4,
7522 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7524 /* i can be used for running any PDCP case
7525 * In this case it is uplane 18-bit NULL-NULL DL encap
7527 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7528 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7529 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7530 RTE_CRYPTO_AUTH_OP_GENERATE,
7531 pdcp_test_data_in[i],
7532 pdcp_test_data_in_len[i],
7533 pdcp_test_data_out[i],
7534 pdcp_test_data_in_len[i]+4,
7538 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7540 /* i can be used for running any PDCP case
7541 * In this case it is uplane 18-bit AES DL encap
7543 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7545 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7546 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7547 RTE_CRYPTO_AUTH_OP_GENERATE,
7548 pdcp_test_data_in[i],
7549 pdcp_test_data_in_len[i],
7550 pdcp_test_data_out[i],
7551 pdcp_test_data_in_len[i],
7555 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7557 /* i can be used for running any PDCP case
7558 * In this case it is cplane 12-bit AES-ZUC DL encap
7560 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7561 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7562 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7563 RTE_CRYPTO_AUTH_OP_GENERATE,
7564 pdcp_test_data_in[i],
7565 pdcp_test_data_in_len[i],
7566 pdcp_test_data_out[i],
7567 pdcp_test_data_in_len[i]+4,
7573 test_AES_GCM_authenticated_encryption_test_case_1(void)
7575 return test_authenticated_encryption(&gcm_test_case_1);
7579 test_AES_GCM_authenticated_encryption_test_case_2(void)
7581 return test_authenticated_encryption(&gcm_test_case_2);
7585 test_AES_GCM_authenticated_encryption_test_case_3(void)
7587 return test_authenticated_encryption(&gcm_test_case_3);
7591 test_AES_GCM_authenticated_encryption_test_case_4(void)
7593 return test_authenticated_encryption(&gcm_test_case_4);
7597 test_AES_GCM_authenticated_encryption_test_case_5(void)
7599 return test_authenticated_encryption(&gcm_test_case_5);
7603 test_AES_GCM_authenticated_encryption_test_case_6(void)
7605 return test_authenticated_encryption(&gcm_test_case_6);
7609 test_AES_GCM_authenticated_encryption_test_case_7(void)
7611 return test_authenticated_encryption(&gcm_test_case_7);
7615 test_AES_GCM_authenticated_encryption_test_case_8(void)
7617 return test_authenticated_encryption(&gcm_test_case_8);
7621 test_AES_GCM_auth_encryption_test_case_192_1(void)
7623 return test_authenticated_encryption(&gcm_test_case_192_1);
7627 test_AES_GCM_auth_encryption_test_case_192_2(void)
7629 return test_authenticated_encryption(&gcm_test_case_192_2);
7633 test_AES_GCM_auth_encryption_test_case_192_3(void)
7635 return test_authenticated_encryption(&gcm_test_case_192_3);
7639 test_AES_GCM_auth_encryption_test_case_192_4(void)
7641 return test_authenticated_encryption(&gcm_test_case_192_4);
7645 test_AES_GCM_auth_encryption_test_case_192_5(void)
7647 return test_authenticated_encryption(&gcm_test_case_192_5);
7651 test_AES_GCM_auth_encryption_test_case_192_6(void)
7653 return test_authenticated_encryption(&gcm_test_case_192_6);
7657 test_AES_GCM_auth_encryption_test_case_192_7(void)
7659 return test_authenticated_encryption(&gcm_test_case_192_7);
7663 test_AES_GCM_auth_encryption_test_case_256_1(void)
7665 return test_authenticated_encryption(&gcm_test_case_256_1);
7669 test_AES_GCM_auth_encryption_test_case_256_2(void)
7671 return test_authenticated_encryption(&gcm_test_case_256_2);
7675 test_AES_GCM_auth_encryption_test_case_256_3(void)
7677 return test_authenticated_encryption(&gcm_test_case_256_3);
7681 test_AES_GCM_auth_encryption_test_case_256_4(void)
7683 return test_authenticated_encryption(&gcm_test_case_256_4);
7687 test_AES_GCM_auth_encryption_test_case_256_5(void)
7689 return test_authenticated_encryption(&gcm_test_case_256_5);
7693 test_AES_GCM_auth_encryption_test_case_256_6(void)
7695 return test_authenticated_encryption(&gcm_test_case_256_6);
7699 test_AES_GCM_auth_encryption_test_case_256_7(void)
7701 return test_authenticated_encryption(&gcm_test_case_256_7);
7705 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7707 return test_authenticated_encryption(&gcm_test_case_aad_1);
7711 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7713 return test_authenticated_encryption(&gcm_test_case_aad_2);
7717 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7719 struct aead_test_data tdata;
7722 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7723 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7724 tdata.iv.data[0] += 1;
7725 res = test_authenticated_encryption(&tdata);
7726 if (res == -ENOTSUP)
7728 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7729 return TEST_SUCCESS;
7733 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7735 struct aead_test_data tdata;
7738 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7739 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7740 tdata.plaintext.data[0] += 1;
7741 res = test_authenticated_encryption(&tdata);
7742 if (res == -ENOTSUP)
7744 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7745 return TEST_SUCCESS;
7749 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7751 struct aead_test_data tdata;
7754 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7755 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7756 tdata.ciphertext.data[0] += 1;
7757 res = test_authenticated_encryption(&tdata);
7758 if (res == -ENOTSUP)
7760 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7761 return TEST_SUCCESS;
7765 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7767 struct aead_test_data tdata;
7770 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7771 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7773 res = test_authenticated_encryption(&tdata);
7774 if (res == -ENOTSUP)
7776 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7777 return TEST_SUCCESS;
7781 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7783 struct aead_test_data tdata;
7784 uint8_t aad[gcm_test_case_7.aad.len];
7787 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7788 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7789 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7791 tdata.aad.data = aad;
7792 res = test_authenticated_encryption(&tdata);
7793 if (res == -ENOTSUP)
7795 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7796 return TEST_SUCCESS;
7800 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7802 struct aead_test_data tdata;
7805 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7806 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7807 tdata.auth_tag.data[0] += 1;
7808 res = test_authenticated_encryption(&tdata);
7809 if (res == -ENOTSUP)
7811 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7812 return TEST_SUCCESS;
7816 test_authenticated_decryption(const struct aead_test_data *tdata)
7818 struct crypto_testsuite_params *ts_params = &testsuite_params;
7819 struct crypto_unittest_params *ut_params = &unittest_params;
7825 /* Verify the capabilities */
7826 struct rte_cryptodev_sym_capability_idx cap_idx;
7827 const struct rte_cryptodev_symmetric_capability *capability;
7828 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7829 cap_idx.algo.aead = tdata->algo;
7830 capability = rte_cryptodev_sym_capability_get(
7831 ts_params->valid_devs[0], &cap_idx);
7832 if (capability == NULL)
7834 if (rte_cryptodev_sym_capability_check_aead(
7835 capability, tdata->key.len, tdata->auth_tag.len,
7836 tdata->aad.len, tdata->iv.len))
7839 /* Create AEAD session */
7840 retval = create_aead_session(ts_params->valid_devs[0],
7842 RTE_CRYPTO_AEAD_OP_DECRYPT,
7843 tdata->key.data, tdata->key.len,
7844 tdata->aad.len, tdata->auth_tag.len,
7849 /* alloc mbuf and set payload */
7850 if (tdata->aad.len > MBUF_SIZE) {
7851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7852 /* Populate full size of add data */
7853 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7854 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7856 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7858 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7859 rte_pktmbuf_tailroom(ut_params->ibuf));
7861 /* Create AEAD operation */
7862 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7866 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7868 ut_params->op->sym->m_src = ut_params->ibuf;
7870 /* Process crypto operation */
7871 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7872 ut_params->op), "failed to process sym crypto op");
7874 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7875 "crypto op processing failed");
7877 if (ut_params->op->sym->m_dst)
7878 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7881 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7883 ut_params->op->sym->cipher.data.offset);
7885 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7888 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7890 tdata->plaintext.data,
7891 tdata->plaintext.len,
7892 "Plaintext data not as expected");
7894 TEST_ASSERT_EQUAL(ut_params->op->status,
7895 RTE_CRYPTO_OP_STATUS_SUCCESS,
7896 "Authentication failed");
7902 test_AES_GCM_authenticated_decryption_test_case_1(void)
7904 return test_authenticated_decryption(&gcm_test_case_1);
7908 test_AES_GCM_authenticated_decryption_test_case_2(void)
7910 return test_authenticated_decryption(&gcm_test_case_2);
7914 test_AES_GCM_authenticated_decryption_test_case_3(void)
7916 return test_authenticated_decryption(&gcm_test_case_3);
7920 test_AES_GCM_authenticated_decryption_test_case_4(void)
7922 return test_authenticated_decryption(&gcm_test_case_4);
7926 test_AES_GCM_authenticated_decryption_test_case_5(void)
7928 return test_authenticated_decryption(&gcm_test_case_5);
7932 test_AES_GCM_authenticated_decryption_test_case_6(void)
7934 return test_authenticated_decryption(&gcm_test_case_6);
7938 test_AES_GCM_authenticated_decryption_test_case_7(void)
7940 return test_authenticated_decryption(&gcm_test_case_7);
7944 test_AES_GCM_authenticated_decryption_test_case_8(void)
7946 return test_authenticated_decryption(&gcm_test_case_8);
7950 test_AES_GCM_auth_decryption_test_case_192_1(void)
7952 return test_authenticated_decryption(&gcm_test_case_192_1);
7956 test_AES_GCM_auth_decryption_test_case_192_2(void)
7958 return test_authenticated_decryption(&gcm_test_case_192_2);
7962 test_AES_GCM_auth_decryption_test_case_192_3(void)
7964 return test_authenticated_decryption(&gcm_test_case_192_3);
7968 test_AES_GCM_auth_decryption_test_case_192_4(void)
7970 return test_authenticated_decryption(&gcm_test_case_192_4);
7974 test_AES_GCM_auth_decryption_test_case_192_5(void)
7976 return test_authenticated_decryption(&gcm_test_case_192_5);
7980 test_AES_GCM_auth_decryption_test_case_192_6(void)
7982 return test_authenticated_decryption(&gcm_test_case_192_6);
7986 test_AES_GCM_auth_decryption_test_case_192_7(void)
7988 return test_authenticated_decryption(&gcm_test_case_192_7);
7992 test_AES_GCM_auth_decryption_test_case_256_1(void)
7994 return test_authenticated_decryption(&gcm_test_case_256_1);
7998 test_AES_GCM_auth_decryption_test_case_256_2(void)
8000 return test_authenticated_decryption(&gcm_test_case_256_2);
8004 test_AES_GCM_auth_decryption_test_case_256_3(void)
8006 return test_authenticated_decryption(&gcm_test_case_256_3);
8010 test_AES_GCM_auth_decryption_test_case_256_4(void)
8012 return test_authenticated_decryption(&gcm_test_case_256_4);
8016 test_AES_GCM_auth_decryption_test_case_256_5(void)
8018 return test_authenticated_decryption(&gcm_test_case_256_5);
8022 test_AES_GCM_auth_decryption_test_case_256_6(void)
8024 return test_authenticated_decryption(&gcm_test_case_256_6);
8028 test_AES_GCM_auth_decryption_test_case_256_7(void)
8030 return test_authenticated_decryption(&gcm_test_case_256_7);
8034 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8036 return test_authenticated_decryption(&gcm_test_case_aad_1);
8040 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8042 return test_authenticated_decryption(&gcm_test_case_aad_2);
8046 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8048 struct aead_test_data tdata;
8051 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8052 tdata.iv.data[0] += 1;
8053 res = test_authenticated_decryption(&tdata);
8054 if (res == -ENOTSUP)
8056 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8057 return TEST_SUCCESS;
8061 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8063 struct aead_test_data tdata;
8066 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8067 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8068 tdata.plaintext.data[0] += 1;
8069 res = test_authenticated_decryption(&tdata);
8070 if (res == -ENOTSUP)
8072 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8073 return TEST_SUCCESS;
8077 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8079 struct aead_test_data tdata;
8082 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8083 tdata.ciphertext.data[0] += 1;
8084 res = test_authenticated_decryption(&tdata);
8085 if (res == -ENOTSUP)
8087 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8088 return TEST_SUCCESS;
8092 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8094 struct aead_test_data tdata;
8097 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8099 res = test_authenticated_decryption(&tdata);
8100 if (res == -ENOTSUP)
8102 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8103 return TEST_SUCCESS;
8107 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8109 struct aead_test_data tdata;
8110 uint8_t aad[gcm_test_case_7.aad.len];
8113 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8114 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8116 tdata.aad.data = aad;
8117 res = test_authenticated_decryption(&tdata);
8118 if (res == -ENOTSUP)
8120 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8121 return TEST_SUCCESS;
8125 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8127 struct aead_test_data tdata;
8130 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8131 tdata.auth_tag.data[0] += 1;
8132 res = test_authenticated_decryption(&tdata);
8133 if (res == -ENOTSUP)
8135 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8136 return TEST_SUCCESS;
8140 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8142 struct crypto_testsuite_params *ts_params = &testsuite_params;
8143 struct crypto_unittest_params *ut_params = &unittest_params;
8146 uint8_t *ciphertext, *auth_tag;
8147 uint16_t plaintext_pad_len;
8149 /* Verify the capabilities */
8150 struct rte_cryptodev_sym_capability_idx cap_idx;
8151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8152 cap_idx.algo.aead = tdata->algo;
8153 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8157 /* Create AEAD session */
8158 retval = create_aead_session(ts_params->valid_devs[0],
8160 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8161 tdata->key.data, tdata->key.len,
8162 tdata->aad.len, tdata->auth_tag.len,
8167 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8168 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8170 /* clear mbuf payload */
8171 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8172 rte_pktmbuf_tailroom(ut_params->ibuf));
8173 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8174 rte_pktmbuf_tailroom(ut_params->obuf));
8176 /* Create AEAD operation */
8177 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8183 ut_params->op->sym->m_src = ut_params->ibuf;
8184 ut_params->op->sym->m_dst = ut_params->obuf;
8186 /* Process crypto operation */
8187 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8188 ut_params->op), "failed to process sym crypto op");
8190 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8191 "crypto op processing failed");
8193 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8195 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8196 ut_params->op->sym->cipher.data.offset);
8197 auth_tag = ciphertext + plaintext_pad_len;
8199 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8200 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8203 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8205 tdata->ciphertext.data,
8206 tdata->ciphertext.len,
8207 "Ciphertext data not as expected");
8209 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8211 tdata->auth_tag.data,
8212 tdata->auth_tag.len,
8213 "Generated auth tag not as expected");
8220 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8222 return test_authenticated_encryption_oop(&gcm_test_case_5);
8226 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8228 struct crypto_testsuite_params *ts_params = &testsuite_params;
8229 struct crypto_unittest_params *ut_params = &unittest_params;
8234 /* Verify the capabilities */
8235 struct rte_cryptodev_sym_capability_idx cap_idx;
8236 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8237 cap_idx.algo.aead = tdata->algo;
8238 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8242 /* Create AEAD session */
8243 retval = create_aead_session(ts_params->valid_devs[0],
8245 RTE_CRYPTO_AEAD_OP_DECRYPT,
8246 tdata->key.data, tdata->key.len,
8247 tdata->aad.len, tdata->auth_tag.len,
8252 /* alloc mbuf and set payload */
8253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8254 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8257 rte_pktmbuf_tailroom(ut_params->ibuf));
8258 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8259 rte_pktmbuf_tailroom(ut_params->obuf));
8261 /* Create AEAD operation */
8262 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8266 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8268 ut_params->op->sym->m_src = ut_params->ibuf;
8269 ut_params->op->sym->m_dst = ut_params->obuf;
8271 /* Process crypto operation */
8272 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8273 ut_params->op), "failed to process sym crypto op");
8275 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8276 "crypto op processing failed");
8278 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8279 ut_params->op->sym->cipher.data.offset);
8281 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8284 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8286 tdata->plaintext.data,
8287 tdata->plaintext.len,
8288 "Plaintext data not as expected");
8290 TEST_ASSERT_EQUAL(ut_params->op->status,
8291 RTE_CRYPTO_OP_STATUS_SUCCESS,
8292 "Authentication failed");
8297 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8299 return test_authenticated_decryption_oop(&gcm_test_case_5);
8303 test_authenticated_encryption_sessionless(
8304 const struct aead_test_data *tdata)
8306 struct crypto_testsuite_params *ts_params = &testsuite_params;
8307 struct crypto_unittest_params *ut_params = &unittest_params;
8310 uint8_t *ciphertext, *auth_tag;
8311 uint16_t plaintext_pad_len;
8312 uint8_t key[tdata->key.len + 1];
8314 /* This test is for AESNI MB and AESNI GCM PMDs only */
8315 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8317 (gbl_driver_id != rte_cryptodev_driver_id_get(
8318 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8321 /* Verify the capabilities */
8322 struct rte_cryptodev_sym_capability_idx cap_idx;
8323 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8324 cap_idx.algo.aead = tdata->algo;
8325 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8331 /* clear mbuf payload */
8332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8333 rte_pktmbuf_tailroom(ut_params->ibuf));
8335 /* Create AEAD operation */
8336 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8340 /* Create GCM xform */
8341 memcpy(key, tdata->key.data, tdata->key.len);
8342 retval = create_aead_xform(ut_params->op,
8344 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8345 key, tdata->key.len,
8346 tdata->aad.len, tdata->auth_tag.len,
8351 ut_params->op->sym->m_src = ut_params->ibuf;
8353 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8354 RTE_CRYPTO_OP_SESSIONLESS,
8355 "crypto op session type not sessionless");
8357 /* Process crypto operation */
8358 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8359 ut_params->op), "failed to process sym crypto op");
8361 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8363 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8364 "crypto op status not success");
8366 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8368 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8369 ut_params->op->sym->cipher.data.offset);
8370 auth_tag = ciphertext + plaintext_pad_len;
8372 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8373 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8376 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8378 tdata->ciphertext.data,
8379 tdata->ciphertext.len,
8380 "Ciphertext data not as expected");
8382 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8384 tdata->auth_tag.data,
8385 tdata->auth_tag.len,
8386 "Generated auth tag not as expected");
8393 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8395 return test_authenticated_encryption_sessionless(
8400 test_authenticated_decryption_sessionless(
8401 const struct aead_test_data *tdata)
8403 struct crypto_testsuite_params *ts_params = &testsuite_params;
8404 struct crypto_unittest_params *ut_params = &unittest_params;
8408 uint8_t key[tdata->key.len + 1];
8410 /* This test is for AESNI MB and AESNI GCM PMDs only */
8411 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8412 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8413 (gbl_driver_id != rte_cryptodev_driver_id_get(
8414 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8417 /* Verify the capabilities */
8418 struct rte_cryptodev_sym_capability_idx cap_idx;
8419 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8420 cap_idx.algo.aead = tdata->algo;
8421 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8425 /* alloc mbuf and set payload */
8426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8428 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8429 rte_pktmbuf_tailroom(ut_params->ibuf));
8431 /* Create AEAD operation */
8432 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8436 /* Create AEAD xform */
8437 memcpy(key, tdata->key.data, tdata->key.len);
8438 retval = create_aead_xform(ut_params->op,
8440 RTE_CRYPTO_AEAD_OP_DECRYPT,
8441 key, tdata->key.len,
8442 tdata->aad.len, tdata->auth_tag.len,
8447 ut_params->op->sym->m_src = ut_params->ibuf;
8449 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8450 RTE_CRYPTO_OP_SESSIONLESS,
8451 "crypto op session type not sessionless");
8453 /* Process crypto operation */
8454 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8455 ut_params->op), "failed to process sym crypto op");
8457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8459 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8460 "crypto op status not success");
8462 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8463 ut_params->op->sym->cipher.data.offset);
8465 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8468 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8470 tdata->plaintext.data,
8471 tdata->plaintext.len,
8472 "Plaintext data not as expected");
8474 TEST_ASSERT_EQUAL(ut_params->op->status,
8475 RTE_CRYPTO_OP_STATUS_SUCCESS,
8476 "Authentication failed");
8481 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8483 return test_authenticated_decryption_sessionless(
8488 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8490 return test_authenticated_encryption(&ccm_test_case_128_1);
8494 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8496 return test_authenticated_encryption(&ccm_test_case_128_2);
8500 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8502 return test_authenticated_encryption(&ccm_test_case_128_3);
8506 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8508 return test_authenticated_decryption(&ccm_test_case_128_1);
8512 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8514 return test_authenticated_decryption(&ccm_test_case_128_2);
8518 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8520 return test_authenticated_decryption(&ccm_test_case_128_3);
8524 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8526 return test_authenticated_encryption(&ccm_test_case_192_1);
8530 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8532 return test_authenticated_encryption(&ccm_test_case_192_2);
8536 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8538 return test_authenticated_encryption(&ccm_test_case_192_3);
8542 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8544 return test_authenticated_decryption(&ccm_test_case_192_1);
8548 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8550 return test_authenticated_decryption(&ccm_test_case_192_2);
8554 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8556 return test_authenticated_decryption(&ccm_test_case_192_3);
8560 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8562 return test_authenticated_encryption(&ccm_test_case_256_1);
8566 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8568 return test_authenticated_encryption(&ccm_test_case_256_2);
8572 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8574 return test_authenticated_encryption(&ccm_test_case_256_3);
8578 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8580 return test_authenticated_decryption(&ccm_test_case_256_1);
8584 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8586 return test_authenticated_decryption(&ccm_test_case_256_2);
8590 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8592 return test_authenticated_decryption(&ccm_test_case_256_3);
8598 struct crypto_testsuite_params *ts_params = &testsuite_params;
8599 struct rte_cryptodev_stats stats;
8600 struct rte_cryptodev *dev;
8601 cryptodev_stats_get_t temp_pfn;
8603 /* Verify the capabilities */
8604 struct rte_cryptodev_sym_capability_idx cap_idx;
8605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8606 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8610 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8611 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8616 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8617 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8618 &stats) == -ENODEV),
8619 "rte_cryptodev_stats_get invalid dev failed");
8620 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8621 "rte_cryptodev_stats_get invalid Param failed");
8622 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8623 temp_pfn = dev->dev_ops->stats_get;
8624 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8625 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8627 "rte_cryptodev_stats_get invalid Param failed");
8628 dev->dev_ops->stats_get = temp_pfn;
8630 /* Test expected values */
8632 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8634 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8636 "rte_cryptodev_stats_get failed");
8637 TEST_ASSERT((stats.enqueued_count == 1),
8638 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8639 TEST_ASSERT((stats.dequeued_count == 1),
8640 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8641 TEST_ASSERT((stats.enqueue_err_count == 0),
8642 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8643 TEST_ASSERT((stats.dequeue_err_count == 0),
8644 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8646 /* invalid device but should ignore and not reset device stats*/
8647 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8648 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8650 "rte_cryptodev_stats_get failed");
8651 TEST_ASSERT((stats.enqueued_count == 1),
8652 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8654 /* check that a valid reset clears stats */
8655 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8656 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8658 "rte_cryptodev_stats_get failed");
8659 TEST_ASSERT((stats.enqueued_count == 0),
8660 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8661 TEST_ASSERT((stats.dequeued_count == 0),
8662 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8664 return TEST_SUCCESS;
8667 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8668 struct crypto_unittest_params *ut_params,
8669 enum rte_crypto_auth_operation op,
8670 const struct HMAC_MD5_vector *test_case)
8674 memcpy(key, test_case->key.data, test_case->key.len);
8676 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8677 ut_params->auth_xform.next = NULL;
8678 ut_params->auth_xform.auth.op = op;
8680 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8682 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8683 ut_params->auth_xform.auth.key.length = test_case->key.len;
8684 ut_params->auth_xform.auth.key.data = key;
8686 ut_params->sess = rte_cryptodev_sym_session_create(
8687 ts_params->session_mpool);
8689 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8690 ut_params->sess, &ut_params->auth_xform,
8691 ts_params->session_priv_mpool);
8693 if (ut_params->sess == NULL)
8696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8698 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8699 rte_pktmbuf_tailroom(ut_params->ibuf));
8704 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8705 const struct HMAC_MD5_vector *test_case,
8706 uint8_t **plaintext)
8708 uint16_t plaintext_pad_len;
8710 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8712 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8715 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8717 memcpy(*plaintext, test_case->plaintext.data,
8718 test_case->plaintext.len);
8720 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8721 ut_params->ibuf, MD5_DIGEST_LEN);
8722 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8723 "no room to append digest");
8724 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8725 ut_params->ibuf, plaintext_pad_len);
8727 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8728 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8729 test_case->auth_tag.len);
8732 sym_op->auth.data.offset = 0;
8733 sym_op->auth.data.length = test_case->plaintext.len;
8735 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8736 ut_params->op->sym->m_src = ut_params->ibuf;
8742 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8744 uint16_t plaintext_pad_len;
8745 uint8_t *plaintext, *auth_tag;
8747 struct crypto_testsuite_params *ts_params = &testsuite_params;
8748 struct crypto_unittest_params *ut_params = &unittest_params;
8750 /* Verify the capabilities */
8751 struct rte_cryptodev_sym_capability_idx cap_idx;
8752 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8753 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8754 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8758 if (MD5_HMAC_create_session(ts_params, ut_params,
8759 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8762 /* Generate Crypto op data structure */
8763 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8764 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8765 TEST_ASSERT_NOT_NULL(ut_params->op,
8766 "Failed to allocate symmetric crypto operation struct");
8768 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8771 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8774 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8775 ut_params->op), "failed to process sym crypto op");
8777 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8778 "crypto op processing failed");
8780 if (ut_params->op->sym->m_dst) {
8781 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8782 uint8_t *, plaintext_pad_len);
8784 auth_tag = plaintext + plaintext_pad_len;
8787 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8789 test_case->auth_tag.data,
8790 test_case->auth_tag.len,
8791 "HMAC_MD5 generated tag not as expected");
8793 return TEST_SUCCESS;
8797 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8801 struct crypto_testsuite_params *ts_params = &testsuite_params;
8802 struct crypto_unittest_params *ut_params = &unittest_params;
8804 /* Verify the capabilities */
8805 struct rte_cryptodev_sym_capability_idx cap_idx;
8806 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8807 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8808 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8812 if (MD5_HMAC_create_session(ts_params, ut_params,
8813 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8817 /* Generate Crypto op data structure */
8818 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8819 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8820 TEST_ASSERT_NOT_NULL(ut_params->op,
8821 "Failed to allocate symmetric crypto operation struct");
8823 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8826 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8827 ut_params->op), "failed to process sym crypto op");
8829 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8830 "HMAC_MD5 crypto op processing failed");
8832 return TEST_SUCCESS;
8836 test_MD5_HMAC_generate_case_1(void)
8838 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8842 test_MD5_HMAC_verify_case_1(void)
8844 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8848 test_MD5_HMAC_generate_case_2(void)
8850 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8854 test_MD5_HMAC_verify_case_2(void)
8856 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8860 test_multi_session(void)
8862 struct crypto_testsuite_params *ts_params = &testsuite_params;
8863 struct crypto_unittest_params *ut_params = &unittest_params;
8865 struct rte_cryptodev_info dev_info;
8866 struct rte_cryptodev_sym_session **sessions;
8870 /* Verify the capabilities */
8871 struct rte_cryptodev_sym_capability_idx cap_idx;
8872 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8873 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
8874 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8877 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8878 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8879 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8883 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8884 aes_cbc_key, hmac_sha512_key);
8887 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8889 sessions = rte_malloc(NULL,
8890 (sizeof(struct rte_cryptodev_sym_session *) *
8891 MAX_NB_SESSIONS) + 1, 0);
8893 /* Create multiple crypto sessions*/
8894 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8896 sessions[i] = rte_cryptodev_sym_session_create(
8897 ts_params->session_mpool);
8899 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8900 sessions[i], &ut_params->auth_xform,
8901 ts_params->session_priv_mpool);
8902 TEST_ASSERT_NOT_NULL(sessions[i],
8903 "Session creation failed at session number %u",
8906 /* Attempt to send a request on each session */
8907 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8911 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8912 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8914 "Failed to perform decrypt on request number %u.", i);
8915 /* free crypto operation structure */
8917 rte_crypto_op_free(ut_params->op);
8920 * free mbuf - both obuf and ibuf are usually the same,
8921 * so check if they point at the same address is necessary,
8922 * to avoid freeing the mbuf twice.
8924 if (ut_params->obuf) {
8925 rte_pktmbuf_free(ut_params->obuf);
8926 if (ut_params->ibuf == ut_params->obuf)
8927 ut_params->ibuf = 0;
8928 ut_params->obuf = 0;
8930 if (ut_params->ibuf) {
8931 rte_pktmbuf_free(ut_params->ibuf);
8932 ut_params->ibuf = 0;
8936 /* Next session create should fail */
8937 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8938 sessions[i], &ut_params->auth_xform,
8939 ts_params->session_priv_mpool);
8940 TEST_ASSERT_NULL(sessions[i],
8941 "Session creation succeeded unexpectedly!");
8943 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8944 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8946 rte_cryptodev_sym_session_free(sessions[i]);
8951 return TEST_SUCCESS;
8954 struct multi_session_params {
8955 struct crypto_unittest_params ut_params;
8956 uint8_t *cipher_key;
8958 const uint8_t *cipher;
8959 const uint8_t *digest;
8963 #define MB_SESSION_NUMBER 3
8966 test_multi_session_random_usage(void)
8968 struct crypto_testsuite_params *ts_params = &testsuite_params;
8969 struct rte_cryptodev_info dev_info;
8970 struct rte_cryptodev_sym_session **sessions;
8972 struct multi_session_params ut_paramz[] = {
8975 .cipher_key = ms_aes_cbc_key0,
8976 .hmac_key = ms_hmac_key0,
8977 .cipher = ms_aes_cbc_cipher0,
8978 .digest = ms_hmac_digest0,
8979 .iv = ms_aes_cbc_iv0
8982 .cipher_key = ms_aes_cbc_key1,
8983 .hmac_key = ms_hmac_key1,
8984 .cipher = ms_aes_cbc_cipher1,
8985 .digest = ms_hmac_digest1,
8986 .iv = ms_aes_cbc_iv1
8989 .cipher_key = ms_aes_cbc_key2,
8990 .hmac_key = ms_hmac_key2,
8991 .cipher = ms_aes_cbc_cipher2,
8992 .digest = ms_hmac_digest2,
8993 .iv = ms_aes_cbc_iv2
8998 /* Verify the capabilities */
8999 struct rte_cryptodev_sym_capability_idx cap_idx;
9000 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9001 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9002 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9006 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9013 sessions = rte_malloc(NULL,
9014 (sizeof(struct rte_cryptodev_sym_session *)
9015 * MAX_NB_SESSIONS) + 1, 0);
9017 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9018 sessions[i] = rte_cryptodev_sym_session_create(
9019 ts_params->session_mpool);
9021 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9022 sizeof(struct crypto_unittest_params));
9024 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9025 &ut_paramz[i].ut_params,
9026 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9028 /* Create multiple crypto sessions*/
9029 rte_cryptodev_sym_session_init(
9030 ts_params->valid_devs[0],
9032 &ut_paramz[i].ut_params.auth_xform,
9033 ts_params->session_priv_mpool);
9035 TEST_ASSERT_NOT_NULL(sessions[i],
9036 "Session creation failed at session number %u",
9042 for (i = 0; i < 40000; i++) {
9044 j = rand() % MB_SESSION_NUMBER;
9046 TEST_ASSERT_SUCCESS(
9047 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9049 &ut_paramz[j].ut_params,
9050 ts_params, ut_paramz[j].cipher,
9051 ut_paramz[j].digest,
9053 "Failed to perform decrypt on request number %u.", i);
9055 if (ut_paramz[j].ut_params.op)
9056 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9059 * free mbuf - both obuf and ibuf are usually the same,
9060 * so check if they point at the same address is necessary,
9061 * to avoid freeing the mbuf twice.
9063 if (ut_paramz[j].ut_params.obuf) {
9064 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9065 if (ut_paramz[j].ut_params.ibuf
9066 == ut_paramz[j].ut_params.obuf)
9067 ut_paramz[j].ut_params.ibuf = 0;
9068 ut_paramz[j].ut_params.obuf = 0;
9070 if (ut_paramz[j].ut_params.ibuf) {
9071 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9072 ut_paramz[j].ut_params.ibuf = 0;
9076 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9077 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9079 rte_cryptodev_sym_session_free(sessions[i]);
9084 return TEST_SUCCESS;
9088 test_null_cipher_only_operation(void)
9090 struct crypto_testsuite_params *ts_params = &testsuite_params;
9091 struct crypto_unittest_params *ut_params = &unittest_params;
9093 /* Verify the capabilities */
9094 struct rte_cryptodev_sym_capability_idx cap_idx;
9095 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9096 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9097 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9101 /* Generate test mbuf data and space for digest */
9102 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9103 catch_22_quote, QUOTE_512_BYTES, 0);
9105 /* Setup Cipher Parameters */
9106 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9107 ut_params->cipher_xform.next = NULL;
9109 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9110 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9112 ut_params->sess = rte_cryptodev_sym_session_create(
9113 ts_params->session_mpool);
9115 /* Create Crypto session*/
9116 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9118 &ut_params->cipher_xform,
9119 ts_params->session_priv_mpool);
9120 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9122 /* Generate Crypto op data structure */
9123 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9124 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9125 TEST_ASSERT_NOT_NULL(ut_params->op,
9126 "Failed to allocate symmetric crypto operation struct");
9128 /* Set crypto operation data parameters */
9129 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9131 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9133 /* set crypto operation source mbuf */
9134 sym_op->m_src = ut_params->ibuf;
9136 sym_op->cipher.data.offset = 0;
9137 sym_op->cipher.data.length = QUOTE_512_BYTES;
9139 /* Process crypto operation */
9140 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9142 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9144 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9145 "crypto operation processing failed");
9148 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9149 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9152 "Ciphertext data not as expected");
9154 return TEST_SUCCESS;
9156 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9157 0xab, 0xab, 0xab, 0xab,
9158 0xab, 0xab, 0xab, 0xab,
9159 0xab, 0xab, 0xab, 0xab};
9161 test_null_auth_only_operation(void)
9163 struct crypto_testsuite_params *ts_params = &testsuite_params;
9164 struct crypto_unittest_params *ut_params = &unittest_params;
9167 /* Verify the capabilities */
9168 struct rte_cryptodev_sym_capability_idx cap_idx;
9169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9170 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9171 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9175 /* Generate test mbuf data and space for digest */
9176 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9177 catch_22_quote, QUOTE_512_BYTES, 0);
9179 /* create a pointer for digest, but don't expect anything to be written
9180 * here in a NULL auth algo so no mbuf append done.
9182 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9184 /* prefill the memory pointed to by digest */
9185 memcpy(digest, orig_data, sizeof(orig_data));
9187 /* Setup HMAC Parameters */
9188 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9189 ut_params->auth_xform.next = NULL;
9191 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9192 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9194 ut_params->sess = rte_cryptodev_sym_session_create(
9195 ts_params->session_mpool);
9197 /* Create Crypto session*/
9198 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9199 ut_params->sess, &ut_params->auth_xform,
9200 ts_params->session_priv_mpool);
9201 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9203 /* Generate Crypto op data structure */
9204 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9205 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9206 TEST_ASSERT_NOT_NULL(ut_params->op,
9207 "Failed to allocate symmetric crypto operation struct");
9209 /* Set crypto operation data parameters */
9210 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9212 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9214 sym_op->m_src = ut_params->ibuf;
9216 sym_op->auth.data.offset = 0;
9217 sym_op->auth.data.length = QUOTE_512_BYTES;
9218 sym_op->auth.digest.data = digest;
9219 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9222 /* Process crypto operation */
9223 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9225 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9227 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9228 "crypto operation processing failed");
9229 /* Make sure memory pointed to by digest hasn't been overwritten */
9230 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9234 "Memory at digest ptr overwritten unexpectedly");
9236 return TEST_SUCCESS;
9241 test_null_cipher_auth_operation(void)
9243 struct crypto_testsuite_params *ts_params = &testsuite_params;
9244 struct crypto_unittest_params *ut_params = &unittest_params;
9247 /* Verify the capabilities */
9248 struct rte_cryptodev_sym_capability_idx cap_idx;
9249 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9250 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9251 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9254 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9255 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9256 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9260 /* Generate test mbuf data and space for digest */
9261 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9262 catch_22_quote, QUOTE_512_BYTES, 0);
9264 /* create a pointer for digest, but don't expect anything to be written
9265 * here in a NULL auth algo so no mbuf append done.
9267 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9269 /* prefill the memory pointed to by digest */
9270 memcpy(digest, orig_data, sizeof(orig_data));
9272 /* Setup Cipher Parameters */
9273 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9274 ut_params->cipher_xform.next = &ut_params->auth_xform;
9276 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9277 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9279 /* Setup HMAC Parameters */
9280 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9281 ut_params->auth_xform.next = NULL;
9283 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9284 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9286 ut_params->sess = rte_cryptodev_sym_session_create(
9287 ts_params->session_mpool);
9289 /* Create Crypto session*/
9290 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9291 ut_params->sess, &ut_params->cipher_xform,
9292 ts_params->session_priv_mpool);
9293 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9295 /* Generate Crypto op data structure */
9296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9298 TEST_ASSERT_NOT_NULL(ut_params->op,
9299 "Failed to allocate symmetric crypto operation struct");
9301 /* Set crypto operation data parameters */
9302 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9304 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9306 sym_op->m_src = ut_params->ibuf;
9308 sym_op->cipher.data.offset = 0;
9309 sym_op->cipher.data.length = QUOTE_512_BYTES;
9311 sym_op->auth.data.offset = 0;
9312 sym_op->auth.data.length = QUOTE_512_BYTES;
9313 sym_op->auth.digest.data = digest;
9314 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9317 /* Process crypto operation */
9318 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9320 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9322 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9323 "crypto operation processing failed");
9326 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9327 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9330 "Ciphertext data not as expected");
9331 /* Make sure memory pointed to by digest hasn't been overwritten */
9332 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9336 "Memory at digest ptr overwritten unexpectedly");
9338 return TEST_SUCCESS;
9342 test_null_auth_cipher_operation(void)
9344 struct crypto_testsuite_params *ts_params = &testsuite_params;
9345 struct crypto_unittest_params *ut_params = &unittest_params;
9348 /* Verify the capabilities */
9349 struct rte_cryptodev_sym_capability_idx cap_idx;
9350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9351 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9355 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9356 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9357 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9361 /* Generate test mbuf data */
9362 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9363 catch_22_quote, QUOTE_512_BYTES, 0);
9365 /* create a pointer for digest, but don't expect anything to be written
9366 * here in a NULL auth algo so no mbuf append done.
9368 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9370 /* prefill the memory pointed to by digest */
9371 memcpy(digest, orig_data, sizeof(orig_data));
9373 /* Setup Cipher Parameters */
9374 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9375 ut_params->cipher_xform.next = NULL;
9377 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9378 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9380 /* Setup HMAC Parameters */
9381 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9382 ut_params->auth_xform.next = &ut_params->cipher_xform;
9384 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9385 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9387 ut_params->sess = rte_cryptodev_sym_session_create(
9388 ts_params->session_mpool);
9390 /* Create Crypto session*/
9391 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9392 ut_params->sess, &ut_params->cipher_xform,
9393 ts_params->session_priv_mpool);
9394 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9396 /* Generate Crypto op data structure */
9397 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9398 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9399 TEST_ASSERT_NOT_NULL(ut_params->op,
9400 "Failed to allocate symmetric crypto operation struct");
9402 /* Set crypto operation data parameters */
9403 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9405 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9407 sym_op->m_src = ut_params->ibuf;
9409 sym_op->cipher.data.offset = 0;
9410 sym_op->cipher.data.length = QUOTE_512_BYTES;
9412 sym_op->auth.data.offset = 0;
9413 sym_op->auth.data.length = QUOTE_512_BYTES;
9414 sym_op->auth.digest.data = digest;
9415 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9418 /* Process crypto operation */
9419 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9421 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9423 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9424 "crypto operation processing failed");
9427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9428 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9431 "Ciphertext data not as expected");
9432 /* Make sure memory pointed to by digest hasn't been overwritten */
9433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9437 "Memory at digest ptr overwritten unexpectedly");
9439 return TEST_SUCCESS;
9444 test_null_invalid_operation(void)
9446 struct crypto_testsuite_params *ts_params = &testsuite_params;
9447 struct crypto_unittest_params *ut_params = &unittest_params;
9450 /* This test is for NULL PMD only */
9451 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9452 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9455 /* Setup Cipher Parameters */
9456 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9457 ut_params->cipher_xform.next = NULL;
9459 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9460 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9462 ut_params->sess = rte_cryptodev_sym_session_create(
9463 ts_params->session_mpool);
9465 /* Create Crypto session*/
9466 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9467 ut_params->sess, &ut_params->cipher_xform,
9468 ts_params->session_priv_mpool);
9469 TEST_ASSERT(ret < 0,
9470 "Session creation succeeded unexpectedly");
9473 /* Setup HMAC Parameters */
9474 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9475 ut_params->auth_xform.next = NULL;
9477 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9478 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9480 ut_params->sess = rte_cryptodev_sym_session_create(
9481 ts_params->session_mpool);
9483 /* Create Crypto session*/
9484 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9485 ut_params->sess, &ut_params->auth_xform,
9486 ts_params->session_priv_mpool);
9487 TEST_ASSERT(ret < 0,
9488 "Session creation succeeded unexpectedly");
9490 return TEST_SUCCESS;
9494 #define NULL_BURST_LENGTH (32)
9497 test_null_burst_operation(void)
9499 struct crypto_testsuite_params *ts_params = &testsuite_params;
9500 struct crypto_unittest_params *ut_params = &unittest_params;
9502 unsigned i, burst_len = NULL_BURST_LENGTH;
9504 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9505 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9507 /* This test is for NULL PMD only */
9508 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9509 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9512 /* Setup Cipher Parameters */
9513 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9514 ut_params->cipher_xform.next = &ut_params->auth_xform;
9516 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9517 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9519 /* Setup HMAC Parameters */
9520 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9521 ut_params->auth_xform.next = NULL;
9523 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9524 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9526 ut_params->sess = rte_cryptodev_sym_session_create(
9527 ts_params->session_mpool);
9529 /* Create Crypto session*/
9530 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9531 ut_params->sess, &ut_params->cipher_xform,
9532 ts_params->session_priv_mpool);
9533 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9535 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9536 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9537 burst_len, "failed to generate burst of crypto ops");
9539 /* Generate an operation for each mbuf in burst */
9540 for (i = 0; i < burst_len; i++) {
9541 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9543 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9545 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9549 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9551 burst[i]->sym->m_src = m;
9554 /* Process crypto operation */
9555 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9556 0, burst, burst_len),
9558 "Error enqueuing burst");
9560 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9561 0, burst_dequeued, burst_len),
9563 "Error dequeuing burst");
9566 for (i = 0; i < burst_len; i++) {
9568 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9569 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9571 "data not as expected");
9573 rte_pktmbuf_free(burst[i]->sym->m_src);
9574 rte_crypto_op_free(burst[i]);
9577 return TEST_SUCCESS;
9581 generate_gmac_large_plaintext(uint8_t *data)
9585 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9586 memcpy(&data[i], &data[0], 32);
9590 create_gmac_operation(enum rte_crypto_auth_operation op,
9591 const struct gmac_test_data *tdata)
9593 struct crypto_testsuite_params *ts_params = &testsuite_params;
9594 struct crypto_unittest_params *ut_params = &unittest_params;
9595 struct rte_crypto_sym_op *sym_op;
9597 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9599 /* Generate Crypto op data structure */
9600 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9601 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9602 TEST_ASSERT_NOT_NULL(ut_params->op,
9603 "Failed to allocate symmetric crypto operation struct");
9605 sym_op = ut_params->op->sym;
9607 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9608 ut_params->ibuf, tdata->gmac_tag.len);
9609 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9610 "no room to append digest");
9612 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9613 ut_params->ibuf, plaintext_pad_len);
9615 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9616 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9617 tdata->gmac_tag.len);
9618 debug_hexdump(stdout, "digest:",
9619 sym_op->auth.digest.data,
9620 tdata->gmac_tag.len);
9623 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9624 uint8_t *, IV_OFFSET);
9626 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9628 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9630 sym_op->cipher.data.length = 0;
9631 sym_op->cipher.data.offset = 0;
9633 sym_op->auth.data.offset = 0;
9634 sym_op->auth.data.length = tdata->plaintext.len;
9639 static int create_gmac_session(uint8_t dev_id,
9640 const struct gmac_test_data *tdata,
9641 enum rte_crypto_auth_operation auth_op)
9643 uint8_t auth_key[tdata->key.len];
9645 struct crypto_testsuite_params *ts_params = &testsuite_params;
9646 struct crypto_unittest_params *ut_params = &unittest_params;
9648 memcpy(auth_key, tdata->key.data, tdata->key.len);
9650 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9651 ut_params->auth_xform.next = NULL;
9653 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9654 ut_params->auth_xform.auth.op = auth_op;
9655 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9656 ut_params->auth_xform.auth.key.length = tdata->key.len;
9657 ut_params->auth_xform.auth.key.data = auth_key;
9658 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9659 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9662 ut_params->sess = rte_cryptodev_sym_session_create(
9663 ts_params->session_mpool);
9665 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9666 &ut_params->auth_xform,
9667 ts_params->session_priv_mpool);
9669 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9675 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9677 struct crypto_testsuite_params *ts_params = &testsuite_params;
9678 struct crypto_unittest_params *ut_params = &unittest_params;
9682 uint8_t *auth_tag, *plaintext;
9683 uint16_t plaintext_pad_len;
9685 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9686 "No GMAC length in the source data");
9688 /* Verify the capabilities */
9689 struct rte_cryptodev_sym_capability_idx cap_idx;
9690 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9691 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9696 retval = create_gmac_session(ts_params->valid_devs[0],
9697 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9702 if (tdata->plaintext.len > MBUF_SIZE)
9703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9705 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9706 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9707 "Failed to allocate input buffer in mempool");
9709 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9710 rte_pktmbuf_tailroom(ut_params->ibuf));
9712 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9714 * Runtime generate the large plain text instead of use hard code
9715 * plain text vector. It is done to avoid create huge source file
9716 * with the test vector.
9718 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9719 generate_gmac_large_plaintext(tdata->plaintext.data);
9721 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9723 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9725 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9726 debug_hexdump(stdout, "plaintext:", plaintext,
9727 tdata->plaintext.len);
9729 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9735 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9737 ut_params->op->sym->m_src = ut_params->ibuf;
9739 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9740 ut_params->op), "failed to process sym crypto op");
9742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9743 "crypto op processing failed");
9745 if (ut_params->op->sym->m_dst) {
9746 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9747 uint8_t *, plaintext_pad_len);
9749 auth_tag = plaintext + plaintext_pad_len;
9752 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9754 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9756 tdata->gmac_tag.data,
9757 tdata->gmac_tag.len,
9758 "GMAC Generated auth tag not as expected");
9764 test_AES_GMAC_authentication_test_case_1(void)
9766 return test_AES_GMAC_authentication(&gmac_test_case_1);
9770 test_AES_GMAC_authentication_test_case_2(void)
9772 return test_AES_GMAC_authentication(&gmac_test_case_2);
9776 test_AES_GMAC_authentication_test_case_3(void)
9778 return test_AES_GMAC_authentication(&gmac_test_case_3);
9782 test_AES_GMAC_authentication_test_case_4(void)
9784 return test_AES_GMAC_authentication(&gmac_test_case_4);
9788 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9790 struct crypto_testsuite_params *ts_params = &testsuite_params;
9791 struct crypto_unittest_params *ut_params = &unittest_params;
9793 uint32_t plaintext_pad_len;
9796 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9797 "No GMAC length in the source data");
9799 /* Verify the capabilities */
9800 struct rte_cryptodev_sym_capability_idx cap_idx;
9801 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9802 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9803 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9807 retval = create_gmac_session(ts_params->valid_devs[0],
9808 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9813 if (tdata->plaintext.len > MBUF_SIZE)
9814 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9816 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9817 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9818 "Failed to allocate input buffer in mempool");
9820 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9821 rte_pktmbuf_tailroom(ut_params->ibuf));
9823 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9826 * Runtime generate the large plain text instead of use hard code
9827 * plain text vector. It is done to avoid create huge source file
9828 * with the test vector.
9830 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9831 generate_gmac_large_plaintext(tdata->plaintext.data);
9833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9835 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9837 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9838 debug_hexdump(stdout, "plaintext:", plaintext,
9839 tdata->plaintext.len);
9841 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9847 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9849 ut_params->op->sym->m_src = ut_params->ibuf;
9851 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9852 ut_params->op), "failed to process sym crypto op");
9854 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9855 "crypto op processing failed");
9862 test_AES_GMAC_authentication_verify_test_case_1(void)
9864 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9868 test_AES_GMAC_authentication_verify_test_case_2(void)
9870 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9874 test_AES_GMAC_authentication_verify_test_case_3(void)
9876 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
9880 test_AES_GMAC_authentication_verify_test_case_4(void)
9882 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
9885 struct test_crypto_vector {
9886 enum rte_crypto_cipher_algorithm crypto_algo;
9887 unsigned int cipher_offset;
9888 unsigned int cipher_len;
9901 const uint8_t *data;
9906 const uint8_t *data;
9910 enum rte_crypto_auth_algorithm auth_algo;
9911 unsigned int auth_offset;
9919 const uint8_t *data;
9929 static const struct test_crypto_vector
9930 hmac_sha1_test_crypto_vector = {
9931 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9933 .data = plaintext_hash,
9938 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9939 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9940 0xDE, 0xF4, 0xDE, 0xAD
9946 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9947 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9948 0x3F, 0x91, 0x64, 0x59
9954 static const struct test_crypto_vector
9955 aes128_gmac_test_vector = {
9956 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9958 .data = plaintext_hash,
9963 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9964 0x08, 0x09, 0x0A, 0x0B
9970 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9971 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9977 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9978 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9984 static const struct test_crypto_vector
9985 aes128cbc_hmac_sha1_test_vector = {
9986 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9991 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9992 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9998 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9999 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10004 .data = plaintext_hash,
10008 .data = ciphertext512_aes128cbc,
10011 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10015 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10016 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10017 0xDE, 0xF4, 0xDE, 0xAD
10023 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10024 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10025 0x18, 0x8C, 0x1D, 0x32
10031 static const struct test_crypto_vector
10032 aes128cbc_hmac_sha1_aad_test_vector = {
10033 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10034 .cipher_offset = 12,
10038 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10039 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10045 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10046 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10051 .data = plaintext_hash,
10055 .data = ciphertext512_aes128cbc_aad,
10058 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10062 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10063 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10064 0xDE, 0xF4, 0xDE, 0xAD
10070 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10071 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10072 0x62, 0x8D, 0x62, 0x65
10079 data_corruption(uint8_t *data)
10085 tag_corruption(uint8_t *data, unsigned int tag_offset)
10087 data[tag_offset] += 1;
10091 create_auth_session(struct crypto_unittest_params *ut_params,
10093 const struct test_crypto_vector *reference,
10094 enum rte_crypto_auth_operation auth_op)
10096 struct crypto_testsuite_params *ts_params = &testsuite_params;
10097 uint8_t auth_key[reference->auth_key.len + 1];
10099 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10101 /* Setup Authentication Parameters */
10102 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10103 ut_params->auth_xform.auth.op = auth_op;
10104 ut_params->auth_xform.next = NULL;
10105 ut_params->auth_xform.auth.algo = reference->auth_algo;
10106 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10107 ut_params->auth_xform.auth.key.data = auth_key;
10108 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10110 /* Create Crypto session*/
10111 ut_params->sess = rte_cryptodev_sym_session_create(
10112 ts_params->session_mpool);
10114 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10115 &ut_params->auth_xform,
10116 ts_params->session_priv_mpool);
10118 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10124 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10126 const struct test_crypto_vector *reference,
10127 enum rte_crypto_auth_operation auth_op,
10128 enum rte_crypto_cipher_operation cipher_op)
10130 struct crypto_testsuite_params *ts_params = &testsuite_params;
10131 uint8_t cipher_key[reference->cipher_key.len + 1];
10132 uint8_t auth_key[reference->auth_key.len + 1];
10134 memcpy(cipher_key, reference->cipher_key.data,
10135 reference->cipher_key.len);
10136 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10138 /* Setup Authentication Parameters */
10139 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10140 ut_params->auth_xform.auth.op = auth_op;
10141 ut_params->auth_xform.auth.algo = reference->auth_algo;
10142 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10143 ut_params->auth_xform.auth.key.data = auth_key;
10144 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10146 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10147 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10148 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10150 ut_params->auth_xform.next = &ut_params->cipher_xform;
10152 /* Setup Cipher Parameters */
10153 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10154 ut_params->cipher_xform.next = NULL;
10155 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10156 ut_params->cipher_xform.cipher.op = cipher_op;
10157 ut_params->cipher_xform.cipher.key.data = cipher_key;
10158 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10159 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10160 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10163 /* Create Crypto session*/
10164 ut_params->sess = rte_cryptodev_sym_session_create(
10165 ts_params->session_mpool);
10167 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10168 &ut_params->auth_xform,
10169 ts_params->session_priv_mpool);
10171 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10177 create_auth_operation(struct crypto_testsuite_params *ts_params,
10178 struct crypto_unittest_params *ut_params,
10179 const struct test_crypto_vector *reference,
10180 unsigned int auth_generate)
10182 /* Generate Crypto op data structure */
10183 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10184 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10185 TEST_ASSERT_NOT_NULL(ut_params->op,
10186 "Failed to allocate pktmbuf offload");
10188 /* Set crypto operation data parameters */
10189 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10191 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10193 /* set crypto operation source mbuf */
10194 sym_op->m_src = ut_params->ibuf;
10197 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10198 ut_params->ibuf, reference->digest.len);
10200 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10201 "no room to append auth tag");
10203 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10204 ut_params->ibuf, reference->plaintext.len);
10207 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10209 memcpy(sym_op->auth.digest.data,
10210 reference->digest.data,
10211 reference->digest.len);
10213 debug_hexdump(stdout, "digest:",
10214 sym_op->auth.digest.data,
10215 reference->digest.len);
10217 sym_op->auth.data.length = reference->plaintext.len;
10218 sym_op->auth.data.offset = 0;
10224 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10225 struct crypto_unittest_params *ut_params,
10226 const struct test_crypto_vector *reference,
10227 unsigned int auth_generate)
10229 /* Generate Crypto op data structure */
10230 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10231 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10232 TEST_ASSERT_NOT_NULL(ut_params->op,
10233 "Failed to allocate pktmbuf offload");
10235 /* Set crypto operation data parameters */
10236 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10238 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10240 /* set crypto operation source mbuf */
10241 sym_op->m_src = ut_params->ibuf;
10244 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10245 ut_params->ibuf, reference->digest.len);
10247 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10248 "no room to append auth tag");
10250 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10251 ut_params->ibuf, reference->ciphertext.len);
10254 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10256 memcpy(sym_op->auth.digest.data,
10257 reference->digest.data,
10258 reference->digest.len);
10260 debug_hexdump(stdout, "digest:",
10261 sym_op->auth.digest.data,
10262 reference->digest.len);
10264 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10265 reference->iv.data, reference->iv.len);
10267 sym_op->cipher.data.length = 0;
10268 sym_op->cipher.data.offset = 0;
10270 sym_op->auth.data.length = reference->plaintext.len;
10271 sym_op->auth.data.offset = 0;
10277 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10278 struct crypto_unittest_params *ut_params,
10279 const struct test_crypto_vector *reference,
10280 unsigned int auth_generate)
10282 /* Generate Crypto op data structure */
10283 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10284 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10285 TEST_ASSERT_NOT_NULL(ut_params->op,
10286 "Failed to allocate pktmbuf offload");
10288 /* Set crypto operation data parameters */
10289 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10291 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10293 /* set crypto operation source mbuf */
10294 sym_op->m_src = ut_params->ibuf;
10297 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10298 ut_params->ibuf, reference->digest.len);
10300 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10301 "no room to append auth tag");
10303 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10304 ut_params->ibuf, reference->ciphertext.len);
10307 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10309 memcpy(sym_op->auth.digest.data,
10310 reference->digest.data,
10311 reference->digest.len);
10313 debug_hexdump(stdout, "digest:",
10314 sym_op->auth.digest.data,
10315 reference->digest.len);
10317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10318 reference->iv.data, reference->iv.len);
10320 sym_op->cipher.data.length = reference->cipher_len;
10321 sym_op->cipher.data.offset = reference->cipher_offset;
10323 sym_op->auth.data.length = reference->plaintext.len;
10324 sym_op->auth.data.offset = reference->auth_offset;
10330 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10331 struct crypto_unittest_params *ut_params,
10332 const struct test_crypto_vector *reference)
10334 return create_auth_operation(ts_params, ut_params, reference, 0);
10338 create_auth_verify_GMAC_operation(
10339 struct crypto_testsuite_params *ts_params,
10340 struct crypto_unittest_params *ut_params,
10341 const struct test_crypto_vector *reference)
10343 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10347 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10348 struct crypto_unittest_params *ut_params,
10349 const struct test_crypto_vector *reference)
10351 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10355 test_authentication_verify_fail_when_data_corruption(
10356 struct crypto_testsuite_params *ts_params,
10357 struct crypto_unittest_params *ut_params,
10358 const struct test_crypto_vector *reference,
10359 unsigned int data_corrupted)
10363 uint8_t *plaintext;
10365 /* Verify the capabilities */
10366 struct rte_cryptodev_sym_capability_idx cap_idx;
10367 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10368 cap_idx.algo.auth = reference->auth_algo;
10369 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10373 /* Create session */
10374 retval = create_auth_session(ut_params,
10375 ts_params->valid_devs[0],
10377 RTE_CRYPTO_AUTH_OP_VERIFY);
10381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10382 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10383 "Failed to allocate input buffer in mempool");
10385 /* clear mbuf payload */
10386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10387 rte_pktmbuf_tailroom(ut_params->ibuf));
10389 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10390 reference->plaintext.len);
10391 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10392 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10394 debug_hexdump(stdout, "plaintext:", plaintext,
10395 reference->plaintext.len);
10397 /* Create operation */
10398 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10403 if (data_corrupted)
10404 data_corruption(plaintext);
10406 tag_corruption(plaintext, reference->plaintext.len);
10408 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10411 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10417 test_authentication_verify_GMAC_fail_when_corruption(
10418 struct crypto_testsuite_params *ts_params,
10419 struct crypto_unittest_params *ut_params,
10420 const struct test_crypto_vector *reference,
10421 unsigned int data_corrupted)
10424 uint8_t *plaintext;
10426 /* Verify the capabilities */
10427 struct rte_cryptodev_sym_capability_idx cap_idx;
10428 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10429 cap_idx.algo.auth = reference->auth_algo;
10430 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10434 /* Create session */
10435 retval = create_auth_cipher_session(ut_params,
10436 ts_params->valid_devs[0],
10438 RTE_CRYPTO_AUTH_OP_VERIFY,
10439 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10444 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10445 "Failed to allocate input buffer in mempool");
10447 /* clear mbuf payload */
10448 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10449 rte_pktmbuf_tailroom(ut_params->ibuf));
10451 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10452 reference->plaintext.len);
10453 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10454 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10456 debug_hexdump(stdout, "plaintext:", plaintext,
10457 reference->plaintext.len);
10459 /* Create operation */
10460 retval = create_auth_verify_GMAC_operation(ts_params,
10467 if (data_corrupted)
10468 data_corruption(plaintext);
10470 tag_corruption(plaintext, reference->aad.len);
10472 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10475 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10481 test_authenticated_decryption_fail_when_corruption(
10482 struct crypto_testsuite_params *ts_params,
10483 struct crypto_unittest_params *ut_params,
10484 const struct test_crypto_vector *reference,
10485 unsigned int data_corrupted)
10489 uint8_t *ciphertext;
10491 /* Verify the capabilities */
10492 struct rte_cryptodev_sym_capability_idx cap_idx;
10493 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10494 cap_idx.algo.auth = reference->auth_algo;
10495 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10499 cap_idx.algo.cipher = reference->crypto_algo;
10500 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10504 /* Create session */
10505 retval = create_auth_cipher_session(ut_params,
10506 ts_params->valid_devs[0],
10508 RTE_CRYPTO_AUTH_OP_VERIFY,
10509 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10514 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10515 "Failed to allocate input buffer in mempool");
10517 /* clear mbuf payload */
10518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10519 rte_pktmbuf_tailroom(ut_params->ibuf));
10521 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10522 reference->ciphertext.len);
10523 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10524 memcpy(ciphertext, reference->ciphertext.data,
10525 reference->ciphertext.len);
10527 /* Create operation */
10528 retval = create_cipher_auth_verify_operation(ts_params,
10535 if (data_corrupted)
10536 data_corruption(ciphertext);
10538 tag_corruption(ciphertext, reference->ciphertext.len);
10540 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10543 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10549 test_authenticated_encryt_with_esn(
10550 struct crypto_testsuite_params *ts_params,
10551 struct crypto_unittest_params *ut_params,
10552 const struct test_crypto_vector *reference)
10556 uint8_t *authciphertext, *plaintext, *auth_tag;
10557 uint16_t plaintext_pad_len;
10558 uint8_t cipher_key[reference->cipher_key.len + 1];
10559 uint8_t auth_key[reference->auth_key.len + 1];
10561 /* Verify the capabilities */
10562 struct rte_cryptodev_sym_capability_idx cap_idx;
10563 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10564 cap_idx.algo.auth = reference->auth_algo;
10565 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10568 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10569 cap_idx.algo.cipher = reference->crypto_algo;
10570 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10574 /* Create session */
10575 memcpy(cipher_key, reference->cipher_key.data,
10576 reference->cipher_key.len);
10577 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10579 /* Setup Cipher Parameters */
10580 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10581 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10582 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10583 ut_params->cipher_xform.cipher.key.data = cipher_key;
10584 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10585 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10586 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10588 ut_params->cipher_xform.next = &ut_params->auth_xform;
10590 /* Setup Authentication Parameters */
10591 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10592 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10593 ut_params->auth_xform.auth.algo = reference->auth_algo;
10594 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10595 ut_params->auth_xform.auth.key.data = auth_key;
10596 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10597 ut_params->auth_xform.next = NULL;
10599 /* Create Crypto session*/
10600 ut_params->sess = rte_cryptodev_sym_session_create(
10601 ts_params->session_mpool);
10603 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10605 &ut_params->cipher_xform,
10606 ts_params->session_priv_mpool);
10608 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10610 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10611 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10612 "Failed to allocate input buffer in mempool");
10614 /* clear mbuf payload */
10615 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10616 rte_pktmbuf_tailroom(ut_params->ibuf));
10618 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10619 reference->plaintext.len);
10620 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10621 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10623 /* Create operation */
10624 retval = create_cipher_auth_operation(ts_params,
10631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10634 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10636 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10637 "crypto op processing failed");
10639 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10641 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10642 ut_params->op->sym->auth.data.offset);
10643 auth_tag = authciphertext + plaintext_pad_len;
10644 debug_hexdump(stdout, "ciphertext:", authciphertext,
10645 reference->ciphertext.len);
10646 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10648 /* Validate obuf */
10649 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10651 reference->ciphertext.data,
10652 reference->ciphertext.len,
10653 "Ciphertext data not as expected");
10655 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10657 reference->digest.data,
10658 reference->digest.len,
10659 "Generated digest not as expected");
10661 return TEST_SUCCESS;
10666 test_authenticated_decrypt_with_esn(
10667 struct crypto_testsuite_params *ts_params,
10668 struct crypto_unittest_params *ut_params,
10669 const struct test_crypto_vector *reference)
10673 uint8_t *ciphertext;
10674 uint8_t cipher_key[reference->cipher_key.len + 1];
10675 uint8_t auth_key[reference->auth_key.len + 1];
10677 /* Verify the capabilities */
10678 struct rte_cryptodev_sym_capability_idx cap_idx;
10679 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10680 cap_idx.algo.auth = reference->auth_algo;
10681 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10684 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10685 cap_idx.algo.cipher = reference->crypto_algo;
10686 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10690 /* Create session */
10691 memcpy(cipher_key, reference->cipher_key.data,
10692 reference->cipher_key.len);
10693 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10695 /* Setup Authentication Parameters */
10696 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10697 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10698 ut_params->auth_xform.auth.algo = reference->auth_algo;
10699 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10700 ut_params->auth_xform.auth.key.data = auth_key;
10701 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10702 ut_params->auth_xform.next = &ut_params->cipher_xform;
10704 /* Setup Cipher Parameters */
10705 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10706 ut_params->cipher_xform.next = NULL;
10707 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10708 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10709 ut_params->cipher_xform.cipher.key.data = cipher_key;
10710 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10711 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10712 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10714 /* Create Crypto session*/
10715 ut_params->sess = rte_cryptodev_sym_session_create(
10716 ts_params->session_mpool);
10718 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10720 &ut_params->auth_xform,
10721 ts_params->session_priv_mpool);
10723 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10725 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10726 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10727 "Failed to allocate input buffer in mempool");
10729 /* clear mbuf payload */
10730 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10731 rte_pktmbuf_tailroom(ut_params->ibuf));
10733 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10734 reference->ciphertext.len);
10735 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10736 memcpy(ciphertext, reference->ciphertext.data,
10737 reference->ciphertext.len);
10739 /* Create operation */
10740 retval = create_cipher_auth_verify_operation(ts_params,
10747 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10751 TEST_ASSERT_EQUAL(ut_params->op->status,
10752 RTE_CRYPTO_OP_STATUS_SUCCESS,
10753 "crypto op processing passed");
10755 ut_params->obuf = ut_params->op->sym->m_src;
10756 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10762 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10763 const struct aead_test_data *tdata,
10764 void *digest_mem, uint64_t digest_phys)
10766 struct crypto_testsuite_params *ts_params = &testsuite_params;
10767 struct crypto_unittest_params *ut_params = &unittest_params;
10769 const unsigned int auth_tag_len = tdata->auth_tag.len;
10770 const unsigned int iv_len = tdata->iv.len;
10771 unsigned int aad_len = tdata->aad.len;
10772 unsigned int aad_len_pad = 0;
10774 /* Generate Crypto op data structure */
10775 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10776 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10777 TEST_ASSERT_NOT_NULL(ut_params->op,
10778 "Failed to allocate symmetric crypto operation struct");
10780 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10782 sym_op->aead.digest.data = digest_mem;
10784 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10785 "no room to append digest");
10787 sym_op->aead.digest.phys_addr = digest_phys;
10789 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10790 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10792 debug_hexdump(stdout, "digest:",
10793 sym_op->aead.digest.data,
10797 /* Append aad data */
10798 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10799 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10800 uint8_t *, IV_OFFSET);
10802 /* Copy IV 1 byte after the IV pointer, according to the API */
10803 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10805 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10807 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10808 ut_params->ibuf, aad_len);
10809 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10810 "no room to prepend aad");
10811 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10814 memset(sym_op->aead.aad.data, 0, aad_len);
10815 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10816 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10818 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10819 debug_hexdump(stdout, "aad:",
10820 sym_op->aead.aad.data, aad_len);
10822 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10823 uint8_t *, IV_OFFSET);
10825 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10827 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
10829 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10830 ut_params->ibuf, aad_len_pad);
10831 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10832 "no room to prepend aad");
10833 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10836 memset(sym_op->aead.aad.data, 0, aad_len);
10837 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10839 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10840 debug_hexdump(stdout, "aad:",
10841 sym_op->aead.aad.data, aad_len);
10844 sym_op->aead.data.length = tdata->plaintext.len;
10845 sym_op->aead.data.offset = aad_len_pad;
10850 #define SGL_MAX_NO 16
10853 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10854 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10856 struct crypto_testsuite_params *ts_params = &testsuite_params;
10857 struct crypto_unittest_params *ut_params = &unittest_params;
10858 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10861 int to_trn_tbl[SGL_MAX_NO];
10863 unsigned int trn_data = 0;
10864 uint8_t *plaintext, *ciphertext, *auth_tag;
10865 struct rte_cryptodev_info dev_info;
10867 /* Verify the capabilities */
10868 struct rte_cryptodev_sym_capability_idx cap_idx;
10869 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10870 cap_idx.algo.aead = tdata->algo;
10871 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10875 /* Detailed check for the particular SGL support flag */
10876 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10878 unsigned int sgl_in = fragsz < tdata->plaintext.len;
10879 if (sgl_in && (!(dev_info.feature_flags &
10880 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
10883 unsigned int sgl_in = fragsz < tdata->plaintext.len;
10884 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
10885 tdata->plaintext.len;
10886 if (sgl_in && !sgl_out) {
10887 if (!(dev_info.feature_flags &
10888 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
10890 } else if (!sgl_in && sgl_out) {
10891 if (!(dev_info.feature_flags &
10892 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
10894 } else if (sgl_in && sgl_out) {
10895 if (!(dev_info.feature_flags &
10896 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
10901 if (fragsz > tdata->plaintext.len)
10902 fragsz = tdata->plaintext.len;
10904 uint16_t plaintext_len = fragsz;
10905 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
10907 if (fragsz_oop > tdata->plaintext.len)
10908 frag_size_oop = tdata->plaintext.len;
10911 void *digest_mem = NULL;
10913 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
10915 if (tdata->plaintext.len % fragsz != 0) {
10916 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
10919 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
10924 * For out-op-place we need to alloc another mbuf
10927 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10928 rte_pktmbuf_append(ut_params->obuf,
10929 frag_size_oop + prepend_len);
10930 buf_oop = ut_params->obuf;
10933 /* Create AEAD session */
10934 retval = create_aead_session(ts_params->valid_devs[0],
10936 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10937 tdata->key.data, tdata->key.len,
10938 tdata->aad.len, tdata->auth_tag.len,
10943 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10945 /* clear mbuf payload */
10946 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10947 rte_pktmbuf_tailroom(ut_params->ibuf));
10949 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10952 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10954 trn_data += plaintext_len;
10956 buf = ut_params->ibuf;
10959 * Loop until no more fragments
10962 while (trn_data < tdata->plaintext.len) {
10964 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10965 (tdata->plaintext.len - trn_data) : fragsz;
10967 to_trn_tbl[ecx++] = to_trn;
10969 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10972 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10973 rte_pktmbuf_tailroom(buf));
10976 if (oop && !fragsz_oop) {
10977 buf_last_oop = buf_oop->next =
10978 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10979 buf_oop = buf_oop->next;
10980 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10981 0, rte_pktmbuf_tailroom(buf_oop));
10982 rte_pktmbuf_append(buf_oop, to_trn);
10985 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10988 memcpy(plaintext, tdata->plaintext.data + trn_data,
10990 trn_data += to_trn;
10991 if (trn_data == tdata->plaintext.len) {
10994 digest_mem = rte_pktmbuf_append(buf_oop,
10995 tdata->auth_tag.len);
10997 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10998 tdata->auth_tag.len);
11002 uint64_t digest_phys = 0;
11004 ut_params->ibuf->nb_segs = segs;
11007 if (fragsz_oop && oop) {
11011 if (frag_size_oop == tdata->plaintext.len) {
11012 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11013 tdata->auth_tag.len);
11015 digest_phys = rte_pktmbuf_iova_offset(
11017 tdata->plaintext.len + prepend_len);
11020 trn_data = frag_size_oop;
11021 while (trn_data < tdata->plaintext.len) {
11024 (tdata->plaintext.len - trn_data <
11026 (tdata->plaintext.len - trn_data) :
11029 to_trn_tbl[ecx++] = to_trn;
11031 buf_last_oop = buf_oop->next =
11032 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11033 buf_oop = buf_oop->next;
11034 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11035 0, rte_pktmbuf_tailroom(buf_oop));
11036 rte_pktmbuf_append(buf_oop, to_trn);
11038 trn_data += to_trn;
11040 if (trn_data == tdata->plaintext.len) {
11041 digest_mem = rte_pktmbuf_append(buf_oop,
11042 tdata->auth_tag.len);
11046 ut_params->obuf->nb_segs = segs;
11050 * Place digest at the end of the last buffer
11053 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11054 if (oop && buf_last_oop)
11055 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11057 if (!digest_mem && !oop) {
11058 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11059 + tdata->auth_tag.len);
11060 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11061 tdata->plaintext.len);
11064 /* Create AEAD operation */
11065 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11066 tdata, digest_mem, digest_phys);
11071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11073 ut_params->op->sym->m_src = ut_params->ibuf;
11075 ut_params->op->sym->m_dst = ut_params->obuf;
11077 /* Process crypto operation */
11078 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11079 ut_params->op), "failed to process sym crypto op");
11081 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11082 "crypto op processing failed");
11085 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11086 uint8_t *, prepend_len);
11088 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11089 uint8_t *, prepend_len);
11093 fragsz = fragsz_oop;
11095 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11097 tdata->ciphertext.data,
11099 "Ciphertext data not as expected");
11101 buf = ut_params->op->sym->m_src->next;
11103 buf = ut_params->op->sym->m_dst->next;
11105 unsigned int off = fragsz;
11109 ciphertext = rte_pktmbuf_mtod(buf,
11112 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11114 tdata->ciphertext.data + off,
11116 "Ciphertext data not as expected");
11118 off += to_trn_tbl[ecx++];
11122 auth_tag = digest_mem;
11123 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11125 tdata->auth_tag.data,
11126 tdata->auth_tag.len,
11127 "Generated auth tag not as expected");
11133 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11135 return test_authenticated_encryption_SGL(
11136 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11140 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11142 return test_authenticated_encryption_SGL(
11143 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11147 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11149 return test_authenticated_encryption_SGL(
11150 &gcm_test_case_8, OUT_OF_PLACE, 400,
11151 gcm_test_case_8.plaintext.len);
11155 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11157 /* This test is not for OPENSSL PMD */
11158 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11159 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11162 return test_authenticated_encryption_SGL(
11163 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11167 test_authentication_verify_fail_when_data_corrupted(
11168 struct crypto_testsuite_params *ts_params,
11169 struct crypto_unittest_params *ut_params,
11170 const struct test_crypto_vector *reference)
11172 return test_authentication_verify_fail_when_data_corruption(
11173 ts_params, ut_params, reference, 1);
11177 test_authentication_verify_fail_when_tag_corrupted(
11178 struct crypto_testsuite_params *ts_params,
11179 struct crypto_unittest_params *ut_params,
11180 const struct test_crypto_vector *reference)
11182 return test_authentication_verify_fail_when_data_corruption(
11183 ts_params, ut_params, reference, 0);
11187 test_authentication_verify_GMAC_fail_when_data_corrupted(
11188 struct crypto_testsuite_params *ts_params,
11189 struct crypto_unittest_params *ut_params,
11190 const struct test_crypto_vector *reference)
11192 return test_authentication_verify_GMAC_fail_when_corruption(
11193 ts_params, ut_params, reference, 1);
11197 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11198 struct crypto_testsuite_params *ts_params,
11199 struct crypto_unittest_params *ut_params,
11200 const struct test_crypto_vector *reference)
11202 return test_authentication_verify_GMAC_fail_when_corruption(
11203 ts_params, ut_params, reference, 0);
11207 test_authenticated_decryption_fail_when_data_corrupted(
11208 struct crypto_testsuite_params *ts_params,
11209 struct crypto_unittest_params *ut_params,
11210 const struct test_crypto_vector *reference)
11212 return test_authenticated_decryption_fail_when_corruption(
11213 ts_params, ut_params, reference, 1);
11217 test_authenticated_decryption_fail_when_tag_corrupted(
11218 struct crypto_testsuite_params *ts_params,
11219 struct crypto_unittest_params *ut_params,
11220 const struct test_crypto_vector *reference)
11222 return test_authenticated_decryption_fail_when_corruption(
11223 ts_params, ut_params, reference, 0);
11227 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11229 return test_authentication_verify_fail_when_data_corrupted(
11230 &testsuite_params, &unittest_params,
11231 &hmac_sha1_test_crypto_vector);
11235 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11237 return test_authentication_verify_fail_when_tag_corrupted(
11238 &testsuite_params, &unittest_params,
11239 &hmac_sha1_test_crypto_vector);
11243 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11245 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11246 &testsuite_params, &unittest_params,
11247 &aes128_gmac_test_vector);
11251 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11253 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11254 &testsuite_params, &unittest_params,
11255 &aes128_gmac_test_vector);
11259 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11261 return test_authenticated_decryption_fail_when_data_corrupted(
11264 &aes128cbc_hmac_sha1_test_vector);
11268 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11270 return test_authenticated_decryption_fail_when_tag_corrupted(
11273 &aes128cbc_hmac_sha1_test_vector);
11277 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11279 return test_authenticated_encryt_with_esn(
11282 &aes128cbc_hmac_sha1_aad_test_vector);
11286 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11288 return test_authenticated_decrypt_with_esn(
11291 &aes128cbc_hmac_sha1_aad_test_vector);
11294 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11296 /* global AESNI slave IDs for the scheduler test */
11297 uint8_t aesni_ids[2];
11300 test_scheduler_attach_slave_op(void)
11302 struct crypto_testsuite_params *ts_params = &testsuite_params;
11303 uint8_t sched_id = ts_params->valid_devs[0];
11304 uint32_t nb_devs, i, nb_devs_attached = 0;
11306 char vdev_name[32];
11308 /* create 2 AESNI_MB if necessary */
11309 nb_devs = rte_cryptodev_device_count_by_driver(
11310 rte_cryptodev_driver_id_get(
11311 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11313 for (i = nb_devs; i < 2; i++) {
11314 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11315 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11317 ret = rte_vdev_init(vdev_name, NULL);
11319 TEST_ASSERT(ret == 0,
11320 "Failed to create instance %u of"
11322 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11326 /* attach 2 AESNI_MB cdevs */
11327 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11329 struct rte_cryptodev_info info;
11330 unsigned int session_size;
11332 rte_cryptodev_info_get(i, &info);
11333 if (info.driver_id != rte_cryptodev_driver_id_get(
11334 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11337 session_size = rte_cryptodev_sym_get_private_session_size(i);
11339 * Create the session mempool again, since now there are new devices
11340 * to use the mempool.
11342 if (ts_params->session_mpool) {
11343 rte_mempool_free(ts_params->session_mpool);
11344 ts_params->session_mpool = NULL;
11346 if (ts_params->session_priv_mpool) {
11347 rte_mempool_free(ts_params->session_priv_mpool);
11348 ts_params->session_priv_mpool = NULL;
11351 if (info.sym.max_nb_sessions != 0 &&
11352 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11353 RTE_LOG(ERR, USER1,
11354 "Device does not support "
11355 "at least %u sessions\n",
11357 return TEST_FAILED;
11360 * Create mempool with maximum number of sessions,
11361 * to include the session headers
11363 if (ts_params->session_mpool == NULL) {
11364 ts_params->session_mpool =
11365 rte_cryptodev_sym_session_pool_create(
11367 MAX_NB_SESSIONS, 0, 0, 0,
11369 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11370 "session mempool allocation failed");
11374 * Create mempool with maximum number of sessions,
11375 * to include device specific session private data
11377 if (ts_params->session_priv_mpool == NULL) {
11378 ts_params->session_priv_mpool = rte_mempool_create(
11379 "test_sess_mp_priv",
11382 0, 0, NULL, NULL, NULL,
11383 NULL, SOCKET_ID_ANY,
11386 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11387 "session mempool allocation failed");
11390 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11391 ts_params->qp_conf.mp_session_private =
11392 ts_params->session_priv_mpool;
11394 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11397 TEST_ASSERT(ret == 0,
11398 "Failed to attach device %u of pmd : %s", i,
11399 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11401 aesni_ids[nb_devs_attached] = (uint8_t)i;
11403 nb_devs_attached++;
11410 test_scheduler_detach_slave_op(void)
11412 struct crypto_testsuite_params *ts_params = &testsuite_params;
11413 uint8_t sched_id = ts_params->valid_devs[0];
11417 for (i = 0; i < 2; i++) {
11418 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11420 TEST_ASSERT(ret == 0,
11421 "Failed to detach device %u", aesni_ids[i]);
11428 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11430 struct crypto_testsuite_params *ts_params = &testsuite_params;
11431 uint8_t sched_id = ts_params->valid_devs[0];
11433 return rte_cryptodev_scheduler_mode_set(sched_id,
11438 test_scheduler_mode_roundrobin_op(void)
11440 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11441 0, "Failed to set roundrobin mode");
11447 test_scheduler_mode_multicore_op(void)
11449 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11450 0, "Failed to set multicore mode");
11456 test_scheduler_mode_failover_op(void)
11458 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11459 0, "Failed to set failover mode");
11465 test_scheduler_mode_pkt_size_distr_op(void)
11467 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11468 0, "Failed to set pktsize mode");
11473 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11474 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11475 .setup = testsuite_setup,
11476 .teardown = testsuite_teardown,
11477 .unit_test_cases = {
11479 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11480 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11481 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11482 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11483 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11484 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11487 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11488 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11489 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11490 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11491 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11492 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11495 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11496 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11497 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11498 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11499 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11500 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11503 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11504 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11505 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11506 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11507 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11508 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11510 TEST_CASES_END() /**< NULL terminate unit test array */
11514 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11516 static struct unit_test_suite cryptodev_testsuite = {
11517 .suite_name = "Crypto Unit Test Suite",
11518 .setup = testsuite_setup,
11519 .teardown = testsuite_teardown,
11520 .unit_test_cases = {
11521 TEST_CASE_ST(ut_setup, ut_teardown,
11522 test_device_configure_invalid_dev_id),
11523 TEST_CASE_ST(ut_setup, ut_teardown,
11524 test_device_configure_invalid_queue_pair_ids),
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_queue_pair_descriptor_setup),
11528 TEST_CASE_ST(ut_setup, ut_teardown,
11529 test_multi_session),
11530 TEST_CASE_ST(ut_setup, ut_teardown,
11531 test_multi_session_random_usage),
11533 TEST_CASE_ST(ut_setup, ut_teardown,
11534 test_null_invalid_operation),
11535 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11537 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11538 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11539 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11540 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11541 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11542 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11543 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11544 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11545 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11547 /** AES CCM Authenticated Encryption 128 bits key */
11548 TEST_CASE_ST(ut_setup, ut_teardown,
11549 test_AES_CCM_authenticated_encryption_test_case_128_1),
11550 TEST_CASE_ST(ut_setup, ut_teardown,
11551 test_AES_CCM_authenticated_encryption_test_case_128_2),
11552 TEST_CASE_ST(ut_setup, ut_teardown,
11553 test_AES_CCM_authenticated_encryption_test_case_128_3),
11555 /** AES CCM Authenticated Decryption 128 bits key*/
11556 TEST_CASE_ST(ut_setup, ut_teardown,
11557 test_AES_CCM_authenticated_decryption_test_case_128_1),
11558 TEST_CASE_ST(ut_setup, ut_teardown,
11559 test_AES_CCM_authenticated_decryption_test_case_128_2),
11560 TEST_CASE_ST(ut_setup, ut_teardown,
11561 test_AES_CCM_authenticated_decryption_test_case_128_3),
11563 /** AES CCM Authenticated Encryption 192 bits key */
11564 TEST_CASE_ST(ut_setup, ut_teardown,
11565 test_AES_CCM_authenticated_encryption_test_case_192_1),
11566 TEST_CASE_ST(ut_setup, ut_teardown,
11567 test_AES_CCM_authenticated_encryption_test_case_192_2),
11568 TEST_CASE_ST(ut_setup, ut_teardown,
11569 test_AES_CCM_authenticated_encryption_test_case_192_3),
11571 /** AES CCM Authenticated Decryption 192 bits key*/
11572 TEST_CASE_ST(ut_setup, ut_teardown,
11573 test_AES_CCM_authenticated_decryption_test_case_192_1),
11574 TEST_CASE_ST(ut_setup, ut_teardown,
11575 test_AES_CCM_authenticated_decryption_test_case_192_2),
11576 TEST_CASE_ST(ut_setup, ut_teardown,
11577 test_AES_CCM_authenticated_decryption_test_case_192_3),
11579 /** AES CCM Authenticated Encryption 256 bits key */
11580 TEST_CASE_ST(ut_setup, ut_teardown,
11581 test_AES_CCM_authenticated_encryption_test_case_256_1),
11582 TEST_CASE_ST(ut_setup, ut_teardown,
11583 test_AES_CCM_authenticated_encryption_test_case_256_2),
11584 TEST_CASE_ST(ut_setup, ut_teardown,
11585 test_AES_CCM_authenticated_encryption_test_case_256_3),
11587 /** AES CCM Authenticated Decryption 256 bits key*/
11588 TEST_CASE_ST(ut_setup, ut_teardown,
11589 test_AES_CCM_authenticated_decryption_test_case_256_1),
11590 TEST_CASE_ST(ut_setup, ut_teardown,
11591 test_AES_CCM_authenticated_decryption_test_case_256_2),
11592 TEST_CASE_ST(ut_setup, ut_teardown,
11593 test_AES_CCM_authenticated_decryption_test_case_256_3),
11595 /** AES GCM Authenticated Encryption */
11596 TEST_CASE_ST(ut_setup, ut_teardown,
11597 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11598 TEST_CASE_ST(ut_setup, ut_teardown,
11599 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11600 TEST_CASE_ST(ut_setup, ut_teardown,
11601 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11602 TEST_CASE_ST(ut_setup, ut_teardown,
11603 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11604 TEST_CASE_ST(ut_setup, ut_teardown,
11605 test_AES_GCM_authenticated_encryption_test_case_1),
11606 TEST_CASE_ST(ut_setup, ut_teardown,
11607 test_AES_GCM_authenticated_encryption_test_case_2),
11608 TEST_CASE_ST(ut_setup, ut_teardown,
11609 test_AES_GCM_authenticated_encryption_test_case_3),
11610 TEST_CASE_ST(ut_setup, ut_teardown,
11611 test_AES_GCM_authenticated_encryption_test_case_4),
11612 TEST_CASE_ST(ut_setup, ut_teardown,
11613 test_AES_GCM_authenticated_encryption_test_case_5),
11614 TEST_CASE_ST(ut_setup, ut_teardown,
11615 test_AES_GCM_authenticated_encryption_test_case_6),
11616 TEST_CASE_ST(ut_setup, ut_teardown,
11617 test_AES_GCM_authenticated_encryption_test_case_7),
11618 TEST_CASE_ST(ut_setup, ut_teardown,
11619 test_AES_GCM_authenticated_encryption_test_case_8),
11621 /** AES GCM Authenticated Decryption */
11622 TEST_CASE_ST(ut_setup, ut_teardown,
11623 test_AES_GCM_authenticated_decryption_test_case_1),
11624 TEST_CASE_ST(ut_setup, ut_teardown,
11625 test_AES_GCM_authenticated_decryption_test_case_2),
11626 TEST_CASE_ST(ut_setup, ut_teardown,
11627 test_AES_GCM_authenticated_decryption_test_case_3),
11628 TEST_CASE_ST(ut_setup, ut_teardown,
11629 test_AES_GCM_authenticated_decryption_test_case_4),
11630 TEST_CASE_ST(ut_setup, ut_teardown,
11631 test_AES_GCM_authenticated_decryption_test_case_5),
11632 TEST_CASE_ST(ut_setup, ut_teardown,
11633 test_AES_GCM_authenticated_decryption_test_case_6),
11634 TEST_CASE_ST(ut_setup, ut_teardown,
11635 test_AES_GCM_authenticated_decryption_test_case_7),
11636 TEST_CASE_ST(ut_setup, ut_teardown,
11637 test_AES_GCM_authenticated_decryption_test_case_8),
11639 /** AES GCM Authenticated Encryption 192 bits key */
11640 TEST_CASE_ST(ut_setup, ut_teardown,
11641 test_AES_GCM_auth_encryption_test_case_192_1),
11642 TEST_CASE_ST(ut_setup, ut_teardown,
11643 test_AES_GCM_auth_encryption_test_case_192_2),
11644 TEST_CASE_ST(ut_setup, ut_teardown,
11645 test_AES_GCM_auth_encryption_test_case_192_3),
11646 TEST_CASE_ST(ut_setup, ut_teardown,
11647 test_AES_GCM_auth_encryption_test_case_192_4),
11648 TEST_CASE_ST(ut_setup, ut_teardown,
11649 test_AES_GCM_auth_encryption_test_case_192_5),
11650 TEST_CASE_ST(ut_setup, ut_teardown,
11651 test_AES_GCM_auth_encryption_test_case_192_6),
11652 TEST_CASE_ST(ut_setup, ut_teardown,
11653 test_AES_GCM_auth_encryption_test_case_192_7),
11655 /** AES GCM Authenticated Decryption 192 bits key */
11656 TEST_CASE_ST(ut_setup, ut_teardown,
11657 test_AES_GCM_auth_decryption_test_case_192_1),
11658 TEST_CASE_ST(ut_setup, ut_teardown,
11659 test_AES_GCM_auth_decryption_test_case_192_2),
11660 TEST_CASE_ST(ut_setup, ut_teardown,
11661 test_AES_GCM_auth_decryption_test_case_192_3),
11662 TEST_CASE_ST(ut_setup, ut_teardown,
11663 test_AES_GCM_auth_decryption_test_case_192_4),
11664 TEST_CASE_ST(ut_setup, ut_teardown,
11665 test_AES_GCM_auth_decryption_test_case_192_5),
11666 TEST_CASE_ST(ut_setup, ut_teardown,
11667 test_AES_GCM_auth_decryption_test_case_192_6),
11668 TEST_CASE_ST(ut_setup, ut_teardown,
11669 test_AES_GCM_auth_decryption_test_case_192_7),
11671 /** AES GCM Authenticated Encryption 256 bits key */
11672 TEST_CASE_ST(ut_setup, ut_teardown,
11673 test_AES_GCM_auth_encryption_test_case_256_1),
11674 TEST_CASE_ST(ut_setup, ut_teardown,
11675 test_AES_GCM_auth_encryption_test_case_256_2),
11676 TEST_CASE_ST(ut_setup, ut_teardown,
11677 test_AES_GCM_auth_encryption_test_case_256_3),
11678 TEST_CASE_ST(ut_setup, ut_teardown,
11679 test_AES_GCM_auth_encryption_test_case_256_4),
11680 TEST_CASE_ST(ut_setup, ut_teardown,
11681 test_AES_GCM_auth_encryption_test_case_256_5),
11682 TEST_CASE_ST(ut_setup, ut_teardown,
11683 test_AES_GCM_auth_encryption_test_case_256_6),
11684 TEST_CASE_ST(ut_setup, ut_teardown,
11685 test_AES_GCM_auth_encryption_test_case_256_7),
11687 /** AES GCM Authenticated Decryption 256 bits key */
11688 TEST_CASE_ST(ut_setup, ut_teardown,
11689 test_AES_GCM_auth_decryption_test_case_256_1),
11690 TEST_CASE_ST(ut_setup, ut_teardown,
11691 test_AES_GCM_auth_decryption_test_case_256_2),
11692 TEST_CASE_ST(ut_setup, ut_teardown,
11693 test_AES_GCM_auth_decryption_test_case_256_3),
11694 TEST_CASE_ST(ut_setup, ut_teardown,
11695 test_AES_GCM_auth_decryption_test_case_256_4),
11696 TEST_CASE_ST(ut_setup, ut_teardown,
11697 test_AES_GCM_auth_decryption_test_case_256_5),
11698 TEST_CASE_ST(ut_setup, ut_teardown,
11699 test_AES_GCM_auth_decryption_test_case_256_6),
11700 TEST_CASE_ST(ut_setup, ut_teardown,
11701 test_AES_GCM_auth_decryption_test_case_256_7),
11703 /** AES GCM Authenticated Encryption big aad size */
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_AES_GCM_auth_encryption_test_case_aad_1),
11706 TEST_CASE_ST(ut_setup, ut_teardown,
11707 test_AES_GCM_auth_encryption_test_case_aad_2),
11709 /** AES GCM Authenticated Decryption big aad size */
11710 TEST_CASE_ST(ut_setup, ut_teardown,
11711 test_AES_GCM_auth_decryption_test_case_aad_1),
11712 TEST_CASE_ST(ut_setup, ut_teardown,
11713 test_AES_GCM_auth_decryption_test_case_aad_2),
11715 /** Out of place tests */
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11718 TEST_CASE_ST(ut_setup, ut_teardown,
11719 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11721 /** Session-less tests */
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11724 TEST_CASE_ST(ut_setup, ut_teardown,
11725 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11727 /** AES GMAC Authentication */
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 test_AES_GMAC_authentication_test_case_1),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 test_AES_GMAC_authentication_verify_test_case_1),
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 test_AES_GMAC_authentication_test_case_2),
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 test_AES_GMAC_authentication_verify_test_case_2),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_AES_GMAC_authentication_test_case_3),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_AES_GMAC_authentication_verify_test_case_3),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_AES_GMAC_authentication_test_case_4),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 test_AES_GMAC_authentication_verify_test_case_4),
11745 /** SNOW 3G encrypt only (UEA2) */
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_snow3g_encryption_test_case_1),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_snow3g_encryption_test_case_2),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_snow3g_encryption_test_case_3),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_snow3g_encryption_test_case_4),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_snow3g_encryption_test_case_5),
11757 TEST_CASE_ST(ut_setup, ut_teardown,
11758 test_snow3g_encryption_test_case_1_oop),
11759 TEST_CASE_ST(ut_setup, ut_teardown,
11760 test_snow3g_encryption_test_case_1_oop_sgl),
11761 TEST_CASE_ST(ut_setup, ut_teardown,
11762 test_snow3g_encryption_test_case_1_offset_oop),
11763 TEST_CASE_ST(ut_setup, ut_teardown,
11764 test_snow3g_decryption_test_case_1_oop),
11766 /** SNOW 3G generate auth, then encrypt (UEA2) */
11767 TEST_CASE_ST(ut_setup, ut_teardown,
11768 test_snow3g_auth_cipher_test_case_1),
11769 TEST_CASE_ST(ut_setup, ut_teardown,
11770 test_snow3g_auth_cipher_test_case_2),
11771 TEST_CASE_ST(ut_setup, ut_teardown,
11772 test_snow3g_auth_cipher_test_case_2_oop),
11773 TEST_CASE_ST(ut_setup, ut_teardown,
11774 test_snow3g_auth_cipher_part_digest_enc),
11775 TEST_CASE_ST(ut_setup, ut_teardown,
11776 test_snow3g_auth_cipher_part_digest_enc_oop),
11777 TEST_CASE_ST(ut_setup, ut_teardown,
11778 test_snow3g_auth_cipher_test_case_3_sgl),
11779 TEST_CASE_ST(ut_setup, ut_teardown,
11780 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11781 TEST_CASE_ST(ut_setup, ut_teardown,
11782 test_snow3g_auth_cipher_part_digest_enc_sgl),
11783 TEST_CASE_ST(ut_setup, ut_teardown,
11784 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11786 /** SNOW 3G decrypt (UEA2), then verify auth */
11787 TEST_CASE_ST(ut_setup, ut_teardown,
11788 test_snow3g_auth_cipher_verify_test_case_1),
11789 TEST_CASE_ST(ut_setup, ut_teardown,
11790 test_snow3g_auth_cipher_verify_test_case_2),
11791 TEST_CASE_ST(ut_setup, ut_teardown,
11792 test_snow3g_auth_cipher_verify_test_case_2_oop),
11793 TEST_CASE_ST(ut_setup, ut_teardown,
11794 test_snow3g_auth_cipher_verify_part_digest_enc),
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11806 /** SNOW 3G decrypt only (UEA2) */
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_snow3g_decryption_test_case_1),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_snow3g_decryption_test_case_2),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_snow3g_decryption_test_case_3),
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_snow3g_decryption_test_case_4),
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_snow3g_decryption_test_case_5),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_snow3g_decryption_with_digest_test_case_1),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_snow3g_hash_generate_test_case_1),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_snow3g_hash_generate_test_case_2),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_snow3g_hash_generate_test_case_3),
11825 /* Tests with buffers which length is not byte-aligned */
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_snow3g_hash_generate_test_case_4),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_snow3g_hash_generate_test_case_5),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_snow3g_hash_generate_test_case_6),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_snow3g_hash_verify_test_case_1),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_snow3g_hash_verify_test_case_2),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_snow3g_hash_verify_test_case_3),
11838 /* Tests with buffers which length is not byte-aligned */
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_snow3g_hash_verify_test_case_4),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_snow3g_hash_verify_test_case_5),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_snow3g_hash_verify_test_case_6),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_snow3g_cipher_auth_test_case_1),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_snow3g_auth_cipher_with_digest_test_case_1),
11850 /** ZUC encrypt only (EEA3) */
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_zuc_encryption_test_case_1),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_zuc_encryption_test_case_2),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_zuc_encryption_test_case_3),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_zuc_encryption_test_case_4),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_zuc_encryption_test_case_5),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_zuc_encryption_test_case_6_sgl),
11864 /** ZUC authenticate (EIA3) */
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_zuc_hash_generate_test_case_1),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_zuc_hash_generate_test_case_2),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_zuc_hash_generate_test_case_3),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_zuc_hash_generate_test_case_4),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_zuc_hash_generate_test_case_5),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_zuc_hash_generate_test_case_6),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_zuc_hash_generate_test_case_7),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_zuc_hash_generate_test_case_8),
11882 /** ZUC alg-chain (EEA3/EIA3) */
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_zuc_cipher_auth_test_case_1),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_zuc_cipher_auth_test_case_2),
11888 /** ZUC generate auth, then encrypt (EEA3) */
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_zuc_auth_cipher_test_case_1),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_zuc_auth_cipher_test_case_1_oop),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_zuc_auth_cipher_test_case_1_sgl),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_zuc_auth_cipher_test_case_1_oop_sgl),
11898 /** ZUC decrypt (EEA3), then verify auth */
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_zuc_auth_cipher_verify_test_case_1),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_zuc_auth_cipher_verify_test_case_1_oop),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_zuc_auth_cipher_verify_test_case_1_sgl),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
11908 /** HMAC_MD5 Authentication */
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_MD5_HMAC_generate_case_1),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_MD5_HMAC_verify_case_1),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_MD5_HMAC_generate_case_2),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_MD5_HMAC_verify_case_2),
11918 /** KASUMI hash only (UIA1) */
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_kasumi_hash_generate_test_case_1),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_kasumi_hash_generate_test_case_2),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_kasumi_hash_generate_test_case_3),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_kasumi_hash_generate_test_case_4),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_kasumi_hash_generate_test_case_5),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_kasumi_hash_generate_test_case_6),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_kasumi_hash_verify_test_case_1),
11934 TEST_CASE_ST(ut_setup, ut_teardown,
11935 test_kasumi_hash_verify_test_case_2),
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_kasumi_hash_verify_test_case_3),
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_kasumi_hash_verify_test_case_4),
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_kasumi_hash_verify_test_case_5),
11943 /** KASUMI encrypt only (UEA1) */
11944 TEST_CASE_ST(ut_setup, ut_teardown,
11945 test_kasumi_encryption_test_case_1),
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_kasumi_encryption_test_case_1_sgl),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_kasumi_encryption_test_case_1_oop),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_kasumi_encryption_test_case_1_oop_sgl),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_kasumi_encryption_test_case_2),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_kasumi_encryption_test_case_3),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_kasumi_encryption_test_case_4),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_kasumi_encryption_test_case_5),
11961 /** KASUMI decrypt only (UEA1) */
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 test_kasumi_decryption_test_case_1),
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_kasumi_decryption_test_case_2),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_kasumi_decryption_test_case_3),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_kasumi_decryption_test_case_4),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_kasumi_decryption_test_case_5),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_kasumi_decryption_test_case_1_oop),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_kasumi_cipher_auth_test_case_1),
11978 /** KASUMI generate auth, then encrypt (F8) */
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_kasumi_auth_cipher_test_case_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_kasumi_auth_cipher_test_case_2),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_kasumi_auth_cipher_test_case_2_oop),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_kasumi_auth_cipher_test_case_2_sgl),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11990 /** KASUMI decrypt (F8), then verify auth */
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_kasumi_auth_cipher_verify_test_case_1),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_kasumi_auth_cipher_verify_test_case_2),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_kasumi_auth_cipher_verify_test_case_2_oop),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12002 /** ESN Testcase */
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12008 /** Negative tests */
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 authentication_verify_AES128_GMAC_fail_data_corrupt),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12046 /** Mixed CIPHER + HASH algorithms */
12047 /** AUTH AES CMAC + CIPHER AES CTR */
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12065 /** AUTH ZUC + CIPHER SNOW3G */
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_auth_zuc_cipher_snow_test_case_1),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_verify_auth_zuc_cipher_snow_test_case_1),
12070 /** AUTH AES CMAC + CIPHER SNOW3G */
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_auth_aes_cmac_cipher_snow_test_case_1),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12075 /** AUTH ZUC + CIPHER AES CTR */
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_auth_zuc_cipher_aes_ctr_test_case_1),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12080 /** AUTH SNOW3G + CIPHER AES CTR */
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_auth_snow_cipher_aes_ctr_test_case_1),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12085 /** AUTH SNOW3G + CIPHER ZUC */
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_auth_snow_cipher_zuc_test_case_1),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_verify_auth_snow_cipher_zuc_test_case_1),
12090 /** AUTH AES CMAC + CIPHER ZUC */
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_auth_aes_cmac_cipher_zuc_test_case_1),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12096 /** AUTH NULL + CIPHER SNOW3G */
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_auth_null_cipher_snow_test_case_1),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_verify_auth_null_cipher_snow_test_case_1),
12101 /** AUTH NULL + CIPHER ZUC */
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_auth_null_cipher_zuc_test_case_1),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_verify_auth_null_cipher_zuc_test_case_1),
12106 /** AUTH SNOW3G + CIPHER NULL */
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_auth_snow_cipher_null_test_case_1),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_verify_auth_snow_cipher_null_test_case_1),
12111 /** AUTH ZUC + CIPHER NULL */
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_auth_zuc_cipher_null_test_case_1),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_verify_auth_zuc_cipher_null_test_case_1),
12116 /** AUTH NULL + CIPHER AES CTR */
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_auth_null_cipher_aes_ctr_test_case_1),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12121 /** AUTH AES CMAC + CIPHER NULL */
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_auth_aes_cmac_cipher_null_test_case_1),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12127 TEST_CASES_END() /**< NULL terminate unit test array */
12131 static struct unit_test_suite cryptodev_virtio_testsuite = {
12132 .suite_name = "Crypto VIRTIO Unit Test Suite",
12133 .setup = testsuite_setup,
12134 .teardown = testsuite_teardown,
12135 .unit_test_cases = {
12136 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12138 TEST_CASES_END() /**< NULL terminate unit test array */
12142 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12143 .suite_name = "Crypto CAAM JR Unit Test Suite",
12144 .setup = testsuite_setup,
12145 .teardown = testsuite_teardown,
12146 .unit_test_cases = {
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_device_configure_invalid_dev_id),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_multi_session),
12152 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12153 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12154 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12155 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12156 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12158 TEST_CASES_END() /**< NULL terminate unit test array */
12162 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12163 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12164 .setup = testsuite_setup,
12165 .teardown = testsuite_teardown,
12166 .unit_test_cases = {
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_device_configure_invalid_dev_id),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_multi_session),
12172 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12173 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12174 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12175 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12176 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12178 #ifdef RTE_LIBRTE_SECURITY
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_PDCP_PROTO_cplane_encap_all),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_PDCP_PROTO_cplane_decap_all),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_PDCP_PROTO_uplane_encap_all),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_PDCP_PROTO_uplane_decap_all),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_PDCP_PROTO_SGL_in_place_32B),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_PDCP_PROTO_SGL_oop_32B_128B),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_PDCP_PROTO_SGL_oop_32B_40B),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_PDCP_PROTO_SGL_oop_128B_32B),
12200 /** AES GCM Authenticated Encryption */
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_AES_GCM_authenticated_encryption_test_case_1),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_AES_GCM_authenticated_encryption_test_case_2),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_AES_GCM_authenticated_encryption_test_case_3),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_AES_GCM_authenticated_encryption_test_case_4),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_AES_GCM_authenticated_encryption_test_case_5),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_AES_GCM_authenticated_encryption_test_case_6),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_AES_GCM_authenticated_encryption_test_case_7),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_AES_GCM_authenticated_encryption_test_case_8),
12226 /** AES GCM Authenticated Decryption */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_AES_GCM_authenticated_decryption_test_case_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_AES_GCM_authenticated_decryption_test_case_2),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_AES_GCM_authenticated_decryption_test_case_3),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_authenticated_decryption_test_case_4),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_authenticated_decryption_test_case_5),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_authenticated_decryption_test_case_6),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_authenticated_decryption_test_case_7),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_authenticated_decryption_test_case_8),
12244 /** AES GCM Authenticated Encryption 192 bits key */
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_encryption_test_case_192_1),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_encryption_test_case_192_2),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_encryption_test_case_192_3),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_encryption_test_case_192_4),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_encryption_test_case_192_5),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_encryption_test_case_192_6),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_encryption_test_case_192_7),
12260 /** AES GCM Authenticated Decryption 192 bits key */
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_decryption_test_case_192_1),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_decryption_test_case_192_2),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_AES_GCM_auth_decryption_test_case_192_3),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_decryption_test_case_192_4),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_decryption_test_case_192_5),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_AES_GCM_auth_decryption_test_case_192_6),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_AES_GCM_auth_decryption_test_case_192_7),
12276 /** AES GCM Authenticated Encryption 256 bits key */
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_AES_GCM_auth_encryption_test_case_256_1),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_AES_GCM_auth_encryption_test_case_256_2),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_AES_GCM_auth_encryption_test_case_256_3),
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_AES_GCM_auth_encryption_test_case_256_4),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_AES_GCM_auth_encryption_test_case_256_5),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_AES_GCM_auth_encryption_test_case_256_6),
12289 TEST_CASE_ST(ut_setup, ut_teardown,
12290 test_AES_GCM_auth_encryption_test_case_256_7),
12292 /** AES GCM Authenticated Decryption 256 bits key */
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_GCM_auth_decryption_test_case_256_1),
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_AES_GCM_auth_decryption_test_case_256_2),
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_AES_GCM_auth_decryption_test_case_256_3),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_AES_GCM_auth_decryption_test_case_256_4),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_AES_GCM_auth_decryption_test_case_256_5),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_AES_GCM_auth_decryption_test_case_256_6),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_AES_GCM_auth_decryption_test_case_256_7),
12308 /** Out of place tests */
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12314 /** SNOW 3G encrypt only (UEA2) */
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_snow3g_encryption_test_case_1),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_snow3g_encryption_test_case_2),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_snow3g_encryption_test_case_3),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_snow3g_encryption_test_case_4),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_snow3g_encryption_test_case_5),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_snow3g_encryption_test_case_1_oop),
12328 TEST_CASE_ST(ut_setup, ut_teardown,
12329 test_snow3g_encryption_test_case_1_oop_sgl),
12330 TEST_CASE_ST(ut_setup, ut_teardown,
12331 test_snow3g_decryption_test_case_1_oop),
12333 /** SNOW 3G decrypt only (UEA2) */
12334 TEST_CASE_ST(ut_setup, ut_teardown,
12335 test_snow3g_decryption_test_case_1),
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_snow3g_decryption_test_case_2),
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_snow3g_decryption_test_case_3),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_snow3g_decryption_test_case_4),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_snow3g_decryption_test_case_5),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_snow3g_hash_generate_test_case_1),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_snow3g_hash_generate_test_case_2),
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_snow3g_hash_generate_test_case_3),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_snow3g_hash_verify_test_case_1),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_snow3g_hash_verify_test_case_2),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_snow3g_hash_verify_test_case_3),
12358 /** ZUC encrypt only (EEA3) */
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_zuc_encryption_test_case_1),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_zuc_encryption_test_case_2),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_zuc_encryption_test_case_3),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_zuc_encryption_test_case_4),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_zuc_encryption_test_case_5),
12370 /** ZUC authenticate (EIA3) */
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_zuc_hash_generate_test_case_6),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_zuc_hash_generate_test_case_7),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_zuc_hash_generate_test_case_8),
12378 /** Negative tests */
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12418 TEST_CASES_END() /**< NULL terminate unit test array */
12422 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12423 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12424 .setup = testsuite_setup,
12425 .teardown = testsuite_teardown,
12426 .unit_test_cases = {
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_device_configure_invalid_dev_id),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_multi_session),
12431 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12432 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12433 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12434 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12435 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12437 #ifdef RTE_LIBRTE_SECURITY
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_PDCP_PROTO_cplane_encap_all),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_PDCP_PROTO_cplane_decap_all),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_PDCP_PROTO_uplane_encap_all),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_PDCP_PROTO_uplane_decap_all),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_PDCP_PROTO_SGL_in_place_32B),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_PDCP_PROTO_SGL_oop_32B_128B),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_PDCP_PROTO_SGL_oop_32B_40B),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_PDCP_PROTO_SGL_oop_128B_32B),
12459 /** AES GCM Authenticated Encryption */
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_AES_GCM_authenticated_encryption_test_case_1),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_AES_GCM_authenticated_encryption_test_case_2),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_AES_GCM_authenticated_encryption_test_case_3),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_AES_GCM_authenticated_encryption_test_case_4),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_GCM_authenticated_encryption_test_case_5),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_AES_GCM_authenticated_encryption_test_case_6),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_AES_GCM_authenticated_encryption_test_case_7),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_AES_GCM_authenticated_encryption_test_case_8),
12485 /** AES GCM Authenticated Decryption */
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_GCM_authenticated_decryption_test_case_1),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_AES_GCM_authenticated_decryption_test_case_2),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_AES_GCM_authenticated_decryption_test_case_3),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_AES_GCM_authenticated_decryption_test_case_4),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_AES_GCM_authenticated_decryption_test_case_5),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_AES_GCM_authenticated_decryption_test_case_6),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_AES_GCM_authenticated_decryption_test_case_7),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_authenticated_decryption_test_case_8),
12503 /** AES GCM Authenticated Encryption 192 bits key */
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_auth_encryption_test_case_192_1),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_auth_encryption_test_case_192_2),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_auth_encryption_test_case_192_3),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_auth_encryption_test_case_192_4),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_auth_encryption_test_case_192_5),
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_AES_GCM_auth_encryption_test_case_192_6),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_auth_encryption_test_case_192_7),
12519 /** AES GCM Authenticated Decryption 192 bits key */
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_decryption_test_case_192_1),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_decryption_test_case_192_2),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_auth_decryption_test_case_192_3),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_auth_decryption_test_case_192_4),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_auth_decryption_test_case_192_5),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_auth_decryption_test_case_192_6),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_auth_decryption_test_case_192_7),
12535 /** AES GCM Authenticated Encryption 256 bits key */
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_encryption_test_case_256_1),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_encryption_test_case_256_2),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_auth_encryption_test_case_256_3),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_encryption_test_case_256_4),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_auth_encryption_test_case_256_5),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_auth_encryption_test_case_256_6),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_auth_encryption_test_case_256_7),
12551 /** AES GCM Authenticated Decryption 256 bits key */
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_decryption_test_case_256_1),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_decryption_test_case_256_2),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_auth_decryption_test_case_256_3),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_auth_decryption_test_case_256_4),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_AES_GCM_auth_decryption_test_case_256_5),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_AES_GCM_auth_decryption_test_case_256_6),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_AES_GCM_auth_decryption_test_case_256_7),
12567 /** Out of place tests */
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12573 /** SNOW 3G encrypt only (UEA2) */
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_encryption_test_case_1),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_encryption_test_case_2),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_snow3g_encryption_test_case_3),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_snow3g_encryption_test_case_4),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_snow3g_encryption_test_case_5),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_snow3g_encryption_test_case_1_oop),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_snow3g_encryption_test_case_1_oop_sgl),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_snow3g_decryption_test_case_1_oop),
12592 /** SNOW 3G decrypt only (UEA2) */
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_snow3g_decryption_test_case_1),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_snow3g_decryption_test_case_2),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_snow3g_decryption_test_case_3),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_snow3g_decryption_test_case_4),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_snow3g_decryption_test_case_5),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_snow3g_hash_generate_test_case_1),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_snow3g_hash_generate_test_case_2),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_snow3g_hash_generate_test_case_3),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_snow3g_hash_verify_test_case_1),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_snow3g_hash_verify_test_case_2),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_snow3g_hash_verify_test_case_3),
12617 /** ZUC encrypt only (EEA3) */
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_zuc_encryption_test_case_1),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_zuc_encryption_test_case_2),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_zuc_encryption_test_case_3),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_zuc_encryption_test_case_4),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_zuc_encryption_test_case_5),
12629 /** ZUC authenticate (EIA3) */
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_zuc_hash_generate_test_case_6),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_zuc_hash_generate_test_case_7),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_zuc_hash_generate_test_case_8),
12637 /** HMAC_MD5 Authentication */
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_MD5_HMAC_generate_case_1),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_MD5_HMAC_verify_case_1),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_MD5_HMAC_generate_case_2),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_MD5_HMAC_verify_case_2),
12647 /** Negative tests */
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12672 TEST_CASE_ST(ut_setup, ut_teardown,
12673 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12688 TEST_CASES_END() /**< NULL terminate unit test array */
12692 static struct unit_test_suite cryptodev_armv8_testsuite = {
12693 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12694 .setup = testsuite_setup,
12695 .teardown = testsuite_teardown,
12696 .unit_test_cases = {
12697 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12699 /** Negative tests */
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12705 TEST_CASES_END() /**< NULL terminate unit test array */
12709 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12710 .suite_name = "Crypto Device Marvell Component Test Suite",
12711 .setup = testsuite_setup,
12712 .teardown = testsuite_teardown,
12713 .unit_test_cases = {
12714 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_multi_session_random_usage),
12717 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12718 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12719 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12720 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12721 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12723 /** Negative tests */
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12733 TEST_CASES_END() /**< NULL terminate unit test array */
12737 static struct unit_test_suite cryptodev_ccp_testsuite = {
12738 .suite_name = "Crypto Device CCP Unit Test Suite",
12739 .setup = testsuite_setup,
12740 .teardown = testsuite_teardown,
12741 .unit_test_cases = {
12742 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_multi_session_random_usage),
12745 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12746 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12747 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12748 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12749 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12751 /** Negative tests */
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12761 TEST_CASES_END() /**< NULL terminate unit test array */
12765 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12766 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12767 .setup = testsuite_setup,
12768 .teardown = testsuite_teardown,
12769 .unit_test_cases = {
12770 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12771 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12772 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12773 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12774 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12776 /** AES GCM Authenticated Encryption */
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_authenticated_encryption_test_case_1),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_authenticated_encryption_test_case_2),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_authenticated_encryption_test_case_3),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_authenticated_encryption_test_case_4),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_authenticated_encryption_test_case_5),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_authenticated_encryption_test_case_6),
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_AES_GCM_authenticated_encryption_test_case_7),
12792 /** AES GCM Authenticated Decryption */
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_authenticated_decryption_test_case_1),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_AES_GCM_authenticated_decryption_test_case_2),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_AES_GCM_authenticated_decryption_test_case_3),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_AES_GCM_authenticated_decryption_test_case_4),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GCM_authenticated_decryption_test_case_5),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_AES_GCM_authenticated_decryption_test_case_6),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_AES_GCM_authenticated_decryption_test_case_7),
12807 /** AES GMAC Authentication */
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_AES_GMAC_authentication_test_case_1),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_AES_GMAC_authentication_verify_test_case_1),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_AES_GMAC_authentication_test_case_2),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_AES_GMAC_authentication_verify_test_case_2),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_AES_GMAC_authentication_test_case_3),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_AES_GMAC_authentication_verify_test_case_3),
12821 /** SNOW 3G encrypt only (UEA2) */
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_snow3g_encryption_test_case_1),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_snow3g_encryption_test_case_2),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_snow3g_encryption_test_case_3),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_snow3g_encryption_test_case_4),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_snow3g_encryption_test_case_5),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_snow3g_encryption_test_case_1_oop),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_snow3g_decryption_test_case_1_oop),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_snow3g_encryption_test_case_1_oop_sgl),
12840 /** SNOW 3G decrypt only (UEA2) */
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_snow3g_decryption_test_case_1),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_snow3g_decryption_test_case_2),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_snow3g_decryption_test_case_3),
12847 TEST_CASE_ST(ut_setup, ut_teardown,
12848 test_snow3g_decryption_test_case_4),
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_snow3g_decryption_test_case_5),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_snow3g_hash_generate_test_case_1),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_snow3g_hash_generate_test_case_2),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_snow3g_hash_generate_test_case_3),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_snow3g_hash_verify_test_case_1),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_snow3g_hash_verify_test_case_2),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_snow3g_hash_verify_test_case_3),
12865 /** ZUC encrypt only (EEA3) */
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_zuc_encryption_test_case_1),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_zuc_encryption_test_case_2),
12870 TEST_CASE_ST(ut_setup, ut_teardown,
12871 test_zuc_encryption_test_case_3),
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_zuc_encryption_test_case_4),
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_zuc_encryption_test_case_5),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_zuc_hash_generate_test_case_1),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_zuc_hash_generate_test_case_2),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_zuc_hash_generate_test_case_3),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_zuc_hash_generate_test_case_4),
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_zuc_hash_generate_test_case_5),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_zuc_encryption_test_case_6_sgl),
12889 /** KASUMI encrypt only (UEA1) */
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_kasumi_encryption_test_case_1),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_kasumi_encryption_test_case_2),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_kasumi_encryption_test_case_3),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_encryption_test_case_4),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_encryption_test_case_5),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_kasumi_encryption_test_case_1_sgl),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_encryption_test_case_1_oop_sgl),
12904 /** KASUMI decrypt only (UEA1) */
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_kasumi_decryption_test_case_1),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_kasumi_decryption_test_case_2),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_kasumi_decryption_test_case_3),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_kasumi_decryption_test_case_4),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_kasumi_decryption_test_case_5),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_kasumi_encryption_test_case_1_oop),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_kasumi_decryption_test_case_1_oop),
12921 /** KASUMI hash only (UIA1) */
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_kasumi_hash_generate_test_case_1),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 test_kasumi_hash_generate_test_case_2),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_kasumi_hash_generate_test_case_3),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_kasumi_hash_generate_test_case_4),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_kasumi_hash_generate_test_case_5),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_kasumi_hash_generate_test_case_6),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_kasumi_hash_verify_test_case_1),
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 test_kasumi_hash_verify_test_case_2),
12938 TEST_CASE_ST(ut_setup, ut_teardown,
12939 test_kasumi_hash_verify_test_case_3),
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 test_kasumi_hash_verify_test_case_4),
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 test_kasumi_hash_verify_test_case_5),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_null_cipher_only_operation),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_null_auth_only_operation),
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_null_cipher_auth_operation),
12952 TEST_CASE_ST(ut_setup, ut_teardown,
12953 test_null_auth_cipher_operation),
12955 /** Negative tests */
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12958 TEST_CASE_ST(ut_setup, ut_teardown,
12959 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 authentication_verify_AES128_GMAC_fail_data_corrupt),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12968 TEST_CASES_END() /**< NULL terminate unit test array */
12972 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12973 .suite_name = "Crypto NITROX Unit Test Suite",
12974 .setup = testsuite_setup,
12975 .teardown = testsuite_teardown,
12976 .unit_test_cases = {
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 test_device_configure_invalid_dev_id),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_device_configure_invalid_queue_pair_ids),
12981 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12983 TEST_CASES_END() /**< NULL terminate unit test array */
12987 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
12988 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
12989 .setup = testsuite_setup,
12990 .teardown = testsuite_teardown,
12991 .unit_test_cases = {
12992 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12993 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12994 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12995 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12996 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12998 /** AES GCM Authenticated Encryption */
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_AES_GCM_authenticated_encryption_test_case_1),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_AES_GCM_authenticated_encryption_test_case_2),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_AES_GCM_authenticated_encryption_test_case_3),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_AES_GCM_authenticated_encryption_test_case_4),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_AES_GCM_authenticated_encryption_test_case_5),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_AES_GCM_authenticated_encryption_test_case_6),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 test_AES_GCM_authenticated_encryption_test_case_7),
13014 /** AES GCM Authenticated Decryption */
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_authenticated_decryption_test_case_1),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_authenticated_decryption_test_case_2),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_authenticated_decryption_test_case_3),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_authenticated_decryption_test_case_4),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_authenticated_decryption_test_case_5),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_AES_GCM_authenticated_decryption_test_case_6),
13027 TEST_CASE_ST(ut_setup, ut_teardown,
13028 test_AES_GCM_authenticated_decryption_test_case_7),
13029 /** AES GMAC Authentication */
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GMAC_authentication_test_case_1),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GMAC_authentication_verify_test_case_1),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GMAC_authentication_test_case_2),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GMAC_authentication_verify_test_case_2),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GMAC_authentication_test_case_3),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_AES_GMAC_authentication_verify_test_case_3),
13043 /** SNOW 3G encrypt only (UEA2) */
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_snow3g_encryption_test_case_1),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_snow3g_encryption_test_case_2),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_snow3g_encryption_test_case_3),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_snow3g_encryption_test_case_4),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_snow3g_encryption_test_case_5),
13055 TEST_CASE_ST(ut_setup, ut_teardown,
13056 test_snow3g_encryption_test_case_1_oop),
13057 TEST_CASE_ST(ut_setup, ut_teardown,
13058 test_snow3g_decryption_test_case_1_oop),
13059 TEST_CASE_ST(ut_setup, ut_teardown,
13060 test_snow3g_encryption_test_case_1_oop_sgl),
13062 /** SNOW 3G decrypt only (UEA2) */
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_snow3g_decryption_test_case_1),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_snow3g_decryption_test_case_2),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_snow3g_decryption_test_case_3),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_snow3g_decryption_test_case_4),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_snow3g_decryption_test_case_5),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_snow3g_hash_generate_test_case_1),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_snow3g_hash_generate_test_case_2),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_snow3g_hash_generate_test_case_3),
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_snow3g_hash_verify_test_case_1),
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_snow3g_hash_verify_test_case_2),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_snow3g_hash_verify_test_case_3),
13087 /** ZUC encrypt only (EEA3) */
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_zuc_encryption_test_case_1),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_zuc_encryption_test_case_2),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_zuc_encryption_test_case_3),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_zuc_encryption_test_case_4),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_zuc_encryption_test_case_5),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_zuc_hash_generate_test_case_1),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_zuc_hash_generate_test_case_2),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_zuc_hash_generate_test_case_3),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_zuc_hash_generate_test_case_4),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_zuc_hash_generate_test_case_5),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_zuc_encryption_test_case_6_sgl),
13111 /** KASUMI encrypt only (UEA1) */
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_kasumi_encryption_test_case_1),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_kasumi_encryption_test_case_2),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_kasumi_encryption_test_case_3),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_kasumi_encryption_test_case_4),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_kasumi_encryption_test_case_5),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_kasumi_encryption_test_case_1_sgl),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_kasumi_encryption_test_case_1_oop_sgl),
13126 /** KASUMI decrypt only (UEA1) */
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_kasumi_decryption_test_case_1),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_kasumi_decryption_test_case_2),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_kasumi_decryption_test_case_3),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 test_kasumi_decryption_test_case_4),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_kasumi_decryption_test_case_5),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_kasumi_encryption_test_case_1_oop),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_kasumi_decryption_test_case_1_oop),
13143 /** KASUMI hash only (UIA1) */
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_kasumi_hash_generate_test_case_1),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_kasumi_hash_generate_test_case_2),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_kasumi_hash_generate_test_case_3),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_kasumi_hash_generate_test_case_4),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_kasumi_hash_generate_test_case_5),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_kasumi_hash_generate_test_case_6),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_kasumi_hash_verify_test_case_1),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_kasumi_hash_verify_test_case_2),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_hash_verify_test_case_3),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_kasumi_hash_verify_test_case_4),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_kasumi_hash_verify_test_case_5),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_null_cipher_only_operation),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_null_auth_only_operation),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_null_cipher_auth_operation),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_null_auth_cipher_operation),
13177 /** Negative tests */
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 authentication_verify_AES128_GMAC_fail_data_corrupt),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13190 TEST_CASES_END() /**< NULL terminate unit test array */
13195 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13197 gbl_driver_id = rte_cryptodev_driver_id_get(
13198 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13200 if (gbl_driver_id == -1) {
13201 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13202 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13203 "are enabled in config file to run this testsuite.\n");
13204 return TEST_SKIPPED;
13207 return unit_test_suite_runner(&cryptodev_testsuite);
13211 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13213 gbl_driver_id = rte_cryptodev_driver_id_get(
13214 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13216 if (gbl_driver_id == -1) {
13217 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13218 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13219 "in config file to run this testsuite.\n");
13220 return TEST_FAILED;
13223 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13227 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13229 gbl_driver_id = rte_cryptodev_driver_id_get(
13230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13232 if (gbl_driver_id == -1) {
13233 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13234 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13235 "in config file to run this testsuite.\n");
13236 return TEST_SKIPPED;
13239 return unit_test_suite_runner(&cryptodev_testsuite);
13243 test_cryptodev_openssl(void)
13245 gbl_driver_id = rte_cryptodev_driver_id_get(
13246 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13248 if (gbl_driver_id == -1) {
13249 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13250 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13251 "in config file to run this testsuite.\n");
13252 return TEST_SKIPPED;
13255 return unit_test_suite_runner(&cryptodev_testsuite);
13259 test_cryptodev_aesni_gcm(void)
13261 gbl_driver_id = rte_cryptodev_driver_id_get(
13262 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13264 if (gbl_driver_id == -1) {
13265 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13266 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13267 "in config file to run this testsuite.\n");
13268 return TEST_SKIPPED;
13271 return unit_test_suite_runner(&cryptodev_testsuite);
13275 test_cryptodev_null(void)
13277 gbl_driver_id = rte_cryptodev_driver_id_get(
13278 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13280 if (gbl_driver_id == -1) {
13281 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13282 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13283 "in config file to run this testsuite.\n");
13284 return TEST_SKIPPED;
13287 return unit_test_suite_runner(&cryptodev_testsuite);
13291 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13293 gbl_driver_id = rte_cryptodev_driver_id_get(
13294 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13296 if (gbl_driver_id == -1) {
13297 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13298 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13299 "in config file to run this testsuite.\n");
13300 return TEST_SKIPPED;
13303 return unit_test_suite_runner(&cryptodev_testsuite);
13307 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13309 gbl_driver_id = rte_cryptodev_driver_id_get(
13310 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13312 if (gbl_driver_id == -1) {
13313 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13314 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13315 "in config file to run this testsuite.\n");
13316 return TEST_SKIPPED;
13319 return unit_test_suite_runner(&cryptodev_testsuite);
13323 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13325 gbl_driver_id = rte_cryptodev_driver_id_get(
13326 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13328 if (gbl_driver_id == -1) {
13329 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13330 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13331 "in config file to run this testsuite.\n");
13332 return TEST_SKIPPED;
13335 return unit_test_suite_runner(&cryptodev_testsuite);
13339 test_cryptodev_armv8(void)
13341 gbl_driver_id = rte_cryptodev_driver_id_get(
13342 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13344 if (gbl_driver_id == -1) {
13345 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13346 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13347 "in config file to run this testsuite.\n");
13348 return TEST_SKIPPED;
13351 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13355 test_cryptodev_mrvl(void)
13357 gbl_driver_id = rte_cryptodev_driver_id_get(
13358 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13360 if (gbl_driver_id == -1) {
13361 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13362 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13363 "in config file to run this testsuite.\n");
13364 return TEST_SKIPPED;
13367 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13370 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13373 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13375 gbl_driver_id = rte_cryptodev_driver_id_get(
13376 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13378 if (gbl_driver_id == -1) {
13379 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13380 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13381 "in config file to run this testsuite.\n");
13382 return TEST_SKIPPED;
13385 if (rte_cryptodev_driver_id_get(
13386 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13387 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13388 " enabled in config file to run this testsuite.\n");
13389 return TEST_SKIPPED;
13391 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13394 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13399 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13401 gbl_driver_id = rte_cryptodev_driver_id_get(
13402 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13404 if (gbl_driver_id == -1) {
13405 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13406 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13407 "in config file to run this testsuite.\n");
13408 return TEST_SKIPPED;
13411 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13415 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13417 gbl_driver_id = rte_cryptodev_driver_id_get(
13418 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13420 if (gbl_driver_id == -1) {
13421 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13422 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13423 "in config file to run this testsuite.\n");
13424 return TEST_SKIPPED;
13427 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13431 test_cryptodev_ccp(void)
13433 gbl_driver_id = rte_cryptodev_driver_id_get(
13434 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13436 if (gbl_driver_id == -1) {
13437 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13438 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13439 "in config file to run this testsuite.\n");
13440 return TEST_FAILED;
13443 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13447 test_cryptodev_octeontx(void)
13449 gbl_driver_id = rte_cryptodev_driver_id_get(
13450 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13451 if (gbl_driver_id == -1) {
13452 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13453 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13454 "enabled in config file to run this "
13456 return TEST_FAILED;
13458 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13462 test_cryptodev_octeontx2(void)
13464 gbl_driver_id = rte_cryptodev_driver_id_get(
13465 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13466 if (gbl_driver_id == -1) {
13467 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13468 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13469 "enabled in config file to run this "
13471 return TEST_FAILED;
13473 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13477 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13479 gbl_driver_id = rte_cryptodev_driver_id_get(
13480 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13482 if (gbl_driver_id == -1) {
13483 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13484 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13485 "in config file to run this testsuite.\n");
13486 return TEST_FAILED;
13489 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13493 test_cryptodev_nitrox(void)
13495 gbl_driver_id = rte_cryptodev_driver_id_get(
13496 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13498 if (gbl_driver_id == -1) {
13499 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13500 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13501 "in config file to run this testsuite.\n");
13502 return TEST_FAILED;
13505 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13508 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13509 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13510 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13511 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13512 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13513 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13514 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13515 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13516 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13517 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13518 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13519 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13520 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13521 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13522 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13523 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13524 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13525 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);