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 printf("Error sending packet for encryption");
152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
158 static struct crypto_testsuite_params testsuite_params = { NULL };
159 static struct crypto_unittest_params unittest_params;
162 testsuite_setup(void)
164 struct crypto_testsuite_params *ts_params = &testsuite_params;
165 struct rte_cryptodev_info info;
166 uint32_t i = 0, nb_devs, dev_id;
170 memset(ts_params, 0, sizeof(*ts_params));
172 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
173 if (ts_params->mbuf_pool == NULL) {
174 /* Not already created so create */
175 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
177 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
179 if (ts_params->mbuf_pool == NULL) {
180 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
185 ts_params->large_mbuf_pool = rte_mempool_lookup(
186 "CRYPTO_LARGE_MBUFPOOL");
187 if (ts_params->large_mbuf_pool == NULL) {
188 /* Not already created so create */
189 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
190 "CRYPTO_LARGE_MBUFPOOL",
193 if (ts_params->large_mbuf_pool == NULL) {
195 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
200 ts_params->op_mpool = rte_crypto_op_pool_create(
201 "MBUF_CRYPTO_SYM_OP_POOL",
202 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
203 NUM_MBUFS, MBUF_CACHE_SIZE,
205 sizeof(struct rte_crypto_sym_xform) +
208 if (ts_params->op_mpool == NULL) {
209 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
213 /* Create an AESNI MB device if required */
214 if (gbl_driver_id == rte_cryptodev_driver_id_get(
215 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
216 nb_devs = rte_cryptodev_device_count_by_driver(
217 rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
223 TEST_ASSERT(ret == 0,
224 "Failed to create instance of"
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
230 /* Create an AESNI GCM device if required */
231 if (gbl_driver_id == rte_cryptodev_driver_id_get(
232 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
233 nb_devs = rte_cryptodev_device_count_by_driver(
234 rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
237 TEST_ASSERT_SUCCESS(rte_vdev_init(
238 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
239 "Failed to create instance of"
241 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
245 /* Create a SNOW 3G device if required */
246 if (gbl_driver_id == rte_cryptodev_driver_id_get(
247 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
248 nb_devs = rte_cryptodev_device_count_by_driver(
249 rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
252 TEST_ASSERT_SUCCESS(rte_vdev_init(
253 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
254 "Failed to create instance of"
256 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
260 /* Create a KASUMI device if required */
261 if (gbl_driver_id == rte_cryptodev_driver_id_get(
262 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
263 nb_devs = rte_cryptodev_device_count_by_driver(
264 rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
267 TEST_ASSERT_SUCCESS(rte_vdev_init(
268 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
269 "Failed to create instance of"
271 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
275 /* Create a ZUC device if required */
276 if (gbl_driver_id == rte_cryptodev_driver_id_get(
277 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
278 nb_devs = rte_cryptodev_device_count_by_driver(
279 rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
282 TEST_ASSERT_SUCCESS(rte_vdev_init(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
284 "Failed to create instance of"
286 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
290 /* Create a NULL device if required */
291 if (gbl_driver_id == rte_cryptodev_driver_id_get(
292 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
293 nb_devs = rte_cryptodev_device_count_by_driver(
294 rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
300 TEST_ASSERT(ret == 0,
301 "Failed to create instance of"
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
307 /* Create an OPENSSL device if required */
308 if (gbl_driver_id == rte_cryptodev_driver_id_get(
309 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
310 nb_devs = rte_cryptodev_device_count_by_driver(
311 rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
318 TEST_ASSERT(ret == 0, "Failed to create "
319 "instance of pmd : %s",
320 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
324 /* Create a ARMv8 device if required */
325 if (gbl_driver_id == rte_cryptodev_driver_id_get(
326 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
327 nb_devs = rte_cryptodev_device_count_by_driver(
328 rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
335 TEST_ASSERT(ret == 0, "Failed to create "
336 "instance of pmd : %s",
337 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
341 /* Create a MVSAM device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
349 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
352 TEST_ASSERT(ret == 0, "Failed to create "
353 "instance of pmd : %s",
354 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
358 /* Create an CCP device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
366 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
369 TEST_ASSERT(ret == 0, "Failed to create "
370 "instance of pmd : %s",
371 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
375 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
376 char vdev_args[VDEV_ARGS_SIZE] = {""};
377 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
378 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
379 uint16_t slave_core_count = 0;
380 uint16_t socket_id = 0;
382 if (gbl_driver_id == rte_cryptodev_driver_id_get(
383 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
385 /* Identify the Slave Cores
386 * Use 2 slave cores for the device args
388 RTE_LCORE_FOREACH_SLAVE(i) {
389 if (slave_core_count > 1)
391 snprintf(vdev_args, sizeof(vdev_args),
392 "%s%d", temp_str, i);
393 strcpy(temp_str, vdev_args);
394 strlcat(temp_str, ";", sizeof(temp_str));
396 socket_id = rte_lcore_to_socket_id(i);
398 if (slave_core_count != 2) {
400 "Cryptodev scheduler test require at least "
401 "two slave cores to run. "
402 "Please use the correct coremask.\n");
405 strcpy(temp_str, vdev_args);
406 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
407 temp_str, socket_id);
408 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
409 nb_devs = rte_cryptodev_device_count_by_driver(
410 rte_cryptodev_driver_id_get(
411 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
414 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
416 TEST_ASSERT(ret == 0,
417 "Failed to create instance %u of"
419 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
422 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
424 nb_devs = rte_cryptodev_count();
426 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
430 /* Create list of valid crypto devs */
431 for (i = 0; i < nb_devs; i++) {
432 rte_cryptodev_info_get(i, &info);
433 if (info.driver_id == gbl_driver_id)
434 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
437 if (ts_params->valid_dev_count < 1)
440 /* Set up all the qps on the first of the valid devices found */
442 dev_id = ts_params->valid_devs[0];
444 rte_cryptodev_info_get(dev_id, &info);
446 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
447 ts_params->conf.socket_id = SOCKET_ID_ANY;
448 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
450 unsigned int session_size =
451 rte_cryptodev_sym_get_private_session_size(dev_id);
454 * Create mempool with maximum number of sessions * 2,
455 * to include the session headers
457 if (info.sym.max_nb_sessions != 0 &&
458 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
459 RTE_LOG(ERR, USER1, "Device does not support "
460 "at least %u sessions\n",
465 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
466 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
468 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
469 "session mempool allocation failed");
471 ts_params->session_priv_mpool = rte_mempool_create(
475 0, 0, NULL, NULL, NULL,
478 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
479 "session mempool allocation failed");
483 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
485 "Failed to configure cryptodev %u with %u qps",
486 dev_id, ts_params->conf.nb_queue_pairs);
488 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
489 ts_params->qp_conf.mp_session = ts_params->session_mpool;
490 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
492 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
493 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
494 dev_id, qp_id, &ts_params->qp_conf,
495 rte_cryptodev_socket_id(dev_id)),
496 "Failed to setup queue pair %u on cryptodev %u",
504 testsuite_teardown(void)
506 struct crypto_testsuite_params *ts_params = &testsuite_params;
508 if (ts_params->mbuf_pool != NULL) {
509 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
510 rte_mempool_avail_count(ts_params->mbuf_pool));
513 if (ts_params->op_mpool != NULL) {
514 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
515 rte_mempool_avail_count(ts_params->op_mpool));
518 /* Free session mempools */
519 if (ts_params->session_priv_mpool != NULL) {
520 rte_mempool_free(ts_params->session_priv_mpool);
521 ts_params->session_priv_mpool = NULL;
524 if (ts_params->session_mpool != NULL) {
525 rte_mempool_free(ts_params->session_mpool);
526 ts_params->session_mpool = NULL;
533 struct crypto_testsuite_params *ts_params = &testsuite_params;
534 struct crypto_unittest_params *ut_params = &unittest_params;
538 /* Clear unit test parameters before running test */
539 memset(ut_params, 0, sizeof(*ut_params));
541 /* Reconfigure device to default parameters */
542 ts_params->conf.socket_id = SOCKET_ID_ANY;
543 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
544 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
545 ts_params->qp_conf.mp_session = ts_params->session_mpool;
546 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
548 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
550 "Failed to configure cryptodev %u",
551 ts_params->valid_devs[0]);
553 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
554 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
555 ts_params->valid_devs[0], qp_id,
557 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
558 "Failed to setup queue pair %u on cryptodev %u",
559 qp_id, ts_params->valid_devs[0]);
563 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
565 /* Start the device */
566 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
567 "Failed to start cryptodev %u",
568 ts_params->valid_devs[0]);
576 struct crypto_testsuite_params *ts_params = &testsuite_params;
577 struct crypto_unittest_params *ut_params = &unittest_params;
578 struct rte_cryptodev_stats stats;
580 /* free crypto session structure */
581 #ifdef RTE_LIBRTE_SECURITY
582 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
583 if (ut_params->sec_session) {
584 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
585 (ts_params->valid_devs[0]),
586 ut_params->sec_session);
587 ut_params->sec_session = NULL;
592 if (ut_params->sess) {
593 rte_cryptodev_sym_session_clear(
594 ts_params->valid_devs[0],
596 rte_cryptodev_sym_session_free(ut_params->sess);
597 ut_params->sess = NULL;
601 /* free crypto operation structure */
603 rte_crypto_op_free(ut_params->op);
606 * free mbuf - both obuf and ibuf are usually the same,
607 * so check if they point at the same address is necessary,
608 * to avoid freeing the mbuf twice.
610 if (ut_params->obuf) {
611 rte_pktmbuf_free(ut_params->obuf);
612 if (ut_params->ibuf == ut_params->obuf)
616 if (ut_params->ibuf) {
617 rte_pktmbuf_free(ut_params->ibuf);
621 if (ts_params->mbuf_pool != NULL)
622 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
623 rte_mempool_avail_count(ts_params->mbuf_pool));
625 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
627 /* Stop the device */
628 rte_cryptodev_stop(ts_params->valid_devs[0]);
632 test_device_configure_invalid_dev_id(void)
634 struct crypto_testsuite_params *ts_params = &testsuite_params;
635 uint16_t dev_id, num_devs = 0;
637 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
638 "Need at least %d devices for test", 1);
640 /* valid dev_id values */
641 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
643 /* Stop the device in case it's started so it can be configured */
644 rte_cryptodev_stop(dev_id);
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
647 "Failed test for rte_cryptodev_configure: "
648 "invalid dev_num %u", dev_id);
650 /* invalid dev_id values */
653 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
654 "Failed test for rte_cryptodev_configure: "
655 "invalid dev_num %u", dev_id);
659 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
660 "Failed test for rte_cryptodev_configure:"
661 "invalid dev_num %u", dev_id);
667 test_device_configure_invalid_queue_pair_ids(void)
669 struct crypto_testsuite_params *ts_params = &testsuite_params;
670 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
672 /* Stop the device in case it's started so it can be configured */
673 rte_cryptodev_stop(ts_params->valid_devs[0]);
675 /* valid - one queue pairs */
676 ts_params->conf.nb_queue_pairs = 1;
678 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
680 "Failed to configure cryptodev: dev_id %u, qp_id %u",
681 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
684 /* valid - max value queue pairs */
685 ts_params->conf.nb_queue_pairs = orig_nb_qps;
687 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
689 "Failed to configure cryptodev: dev_id %u, qp_id %u",
690 ts_params->valid_devs[0],
691 ts_params->conf.nb_queue_pairs);
694 /* invalid - zero queue pairs */
695 ts_params->conf.nb_queue_pairs = 0;
697 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
699 "Failed test for rte_cryptodev_configure, dev_id %u,"
701 ts_params->valid_devs[0],
702 ts_params->conf.nb_queue_pairs);
705 /* invalid - max value supported by field queue pairs */
706 ts_params->conf.nb_queue_pairs = UINT16_MAX;
708 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
710 "Failed test for rte_cryptodev_configure, dev_id %u,"
712 ts_params->valid_devs[0],
713 ts_params->conf.nb_queue_pairs);
716 /* invalid - max value + 1 queue pairs */
717 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
719 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
721 "Failed test for rte_cryptodev_configure, dev_id %u,"
723 ts_params->valid_devs[0],
724 ts_params->conf.nb_queue_pairs);
726 /* revert to original testsuite value */
727 ts_params->conf.nb_queue_pairs = orig_nb_qps;
733 test_queue_pair_descriptor_setup(void)
735 struct crypto_testsuite_params *ts_params = &testsuite_params;
736 struct rte_cryptodev_info dev_info;
737 struct rte_cryptodev_qp_conf qp_conf = {
738 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
743 /* Stop the device in case it's started so it can be configured */
744 rte_cryptodev_stop(ts_params->valid_devs[0]);
747 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
749 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
751 "Failed to configure cryptodev %u",
752 ts_params->valid_devs[0]);
755 * Test various ring sizes on this device. memzones can't be
756 * freed so are re-used if ring is released and re-created.
758 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
759 qp_conf.mp_session = ts_params->session_mpool;
760 qp_conf.mp_session_private = ts_params->session_priv_mpool;
762 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
763 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
764 ts_params->valid_devs[0], qp_id, &qp_conf,
765 rte_cryptodev_socket_id(
766 ts_params->valid_devs[0])),
768 "rte_cryptodev_queue_pair_setup: num_inflights "
769 "%u on qp %u on cryptodev %u",
770 qp_conf.nb_descriptors, qp_id,
771 ts_params->valid_devs[0]);
774 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
776 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
777 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
778 ts_params->valid_devs[0], qp_id, &qp_conf,
779 rte_cryptodev_socket_id(
780 ts_params->valid_devs[0])),
782 " rte_cryptodev_queue_pair_setup: num_inflights"
783 " %u on qp %u on cryptodev %u",
784 qp_conf.nb_descriptors, qp_id,
785 ts_params->valid_devs[0]);
788 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
790 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
791 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
792 ts_params->valid_devs[0], qp_id, &qp_conf,
793 rte_cryptodev_socket_id(
794 ts_params->valid_devs[0])),
796 "rte_cryptodev_queue_pair_setup: num_inflights"
797 " %u on qp %u on cryptodev %u",
798 qp_conf.nb_descriptors, qp_id,
799 ts_params->valid_devs[0]);
802 /* invalid number of descriptors - max supported + 2 */
803 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
805 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
806 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
807 ts_params->valid_devs[0], qp_id, &qp_conf,
808 rte_cryptodev_socket_id(
809 ts_params->valid_devs[0])),
810 "Unexpectedly passed test for "
811 "rte_cryptodev_queue_pair_setup:"
812 "num_inflights %u on qp %u on cryptodev %u",
813 qp_conf.nb_descriptors, qp_id,
814 ts_params->valid_devs[0]);
817 /* invalid number of descriptors - max value of parameter */
818 qp_conf.nb_descriptors = UINT32_MAX-1;
820 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
821 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
822 ts_params->valid_devs[0], qp_id, &qp_conf,
823 rte_cryptodev_socket_id(
824 ts_params->valid_devs[0])),
825 "Unexpectedly passed test for "
826 "rte_cryptodev_queue_pair_setup:"
827 "num_inflights %u on qp %u on cryptodev %u",
828 qp_conf.nb_descriptors, qp_id,
829 ts_params->valid_devs[0]);
832 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
834 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
835 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
836 ts_params->valid_devs[0], qp_id, &qp_conf,
837 rte_cryptodev_socket_id(
838 ts_params->valid_devs[0])),
840 " rte_cryptodev_queue_pair_setup:"
841 "num_inflights %u on qp %u on cryptodev %u",
842 qp_conf.nb_descriptors, qp_id,
843 ts_params->valid_devs[0]);
846 /* invalid number of descriptors - max supported + 1 */
847 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
849 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
850 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
851 ts_params->valid_devs[0], qp_id, &qp_conf,
852 rte_cryptodev_socket_id(
853 ts_params->valid_devs[0])),
854 "Unexpectedly passed test for "
855 "rte_cryptodev_queue_pair_setup:"
856 "num_inflights %u on qp %u on cryptodev %u",
857 qp_conf.nb_descriptors, qp_id,
858 ts_params->valid_devs[0]);
861 /* test invalid queue pair id */
862 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
864 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
866 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
867 ts_params->valid_devs[0],
869 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
870 "Failed test for rte_cryptodev_queue_pair_setup:"
871 "invalid qp %u on cryptodev %u",
872 qp_id, ts_params->valid_devs[0]);
874 qp_id = 0xffff; /*invalid*/
876 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
877 ts_params->valid_devs[0],
879 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
880 "Failed test for rte_cryptodev_queue_pair_setup:"
881 "invalid qp %u on cryptodev %u",
882 qp_id, ts_params->valid_devs[0]);
887 /* ***** Plaintext data for tests ***** */
889 const char catch_22_quote_1[] =
890 "There was only one catch and that was Catch-22, which "
891 "specified that a concern for one's safety in the face of "
892 "dangers that were real and immediate was the process of a "
893 "rational mind. Orr was crazy and could be grounded. All he "
894 "had to do was ask; and as soon as he did, he would no longer "
895 "be crazy and would have to fly more missions. Orr would be "
896 "crazy to fly more missions and sane if he didn't, but if he "
897 "was sane he had to fly them. If he flew them he was crazy "
898 "and didn't have to; but if he didn't want to he was sane and "
899 "had to. Yossarian was moved very deeply by the absolute "
900 "simplicity of this clause of Catch-22 and let out a "
901 "respectful whistle. \"That's some catch, that Catch-22\", he "
902 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
904 const char catch_22_quote[] =
905 "What a lousy earth! He wondered how many people were "
906 "destitute that same night even in his own prosperous country, "
907 "how many homes were shanties, how many husbands were drunk "
908 "and wives socked, and how many children were bullied, abused, "
909 "or abandoned. How many families hungered for food they could "
910 "not afford to buy? How many hearts were broken? How many "
911 "suicides would take place that same night, how many people "
912 "would go insane? How many cockroaches and landlords would "
913 "triumph? How many winners were losers, successes failures, "
914 "and rich men poor men? How many wise guys were stupid? How "
915 "many happy endings were unhappy endings? How many honest men "
916 "were liars, brave men cowards, loyal men traitors, how many "
917 "sainted men were corrupt, how many people in positions of "
918 "trust had sold their souls to bodyguards, how many had never "
919 "had souls? How many straight-and-narrow paths were crooked "
920 "paths? How many best families were worst families and how "
921 "many good people were bad people? When you added them all up "
922 "and then subtracted, you might be left with only the children, "
923 "and perhaps with Albert Einstein and an old violinist or "
924 "sculptor somewhere.";
926 #define QUOTE_480_BYTES (480)
927 #define QUOTE_512_BYTES (512)
928 #define QUOTE_768_BYTES (768)
929 #define QUOTE_1024_BYTES (1024)
933 /* ***** SHA1 Hash Tests ***** */
935 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
937 static uint8_t hmac_sha1_key[] = {
938 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
939 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
940 0xDE, 0xF4, 0xDE, 0xAD };
942 /* ***** SHA224 Hash Tests ***** */
944 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
947 /* ***** AES-CBC Cipher Tests ***** */
949 #define CIPHER_KEY_LENGTH_AES_CBC (16)
950 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
952 static uint8_t aes_cbc_key[] = {
953 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
954 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
956 static uint8_t aes_cbc_iv[] = {
957 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
958 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
961 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
963 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
964 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
965 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
966 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
967 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
968 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
969 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
970 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
971 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
972 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
973 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
974 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
975 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
976 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
977 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
978 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
979 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
980 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
981 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
982 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
983 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
984 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
985 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
986 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
987 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
988 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
989 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
990 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
991 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
992 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
993 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
994 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
995 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
996 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
997 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
998 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
999 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1000 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1001 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1002 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1003 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1004 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1005 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1006 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1007 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1008 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1009 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1010 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1011 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1012 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1013 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1014 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1015 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1016 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1017 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1018 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1019 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1020 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1021 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1022 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1023 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1024 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1025 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1026 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1027 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1030 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1031 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1032 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1033 0x18, 0x8c, 0x1d, 0x32
1037 /* Multisession Vector context Test */
1038 /*Begin Session 0 */
1039 static uint8_t ms_aes_cbc_key0[] = {
1040 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1041 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1044 static uint8_t ms_aes_cbc_iv0[] = {
1045 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1049 static const uint8_t ms_aes_cbc_cipher0[] = {
1050 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1051 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1052 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1053 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1054 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1055 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1056 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1057 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1058 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1059 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1060 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1061 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1062 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1063 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1064 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1065 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1066 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1067 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1068 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1069 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1070 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1071 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1072 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1073 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1074 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1075 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1076 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1077 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1078 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1079 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1080 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1081 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1082 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1083 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1084 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1085 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1086 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1087 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1088 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1089 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1090 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1091 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1092 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1093 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1094 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1095 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1096 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1097 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1098 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1099 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1100 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1101 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1102 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1103 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1104 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1105 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1106 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1107 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1108 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1109 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1110 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1111 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1112 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1113 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1117 static uint8_t ms_hmac_key0[] = {
1118 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1119 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1120 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1121 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1122 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1123 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1124 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1125 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1128 static const uint8_t ms_hmac_digest0[] = {
1129 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1130 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1131 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1132 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1133 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1134 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1135 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1136 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1140 /* Begin session 1 */
1142 static uint8_t ms_aes_cbc_key1[] = {
1143 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1144 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1147 static uint8_t ms_aes_cbc_iv1[] = {
1148 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1152 static const uint8_t ms_aes_cbc_cipher1[] = {
1153 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1154 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1155 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1156 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1157 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1158 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1159 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1160 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1161 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1162 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1163 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1164 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1165 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1166 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1167 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1168 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1169 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1170 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1171 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1172 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1173 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1174 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1175 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1176 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1177 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1178 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1179 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1180 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1181 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1182 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1183 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1184 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1185 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1186 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1187 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1188 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1189 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1190 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1191 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1192 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1193 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1194 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1195 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1196 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1197 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1198 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1199 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1200 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1201 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1202 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1203 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1204 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1205 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1206 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1207 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1208 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1209 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1210 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1211 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1212 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1213 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1214 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1215 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1216 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1220 static uint8_t ms_hmac_key1[] = {
1221 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1222 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1223 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1224 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1225 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1226 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1227 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1228 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1231 static const uint8_t ms_hmac_digest1[] = {
1232 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1233 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1234 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1235 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1236 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1237 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1238 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1239 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1242 /* Begin Session 2 */
1243 static uint8_t ms_aes_cbc_key2[] = {
1244 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1245 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1248 static uint8_t ms_aes_cbc_iv2[] = {
1249 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1250 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1253 static const uint8_t ms_aes_cbc_cipher2[] = {
1254 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1255 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1256 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1257 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1258 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1259 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1260 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1261 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1262 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1263 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1264 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1265 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1266 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1267 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1268 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1269 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1270 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1271 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1272 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1273 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1274 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1275 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1276 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1277 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1278 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1279 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1280 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1281 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1282 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1283 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1284 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1285 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1286 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1287 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1288 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1289 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1290 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1291 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1292 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1293 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1294 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1295 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1296 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1297 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1298 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1299 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1300 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1301 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1302 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1303 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1304 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1305 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1306 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1307 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1308 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1309 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1310 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1311 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1312 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1313 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1314 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1315 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1316 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1317 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1320 static uint8_t ms_hmac_key2[] = {
1321 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1322 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1323 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1324 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1325 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1326 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1327 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1328 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1331 static const uint8_t ms_hmac_digest2[] = {
1332 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1333 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1334 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1335 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1336 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1337 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1338 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1339 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1346 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1348 struct crypto_testsuite_params *ts_params = &testsuite_params;
1349 struct crypto_unittest_params *ut_params = &unittest_params;
1351 /* Generate test mbuf data and space for digest */
1352 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1353 catch_22_quote, QUOTE_512_BYTES, 0);
1355 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1356 DIGEST_BYTE_LENGTH_SHA1);
1357 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1359 /* Setup Cipher Parameters */
1360 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1361 ut_params->cipher_xform.next = &ut_params->auth_xform;
1363 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1364 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1365 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1366 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1367 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1368 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1370 /* Setup HMAC Parameters */
1371 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1373 ut_params->auth_xform.next = NULL;
1375 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1376 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1377 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1378 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1379 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1381 ut_params->sess = rte_cryptodev_sym_session_create(
1382 ts_params->session_mpool);
1384 /* Create crypto session*/
1385 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1386 ut_params->sess, &ut_params->cipher_xform,
1387 ts_params->session_priv_mpool);
1388 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1390 /* Generate crypto op data structure */
1391 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1392 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1393 TEST_ASSERT_NOT_NULL(ut_params->op,
1394 "Failed to allocate symmetric crypto operation struct");
1396 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1398 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1400 /* set crypto operation source mbuf */
1401 sym_op->m_src = ut_params->ibuf;
1403 /* Set crypto operation authentication parameters */
1404 sym_op->auth.digest.data = ut_params->digest;
1405 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1406 ut_params->ibuf, QUOTE_512_BYTES);
1408 sym_op->auth.data.offset = 0;
1409 sym_op->auth.data.length = QUOTE_512_BYTES;
1411 /* Copy IV at the end of the crypto operation */
1412 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1413 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1415 /* Set crypto operation cipher parameters */
1416 sym_op->cipher.data.offset = 0;
1417 sym_op->cipher.data.length = QUOTE_512_BYTES;
1419 /* Process crypto operation */
1420 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1421 ut_params->op), "failed to process sym crypto op");
1423 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1424 "crypto op processing failed");
1427 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1430 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1431 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1433 "ciphertext data not as expected");
1435 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1437 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1438 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1439 gbl_driver_id == rte_cryptodev_driver_id_get(
1440 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1441 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1442 DIGEST_BYTE_LENGTH_SHA1,
1443 "Generated digest data not as expected");
1445 return TEST_SUCCESS;
1448 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1450 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1452 static uint8_t hmac_sha512_key[] = {
1453 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1454 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1455 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1456 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1457 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1458 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1459 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1460 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1462 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1463 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1464 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1465 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1466 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1467 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1468 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1469 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1470 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1475 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1476 struct crypto_unittest_params *ut_params,
1477 uint8_t *cipher_key,
1481 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1482 struct crypto_unittest_params *ut_params,
1483 struct crypto_testsuite_params *ts_params,
1484 const uint8_t *cipher,
1485 const uint8_t *digest,
1490 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1491 struct crypto_unittest_params *ut_params,
1492 uint8_t *cipher_key,
1496 /* Setup Cipher Parameters */
1497 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1498 ut_params->cipher_xform.next = NULL;
1500 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1501 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1502 ut_params->cipher_xform.cipher.key.data = cipher_key;
1503 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1504 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1505 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1507 /* Setup HMAC Parameters */
1508 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1509 ut_params->auth_xform.next = &ut_params->cipher_xform;
1511 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1512 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1513 ut_params->auth_xform.auth.key.data = hmac_key;
1514 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1515 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1517 return TEST_SUCCESS;
1522 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1523 struct crypto_unittest_params *ut_params,
1524 struct crypto_testsuite_params *ts_params,
1525 const uint8_t *cipher,
1526 const uint8_t *digest,
1529 /* Generate test mbuf data and digest */
1530 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1533 QUOTE_512_BYTES, 0);
1535 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1536 DIGEST_BYTE_LENGTH_SHA512);
1537 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1539 rte_memcpy(ut_params->digest,
1541 DIGEST_BYTE_LENGTH_SHA512);
1543 /* Generate Crypto op data structure */
1544 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1545 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1546 TEST_ASSERT_NOT_NULL(ut_params->op,
1547 "Failed to allocate symmetric crypto operation struct");
1549 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1551 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1553 /* set crypto operation source mbuf */
1554 sym_op->m_src = ut_params->ibuf;
1556 sym_op->auth.digest.data = ut_params->digest;
1557 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1558 ut_params->ibuf, QUOTE_512_BYTES);
1560 sym_op->auth.data.offset = 0;
1561 sym_op->auth.data.length = QUOTE_512_BYTES;
1563 /* Copy IV at the end of the crypto operation */
1564 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1565 iv, CIPHER_IV_LENGTH_AES_CBC);
1567 sym_op->cipher.data.offset = 0;
1568 sym_op->cipher.data.length = QUOTE_512_BYTES;
1570 /* Process crypto operation */
1571 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1572 ut_params->op), "failed to process sym crypto op");
1574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1575 "crypto op processing failed");
1577 ut_params->obuf = ut_params->op->sym->m_src;
1580 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1581 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1584 "Plaintext data not as expected");
1587 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1588 "Digest verification failed");
1590 return TEST_SUCCESS;
1594 test_AES_cipheronly_mb_all(void)
1596 struct crypto_testsuite_params *ts_params = &testsuite_params;
1599 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1600 ts_params->op_mpool,
1601 ts_params->session_mpool, ts_params->session_priv_mpool,
1602 ts_params->valid_devs[0],
1603 rte_cryptodev_driver_id_get(
1604 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1605 BLKCIPHER_AES_CIPHERONLY_TYPE);
1607 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1609 return TEST_SUCCESS;
1613 test_AES_docsis_mb_all(void)
1615 struct crypto_testsuite_params *ts_params = &testsuite_params;
1618 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1619 ts_params->op_mpool,
1620 ts_params->session_mpool, ts_params->session_priv_mpool,
1621 ts_params->valid_devs[0],
1622 rte_cryptodev_driver_id_get(
1623 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1624 BLKCIPHER_AES_DOCSIS_TYPE);
1626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1628 return TEST_SUCCESS;
1632 test_AES_docsis_qat_all(void)
1634 struct crypto_testsuite_params *ts_params = &testsuite_params;
1637 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1638 ts_params->op_mpool,
1639 ts_params->session_mpool, ts_params->session_priv_mpool,
1640 ts_params->valid_devs[0],
1641 rte_cryptodev_driver_id_get(
1642 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1643 BLKCIPHER_AES_DOCSIS_TYPE);
1645 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1647 return TEST_SUCCESS;
1651 test_DES_docsis_qat_all(void)
1653 struct crypto_testsuite_params *ts_params = &testsuite_params;
1656 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1657 ts_params->op_mpool,
1658 ts_params->session_mpool, ts_params->session_priv_mpool,
1659 ts_params->valid_devs[0],
1660 rte_cryptodev_driver_id_get(
1661 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1662 BLKCIPHER_DES_DOCSIS_TYPE);
1664 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1666 return TEST_SUCCESS;
1670 test_authonly_mb_all(void)
1672 struct crypto_testsuite_params *ts_params = &testsuite_params;
1675 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1676 ts_params->op_mpool,
1677 ts_params->session_mpool, ts_params->session_priv_mpool,
1678 ts_params->valid_devs[0],
1679 rte_cryptodev_driver_id_get(
1680 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1681 BLKCIPHER_AUTHONLY_TYPE);
1683 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1685 return TEST_SUCCESS;
1689 test_authonly_qat_all(void)
1691 struct crypto_testsuite_params *ts_params = &testsuite_params;
1694 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1695 ts_params->op_mpool,
1696 ts_params->session_mpool, ts_params->session_priv_mpool,
1697 ts_params->valid_devs[0],
1698 rte_cryptodev_driver_id_get(
1699 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1700 BLKCIPHER_AUTHONLY_TYPE);
1702 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1704 return TEST_SUCCESS;
1708 test_AES_chain_null_all(void)
1710 struct crypto_testsuite_params *ts_params = &testsuite_params;
1713 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1714 ts_params->op_mpool,
1715 ts_params->session_mpool, ts_params->session_priv_mpool,
1716 ts_params->valid_devs[0],
1717 rte_cryptodev_driver_id_get(
1718 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1719 BLKCIPHER_AES_CHAIN_TYPE);
1721 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1723 return TEST_SUCCESS;
1727 test_AES_cipheronly_null_all(void)
1729 struct crypto_testsuite_params *ts_params = &testsuite_params;
1732 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1733 ts_params->op_mpool,
1734 ts_params->session_mpool, ts_params->session_priv_mpool,
1735 ts_params->valid_devs[0],
1736 rte_cryptodev_driver_id_get(
1737 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1738 BLKCIPHER_AES_CIPHERONLY_TYPE);
1740 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1742 return TEST_SUCCESS;
1746 test_authonly_null_all(void)
1748 struct crypto_testsuite_params *ts_params = &testsuite_params;
1751 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1752 ts_params->op_mpool,
1753 ts_params->session_mpool, ts_params->session_priv_mpool,
1754 ts_params->valid_devs[0],
1755 rte_cryptodev_driver_id_get(
1756 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1757 BLKCIPHER_AUTHONLY_TYPE);
1759 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1761 return TEST_SUCCESS;
1765 test_AES_chain_mb_all(void)
1767 struct crypto_testsuite_params *ts_params = &testsuite_params;
1770 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1771 ts_params->op_mpool,
1772 ts_params->session_mpool, ts_params->session_priv_mpool,
1773 ts_params->valid_devs[0],
1774 rte_cryptodev_driver_id_get(
1775 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1776 BLKCIPHER_AES_CHAIN_TYPE);
1778 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1780 return TEST_SUCCESS;
1783 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1786 test_AES_cipheronly_scheduler_all(void)
1788 struct crypto_testsuite_params *ts_params = &testsuite_params;
1791 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1792 ts_params->op_mpool,
1793 ts_params->session_mpool, ts_params->session_priv_mpool,
1794 ts_params->valid_devs[0],
1795 rte_cryptodev_driver_id_get(
1796 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1797 BLKCIPHER_AES_CIPHERONLY_TYPE);
1799 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1801 return TEST_SUCCESS;
1805 test_AES_chain_scheduler_all(void)
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1810 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1811 ts_params->op_mpool,
1812 ts_params->session_mpool, ts_params->session_priv_mpool,
1813 ts_params->valid_devs[0],
1814 rte_cryptodev_driver_id_get(
1815 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1816 BLKCIPHER_AES_CHAIN_TYPE);
1818 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1820 return TEST_SUCCESS;
1824 test_authonly_scheduler_all(void)
1826 struct crypto_testsuite_params *ts_params = &testsuite_params;
1829 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1830 ts_params->op_mpool,
1831 ts_params->session_mpool, ts_params->session_priv_mpool,
1832 ts_params->valid_devs[0],
1833 rte_cryptodev_driver_id_get(
1834 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1835 BLKCIPHER_AUTHONLY_TYPE);
1837 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1839 return TEST_SUCCESS;
1842 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1845 test_AES_chain_openssl_all(void)
1847 struct crypto_testsuite_params *ts_params = &testsuite_params;
1850 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1851 ts_params->op_mpool,
1852 ts_params->session_mpool, ts_params->session_priv_mpool,
1853 ts_params->valid_devs[0],
1854 rte_cryptodev_driver_id_get(
1855 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1856 BLKCIPHER_AES_CHAIN_TYPE);
1858 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1860 return TEST_SUCCESS;
1864 test_AES_cipheronly_openssl_all(void)
1866 struct crypto_testsuite_params *ts_params = &testsuite_params;
1869 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1870 ts_params->op_mpool,
1871 ts_params->session_mpool, ts_params->session_priv_mpool,
1872 ts_params->valid_devs[0],
1873 rte_cryptodev_driver_id_get(
1874 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1875 BLKCIPHER_AES_CIPHERONLY_TYPE);
1877 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1879 return TEST_SUCCESS;
1883 test_AES_chain_ccp_all(void)
1885 struct crypto_testsuite_params *ts_params = &testsuite_params;
1888 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1889 ts_params->op_mpool,
1890 ts_params->session_mpool, ts_params->session_priv_mpool,
1891 ts_params->valid_devs[0],
1892 rte_cryptodev_driver_id_get(
1893 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1894 BLKCIPHER_AES_CHAIN_TYPE);
1896 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1898 return TEST_SUCCESS;
1902 test_AES_cipheronly_ccp_all(void)
1904 struct crypto_testsuite_params *ts_params = &testsuite_params;
1907 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1908 ts_params->op_mpool,
1909 ts_params->session_mpool, ts_params->session_priv_mpool,
1910 ts_params->valid_devs[0],
1911 rte_cryptodev_driver_id_get(
1912 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1913 BLKCIPHER_AES_CIPHERONLY_TYPE);
1915 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1917 return TEST_SUCCESS;
1921 test_AES_chain_qat_all(void)
1923 struct crypto_testsuite_params *ts_params = &testsuite_params;
1926 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1927 ts_params->op_mpool,
1928 ts_params->session_mpool, ts_params->session_priv_mpool,
1929 ts_params->valid_devs[0],
1930 rte_cryptodev_driver_id_get(
1931 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1932 BLKCIPHER_AES_CHAIN_TYPE);
1934 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1936 return TEST_SUCCESS;
1940 test_AES_cipheronly_qat_all(void)
1942 struct crypto_testsuite_params *ts_params = &testsuite_params;
1945 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1946 ts_params->op_mpool,
1947 ts_params->session_mpool, ts_params->session_priv_mpool,
1948 ts_params->valid_devs[0],
1949 rte_cryptodev_driver_id_get(
1950 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1951 BLKCIPHER_AES_CIPHERONLY_TYPE);
1953 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1955 return TEST_SUCCESS;
1959 test_AES_cipheronly_virtio_all(void)
1961 struct crypto_testsuite_params *ts_params = &testsuite_params;
1964 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1965 ts_params->op_mpool,
1966 ts_params->session_mpool, ts_params->session_priv_mpool,
1967 ts_params->valid_devs[0],
1968 rte_cryptodev_driver_id_get(
1969 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1970 BLKCIPHER_AES_CIPHERONLY_TYPE);
1972 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1974 return TEST_SUCCESS;
1978 test_AES_chain_caam_jr_all(void)
1980 struct crypto_testsuite_params *ts_params = &testsuite_params;
1983 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1984 ts_params->op_mpool,
1985 ts_params->session_mpool, ts_params->session_priv_mpool,
1986 ts_params->valid_devs[0],
1987 rte_cryptodev_driver_id_get(
1988 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1989 BLKCIPHER_AES_CHAIN_TYPE);
1991 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1993 return TEST_SUCCESS;
1997 test_AES_cipheronly_caam_jr_all(void)
1999 struct crypto_testsuite_params *ts_params = &testsuite_params;
2002 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2003 ts_params->op_mpool,
2004 ts_params->session_mpool, ts_params->session_priv_mpool,
2005 ts_params->valid_devs[0],
2006 rte_cryptodev_driver_id_get(
2007 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2008 BLKCIPHER_AES_CIPHERONLY_TYPE);
2010 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2012 return TEST_SUCCESS;
2016 test_authonly_caam_jr_all(void)
2018 struct crypto_testsuite_params *ts_params = &testsuite_params;
2021 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2022 ts_params->op_mpool,
2023 ts_params->session_mpool, ts_params->session_priv_mpool,
2024 ts_params->valid_devs[0],
2025 rte_cryptodev_driver_id_get(
2026 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2027 BLKCIPHER_AUTHONLY_TYPE);
2029 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2031 return TEST_SUCCESS;
2036 test_AES_chain_dpaa_sec_all(void)
2038 struct crypto_testsuite_params *ts_params = &testsuite_params;
2041 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2042 ts_params->op_mpool,
2043 ts_params->session_mpool, ts_params->session_priv_mpool,
2044 ts_params->valid_devs[0],
2045 rte_cryptodev_driver_id_get(
2046 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2047 BLKCIPHER_AES_CHAIN_TYPE);
2049 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2051 return TEST_SUCCESS;
2055 test_AES_cipheronly_dpaa_sec_all(void)
2057 struct crypto_testsuite_params *ts_params = &testsuite_params;
2060 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2061 ts_params->op_mpool,
2062 ts_params->session_mpool, ts_params->session_priv_mpool,
2063 ts_params->valid_devs[0],
2064 rte_cryptodev_driver_id_get(
2065 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2066 BLKCIPHER_AES_CIPHERONLY_TYPE);
2068 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2070 return TEST_SUCCESS;
2074 test_authonly_dpaa_sec_all(void)
2076 struct crypto_testsuite_params *ts_params = &testsuite_params;
2079 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2080 ts_params->op_mpool,
2081 ts_params->session_mpool, ts_params->session_priv_mpool,
2082 ts_params->valid_devs[0],
2083 rte_cryptodev_driver_id_get(
2084 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2085 BLKCIPHER_AUTHONLY_TYPE);
2087 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2089 return TEST_SUCCESS;
2093 test_AES_chain_dpaa2_sec_all(void)
2095 struct crypto_testsuite_params *ts_params = &testsuite_params;
2098 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2099 ts_params->op_mpool,
2100 ts_params->session_mpool, ts_params->session_priv_mpool,
2101 ts_params->valid_devs[0],
2102 rte_cryptodev_driver_id_get(
2103 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2104 BLKCIPHER_AES_CHAIN_TYPE);
2106 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2108 return TEST_SUCCESS;
2112 test_AES_cipheronly_dpaa2_sec_all(void)
2114 struct crypto_testsuite_params *ts_params = &testsuite_params;
2117 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2118 ts_params->op_mpool,
2119 ts_params->session_mpool, ts_params->session_priv_mpool,
2120 ts_params->valid_devs[0],
2121 rte_cryptodev_driver_id_get(
2122 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2123 BLKCIPHER_AES_CIPHERONLY_TYPE);
2125 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2127 return TEST_SUCCESS;
2131 test_authonly_dpaa2_sec_all(void)
2133 struct crypto_testsuite_params *ts_params = &testsuite_params;
2136 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2137 ts_params->op_mpool,
2138 ts_params->session_mpool, ts_params->session_priv_mpool,
2139 ts_params->valid_devs[0],
2140 rte_cryptodev_driver_id_get(
2141 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2142 BLKCIPHER_AUTHONLY_TYPE);
2144 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2146 return TEST_SUCCESS;
2150 test_authonly_openssl_all(void)
2152 struct crypto_testsuite_params *ts_params = &testsuite_params;
2155 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2156 ts_params->op_mpool,
2157 ts_params->session_mpool, ts_params->session_priv_mpool,
2158 ts_params->valid_devs[0],
2159 rte_cryptodev_driver_id_get(
2160 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2161 BLKCIPHER_AUTHONLY_TYPE);
2163 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2165 return TEST_SUCCESS;
2169 test_authonly_ccp_all(void)
2171 struct crypto_testsuite_params *ts_params = &testsuite_params;
2174 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2175 ts_params->op_mpool,
2176 ts_params->session_mpool, ts_params->session_priv_mpool,
2177 ts_params->valid_devs[0],
2178 rte_cryptodev_driver_id_get(
2179 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2180 BLKCIPHER_AUTHONLY_TYPE);
2182 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2184 return TEST_SUCCESS;
2188 test_AES_chain_armv8_all(void)
2190 struct crypto_testsuite_params *ts_params = &testsuite_params;
2193 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2194 ts_params->op_mpool,
2195 ts_params->session_mpool, ts_params->session_priv_mpool,
2196 ts_params->valid_devs[0],
2197 rte_cryptodev_driver_id_get(
2198 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2199 BLKCIPHER_AES_CHAIN_TYPE);
2201 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2203 return TEST_SUCCESS;
2207 test_AES_chain_mrvl_all(void)
2209 struct crypto_testsuite_params *ts_params = &testsuite_params;
2212 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2213 ts_params->op_mpool,
2214 ts_params->session_mpool, ts_params->session_priv_mpool,
2215 ts_params->valid_devs[0],
2216 rte_cryptodev_driver_id_get(
2217 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2218 BLKCIPHER_AES_CHAIN_TYPE);
2220 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2222 return TEST_SUCCESS;
2226 test_AES_cipheronly_mrvl_all(void)
2228 struct crypto_testsuite_params *ts_params = &testsuite_params;
2231 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2232 ts_params->op_mpool,
2233 ts_params->session_mpool, ts_params->session_priv_mpool,
2234 ts_params->valid_devs[0],
2235 rte_cryptodev_driver_id_get(
2236 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2237 BLKCIPHER_AES_CIPHERONLY_TYPE);
2239 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2241 return TEST_SUCCESS;
2245 test_authonly_mrvl_all(void)
2247 struct crypto_testsuite_params *ts_params = &testsuite_params;
2250 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2251 ts_params->op_mpool,
2252 ts_params->session_mpool, ts_params->session_priv_mpool,
2253 ts_params->valid_devs[0],
2254 rte_cryptodev_driver_id_get(
2255 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2256 BLKCIPHER_AUTHONLY_TYPE);
2258 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2260 return TEST_SUCCESS;
2264 test_3DES_chain_mrvl_all(void)
2266 struct crypto_testsuite_params *ts_params = &testsuite_params;
2269 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2270 ts_params->op_mpool,
2271 ts_params->session_mpool, ts_params->session_priv_mpool,
2272 ts_params->valid_devs[0],
2273 rte_cryptodev_driver_id_get(
2274 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2275 BLKCIPHER_3DES_CHAIN_TYPE);
2277 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2279 return TEST_SUCCESS;
2283 test_3DES_cipheronly_mrvl_all(void)
2285 struct crypto_testsuite_params *ts_params = &testsuite_params;
2288 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2289 ts_params->op_mpool,
2290 ts_params->session_mpool, ts_params->session_priv_mpool,
2291 ts_params->valid_devs[0],
2292 rte_cryptodev_driver_id_get(
2293 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2294 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2296 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2298 return TEST_SUCCESS;
2302 test_AES_chain_octeontx_all(void)
2304 struct crypto_testsuite_params *ts_params = &testsuite_params;
2307 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2308 ts_params->op_mpool, ts_params->session_mpool,
2309 ts_params->session_priv_mpool,
2310 ts_params->valid_devs[0],
2311 rte_cryptodev_driver_id_get(
2312 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2313 BLKCIPHER_AES_CHAIN_TYPE);
2315 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2317 return TEST_SUCCESS;
2321 test_AES_cipheronly_octeontx_all(void)
2323 struct crypto_testsuite_params *ts_params = &testsuite_params;
2326 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2327 ts_params->op_mpool, ts_params->session_mpool,
2328 ts_params->session_priv_mpool,
2329 ts_params->valid_devs[0],
2330 rte_cryptodev_driver_id_get(
2331 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2332 BLKCIPHER_AES_CIPHERONLY_TYPE);
2334 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2336 return TEST_SUCCESS;
2340 test_3DES_chain_octeontx_all(void)
2342 struct crypto_testsuite_params *ts_params = &testsuite_params;
2345 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2346 ts_params->op_mpool, ts_params->session_mpool,
2347 ts_params->session_priv_mpool,
2348 ts_params->valid_devs[0],
2349 rte_cryptodev_driver_id_get(
2350 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2351 BLKCIPHER_3DES_CHAIN_TYPE);
2353 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2355 return TEST_SUCCESS;
2359 test_AES_chain_nitrox_all(void)
2361 struct crypto_testsuite_params *ts_params = &testsuite_params;
2364 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2365 ts_params->op_mpool,
2366 ts_params->session_mpool, ts_params->session_priv_mpool,
2367 ts_params->valid_devs[0],
2368 rte_cryptodev_driver_id_get(
2369 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2370 BLKCIPHER_AES_CHAIN_TYPE);
2372 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2374 return TEST_SUCCESS;
2378 test_3DES_cipheronly_octeontx_all(void)
2380 struct crypto_testsuite_params *ts_params = &testsuite_params;
2383 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2384 ts_params->op_mpool, ts_params->session_mpool,
2385 ts_params->session_priv_mpool,
2386 ts_params->valid_devs[0],
2387 rte_cryptodev_driver_id_get(
2388 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2389 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2391 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2393 return TEST_SUCCESS;
2397 test_authonly_octeontx_all(void)
2399 struct crypto_testsuite_params *ts_params = &testsuite_params;
2402 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2403 ts_params->op_mpool, ts_params->session_mpool,
2404 ts_params->session_priv_mpool,
2405 ts_params->valid_devs[0],
2406 rte_cryptodev_driver_id_get(
2407 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2408 BLKCIPHER_AUTHONLY_TYPE);
2410 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2412 return TEST_SUCCESS;
2416 test_AES_chain_octeontx2_all(void)
2418 struct crypto_testsuite_params *ts_params = &testsuite_params;
2421 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2422 ts_params->op_mpool, ts_params->session_mpool,
2423 ts_params->session_priv_mpool,
2424 ts_params->valid_devs[0],
2425 rte_cryptodev_driver_id_get(
2426 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2427 BLKCIPHER_AES_CHAIN_TYPE);
2429 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2431 return TEST_SUCCESS;
2435 test_AES_cipheronly_octeontx2_all(void)
2437 struct crypto_testsuite_params *ts_params = &testsuite_params;
2440 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2441 ts_params->op_mpool, ts_params->session_mpool,
2442 ts_params->session_priv_mpool,
2443 ts_params->valid_devs[0],
2444 rte_cryptodev_driver_id_get(
2445 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2446 BLKCIPHER_AES_CIPHERONLY_TYPE);
2448 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2450 return TEST_SUCCESS;
2454 test_3DES_chain_octeontx2_all(void)
2456 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2460 ts_params->op_mpool, ts_params->session_mpool,
2461 ts_params->session_priv_mpool,
2462 ts_params->valid_devs[0],
2463 rte_cryptodev_driver_id_get(
2464 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2465 BLKCIPHER_3DES_CHAIN_TYPE);
2467 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2469 return TEST_SUCCESS;
2473 test_3DES_cipheronly_octeontx2_all(void)
2475 struct crypto_testsuite_params *ts_params = &testsuite_params;
2478 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2479 ts_params->op_mpool, ts_params->session_mpool,
2480 ts_params->session_priv_mpool,
2481 ts_params->valid_devs[0],
2482 rte_cryptodev_driver_id_get(
2483 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2484 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2486 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2488 return TEST_SUCCESS;
2492 test_authonly_octeontx2_all(void)
2494 struct crypto_testsuite_params *ts_params = &testsuite_params;
2497 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2498 ts_params->op_mpool, ts_params->session_mpool,
2499 ts_params->session_priv_mpool,
2500 ts_params->valid_devs[0],
2501 rte_cryptodev_driver_id_get(
2502 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2503 BLKCIPHER_AUTHONLY_TYPE);
2505 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2507 return TEST_SUCCESS;
2510 /* ***** SNOW 3G Tests ***** */
2512 create_wireless_algo_hash_session(uint8_t dev_id,
2513 const uint8_t *key, const uint8_t key_len,
2514 const uint8_t iv_len, const uint8_t auth_len,
2515 enum rte_crypto_auth_operation op,
2516 enum rte_crypto_auth_algorithm algo)
2518 uint8_t hash_key[key_len];
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2524 memcpy(hash_key, key, key_len);
2526 debug_hexdump(stdout, "key:", key, key_len);
2528 /* Setup Authentication Parameters */
2529 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2530 ut_params->auth_xform.next = NULL;
2532 ut_params->auth_xform.auth.op = op;
2533 ut_params->auth_xform.auth.algo = algo;
2534 ut_params->auth_xform.auth.key.length = key_len;
2535 ut_params->auth_xform.auth.key.data = hash_key;
2536 ut_params->auth_xform.auth.digest_length = auth_len;
2537 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2538 ut_params->auth_xform.auth.iv.length = iv_len;
2539 ut_params->sess = rte_cryptodev_sym_session_create(
2540 ts_params->session_mpool);
2542 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2543 &ut_params->auth_xform,
2544 ts_params->session_priv_mpool);
2545 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2546 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2551 create_wireless_algo_cipher_session(uint8_t dev_id,
2552 enum rte_crypto_cipher_operation op,
2553 enum rte_crypto_cipher_algorithm algo,
2554 const uint8_t *key, const uint8_t key_len,
2557 uint8_t cipher_key[key_len];
2559 struct crypto_testsuite_params *ts_params = &testsuite_params;
2560 struct crypto_unittest_params *ut_params = &unittest_params;
2562 memcpy(cipher_key, key, key_len);
2564 /* Setup Cipher Parameters */
2565 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2566 ut_params->cipher_xform.next = NULL;
2568 ut_params->cipher_xform.cipher.algo = algo;
2569 ut_params->cipher_xform.cipher.op = op;
2570 ut_params->cipher_xform.cipher.key.data = cipher_key;
2571 ut_params->cipher_xform.cipher.key.length = key_len;
2572 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2573 ut_params->cipher_xform.cipher.iv.length = iv_len;
2575 debug_hexdump(stdout, "key:", key, key_len);
2577 /* Create Crypto session */
2578 ut_params->sess = rte_cryptodev_sym_session_create(
2579 ts_params->session_mpool);
2581 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2582 &ut_params->cipher_xform,
2583 ts_params->session_priv_mpool);
2584 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2585 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2590 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2591 unsigned int cipher_len,
2592 unsigned int cipher_offset)
2594 struct crypto_testsuite_params *ts_params = &testsuite_params;
2595 struct crypto_unittest_params *ut_params = &unittest_params;
2597 /* Generate Crypto op data structure */
2598 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2599 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2600 TEST_ASSERT_NOT_NULL(ut_params->op,
2601 "Failed to allocate pktmbuf offload");
2603 /* Set crypto operation data parameters */
2604 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2606 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2608 /* set crypto operation source mbuf */
2609 sym_op->m_src = ut_params->ibuf;
2612 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2614 sym_op->cipher.data.length = cipher_len;
2615 sym_op->cipher.data.offset = cipher_offset;
2620 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2621 unsigned int cipher_len,
2622 unsigned int cipher_offset)
2624 struct crypto_testsuite_params *ts_params = &testsuite_params;
2625 struct crypto_unittest_params *ut_params = &unittest_params;
2627 /* Generate Crypto op data structure */
2628 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2629 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2630 TEST_ASSERT_NOT_NULL(ut_params->op,
2631 "Failed to allocate pktmbuf offload");
2633 /* Set crypto operation data parameters */
2634 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2636 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2638 /* set crypto operation source mbuf */
2639 sym_op->m_src = ut_params->ibuf;
2640 sym_op->m_dst = ut_params->obuf;
2643 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2645 sym_op->cipher.data.length = cipher_len;
2646 sym_op->cipher.data.offset = cipher_offset;
2651 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2652 enum rte_crypto_cipher_operation cipher_op,
2653 enum rte_crypto_auth_operation auth_op,
2654 enum rte_crypto_auth_algorithm auth_algo,
2655 enum rte_crypto_cipher_algorithm cipher_algo,
2656 const uint8_t *key, uint8_t key_len,
2657 uint8_t auth_iv_len, uint8_t auth_len,
2658 uint8_t cipher_iv_len)
2661 uint8_t cipher_auth_key[key_len];
2664 struct crypto_testsuite_params *ts_params = &testsuite_params;
2665 struct crypto_unittest_params *ut_params = &unittest_params;
2667 memcpy(cipher_auth_key, key, key_len);
2669 /* Setup Authentication Parameters */
2670 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2671 ut_params->auth_xform.next = NULL;
2673 ut_params->auth_xform.auth.op = auth_op;
2674 ut_params->auth_xform.auth.algo = auth_algo;
2675 ut_params->auth_xform.auth.key.length = key_len;
2676 /* Hash key = cipher key */
2677 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2678 ut_params->auth_xform.auth.digest_length = auth_len;
2679 /* Auth IV will be after cipher IV */
2680 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2681 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2683 /* Setup Cipher Parameters */
2684 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2685 ut_params->cipher_xform.next = &ut_params->auth_xform;
2687 ut_params->cipher_xform.cipher.algo = cipher_algo;
2688 ut_params->cipher_xform.cipher.op = cipher_op;
2689 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2690 ut_params->cipher_xform.cipher.key.length = key_len;
2691 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2692 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2694 debug_hexdump(stdout, "key:", key, key_len);
2696 /* Create Crypto session*/
2697 ut_params->sess = rte_cryptodev_sym_session_create(
2698 ts_params->session_mpool);
2700 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2701 &ut_params->cipher_xform,
2702 ts_params->session_priv_mpool);
2704 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2705 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2710 create_wireless_cipher_auth_session(uint8_t dev_id,
2711 enum rte_crypto_cipher_operation cipher_op,
2712 enum rte_crypto_auth_operation auth_op,
2713 enum rte_crypto_auth_algorithm auth_algo,
2714 enum rte_crypto_cipher_algorithm cipher_algo,
2715 const struct wireless_test_data *tdata)
2717 const uint8_t key_len = tdata->key.len;
2718 uint8_t cipher_auth_key[key_len];
2721 struct crypto_testsuite_params *ts_params = &testsuite_params;
2722 struct crypto_unittest_params *ut_params = &unittest_params;
2723 const uint8_t *key = tdata->key.data;
2724 const uint8_t auth_len = tdata->digest.len;
2725 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2726 uint8_t auth_iv_len = tdata->auth_iv.len;
2728 memcpy(cipher_auth_key, key, key_len);
2730 /* Setup Authentication Parameters */
2731 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2732 ut_params->auth_xform.next = NULL;
2734 ut_params->auth_xform.auth.op = auth_op;
2735 ut_params->auth_xform.auth.algo = auth_algo;
2736 ut_params->auth_xform.auth.key.length = key_len;
2737 /* Hash key = cipher key */
2738 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2739 ut_params->auth_xform.auth.digest_length = auth_len;
2740 /* Auth IV will be after cipher IV */
2741 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2742 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2744 /* Setup Cipher Parameters */
2745 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2746 ut_params->cipher_xform.next = &ut_params->auth_xform;
2748 ut_params->cipher_xform.cipher.algo = cipher_algo;
2749 ut_params->cipher_xform.cipher.op = cipher_op;
2750 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2751 ut_params->cipher_xform.cipher.key.length = key_len;
2752 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2753 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2756 debug_hexdump(stdout, "key:", key, key_len);
2758 /* Create Crypto session*/
2759 ut_params->sess = rte_cryptodev_sym_session_create(
2760 ts_params->session_mpool);
2762 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2763 &ut_params->cipher_xform,
2764 ts_params->session_priv_mpool);
2766 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2767 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2772 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2773 const struct wireless_test_data *tdata)
2775 return create_wireless_cipher_auth_session(dev_id,
2776 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2777 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2778 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2782 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2783 enum rte_crypto_cipher_operation cipher_op,
2784 enum rte_crypto_auth_operation auth_op,
2785 enum rte_crypto_auth_algorithm auth_algo,
2786 enum rte_crypto_cipher_algorithm cipher_algo,
2787 const uint8_t *key, const uint8_t key_len,
2788 uint8_t auth_iv_len, uint8_t auth_len,
2789 uint8_t cipher_iv_len)
2791 uint8_t auth_cipher_key[key_len];
2793 struct crypto_testsuite_params *ts_params = &testsuite_params;
2794 struct crypto_unittest_params *ut_params = &unittest_params;
2796 memcpy(auth_cipher_key, key, key_len);
2798 /* Setup Authentication Parameters */
2799 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2800 ut_params->auth_xform.auth.op = auth_op;
2801 ut_params->auth_xform.next = &ut_params->cipher_xform;
2802 ut_params->auth_xform.auth.algo = auth_algo;
2803 ut_params->auth_xform.auth.key.length = key_len;
2804 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2805 ut_params->auth_xform.auth.digest_length = auth_len;
2806 /* Auth IV will be after cipher IV */
2807 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2808 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2810 /* Setup Cipher Parameters */
2811 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2812 ut_params->cipher_xform.next = NULL;
2813 ut_params->cipher_xform.cipher.algo = cipher_algo;
2814 ut_params->cipher_xform.cipher.op = cipher_op;
2815 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2816 ut_params->cipher_xform.cipher.key.length = key_len;
2817 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2818 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2820 debug_hexdump(stdout, "key:", key, key_len);
2822 /* Create Crypto session*/
2823 ut_params->sess = rte_cryptodev_sym_session_create(
2824 ts_params->session_mpool);
2826 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2827 &ut_params->auth_xform,
2828 ts_params->session_priv_mpool);
2829 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2830 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2836 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2837 unsigned int auth_tag_len,
2838 const uint8_t *iv, unsigned int iv_len,
2839 unsigned int data_pad_len,
2840 enum rte_crypto_auth_operation op,
2841 unsigned int auth_len, unsigned int auth_offset)
2843 struct crypto_testsuite_params *ts_params = &testsuite_params;
2845 struct crypto_unittest_params *ut_params = &unittest_params;
2847 /* Generate Crypto op data structure */
2848 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2849 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2850 TEST_ASSERT_NOT_NULL(ut_params->op,
2851 "Failed to allocate pktmbuf offload");
2853 /* Set crypto operation data parameters */
2854 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2856 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2858 /* set crypto operation source mbuf */
2859 sym_op->m_src = ut_params->ibuf;
2862 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2865 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2866 ut_params->ibuf, auth_tag_len);
2868 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2869 "no room to append auth tag");
2870 ut_params->digest = sym_op->auth.digest.data;
2871 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2872 ut_params->ibuf, data_pad_len);
2873 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2874 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2876 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2878 debug_hexdump(stdout, "digest:",
2879 sym_op->auth.digest.data,
2882 sym_op->auth.data.length = auth_len;
2883 sym_op->auth.data.offset = auth_offset;
2889 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2890 enum rte_crypto_auth_operation op)
2892 struct crypto_testsuite_params *ts_params = &testsuite_params;
2893 struct crypto_unittest_params *ut_params = &unittest_params;
2895 const uint8_t *auth_tag = tdata->digest.data;
2896 const unsigned int auth_tag_len = tdata->digest.len;
2897 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2898 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2900 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2901 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2902 const uint8_t *auth_iv = tdata->auth_iv.data;
2903 const uint8_t auth_iv_len = tdata->auth_iv.len;
2904 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2905 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2907 /* Generate Crypto op data structure */
2908 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2909 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2910 TEST_ASSERT_NOT_NULL(ut_params->op,
2911 "Failed to allocate pktmbuf offload");
2912 /* Set crypto operation data parameters */
2913 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2915 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2917 /* set crypto operation source mbuf */
2918 sym_op->m_src = ut_params->ibuf;
2921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2922 ut_params->ibuf, auth_tag_len);
2924 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2925 "no room to append auth tag");
2926 ut_params->digest = sym_op->auth.digest.data;
2927 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2928 ut_params->ibuf, data_pad_len);
2929 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2930 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2932 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2934 debug_hexdump(stdout, "digest:",
2935 sym_op->auth.digest.data,
2938 /* Copy cipher and auth IVs at the end of the crypto operation */
2939 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2941 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2942 iv_ptr += cipher_iv_len;
2943 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2945 sym_op->cipher.data.length = cipher_len;
2946 sym_op->cipher.data.offset = 0;
2947 sym_op->auth.data.length = auth_len;
2948 sym_op->auth.data.offset = 0;
2954 create_zuc_cipher_hash_generate_operation(
2955 const struct wireless_test_data *tdata)
2957 return create_wireless_cipher_hash_operation(tdata,
2958 RTE_CRYPTO_AUTH_OP_GENERATE);
2962 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2963 const unsigned auth_tag_len,
2964 const uint8_t *auth_iv, uint8_t auth_iv_len,
2965 unsigned data_pad_len,
2966 enum rte_crypto_auth_operation op,
2967 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2968 const unsigned cipher_len, const unsigned cipher_offset,
2969 const unsigned auth_len, const unsigned auth_offset)
2971 struct crypto_testsuite_params *ts_params = &testsuite_params;
2972 struct crypto_unittest_params *ut_params = &unittest_params;
2974 /* Generate Crypto op data structure */
2975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2976 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2977 TEST_ASSERT_NOT_NULL(ut_params->op,
2978 "Failed to allocate pktmbuf offload");
2979 /* Set crypto operation data parameters */
2980 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2982 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2984 /* set crypto operation source mbuf */
2985 sym_op->m_src = ut_params->ibuf;
2988 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2989 ut_params->ibuf, auth_tag_len);
2991 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2992 "no room to append auth tag");
2993 ut_params->digest = sym_op->auth.digest.data;
2994 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2995 ut_params->ibuf, data_pad_len);
2996 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2997 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2999 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3001 debug_hexdump(stdout, "digest:",
3002 sym_op->auth.digest.data,
3005 /* Copy cipher and auth IVs at the end of the crypto operation */
3006 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3008 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3009 iv_ptr += cipher_iv_len;
3010 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3012 sym_op->cipher.data.length = cipher_len;
3013 sym_op->cipher.data.offset = cipher_offset;
3014 sym_op->auth.data.length = auth_len;
3015 sym_op->auth.data.offset = auth_offset;
3021 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
3022 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3023 const uint8_t *auth_iv, uint8_t auth_iv_len,
3024 unsigned int data_pad_len,
3025 unsigned int cipher_len, unsigned int cipher_offset,
3026 unsigned int auth_len, unsigned int auth_offset,
3027 uint8_t op_mode, uint8_t do_sgl)
3029 struct crypto_testsuite_params *ts_params = &testsuite_params;
3030 struct crypto_unittest_params *ut_params = &unittest_params;
3032 enum rte_crypto_cipher_algorithm cipher_algo =
3033 ut_params->cipher_xform.cipher.algo;
3034 enum rte_crypto_auth_algorithm auth_algo =
3035 ut_params->auth_xform.auth.algo;
3037 /* Generate Crypto op data structure */
3038 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3039 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3040 TEST_ASSERT_NOT_NULL(ut_params->op,
3041 "Failed to allocate pktmbuf offload");
3043 /* Set crypto operation data parameters */
3044 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3046 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3048 /* set crypto operation mbufs */
3049 sym_op->m_src = ut_params->ibuf;
3050 if (op_mode == OUT_OF_PLACE)
3051 sym_op->m_dst = ut_params->obuf;
3055 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3056 (op_mode == IN_PLACE ?
3057 ut_params->ibuf : ut_params->obuf),
3058 uint8_t *, data_pad_len);
3059 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3060 (op_mode == IN_PLACE ?
3061 ut_params->ibuf : ut_params->obuf),
3063 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3065 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3066 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3067 sym_op->m_src : sym_op->m_dst);
3068 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3069 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3070 sgl_buf = sgl_buf->next;
3072 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3073 uint8_t *, remaining_off);
3074 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3076 memset(sym_op->auth.digest.data, 0, remaining_off);
3077 while (sgl_buf->next != NULL) {
3078 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3079 0, rte_pktmbuf_data_len(sgl_buf));
3080 sgl_buf = sgl_buf->next;
3084 /* Copy cipher and auth IVs at the end of the crypto operation */
3085 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3086 ut_params->op, uint8_t *, IV_OFFSET);
3088 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3089 iv_ptr += cipher_iv_len;
3090 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3092 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3093 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3094 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3095 sym_op->cipher.data.length = cipher_len;
3096 sym_op->cipher.data.offset = cipher_offset;
3098 sym_op->cipher.data.length = cipher_len >> 3;
3099 sym_op->cipher.data.offset = cipher_offset >> 3;
3102 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3103 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3104 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3105 sym_op->auth.data.length = auth_len;
3106 sym_op->auth.data.offset = auth_offset;
3108 sym_op->auth.data.length = auth_len >> 3;
3109 sym_op->auth.data.offset = auth_offset >> 3;
3116 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3118 struct crypto_testsuite_params *ts_params = &testsuite_params;
3119 struct crypto_unittest_params *ut_params = &unittest_params;
3122 unsigned plaintext_pad_len;
3123 unsigned plaintext_len;
3126 /* Create SNOW 3G session */
3127 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3128 tdata->key.data, tdata->key.len,
3129 tdata->auth_iv.len, tdata->digest.len,
3130 RTE_CRYPTO_AUTH_OP_GENERATE,
3131 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3135 /* alloc mbuf and set payload */
3136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3139 rte_pktmbuf_tailroom(ut_params->ibuf));
3141 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3142 /* Append data which is padded to a multiple of */
3143 /* the algorithms block size */
3144 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3145 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3147 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3149 /* Create SNOW 3G operation */
3150 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3151 tdata->auth_iv.data, tdata->auth_iv.len,
3152 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3153 tdata->validAuthLenInBits.len,
3158 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3160 ut_params->obuf = ut_params->op->sym->m_src;
3161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3162 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3163 + plaintext_pad_len;
3166 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3169 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3170 "SNOW 3G Generated auth tag not as expected");
3176 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3178 struct crypto_testsuite_params *ts_params = &testsuite_params;
3179 struct crypto_unittest_params *ut_params = &unittest_params;
3182 unsigned plaintext_pad_len;
3183 unsigned plaintext_len;
3186 /* Create SNOW 3G session */
3187 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3188 tdata->key.data, tdata->key.len,
3189 tdata->auth_iv.len, tdata->digest.len,
3190 RTE_CRYPTO_AUTH_OP_VERIFY,
3191 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3194 /* alloc mbuf and set payload */
3195 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3197 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3198 rte_pktmbuf_tailroom(ut_params->ibuf));
3200 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3201 /* Append data which is padded to a multiple of */
3202 /* the algorithms block size */
3203 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3204 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3206 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3208 /* Create SNOW 3G operation */
3209 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3211 tdata->auth_iv.data, tdata->auth_iv.len,
3213 RTE_CRYPTO_AUTH_OP_VERIFY,
3214 tdata->validAuthLenInBits.len,
3219 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3222 ut_params->obuf = ut_params->op->sym->m_src;
3223 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3224 + plaintext_pad_len;
3227 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3236 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3238 struct crypto_testsuite_params *ts_params = &testsuite_params;
3239 struct crypto_unittest_params *ut_params = &unittest_params;
3242 unsigned plaintext_pad_len;
3243 unsigned plaintext_len;
3246 /* Create KASUMI session */
3247 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3248 tdata->key.data, tdata->key.len,
3249 0, tdata->digest.len,
3250 RTE_CRYPTO_AUTH_OP_GENERATE,
3251 RTE_CRYPTO_AUTH_KASUMI_F9);
3255 /* alloc mbuf and set payload */
3256 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3258 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3259 rte_pktmbuf_tailroom(ut_params->ibuf));
3261 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3262 /* Append data which is padded to a multiple of */
3263 /* the algorithms block size */
3264 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3265 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3267 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3269 /* Create KASUMI operation */
3270 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3272 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3273 tdata->plaintext.len,
3278 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3280 ut_params->obuf = ut_params->op->sym->m_src;
3281 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3282 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3283 + plaintext_pad_len;
3286 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3289 DIGEST_BYTE_LENGTH_KASUMI_F9,
3290 "KASUMI Generated auth tag not as expected");
3296 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3298 struct crypto_testsuite_params *ts_params = &testsuite_params;
3299 struct crypto_unittest_params *ut_params = &unittest_params;
3302 unsigned plaintext_pad_len;
3303 unsigned plaintext_len;
3306 /* Create KASUMI session */
3307 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3308 tdata->key.data, tdata->key.len,
3309 0, tdata->digest.len,
3310 RTE_CRYPTO_AUTH_OP_VERIFY,
3311 RTE_CRYPTO_AUTH_KASUMI_F9);
3314 /* alloc mbuf and set payload */
3315 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3317 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3318 rte_pktmbuf_tailroom(ut_params->ibuf));
3320 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3321 /* Append data which is padded to a multiple */
3322 /* of the algorithms block size */
3323 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3324 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3326 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3328 /* Create KASUMI operation */
3329 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3333 RTE_CRYPTO_AUTH_OP_VERIFY,
3334 tdata->plaintext.len,
3339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3342 ut_params->obuf = ut_params->op->sym->m_src;
3343 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3344 + plaintext_pad_len;
3347 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3356 test_snow3g_hash_generate_test_case_1(void)
3358 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3362 test_snow3g_hash_generate_test_case_2(void)
3364 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3368 test_snow3g_hash_generate_test_case_3(void)
3370 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3374 test_snow3g_hash_generate_test_case_4(void)
3376 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3380 test_snow3g_hash_generate_test_case_5(void)
3382 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3386 test_snow3g_hash_generate_test_case_6(void)
3388 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3392 test_snow3g_hash_verify_test_case_1(void)
3394 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3399 test_snow3g_hash_verify_test_case_2(void)
3401 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3405 test_snow3g_hash_verify_test_case_3(void)
3407 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3411 test_snow3g_hash_verify_test_case_4(void)
3413 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3417 test_snow3g_hash_verify_test_case_5(void)
3419 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3423 test_snow3g_hash_verify_test_case_6(void)
3425 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3429 test_kasumi_hash_generate_test_case_1(void)
3431 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3435 test_kasumi_hash_generate_test_case_2(void)
3437 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3441 test_kasumi_hash_generate_test_case_3(void)
3443 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3447 test_kasumi_hash_generate_test_case_4(void)
3449 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3453 test_kasumi_hash_generate_test_case_5(void)
3455 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3459 test_kasumi_hash_generate_test_case_6(void)
3461 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3465 test_kasumi_hash_verify_test_case_1(void)
3467 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3471 test_kasumi_hash_verify_test_case_2(void)
3473 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3477 test_kasumi_hash_verify_test_case_3(void)
3479 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3483 test_kasumi_hash_verify_test_case_4(void)
3485 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3489 test_kasumi_hash_verify_test_case_5(void)
3491 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3495 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3497 struct crypto_testsuite_params *ts_params = &testsuite_params;
3498 struct crypto_unittest_params *ut_params = &unittest_params;
3501 uint8_t *plaintext, *ciphertext;
3502 unsigned plaintext_pad_len;
3503 unsigned plaintext_len;
3505 /* Create KASUMI session */
3506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3508 RTE_CRYPTO_CIPHER_KASUMI_F8,
3509 tdata->key.data, tdata->key.len,
3510 tdata->cipher_iv.len);
3514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3516 /* Clear mbuf payload */
3517 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3518 rte_pktmbuf_tailroom(ut_params->ibuf));
3520 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3521 /* Append data which is padded to a multiple */
3522 /* of the algorithms block size */
3523 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3524 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3526 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3528 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3530 /* Create KASUMI operation */
3531 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3532 tdata->cipher_iv.len,
3533 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3534 tdata->validCipherOffsetInBits.len);
3538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3542 ut_params->obuf = ut_params->op->sym->m_dst;
3543 if (ut_params->obuf)
3544 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3546 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3548 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3550 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3551 (tdata->validCipherOffsetInBits.len >> 3);
3553 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3555 reference_ciphertext,
3556 tdata->validCipherLenInBits.len,
3557 "KASUMI Ciphertext data not as expected");
3562 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3564 struct crypto_testsuite_params *ts_params = &testsuite_params;
3565 struct crypto_unittest_params *ut_params = &unittest_params;
3569 unsigned int plaintext_pad_len;
3570 unsigned int plaintext_len;
3572 uint8_t buffer[10000];
3573 const uint8_t *ciphertext;
3575 struct rte_cryptodev_info dev_info;
3577 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3579 uint64_t feat_flags = dev_info.feature_flags;
3581 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3582 printf("Device doesn't support in-place scatter-gather. "
3587 /* Create KASUMI session */
3588 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3589 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3590 RTE_CRYPTO_CIPHER_KASUMI_F8,
3591 tdata->key.data, tdata->key.len,
3592 tdata->cipher_iv.len);
3596 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3599 /* Append data which is padded to a multiple */
3600 /* of the algorithms block size */
3601 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3603 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3604 plaintext_pad_len, 10, 0);
3606 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3608 /* Create KASUMI operation */
3609 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3610 tdata->cipher_iv.len,
3611 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3612 tdata->validCipherOffsetInBits.len);
3616 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3618 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3620 ut_params->obuf = ut_params->op->sym->m_dst;
3622 if (ut_params->obuf)
3623 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3624 plaintext_len, buffer);
3626 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3627 tdata->validCipherOffsetInBits.len >> 3,
3628 plaintext_len, buffer);
3631 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3633 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3634 (tdata->validCipherOffsetInBits.len >> 3);
3636 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3638 reference_ciphertext,
3639 tdata->validCipherLenInBits.len,
3640 "KASUMI Ciphertext data not as expected");
3645 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3647 struct crypto_testsuite_params *ts_params = &testsuite_params;
3648 struct crypto_unittest_params *ut_params = &unittest_params;
3651 uint8_t *plaintext, *ciphertext;
3652 unsigned plaintext_pad_len;
3653 unsigned plaintext_len;
3655 /* Create KASUMI session */
3656 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3657 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3658 RTE_CRYPTO_CIPHER_KASUMI_F8,
3659 tdata->key.data, tdata->key.len,
3660 tdata->cipher_iv.len);
3664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3665 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3667 /* Clear mbuf payload */
3668 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3669 rte_pktmbuf_tailroom(ut_params->ibuf));
3671 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3672 /* Append data which is padded to a multiple */
3673 /* of the algorithms block size */
3674 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3675 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3677 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3678 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3680 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3682 /* Create KASUMI operation */
3683 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3684 tdata->cipher_iv.len,
3685 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3686 tdata->validCipherOffsetInBits.len);
3690 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3692 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3694 ut_params->obuf = ut_params->op->sym->m_dst;
3695 if (ut_params->obuf)
3696 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3698 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3700 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3702 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3703 (tdata->validCipherOffsetInBits.len >> 3);
3705 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3707 reference_ciphertext,
3708 tdata->validCipherLenInBits.len,
3709 "KASUMI Ciphertext data not as expected");
3714 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3716 struct crypto_testsuite_params *ts_params = &testsuite_params;
3717 struct crypto_unittest_params *ut_params = &unittest_params;
3720 unsigned int plaintext_pad_len;
3721 unsigned int plaintext_len;
3723 const uint8_t *ciphertext;
3724 uint8_t buffer[2048];
3726 struct rte_cryptodev_info dev_info;
3728 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3730 uint64_t feat_flags = dev_info.feature_flags;
3731 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3732 printf("Device doesn't support out-of-place scatter-gather "
3733 "in both input and output mbufs. "
3738 /* Create KASUMI session */
3739 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3740 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3741 RTE_CRYPTO_CIPHER_KASUMI_F8,
3742 tdata->key.data, tdata->key.len,
3743 tdata->cipher_iv.len);
3747 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3748 /* Append data which is padded to a multiple */
3749 /* of the algorithms block size */
3750 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3752 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3753 plaintext_pad_len, 10, 0);
3754 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3755 plaintext_pad_len, 3, 0);
3757 /* Append data which is padded to a multiple */
3758 /* of the algorithms block size */
3759 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3761 /* Create KASUMI operation */
3762 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3763 tdata->cipher_iv.len,
3764 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3765 tdata->validCipherOffsetInBits.len);
3769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3774 if (ut_params->obuf)
3775 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3776 plaintext_pad_len, buffer);
3778 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3779 tdata->validCipherOffsetInBits.len >> 3,
3780 plaintext_pad_len, buffer);
3782 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3783 (tdata->validCipherOffsetInBits.len >> 3);
3785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3787 reference_ciphertext,
3788 tdata->validCipherLenInBits.len,
3789 "KASUMI Ciphertext data not as expected");
3795 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3797 struct crypto_testsuite_params *ts_params = &testsuite_params;
3798 struct crypto_unittest_params *ut_params = &unittest_params;
3801 uint8_t *ciphertext, *plaintext;
3802 unsigned ciphertext_pad_len;
3803 unsigned ciphertext_len;
3805 /* Create KASUMI session */
3806 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3807 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3808 RTE_CRYPTO_CIPHER_KASUMI_F8,
3809 tdata->key.data, tdata->key.len,
3810 tdata->cipher_iv.len);
3814 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3815 ut_params->obuf = 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 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3822 /* Append data which is padded to a multiple */
3823 /* of the algorithms block size */
3824 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3825 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3826 ciphertext_pad_len);
3827 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3828 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3830 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3832 /* Create KASUMI operation */
3833 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3834 tdata->cipher_iv.len,
3835 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3836 tdata->validCipherOffsetInBits.len);
3840 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3842 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3844 ut_params->obuf = ut_params->op->sym->m_dst;
3845 if (ut_params->obuf)
3846 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3848 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3850 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3852 const uint8_t *reference_plaintext = tdata->plaintext.data +
3853 (tdata->validCipherOffsetInBits.len >> 3);
3855 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3857 reference_plaintext,
3858 tdata->validCipherLenInBits.len,
3859 "KASUMI Plaintext data not as expected");
3864 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3866 struct crypto_testsuite_params *ts_params = &testsuite_params;
3867 struct crypto_unittest_params *ut_params = &unittest_params;
3870 uint8_t *ciphertext, *plaintext;
3871 unsigned ciphertext_pad_len;
3872 unsigned ciphertext_len;
3874 /* Create KASUMI session */
3875 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3876 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3877 RTE_CRYPTO_CIPHER_KASUMI_F8,
3878 tdata->key.data, tdata->key.len,
3879 tdata->cipher_iv.len);
3883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3885 /* Clear mbuf payload */
3886 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3887 rte_pktmbuf_tailroom(ut_params->ibuf));
3889 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3890 /* Append data which is padded to a multiple */
3891 /* of the algorithms block size */
3892 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3893 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3894 ciphertext_pad_len);
3895 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3897 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3899 /* Create KASUMI operation */
3900 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3901 tdata->cipher_iv.len,
3902 tdata->ciphertext.len,
3903 tdata->validCipherOffsetInBits.len);
3907 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3909 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3911 ut_params->obuf = ut_params->op->sym->m_dst;
3912 if (ut_params->obuf)
3913 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3915 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3917 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3919 const uint8_t *reference_plaintext = tdata->plaintext.data +
3920 (tdata->validCipherOffsetInBits.len >> 3);
3922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3924 reference_plaintext,
3925 tdata->validCipherLenInBits.len,
3926 "KASUMI Plaintext data not as expected");
3931 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3933 struct crypto_testsuite_params *ts_params = &testsuite_params;
3934 struct crypto_unittest_params *ut_params = &unittest_params;
3937 uint8_t *plaintext, *ciphertext;
3938 unsigned plaintext_pad_len;
3939 unsigned plaintext_len;
3941 /* Create SNOW 3G session */
3942 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3943 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3944 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3945 tdata->key.data, tdata->key.len,
3946 tdata->cipher_iv.len);
3950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3952 /* Clear mbuf payload */
3953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 rte_pktmbuf_tailroom(ut_params->ibuf));
3956 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3957 /* Append data which is padded to a multiple of */
3958 /* the algorithms block size */
3959 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3960 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3964 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3966 /* Create SNOW 3G operation */
3967 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3968 tdata->cipher_iv.len,
3969 tdata->validCipherLenInBits.len,
3974 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3978 ut_params->obuf = ut_params->op->sym->m_dst;
3979 if (ut_params->obuf)
3980 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3982 ciphertext = plaintext;
3984 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3989 tdata->ciphertext.data,
3990 tdata->validDataLenInBits.len,
3991 "SNOW 3G Ciphertext data not as expected");
3997 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3999 struct crypto_testsuite_params *ts_params = &testsuite_params;
4000 struct crypto_unittest_params *ut_params = &unittest_params;
4001 uint8_t *plaintext, *ciphertext;
4004 unsigned plaintext_pad_len;
4005 unsigned plaintext_len;
4007 /* Create SNOW 3G session */
4008 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4009 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4010 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4011 tdata->key.data, tdata->key.len,
4012 tdata->cipher_iv.len);
4016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4017 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4019 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4020 "Failed to allocate input buffer in mempool");
4021 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4022 "Failed to allocate output buffer in mempool");
4024 /* Clear mbuf payload */
4025 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4026 rte_pktmbuf_tailroom(ut_params->ibuf));
4028 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4029 /* Append data which is padded to a multiple of */
4030 /* the algorithms block size */
4031 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4032 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4034 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4035 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4037 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4039 /* Create SNOW 3G operation */
4040 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4041 tdata->cipher_iv.len,
4042 tdata->validCipherLenInBits.len,
4047 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4049 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4051 ut_params->obuf = ut_params->op->sym->m_dst;
4052 if (ut_params->obuf)
4053 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4055 ciphertext = plaintext;
4057 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4060 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4062 tdata->ciphertext.data,
4063 tdata->validDataLenInBits.len,
4064 "SNOW 3G Ciphertext data not as expected");
4069 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4071 struct crypto_testsuite_params *ts_params = &testsuite_params;
4072 struct crypto_unittest_params *ut_params = &unittest_params;
4075 unsigned int plaintext_pad_len;
4076 unsigned int plaintext_len;
4077 uint8_t buffer[10000];
4078 const uint8_t *ciphertext;
4080 struct rte_cryptodev_info dev_info;
4082 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4084 uint64_t feat_flags = dev_info.feature_flags;
4086 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4087 printf("Device doesn't support out-of-place scatter-gather "
4088 "in both input and output mbufs. "
4093 /* Create SNOW 3G session */
4094 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4095 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4096 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4097 tdata->key.data, tdata->key.len,
4098 tdata->cipher_iv.len);
4102 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4103 /* Append data which is padded to a multiple of */
4104 /* the algorithms block size */
4105 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4107 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4108 plaintext_pad_len, 10, 0);
4109 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4110 plaintext_pad_len, 3, 0);
4112 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4113 "Failed to allocate input buffer in mempool");
4114 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4115 "Failed to allocate output buffer in mempool");
4117 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4119 /* Create SNOW 3G operation */
4120 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4121 tdata->cipher_iv.len,
4122 tdata->validCipherLenInBits.len,
4127 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4131 ut_params->obuf = ut_params->op->sym->m_dst;
4132 if (ut_params->obuf)
4133 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4134 plaintext_len, buffer);
4136 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4137 plaintext_len, buffer);
4139 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4142 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4144 tdata->ciphertext.data,
4145 tdata->validDataLenInBits.len,
4146 "SNOW 3G Ciphertext data not as expected");
4151 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4153 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4155 uint8_t curr_byte, prev_byte;
4156 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4157 uint8_t lower_byte_mask = (1 << offset) - 1;
4160 prev_byte = buffer[0];
4161 buffer[0] >>= offset;
4163 for (i = 1; i < length_in_bytes; i++) {
4164 curr_byte = buffer[i];
4165 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4166 (curr_byte >> offset);
4167 prev_byte = curr_byte;
4172 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4174 struct crypto_testsuite_params *ts_params = &testsuite_params;
4175 struct crypto_unittest_params *ut_params = &unittest_params;
4176 uint8_t *plaintext, *ciphertext;
4178 uint32_t plaintext_len;
4179 uint32_t plaintext_pad_len;
4180 uint8_t extra_offset = 4;
4181 uint8_t *expected_ciphertext_shifted;
4183 /* Create SNOW 3G session */
4184 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4185 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4186 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4187 tdata->key.data, tdata->key.len,
4188 tdata->cipher_iv.len);
4192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4193 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4195 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4196 "Failed to allocate input buffer in mempool");
4197 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4198 "Failed to allocate output buffer in mempool");
4200 /* Clear mbuf payload */
4201 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4202 rte_pktmbuf_tailroom(ut_params->ibuf));
4204 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4206 * Append data which is padded to a
4207 * multiple of the algorithms block size
4209 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4211 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4214 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4216 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4217 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4219 #ifdef RTE_APP_TEST_DEBUG
4220 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4222 /* Create SNOW 3G operation */
4223 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4224 tdata->cipher_iv.len,
4225 tdata->validCipherLenInBits.len,
4230 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4232 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4234 ut_params->obuf = ut_params->op->sym->m_dst;
4235 if (ut_params->obuf)
4236 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4238 ciphertext = plaintext;
4240 #ifdef RTE_APP_TEST_DEBUG
4241 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4244 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4246 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4247 "failed to reserve memory for ciphertext shifted\n");
4249 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4250 ceil_byte_length(tdata->ciphertext.len));
4251 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4256 expected_ciphertext_shifted,
4257 tdata->validDataLenInBits.len,
4259 "SNOW 3G Ciphertext data not as expected");
4263 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4265 struct crypto_testsuite_params *ts_params = &testsuite_params;
4266 struct crypto_unittest_params *ut_params = &unittest_params;
4270 uint8_t *plaintext, *ciphertext;
4271 unsigned ciphertext_pad_len;
4272 unsigned ciphertext_len;
4274 /* Create SNOW 3G session */
4275 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4276 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4277 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4278 tdata->key.data, tdata->key.len,
4279 tdata->cipher_iv.len);
4283 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4285 /* Clear mbuf payload */
4286 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4287 rte_pktmbuf_tailroom(ut_params->ibuf));
4289 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4290 /* Append data which is padded to a multiple of */
4291 /* the algorithms block size */
4292 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4293 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4294 ciphertext_pad_len);
4295 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4297 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4299 /* Create SNOW 3G operation */
4300 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4301 tdata->cipher_iv.len,
4302 tdata->validCipherLenInBits.len,
4303 tdata->cipher.offset_bits);
4307 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4309 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4310 ut_params->obuf = ut_params->op->sym->m_dst;
4311 if (ut_params->obuf)
4312 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4314 plaintext = ciphertext;
4316 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4319 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4320 tdata->plaintext.data,
4321 tdata->validDataLenInBits.len,
4322 "SNOW 3G Plaintext data not as expected");
4326 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4328 struct crypto_testsuite_params *ts_params = &testsuite_params;
4329 struct crypto_unittest_params *ut_params = &unittest_params;
4333 uint8_t *plaintext, *ciphertext;
4334 unsigned ciphertext_pad_len;
4335 unsigned ciphertext_len;
4337 /* Create SNOW 3G session */
4338 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4339 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4340 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4341 tdata->key.data, tdata->key.len,
4342 tdata->cipher_iv.len);
4346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4347 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4349 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4350 "Failed to allocate input buffer");
4351 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4352 "Failed to allocate output buffer");
4354 /* Clear mbuf payload */
4355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4356 rte_pktmbuf_tailroom(ut_params->ibuf));
4358 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4359 rte_pktmbuf_tailroom(ut_params->obuf));
4361 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4362 /* Append data which is padded to a multiple of */
4363 /* the algorithms block size */
4364 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4365 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4366 ciphertext_pad_len);
4367 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4368 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4370 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4372 /* Create SNOW 3G operation */
4373 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4374 tdata->cipher_iv.len,
4375 tdata->validCipherLenInBits.len,
4380 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4382 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4383 ut_params->obuf = ut_params->op->sym->m_dst;
4384 if (ut_params->obuf)
4385 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4387 plaintext = ciphertext;
4389 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4392 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4393 tdata->plaintext.data,
4394 tdata->validDataLenInBits.len,
4395 "SNOW 3G Plaintext data not as expected");
4400 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4402 struct crypto_testsuite_params *ts_params = &testsuite_params;
4403 struct crypto_unittest_params *ut_params = &unittest_params;
4407 uint8_t *plaintext, *ciphertext;
4408 unsigned int plaintext_pad_len;
4409 unsigned int plaintext_len;
4411 struct rte_cryptodev_sym_capability_idx cap_idx;
4413 /* Check if device supports ZUC EEA3 */
4414 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4415 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4417 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4421 /* Check if device supports ZUC EIA3 */
4422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4423 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4425 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4429 /* Create ZUC session */
4430 retval = create_zuc_cipher_auth_encrypt_generate_session(
4431 ts_params->valid_devs[0],
4435 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4437 /* clear mbuf payload */
4438 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4439 rte_pktmbuf_tailroom(ut_params->ibuf));
4441 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4442 /* Append data which is padded to a multiple of */
4443 /* the algorithms block size */
4444 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4445 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4447 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4449 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4451 /* Create ZUC operation */
4452 retval = create_zuc_cipher_hash_generate_operation(tdata);
4456 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4459 ut_params->obuf = ut_params->op->sym->m_src;
4460 if (ut_params->obuf)
4461 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4463 ciphertext = plaintext;
4465 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4467 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4469 tdata->ciphertext.data,
4470 tdata->validDataLenInBits.len,
4471 "ZUC Ciphertext data not as expected");
4473 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4474 + plaintext_pad_len;
4477 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4481 "ZUC Generated auth tag not as expected");
4486 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4488 struct crypto_testsuite_params *ts_params = &testsuite_params;
4489 struct crypto_unittest_params *ut_params = &unittest_params;
4493 uint8_t *plaintext, *ciphertext;
4494 unsigned plaintext_pad_len;
4495 unsigned plaintext_len;
4497 /* Create SNOW 3G session */
4498 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4499 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4500 RTE_CRYPTO_AUTH_OP_GENERATE,
4501 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4502 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4503 tdata->key.data, tdata->key.len,
4504 tdata->auth_iv.len, tdata->digest.len,
4505 tdata->cipher_iv.len);
4508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4510 /* clear mbuf payload */
4511 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4512 rte_pktmbuf_tailroom(ut_params->ibuf));
4514 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4515 /* Append data which is padded to a multiple of */
4516 /* the algorithms block size */
4517 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4518 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4520 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4522 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4524 /* Create SNOW 3G operation */
4525 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4526 tdata->digest.len, tdata->auth_iv.data,
4528 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4529 tdata->cipher_iv.data, tdata->cipher_iv.len,
4530 tdata->validCipherLenInBits.len,
4532 tdata->validAuthLenInBits.len,
4538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4541 ut_params->obuf = ut_params->op->sym->m_src;
4542 if (ut_params->obuf)
4543 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4545 ciphertext = plaintext;
4547 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4549 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4551 tdata->ciphertext.data,
4552 tdata->validDataLenInBits.len,
4553 "SNOW 3G Ciphertext data not as expected");
4555 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4556 + plaintext_pad_len;
4559 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4562 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4563 "SNOW 3G Generated auth tag not as expected");
4568 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4569 uint8_t op_mode, uint8_t verify)
4571 struct crypto_testsuite_params *ts_params = &testsuite_params;
4572 struct crypto_unittest_params *ut_params = &unittest_params;
4576 uint8_t *plaintext = NULL, *ciphertext = NULL;
4577 unsigned int plaintext_pad_len;
4578 unsigned int plaintext_len;
4579 unsigned int ciphertext_pad_len;
4580 unsigned int ciphertext_len;
4582 struct rte_cryptodev_info dev_info;
4584 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4586 uint64_t feat_flags = dev_info.feature_flags;
4588 if (op_mode == OUT_OF_PLACE) {
4589 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4590 printf("Device doesn't support digest encrypted.\n");
4595 /* Create SNOW 3G session */
4596 retval = create_wireless_algo_auth_cipher_session(
4597 ts_params->valid_devs[0],
4598 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4599 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4600 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4601 : RTE_CRYPTO_AUTH_OP_GENERATE),
4602 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4603 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4604 tdata->key.data, tdata->key.len,
4605 tdata->auth_iv.len, tdata->digest.len,
4606 tdata->cipher_iv.len);
4611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4612 if (op_mode == OUT_OF_PLACE)
4613 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4615 /* clear mbuf payload */
4616 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4617 rte_pktmbuf_tailroom(ut_params->ibuf));
4618 if (op_mode == OUT_OF_PLACE)
4619 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4620 rte_pktmbuf_tailroom(ut_params->obuf));
4622 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4624 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4625 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4628 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4629 ciphertext_pad_len);
4630 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4631 if (op_mode == OUT_OF_PLACE)
4632 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4633 debug_hexdump(stdout, "ciphertext:", ciphertext,
4636 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4638 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4639 if (op_mode == OUT_OF_PLACE)
4640 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4641 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4644 /* Create SNOW 3G operation */
4645 retval = create_wireless_algo_auth_cipher_operation(
4647 tdata->cipher_iv.data, tdata->cipher_iv.len,
4648 tdata->auth_iv.data, tdata->auth_iv.len,
4649 (tdata->digest.offset_bytes == 0 ?
4650 (verify ? ciphertext_pad_len : plaintext_pad_len)
4651 : tdata->digest.offset_bytes),
4652 tdata->validCipherLenInBits.len,
4653 tdata->cipher.offset_bits,
4654 tdata->validAuthLenInBits.len,
4655 tdata->auth.offset_bits,
4661 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4666 ut_params->obuf = (op_mode == IN_PLACE ?
4667 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4670 if (ut_params->obuf)
4671 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4674 plaintext = ciphertext +
4675 (tdata->cipher.offset_bits >> 3);
4677 debug_hexdump(stdout, "plaintext:", plaintext,
4678 (tdata->plaintext.len >> 3) - tdata->digest.len);
4679 debug_hexdump(stdout, "plaintext expected:",
4680 tdata->plaintext.data,
4681 (tdata->plaintext.len >> 3) - tdata->digest.len);
4683 if (ut_params->obuf)
4684 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4687 ciphertext = plaintext;
4689 debug_hexdump(stdout, "ciphertext:", ciphertext,
4691 debug_hexdump(stdout, "ciphertext expected:",
4692 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4694 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4695 + (tdata->digest.offset_bytes == 0 ?
4696 plaintext_pad_len : tdata->digest.offset_bytes);
4698 debug_hexdump(stdout, "digest:", ut_params->digest,
4700 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4706 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4708 tdata->plaintext.data,
4709 tdata->plaintext.len >> 3,
4710 "SNOW 3G Plaintext data not as expected");
4712 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4714 tdata->ciphertext.data,
4715 tdata->validDataLenInBits.len,
4716 "SNOW 3G Ciphertext data not as expected");
4718 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4721 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4722 "SNOW 3G Generated auth tag not as expected");
4728 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4729 uint8_t op_mode, uint8_t verify)
4731 struct crypto_testsuite_params *ts_params = &testsuite_params;
4732 struct crypto_unittest_params *ut_params = &unittest_params;
4736 const uint8_t *plaintext = NULL;
4737 const uint8_t *ciphertext = NULL;
4738 const uint8_t *digest = NULL;
4739 unsigned int plaintext_pad_len;
4740 unsigned int plaintext_len;
4741 unsigned int ciphertext_pad_len;
4742 unsigned int ciphertext_len;
4743 uint8_t buffer[10000];
4744 uint8_t digest_buffer[10000];
4746 struct rte_cryptodev_info dev_info;
4748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4750 uint64_t feat_flags = dev_info.feature_flags;
4752 if (op_mode == IN_PLACE) {
4753 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4754 printf("Device doesn't support in-place scatter-gather "
4755 "in both input and output mbufs.\n");
4759 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4760 printf("Device doesn't support out-of-place scatter-gather "
4761 "in both input and output mbufs.\n");
4764 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4765 printf("Device doesn't support digest encrypted.\n");
4770 /* Create SNOW 3G session */
4771 retval = create_wireless_algo_auth_cipher_session(
4772 ts_params->valid_devs[0],
4773 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4774 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4775 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4776 : RTE_CRYPTO_AUTH_OP_GENERATE),
4777 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4778 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4779 tdata->key.data, tdata->key.len,
4780 tdata->auth_iv.len, tdata->digest.len,
4781 tdata->cipher_iv.len);
4786 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4788 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4789 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4791 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4792 plaintext_pad_len, 15, 0);
4793 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4794 "Failed to allocate input buffer in mempool");
4796 if (op_mode == OUT_OF_PLACE) {
4797 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4798 plaintext_pad_len, 15, 0);
4799 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4800 "Failed to allocate output buffer in mempool");
4804 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4805 tdata->ciphertext.data);
4806 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4807 ciphertext_len, buffer);
4808 debug_hexdump(stdout, "ciphertext:", ciphertext,
4811 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4812 tdata->plaintext.data);
4813 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4814 plaintext_len, buffer);
4815 debug_hexdump(stdout, "plaintext:", plaintext,
4818 memset(buffer, 0, sizeof(buffer));
4820 /* Create SNOW 3G operation */
4821 retval = create_wireless_algo_auth_cipher_operation(
4823 tdata->cipher_iv.data, tdata->cipher_iv.len,
4824 tdata->auth_iv.data, tdata->auth_iv.len,
4825 (tdata->digest.offset_bytes == 0 ?
4826 (verify ? ciphertext_pad_len : plaintext_pad_len)
4827 : tdata->digest.offset_bytes),
4828 tdata->validCipherLenInBits.len,
4829 tdata->cipher.offset_bits,
4830 tdata->validAuthLenInBits.len,
4831 tdata->auth.offset_bits,
4837 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4840 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4842 ut_params->obuf = (op_mode == IN_PLACE ?
4843 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4846 if (ut_params->obuf)
4847 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4848 plaintext_len, buffer);
4850 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4851 plaintext_len, buffer);
4853 debug_hexdump(stdout, "plaintext:", plaintext,
4854 (tdata->plaintext.len >> 3) - tdata->digest.len);
4855 debug_hexdump(stdout, "plaintext expected:",
4856 tdata->plaintext.data,
4857 (tdata->plaintext.len >> 3) - tdata->digest.len);
4859 if (ut_params->obuf)
4860 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4861 ciphertext_len, buffer);
4863 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4864 ciphertext_len, buffer);
4866 debug_hexdump(stdout, "ciphertext:", ciphertext,
4868 debug_hexdump(stdout, "ciphertext expected:",
4869 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4871 if (ut_params->obuf)
4872 digest = rte_pktmbuf_read(ut_params->obuf,
4873 (tdata->digest.offset_bytes == 0 ?
4874 plaintext_pad_len : tdata->digest.offset_bytes),
4875 tdata->digest.len, digest_buffer);
4877 digest = rte_pktmbuf_read(ut_params->ibuf,
4878 (tdata->digest.offset_bytes == 0 ?
4879 plaintext_pad_len : tdata->digest.offset_bytes),
4880 tdata->digest.len, digest_buffer);
4882 debug_hexdump(stdout, "digest:", digest,
4884 debug_hexdump(stdout, "digest expected:",
4885 tdata->digest.data, tdata->digest.len);
4890 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4892 tdata->plaintext.data,
4893 tdata->plaintext.len >> 3,
4894 "SNOW 3G Plaintext data not as expected");
4896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4898 tdata->ciphertext.data,
4899 tdata->validDataLenInBits.len,
4900 "SNOW 3G Ciphertext data not as expected");
4902 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4905 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4906 "SNOW 3G Generated auth tag not as expected");
4912 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4913 uint8_t op_mode, uint8_t verify)
4915 struct crypto_testsuite_params *ts_params = &testsuite_params;
4916 struct crypto_unittest_params *ut_params = &unittest_params;
4920 uint8_t *plaintext = NULL, *ciphertext = NULL;
4921 unsigned int plaintext_pad_len;
4922 unsigned int plaintext_len;
4923 unsigned int ciphertext_pad_len;
4924 unsigned int ciphertext_len;
4926 struct rte_cryptodev_info dev_info;
4928 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4930 uint64_t feat_flags = dev_info.feature_flags;
4932 if (op_mode == OUT_OF_PLACE) {
4933 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4934 printf("Device doesn't support digest encrypted.\n");
4939 /* Create KASUMI session */
4940 retval = create_wireless_algo_auth_cipher_session(
4941 ts_params->valid_devs[0],
4942 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4943 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4944 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4945 : RTE_CRYPTO_AUTH_OP_GENERATE),
4946 RTE_CRYPTO_AUTH_KASUMI_F9,
4947 RTE_CRYPTO_CIPHER_KASUMI_F8,
4948 tdata->key.data, tdata->key.len,
4949 0, tdata->digest.len,
4950 tdata->cipher_iv.len);
4955 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4956 if (op_mode == OUT_OF_PLACE)
4957 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4959 /* clear mbuf payload */
4960 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4961 rte_pktmbuf_tailroom(ut_params->ibuf));
4962 if (op_mode == OUT_OF_PLACE)
4963 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4964 rte_pktmbuf_tailroom(ut_params->obuf));
4966 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4967 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4968 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4969 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4972 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4973 ciphertext_pad_len);
4974 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4975 if (op_mode == OUT_OF_PLACE)
4976 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4977 debug_hexdump(stdout, "ciphertext:", ciphertext,
4980 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4982 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4983 if (op_mode == OUT_OF_PLACE)
4984 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4985 debug_hexdump(stdout, "plaintext:", plaintext,
4989 /* Create KASUMI operation */
4990 retval = create_wireless_algo_auth_cipher_operation(
4992 tdata->cipher_iv.data, tdata->cipher_iv.len,
4994 (tdata->digest.offset_bytes == 0 ?
4995 (verify ? ciphertext_pad_len : plaintext_pad_len)
4996 : tdata->digest.offset_bytes),
4997 tdata->validCipherLenInBits.len,
4998 tdata->validCipherOffsetInBits.len,
4999 tdata->validAuthLenInBits.len,
5006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5009 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5011 ut_params->obuf = (op_mode == IN_PLACE ?
5012 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5016 if (ut_params->obuf)
5017 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5020 plaintext = ciphertext;
5022 debug_hexdump(stdout, "plaintext:", plaintext,
5023 (tdata->plaintext.len >> 3) - tdata->digest.len);
5024 debug_hexdump(stdout, "plaintext expected:",
5025 tdata->plaintext.data,
5026 (tdata->plaintext.len >> 3) - tdata->digest.len);
5028 if (ut_params->obuf)
5029 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5032 ciphertext = plaintext;
5034 debug_hexdump(stdout, "ciphertext:", ciphertext,
5036 debug_hexdump(stdout, "ciphertext expected:",
5037 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5039 ut_params->digest = rte_pktmbuf_mtod(
5040 ut_params->obuf, uint8_t *) +
5041 (tdata->digest.offset_bytes == 0 ?
5042 plaintext_pad_len : tdata->digest.offset_bytes);
5044 debug_hexdump(stdout, "digest:", ut_params->digest,
5046 debug_hexdump(stdout, "digest expected:",
5047 tdata->digest.data, tdata->digest.len);
5052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5054 tdata->plaintext.data,
5055 tdata->plaintext.len >> 3,
5056 "KASUMI Plaintext data not as expected");
5058 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5060 tdata->ciphertext.data,
5061 tdata->ciphertext.len >> 3,
5062 "KASUMI Ciphertext data not as expected");
5064 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5067 DIGEST_BYTE_LENGTH_KASUMI_F9,
5068 "KASUMI Generated auth tag not as expected");
5074 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5075 uint8_t op_mode, uint8_t verify)
5077 struct crypto_testsuite_params *ts_params = &testsuite_params;
5078 struct crypto_unittest_params *ut_params = &unittest_params;
5082 const uint8_t *plaintext = NULL;
5083 const uint8_t *ciphertext = NULL;
5084 const uint8_t *digest = NULL;
5085 unsigned int plaintext_pad_len;
5086 unsigned int plaintext_len;
5087 unsigned int ciphertext_pad_len;
5088 unsigned int ciphertext_len;
5089 uint8_t buffer[10000];
5090 uint8_t digest_buffer[10000];
5092 struct rte_cryptodev_info dev_info;
5094 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5096 uint64_t feat_flags = dev_info.feature_flags;
5098 if (op_mode == IN_PLACE) {
5099 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5100 printf("Device doesn't support in-place scatter-gather "
5101 "in both input and output mbufs.\n");
5105 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5106 printf("Device doesn't support out-of-place scatter-gather "
5107 "in both input and output mbufs.\n");
5110 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5111 printf("Device doesn't support digest encrypted.\n");
5116 /* Create KASUMI session */
5117 retval = create_wireless_algo_auth_cipher_session(
5118 ts_params->valid_devs[0],
5119 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5120 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5121 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5122 : RTE_CRYPTO_AUTH_OP_GENERATE),
5123 RTE_CRYPTO_AUTH_KASUMI_F9,
5124 RTE_CRYPTO_CIPHER_KASUMI_F8,
5125 tdata->key.data, tdata->key.len,
5126 0, tdata->digest.len,
5127 tdata->cipher_iv.len);
5132 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5133 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5134 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5135 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5137 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5138 plaintext_pad_len, 15, 0);
5139 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5140 "Failed to allocate input buffer in mempool");
5142 if (op_mode == OUT_OF_PLACE) {
5143 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5144 plaintext_pad_len, 15, 0);
5145 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5146 "Failed to allocate output buffer in mempool");
5150 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5151 tdata->ciphertext.data);
5152 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5153 ciphertext_len, buffer);
5154 debug_hexdump(stdout, "ciphertext:", ciphertext,
5157 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5158 tdata->plaintext.data);
5159 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5160 plaintext_len, buffer);
5161 debug_hexdump(stdout, "plaintext:", plaintext,
5164 memset(buffer, 0, sizeof(buffer));
5166 /* Create KASUMI operation */
5167 retval = create_wireless_algo_auth_cipher_operation(
5169 tdata->cipher_iv.data, tdata->cipher_iv.len,
5171 (tdata->digest.offset_bytes == 0 ?
5172 (verify ? ciphertext_pad_len : plaintext_pad_len)
5173 : tdata->digest.offset_bytes),
5174 tdata->validCipherLenInBits.len,
5175 tdata->validCipherOffsetInBits.len,
5176 tdata->validAuthLenInBits.len,
5183 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5186 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5188 ut_params->obuf = (op_mode == IN_PLACE ?
5189 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5192 if (ut_params->obuf)
5193 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5194 plaintext_len, buffer);
5196 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5197 plaintext_len, buffer);
5199 debug_hexdump(stdout, "plaintext:", plaintext,
5200 (tdata->plaintext.len >> 3) - tdata->digest.len);
5201 debug_hexdump(stdout, "plaintext expected:",
5202 tdata->plaintext.data,
5203 (tdata->plaintext.len >> 3) - tdata->digest.len);
5205 if (ut_params->obuf)
5206 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5207 ciphertext_len, buffer);
5209 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5210 ciphertext_len, buffer);
5212 debug_hexdump(stdout, "ciphertext:", ciphertext,
5214 debug_hexdump(stdout, "ciphertext expected:",
5215 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5217 if (ut_params->obuf)
5218 digest = rte_pktmbuf_read(ut_params->obuf,
5219 (tdata->digest.offset_bytes == 0 ?
5220 plaintext_pad_len : tdata->digest.offset_bytes),
5221 tdata->digest.len, digest_buffer);
5223 digest = rte_pktmbuf_read(ut_params->ibuf,
5224 (tdata->digest.offset_bytes == 0 ?
5225 plaintext_pad_len : tdata->digest.offset_bytes),
5226 tdata->digest.len, digest_buffer);
5228 debug_hexdump(stdout, "digest:", digest,
5230 debug_hexdump(stdout, "digest expected:",
5231 tdata->digest.data, tdata->digest.len);
5236 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5238 tdata->plaintext.data,
5239 tdata->plaintext.len >> 3,
5240 "KASUMI Plaintext data not as expected");
5242 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5244 tdata->ciphertext.data,
5245 tdata->validDataLenInBits.len,
5246 "KASUMI Ciphertext data not as expected");
5248 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5251 DIGEST_BYTE_LENGTH_KASUMI_F9,
5252 "KASUMI Generated auth tag not as expected");
5258 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5260 struct crypto_testsuite_params *ts_params = &testsuite_params;
5261 struct crypto_unittest_params *ut_params = &unittest_params;
5265 uint8_t *plaintext, *ciphertext;
5266 unsigned plaintext_pad_len;
5267 unsigned plaintext_len;
5269 /* Create KASUMI session */
5270 retval = create_wireless_algo_cipher_auth_session(
5271 ts_params->valid_devs[0],
5272 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5273 RTE_CRYPTO_AUTH_OP_GENERATE,
5274 RTE_CRYPTO_AUTH_KASUMI_F9,
5275 RTE_CRYPTO_CIPHER_KASUMI_F8,
5276 tdata->key.data, tdata->key.len,
5277 0, tdata->digest.len,
5278 tdata->cipher_iv.len);
5282 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5284 /* clear mbuf payload */
5285 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5286 rte_pktmbuf_tailroom(ut_params->ibuf));
5288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5289 /* Append data which is padded to a multiple of */
5290 /* the algorithms block size */
5291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5292 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5294 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5296 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5298 /* Create KASUMI operation */
5299 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5300 tdata->digest.len, NULL, 0,
5301 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5302 tdata->cipher_iv.data, tdata->cipher_iv.len,
5303 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5304 tdata->validCipherOffsetInBits.len,
5305 tdata->validAuthLenInBits.len,
5311 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5313 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5315 if (ut_params->op->sym->m_dst)
5316 ut_params->obuf = ut_params->op->sym->m_dst;
5318 ut_params->obuf = ut_params->op->sym->m_src;
5320 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5321 tdata->validCipherOffsetInBits.len >> 3);
5323 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5324 + plaintext_pad_len;
5326 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5327 (tdata->validCipherOffsetInBits.len >> 3);
5329 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5331 reference_ciphertext,
5332 tdata->validCipherLenInBits.len,
5333 "KASUMI Ciphertext data not as expected");
5336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5339 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5340 "KASUMI Generated auth tag not as expected");
5345 test_zuc_encryption(const struct wireless_test_data *tdata)
5347 struct crypto_testsuite_params *ts_params = &testsuite_params;
5348 struct crypto_unittest_params *ut_params = &unittest_params;
5351 uint8_t *plaintext, *ciphertext;
5352 unsigned plaintext_pad_len;
5353 unsigned plaintext_len;
5355 struct rte_cryptodev_sym_capability_idx cap_idx;
5357 /* Check if device supports ZUC EEA3 */
5358 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5359 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5365 /* Create ZUC session */
5366 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5367 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5368 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5369 tdata->key.data, tdata->key.len,
5370 tdata->cipher_iv.len);
5374 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5376 /* Clear mbuf payload */
5377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5378 rte_pktmbuf_tailroom(ut_params->ibuf));
5380 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5381 /* Append data which is padded to a multiple */
5382 /* of the algorithms block size */
5383 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5384 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5386 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5388 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5390 /* Create ZUC operation */
5391 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5392 tdata->cipher_iv.len,
5393 tdata->plaintext.len,
5398 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5400 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5402 ut_params->obuf = ut_params->op->sym->m_dst;
5403 if (ut_params->obuf)
5404 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5406 ciphertext = plaintext;
5408 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5411 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5413 tdata->ciphertext.data,
5414 tdata->validCipherLenInBits.len,
5415 "ZUC Ciphertext data not as expected");
5420 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5422 struct crypto_testsuite_params *ts_params = &testsuite_params;
5423 struct crypto_unittest_params *ut_params = &unittest_params;
5427 unsigned int plaintext_pad_len;
5428 unsigned int plaintext_len;
5429 const uint8_t *ciphertext;
5430 uint8_t ciphertext_buffer[2048];
5431 struct rte_cryptodev_info dev_info;
5433 struct rte_cryptodev_sym_capability_idx cap_idx;
5435 /* Check if device supports ZUC EEA3 */
5436 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5437 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5439 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5443 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5445 uint64_t feat_flags = dev_info.feature_flags;
5447 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5448 printf("Device doesn't support in-place scatter-gather. "
5453 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5455 /* Append data which is padded to a multiple */
5456 /* of the algorithms block size */
5457 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5459 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5460 plaintext_pad_len, 10, 0);
5462 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5463 tdata->plaintext.data);
5465 /* Create ZUC session */
5466 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5467 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5468 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5469 tdata->key.data, tdata->key.len,
5470 tdata->cipher_iv.len);
5474 /* Clear mbuf payload */
5476 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5478 /* Create ZUC operation */
5479 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5480 tdata->cipher_iv.len, tdata->plaintext.len,
5485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5489 ut_params->obuf = ut_params->op->sym->m_dst;
5490 if (ut_params->obuf)
5491 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5492 0, plaintext_len, ciphertext_buffer);
5494 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5495 0, plaintext_len, ciphertext_buffer);
5498 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5501 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5503 tdata->ciphertext.data,
5504 tdata->validCipherLenInBits.len,
5505 "ZUC Ciphertext data not as expected");
5511 test_zuc_authentication(const struct wireless_test_data *tdata)
5513 struct crypto_testsuite_params *ts_params = &testsuite_params;
5514 struct crypto_unittest_params *ut_params = &unittest_params;
5517 unsigned plaintext_pad_len;
5518 unsigned plaintext_len;
5521 struct rte_cryptodev_sym_capability_idx cap_idx;
5523 /* Check if device supports ZUC EIA3 */
5524 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5525 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5527 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5531 /* Create ZUC session */
5532 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5533 tdata->key.data, tdata->key.len,
5534 tdata->auth_iv.len, tdata->digest.len,
5535 RTE_CRYPTO_AUTH_OP_GENERATE,
5536 RTE_CRYPTO_AUTH_ZUC_EIA3);
5540 /* alloc mbuf and set payload */
5541 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5543 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5544 rte_pktmbuf_tailroom(ut_params->ibuf));
5546 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5547 /* Append data which is padded to a multiple of */
5548 /* the algorithms block size */
5549 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5550 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5552 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5554 /* Create ZUC operation */
5555 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5556 tdata->auth_iv.data, tdata->auth_iv.len,
5557 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5558 tdata->validAuthLenInBits.len,
5563 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5565 ut_params->obuf = ut_params->op->sym->m_src;
5566 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5567 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5568 + plaintext_pad_len;
5571 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5574 DIGEST_BYTE_LENGTH_KASUMI_F9,
5575 "ZUC Generated auth tag not as expected");
5581 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5582 uint8_t op_mode, uint8_t verify)
5584 struct crypto_testsuite_params *ts_params = &testsuite_params;
5585 struct crypto_unittest_params *ut_params = &unittest_params;
5589 uint8_t *plaintext = NULL, *ciphertext = NULL;
5590 unsigned int plaintext_pad_len;
5591 unsigned int plaintext_len;
5592 unsigned int ciphertext_pad_len;
5593 unsigned int ciphertext_len;
5595 struct rte_cryptodev_info dev_info;
5596 struct rte_cryptodev_sym_capability_idx cap_idx;
5598 /* Check if device supports ZUC EIA3 */
5599 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5600 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5606 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5608 uint64_t feat_flags = dev_info.feature_flags;
5610 if (op_mode == OUT_OF_PLACE) {
5611 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5612 printf("Device doesn't support digest encrypted.\n");
5617 /* Create ZUC session */
5618 retval = create_wireless_algo_auth_cipher_session(
5619 ts_params->valid_devs[0],
5620 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5621 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5622 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5623 : RTE_CRYPTO_AUTH_OP_GENERATE),
5624 RTE_CRYPTO_AUTH_ZUC_EIA3,
5625 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5626 tdata->key.data, tdata->key.len,
5627 tdata->auth_iv.len, tdata->digest.len,
5628 tdata->cipher_iv.len);
5633 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5634 if (op_mode == OUT_OF_PLACE)
5635 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5637 /* clear mbuf payload */
5638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5639 rte_pktmbuf_tailroom(ut_params->ibuf));
5640 if (op_mode == OUT_OF_PLACE)
5641 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5642 rte_pktmbuf_tailroom(ut_params->obuf));
5644 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5645 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5646 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5647 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5650 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5651 ciphertext_pad_len);
5652 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5653 if (op_mode == OUT_OF_PLACE)
5654 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5655 debug_hexdump(stdout, "ciphertext:", ciphertext,
5658 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5660 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5661 if (op_mode == OUT_OF_PLACE)
5662 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5663 debug_hexdump(stdout, "plaintext:", plaintext,
5667 /* Create ZUC operation */
5668 retval = create_wireless_algo_auth_cipher_operation(
5670 tdata->cipher_iv.data, tdata->cipher_iv.len,
5671 tdata->auth_iv.data, tdata->auth_iv.len,
5672 (tdata->digest.offset_bytes == 0 ?
5673 (verify ? ciphertext_pad_len : plaintext_pad_len)
5674 : tdata->digest.offset_bytes),
5675 tdata->validCipherLenInBits.len,
5676 tdata->validCipherOffsetInBits.len,
5677 tdata->validAuthLenInBits.len,
5684 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5687 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5689 ut_params->obuf = (op_mode == IN_PLACE ?
5690 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5694 if (ut_params->obuf)
5695 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5698 plaintext = ciphertext;
5700 debug_hexdump(stdout, "plaintext:", plaintext,
5701 (tdata->plaintext.len >> 3) - tdata->digest.len);
5702 debug_hexdump(stdout, "plaintext expected:",
5703 tdata->plaintext.data,
5704 (tdata->plaintext.len >> 3) - tdata->digest.len);
5706 if (ut_params->obuf)
5707 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5710 ciphertext = plaintext;
5712 debug_hexdump(stdout, "ciphertext:", ciphertext,
5714 debug_hexdump(stdout, "ciphertext expected:",
5715 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5717 ut_params->digest = rte_pktmbuf_mtod(
5718 ut_params->obuf, uint8_t *) +
5719 (tdata->digest.offset_bytes == 0 ?
5720 plaintext_pad_len : tdata->digest.offset_bytes);
5722 debug_hexdump(stdout, "digest:", ut_params->digest,
5724 debug_hexdump(stdout, "digest expected:",
5725 tdata->digest.data, tdata->digest.len);
5730 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5732 tdata->plaintext.data,
5733 tdata->plaintext.len >> 3,
5734 "ZUC Plaintext data not as expected");
5736 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5738 tdata->ciphertext.data,
5739 tdata->ciphertext.len >> 3,
5740 "ZUC Ciphertext data not as expected");
5742 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5745 DIGEST_BYTE_LENGTH_KASUMI_F9,
5746 "ZUC Generated auth tag not as expected");
5752 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5753 uint8_t op_mode, uint8_t verify)
5755 struct crypto_testsuite_params *ts_params = &testsuite_params;
5756 struct crypto_unittest_params *ut_params = &unittest_params;
5760 const uint8_t *plaintext = NULL;
5761 const uint8_t *ciphertext = NULL;
5762 const uint8_t *digest = NULL;
5763 unsigned int plaintext_pad_len;
5764 unsigned int plaintext_len;
5765 unsigned int ciphertext_pad_len;
5766 unsigned int ciphertext_len;
5767 uint8_t buffer[10000];
5768 uint8_t digest_buffer[10000];
5770 struct rte_cryptodev_info dev_info;
5771 struct rte_cryptodev_sym_capability_idx cap_idx;
5773 /* Check if device supports ZUC EIA3 */
5774 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5775 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5777 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5781 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5783 uint64_t feat_flags = dev_info.feature_flags;
5785 if (op_mode == IN_PLACE) {
5786 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5787 printf("Device doesn't support in-place scatter-gather "
5788 "in both input and output mbufs.\n");
5792 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5793 printf("Device doesn't support out-of-place scatter-gather "
5794 "in both input and output mbufs.\n");
5797 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5798 printf("Device doesn't support digest encrypted.\n");
5803 /* Create ZUC session */
5804 retval = create_wireless_algo_auth_cipher_session(
5805 ts_params->valid_devs[0],
5806 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5807 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5808 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5809 : RTE_CRYPTO_AUTH_OP_GENERATE),
5810 RTE_CRYPTO_AUTH_ZUC_EIA3,
5811 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5812 tdata->key.data, tdata->key.len,
5813 tdata->auth_iv.len, tdata->digest.len,
5814 tdata->cipher_iv.len);
5819 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5820 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5821 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5822 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5824 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5825 plaintext_pad_len, 15, 0);
5826 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5827 "Failed to allocate input buffer in mempool");
5829 if (op_mode == OUT_OF_PLACE) {
5830 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5831 plaintext_pad_len, 15, 0);
5832 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5833 "Failed to allocate output buffer in mempool");
5837 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5838 tdata->ciphertext.data);
5839 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5840 ciphertext_len, buffer);
5841 debug_hexdump(stdout, "ciphertext:", ciphertext,
5844 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5845 tdata->plaintext.data);
5846 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5847 plaintext_len, buffer);
5848 debug_hexdump(stdout, "plaintext:", plaintext,
5851 memset(buffer, 0, sizeof(buffer));
5853 /* Create ZUC operation */
5854 retval = create_wireless_algo_auth_cipher_operation(
5856 tdata->cipher_iv.data, tdata->cipher_iv.len,
5858 (tdata->digest.offset_bytes == 0 ?
5859 (verify ? ciphertext_pad_len : plaintext_pad_len)
5860 : tdata->digest.offset_bytes),
5861 tdata->validCipherLenInBits.len,
5862 tdata->validCipherOffsetInBits.len,
5863 tdata->validAuthLenInBits.len,
5870 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5873 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5875 ut_params->obuf = (op_mode == IN_PLACE ?
5876 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5879 if (ut_params->obuf)
5880 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5881 plaintext_len, buffer);
5883 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5884 plaintext_len, buffer);
5886 debug_hexdump(stdout, "plaintext:", plaintext,
5887 (tdata->plaintext.len >> 3) - tdata->digest.len);
5888 debug_hexdump(stdout, "plaintext expected:",
5889 tdata->plaintext.data,
5890 (tdata->plaintext.len >> 3) - tdata->digest.len);
5892 if (ut_params->obuf)
5893 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5894 ciphertext_len, buffer);
5896 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5897 ciphertext_len, buffer);
5899 debug_hexdump(stdout, "ciphertext:", ciphertext,
5901 debug_hexdump(stdout, "ciphertext expected:",
5902 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5904 if (ut_params->obuf)
5905 digest = rte_pktmbuf_read(ut_params->obuf,
5906 (tdata->digest.offset_bytes == 0 ?
5907 plaintext_pad_len : tdata->digest.offset_bytes),
5908 tdata->digest.len, digest_buffer);
5910 digest = rte_pktmbuf_read(ut_params->ibuf,
5911 (tdata->digest.offset_bytes == 0 ?
5912 plaintext_pad_len : tdata->digest.offset_bytes),
5913 tdata->digest.len, digest_buffer);
5915 debug_hexdump(stdout, "digest:", digest,
5917 debug_hexdump(stdout, "digest expected:",
5918 tdata->digest.data, tdata->digest.len);
5923 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5925 tdata->plaintext.data,
5926 tdata->plaintext.len >> 3,
5927 "ZUC Plaintext data not as expected");
5929 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5931 tdata->ciphertext.data,
5932 tdata->validDataLenInBits.len,
5933 "ZUC Ciphertext data not as expected");
5935 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5938 DIGEST_BYTE_LENGTH_KASUMI_F9,
5939 "ZUC Generated auth tag not as expected");
5945 test_kasumi_encryption_test_case_1(void)
5947 return test_kasumi_encryption(&kasumi_test_case_1);
5951 test_kasumi_encryption_test_case_1_sgl(void)
5953 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5957 test_kasumi_encryption_test_case_1_oop(void)
5959 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5963 test_kasumi_encryption_test_case_1_oop_sgl(void)
5965 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5969 test_kasumi_encryption_test_case_2(void)
5971 return test_kasumi_encryption(&kasumi_test_case_2);
5975 test_kasumi_encryption_test_case_3(void)
5977 return test_kasumi_encryption(&kasumi_test_case_3);
5981 test_kasumi_encryption_test_case_4(void)
5983 return test_kasumi_encryption(&kasumi_test_case_4);
5987 test_kasumi_encryption_test_case_5(void)
5989 return test_kasumi_encryption(&kasumi_test_case_5);
5993 test_kasumi_decryption_test_case_1(void)
5995 return test_kasumi_decryption(&kasumi_test_case_1);
5999 test_kasumi_decryption_test_case_1_oop(void)
6001 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6005 test_kasumi_decryption_test_case_2(void)
6007 return test_kasumi_decryption(&kasumi_test_case_2);
6011 test_kasumi_decryption_test_case_3(void)
6013 return test_kasumi_decryption(&kasumi_test_case_3);
6017 test_kasumi_decryption_test_case_4(void)
6019 return test_kasumi_decryption(&kasumi_test_case_4);
6023 test_kasumi_decryption_test_case_5(void)
6025 return test_kasumi_decryption(&kasumi_test_case_5);
6028 test_snow3g_encryption_test_case_1(void)
6030 return test_snow3g_encryption(&snow3g_test_case_1);
6034 test_snow3g_encryption_test_case_1_oop(void)
6036 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6040 test_snow3g_encryption_test_case_1_oop_sgl(void)
6042 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6047 test_snow3g_encryption_test_case_1_offset_oop(void)
6049 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6053 test_snow3g_encryption_test_case_2(void)
6055 return test_snow3g_encryption(&snow3g_test_case_2);
6059 test_snow3g_encryption_test_case_3(void)
6061 return test_snow3g_encryption(&snow3g_test_case_3);
6065 test_snow3g_encryption_test_case_4(void)
6067 return test_snow3g_encryption(&snow3g_test_case_4);
6071 test_snow3g_encryption_test_case_5(void)
6073 return test_snow3g_encryption(&snow3g_test_case_5);
6077 test_snow3g_decryption_test_case_1(void)
6079 return test_snow3g_decryption(&snow3g_test_case_1);
6083 test_snow3g_decryption_test_case_1_oop(void)
6085 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6089 test_snow3g_decryption_test_case_2(void)
6091 return test_snow3g_decryption(&snow3g_test_case_2);
6095 test_snow3g_decryption_test_case_3(void)
6097 return test_snow3g_decryption(&snow3g_test_case_3);
6101 test_snow3g_decryption_test_case_4(void)
6103 return test_snow3g_decryption(&snow3g_test_case_4);
6107 test_snow3g_decryption_test_case_5(void)
6109 return test_snow3g_decryption(&snow3g_test_case_5);
6113 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6114 * Pattern digest from snow3g_test_data must be allocated as
6115 * 4 last bytes in plaintext.
6118 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6119 struct snow3g_hash_test_data *output)
6121 if ((pattern != NULL) && (output != NULL)) {
6122 output->key.len = pattern->key.len;
6124 memcpy(output->key.data,
6125 pattern->key.data, pattern->key.len);
6127 output->auth_iv.len = pattern->auth_iv.len;
6129 memcpy(output->auth_iv.data,
6130 pattern->auth_iv.data, pattern->auth_iv.len);
6132 output->plaintext.len = pattern->plaintext.len;
6134 memcpy(output->plaintext.data,
6135 pattern->plaintext.data, pattern->plaintext.len >> 3);
6137 output->digest.len = pattern->digest.len;
6139 memcpy(output->digest.data,
6140 &pattern->plaintext.data[pattern->digest.offset_bytes],
6141 pattern->digest.len);
6143 output->validAuthLenInBits.len =
6144 pattern->validAuthLenInBits.len;
6149 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6152 test_snow3g_decryption_with_digest_test_case_1(void)
6154 struct snow3g_hash_test_data snow3g_hash_data;
6157 * Function prepare data for hash veryfication test case.
6158 * Digest is allocated in 4 last bytes in plaintext, pattern.
6160 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6162 return test_snow3g_decryption(&snow3g_test_case_7) &
6163 test_snow3g_authentication_verify(&snow3g_hash_data);
6167 test_snow3g_cipher_auth_test_case_1(void)
6169 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6173 test_snow3g_auth_cipher_test_case_1(void)
6175 return test_snow3g_auth_cipher(
6176 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6180 test_snow3g_auth_cipher_test_case_2(void)
6182 return test_snow3g_auth_cipher(
6183 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6187 test_snow3g_auth_cipher_test_case_2_oop(void)
6189 return test_snow3g_auth_cipher(
6190 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6194 test_snow3g_auth_cipher_part_digest_enc(void)
6196 return test_snow3g_auth_cipher(
6197 &snow3g_auth_cipher_partial_digest_encryption,
6202 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6204 return test_snow3g_auth_cipher(
6205 &snow3g_auth_cipher_partial_digest_encryption,
6210 test_snow3g_auth_cipher_test_case_3_sgl(void)
6212 return test_snow3g_auth_cipher_sgl(
6213 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6217 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6219 return test_snow3g_auth_cipher_sgl(
6220 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6224 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6226 return test_snow3g_auth_cipher_sgl(
6227 &snow3g_auth_cipher_partial_digest_encryption,
6232 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6234 return test_snow3g_auth_cipher_sgl(
6235 &snow3g_auth_cipher_partial_digest_encryption,
6240 test_snow3g_auth_cipher_verify_test_case_1(void)
6242 return test_snow3g_auth_cipher(
6243 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6247 test_snow3g_auth_cipher_verify_test_case_2(void)
6249 return test_snow3g_auth_cipher(
6250 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6254 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6256 return test_snow3g_auth_cipher(
6257 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6261 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6263 return test_snow3g_auth_cipher(
6264 &snow3g_auth_cipher_partial_digest_encryption,
6269 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6271 return test_snow3g_auth_cipher(
6272 &snow3g_auth_cipher_partial_digest_encryption,
6277 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6279 return test_snow3g_auth_cipher_sgl(
6280 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6284 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6286 return test_snow3g_auth_cipher_sgl(
6287 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6291 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6293 return test_snow3g_auth_cipher_sgl(
6294 &snow3g_auth_cipher_partial_digest_encryption,
6299 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6301 return test_snow3g_auth_cipher_sgl(
6302 &snow3g_auth_cipher_partial_digest_encryption,
6307 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6309 return test_snow3g_auth_cipher(
6310 &snow3g_test_case_7, IN_PLACE, 0);
6314 test_kasumi_auth_cipher_test_case_1(void)
6316 return test_kasumi_auth_cipher(
6317 &kasumi_test_case_3, IN_PLACE, 0);
6321 test_kasumi_auth_cipher_test_case_2(void)
6323 return test_kasumi_auth_cipher(
6324 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6328 test_kasumi_auth_cipher_test_case_2_oop(void)
6330 return test_kasumi_auth_cipher(
6331 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6335 test_kasumi_auth_cipher_test_case_2_sgl(void)
6337 return test_kasumi_auth_cipher_sgl(
6338 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6342 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6344 return test_kasumi_auth_cipher_sgl(
6345 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6349 test_kasumi_auth_cipher_verify_test_case_1(void)
6351 return test_kasumi_auth_cipher(
6352 &kasumi_test_case_3, IN_PLACE, 1);
6356 test_kasumi_auth_cipher_verify_test_case_2(void)
6358 return test_kasumi_auth_cipher(
6359 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6363 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6365 return test_kasumi_auth_cipher(
6366 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6370 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6372 return test_kasumi_auth_cipher_sgl(
6373 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6377 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6379 return test_kasumi_auth_cipher_sgl(
6380 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6384 test_kasumi_cipher_auth_test_case_1(void)
6386 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6390 test_zuc_encryption_test_case_1(void)
6392 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6396 test_zuc_encryption_test_case_2(void)
6398 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6402 test_zuc_encryption_test_case_3(void)
6404 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6408 test_zuc_encryption_test_case_4(void)
6410 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6414 test_zuc_encryption_test_case_5(void)
6416 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6420 test_zuc_encryption_test_case_6_sgl(void)
6422 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6426 test_zuc_hash_generate_test_case_1(void)
6428 return test_zuc_authentication(&zuc_test_case_auth_1b);
6432 test_zuc_hash_generate_test_case_2(void)
6434 return test_zuc_authentication(&zuc_test_case_auth_90b);
6438 test_zuc_hash_generate_test_case_3(void)
6440 return test_zuc_authentication(&zuc_test_case_auth_577b);
6444 test_zuc_hash_generate_test_case_4(void)
6446 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6450 test_zuc_hash_generate_test_case_5(void)
6452 return test_zuc_authentication(&zuc_test_auth_5670b);
6456 test_zuc_hash_generate_test_case_6(void)
6458 return test_zuc_authentication(&zuc_test_case_auth_128b);
6462 test_zuc_hash_generate_test_case_7(void)
6464 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6468 test_zuc_hash_generate_test_case_8(void)
6470 return test_zuc_authentication(&zuc_test_case_auth_584b);
6474 test_zuc_cipher_auth_test_case_1(void)
6476 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6480 test_zuc_cipher_auth_test_case_2(void)
6482 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6486 test_zuc_auth_cipher_test_case_1(void)
6488 return test_zuc_auth_cipher(
6489 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6493 test_zuc_auth_cipher_test_case_1_oop(void)
6495 return test_zuc_auth_cipher(
6496 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6500 test_zuc_auth_cipher_test_case_1_sgl(void)
6502 return test_zuc_auth_cipher_sgl(
6503 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6507 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6509 return test_zuc_auth_cipher_sgl(
6510 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6514 test_zuc_auth_cipher_verify_test_case_1(void)
6516 return test_zuc_auth_cipher(
6517 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6521 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6523 return test_zuc_auth_cipher(
6524 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6528 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6530 return test_zuc_auth_cipher_sgl(
6531 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6535 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6537 return test_zuc_auth_cipher_sgl(
6538 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6542 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6544 uint8_t dev_id = testsuite_params.valid_devs[0];
6546 struct rte_cryptodev_sym_capability_idx cap_idx;
6548 /* Check if device supports particular cipher algorithm */
6549 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6550 cap_idx.algo.cipher = tdata->cipher_algo;
6551 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6554 /* Check if device supports particular hash algorithm */
6555 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6556 cap_idx.algo.auth = tdata->auth_algo;
6557 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6564 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6565 uint8_t op_mode, uint8_t verify)
6567 struct crypto_testsuite_params *ts_params = &testsuite_params;
6568 struct crypto_unittest_params *ut_params = &unittest_params;
6572 uint8_t *plaintext = NULL, *ciphertext = NULL;
6573 unsigned int plaintext_pad_len;
6574 unsigned int plaintext_len;
6575 unsigned int ciphertext_pad_len;
6576 unsigned int ciphertext_len;
6578 struct rte_cryptodev_info dev_info;
6580 /* Check if device supports particular algorithms */
6581 if (test_mixed_check_if_unsupported(tdata))
6584 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6586 uint64_t feat_flags = dev_info.feature_flags;
6588 if (op_mode == OUT_OF_PLACE) {
6589 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6590 printf("Device doesn't support digest encrypted.\n");
6595 /* Create the session */
6596 retval = create_wireless_algo_auth_cipher_session(
6597 ts_params->valid_devs[0],
6598 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6599 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6600 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6601 : RTE_CRYPTO_AUTH_OP_GENERATE),
6604 tdata->auth_key.data, tdata->auth_key.len,
6605 tdata->auth_iv.len, tdata->digest_enc.len,
6606 tdata->cipher_iv.len);
6611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6612 if (op_mode == OUT_OF_PLACE)
6613 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6615 /* clear mbuf payload */
6616 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6617 rte_pktmbuf_tailroom(ut_params->ibuf));
6618 if (op_mode == OUT_OF_PLACE)
6619 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6620 rte_pktmbuf_tailroom(ut_params->obuf));
6622 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6623 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6624 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6625 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6628 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6629 ciphertext_pad_len);
6630 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6631 if (op_mode == OUT_OF_PLACE)
6632 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6633 debug_hexdump(stdout, "ciphertext:", ciphertext,
6636 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6638 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6639 if (op_mode == OUT_OF_PLACE)
6640 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6641 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6644 /* Create the operation */
6645 retval = create_wireless_algo_auth_cipher_operation(
6646 tdata->digest_enc.len,
6647 tdata->cipher_iv.data, tdata->cipher_iv.len,
6648 tdata->auth_iv.data, tdata->auth_iv.len,
6649 (tdata->digest_enc.offset == 0 ?
6650 (verify ? ciphertext_pad_len : plaintext_pad_len)
6651 : tdata->digest_enc.offset),
6652 tdata->validCipherLen.len_bits,
6653 tdata->cipher.offset_bits,
6654 tdata->validAuthLen.len_bits,
6655 tdata->auth.offset_bits,
6661 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6666 ut_params->obuf = (op_mode == IN_PLACE ?
6667 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6670 if (ut_params->obuf)
6671 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6674 plaintext = ciphertext +
6675 (tdata->cipher.offset_bits >> 3);
6677 debug_hexdump(stdout, "plaintext:", plaintext,
6678 (tdata->plaintext.len_bits >> 3) -
6679 tdata->digest_enc.len);
6680 debug_hexdump(stdout, "plaintext expected:",
6681 tdata->plaintext.data,
6682 (tdata->plaintext.len_bits >> 3) -
6683 tdata->digest_enc.len);
6685 if (ut_params->obuf)
6686 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6689 ciphertext = plaintext;
6691 debug_hexdump(stdout, "ciphertext:", ciphertext,
6693 debug_hexdump(stdout, "ciphertext expected:",
6694 tdata->ciphertext.data,
6695 tdata->ciphertext.len_bits >> 3);
6697 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6698 + (tdata->digest_enc.offset == 0 ?
6699 plaintext_pad_len : tdata->digest_enc.offset);
6701 debug_hexdump(stdout, "digest:", ut_params->digest,
6702 tdata->digest_enc.len);
6703 debug_hexdump(stdout, "digest expected:",
6704 tdata->digest_enc.data,
6705 tdata->digest_enc.len);
6710 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6712 tdata->plaintext.data,
6713 tdata->plaintext.len_bits >> 3,
6714 "Plaintext data not as expected");
6716 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6718 tdata->ciphertext.data,
6719 tdata->validDataLen.len_bits,
6720 "Ciphertext data not as expected");
6722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6724 tdata->digest_enc.data,
6725 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6726 "Generated auth tag not as expected");
6732 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6733 uint8_t op_mode, uint8_t verify)
6735 struct crypto_testsuite_params *ts_params = &testsuite_params;
6736 struct crypto_unittest_params *ut_params = &unittest_params;
6740 const uint8_t *plaintext = NULL;
6741 const uint8_t *ciphertext = NULL;
6742 const uint8_t *digest = NULL;
6743 unsigned int plaintext_pad_len;
6744 unsigned int plaintext_len;
6745 unsigned int ciphertext_pad_len;
6746 unsigned int ciphertext_len;
6747 uint8_t buffer[10000];
6748 uint8_t digest_buffer[10000];
6750 struct rte_cryptodev_info dev_info;
6752 /* Check if device supports particular algorithms */
6753 if (test_mixed_check_if_unsupported(tdata))
6756 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6758 uint64_t feat_flags = dev_info.feature_flags;
6760 if (op_mode == IN_PLACE) {
6761 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6762 printf("Device doesn't support in-place scatter-gather "
6763 "in both input and output mbufs.\n");
6767 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6768 printf("Device doesn't support out-of-place scatter-gather "
6769 "in both input and output mbufs.\n");
6772 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6773 printf("Device doesn't support digest encrypted.\n");
6778 /* Create the session */
6779 retval = create_wireless_algo_auth_cipher_session(
6780 ts_params->valid_devs[0],
6781 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6782 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6783 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6784 : RTE_CRYPTO_AUTH_OP_GENERATE),
6787 tdata->auth_key.data, tdata->auth_key.len,
6788 tdata->auth_iv.len, tdata->digest_enc.len,
6789 tdata->cipher_iv.len);
6794 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6795 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6796 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6797 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6799 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6800 plaintext_pad_len, 15, 0);
6801 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6802 "Failed to allocate input buffer in mempool");
6804 if (op_mode == OUT_OF_PLACE) {
6805 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6806 plaintext_pad_len, 15, 0);
6807 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6808 "Failed to allocate output buffer in mempool");
6812 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6813 tdata->ciphertext.data);
6814 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6815 ciphertext_len, buffer);
6816 debug_hexdump(stdout, "ciphertext:", ciphertext,
6819 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6820 tdata->plaintext.data);
6821 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6822 plaintext_len, buffer);
6823 debug_hexdump(stdout, "plaintext:", plaintext,
6826 memset(buffer, 0, sizeof(buffer));
6828 /* Create the operation */
6829 retval = create_wireless_algo_auth_cipher_operation(
6830 tdata->digest_enc.len,
6831 tdata->cipher_iv.data, tdata->cipher_iv.len,
6832 tdata->auth_iv.data, tdata->auth_iv.len,
6833 (tdata->digest_enc.offset == 0 ?
6834 (verify ? ciphertext_pad_len : plaintext_pad_len)
6835 : tdata->digest_enc.offset),
6836 tdata->validCipherLen.len_bits,
6837 tdata->cipher.offset_bits,
6838 tdata->validAuthLen.len_bits,
6839 tdata->auth.offset_bits,
6845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6848 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6850 ut_params->obuf = (op_mode == IN_PLACE ?
6851 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6854 if (ut_params->obuf)
6855 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6856 plaintext_len, buffer);
6858 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6859 plaintext_len, buffer);
6861 debug_hexdump(stdout, "plaintext:", plaintext,
6862 (tdata->plaintext.len_bits >> 3) -
6863 tdata->digest_enc.len);
6864 debug_hexdump(stdout, "plaintext expected:",
6865 tdata->plaintext.data,
6866 (tdata->plaintext.len_bits >> 3) -
6867 tdata->digest_enc.len);
6869 if (ut_params->obuf)
6870 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6871 ciphertext_len, buffer);
6873 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6874 ciphertext_len, buffer);
6876 debug_hexdump(stdout, "ciphertext:", ciphertext,
6878 debug_hexdump(stdout, "ciphertext expected:",
6879 tdata->ciphertext.data,
6880 tdata->ciphertext.len_bits >> 3);
6882 if (ut_params->obuf)
6883 digest = rte_pktmbuf_read(ut_params->obuf,
6884 (tdata->digest_enc.offset == 0 ?
6886 tdata->digest_enc.offset),
6887 tdata->digest_enc.len, digest_buffer);
6889 digest = rte_pktmbuf_read(ut_params->ibuf,
6890 (tdata->digest_enc.offset == 0 ?
6892 tdata->digest_enc.offset),
6893 tdata->digest_enc.len, digest_buffer);
6895 debug_hexdump(stdout, "digest:", digest,
6896 tdata->digest_enc.len);
6897 debug_hexdump(stdout, "digest expected:",
6898 tdata->digest_enc.data, tdata->digest_enc.len);
6903 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6905 tdata->plaintext.data,
6906 tdata->plaintext.len_bits >> 3,
6907 "Plaintext data not as expected");
6909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6911 tdata->ciphertext.data,
6912 tdata->validDataLen.len_bits,
6913 "Ciphertext data not as expected");
6914 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6916 tdata->digest_enc.data,
6917 tdata->digest_enc.len,
6918 "Generated auth tag not as expected");
6923 /** AUTH AES CMAC + CIPHER AES CTR */
6926 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6928 return test_mixed_auth_cipher(
6929 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6933 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6935 return test_mixed_auth_cipher(
6936 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6940 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6942 return test_mixed_auth_cipher_sgl(
6943 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6947 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6949 return test_mixed_auth_cipher_sgl(
6950 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6954 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6956 return test_mixed_auth_cipher(
6957 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6961 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6963 return test_mixed_auth_cipher(
6964 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6968 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6970 return test_mixed_auth_cipher_sgl(
6971 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6975 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6977 return test_mixed_auth_cipher_sgl(
6978 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6982 test_3DES_chain_qat_all(void)
6984 struct crypto_testsuite_params *ts_params = &testsuite_params;
6987 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6988 ts_params->op_mpool,
6989 ts_params->session_mpool, ts_params->session_priv_mpool,
6990 ts_params->valid_devs[0],
6991 rte_cryptodev_driver_id_get(
6992 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6993 BLKCIPHER_3DES_CHAIN_TYPE);
6995 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6997 return TEST_SUCCESS;
7001 test_DES_cipheronly_qat_all(void)
7003 struct crypto_testsuite_params *ts_params = &testsuite_params;
7006 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7007 ts_params->op_mpool,
7008 ts_params->session_mpool, ts_params->session_priv_mpool,
7009 ts_params->valid_devs[0],
7010 rte_cryptodev_driver_id_get(
7011 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7012 BLKCIPHER_DES_CIPHERONLY_TYPE);
7014 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7016 return TEST_SUCCESS;
7020 test_DES_cipheronly_openssl_all(void)
7022 struct crypto_testsuite_params *ts_params = &testsuite_params;
7025 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7026 ts_params->op_mpool,
7027 ts_params->session_mpool, ts_params->session_priv_mpool,
7028 ts_params->valid_devs[0],
7029 rte_cryptodev_driver_id_get(
7030 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7031 BLKCIPHER_DES_CIPHERONLY_TYPE);
7033 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7035 return TEST_SUCCESS;
7039 test_DES_docsis_openssl_all(void)
7041 struct crypto_testsuite_params *ts_params = &testsuite_params;
7044 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7045 ts_params->op_mpool,
7046 ts_params->session_mpool, ts_params->session_priv_mpool,
7047 ts_params->valid_devs[0],
7048 rte_cryptodev_driver_id_get(
7049 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7050 BLKCIPHER_DES_DOCSIS_TYPE);
7052 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7054 return TEST_SUCCESS;
7058 test_DES_cipheronly_mb_all(void)
7060 struct crypto_testsuite_params *ts_params = &testsuite_params;
7063 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7064 ts_params->op_mpool,
7065 ts_params->session_mpool, ts_params->session_priv_mpool,
7066 ts_params->valid_devs[0],
7067 rte_cryptodev_driver_id_get(
7068 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7069 BLKCIPHER_DES_CIPHERONLY_TYPE);
7071 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7073 return TEST_SUCCESS;
7076 test_3DES_cipheronly_mb_all(void)
7078 struct crypto_testsuite_params *ts_params = &testsuite_params;
7081 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7082 ts_params->op_mpool,
7083 ts_params->session_mpool, ts_params->session_priv_mpool,
7084 ts_params->valid_devs[0],
7085 rte_cryptodev_driver_id_get(
7086 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7087 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7089 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7091 return TEST_SUCCESS;
7095 test_DES_docsis_mb_all(void)
7097 struct crypto_testsuite_params *ts_params = &testsuite_params;
7100 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7101 ts_params->op_mpool,
7102 ts_params->session_mpool, ts_params->session_priv_mpool,
7103 ts_params->valid_devs[0],
7104 rte_cryptodev_driver_id_get(
7105 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7106 BLKCIPHER_DES_DOCSIS_TYPE);
7108 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7110 return TEST_SUCCESS;
7114 test_3DES_chain_caam_jr_all(void)
7116 struct crypto_testsuite_params *ts_params = &testsuite_params;
7119 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7120 ts_params->op_mpool,
7121 ts_params->session_mpool, ts_params->session_priv_mpool,
7122 ts_params->valid_devs[0],
7123 rte_cryptodev_driver_id_get(
7124 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7125 BLKCIPHER_3DES_CHAIN_TYPE);
7127 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7129 return TEST_SUCCESS;
7133 test_3DES_cipheronly_caam_jr_all(void)
7135 struct crypto_testsuite_params *ts_params = &testsuite_params;
7138 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7139 ts_params->op_mpool,
7140 ts_params->session_mpool, ts_params->session_priv_mpool,
7141 ts_params->valid_devs[0],
7142 rte_cryptodev_driver_id_get(
7143 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7144 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7146 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7148 return TEST_SUCCESS;
7152 test_3DES_chain_dpaa_sec_all(void)
7154 struct crypto_testsuite_params *ts_params = &testsuite_params;
7157 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7158 ts_params->op_mpool,
7159 ts_params->session_mpool, ts_params->session_priv_mpool,
7160 ts_params->valid_devs[0],
7161 rte_cryptodev_driver_id_get(
7162 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7163 BLKCIPHER_3DES_CHAIN_TYPE);
7165 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7167 return TEST_SUCCESS;
7171 test_3DES_cipheronly_dpaa_sec_all(void)
7173 struct crypto_testsuite_params *ts_params = &testsuite_params;
7176 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7177 ts_params->op_mpool,
7178 ts_params->session_mpool, ts_params->session_priv_mpool,
7179 ts_params->valid_devs[0],
7180 rte_cryptodev_driver_id_get(
7181 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7182 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7184 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7186 return TEST_SUCCESS;
7190 test_3DES_chain_dpaa2_sec_all(void)
7192 struct crypto_testsuite_params *ts_params = &testsuite_params;
7195 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7196 ts_params->op_mpool,
7197 ts_params->session_mpool, ts_params->session_priv_mpool,
7198 ts_params->valid_devs[0],
7199 rte_cryptodev_driver_id_get(
7200 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7201 BLKCIPHER_3DES_CHAIN_TYPE);
7203 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7205 return TEST_SUCCESS;
7209 test_3DES_cipheronly_dpaa2_sec_all(void)
7211 struct crypto_testsuite_params *ts_params = &testsuite_params;
7214 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7215 ts_params->op_mpool,
7216 ts_params->session_mpool, ts_params->session_priv_mpool,
7217 ts_params->valid_devs[0],
7218 rte_cryptodev_driver_id_get(
7219 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7220 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7222 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7224 return TEST_SUCCESS;
7228 test_3DES_chain_ccp_all(void)
7230 struct crypto_testsuite_params *ts_params = &testsuite_params;
7233 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7234 ts_params->op_mpool,
7235 ts_params->session_mpool, ts_params->session_priv_mpool,
7236 ts_params->valid_devs[0],
7237 rte_cryptodev_driver_id_get(
7238 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7239 BLKCIPHER_3DES_CHAIN_TYPE);
7241 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7243 return TEST_SUCCESS;
7247 test_3DES_cipheronly_ccp_all(void)
7249 struct crypto_testsuite_params *ts_params = &testsuite_params;
7252 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7253 ts_params->op_mpool,
7254 ts_params->session_mpool, ts_params->session_priv_mpool,
7255 ts_params->valid_devs[0],
7256 rte_cryptodev_driver_id_get(
7257 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7258 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7260 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7262 return TEST_SUCCESS;
7266 test_3DES_cipheronly_qat_all(void)
7268 struct crypto_testsuite_params *ts_params = &testsuite_params;
7271 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7272 ts_params->op_mpool,
7273 ts_params->session_mpool, ts_params->session_priv_mpool,
7274 ts_params->valid_devs[0],
7275 rte_cryptodev_driver_id_get(
7276 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7277 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7279 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7281 return TEST_SUCCESS;
7285 test_3DES_chain_openssl_all(void)
7287 struct crypto_testsuite_params *ts_params = &testsuite_params;
7290 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7291 ts_params->op_mpool,
7292 ts_params->session_mpool, ts_params->session_priv_mpool,
7293 ts_params->valid_devs[0],
7294 rte_cryptodev_driver_id_get(
7295 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7296 BLKCIPHER_3DES_CHAIN_TYPE);
7298 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7300 return TEST_SUCCESS;
7304 test_3DES_cipheronly_openssl_all(void)
7306 struct crypto_testsuite_params *ts_params = &testsuite_params;
7309 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7310 ts_params->op_mpool,
7311 ts_params->session_mpool, ts_params->session_priv_mpool,
7312 ts_params->valid_devs[0],
7313 rte_cryptodev_driver_id_get(
7314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7315 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7317 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7319 return TEST_SUCCESS;
7322 /* ***** AEAD algorithm Tests ***** */
7325 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7326 enum rte_crypto_aead_operation op,
7327 const uint8_t *key, const uint8_t key_len,
7328 const uint16_t aad_len, const uint8_t auth_len,
7331 uint8_t aead_key[key_len];
7333 struct crypto_testsuite_params *ts_params = &testsuite_params;
7334 struct crypto_unittest_params *ut_params = &unittest_params;
7336 memcpy(aead_key, key, key_len);
7338 /* Setup AEAD Parameters */
7339 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7340 ut_params->aead_xform.next = NULL;
7341 ut_params->aead_xform.aead.algo = algo;
7342 ut_params->aead_xform.aead.op = op;
7343 ut_params->aead_xform.aead.key.data = aead_key;
7344 ut_params->aead_xform.aead.key.length = key_len;
7345 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7346 ut_params->aead_xform.aead.iv.length = iv_len;
7347 ut_params->aead_xform.aead.digest_length = auth_len;
7348 ut_params->aead_xform.aead.aad_length = aad_len;
7350 debug_hexdump(stdout, "key:", key, key_len);
7352 /* Create Crypto session*/
7353 ut_params->sess = rte_cryptodev_sym_session_create(
7354 ts_params->session_mpool);
7356 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7357 &ut_params->aead_xform,
7358 ts_params->session_priv_mpool);
7360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7366 create_aead_xform(struct rte_crypto_op *op,
7367 enum rte_crypto_aead_algorithm algo,
7368 enum rte_crypto_aead_operation aead_op,
7369 uint8_t *key, const uint8_t key_len,
7370 const uint8_t aad_len, const uint8_t auth_len,
7373 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7374 "failed to allocate space for crypto transform");
7376 struct rte_crypto_sym_op *sym_op = op->sym;
7378 /* Setup AEAD Parameters */
7379 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7380 sym_op->xform->next = NULL;
7381 sym_op->xform->aead.algo = algo;
7382 sym_op->xform->aead.op = aead_op;
7383 sym_op->xform->aead.key.data = key;
7384 sym_op->xform->aead.key.length = key_len;
7385 sym_op->xform->aead.iv.offset = IV_OFFSET;
7386 sym_op->xform->aead.iv.length = iv_len;
7387 sym_op->xform->aead.digest_length = auth_len;
7388 sym_op->xform->aead.aad_length = aad_len;
7390 debug_hexdump(stdout, "key:", key, key_len);
7396 create_aead_operation(enum rte_crypto_aead_operation op,
7397 const struct aead_test_data *tdata)
7399 struct crypto_testsuite_params *ts_params = &testsuite_params;
7400 struct crypto_unittest_params *ut_params = &unittest_params;
7402 uint8_t *plaintext, *ciphertext;
7403 unsigned int aad_pad_len, plaintext_pad_len;
7405 /* Generate Crypto op data structure */
7406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7408 TEST_ASSERT_NOT_NULL(ut_params->op,
7409 "Failed to allocate symmetric crypto operation struct");
7411 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7413 /* Append aad data */
7414 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7415 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7416 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7418 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7419 "no room to append aad");
7421 sym_op->aead.aad.phys_addr =
7422 rte_pktmbuf_iova(ut_params->ibuf);
7423 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7424 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7425 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7428 /* Append IV at the end of the crypto operation*/
7429 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7430 uint8_t *, IV_OFFSET);
7432 /* Copy IV 1 byte after the IV pointer, according to the API */
7433 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7434 debug_hexdump(stdout, "iv:", iv_ptr,
7437 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7438 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7440 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7441 "no room to append aad");
7443 sym_op->aead.aad.phys_addr =
7444 rte_pktmbuf_iova(ut_params->ibuf);
7445 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7446 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7449 /* Append IV at the end of the crypto operation*/
7450 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7451 uint8_t *, IV_OFFSET);
7453 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7454 debug_hexdump(stdout, "iv:", iv_ptr,
7458 /* Append plaintext/ciphertext */
7459 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7460 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7461 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7463 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7465 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7466 debug_hexdump(stdout, "plaintext:", plaintext,
7467 tdata->plaintext.len);
7469 if (ut_params->obuf) {
7470 ciphertext = (uint8_t *)rte_pktmbuf_append(
7472 plaintext_pad_len + aad_pad_len);
7473 TEST_ASSERT_NOT_NULL(ciphertext,
7474 "no room to append ciphertext");
7476 memset(ciphertext + aad_pad_len, 0,
7477 tdata->ciphertext.len);
7480 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7481 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7483 TEST_ASSERT_NOT_NULL(ciphertext,
7484 "no room to append ciphertext");
7486 memcpy(ciphertext, tdata->ciphertext.data,
7487 tdata->ciphertext.len);
7488 debug_hexdump(stdout, "ciphertext:", ciphertext,
7489 tdata->ciphertext.len);
7491 if (ut_params->obuf) {
7492 plaintext = (uint8_t *)rte_pktmbuf_append(
7494 plaintext_pad_len + aad_pad_len);
7495 TEST_ASSERT_NOT_NULL(plaintext,
7496 "no room to append plaintext");
7498 memset(plaintext + aad_pad_len, 0,
7499 tdata->plaintext.len);
7503 /* Append digest data */
7504 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7505 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7506 ut_params->obuf ? ut_params->obuf :
7508 tdata->auth_tag.len);
7509 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7510 "no room to append digest");
7511 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7512 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7513 ut_params->obuf ? ut_params->obuf :
7518 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7519 ut_params->ibuf, tdata->auth_tag.len);
7520 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7521 "no room to append digest");
7522 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7524 plaintext_pad_len + aad_pad_len);
7526 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7527 tdata->auth_tag.len);
7528 debug_hexdump(stdout, "digest:",
7529 sym_op->aead.digest.data,
7530 tdata->auth_tag.len);
7533 sym_op->aead.data.length = tdata->plaintext.len;
7534 sym_op->aead.data.offset = aad_pad_len;
7540 test_authenticated_encryption(const struct aead_test_data *tdata)
7542 struct crypto_testsuite_params *ts_params = &testsuite_params;
7543 struct crypto_unittest_params *ut_params = &unittest_params;
7546 uint8_t *ciphertext, *auth_tag;
7547 uint16_t plaintext_pad_len;
7550 /* Create AEAD session */
7551 retval = create_aead_session(ts_params->valid_devs[0],
7553 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7554 tdata->key.data, tdata->key.len,
7555 tdata->aad.len, tdata->auth_tag.len,
7560 if (tdata->aad.len > MBUF_SIZE) {
7561 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7562 /* Populate full size of add data */
7563 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7564 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7568 /* clear mbuf payload */
7569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7570 rte_pktmbuf_tailroom(ut_params->ibuf));
7572 /* Create AEAD operation */
7573 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7577 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7579 ut_params->op->sym->m_src = ut_params->ibuf;
7581 /* Process crypto operation */
7582 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7583 ut_params->op), "failed to process sym crypto op");
7585 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7586 "crypto op processing failed");
7588 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7590 if (ut_params->op->sym->m_dst) {
7591 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7593 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7594 uint8_t *, plaintext_pad_len);
7596 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7598 ut_params->op->sym->cipher.data.offset);
7599 auth_tag = ciphertext + plaintext_pad_len;
7602 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7603 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7606 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7608 tdata->ciphertext.data,
7609 tdata->ciphertext.len,
7610 "Ciphertext data not as expected");
7612 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7614 tdata->auth_tag.data,
7615 tdata->auth_tag.len,
7616 "Generated auth tag not as expected");
7622 #ifdef RTE_LIBRTE_SECURITY
7623 /* Basic algorithm run function for async inplace mode.
7624 * Creates a session from input parameters and runs one operation
7625 * on input_vec. Checks the output of the crypto operation against
7629 test_pdcp_proto(int i, int oop,
7630 enum rte_crypto_cipher_operation opc,
7631 enum rte_crypto_auth_operation opa,
7633 unsigned int input_vec_len,
7634 uint8_t *output_vec,
7635 unsigned int output_vec_len)
7637 struct crypto_testsuite_params *ts_params = &testsuite_params;
7638 struct crypto_unittest_params *ut_params = &unittest_params;
7640 int ret = TEST_SUCCESS;
7642 /* Generate test mbuf data */
7643 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7645 /* clear mbuf payload */
7646 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7647 rte_pktmbuf_tailroom(ut_params->ibuf));
7649 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7651 memcpy(plaintext, input_vec, input_vec_len);
7653 /* Out of place support */
7656 * For out-op-place we need to alloc another mbuf
7658 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7659 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7662 /* Set crypto type as IPSEC */
7663 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7665 /* Setup Cipher Parameters */
7666 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7667 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7668 ut_params->cipher_xform.cipher.op = opc;
7669 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7670 ut_params->cipher_xform.cipher.key.length =
7671 pdcp_test_params[i].cipher_key_len;
7672 ut_params->cipher_xform.cipher.iv.length = 0;
7674 /* Setup HMAC Parameters if ICV header is required */
7675 if (pdcp_test_params[i].auth_alg != 0) {
7676 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7677 ut_params->auth_xform.next = NULL;
7678 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7679 ut_params->auth_xform.auth.op = opa;
7680 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7681 ut_params->auth_xform.auth.key.length =
7682 pdcp_test_params[i].auth_key_len;
7684 ut_params->cipher_xform.next = &ut_params->auth_xform;
7686 ut_params->cipher_xform.next = NULL;
7689 struct rte_security_session_conf sess_conf = {
7690 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7691 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7693 .bearer = pdcp_test_bearer[i],
7694 .domain = pdcp_test_params[i].domain,
7695 .pkt_dir = pdcp_test_packet_direction[i],
7696 .sn_size = pdcp_test_data_sn_size[i],
7697 .hfn = pdcp_test_hfn[i],
7698 .hfn_threshold = pdcp_test_hfn_threshold[i],
7700 .crypto_xform = &ut_params->cipher_xform
7703 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7704 rte_cryptodev_get_sec_ctx(
7705 ts_params->valid_devs[0]);
7707 /* Create security session */
7708 ut_params->sec_session = rte_security_session_create(ctx,
7709 &sess_conf, ts_params->session_priv_mpool);
7711 if (!ut_params->sec_session) {
7712 printf("TestCase %s()-%d line %d failed %s: ",
7713 __func__, i, __LINE__, "Failed to allocate session");
7718 /* Generate crypto op data structure */
7719 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7720 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7721 if (!ut_params->op) {
7722 printf("TestCase %s()-%d line %d failed %s: ",
7723 __func__, i, __LINE__,
7724 "Failed to allocate symmetric crypto operation struct");
7729 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7731 /* set crypto operation source mbuf */
7732 ut_params->op->sym->m_src = ut_params->ibuf;
7734 ut_params->op->sym->m_dst = ut_params->obuf;
7736 /* Process crypto operation */
7737 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7739 printf("TestCase %s()-%d line %d failed %s: ",
7740 __func__, i, __LINE__,
7741 "failed to process sym crypto op");
7746 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7747 printf("TestCase %s()-%d line %d failed %s: ",
7748 __func__, i, __LINE__, "crypto op processing failed");
7754 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7757 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7761 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7762 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7763 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7764 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7770 rte_crypto_op_free(ut_params->op);
7771 ut_params->op = NULL;
7773 if (ut_params->sec_session)
7774 rte_security_session_destroy(ctx, ut_params->sec_session);
7775 ut_params->sec_session = NULL;
7777 rte_pktmbuf_free(ut_params->ibuf);
7778 ut_params->ibuf = NULL;
7780 rte_pktmbuf_free(ut_params->obuf);
7781 ut_params->obuf = NULL;
7788 test_pdcp_proto_SGL(int i, int oop,
7789 enum rte_crypto_cipher_operation opc,
7790 enum rte_crypto_auth_operation opa,
7792 unsigned int input_vec_len,
7793 uint8_t *output_vec,
7794 unsigned int output_vec_len,
7796 uint32_t fragsz_oop)
7798 struct crypto_testsuite_params *ts_params = &testsuite_params;
7799 struct crypto_unittest_params *ut_params = &unittest_params;
7801 struct rte_mbuf *buf, *buf_oop = NULL;
7802 int ret = TEST_SUCCESS;
7806 unsigned int trn_data = 0;
7808 if (fragsz > input_vec_len)
7809 fragsz = input_vec_len;
7811 uint16_t plaintext_len = fragsz;
7812 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7814 if (fragsz_oop > output_vec_len)
7815 frag_size_oop = output_vec_len;
7818 if (input_vec_len % fragsz != 0) {
7819 if (input_vec_len / fragsz + 1 > 16)
7821 } else if (input_vec_len / fragsz > 16)
7824 /* Out of place support */
7827 * For out-op-place we need to alloc another mbuf
7829 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7830 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7831 buf_oop = ut_params->obuf;
7834 /* Generate test mbuf data */
7835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7837 /* clear mbuf payload */
7838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7839 rte_pktmbuf_tailroom(ut_params->ibuf));
7841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7843 memcpy(plaintext, input_vec, plaintext_len);
7844 trn_data += plaintext_len;
7846 buf = ut_params->ibuf;
7849 * Loop until no more fragments
7852 while (trn_data < input_vec_len) {
7854 to_trn = (input_vec_len - trn_data < fragsz) ?
7855 (input_vec_len - trn_data) : fragsz;
7857 to_trn_tbl[ecx++] = to_trn;
7859 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7862 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7863 rte_pktmbuf_tailroom(buf));
7866 if (oop && !fragsz_oop) {
7868 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7869 buf_oop = buf_oop->next;
7870 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7871 0, rte_pktmbuf_tailroom(buf_oop));
7872 rte_pktmbuf_append(buf_oop, to_trn);
7875 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7878 memcpy(plaintext, input_vec + trn_data, to_trn);
7882 ut_params->ibuf->nb_segs = segs;
7885 if (fragsz_oop && oop) {
7889 trn_data = frag_size_oop;
7890 while (trn_data < output_vec_len) {
7893 (output_vec_len - trn_data <
7895 (output_vec_len - trn_data) :
7898 to_trn_tbl[ecx++] = to_trn;
7901 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7902 buf_oop = buf_oop->next;
7903 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7904 0, rte_pktmbuf_tailroom(buf_oop));
7905 rte_pktmbuf_append(buf_oop, to_trn);
7909 ut_params->obuf->nb_segs = segs;
7912 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7914 /* Setup Cipher Parameters */
7915 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7916 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7917 ut_params->cipher_xform.cipher.op = opc;
7918 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7919 ut_params->cipher_xform.cipher.key.length =
7920 pdcp_test_params[i].cipher_key_len;
7921 ut_params->cipher_xform.cipher.iv.length = 0;
7923 /* Setup HMAC Parameters if ICV header is required */
7924 if (pdcp_test_params[i].auth_alg != 0) {
7925 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7926 ut_params->auth_xform.next = NULL;
7927 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7928 ut_params->auth_xform.auth.op = opa;
7929 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7930 ut_params->auth_xform.auth.key.length =
7931 pdcp_test_params[i].auth_key_len;
7933 ut_params->cipher_xform.next = &ut_params->auth_xform;
7935 ut_params->cipher_xform.next = NULL;
7938 struct rte_security_session_conf sess_conf = {
7939 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7940 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7942 .bearer = pdcp_test_bearer[i],
7943 .domain = pdcp_test_params[i].domain,
7944 .pkt_dir = pdcp_test_packet_direction[i],
7945 .sn_size = pdcp_test_data_sn_size[i],
7946 .hfn = pdcp_test_hfn[i],
7947 .hfn_threshold = pdcp_test_hfn_threshold[i],
7949 .crypto_xform = &ut_params->cipher_xform
7952 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7953 rte_cryptodev_get_sec_ctx(
7954 ts_params->valid_devs[0]);
7956 /* Create security session */
7957 ut_params->sec_session = rte_security_session_create(ctx,
7958 &sess_conf, ts_params->session_priv_mpool);
7960 if (!ut_params->sec_session) {
7961 printf("TestCase %s()-%d line %d failed %s: ",
7962 __func__, i, __LINE__, "Failed to allocate session");
7967 /* Generate crypto op data structure */
7968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7970 if (!ut_params->op) {
7971 printf("TestCase %s()-%d line %d failed %s: ",
7972 __func__, i, __LINE__,
7973 "Failed to allocate symmetric crypto operation struct");
7978 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7980 /* set crypto operation source mbuf */
7981 ut_params->op->sym->m_src = ut_params->ibuf;
7983 ut_params->op->sym->m_dst = ut_params->obuf;
7985 /* Process crypto operation */
7986 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7988 printf("TestCase %s()-%d line %d failed %s: ",
7989 __func__, i, __LINE__,
7990 "failed to process sym crypto op");
7995 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7996 printf("TestCase %s()-%d line %d failed %s: ",
7997 __func__, i, __LINE__, "crypto op processing failed");
8003 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8006 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8010 fragsz = frag_size_oop;
8011 if (memcmp(ciphertext, output_vec, fragsz)) {
8012 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8013 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8014 rte_hexdump(stdout, "reference", output_vec, fragsz);
8019 buf = ut_params->op->sym->m_src->next;
8021 buf = ut_params->op->sym->m_dst->next;
8023 unsigned int off = fragsz;
8027 ciphertext = rte_pktmbuf_mtod(buf,
8029 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8030 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8031 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8032 rte_hexdump(stdout, "reference", output_vec + off,
8037 off += to_trn_tbl[ecx++];
8041 rte_crypto_op_free(ut_params->op);
8042 ut_params->op = NULL;
8044 if (ut_params->sec_session)
8045 rte_security_session_destroy(ctx, ut_params->sec_session);
8046 ut_params->sec_session = NULL;
8048 rte_pktmbuf_free(ut_params->ibuf);
8049 ut_params->ibuf = NULL;
8051 rte_pktmbuf_free(ut_params->obuf);
8052 ut_params->obuf = NULL;
8059 test_pdcp_proto_cplane_encap(int i)
8061 return test_pdcp_proto(i, 0,
8062 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8063 RTE_CRYPTO_AUTH_OP_GENERATE,
8064 pdcp_test_data_in[i],
8065 pdcp_test_data_in_len[i],
8066 pdcp_test_data_out[i],
8067 pdcp_test_data_in_len[i]+4);
8071 test_pdcp_proto_uplane_encap(int i)
8073 return test_pdcp_proto(i, 0,
8074 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8075 RTE_CRYPTO_AUTH_OP_GENERATE,
8076 pdcp_test_data_in[i],
8077 pdcp_test_data_in_len[i],
8078 pdcp_test_data_out[i],
8079 pdcp_test_data_in_len[i]);
8084 test_pdcp_proto_uplane_encap_with_int(int i)
8086 return test_pdcp_proto(i, 0,
8087 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8088 RTE_CRYPTO_AUTH_OP_GENERATE,
8089 pdcp_test_data_in[i],
8090 pdcp_test_data_in_len[i],
8091 pdcp_test_data_out[i],
8092 pdcp_test_data_in_len[i] + 4);
8096 test_pdcp_proto_cplane_decap(int i)
8098 return test_pdcp_proto(i, 0,
8099 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8100 RTE_CRYPTO_AUTH_OP_VERIFY,
8101 pdcp_test_data_out[i],
8102 pdcp_test_data_in_len[i] + 4,
8103 pdcp_test_data_in[i],
8104 pdcp_test_data_in_len[i]);
8108 test_pdcp_proto_uplane_decap(int i)
8110 return test_pdcp_proto(i, 0,
8111 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8112 RTE_CRYPTO_AUTH_OP_VERIFY,
8113 pdcp_test_data_out[i],
8114 pdcp_test_data_in_len[i],
8115 pdcp_test_data_in[i],
8116 pdcp_test_data_in_len[i]);
8120 test_pdcp_proto_uplane_decap_with_int(int i)
8122 return test_pdcp_proto(i, 0,
8123 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8124 RTE_CRYPTO_AUTH_OP_VERIFY,
8125 pdcp_test_data_out[i],
8126 pdcp_test_data_in_len[i] + 4,
8127 pdcp_test_data_in[i],
8128 pdcp_test_data_in_len[i]);
8132 test_PDCP_PROTO_SGL_in_place_32B(void)
8134 /* i can be used for running any PDCP case
8135 * In this case it is uplane 12-bit AES-SNOW DL encap
8137 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8138 return test_pdcp_proto_SGL(i, IN_PLACE,
8139 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8140 RTE_CRYPTO_AUTH_OP_GENERATE,
8141 pdcp_test_data_in[i],
8142 pdcp_test_data_in_len[i],
8143 pdcp_test_data_out[i],
8144 pdcp_test_data_in_len[i]+4,
8148 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8150 /* i can be used for running any PDCP case
8151 * In this case it is uplane 18-bit NULL-NULL DL encap
8153 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8154 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8155 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8156 RTE_CRYPTO_AUTH_OP_GENERATE,
8157 pdcp_test_data_in[i],
8158 pdcp_test_data_in_len[i],
8159 pdcp_test_data_out[i],
8160 pdcp_test_data_in_len[i]+4,
8164 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8166 /* i can be used for running any PDCP case
8167 * In this case it is uplane 18-bit AES DL encap
8169 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8171 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8172 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8173 RTE_CRYPTO_AUTH_OP_GENERATE,
8174 pdcp_test_data_in[i],
8175 pdcp_test_data_in_len[i],
8176 pdcp_test_data_out[i],
8177 pdcp_test_data_in_len[i],
8181 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8183 /* i can be used for running any PDCP case
8184 * In this case it is cplane 12-bit AES-ZUC DL encap
8186 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8187 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8188 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8189 RTE_CRYPTO_AUTH_OP_GENERATE,
8190 pdcp_test_data_in[i],
8191 pdcp_test_data_in_len[i],
8192 pdcp_test_data_out[i],
8193 pdcp_test_data_in_len[i]+4,
8199 test_AES_GCM_authenticated_encryption_test_case_1(void)
8201 return test_authenticated_encryption(&gcm_test_case_1);
8205 test_AES_GCM_authenticated_encryption_test_case_2(void)
8207 return test_authenticated_encryption(&gcm_test_case_2);
8211 test_AES_GCM_authenticated_encryption_test_case_3(void)
8213 return test_authenticated_encryption(&gcm_test_case_3);
8217 test_AES_GCM_authenticated_encryption_test_case_4(void)
8219 return test_authenticated_encryption(&gcm_test_case_4);
8223 test_AES_GCM_authenticated_encryption_test_case_5(void)
8225 return test_authenticated_encryption(&gcm_test_case_5);
8229 test_AES_GCM_authenticated_encryption_test_case_6(void)
8231 return test_authenticated_encryption(&gcm_test_case_6);
8235 test_AES_GCM_authenticated_encryption_test_case_7(void)
8237 return test_authenticated_encryption(&gcm_test_case_7);
8241 test_AES_GCM_authenticated_encryption_test_case_8(void)
8243 return test_authenticated_encryption(&gcm_test_case_8);
8247 test_AES_GCM_auth_encryption_test_case_192_1(void)
8249 return test_authenticated_encryption(&gcm_test_case_192_1);
8253 test_AES_GCM_auth_encryption_test_case_192_2(void)
8255 return test_authenticated_encryption(&gcm_test_case_192_2);
8259 test_AES_GCM_auth_encryption_test_case_192_3(void)
8261 return test_authenticated_encryption(&gcm_test_case_192_3);
8265 test_AES_GCM_auth_encryption_test_case_192_4(void)
8267 return test_authenticated_encryption(&gcm_test_case_192_4);
8271 test_AES_GCM_auth_encryption_test_case_192_5(void)
8273 return test_authenticated_encryption(&gcm_test_case_192_5);
8277 test_AES_GCM_auth_encryption_test_case_192_6(void)
8279 return test_authenticated_encryption(&gcm_test_case_192_6);
8283 test_AES_GCM_auth_encryption_test_case_192_7(void)
8285 return test_authenticated_encryption(&gcm_test_case_192_7);
8289 test_AES_GCM_auth_encryption_test_case_256_1(void)
8291 return test_authenticated_encryption(&gcm_test_case_256_1);
8295 test_AES_GCM_auth_encryption_test_case_256_2(void)
8297 return test_authenticated_encryption(&gcm_test_case_256_2);
8301 test_AES_GCM_auth_encryption_test_case_256_3(void)
8303 return test_authenticated_encryption(&gcm_test_case_256_3);
8307 test_AES_GCM_auth_encryption_test_case_256_4(void)
8309 return test_authenticated_encryption(&gcm_test_case_256_4);
8313 test_AES_GCM_auth_encryption_test_case_256_5(void)
8315 return test_authenticated_encryption(&gcm_test_case_256_5);
8319 test_AES_GCM_auth_encryption_test_case_256_6(void)
8321 return test_authenticated_encryption(&gcm_test_case_256_6);
8325 test_AES_GCM_auth_encryption_test_case_256_7(void)
8327 return test_authenticated_encryption(&gcm_test_case_256_7);
8331 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8333 return test_authenticated_encryption(&gcm_test_case_aad_1);
8337 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8339 return test_authenticated_encryption(&gcm_test_case_aad_2);
8343 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8345 struct aead_test_data tdata;
8348 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8349 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8350 tdata.iv.data[0] += 1;
8351 res = test_authenticated_encryption(&tdata);
8352 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8353 return TEST_SUCCESS;
8357 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8359 struct aead_test_data tdata;
8362 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8363 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8364 tdata.plaintext.data[0] += 1;
8365 res = test_authenticated_encryption(&tdata);
8366 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8367 return TEST_SUCCESS;
8371 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8373 struct aead_test_data tdata;
8376 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8377 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8378 tdata.ciphertext.data[0] += 1;
8379 res = test_authenticated_encryption(&tdata);
8380 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8381 return TEST_SUCCESS;
8385 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8387 struct aead_test_data tdata;
8390 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8391 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8393 res = test_authenticated_encryption(&tdata);
8394 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8395 return TEST_SUCCESS;
8399 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8401 struct aead_test_data tdata;
8402 uint8_t aad[gcm_test_case_7.aad.len];
8405 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8406 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8407 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8409 tdata.aad.data = aad;
8410 res = test_authenticated_encryption(&tdata);
8411 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8412 return TEST_SUCCESS;
8416 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8418 struct aead_test_data tdata;
8421 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8422 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8423 tdata.auth_tag.data[0] += 1;
8424 res = test_authenticated_encryption(&tdata);
8425 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8426 return TEST_SUCCESS;
8430 test_authenticated_decryption(const struct aead_test_data *tdata)
8432 struct crypto_testsuite_params *ts_params = &testsuite_params;
8433 struct crypto_unittest_params *ut_params = &unittest_params;
8439 /* Create AEAD session */
8440 retval = create_aead_session(ts_params->valid_devs[0],
8442 RTE_CRYPTO_AEAD_OP_DECRYPT,
8443 tdata->key.data, tdata->key.len,
8444 tdata->aad.len, tdata->auth_tag.len,
8449 /* alloc mbuf and set payload */
8450 if (tdata->aad.len > MBUF_SIZE) {
8451 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8452 /* Populate full size of add data */
8453 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8454 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8459 rte_pktmbuf_tailroom(ut_params->ibuf));
8461 /* Create AEAD operation */
8462 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8466 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8468 ut_params->op->sym->m_src = ut_params->ibuf;
8470 /* Process crypto operation */
8471 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8472 ut_params->op), "failed to process sym crypto op");
8474 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8475 "crypto op processing failed");
8477 if (ut_params->op->sym->m_dst)
8478 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8481 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8483 ut_params->op->sym->cipher.data.offset);
8485 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8490 tdata->plaintext.data,
8491 tdata->plaintext.len,
8492 "Plaintext data not as expected");
8494 TEST_ASSERT_EQUAL(ut_params->op->status,
8495 RTE_CRYPTO_OP_STATUS_SUCCESS,
8496 "Authentication failed");
8502 test_AES_GCM_authenticated_decryption_test_case_1(void)
8504 return test_authenticated_decryption(&gcm_test_case_1);
8508 test_AES_GCM_authenticated_decryption_test_case_2(void)
8510 return test_authenticated_decryption(&gcm_test_case_2);
8514 test_AES_GCM_authenticated_decryption_test_case_3(void)
8516 return test_authenticated_decryption(&gcm_test_case_3);
8520 test_AES_GCM_authenticated_decryption_test_case_4(void)
8522 return test_authenticated_decryption(&gcm_test_case_4);
8526 test_AES_GCM_authenticated_decryption_test_case_5(void)
8528 return test_authenticated_decryption(&gcm_test_case_5);
8532 test_AES_GCM_authenticated_decryption_test_case_6(void)
8534 return test_authenticated_decryption(&gcm_test_case_6);
8538 test_AES_GCM_authenticated_decryption_test_case_7(void)
8540 return test_authenticated_decryption(&gcm_test_case_7);
8544 test_AES_GCM_authenticated_decryption_test_case_8(void)
8546 return test_authenticated_decryption(&gcm_test_case_8);
8550 test_AES_GCM_auth_decryption_test_case_192_1(void)
8552 return test_authenticated_decryption(&gcm_test_case_192_1);
8556 test_AES_GCM_auth_decryption_test_case_192_2(void)
8558 return test_authenticated_decryption(&gcm_test_case_192_2);
8562 test_AES_GCM_auth_decryption_test_case_192_3(void)
8564 return test_authenticated_decryption(&gcm_test_case_192_3);
8568 test_AES_GCM_auth_decryption_test_case_192_4(void)
8570 return test_authenticated_decryption(&gcm_test_case_192_4);
8574 test_AES_GCM_auth_decryption_test_case_192_5(void)
8576 return test_authenticated_decryption(&gcm_test_case_192_5);
8580 test_AES_GCM_auth_decryption_test_case_192_6(void)
8582 return test_authenticated_decryption(&gcm_test_case_192_6);
8586 test_AES_GCM_auth_decryption_test_case_192_7(void)
8588 return test_authenticated_decryption(&gcm_test_case_192_7);
8592 test_AES_GCM_auth_decryption_test_case_256_1(void)
8594 return test_authenticated_decryption(&gcm_test_case_256_1);
8598 test_AES_GCM_auth_decryption_test_case_256_2(void)
8600 return test_authenticated_decryption(&gcm_test_case_256_2);
8604 test_AES_GCM_auth_decryption_test_case_256_3(void)
8606 return test_authenticated_decryption(&gcm_test_case_256_3);
8610 test_AES_GCM_auth_decryption_test_case_256_4(void)
8612 return test_authenticated_decryption(&gcm_test_case_256_4);
8616 test_AES_GCM_auth_decryption_test_case_256_5(void)
8618 return test_authenticated_decryption(&gcm_test_case_256_5);
8622 test_AES_GCM_auth_decryption_test_case_256_6(void)
8624 return test_authenticated_decryption(&gcm_test_case_256_6);
8628 test_AES_GCM_auth_decryption_test_case_256_7(void)
8630 return test_authenticated_decryption(&gcm_test_case_256_7);
8634 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8636 return test_authenticated_decryption(&gcm_test_case_aad_1);
8640 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8642 return test_authenticated_decryption(&gcm_test_case_aad_2);
8646 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8648 struct aead_test_data tdata;
8651 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8652 tdata.iv.data[0] += 1;
8653 res = test_authenticated_decryption(&tdata);
8654 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8655 return TEST_SUCCESS;
8659 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8661 struct aead_test_data tdata;
8664 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8665 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8666 tdata.plaintext.data[0] += 1;
8667 res = test_authenticated_decryption(&tdata);
8668 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8669 return TEST_SUCCESS;
8673 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8675 struct aead_test_data tdata;
8678 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8679 tdata.ciphertext.data[0] += 1;
8680 res = test_authenticated_decryption(&tdata);
8681 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8682 return TEST_SUCCESS;
8686 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8688 struct aead_test_data tdata;
8691 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8693 res = test_authenticated_decryption(&tdata);
8694 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8695 return TEST_SUCCESS;
8699 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8701 struct aead_test_data tdata;
8702 uint8_t aad[gcm_test_case_7.aad.len];
8705 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8706 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8708 tdata.aad.data = aad;
8709 res = test_authenticated_decryption(&tdata);
8710 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8711 return TEST_SUCCESS;
8715 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8717 struct aead_test_data tdata;
8720 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8721 tdata.auth_tag.data[0] += 1;
8722 res = test_authenticated_decryption(&tdata);
8723 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8724 return TEST_SUCCESS;
8728 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8730 struct crypto_testsuite_params *ts_params = &testsuite_params;
8731 struct crypto_unittest_params *ut_params = &unittest_params;
8734 uint8_t *ciphertext, *auth_tag;
8735 uint16_t plaintext_pad_len;
8737 /* Create AEAD session */
8738 retval = create_aead_session(ts_params->valid_devs[0],
8740 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8741 tdata->key.data, tdata->key.len,
8742 tdata->aad.len, tdata->auth_tag.len,
8747 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8748 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8750 /* clear mbuf payload */
8751 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8752 rte_pktmbuf_tailroom(ut_params->ibuf));
8753 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8754 rte_pktmbuf_tailroom(ut_params->obuf));
8756 /* Create AEAD operation */
8757 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8761 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8763 ut_params->op->sym->m_src = ut_params->ibuf;
8764 ut_params->op->sym->m_dst = ut_params->obuf;
8766 /* Process crypto operation */
8767 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8768 ut_params->op), "failed to process sym crypto op");
8770 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8771 "crypto op processing failed");
8773 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8775 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8776 ut_params->op->sym->cipher.data.offset);
8777 auth_tag = ciphertext + plaintext_pad_len;
8779 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8780 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8783 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8785 tdata->ciphertext.data,
8786 tdata->ciphertext.len,
8787 "Ciphertext data not as expected");
8789 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8791 tdata->auth_tag.data,
8792 tdata->auth_tag.len,
8793 "Generated auth tag not as expected");
8800 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8802 return test_authenticated_encryption_oop(&gcm_test_case_5);
8806 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8808 struct crypto_testsuite_params *ts_params = &testsuite_params;
8809 struct crypto_unittest_params *ut_params = &unittest_params;
8814 /* Create AEAD session */
8815 retval = create_aead_session(ts_params->valid_devs[0],
8817 RTE_CRYPTO_AEAD_OP_DECRYPT,
8818 tdata->key.data, tdata->key.len,
8819 tdata->aad.len, tdata->auth_tag.len,
8824 /* alloc mbuf and set payload */
8825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8826 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8828 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8829 rte_pktmbuf_tailroom(ut_params->ibuf));
8830 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8831 rte_pktmbuf_tailroom(ut_params->obuf));
8833 /* Create AEAD operation */
8834 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8838 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8840 ut_params->op->sym->m_src = ut_params->ibuf;
8841 ut_params->op->sym->m_dst = ut_params->obuf;
8843 /* Process crypto operation */
8844 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8845 ut_params->op), "failed to process sym crypto op");
8847 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8848 "crypto op processing failed");
8850 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8851 ut_params->op->sym->cipher.data.offset);
8853 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8856 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8858 tdata->plaintext.data,
8859 tdata->plaintext.len,
8860 "Plaintext data not as expected");
8862 TEST_ASSERT_EQUAL(ut_params->op->status,
8863 RTE_CRYPTO_OP_STATUS_SUCCESS,
8864 "Authentication failed");
8869 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8871 return test_authenticated_decryption_oop(&gcm_test_case_5);
8875 test_authenticated_encryption_sessionless(
8876 const struct aead_test_data *tdata)
8878 struct crypto_testsuite_params *ts_params = &testsuite_params;
8879 struct crypto_unittest_params *ut_params = &unittest_params;
8882 uint8_t *ciphertext, *auth_tag;
8883 uint16_t plaintext_pad_len;
8884 uint8_t key[tdata->key.len + 1];
8886 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8888 /* clear mbuf payload */
8889 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8890 rte_pktmbuf_tailroom(ut_params->ibuf));
8892 /* Create AEAD operation */
8893 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8897 /* Create GCM xform */
8898 memcpy(key, tdata->key.data, tdata->key.len);
8899 retval = create_aead_xform(ut_params->op,
8901 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8902 key, tdata->key.len,
8903 tdata->aad.len, tdata->auth_tag.len,
8908 ut_params->op->sym->m_src = ut_params->ibuf;
8910 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8911 RTE_CRYPTO_OP_SESSIONLESS,
8912 "crypto op session type not sessionless");
8914 /* Process crypto operation */
8915 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8916 ut_params->op), "failed to process sym crypto op");
8918 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8920 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8921 "crypto op status not success");
8923 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8925 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8926 ut_params->op->sym->cipher.data.offset);
8927 auth_tag = ciphertext + plaintext_pad_len;
8929 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8930 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8933 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8935 tdata->ciphertext.data,
8936 tdata->ciphertext.len,
8937 "Ciphertext data not as expected");
8939 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8941 tdata->auth_tag.data,
8942 tdata->auth_tag.len,
8943 "Generated auth tag not as expected");
8950 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8952 return test_authenticated_encryption_sessionless(
8957 test_authenticated_decryption_sessionless(
8958 const struct aead_test_data *tdata)
8960 struct crypto_testsuite_params *ts_params = &testsuite_params;
8961 struct crypto_unittest_params *ut_params = &unittest_params;
8965 uint8_t key[tdata->key.len + 1];
8967 /* alloc mbuf and set payload */
8968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8971 rte_pktmbuf_tailroom(ut_params->ibuf));
8973 /* Create AEAD operation */
8974 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8978 /* Create AEAD xform */
8979 memcpy(key, tdata->key.data, tdata->key.len);
8980 retval = create_aead_xform(ut_params->op,
8982 RTE_CRYPTO_AEAD_OP_DECRYPT,
8983 key, tdata->key.len,
8984 tdata->aad.len, tdata->auth_tag.len,
8989 ut_params->op->sym->m_src = ut_params->ibuf;
8991 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8992 RTE_CRYPTO_OP_SESSIONLESS,
8993 "crypto op session type not sessionless");
8995 /* Process crypto operation */
8996 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8997 ut_params->op), "failed to process sym crypto op");
8999 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9001 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9002 "crypto op status not success");
9004 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9005 ut_params->op->sym->cipher.data.offset);
9007 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9012 tdata->plaintext.data,
9013 tdata->plaintext.len,
9014 "Plaintext data not as expected");
9016 TEST_ASSERT_EQUAL(ut_params->op->status,
9017 RTE_CRYPTO_OP_STATUS_SUCCESS,
9018 "Authentication failed");
9023 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9025 return test_authenticated_decryption_sessionless(
9030 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9032 return test_authenticated_encryption(&ccm_test_case_128_1);
9036 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9038 return test_authenticated_encryption(&ccm_test_case_128_2);
9042 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9044 return test_authenticated_encryption(&ccm_test_case_128_3);
9048 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9050 return test_authenticated_decryption(&ccm_test_case_128_1);
9054 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9056 return test_authenticated_decryption(&ccm_test_case_128_2);
9060 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9062 return test_authenticated_decryption(&ccm_test_case_128_3);
9066 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9068 return test_authenticated_encryption(&ccm_test_case_192_1);
9072 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9074 return test_authenticated_encryption(&ccm_test_case_192_2);
9078 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9080 return test_authenticated_encryption(&ccm_test_case_192_3);
9084 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9086 return test_authenticated_decryption(&ccm_test_case_192_1);
9090 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9092 return test_authenticated_decryption(&ccm_test_case_192_2);
9096 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9098 return test_authenticated_decryption(&ccm_test_case_192_3);
9102 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9104 return test_authenticated_encryption(&ccm_test_case_256_1);
9108 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9110 return test_authenticated_encryption(&ccm_test_case_256_2);
9114 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9116 return test_authenticated_encryption(&ccm_test_case_256_3);
9120 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9122 return test_authenticated_decryption(&ccm_test_case_256_1);
9126 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9128 return test_authenticated_decryption(&ccm_test_case_256_2);
9132 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9134 return test_authenticated_decryption(&ccm_test_case_256_3);
9140 struct crypto_testsuite_params *ts_params = &testsuite_params;
9141 struct rte_cryptodev_stats stats;
9142 struct rte_cryptodev *dev;
9143 cryptodev_stats_get_t temp_pfn;
9145 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9146 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9147 &stats) == -ENODEV),
9148 "rte_cryptodev_stats_get invalid dev failed");
9149 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9150 "rte_cryptodev_stats_get invalid Param failed");
9151 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9152 temp_pfn = dev->dev_ops->stats_get;
9153 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9154 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9156 "rte_cryptodev_stats_get invalid Param failed");
9157 dev->dev_ops->stats_get = temp_pfn;
9159 /* Test expected values */
9161 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9163 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9165 "rte_cryptodev_stats_get failed");
9166 TEST_ASSERT((stats.enqueued_count == 1),
9167 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9168 TEST_ASSERT((stats.dequeued_count == 1),
9169 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9170 TEST_ASSERT((stats.enqueue_err_count == 0),
9171 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9172 TEST_ASSERT((stats.dequeue_err_count == 0),
9173 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9175 /* invalid device but should ignore and not reset device stats*/
9176 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9177 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9179 "rte_cryptodev_stats_get failed");
9180 TEST_ASSERT((stats.enqueued_count == 1),
9181 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9183 /* check that a valid reset clears stats */
9184 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9185 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9187 "rte_cryptodev_stats_get failed");
9188 TEST_ASSERT((stats.enqueued_count == 0),
9189 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9190 TEST_ASSERT((stats.dequeued_count == 0),
9191 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9193 return TEST_SUCCESS;
9196 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9197 struct crypto_unittest_params *ut_params,
9198 enum rte_crypto_auth_operation op,
9199 const struct HMAC_MD5_vector *test_case)
9203 memcpy(key, test_case->key.data, test_case->key.len);
9205 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9206 ut_params->auth_xform.next = NULL;
9207 ut_params->auth_xform.auth.op = op;
9209 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9211 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9212 ut_params->auth_xform.auth.key.length = test_case->key.len;
9213 ut_params->auth_xform.auth.key.data = key;
9215 ut_params->sess = rte_cryptodev_sym_session_create(
9216 ts_params->session_mpool);
9218 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9219 ut_params->sess, &ut_params->auth_xform,
9220 ts_params->session_priv_mpool);
9222 if (ut_params->sess == NULL)
9225 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9227 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9228 rte_pktmbuf_tailroom(ut_params->ibuf));
9233 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9234 const struct HMAC_MD5_vector *test_case,
9235 uint8_t **plaintext)
9237 uint16_t plaintext_pad_len;
9239 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9241 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9244 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9246 memcpy(*plaintext, test_case->plaintext.data,
9247 test_case->plaintext.len);
9249 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9250 ut_params->ibuf, MD5_DIGEST_LEN);
9251 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9252 "no room to append digest");
9253 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9254 ut_params->ibuf, plaintext_pad_len);
9256 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9257 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9258 test_case->auth_tag.len);
9261 sym_op->auth.data.offset = 0;
9262 sym_op->auth.data.length = test_case->plaintext.len;
9264 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9265 ut_params->op->sym->m_src = ut_params->ibuf;
9271 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9273 uint16_t plaintext_pad_len;
9274 uint8_t *plaintext, *auth_tag;
9276 struct crypto_testsuite_params *ts_params = &testsuite_params;
9277 struct crypto_unittest_params *ut_params = &unittest_params;
9279 if (MD5_HMAC_create_session(ts_params, ut_params,
9280 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9283 /* Generate Crypto op data structure */
9284 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9285 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9286 TEST_ASSERT_NOT_NULL(ut_params->op,
9287 "Failed to allocate symmetric crypto operation struct");
9289 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9292 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9295 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9296 ut_params->op), "failed to process sym crypto op");
9298 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9299 "crypto op processing failed");
9301 if (ut_params->op->sym->m_dst) {
9302 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9303 uint8_t *, plaintext_pad_len);
9305 auth_tag = plaintext + plaintext_pad_len;
9308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9310 test_case->auth_tag.data,
9311 test_case->auth_tag.len,
9312 "HMAC_MD5 generated tag not as expected");
9314 return TEST_SUCCESS;
9318 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9322 struct crypto_testsuite_params *ts_params = &testsuite_params;
9323 struct crypto_unittest_params *ut_params = &unittest_params;
9325 if (MD5_HMAC_create_session(ts_params, ut_params,
9326 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9330 /* Generate Crypto op data structure */
9331 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9332 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9333 TEST_ASSERT_NOT_NULL(ut_params->op,
9334 "Failed to allocate symmetric crypto operation struct");
9336 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9339 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9340 ut_params->op), "failed to process sym crypto op");
9342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9343 "HMAC_MD5 crypto op processing failed");
9345 return TEST_SUCCESS;
9349 test_MD5_HMAC_generate_case_1(void)
9351 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9355 test_MD5_HMAC_verify_case_1(void)
9357 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9361 test_MD5_HMAC_generate_case_2(void)
9363 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9367 test_MD5_HMAC_verify_case_2(void)
9369 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9373 test_multi_session(void)
9375 struct crypto_testsuite_params *ts_params = &testsuite_params;
9376 struct crypto_unittest_params *ut_params = &unittest_params;
9378 struct rte_cryptodev_info dev_info;
9379 struct rte_cryptodev_sym_session **sessions;
9383 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9384 aes_cbc_key, hmac_sha512_key);
9387 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9389 sessions = rte_malloc(NULL,
9390 (sizeof(struct rte_cryptodev_sym_session *) *
9391 MAX_NB_SESSIONS) + 1, 0);
9393 /* Create multiple crypto sessions*/
9394 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9396 sessions[i] = rte_cryptodev_sym_session_create(
9397 ts_params->session_mpool);
9399 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9400 sessions[i], &ut_params->auth_xform,
9401 ts_params->session_priv_mpool);
9402 TEST_ASSERT_NOT_NULL(sessions[i],
9403 "Session creation failed at session number %u",
9406 /* Attempt to send a request on each session */
9407 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9411 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9412 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9414 "Failed to perform decrypt on request number %u.", i);
9415 /* free crypto operation structure */
9417 rte_crypto_op_free(ut_params->op);
9420 * free mbuf - both obuf and ibuf are usually the same,
9421 * so check if they point at the same address is necessary,
9422 * to avoid freeing the mbuf twice.
9424 if (ut_params->obuf) {
9425 rte_pktmbuf_free(ut_params->obuf);
9426 if (ut_params->ibuf == ut_params->obuf)
9427 ut_params->ibuf = 0;
9428 ut_params->obuf = 0;
9430 if (ut_params->ibuf) {
9431 rte_pktmbuf_free(ut_params->ibuf);
9432 ut_params->ibuf = 0;
9436 /* Next session create should fail */
9437 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9438 sessions[i], &ut_params->auth_xform,
9439 ts_params->session_priv_mpool);
9440 TEST_ASSERT_NULL(sessions[i],
9441 "Session creation succeeded unexpectedly!");
9443 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9444 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9446 rte_cryptodev_sym_session_free(sessions[i]);
9451 return TEST_SUCCESS;
9454 struct multi_session_params {
9455 struct crypto_unittest_params ut_params;
9456 uint8_t *cipher_key;
9458 const uint8_t *cipher;
9459 const uint8_t *digest;
9463 #define MB_SESSION_NUMBER 3
9466 test_multi_session_random_usage(void)
9468 struct crypto_testsuite_params *ts_params = &testsuite_params;
9469 struct rte_cryptodev_info dev_info;
9470 struct rte_cryptodev_sym_session **sessions;
9472 struct multi_session_params ut_paramz[] = {
9475 .cipher_key = ms_aes_cbc_key0,
9476 .hmac_key = ms_hmac_key0,
9477 .cipher = ms_aes_cbc_cipher0,
9478 .digest = ms_hmac_digest0,
9479 .iv = ms_aes_cbc_iv0
9482 .cipher_key = ms_aes_cbc_key1,
9483 .hmac_key = ms_hmac_key1,
9484 .cipher = ms_aes_cbc_cipher1,
9485 .digest = ms_hmac_digest1,
9486 .iv = ms_aes_cbc_iv1
9489 .cipher_key = ms_aes_cbc_key2,
9490 .hmac_key = ms_hmac_key2,
9491 .cipher = ms_aes_cbc_cipher2,
9492 .digest = ms_hmac_digest2,
9493 .iv = ms_aes_cbc_iv2
9498 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9500 sessions = rte_malloc(NULL,
9501 (sizeof(struct rte_cryptodev_sym_session *)
9502 * MAX_NB_SESSIONS) + 1, 0);
9504 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9505 sessions[i] = rte_cryptodev_sym_session_create(
9506 ts_params->session_mpool);
9508 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9509 sizeof(struct crypto_unittest_params));
9511 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9512 &ut_paramz[i].ut_params,
9513 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9515 /* Create multiple crypto sessions*/
9516 rte_cryptodev_sym_session_init(
9517 ts_params->valid_devs[0],
9519 &ut_paramz[i].ut_params.auth_xform,
9520 ts_params->session_priv_mpool);
9522 TEST_ASSERT_NOT_NULL(sessions[i],
9523 "Session creation failed at session number %u",
9529 for (i = 0; i < 40000; i++) {
9531 j = rand() % MB_SESSION_NUMBER;
9533 TEST_ASSERT_SUCCESS(
9534 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9536 &ut_paramz[j].ut_params,
9537 ts_params, ut_paramz[j].cipher,
9538 ut_paramz[j].digest,
9540 "Failed to perform decrypt on request number %u.", i);
9542 if (ut_paramz[j].ut_params.op)
9543 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9546 * free mbuf - both obuf and ibuf are usually the same,
9547 * so check if they point at the same address is necessary,
9548 * to avoid freeing the mbuf twice.
9550 if (ut_paramz[j].ut_params.obuf) {
9551 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9552 if (ut_paramz[j].ut_params.ibuf
9553 == ut_paramz[j].ut_params.obuf)
9554 ut_paramz[j].ut_params.ibuf = 0;
9555 ut_paramz[j].ut_params.obuf = 0;
9557 if (ut_paramz[j].ut_params.ibuf) {
9558 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9559 ut_paramz[j].ut_params.ibuf = 0;
9563 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9564 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9566 rte_cryptodev_sym_session_free(sessions[i]);
9571 return TEST_SUCCESS;
9575 test_null_cipher_only_operation(void)
9577 struct crypto_testsuite_params *ts_params = &testsuite_params;
9578 struct crypto_unittest_params *ut_params = &unittest_params;
9580 /* Generate test mbuf data and space for digest */
9581 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9582 catch_22_quote, QUOTE_512_BYTES, 0);
9584 /* Setup Cipher Parameters */
9585 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9586 ut_params->cipher_xform.next = NULL;
9588 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9589 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9591 ut_params->sess = rte_cryptodev_sym_session_create(
9592 ts_params->session_mpool);
9594 /* Create Crypto session*/
9595 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9597 &ut_params->cipher_xform,
9598 ts_params->session_priv_mpool);
9599 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9601 /* Generate Crypto op data structure */
9602 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9603 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9604 TEST_ASSERT_NOT_NULL(ut_params->op,
9605 "Failed to allocate symmetric crypto operation struct");
9607 /* Set crypto operation data parameters */
9608 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9610 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9612 /* set crypto operation source mbuf */
9613 sym_op->m_src = ut_params->ibuf;
9615 sym_op->cipher.data.offset = 0;
9616 sym_op->cipher.data.length = QUOTE_512_BYTES;
9618 /* Process crypto operation */
9619 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9621 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9623 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9624 "crypto operation processing failed");
9627 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9628 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9631 "Ciphertext data not as expected");
9633 return TEST_SUCCESS;
9635 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9636 0xab, 0xab, 0xab, 0xab,
9637 0xab, 0xab, 0xab, 0xab,
9638 0xab, 0xab, 0xab, 0xab};
9640 test_null_auth_only_operation(void)
9642 struct crypto_testsuite_params *ts_params = &testsuite_params;
9643 struct crypto_unittest_params *ut_params = &unittest_params;
9646 /* Generate test mbuf data and space for digest */
9647 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9648 catch_22_quote, QUOTE_512_BYTES, 0);
9650 /* create a pointer for digest, but don't expect anything to be written
9651 * here in a NULL auth algo so no mbuf append done.
9653 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9655 /* prefill the memory pointed to by digest */
9656 memcpy(digest, orig_data, sizeof(orig_data));
9658 /* Setup HMAC Parameters */
9659 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9660 ut_params->auth_xform.next = NULL;
9662 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9663 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9665 ut_params->sess = rte_cryptodev_sym_session_create(
9666 ts_params->session_mpool);
9668 /* Create Crypto session*/
9669 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9670 ut_params->sess, &ut_params->auth_xform,
9671 ts_params->session_priv_mpool);
9672 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9674 /* Generate Crypto op data structure */
9675 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9676 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9677 TEST_ASSERT_NOT_NULL(ut_params->op,
9678 "Failed to allocate symmetric crypto operation struct");
9680 /* Set crypto operation data parameters */
9681 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9683 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9685 sym_op->m_src = ut_params->ibuf;
9687 sym_op->auth.data.offset = 0;
9688 sym_op->auth.data.length = QUOTE_512_BYTES;
9689 sym_op->auth.digest.data = digest;
9690 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9693 /* Process crypto operation */
9694 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9696 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9698 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9699 "crypto operation processing failed");
9700 /* Make sure memory pointed to by digest hasn't been overwritten */
9701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9705 "Memory at digest ptr overwritten unexpectedly");
9707 return TEST_SUCCESS;
9712 test_null_cipher_auth_operation(void)
9714 struct crypto_testsuite_params *ts_params = &testsuite_params;
9715 struct crypto_unittest_params *ut_params = &unittest_params;
9718 /* Generate test mbuf data and space for digest */
9719 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9720 catch_22_quote, QUOTE_512_BYTES, 0);
9722 /* create a pointer for digest, but don't expect anything to be written
9723 * here in a NULL auth algo so no mbuf append done.
9725 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9727 /* prefill the memory pointed to by digest */
9728 memcpy(digest, orig_data, sizeof(orig_data));
9730 /* Setup Cipher Parameters */
9731 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9732 ut_params->cipher_xform.next = &ut_params->auth_xform;
9734 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9735 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9737 /* Setup HMAC Parameters */
9738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9739 ut_params->auth_xform.next = NULL;
9741 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9742 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9744 ut_params->sess = rte_cryptodev_sym_session_create(
9745 ts_params->session_mpool);
9747 /* Create Crypto session*/
9748 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9749 ut_params->sess, &ut_params->cipher_xform,
9750 ts_params->session_priv_mpool);
9751 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9753 /* Generate Crypto op data structure */
9754 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9755 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9756 TEST_ASSERT_NOT_NULL(ut_params->op,
9757 "Failed to allocate symmetric crypto operation struct");
9759 /* Set crypto operation data parameters */
9760 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9762 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9764 sym_op->m_src = ut_params->ibuf;
9766 sym_op->cipher.data.offset = 0;
9767 sym_op->cipher.data.length = QUOTE_512_BYTES;
9769 sym_op->auth.data.offset = 0;
9770 sym_op->auth.data.length = QUOTE_512_BYTES;
9771 sym_op->auth.digest.data = digest;
9772 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9775 /* Process crypto operation */
9776 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9778 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9780 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9781 "crypto operation processing failed");
9784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9785 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9788 "Ciphertext data not as expected");
9789 /* Make sure memory pointed to by digest hasn't been overwritten */
9790 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9794 "Memory at digest ptr overwritten unexpectedly");
9796 return TEST_SUCCESS;
9800 test_null_auth_cipher_operation(void)
9802 struct crypto_testsuite_params *ts_params = &testsuite_params;
9803 struct crypto_unittest_params *ut_params = &unittest_params;
9806 /* Generate test mbuf data */
9807 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9808 catch_22_quote, QUOTE_512_BYTES, 0);
9810 /* create a pointer for digest, but don't expect anything to be written
9811 * here in a NULL auth algo so no mbuf append done.
9813 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9815 /* prefill the memory pointed to by digest */
9816 memcpy(digest, orig_data, sizeof(orig_data));
9818 /* Setup Cipher Parameters */
9819 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9820 ut_params->cipher_xform.next = NULL;
9822 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9823 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9825 /* Setup HMAC Parameters */
9826 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9827 ut_params->auth_xform.next = &ut_params->cipher_xform;
9829 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9830 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9832 ut_params->sess = rte_cryptodev_sym_session_create(
9833 ts_params->session_mpool);
9835 /* Create Crypto session*/
9836 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9837 ut_params->sess, &ut_params->cipher_xform,
9838 ts_params->session_priv_mpool);
9839 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9841 /* Generate Crypto op data structure */
9842 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9843 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9844 TEST_ASSERT_NOT_NULL(ut_params->op,
9845 "Failed to allocate symmetric crypto operation struct");
9847 /* Set crypto operation data parameters */
9848 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9850 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9852 sym_op->m_src = ut_params->ibuf;
9854 sym_op->cipher.data.offset = 0;
9855 sym_op->cipher.data.length = QUOTE_512_BYTES;
9857 sym_op->auth.data.offset = 0;
9858 sym_op->auth.data.length = QUOTE_512_BYTES;
9859 sym_op->auth.digest.data = digest;
9860 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9863 /* Process crypto operation */
9864 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9866 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9868 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9869 "crypto operation processing failed");
9872 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9873 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9876 "Ciphertext data not as expected");
9877 /* Make sure memory pointed to by digest hasn't been overwritten */
9878 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9882 "Memory at digest ptr overwritten unexpectedly");
9884 return TEST_SUCCESS;
9889 test_null_invalid_operation(void)
9891 struct crypto_testsuite_params *ts_params = &testsuite_params;
9892 struct crypto_unittest_params *ut_params = &unittest_params;
9895 /* Setup Cipher Parameters */
9896 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9897 ut_params->cipher_xform.next = NULL;
9899 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9900 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9902 ut_params->sess = rte_cryptodev_sym_session_create(
9903 ts_params->session_mpool);
9905 /* Create Crypto session*/
9906 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9907 ut_params->sess, &ut_params->cipher_xform,
9908 ts_params->session_priv_mpool);
9909 TEST_ASSERT(ret < 0,
9910 "Session creation succeeded unexpectedly");
9913 /* Setup HMAC Parameters */
9914 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9915 ut_params->auth_xform.next = NULL;
9917 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9918 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9920 ut_params->sess = rte_cryptodev_sym_session_create(
9921 ts_params->session_mpool);
9923 /* Create Crypto session*/
9924 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9925 ut_params->sess, &ut_params->auth_xform,
9926 ts_params->session_priv_mpool);
9927 TEST_ASSERT(ret < 0,
9928 "Session creation succeeded unexpectedly");
9930 return TEST_SUCCESS;
9934 #define NULL_BURST_LENGTH (32)
9937 test_null_burst_operation(void)
9939 struct crypto_testsuite_params *ts_params = &testsuite_params;
9940 struct crypto_unittest_params *ut_params = &unittest_params;
9942 unsigned i, burst_len = NULL_BURST_LENGTH;
9944 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9945 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9947 /* Setup Cipher Parameters */
9948 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9949 ut_params->cipher_xform.next = &ut_params->auth_xform;
9951 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9952 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9954 /* Setup HMAC Parameters */
9955 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9956 ut_params->auth_xform.next = NULL;
9958 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9959 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9961 ut_params->sess = rte_cryptodev_sym_session_create(
9962 ts_params->session_mpool);
9964 /* Create Crypto session*/
9965 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9966 ut_params->sess, &ut_params->cipher_xform,
9967 ts_params->session_priv_mpool);
9968 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9970 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9971 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9972 burst_len, "failed to generate burst of crypto ops");
9974 /* Generate an operation for each mbuf in burst */
9975 for (i = 0; i < burst_len; i++) {
9976 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9978 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9980 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9984 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9986 burst[i]->sym->m_src = m;
9989 /* Process crypto operation */
9990 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9991 0, burst, burst_len),
9993 "Error enqueuing burst");
9995 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9996 0, burst_dequeued, burst_len),
9998 "Error dequeuing burst");
10001 for (i = 0; i < burst_len; i++) {
10003 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10004 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10006 "data not as expected");
10008 rte_pktmbuf_free(burst[i]->sym->m_src);
10009 rte_crypto_op_free(burst[i]);
10012 return TEST_SUCCESS;
10016 generate_gmac_large_plaintext(uint8_t *data)
10020 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10021 memcpy(&data[i], &data[0], 32);
10025 create_gmac_operation(enum rte_crypto_auth_operation op,
10026 const struct gmac_test_data *tdata)
10028 struct crypto_testsuite_params *ts_params = &testsuite_params;
10029 struct crypto_unittest_params *ut_params = &unittest_params;
10030 struct rte_crypto_sym_op *sym_op;
10032 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10034 /* Generate Crypto op data structure */
10035 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10036 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10037 TEST_ASSERT_NOT_NULL(ut_params->op,
10038 "Failed to allocate symmetric crypto operation struct");
10040 sym_op = ut_params->op->sym;
10042 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10043 ut_params->ibuf, tdata->gmac_tag.len);
10044 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10045 "no room to append digest");
10047 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10048 ut_params->ibuf, plaintext_pad_len);
10050 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10051 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10052 tdata->gmac_tag.len);
10053 debug_hexdump(stdout, "digest:",
10054 sym_op->auth.digest.data,
10055 tdata->gmac_tag.len);
10058 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10059 uint8_t *, IV_OFFSET);
10061 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10063 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10065 sym_op->cipher.data.length = 0;
10066 sym_op->cipher.data.offset = 0;
10068 sym_op->auth.data.offset = 0;
10069 sym_op->auth.data.length = tdata->plaintext.len;
10074 static int create_gmac_session(uint8_t dev_id,
10075 const struct gmac_test_data *tdata,
10076 enum rte_crypto_auth_operation auth_op)
10078 uint8_t auth_key[tdata->key.len];
10080 struct crypto_testsuite_params *ts_params = &testsuite_params;
10081 struct crypto_unittest_params *ut_params = &unittest_params;
10083 memcpy(auth_key, tdata->key.data, tdata->key.len);
10085 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10086 ut_params->auth_xform.next = NULL;
10088 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10089 ut_params->auth_xform.auth.op = auth_op;
10090 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10091 ut_params->auth_xform.auth.key.length = tdata->key.len;
10092 ut_params->auth_xform.auth.key.data = auth_key;
10093 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10094 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10097 ut_params->sess = rte_cryptodev_sym_session_create(
10098 ts_params->session_mpool);
10100 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10101 &ut_params->auth_xform,
10102 ts_params->session_priv_mpool);
10104 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10110 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10112 struct crypto_testsuite_params *ts_params = &testsuite_params;
10113 struct crypto_unittest_params *ut_params = &unittest_params;
10117 uint8_t *auth_tag, *plaintext;
10118 uint16_t plaintext_pad_len;
10120 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10121 "No GMAC length in the source data");
10123 retval = create_gmac_session(ts_params->valid_devs[0],
10124 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10129 if (tdata->plaintext.len > MBUF_SIZE)
10130 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10133 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10134 "Failed to allocate input buffer in mempool");
10136 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10137 rte_pktmbuf_tailroom(ut_params->ibuf));
10139 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10141 * Runtime generate the large plain text instead of use hard code
10142 * plain text vector. It is done to avoid create huge source file
10143 * with the test vector.
10145 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10146 generate_gmac_large_plaintext(tdata->plaintext.data);
10148 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10149 plaintext_pad_len);
10150 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10152 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10153 debug_hexdump(stdout, "plaintext:", plaintext,
10154 tdata->plaintext.len);
10156 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10162 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10164 ut_params->op->sym->m_src = ut_params->ibuf;
10166 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10167 ut_params->op), "failed to process sym crypto op");
10169 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10170 "crypto op processing failed");
10172 if (ut_params->op->sym->m_dst) {
10173 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10174 uint8_t *, plaintext_pad_len);
10176 auth_tag = plaintext + plaintext_pad_len;
10179 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10181 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10183 tdata->gmac_tag.data,
10184 tdata->gmac_tag.len,
10185 "GMAC Generated auth tag not as expected");
10191 test_AES_GMAC_authentication_test_case_1(void)
10193 return test_AES_GMAC_authentication(&gmac_test_case_1);
10197 test_AES_GMAC_authentication_test_case_2(void)
10199 return test_AES_GMAC_authentication(&gmac_test_case_2);
10203 test_AES_GMAC_authentication_test_case_3(void)
10205 return test_AES_GMAC_authentication(&gmac_test_case_3);
10209 test_AES_GMAC_authentication_test_case_4(void)
10211 return test_AES_GMAC_authentication(&gmac_test_case_4);
10215 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10217 struct crypto_testsuite_params *ts_params = &testsuite_params;
10218 struct crypto_unittest_params *ut_params = &unittest_params;
10220 uint32_t plaintext_pad_len;
10221 uint8_t *plaintext;
10223 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10224 "No GMAC length in the source data");
10226 retval = create_gmac_session(ts_params->valid_devs[0],
10227 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10232 if (tdata->plaintext.len > MBUF_SIZE)
10233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10235 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10236 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10237 "Failed to allocate input buffer in mempool");
10239 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10240 rte_pktmbuf_tailroom(ut_params->ibuf));
10242 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10245 * Runtime generate the large plain text instead of use hard code
10246 * plain text vector. It is done to avoid create huge source file
10247 * with the test vector.
10249 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10250 generate_gmac_large_plaintext(tdata->plaintext.data);
10252 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10253 plaintext_pad_len);
10254 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10256 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10257 debug_hexdump(stdout, "plaintext:", plaintext,
10258 tdata->plaintext.len);
10260 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10266 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10268 ut_params->op->sym->m_src = ut_params->ibuf;
10270 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10271 ut_params->op), "failed to process sym crypto op");
10273 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10274 "crypto op processing failed");
10281 test_AES_GMAC_authentication_verify_test_case_1(void)
10283 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10287 test_AES_GMAC_authentication_verify_test_case_2(void)
10289 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10293 test_AES_GMAC_authentication_verify_test_case_3(void)
10295 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10299 test_AES_GMAC_authentication_verify_test_case_4(void)
10301 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10304 struct test_crypto_vector {
10305 enum rte_crypto_cipher_algorithm crypto_algo;
10306 unsigned int cipher_offset;
10307 unsigned int cipher_len;
10320 const uint8_t *data;
10325 const uint8_t *data;
10329 enum rte_crypto_auth_algorithm auth_algo;
10330 unsigned int auth_offset;
10338 const uint8_t *data;
10348 static const struct test_crypto_vector
10349 hmac_sha1_test_crypto_vector = {
10350 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10352 .data = plaintext_hash,
10357 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10358 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10359 0xDE, 0xF4, 0xDE, 0xAD
10365 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10366 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10367 0x3F, 0x91, 0x64, 0x59
10373 static const struct test_crypto_vector
10374 aes128_gmac_test_vector = {
10375 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10377 .data = plaintext_hash,
10382 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10383 0x08, 0x09, 0x0A, 0x0B
10389 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10390 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10396 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10397 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10403 static const struct test_crypto_vector
10404 aes128cbc_hmac_sha1_test_vector = {
10405 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10406 .cipher_offset = 0,
10410 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10411 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10417 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10418 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10423 .data = plaintext_hash,
10427 .data = ciphertext512_aes128cbc,
10430 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10434 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10435 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10436 0xDE, 0xF4, 0xDE, 0xAD
10442 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10443 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10444 0x18, 0x8C, 0x1D, 0x32
10450 static const struct test_crypto_vector
10451 aes128cbc_hmac_sha1_aad_test_vector = {
10452 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10453 .cipher_offset = 12,
10457 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10458 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10464 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10465 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10470 .data = plaintext_hash,
10474 .data = ciphertext512_aes128cbc_aad,
10477 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10481 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10482 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10483 0xDE, 0xF4, 0xDE, 0xAD
10489 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10490 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10491 0x62, 0x8D, 0x62, 0x65
10498 data_corruption(uint8_t *data)
10504 tag_corruption(uint8_t *data, unsigned int tag_offset)
10506 data[tag_offset] += 1;
10510 create_auth_session(struct crypto_unittest_params *ut_params,
10512 const struct test_crypto_vector *reference,
10513 enum rte_crypto_auth_operation auth_op)
10515 struct crypto_testsuite_params *ts_params = &testsuite_params;
10516 uint8_t auth_key[reference->auth_key.len + 1];
10518 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10520 /* Setup Authentication Parameters */
10521 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10522 ut_params->auth_xform.auth.op = auth_op;
10523 ut_params->auth_xform.next = NULL;
10524 ut_params->auth_xform.auth.algo = reference->auth_algo;
10525 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10526 ut_params->auth_xform.auth.key.data = auth_key;
10527 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10529 /* Create Crypto session*/
10530 ut_params->sess = rte_cryptodev_sym_session_create(
10531 ts_params->session_mpool);
10533 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10534 &ut_params->auth_xform,
10535 ts_params->session_priv_mpool);
10537 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10543 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10545 const struct test_crypto_vector *reference,
10546 enum rte_crypto_auth_operation auth_op,
10547 enum rte_crypto_cipher_operation cipher_op)
10549 struct crypto_testsuite_params *ts_params = &testsuite_params;
10550 uint8_t cipher_key[reference->cipher_key.len + 1];
10551 uint8_t auth_key[reference->auth_key.len + 1];
10553 memcpy(cipher_key, reference->cipher_key.data,
10554 reference->cipher_key.len);
10555 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10557 /* Setup Authentication Parameters */
10558 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10559 ut_params->auth_xform.auth.op = auth_op;
10560 ut_params->auth_xform.auth.algo = reference->auth_algo;
10561 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10562 ut_params->auth_xform.auth.key.data = auth_key;
10563 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10565 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10566 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10567 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10569 ut_params->auth_xform.next = &ut_params->cipher_xform;
10571 /* Setup Cipher Parameters */
10572 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10573 ut_params->cipher_xform.next = NULL;
10574 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10575 ut_params->cipher_xform.cipher.op = cipher_op;
10576 ut_params->cipher_xform.cipher.key.data = cipher_key;
10577 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10578 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10579 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10582 /* Create Crypto session*/
10583 ut_params->sess = rte_cryptodev_sym_session_create(
10584 ts_params->session_mpool);
10586 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10587 &ut_params->auth_xform,
10588 ts_params->session_priv_mpool);
10590 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10596 create_auth_operation(struct crypto_testsuite_params *ts_params,
10597 struct crypto_unittest_params *ut_params,
10598 const struct test_crypto_vector *reference,
10599 unsigned int auth_generate)
10601 /* Generate Crypto op data structure */
10602 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10603 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10604 TEST_ASSERT_NOT_NULL(ut_params->op,
10605 "Failed to allocate pktmbuf offload");
10607 /* Set crypto operation data parameters */
10608 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10610 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10612 /* set crypto operation source mbuf */
10613 sym_op->m_src = ut_params->ibuf;
10616 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10617 ut_params->ibuf, reference->digest.len);
10619 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10620 "no room to append auth tag");
10622 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10623 ut_params->ibuf, reference->plaintext.len);
10626 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10628 memcpy(sym_op->auth.digest.data,
10629 reference->digest.data,
10630 reference->digest.len);
10632 debug_hexdump(stdout, "digest:",
10633 sym_op->auth.digest.data,
10634 reference->digest.len);
10636 sym_op->auth.data.length = reference->plaintext.len;
10637 sym_op->auth.data.offset = 0;
10643 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10644 struct crypto_unittest_params *ut_params,
10645 const struct test_crypto_vector *reference,
10646 unsigned int auth_generate)
10648 /* Generate Crypto op data structure */
10649 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10650 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10651 TEST_ASSERT_NOT_NULL(ut_params->op,
10652 "Failed to allocate pktmbuf offload");
10654 /* Set crypto operation data parameters */
10655 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10657 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10659 /* set crypto operation source mbuf */
10660 sym_op->m_src = ut_params->ibuf;
10663 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10664 ut_params->ibuf, reference->digest.len);
10666 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10667 "no room to append auth tag");
10669 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10670 ut_params->ibuf, reference->ciphertext.len);
10673 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10675 memcpy(sym_op->auth.digest.data,
10676 reference->digest.data,
10677 reference->digest.len);
10679 debug_hexdump(stdout, "digest:",
10680 sym_op->auth.digest.data,
10681 reference->digest.len);
10683 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10684 reference->iv.data, reference->iv.len);
10686 sym_op->cipher.data.length = 0;
10687 sym_op->cipher.data.offset = 0;
10689 sym_op->auth.data.length = reference->plaintext.len;
10690 sym_op->auth.data.offset = 0;
10696 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10697 struct crypto_unittest_params *ut_params,
10698 const struct test_crypto_vector *reference,
10699 unsigned int auth_generate)
10701 /* Generate Crypto op data structure */
10702 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10703 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10704 TEST_ASSERT_NOT_NULL(ut_params->op,
10705 "Failed to allocate pktmbuf offload");
10707 /* Set crypto operation data parameters */
10708 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10710 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10712 /* set crypto operation source mbuf */
10713 sym_op->m_src = ut_params->ibuf;
10716 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10717 ut_params->ibuf, reference->digest.len);
10719 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10720 "no room to append auth tag");
10722 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10723 ut_params->ibuf, reference->ciphertext.len);
10726 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10728 memcpy(sym_op->auth.digest.data,
10729 reference->digest.data,
10730 reference->digest.len);
10732 debug_hexdump(stdout, "digest:",
10733 sym_op->auth.digest.data,
10734 reference->digest.len);
10736 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10737 reference->iv.data, reference->iv.len);
10739 sym_op->cipher.data.length = reference->cipher_len;
10740 sym_op->cipher.data.offset = reference->cipher_offset;
10742 sym_op->auth.data.length = reference->plaintext.len;
10743 sym_op->auth.data.offset = reference->auth_offset;
10749 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10750 struct crypto_unittest_params *ut_params,
10751 const struct test_crypto_vector *reference)
10753 return create_auth_operation(ts_params, ut_params, reference, 0);
10757 create_auth_verify_GMAC_operation(
10758 struct crypto_testsuite_params *ts_params,
10759 struct crypto_unittest_params *ut_params,
10760 const struct test_crypto_vector *reference)
10762 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10766 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10767 struct crypto_unittest_params *ut_params,
10768 const struct test_crypto_vector *reference)
10770 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10774 test_authentication_verify_fail_when_data_corruption(
10775 struct crypto_testsuite_params *ts_params,
10776 struct crypto_unittest_params *ut_params,
10777 const struct test_crypto_vector *reference,
10778 unsigned int data_corrupted)
10782 uint8_t *plaintext;
10784 /* Create session */
10785 retval = create_auth_session(ut_params,
10786 ts_params->valid_devs[0],
10788 RTE_CRYPTO_AUTH_OP_VERIFY);
10792 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10793 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10794 "Failed to allocate input buffer in mempool");
10796 /* clear mbuf payload */
10797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10798 rte_pktmbuf_tailroom(ut_params->ibuf));
10800 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10801 reference->plaintext.len);
10802 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10803 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10805 debug_hexdump(stdout, "plaintext:", plaintext,
10806 reference->plaintext.len);
10808 /* Create operation */
10809 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10814 if (data_corrupted)
10815 data_corruption(plaintext);
10817 tag_corruption(plaintext, reference->plaintext.len);
10819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10822 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10823 RTE_CRYPTO_OP_STATUS_SUCCESS,
10824 "authentication not failed");
10826 ut_params->obuf = ut_params->op->sym->m_src;
10827 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10833 test_authentication_verify_GMAC_fail_when_corruption(
10834 struct crypto_testsuite_params *ts_params,
10835 struct crypto_unittest_params *ut_params,
10836 const struct test_crypto_vector *reference,
10837 unsigned int data_corrupted)
10840 uint8_t *plaintext;
10842 /* Create session */
10843 retval = create_auth_cipher_session(ut_params,
10844 ts_params->valid_devs[0],
10846 RTE_CRYPTO_AUTH_OP_VERIFY,
10847 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10852 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10853 "Failed to allocate input buffer in mempool");
10855 /* clear mbuf payload */
10856 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10857 rte_pktmbuf_tailroom(ut_params->ibuf));
10859 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10860 reference->plaintext.len);
10861 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10862 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10864 debug_hexdump(stdout, "plaintext:", plaintext,
10865 reference->plaintext.len);
10867 /* Create operation */
10868 retval = create_auth_verify_GMAC_operation(ts_params,
10875 if (data_corrupted)
10876 data_corruption(plaintext);
10878 tag_corruption(plaintext, reference->aad.len);
10880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10883 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10884 RTE_CRYPTO_OP_STATUS_SUCCESS,
10885 "authentication not failed");
10887 ut_params->obuf = ut_params->op->sym->m_src;
10888 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10894 test_authenticated_decryption_fail_when_corruption(
10895 struct crypto_testsuite_params *ts_params,
10896 struct crypto_unittest_params *ut_params,
10897 const struct test_crypto_vector *reference,
10898 unsigned int data_corrupted)
10902 uint8_t *ciphertext;
10904 /* Create session */
10905 retval = create_auth_cipher_session(ut_params,
10906 ts_params->valid_devs[0],
10908 RTE_CRYPTO_AUTH_OP_VERIFY,
10909 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10913 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10914 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10915 "Failed to allocate input buffer in mempool");
10917 /* clear mbuf payload */
10918 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10919 rte_pktmbuf_tailroom(ut_params->ibuf));
10921 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10922 reference->ciphertext.len);
10923 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10924 memcpy(ciphertext, reference->ciphertext.data,
10925 reference->ciphertext.len);
10927 /* Create operation */
10928 retval = create_cipher_auth_verify_operation(ts_params,
10935 if (data_corrupted)
10936 data_corruption(ciphertext);
10938 tag_corruption(ciphertext, reference->ciphertext.len);
10940 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10943 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10944 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10945 RTE_CRYPTO_OP_STATUS_SUCCESS,
10946 "authentication not failed");
10948 ut_params->obuf = ut_params->op->sym->m_src;
10949 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10955 test_authenticated_encryt_with_esn(
10956 struct crypto_testsuite_params *ts_params,
10957 struct crypto_unittest_params *ut_params,
10958 const struct test_crypto_vector *reference)
10962 uint8_t *authciphertext, *plaintext, *auth_tag;
10963 uint16_t plaintext_pad_len;
10964 uint8_t cipher_key[reference->cipher_key.len + 1];
10965 uint8_t auth_key[reference->auth_key.len + 1];
10967 /* Create session */
10968 memcpy(cipher_key, reference->cipher_key.data,
10969 reference->cipher_key.len);
10970 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10972 /* Setup Cipher Parameters */
10973 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10974 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10975 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10976 ut_params->cipher_xform.cipher.key.data = cipher_key;
10977 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10978 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10979 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10981 ut_params->cipher_xform.next = &ut_params->auth_xform;
10983 /* Setup Authentication Parameters */
10984 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10985 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10986 ut_params->auth_xform.auth.algo = reference->auth_algo;
10987 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10988 ut_params->auth_xform.auth.key.data = auth_key;
10989 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10990 ut_params->auth_xform.next = NULL;
10992 /* Create Crypto session*/
10993 ut_params->sess = rte_cryptodev_sym_session_create(
10994 ts_params->session_mpool);
10996 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10998 &ut_params->cipher_xform,
10999 ts_params->session_priv_mpool);
11001 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11003 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11004 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11005 "Failed to allocate input buffer in mempool");
11007 /* clear mbuf payload */
11008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11009 rte_pktmbuf_tailroom(ut_params->ibuf));
11011 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11012 reference->plaintext.len);
11013 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11014 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11016 /* Create operation */
11017 retval = create_cipher_auth_operation(ts_params,
11024 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11027 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11029 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11030 "crypto op processing failed");
11032 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11034 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11035 ut_params->op->sym->auth.data.offset);
11036 auth_tag = authciphertext + plaintext_pad_len;
11037 debug_hexdump(stdout, "ciphertext:", authciphertext,
11038 reference->ciphertext.len);
11039 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11041 /* Validate obuf */
11042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11044 reference->ciphertext.data,
11045 reference->ciphertext.len,
11046 "Ciphertext data not as expected");
11048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11050 reference->digest.data,
11051 reference->digest.len,
11052 "Generated digest not as expected");
11054 return TEST_SUCCESS;
11059 test_authenticated_decrypt_with_esn(
11060 struct crypto_testsuite_params *ts_params,
11061 struct crypto_unittest_params *ut_params,
11062 const struct test_crypto_vector *reference)
11066 uint8_t *ciphertext;
11067 uint8_t cipher_key[reference->cipher_key.len + 1];
11068 uint8_t auth_key[reference->auth_key.len + 1];
11070 /* Create session */
11071 memcpy(cipher_key, reference->cipher_key.data,
11072 reference->cipher_key.len);
11073 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11075 /* Setup Authentication Parameters */
11076 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11077 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11078 ut_params->auth_xform.auth.algo = reference->auth_algo;
11079 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11080 ut_params->auth_xform.auth.key.data = auth_key;
11081 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11082 ut_params->auth_xform.next = &ut_params->cipher_xform;
11084 /* Setup Cipher Parameters */
11085 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11086 ut_params->cipher_xform.next = NULL;
11087 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11088 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11089 ut_params->cipher_xform.cipher.key.data = cipher_key;
11090 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11091 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11092 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11094 /* Create Crypto session*/
11095 ut_params->sess = rte_cryptodev_sym_session_create(
11096 ts_params->session_mpool);
11098 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11100 &ut_params->auth_xform,
11101 ts_params->session_priv_mpool);
11103 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11105 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11106 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11107 "Failed to allocate input buffer in mempool");
11109 /* clear mbuf payload */
11110 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11111 rte_pktmbuf_tailroom(ut_params->ibuf));
11113 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11114 reference->ciphertext.len);
11115 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11116 memcpy(ciphertext, reference->ciphertext.data,
11117 reference->ciphertext.len);
11119 /* Create operation */
11120 retval = create_cipher_auth_verify_operation(ts_params,
11127 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11130 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11131 TEST_ASSERT_EQUAL(ut_params->op->status,
11132 RTE_CRYPTO_OP_STATUS_SUCCESS,
11133 "crypto op processing passed");
11135 ut_params->obuf = ut_params->op->sym->m_src;
11136 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11142 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11143 const struct aead_test_data *tdata,
11144 void *digest_mem, uint64_t digest_phys)
11146 struct crypto_testsuite_params *ts_params = &testsuite_params;
11147 struct crypto_unittest_params *ut_params = &unittest_params;
11149 const unsigned int auth_tag_len = tdata->auth_tag.len;
11150 const unsigned int iv_len = tdata->iv.len;
11151 unsigned int aad_len = tdata->aad.len;
11153 /* Generate Crypto op data structure */
11154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11156 TEST_ASSERT_NOT_NULL(ut_params->op,
11157 "Failed to allocate symmetric crypto operation struct");
11159 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11161 sym_op->aead.digest.data = digest_mem;
11163 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11164 "no room to append digest");
11166 sym_op->aead.digest.phys_addr = digest_phys;
11168 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11169 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11171 debug_hexdump(stdout, "digest:",
11172 sym_op->aead.digest.data,
11176 /* Append aad data */
11177 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11178 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11179 uint8_t *, IV_OFFSET);
11181 /* Copy IV 1 byte after the IV pointer, according to the API */
11182 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11184 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11186 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11187 ut_params->ibuf, aad_len);
11188 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11189 "no room to prepend aad");
11190 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11193 memset(sym_op->aead.aad.data, 0, aad_len);
11194 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11195 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11197 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11198 debug_hexdump(stdout, "aad:",
11199 sym_op->aead.aad.data, aad_len);
11201 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11202 uint8_t *, IV_OFFSET);
11204 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11206 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11207 ut_params->ibuf, aad_len);
11208 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11209 "no room to prepend aad");
11210 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11213 memset(sym_op->aead.aad.data, 0, aad_len);
11214 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11216 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11217 debug_hexdump(stdout, "aad:",
11218 sym_op->aead.aad.data, aad_len);
11221 sym_op->aead.data.length = tdata->plaintext.len;
11222 sym_op->aead.data.offset = aad_len;
11227 #define SGL_MAX_NO 16
11230 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11231 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11233 struct crypto_testsuite_params *ts_params = &testsuite_params;
11234 struct crypto_unittest_params *ut_params = &unittest_params;
11235 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11238 int to_trn_tbl[SGL_MAX_NO];
11240 unsigned int trn_data = 0;
11241 uint8_t *plaintext, *ciphertext, *auth_tag;
11243 if (fragsz > tdata->plaintext.len)
11244 fragsz = tdata->plaintext.len;
11246 uint16_t plaintext_len = fragsz;
11247 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11249 if (fragsz_oop > tdata->plaintext.len)
11250 frag_size_oop = tdata->plaintext.len;
11253 void *digest_mem = NULL;
11255 uint32_t prepend_len = tdata->aad.len;
11257 if (tdata->plaintext.len % fragsz != 0) {
11258 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11261 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11266 * For out-op-place we need to alloc another mbuf
11269 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11270 rte_pktmbuf_append(ut_params->obuf,
11271 frag_size_oop + prepend_len);
11272 buf_oop = ut_params->obuf;
11275 /* Create AEAD session */
11276 retval = create_aead_session(ts_params->valid_devs[0],
11278 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11279 tdata->key.data, tdata->key.len,
11280 tdata->aad.len, tdata->auth_tag.len,
11285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11287 /* clear mbuf payload */
11288 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11289 rte_pktmbuf_tailroom(ut_params->ibuf));
11291 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11294 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11296 trn_data += plaintext_len;
11298 buf = ut_params->ibuf;
11301 * Loop until no more fragments
11304 while (trn_data < tdata->plaintext.len) {
11306 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11307 (tdata->plaintext.len - trn_data) : fragsz;
11309 to_trn_tbl[ecx++] = to_trn;
11311 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11314 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11315 rte_pktmbuf_tailroom(buf));
11318 if (oop && !fragsz_oop) {
11319 buf_last_oop = buf_oop->next =
11320 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11321 buf_oop = buf_oop->next;
11322 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11323 0, rte_pktmbuf_tailroom(buf_oop));
11324 rte_pktmbuf_append(buf_oop, to_trn);
11327 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11330 memcpy(plaintext, tdata->plaintext.data + trn_data,
11332 trn_data += to_trn;
11333 if (trn_data == tdata->plaintext.len) {
11336 digest_mem = rte_pktmbuf_append(buf_oop,
11337 tdata->auth_tag.len);
11339 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11340 tdata->auth_tag.len);
11344 uint64_t digest_phys = 0;
11346 ut_params->ibuf->nb_segs = segs;
11349 if (fragsz_oop && oop) {
11353 if (frag_size_oop == tdata->plaintext.len) {
11354 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11355 tdata->auth_tag.len);
11357 digest_phys = rte_pktmbuf_iova_offset(
11359 tdata->plaintext.len + prepend_len);
11362 trn_data = frag_size_oop;
11363 while (trn_data < tdata->plaintext.len) {
11366 (tdata->plaintext.len - trn_data <
11368 (tdata->plaintext.len - trn_data) :
11371 to_trn_tbl[ecx++] = to_trn;
11373 buf_last_oop = buf_oop->next =
11374 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11375 buf_oop = buf_oop->next;
11376 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11377 0, rte_pktmbuf_tailroom(buf_oop));
11378 rte_pktmbuf_append(buf_oop, to_trn);
11380 trn_data += to_trn;
11382 if (trn_data == tdata->plaintext.len) {
11383 digest_mem = rte_pktmbuf_append(buf_oop,
11384 tdata->auth_tag.len);
11388 ut_params->obuf->nb_segs = segs;
11392 * Place digest at the end of the last buffer
11395 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11396 if (oop && buf_last_oop)
11397 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11399 if (!digest_mem && !oop) {
11400 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11401 + tdata->auth_tag.len);
11402 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11403 tdata->plaintext.len);
11406 /* Create AEAD operation */
11407 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11408 tdata, digest_mem, digest_phys);
11413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11415 ut_params->op->sym->m_src = ut_params->ibuf;
11417 ut_params->op->sym->m_dst = ut_params->obuf;
11419 /* Process crypto operation */
11420 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11421 ut_params->op), "failed to process sym crypto op");
11423 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11424 "crypto op processing failed");
11427 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11428 uint8_t *, prepend_len);
11430 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11431 uint8_t *, prepend_len);
11435 fragsz = fragsz_oop;
11437 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11439 tdata->ciphertext.data,
11441 "Ciphertext data not as expected");
11443 buf = ut_params->op->sym->m_src->next;
11445 buf = ut_params->op->sym->m_dst->next;
11447 unsigned int off = fragsz;
11451 ciphertext = rte_pktmbuf_mtod(buf,
11454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11456 tdata->ciphertext.data + off,
11458 "Ciphertext data not as expected");
11460 off += to_trn_tbl[ecx++];
11464 auth_tag = digest_mem;
11465 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11467 tdata->auth_tag.data,
11468 tdata->auth_tag.len,
11469 "Generated auth tag not as expected");
11475 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11477 return test_authenticated_encryption_SGL(
11478 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11482 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11484 return test_authenticated_encryption_SGL(
11485 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11489 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11491 return test_authenticated_encryption_SGL(
11492 &gcm_test_case_8, OUT_OF_PLACE, 400,
11493 gcm_test_case_8.plaintext.len);
11497 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11500 return test_authenticated_encryption_SGL(
11501 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11505 test_authentication_verify_fail_when_data_corrupted(
11506 struct crypto_testsuite_params *ts_params,
11507 struct crypto_unittest_params *ut_params,
11508 const struct test_crypto_vector *reference)
11510 return test_authentication_verify_fail_when_data_corruption(
11511 ts_params, ut_params, reference, 1);
11515 test_authentication_verify_fail_when_tag_corrupted(
11516 struct crypto_testsuite_params *ts_params,
11517 struct crypto_unittest_params *ut_params,
11518 const struct test_crypto_vector *reference)
11520 return test_authentication_verify_fail_when_data_corruption(
11521 ts_params, ut_params, reference, 0);
11525 test_authentication_verify_GMAC_fail_when_data_corrupted(
11526 struct crypto_testsuite_params *ts_params,
11527 struct crypto_unittest_params *ut_params,
11528 const struct test_crypto_vector *reference)
11530 return test_authentication_verify_GMAC_fail_when_corruption(
11531 ts_params, ut_params, reference, 1);
11535 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11536 struct crypto_testsuite_params *ts_params,
11537 struct crypto_unittest_params *ut_params,
11538 const struct test_crypto_vector *reference)
11540 return test_authentication_verify_GMAC_fail_when_corruption(
11541 ts_params, ut_params, reference, 0);
11545 test_authenticated_decryption_fail_when_data_corrupted(
11546 struct crypto_testsuite_params *ts_params,
11547 struct crypto_unittest_params *ut_params,
11548 const struct test_crypto_vector *reference)
11550 return test_authenticated_decryption_fail_when_corruption(
11551 ts_params, ut_params, reference, 1);
11555 test_authenticated_decryption_fail_when_tag_corrupted(
11556 struct crypto_testsuite_params *ts_params,
11557 struct crypto_unittest_params *ut_params,
11558 const struct test_crypto_vector *reference)
11560 return test_authenticated_decryption_fail_when_corruption(
11561 ts_params, ut_params, reference, 0);
11565 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11567 return test_authentication_verify_fail_when_data_corrupted(
11568 &testsuite_params, &unittest_params,
11569 &hmac_sha1_test_crypto_vector);
11573 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11575 return test_authentication_verify_fail_when_tag_corrupted(
11576 &testsuite_params, &unittest_params,
11577 &hmac_sha1_test_crypto_vector);
11581 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11583 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11584 &testsuite_params, &unittest_params,
11585 &aes128_gmac_test_vector);
11589 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11591 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11592 &testsuite_params, &unittest_params,
11593 &aes128_gmac_test_vector);
11597 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11599 return test_authenticated_decryption_fail_when_data_corrupted(
11602 &aes128cbc_hmac_sha1_test_vector);
11606 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11608 return test_authenticated_decryption_fail_when_tag_corrupted(
11611 &aes128cbc_hmac_sha1_test_vector);
11615 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11617 return test_authenticated_encryt_with_esn(
11620 &aes128cbc_hmac_sha1_aad_test_vector);
11624 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11626 return test_authenticated_decrypt_with_esn(
11629 &aes128cbc_hmac_sha1_aad_test_vector);
11632 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11634 /* global AESNI slave IDs for the scheduler test */
11635 uint8_t aesni_ids[2];
11638 test_scheduler_attach_slave_op(void)
11640 struct crypto_testsuite_params *ts_params = &testsuite_params;
11641 uint8_t sched_id = ts_params->valid_devs[0];
11642 uint32_t nb_devs, i, nb_devs_attached = 0;
11644 char vdev_name[32];
11646 /* create 2 AESNI_MB if necessary */
11647 nb_devs = rte_cryptodev_device_count_by_driver(
11648 rte_cryptodev_driver_id_get(
11649 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11651 for (i = nb_devs; i < 2; i++) {
11652 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11653 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11655 ret = rte_vdev_init(vdev_name, NULL);
11657 TEST_ASSERT(ret == 0,
11658 "Failed to create instance %u of"
11660 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11664 /* attach 2 AESNI_MB cdevs */
11665 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11667 struct rte_cryptodev_info info;
11668 unsigned int session_size;
11670 rte_cryptodev_info_get(i, &info);
11671 if (info.driver_id != rte_cryptodev_driver_id_get(
11672 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11675 session_size = rte_cryptodev_sym_get_private_session_size(i);
11677 * Create the session mempool again, since now there are new devices
11678 * to use the mempool.
11680 if (ts_params->session_mpool) {
11681 rte_mempool_free(ts_params->session_mpool);
11682 ts_params->session_mpool = NULL;
11684 if (ts_params->session_priv_mpool) {
11685 rte_mempool_free(ts_params->session_priv_mpool);
11686 ts_params->session_priv_mpool = NULL;
11689 if (info.sym.max_nb_sessions != 0 &&
11690 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11691 RTE_LOG(ERR, USER1,
11692 "Device does not support "
11693 "at least %u sessions\n",
11695 return TEST_FAILED;
11698 * Create mempool with maximum number of sessions,
11699 * to include the session headers
11701 if (ts_params->session_mpool == NULL) {
11702 ts_params->session_mpool =
11703 rte_cryptodev_sym_session_pool_create(
11705 MAX_NB_SESSIONS, 0, 0, 0,
11707 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11708 "session mempool allocation failed");
11712 * Create mempool with maximum number of sessions,
11713 * to include device specific session private data
11715 if (ts_params->session_priv_mpool == NULL) {
11716 ts_params->session_priv_mpool = rte_mempool_create(
11717 "test_sess_mp_priv",
11720 0, 0, NULL, NULL, NULL,
11721 NULL, SOCKET_ID_ANY,
11724 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11725 "session mempool allocation failed");
11728 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11729 ts_params->qp_conf.mp_session_private =
11730 ts_params->session_priv_mpool;
11732 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11735 TEST_ASSERT(ret == 0,
11736 "Failed to attach device %u of pmd : %s", i,
11737 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11739 aesni_ids[nb_devs_attached] = (uint8_t)i;
11741 nb_devs_attached++;
11748 test_scheduler_detach_slave_op(void)
11750 struct crypto_testsuite_params *ts_params = &testsuite_params;
11751 uint8_t sched_id = ts_params->valid_devs[0];
11755 for (i = 0; i < 2; i++) {
11756 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11758 TEST_ASSERT(ret == 0,
11759 "Failed to detach device %u", aesni_ids[i]);
11766 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11768 struct crypto_testsuite_params *ts_params = &testsuite_params;
11769 uint8_t sched_id = ts_params->valid_devs[0];
11771 return rte_cryptodev_scheduler_mode_set(sched_id,
11776 test_scheduler_mode_roundrobin_op(void)
11778 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11779 0, "Failed to set roundrobin mode");
11785 test_scheduler_mode_multicore_op(void)
11787 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11788 0, "Failed to set multicore mode");
11794 test_scheduler_mode_failover_op(void)
11796 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11797 0, "Failed to set failover mode");
11803 test_scheduler_mode_pkt_size_distr_op(void)
11805 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11806 0, "Failed to set pktsize mode");
11811 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11812 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11813 .setup = testsuite_setup,
11814 .teardown = testsuite_teardown,
11815 .unit_test_cases = {
11817 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11818 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_AES_chain_scheduler_all),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_cipheronly_scheduler_all),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_authonly_scheduler_all),
11825 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11828 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11829 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_chain_scheduler_all),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_cipheronly_scheduler_all),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_authonly_scheduler_all),
11836 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11839 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11840 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_chain_scheduler_all),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_cipheronly_scheduler_all),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_authonly_scheduler_all),
11847 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11850 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11851 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_chain_scheduler_all),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_cipheronly_scheduler_all),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_authonly_scheduler_all),
11858 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11860 TEST_CASES_END() /**< NULL terminate unit test array */
11864 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11866 static struct unit_test_suite cryptodev_qat_testsuite = {
11867 .suite_name = "Crypto QAT Unit Test Suite",
11868 .setup = testsuite_setup,
11869 .teardown = testsuite_teardown,
11870 .unit_test_cases = {
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_device_configure_invalid_dev_id),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_device_configure_invalid_queue_pair_ids),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_queue_pair_descriptor_setup),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_multi_session),
11880 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_cipheronly_qat_all),
11883 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_3DES_cipheronly_qat_all),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_DES_cipheronly_qat_all),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_AES_docsis_qat_all),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_DES_docsis_qat_all),
11892 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11893 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11895 /** AES CCM Authenticated Encryption 128 bits key */
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_CCM_authenticated_encryption_test_case_128_1),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_CCM_authenticated_encryption_test_case_128_2),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_CCM_authenticated_encryption_test_case_128_3),
11903 /** AES CCM Authenticated Decryption 128 bits key*/
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_AES_CCM_authenticated_decryption_test_case_128_1),
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_AES_CCM_authenticated_decryption_test_case_128_2),
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_AES_CCM_authenticated_decryption_test_case_128_3),
11911 /** AES GCM Authenticated Encryption */
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_AES_GCM_authenticated_encryption_test_case_1),
11920 TEST_CASE_ST(ut_setup, ut_teardown,
11921 test_AES_GCM_authenticated_encryption_test_case_2),
11922 TEST_CASE_ST(ut_setup, ut_teardown,
11923 test_AES_GCM_authenticated_encryption_test_case_3),
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_AES_GCM_authenticated_encryption_test_case_4),
11926 TEST_CASE_ST(ut_setup, ut_teardown,
11927 test_AES_GCM_authenticated_encryption_test_case_5),
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_AES_GCM_authenticated_encryption_test_case_6),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_AES_GCM_authenticated_encryption_test_case_7),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_AES_GCM_authenticated_encryption_test_case_8),
11935 /** AES GCM Authenticated Decryption */
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_AES_GCM_authenticated_decryption_test_case_1),
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_AES_GCM_authenticated_decryption_test_case_2),
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_AES_GCM_authenticated_decryption_test_case_3),
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_AES_GCM_authenticated_decryption_test_case_4),
11944 TEST_CASE_ST(ut_setup, ut_teardown,
11945 test_AES_GCM_authenticated_decryption_test_case_5),
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_AES_GCM_authenticated_decryption_test_case_6),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GCM_authenticated_decryption_test_case_7),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_GCM_authenticated_decryption_test_case_8),
11953 /** AES GCM Authenticated Encryption 192 bits key */
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GCM_auth_encryption_test_case_192_1),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_GCM_auth_encryption_test_case_192_2),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_GCM_auth_encryption_test_case_192_3),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_GCM_auth_encryption_test_case_192_4),
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 test_AES_GCM_auth_encryption_test_case_192_5),
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_AES_GCM_auth_encryption_test_case_192_6),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_AES_GCM_auth_encryption_test_case_192_7),
11969 /** AES GCM Authenticated Decryption 192 bits key */
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_AES_GCM_auth_decryption_test_case_192_1),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_AES_GCM_auth_decryption_test_case_192_2),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_AES_GCM_auth_decryption_test_case_192_3),
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_AES_GCM_auth_decryption_test_case_192_4),
11978 TEST_CASE_ST(ut_setup, ut_teardown,
11979 test_AES_GCM_auth_decryption_test_case_192_5),
11980 TEST_CASE_ST(ut_setup, ut_teardown,
11981 test_AES_GCM_auth_decryption_test_case_192_6),
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_AES_GCM_auth_decryption_test_case_192_7),
11985 /** AES GCM Authenticated Encryption 256 bits key */
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_AES_GCM_auth_encryption_test_case_256_1),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_AES_GCM_auth_encryption_test_case_256_2),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_AES_GCM_auth_encryption_test_case_256_3),
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_AES_GCM_auth_encryption_test_case_256_4),
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_AES_GCM_auth_encryption_test_case_256_5),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_AES_GCM_auth_encryption_test_case_256_6),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_AES_GCM_auth_encryption_test_case_256_7),
12001 /** AES GCM Authenticated Decryption 256 bits key */
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_AES_GCM_auth_decryption_test_case_256_1),
12004 TEST_CASE_ST(ut_setup, ut_teardown,
12005 test_AES_GCM_auth_decryption_test_case_256_2),
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_AES_GCM_auth_decryption_test_case_256_3),
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_AES_GCM_auth_decryption_test_case_256_4),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_AES_GCM_auth_decryption_test_case_256_5),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_AES_GCM_auth_decryption_test_case_256_6),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_AES_GCM_auth_decryption_test_case_256_7),
12017 /** AES GMAC Authentication */
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_AES_GMAC_authentication_test_case_1),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_AES_GMAC_authentication_verify_test_case_1),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_AES_GMAC_authentication_test_case_2),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_AES_GMAC_authentication_verify_test_case_2),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_AES_GMAC_authentication_test_case_3),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_AES_GMAC_authentication_verify_test_case_3),
12031 /** SNOW 3G encrypt only (UEA2) */
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_encryption_test_case_1),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_snow3g_encryption_test_case_2),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_encryption_test_case_3),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_encryption_test_case_4),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_encryption_test_case_5),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_snow3g_encryption_test_case_1_oop),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_snow3g_decryption_test_case_1_oop),
12048 /** SNOW 3G generate auth, then encrypt (UEA2) */
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_snow3g_auth_cipher_test_case_1),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_snow3g_auth_cipher_test_case_2),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_snow3g_auth_cipher_test_case_2_oop),
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_snow3g_auth_cipher_part_digest_enc),
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_snow3g_auth_cipher_part_digest_enc_oop),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_snow3g_auth_cipher_test_case_3_sgl),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_snow3g_auth_cipher_part_digest_enc_sgl),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12068 /** SNOW 3G decrypt (UEA2), then verify auth */
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_snow3g_auth_cipher_verify_test_case_1),
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_snow3g_auth_cipher_verify_test_case_2),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_snow3g_auth_cipher_verify_test_case_2_oop),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_snow3g_auth_cipher_verify_part_digest_enc),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12088 /** SNOW 3G decrypt only (UEA2) */
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_snow3g_decryption_test_case_1),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_snow3g_decryption_test_case_2),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_snow3g_decryption_test_case_3),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_snow3g_decryption_test_case_4),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_snow3g_decryption_test_case_5),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_snow3g_decryption_with_digest_test_case_1),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_snow3g_hash_generate_test_case_1),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_snow3g_hash_generate_test_case_2),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_snow3g_hash_generate_test_case_3),
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_snow3g_hash_verify_test_case_1),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_snow3g_hash_verify_test_case_2),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_snow3g_hash_verify_test_case_3),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_snow3g_cipher_auth_test_case_1),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_snow3g_auth_cipher_with_digest_test_case_1),
12118 /** ZUC encrypt only (EEA3) */
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_zuc_encryption_test_case_1),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_zuc_encryption_test_case_2),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_zuc_encryption_test_case_3),
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_zuc_encryption_test_case_4),
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_zuc_encryption_test_case_5),
12130 /** ZUC authenticate (EIA3) */
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_zuc_hash_generate_test_case_6),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_zuc_hash_generate_test_case_7),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_zuc_hash_generate_test_case_8),
12138 /** ZUC alg-chain (EEA3/EIA3) */
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_zuc_cipher_auth_test_case_1),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_zuc_cipher_auth_test_case_2),
12144 /** ZUC generate auth, then encrypt (EEA3) */
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_zuc_auth_cipher_test_case_1),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_zuc_auth_cipher_test_case_1_oop),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_zuc_auth_cipher_test_case_1_sgl),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_zuc_auth_cipher_test_case_1_oop_sgl),
12154 /** ZUC decrypt (EEA3), then verify auth */
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_zuc_auth_cipher_verify_test_case_1),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_zuc_auth_cipher_verify_test_case_1_oop),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_zuc_auth_cipher_verify_test_case_1_sgl),
12161 TEST_CASE_ST(ut_setup, ut_teardown,
12162 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12164 /** HMAC_MD5 Authentication */
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_MD5_HMAC_generate_case_1),
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_MD5_HMAC_verify_case_1),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_MD5_HMAC_generate_case_2),
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 test_MD5_HMAC_verify_case_2),
12174 /** NULL algo tests done in chain_all,
12175 * cipheronly and authonly suites
12178 /** KASUMI tests */
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_kasumi_hash_generate_test_case_1),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_kasumi_hash_generate_test_case_2),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_kasumi_hash_generate_test_case_3),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_kasumi_hash_generate_test_case_4),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_generate_test_case_5),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_generate_test_case_6),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_kasumi_hash_verify_test_case_1),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_kasumi_hash_verify_test_case_2),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_kasumi_hash_verify_test_case_3),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_kasumi_hash_verify_test_case_4),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_kasumi_hash_verify_test_case_5),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_encryption_test_case_1),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_encryption_test_case_3),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_cipher_auth_test_case_1),
12210 /** KASUMI generate auth, then encrypt (F8) */
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_auth_cipher_test_case_1),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_auth_cipher_test_case_2),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_auth_cipher_test_case_2_oop),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_auth_cipher_test_case_2_sgl),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12222 /** KASUMI decrypt (F8), then verify auth */
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_auth_cipher_verify_test_case_1),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_kasumi_auth_cipher_verify_test_case_2),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_auth_cipher_verify_test_case_2_oop),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12234 /** Negative tests */
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 authentication_verify_AES128_GMAC_fail_data_corrupt),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12272 /** Mixed CIPHER + HASH algorithms */
12273 /** AUTH AES CMAC + CIPHER AES CTR */
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12291 TEST_CASES_END() /**< NULL terminate unit test array */
12295 static struct unit_test_suite cryptodev_virtio_testsuite = {
12296 .suite_name = "Crypto VIRTIO Unit Test Suite",
12297 .setup = testsuite_setup,
12298 .teardown = testsuite_teardown,
12299 .unit_test_cases = {
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_AES_cipheronly_virtio_all),
12303 TEST_CASES_END() /**< NULL terminate unit test array */
12307 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12308 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12309 .setup = testsuite_setup,
12310 .teardown = testsuite_teardown,
12311 .unit_test_cases = {
12312 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_AES_GCM_authenticated_encryption_test_case_1),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_AES_GCM_authenticated_encryption_test_case_2),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_AES_GCM_authenticated_encryption_test_case_3),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_AES_GCM_authenticated_encryption_test_case_4),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_GCM_authenticated_encryption_test_case_5),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_AES_GCM_authenticated_encryption_test_case_6),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_AES_GCM_authenticated_encryption_test_case_7),
12328 /** AES GCM Authenticated Decryption */
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_AES_GCM_authenticated_decryption_test_case_1),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_AES_GCM_authenticated_decryption_test_case_2),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_AES_GCM_authenticated_decryption_test_case_3),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_AES_GCM_authenticated_decryption_test_case_4),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_AES_GCM_authenticated_decryption_test_case_5),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_AES_GCM_authenticated_decryption_test_case_6),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_AES_GCM_authenticated_decryption_test_case_7),
12344 /** AES GCM Authenticated Encryption 192 bits key */
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_AES_GCM_auth_encryption_test_case_192_1),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_AES_GCM_auth_encryption_test_case_192_2),
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_AES_GCM_auth_encryption_test_case_192_3),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_AES_GCM_auth_encryption_test_case_192_4),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_AES_GCM_auth_encryption_test_case_192_5),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_AES_GCM_auth_encryption_test_case_192_6),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_AES_GCM_auth_encryption_test_case_192_7),
12360 /** AES GCM Authenticated Decryption 192 bits key */
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_AES_GCM_auth_decryption_test_case_192_1),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_AES_GCM_auth_decryption_test_case_192_2),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_AES_GCM_auth_decryption_test_case_192_3),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_AES_GCM_auth_decryption_test_case_192_4),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_AES_GCM_auth_decryption_test_case_192_5),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_AES_GCM_auth_decryption_test_case_192_6),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_AES_GCM_auth_decryption_test_case_192_7),
12376 /** AES GCM Authenticated Encryption 256 bits key */
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_AES_GCM_auth_encryption_test_case_256_1),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GCM_auth_encryption_test_case_256_2),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_AES_GCM_auth_encryption_test_case_256_3),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_AES_GCM_auth_encryption_test_case_256_4),
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_AES_GCM_auth_encryption_test_case_256_5),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_AES_GCM_auth_encryption_test_case_256_6),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_AES_GCM_auth_encryption_test_case_256_7),
12392 /** AES GCM Authenticated Decryption 256 bits key */
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_auth_decryption_test_case_256_1),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_auth_decryption_test_case_256_2),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_AES_GCM_auth_decryption_test_case_256_3),
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_AES_GCM_auth_decryption_test_case_256_4),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_auth_decryption_test_case_256_5),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_AES_GCM_auth_decryption_test_case_256_6),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_AES_GCM_auth_decryption_test_case_256_7),
12408 /** AES GCM Authenticated Encryption big aad size */
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_AES_GCM_auth_encryption_test_case_aad_1),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_AES_GCM_auth_encryption_test_case_aad_2),
12414 /** AES GCM Authenticated Decryption big aad size */
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_AES_GCM_auth_decryption_test_case_aad_1),
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_AES_GCM_auth_decryption_test_case_aad_2),
12420 /** Session-less tests */
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12426 /** AES GMAC Authentication */
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GMAC_authentication_test_case_1),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GMAC_authentication_verify_test_case_1),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GMAC_authentication_test_case_2),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GMAC_authentication_verify_test_case_2),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GMAC_authentication_test_case_3),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GMAC_authentication_verify_test_case_3),
12439 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12441 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12442 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12443 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12444 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_DES_cipheronly_mb_all),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_DES_docsis_mb_all),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_3DES_cipheronly_mb_all),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_AES_CCM_authenticated_encryption_test_case_128_1),
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_AES_CCM_authenticated_decryption_test_case_128_1),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_AES_CCM_authenticated_encryption_test_case_128_2),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_AES_CCM_authenticated_decryption_test_case_128_2),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_CCM_authenticated_encryption_test_case_128_3),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_AES_CCM_authenticated_decryption_test_case_128_3),
12464 TEST_CASES_END() /**< NULL terminate unit test array */
12468 static struct unit_test_suite cryptodev_openssl_testsuite = {
12469 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12470 .setup = testsuite_setup,
12471 .teardown = testsuite_teardown,
12472 .unit_test_cases = {
12473 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_multi_session_random_usage),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_chain_openssl_all),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_AES_cipheronly_openssl_all),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_3DES_chain_openssl_all),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_3DES_cipheronly_openssl_all),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_DES_cipheronly_openssl_all),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_DES_docsis_openssl_all),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_authonly_openssl_all),
12491 /** AES GCM Authenticated Encryption */
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_AES_GCM_authenticated_encryption_test_case_1),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_AES_GCM_authenticated_encryption_test_case_2),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_AES_GCM_authenticated_encryption_test_case_3),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_AES_GCM_authenticated_encryption_test_case_4),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_authenticated_encryption_test_case_5),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_authenticated_encryption_test_case_6),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_authenticated_encryption_test_case_7),
12507 /** AES GCM Authenticated Decryption */
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_authenticated_decryption_test_case_1),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_authenticated_decryption_test_case_2),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_authenticated_decryption_test_case_3),
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_AES_GCM_authenticated_decryption_test_case_4),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_authenticated_decryption_test_case_5),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_authenticated_decryption_test_case_6),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_authenticated_decryption_test_case_7),
12524 /** AES GCM Authenticated Encryption 192 bits key */
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_AES_GCM_auth_encryption_test_case_192_1),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_AES_GCM_auth_encryption_test_case_192_2),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_AES_GCM_auth_encryption_test_case_192_3),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_AES_GCM_auth_encryption_test_case_192_4),
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_AES_GCM_auth_encryption_test_case_192_5),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_AES_GCM_auth_encryption_test_case_192_6),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_AES_GCM_auth_encryption_test_case_192_7),
12540 /** AES GCM Authenticated Decryption 192 bits key */
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_AES_GCM_auth_decryption_test_case_192_1),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_AES_GCM_auth_decryption_test_case_192_2),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_AES_GCM_auth_decryption_test_case_192_3),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_AES_GCM_auth_decryption_test_case_192_4),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_AES_GCM_auth_decryption_test_case_192_5),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_AES_GCM_auth_decryption_test_case_192_6),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_AES_GCM_auth_decryption_test_case_192_7),
12556 /** AES GCM Authenticated Encryption 256 bits key */
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_AES_GCM_auth_encryption_test_case_256_1),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_AES_GCM_auth_encryption_test_case_256_2),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_AES_GCM_auth_encryption_test_case_256_3),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 test_AES_GCM_auth_encryption_test_case_256_4),
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_AES_GCM_auth_encryption_test_case_256_5),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_AES_GCM_auth_encryption_test_case_256_6),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_AES_GCM_auth_encryption_test_case_256_7),
12572 /** AES GCM Authenticated Decryption 256 bits key */
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_AES_GCM_auth_decryption_test_case_256_1),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_AES_GCM_auth_decryption_test_case_256_2),
12577 TEST_CASE_ST(ut_setup, ut_teardown,
12578 test_AES_GCM_auth_decryption_test_case_256_3),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_AES_GCM_auth_decryption_test_case_256_4),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_AES_GCM_auth_decryption_test_case_256_5),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_AES_GCM_auth_decryption_test_case_256_6),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_AES_GCM_auth_decryption_test_case_256_7),
12588 /** AES GMAC Authentication */
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_AES_GMAC_authentication_test_case_1),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_AES_GMAC_authentication_verify_test_case_1),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_AES_GMAC_authentication_test_case_2),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_AES_GMAC_authentication_verify_test_case_2),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_AES_GMAC_authentication_test_case_3),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_AES_GMAC_authentication_verify_test_case_3),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_AES_GMAC_authentication_test_case_4),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_AES_GMAC_authentication_verify_test_case_4),
12606 /** AES CCM Authenticated Encryption 128 bits key */
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_AES_CCM_authenticated_encryption_test_case_128_1),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_AES_CCM_authenticated_encryption_test_case_128_2),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_AES_CCM_authenticated_encryption_test_case_128_3),
12614 /** AES CCM Authenticated Decryption 128 bits key*/
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_AES_CCM_authenticated_decryption_test_case_128_1),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_AES_CCM_authenticated_decryption_test_case_128_2),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_AES_CCM_authenticated_decryption_test_case_128_3),
12622 /** AES CCM Authenticated Encryption 192 bits key */
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_AES_CCM_authenticated_encryption_test_case_192_1),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_AES_CCM_authenticated_encryption_test_case_192_2),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_AES_CCM_authenticated_encryption_test_case_192_3),
12630 /** AES CCM Authenticated Decryption 192 bits key*/
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_AES_CCM_authenticated_decryption_test_case_192_1),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_AES_CCM_authenticated_decryption_test_case_192_2),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_AES_CCM_authenticated_decryption_test_case_192_3),
12638 /** AES CCM Authenticated Encryption 256 bits key */
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_AES_CCM_authenticated_encryption_test_case_256_1),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_AES_CCM_authenticated_encryption_test_case_256_2),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_AES_CCM_authenticated_encryption_test_case_256_3),
12646 /** AES CCM Authenticated Decryption 256 bits key*/
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_AES_CCM_authenticated_decryption_test_case_256_1),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 test_AES_CCM_authenticated_decryption_test_case_256_2),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 test_AES_CCM_authenticated_decryption_test_case_256_3),
12654 /** Scatter-Gather */
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12658 /** Negative tests */
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 authentication_verify_AES128_GMAC_fail_data_corrupt),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12679 TEST_CASES_END() /**< NULL terminate unit test array */
12683 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12684 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12685 .setup = testsuite_setup,
12686 .teardown = testsuite_teardown,
12687 .unit_test_cases = {
12688 /** AES GCM Authenticated Encryption */
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_AES_GCM_authenticated_encryption_test_case_1),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_AES_GCM_authenticated_encryption_test_case_2),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_AES_GCM_authenticated_encryption_test_case_3),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_AES_GCM_authenticated_encryption_test_case_4),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_AES_GCM_authenticated_encryption_test_case_5),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_AES_GCM_authenticated_encryption_test_case_6),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_AES_GCM_authenticated_encryption_test_case_7),
12704 /** AES GCM Authenticated Decryption */
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_AES_GCM_authenticated_decryption_test_case_1),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_AES_GCM_authenticated_decryption_test_case_2),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_authenticated_decryption_test_case_3),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_AES_GCM_authenticated_decryption_test_case_4),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_authenticated_decryption_test_case_5),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_authenticated_decryption_test_case_6),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_authenticated_decryption_test_case_7),
12720 /** AES GCM Authenticated Encryption 192 bits key */
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_auth_encryption_test_case_192_1),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_auth_encryption_test_case_192_2),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_auth_encryption_test_case_192_3),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_auth_encryption_test_case_192_4),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_auth_encryption_test_case_192_5),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_auth_encryption_test_case_192_6),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_auth_encryption_test_case_192_7),
12736 /** AES GCM Authenticated Decryption 192 bits key */
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_AES_GCM_auth_decryption_test_case_192_1),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_auth_decryption_test_case_192_2),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_auth_decryption_test_case_192_3),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_auth_decryption_test_case_192_4),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_auth_decryption_test_case_192_5),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_auth_decryption_test_case_192_6),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_auth_decryption_test_case_192_7),
12752 /** AES GCM Authenticated Encryption 256 bits key */
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_auth_encryption_test_case_256_1),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_auth_encryption_test_case_256_2),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_encryption_test_case_256_3),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_encryption_test_case_256_4),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_256_5),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_256_6),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_256_7),
12768 /** AES GCM Authenticated Decryption 256 bits key */
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_auth_decryption_test_case_256_1),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_auth_decryption_test_case_256_2),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_auth_decryption_test_case_256_3),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_auth_decryption_test_case_256_4),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_256_5),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_256_6),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_256_7),
12784 /** AES GCM Authenticated Encryption big aad size */
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_auth_encryption_test_case_aad_1),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_auth_encryption_test_case_aad_2),
12790 /** AES GCM Authenticated Decryption big aad size */
12791 TEST_CASE_ST(ut_setup, ut_teardown,
12792 test_AES_GCM_auth_decryption_test_case_aad_1),
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_auth_decryption_test_case_aad_2),
12796 /** AES GMAC Authentication */
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_AES_GMAC_authentication_test_case_1),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_AES_GMAC_authentication_verify_test_case_1),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GMAC_authentication_test_case_3),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_AES_GMAC_authentication_verify_test_case_3),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_AES_GMAC_authentication_test_case_4),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_AES_GMAC_authentication_verify_test_case_4),
12810 /** Negative tests */
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 authentication_verify_AES128_GMAC_fail_data_corrupt),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12816 /** Out of place tests */
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12822 /** Session-less tests */
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12828 /** Scatter-Gather */
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12832 TEST_CASES_END() /**< NULL terminate unit test array */
12836 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12837 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12838 .setup = testsuite_setup,
12839 .teardown = testsuite_teardown,
12840 .unit_test_cases = {
12841 /** KASUMI encrypt only (UEA1) */
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_kasumi_encryption_test_case_1),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_kasumi_encryption_test_case_1_sgl),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_kasumi_encryption_test_case_2),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_kasumi_encryption_test_case_3),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_kasumi_encryption_test_case_4),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_kasumi_encryption_test_case_5),
12854 /** KASUMI decrypt only (UEA1) */
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_kasumi_decryption_test_case_1),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_kasumi_decryption_test_case_2),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_kasumi_decryption_test_case_3),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_kasumi_decryption_test_case_4),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_kasumi_decryption_test_case_5),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_kasumi_encryption_test_case_1_oop),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_kasumi_encryption_test_case_1_oop_sgl),
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_kasumi_decryption_test_case_1_oop),
12875 /** KASUMI hash only (UIA1) */
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_kasumi_hash_generate_test_case_1),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_kasumi_hash_generate_test_case_2),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_kasumi_hash_generate_test_case_3),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_kasumi_hash_generate_test_case_4),
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_kasumi_hash_generate_test_case_5),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_kasumi_hash_generate_test_case_6),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_kasumi_hash_verify_test_case_1),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_kasumi_hash_verify_test_case_2),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_kasumi_hash_verify_test_case_3),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_kasumi_hash_verify_test_case_4),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_hash_verify_test_case_5),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_cipher_auth_test_case_1),
12901 /** KASUMI generate auth, then encrypt (F8) */
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_auth_cipher_test_case_1),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_kasumi_auth_cipher_test_case_2),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_kasumi_auth_cipher_test_case_2_oop),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_kasumi_auth_cipher_test_case_2_sgl),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12913 /** KASUMI decrypt (F8), then verify auth */
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_kasumi_auth_cipher_verify_test_case_1),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_kasumi_auth_cipher_verify_test_case_2),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_kasumi_auth_cipher_verify_test_case_2_oop),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12924 TEST_CASES_END() /**< NULL terminate unit test array */
12927 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12928 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12929 .setup = testsuite_setup,
12930 .teardown = testsuite_teardown,
12931 .unit_test_cases = {
12932 /** SNOW 3G encrypt only (UEA2) */
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_snow3g_encryption_test_case_1),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 test_snow3g_encryption_test_case_2),
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 test_snow3g_encryption_test_case_3),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_snow3g_encryption_test_case_4),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_snow3g_encryption_test_case_5),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_snow3g_auth_cipher_with_digest_test_case_1),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_snow3g_encryption_test_case_1_oop),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_snow3g_encryption_test_case_1_oop_sgl),
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_snow3g_decryption_test_case_1_oop),
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_snow3g_encryption_test_case_1_offset_oop),
12956 /** SNOW 3G decrypt only (UEA2) */
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_snow3g_decryption_test_case_1),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_snow3g_decryption_test_case_2),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_snow3g_decryption_test_case_3),
12963 TEST_CASE_ST(ut_setup, ut_teardown,
12964 test_snow3g_decryption_test_case_4),
12965 TEST_CASE_ST(ut_setup, ut_teardown,
12966 test_snow3g_decryption_test_case_5),
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_snow3g_decryption_with_digest_test_case_1),
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_snow3g_hash_generate_test_case_1),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_snow3g_hash_generate_test_case_2),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_snow3g_hash_generate_test_case_3),
12975 /* Tests with buffers which length is not byte-aligned */
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_snow3g_hash_generate_test_case_4),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_snow3g_hash_generate_test_case_5),
12980 TEST_CASE_ST(ut_setup, ut_teardown,
12981 test_snow3g_hash_generate_test_case_6),
12982 TEST_CASE_ST(ut_setup, ut_teardown,
12983 test_snow3g_hash_verify_test_case_1),
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_snow3g_hash_verify_test_case_2),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_snow3g_hash_verify_test_case_3),
12988 /* Tests with buffers which length is not byte-aligned */
12989 TEST_CASE_ST(ut_setup, ut_teardown,
12990 test_snow3g_hash_verify_test_case_4),
12991 TEST_CASE_ST(ut_setup, ut_teardown,
12992 test_snow3g_hash_verify_test_case_5),
12993 TEST_CASE_ST(ut_setup, ut_teardown,
12994 test_snow3g_hash_verify_test_case_6),
12995 TEST_CASE_ST(ut_setup, ut_teardown,
12996 test_snow3g_cipher_auth_test_case_1),
12998 /** SNOW 3G generate auth, then encrypt (UEA2) */
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_snow3g_auth_cipher_test_case_1),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_snow3g_auth_cipher_test_case_2),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_snow3g_auth_cipher_test_case_2_oop),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_snow3g_auth_cipher_part_digest_enc),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_snow3g_auth_cipher_part_digest_enc_oop),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_snow3g_auth_cipher_test_case_3_sgl),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_snow3g_auth_cipher_part_digest_enc_sgl),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13018 /** SNOW 3G decrypt (UEA2), then verify auth */
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_snow3g_auth_cipher_verify_test_case_1),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_snow3g_auth_cipher_verify_test_case_2),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_snow3g_auth_cipher_verify_test_case_2_oop),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_snow3g_auth_cipher_verify_part_digest_enc),
13027 TEST_CASE_ST(ut_setup, ut_teardown,
13028 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13038 TEST_CASES_END() /**< NULL terminate unit test array */
13042 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
13043 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13044 .setup = testsuite_setup,
13045 .teardown = testsuite_teardown,
13046 .unit_test_cases = {
13047 /** ZUC encrypt only (EEA3) */
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_zuc_encryption_test_case_1),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_zuc_encryption_test_case_2),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_zuc_encryption_test_case_3),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_zuc_encryption_test_case_4),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_zuc_encryption_test_case_5),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_zuc_hash_generate_test_case_1),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_zuc_hash_generate_test_case_2),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_zuc_hash_generate_test_case_3),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_zuc_hash_generate_test_case_4),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_zuc_hash_generate_test_case_5),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_zuc_encryption_test_case_6_sgl),
13070 TEST_CASES_END() /**< NULL terminate unit test array */
13074 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13075 .suite_name = "Crypto CAAM JR Unit Test Suite",
13076 .setup = testsuite_setup,
13077 .teardown = testsuite_teardown,
13078 .unit_test_cases = {
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_device_configure_invalid_dev_id),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_multi_session),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_AES_chain_caam_jr_all),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_3DES_chain_caam_jr_all),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_AES_cipheronly_caam_jr_all),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_3DES_cipheronly_caam_jr_all),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_authonly_caam_jr_all),
13095 TEST_CASES_END() /**< NULL terminate unit test array */
13099 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
13100 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13101 .setup = testsuite_setup,
13102 .teardown = testsuite_teardown,
13103 .unit_test_cases = {
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_device_configure_invalid_dev_id),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_multi_session),
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_AES_chain_dpaa_sec_all),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_3DES_chain_dpaa_sec_all),
13113 TEST_CASE_ST(ut_setup, ut_teardown,
13114 test_AES_cipheronly_dpaa_sec_all),
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_3DES_cipheronly_dpaa_sec_all),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_authonly_dpaa_sec_all),
13120 #ifdef RTE_LIBRTE_SECURITY
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_PDCP_PROTO_cplane_encap_all),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_PDCP_PROTO_cplane_decap_all),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_PDCP_PROTO_uplane_encap_all),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_PDCP_PROTO_uplane_decap_all),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 test_PDCP_PROTO_SGL_in_place_32B),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_PDCP_PROTO_SGL_oop_32B_128B),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_PDCP_PROTO_SGL_oop_32B_40B),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_PDCP_PROTO_SGL_oop_128B_32B),
13142 /** AES GCM Authenticated Encryption */
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13151 TEST_CASE_ST(ut_setup, ut_teardown,
13152 test_AES_GCM_authenticated_encryption_test_case_1),
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_AES_GCM_authenticated_encryption_test_case_2),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_AES_GCM_authenticated_encryption_test_case_3),
13157 TEST_CASE_ST(ut_setup, ut_teardown,
13158 test_AES_GCM_authenticated_encryption_test_case_4),
13159 TEST_CASE_ST(ut_setup, ut_teardown,
13160 test_AES_GCM_authenticated_encryption_test_case_5),
13161 TEST_CASE_ST(ut_setup, ut_teardown,
13162 test_AES_GCM_authenticated_encryption_test_case_6),
13163 TEST_CASE_ST(ut_setup, ut_teardown,
13164 test_AES_GCM_authenticated_encryption_test_case_7),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_AES_GCM_authenticated_encryption_test_case_8),
13168 /** AES GCM Authenticated Decryption */
13169 TEST_CASE_ST(ut_setup, ut_teardown,
13170 test_AES_GCM_authenticated_decryption_test_case_1),
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_AES_GCM_authenticated_decryption_test_case_2),
13173 TEST_CASE_ST(ut_setup, ut_teardown,
13174 test_AES_GCM_authenticated_decryption_test_case_3),
13175 TEST_CASE_ST(ut_setup, ut_teardown,
13176 test_AES_GCM_authenticated_decryption_test_case_4),
13177 TEST_CASE_ST(ut_setup, ut_teardown,
13178 test_AES_GCM_authenticated_decryption_test_case_5),
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 test_AES_GCM_authenticated_decryption_test_case_6),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_AES_GCM_authenticated_decryption_test_case_7),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_AES_GCM_authenticated_decryption_test_case_8),
13186 /** AES GCM Authenticated Encryption 192 bits key */
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_AES_GCM_auth_encryption_test_case_192_1),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_AES_GCM_auth_encryption_test_case_192_2),
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_AES_GCM_auth_encryption_test_case_192_3),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_AES_GCM_auth_encryption_test_case_192_4),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_AES_GCM_auth_encryption_test_case_192_5),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_AES_GCM_auth_encryption_test_case_192_6),
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_AES_GCM_auth_encryption_test_case_192_7),
13202 /** AES GCM Authenticated Decryption 192 bits key */
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_AES_GCM_auth_decryption_test_case_192_1),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_AES_GCM_auth_decryption_test_case_192_2),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_AES_GCM_auth_decryption_test_case_192_3),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_AES_GCM_auth_decryption_test_case_192_4),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 test_AES_GCM_auth_decryption_test_case_192_5),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_AES_GCM_auth_decryption_test_case_192_6),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 test_AES_GCM_auth_decryption_test_case_192_7),
13218 /** AES GCM Authenticated Encryption 256 bits key */
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 test_AES_GCM_auth_encryption_test_case_256_1),
13221 TEST_CASE_ST(ut_setup, ut_teardown,
13222 test_AES_GCM_auth_encryption_test_case_256_2),
13223 TEST_CASE_ST(ut_setup, ut_teardown,
13224 test_AES_GCM_auth_encryption_test_case_256_3),
13225 TEST_CASE_ST(ut_setup, ut_teardown,
13226 test_AES_GCM_auth_encryption_test_case_256_4),
13227 TEST_CASE_ST(ut_setup, ut_teardown,
13228 test_AES_GCM_auth_encryption_test_case_256_5),
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_AES_GCM_auth_encryption_test_case_256_6),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_AES_GCM_auth_encryption_test_case_256_7),
13234 /** AES GCM Authenticated Decryption 256 bits key */
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_AES_GCM_auth_decryption_test_case_256_1),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_AES_GCM_auth_decryption_test_case_256_2),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_AES_GCM_auth_decryption_test_case_256_3),
13241 TEST_CASE_ST(ut_setup, ut_teardown,
13242 test_AES_GCM_auth_decryption_test_case_256_4),
13243 TEST_CASE_ST(ut_setup, ut_teardown,
13244 test_AES_GCM_auth_decryption_test_case_256_5),
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 test_AES_GCM_auth_decryption_test_case_256_6),
13247 TEST_CASE_ST(ut_setup, ut_teardown,
13248 test_AES_GCM_auth_decryption_test_case_256_7),
13250 /** Out of place tests */
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13256 /** SNOW 3G encrypt only (UEA2) */
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_snow3g_encryption_test_case_1),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_snow3g_encryption_test_case_2),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_snow3g_encryption_test_case_3),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_snow3g_encryption_test_case_4),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_snow3g_encryption_test_case_5),
13268 TEST_CASE_ST(ut_setup, ut_teardown,
13269 test_snow3g_encryption_test_case_1_oop),
13270 TEST_CASE_ST(ut_setup, ut_teardown,
13271 test_snow3g_encryption_test_case_1_oop_sgl),
13272 TEST_CASE_ST(ut_setup, ut_teardown,
13273 test_snow3g_decryption_test_case_1_oop),
13275 /** SNOW 3G decrypt only (UEA2) */
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_snow3g_decryption_test_case_1),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_snow3g_decryption_test_case_2),
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_snow3g_decryption_test_case_3),
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_snow3g_decryption_test_case_4),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_snow3g_decryption_test_case_5),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_snow3g_hash_generate_test_case_1),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_hash_generate_test_case_2),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_snow3g_hash_generate_test_case_3),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_snow3g_hash_verify_test_case_1),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_snow3g_hash_verify_test_case_2),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_snow3g_hash_verify_test_case_3),
13300 /** ZUC encrypt only (EEA3) */
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_zuc_encryption_test_case_1),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_zuc_encryption_test_case_2),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_zuc_encryption_test_case_3),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_zuc_encryption_test_case_4),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_zuc_encryption_test_case_5),
13312 /** ZUC authenticate (EIA3) */
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_zuc_hash_generate_test_case_6),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_zuc_hash_generate_test_case_7),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_zuc_hash_generate_test_case_8),
13320 /** Negative tests */
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13360 TEST_CASES_END() /**< NULL terminate unit test array */
13364 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13365 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13366 .setup = testsuite_setup,
13367 .teardown = testsuite_teardown,
13368 .unit_test_cases = {
13369 TEST_CASE_ST(ut_setup, ut_teardown,
13370 test_device_configure_invalid_dev_id),
13371 TEST_CASE_ST(ut_setup, ut_teardown,
13372 test_multi_session),
13373 TEST_CASE_ST(ut_setup, ut_teardown,
13374 test_AES_chain_dpaa2_sec_all),
13375 TEST_CASE_ST(ut_setup, ut_teardown,
13376 test_3DES_chain_dpaa2_sec_all),
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_AES_cipheronly_dpaa2_sec_all),
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 test_3DES_cipheronly_dpaa2_sec_all),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_authonly_dpaa2_sec_all),
13384 #ifdef RTE_LIBRTE_SECURITY
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_PDCP_PROTO_cplane_encap_all),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_PDCP_PROTO_cplane_decap_all),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_PDCP_PROTO_uplane_encap_all),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_PDCP_PROTO_uplane_decap_all),
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_PDCP_PROTO_SGL_in_place_32B),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_PDCP_PROTO_SGL_oop_32B_128B),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_PDCP_PROTO_SGL_oop_32B_40B),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_PDCP_PROTO_SGL_oop_128B_32B),
13406 /** AES GCM Authenticated Encryption */
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13413 TEST_CASE_ST(ut_setup, ut_teardown,
13414 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 test_AES_GCM_authenticated_encryption_test_case_1),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_AES_GCM_authenticated_encryption_test_case_2),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_AES_GCM_authenticated_encryption_test_case_3),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_AES_GCM_authenticated_encryption_test_case_4),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_AES_GCM_authenticated_encryption_test_case_5),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_AES_GCM_authenticated_encryption_test_case_6),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_AES_GCM_authenticated_encryption_test_case_7),
13429 TEST_CASE_ST(ut_setup, ut_teardown,
13430 test_AES_GCM_authenticated_encryption_test_case_8),
13432 /** AES GCM Authenticated Decryption */
13433 TEST_CASE_ST(ut_setup, ut_teardown,
13434 test_AES_GCM_authenticated_decryption_test_case_1),
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_AES_GCM_authenticated_decryption_test_case_2),
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_AES_GCM_authenticated_decryption_test_case_3),
13439 TEST_CASE_ST(ut_setup, ut_teardown,
13440 test_AES_GCM_authenticated_decryption_test_case_4),
13441 TEST_CASE_ST(ut_setup, ut_teardown,
13442 test_AES_GCM_authenticated_decryption_test_case_5),
13443 TEST_CASE_ST(ut_setup, ut_teardown,
13444 test_AES_GCM_authenticated_decryption_test_case_6),
13445 TEST_CASE_ST(ut_setup, ut_teardown,
13446 test_AES_GCM_authenticated_decryption_test_case_7),
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_AES_GCM_authenticated_decryption_test_case_8),
13450 /** AES GCM Authenticated Encryption 192 bits key */
13451 TEST_CASE_ST(ut_setup, ut_teardown,
13452 test_AES_GCM_auth_encryption_test_case_192_1),
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_AES_GCM_auth_encryption_test_case_192_2),
13455 TEST_CASE_ST(ut_setup, ut_teardown,
13456 test_AES_GCM_auth_encryption_test_case_192_3),
13457 TEST_CASE_ST(ut_setup, ut_teardown,
13458 test_AES_GCM_auth_encryption_test_case_192_4),
13459 TEST_CASE_ST(ut_setup, ut_teardown,
13460 test_AES_GCM_auth_encryption_test_case_192_5),
13461 TEST_CASE_ST(ut_setup, ut_teardown,
13462 test_AES_GCM_auth_encryption_test_case_192_6),
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_AES_GCM_auth_encryption_test_case_192_7),
13466 /** AES GCM Authenticated Decryption 192 bits key */
13467 TEST_CASE_ST(ut_setup, ut_teardown,
13468 test_AES_GCM_auth_decryption_test_case_192_1),
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GCM_auth_decryption_test_case_192_2),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GCM_auth_decryption_test_case_192_3),
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_AES_GCM_auth_decryption_test_case_192_4),
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_AES_GCM_auth_decryption_test_case_192_5),
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_AES_GCM_auth_decryption_test_case_192_6),
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_AES_GCM_auth_decryption_test_case_192_7),
13482 /** AES GCM Authenticated Encryption 256 bits key */
13483 TEST_CASE_ST(ut_setup, ut_teardown,
13484 test_AES_GCM_auth_encryption_test_case_256_1),
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_AES_GCM_auth_encryption_test_case_256_2),
13487 TEST_CASE_ST(ut_setup, ut_teardown,
13488 test_AES_GCM_auth_encryption_test_case_256_3),
13489 TEST_CASE_ST(ut_setup, ut_teardown,
13490 test_AES_GCM_auth_encryption_test_case_256_4),
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_AES_GCM_auth_encryption_test_case_256_5),
13493 TEST_CASE_ST(ut_setup, ut_teardown,
13494 test_AES_GCM_auth_encryption_test_case_256_6),
13495 TEST_CASE_ST(ut_setup, ut_teardown,
13496 test_AES_GCM_auth_encryption_test_case_256_7),
13498 /** AES GCM Authenticated Decryption 256 bits key */
13499 TEST_CASE_ST(ut_setup, ut_teardown,
13500 test_AES_GCM_auth_decryption_test_case_256_1),
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_AES_GCM_auth_decryption_test_case_256_2),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GCM_auth_decryption_test_case_256_3),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_AES_GCM_auth_decryption_test_case_256_4),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_AES_GCM_auth_decryption_test_case_256_5),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GCM_auth_decryption_test_case_256_6),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_AES_GCM_auth_decryption_test_case_256_7),
13514 /** Out of place tests */
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13520 /** SNOW 3G encrypt only (UEA2) */
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_snow3g_encryption_test_case_1),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_snow3g_encryption_test_case_2),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_snow3g_encryption_test_case_3),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_snow3g_encryption_test_case_4),
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_snow3g_encryption_test_case_5),
13532 TEST_CASE_ST(ut_setup, ut_teardown,
13533 test_snow3g_encryption_test_case_1_oop),
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_snow3g_encryption_test_case_1_oop_sgl),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_snow3g_decryption_test_case_1_oop),
13539 /** SNOW 3G decrypt only (UEA2) */
13540 TEST_CASE_ST(ut_setup, ut_teardown,
13541 test_snow3g_decryption_test_case_1),
13542 TEST_CASE_ST(ut_setup, ut_teardown,
13543 test_snow3g_decryption_test_case_2),
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_snow3g_decryption_test_case_3),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_snow3g_decryption_test_case_4),
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 test_snow3g_decryption_test_case_5),
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_snow3g_hash_generate_test_case_1),
13553 TEST_CASE_ST(ut_setup, ut_teardown,
13554 test_snow3g_hash_generate_test_case_2),
13555 TEST_CASE_ST(ut_setup, ut_teardown,
13556 test_snow3g_hash_generate_test_case_3),
13557 TEST_CASE_ST(ut_setup, ut_teardown,
13558 test_snow3g_hash_verify_test_case_1),
13559 TEST_CASE_ST(ut_setup, ut_teardown,
13560 test_snow3g_hash_verify_test_case_2),
13561 TEST_CASE_ST(ut_setup, ut_teardown,
13562 test_snow3g_hash_verify_test_case_3),
13564 /** ZUC encrypt only (EEA3) */
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_zuc_encryption_test_case_1),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_zuc_encryption_test_case_2),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_zuc_encryption_test_case_3),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_zuc_encryption_test_case_4),
13573 TEST_CASE_ST(ut_setup, ut_teardown,
13574 test_zuc_encryption_test_case_5),
13576 /** ZUC authenticate (EIA3) */
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_zuc_hash_generate_test_case_6),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_zuc_hash_generate_test_case_7),
13581 TEST_CASE_ST(ut_setup, ut_teardown,
13582 test_zuc_hash_generate_test_case_8),
13584 /** HMAC_MD5 Authentication */
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_MD5_HMAC_generate_case_1),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_MD5_HMAC_verify_case_1),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_MD5_HMAC_generate_case_2),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_MD5_HMAC_verify_case_2),
13594 /** Negative tests */
13595 TEST_CASE_ST(ut_setup, ut_teardown,
13596 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13597 TEST_CASE_ST(ut_setup, ut_teardown,
13598 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13599 TEST_CASE_ST(ut_setup, ut_teardown,
13600 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13601 TEST_CASE_ST(ut_setup, ut_teardown,
13602 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13603 TEST_CASE_ST(ut_setup, ut_teardown,
13604 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13605 TEST_CASE_ST(ut_setup, ut_teardown,
13606 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13607 TEST_CASE_ST(ut_setup, ut_teardown,
13608 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13609 TEST_CASE_ST(ut_setup, ut_teardown,
13610 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13611 TEST_CASE_ST(ut_setup, ut_teardown,
13612 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13615 TEST_CASE_ST(ut_setup, ut_teardown,
13616 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13632 TEST_CASE_ST(ut_setup, ut_teardown,
13633 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13635 TEST_CASES_END() /**< NULL terminate unit test array */
13639 static struct unit_test_suite cryptodev_null_testsuite = {
13640 .suite_name = "Crypto Device NULL Unit Test Suite",
13641 .setup = testsuite_setup,
13642 .teardown = testsuite_teardown,
13643 .unit_test_cases = {
13644 TEST_CASE_ST(ut_setup, ut_teardown,
13645 test_null_invalid_operation),
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_null_burst_operation),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_AES_chain_null_all),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 test_AES_cipheronly_null_all),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_authonly_null_all),
13655 TEST_CASES_END() /**< NULL terminate unit test array */
13659 static struct unit_test_suite cryptodev_armv8_testsuite = {
13660 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13661 .setup = testsuite_setup,
13662 .teardown = testsuite_teardown,
13663 .unit_test_cases = {
13664 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13666 /** Negative tests */
13667 TEST_CASE_ST(ut_setup, ut_teardown,
13668 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13669 TEST_CASE_ST(ut_setup, ut_teardown,
13670 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13672 TEST_CASES_END() /**< NULL terminate unit test array */
13676 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13677 .suite_name = "Crypto Device Marvell Component Test Suite",
13678 .setup = testsuite_setup,
13679 .teardown = testsuite_teardown,
13680 .unit_test_cases = {
13681 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13682 TEST_CASE_ST(ut_setup, ut_teardown,
13683 test_multi_session_random_usage),
13684 TEST_CASE_ST(ut_setup, ut_teardown,
13685 test_AES_chain_mrvl_all),
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 test_AES_cipheronly_mrvl_all),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 test_authonly_mrvl_all),
13690 TEST_CASE_ST(ut_setup, ut_teardown,
13691 test_3DES_chain_mrvl_all),
13692 TEST_CASE_ST(ut_setup, ut_teardown,
13693 test_3DES_cipheronly_mrvl_all),
13695 /** Negative tests */
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13700 TEST_CASE_ST(ut_setup, ut_teardown,
13701 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13702 TEST_CASE_ST(ut_setup, ut_teardown,
13703 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13705 TEST_CASES_END() /**< NULL terminate unit test array */
13709 static struct unit_test_suite cryptodev_ccp_testsuite = {
13710 .suite_name = "Crypto Device CCP Unit Test Suite",
13711 .setup = testsuite_setup,
13712 .teardown = testsuite_teardown,
13713 .unit_test_cases = {
13714 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13715 TEST_CASE_ST(ut_setup, ut_teardown,
13716 test_multi_session_random_usage),
13717 TEST_CASE_ST(ut_setup, ut_teardown,
13718 test_AES_chain_ccp_all),
13719 TEST_CASE_ST(ut_setup, ut_teardown,
13720 test_AES_cipheronly_ccp_all),
13721 TEST_CASE_ST(ut_setup, ut_teardown,
13722 test_3DES_chain_ccp_all),
13723 TEST_CASE_ST(ut_setup, ut_teardown,
13724 test_3DES_cipheronly_ccp_all),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_authonly_ccp_all),
13728 /** Negative tests */
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13738 TEST_CASES_END() /**< NULL terminate unit test array */
13742 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13743 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13744 .setup = testsuite_setup,
13745 .teardown = testsuite_teardown,
13746 .unit_test_cases = {
13747 TEST_CASE_ST(ut_setup, ut_teardown,
13748 test_AES_chain_octeontx_all),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_AES_cipheronly_octeontx_all),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_3DES_chain_octeontx_all),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 test_3DES_cipheronly_octeontx_all),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_authonly_octeontx_all),
13758 /** AES GCM Authenticated Encryption */
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_AES_GCM_authenticated_encryption_test_case_1),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_AES_GCM_authenticated_encryption_test_case_2),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_AES_GCM_authenticated_encryption_test_case_3),
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_AES_GCM_authenticated_encryption_test_case_4),
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_AES_GCM_authenticated_encryption_test_case_5),
13769 TEST_CASE_ST(ut_setup, ut_teardown,
13770 test_AES_GCM_authenticated_encryption_test_case_6),
13771 TEST_CASE_ST(ut_setup, ut_teardown,
13772 test_AES_GCM_authenticated_encryption_test_case_7),
13774 /** AES GCM Authenticated Decryption */
13775 TEST_CASE_ST(ut_setup, ut_teardown,
13776 test_AES_GCM_authenticated_decryption_test_case_1),
13777 TEST_CASE_ST(ut_setup, ut_teardown,
13778 test_AES_GCM_authenticated_decryption_test_case_2),
13779 TEST_CASE_ST(ut_setup, ut_teardown,
13780 test_AES_GCM_authenticated_decryption_test_case_3),
13781 TEST_CASE_ST(ut_setup, ut_teardown,
13782 test_AES_GCM_authenticated_decryption_test_case_4),
13783 TEST_CASE_ST(ut_setup, ut_teardown,
13784 test_AES_GCM_authenticated_decryption_test_case_5),
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_AES_GCM_authenticated_decryption_test_case_6),
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_AES_GCM_authenticated_decryption_test_case_7),
13789 /** AES GMAC Authentication */
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 test_AES_GMAC_authentication_test_case_1),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 test_AES_GMAC_authentication_verify_test_case_1),
13794 TEST_CASE_ST(ut_setup, ut_teardown,
13795 test_AES_GMAC_authentication_test_case_2),
13796 TEST_CASE_ST(ut_setup, ut_teardown,
13797 test_AES_GMAC_authentication_verify_test_case_2),
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 test_AES_GMAC_authentication_test_case_3),
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 test_AES_GMAC_authentication_verify_test_case_3),
13803 /** SNOW 3G encrypt only (UEA2) */
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 test_snow3g_encryption_test_case_1),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_snow3g_encryption_test_case_2),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_snow3g_encryption_test_case_3),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_snow3g_encryption_test_case_4),
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_snow3g_encryption_test_case_5),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_snow3g_encryption_test_case_1_oop),
13817 TEST_CASE_ST(ut_setup, ut_teardown,
13818 test_snow3g_decryption_test_case_1_oop),
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_snow3g_encryption_test_case_1_oop_sgl),
13822 /** SNOW 3G decrypt only (UEA2) */
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_snow3g_decryption_test_case_1),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_snow3g_decryption_test_case_2),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_snow3g_decryption_test_case_3),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_snow3g_decryption_test_case_4),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_snow3g_decryption_test_case_5),
13834 TEST_CASE_ST(ut_setup, ut_teardown,
13835 test_snow3g_hash_generate_test_case_1),
13836 TEST_CASE_ST(ut_setup, ut_teardown,
13837 test_snow3g_hash_generate_test_case_2),
13838 TEST_CASE_ST(ut_setup, ut_teardown,
13839 test_snow3g_hash_generate_test_case_3),
13840 TEST_CASE_ST(ut_setup, ut_teardown,
13841 test_snow3g_hash_verify_test_case_1),
13842 TEST_CASE_ST(ut_setup, ut_teardown,
13843 test_snow3g_hash_verify_test_case_2),
13844 TEST_CASE_ST(ut_setup, ut_teardown,
13845 test_snow3g_hash_verify_test_case_3),
13847 /** ZUC encrypt only (EEA3) */
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_zuc_encryption_test_case_1),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_zuc_encryption_test_case_2),
13852 TEST_CASE_ST(ut_setup, ut_teardown,
13853 test_zuc_encryption_test_case_3),
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_zuc_encryption_test_case_4),
13856 TEST_CASE_ST(ut_setup, ut_teardown,
13857 test_zuc_encryption_test_case_5),
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_zuc_hash_generate_test_case_1),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_zuc_hash_generate_test_case_2),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_zuc_hash_generate_test_case_3),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_zuc_hash_generate_test_case_4),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_zuc_hash_generate_test_case_5),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_zuc_encryption_test_case_6_sgl),
13871 /** KASUMI encrypt only (UEA1) */
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_kasumi_encryption_test_case_1),
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_kasumi_encryption_test_case_2),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_kasumi_encryption_test_case_3),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_kasumi_encryption_test_case_4),
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_kasumi_encryption_test_case_5),
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_kasumi_encryption_test_case_1_sgl),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_kasumi_encryption_test_case_1_oop_sgl),
13886 /** KASUMI decrypt only (UEA1) */
13887 TEST_CASE_ST(ut_setup, ut_teardown,
13888 test_kasumi_decryption_test_case_1),
13889 TEST_CASE_ST(ut_setup, ut_teardown,
13890 test_kasumi_decryption_test_case_2),
13891 TEST_CASE_ST(ut_setup, ut_teardown,
13892 test_kasumi_decryption_test_case_3),
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_kasumi_decryption_test_case_4),
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_kasumi_decryption_test_case_5),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_kasumi_encryption_test_case_1_oop),
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_kasumi_decryption_test_case_1_oop),
13903 /** KASUMI hash only (UIA1) */
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_kasumi_hash_generate_test_case_1),
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_kasumi_hash_generate_test_case_2),
13908 TEST_CASE_ST(ut_setup, ut_teardown,
13909 test_kasumi_hash_generate_test_case_3),
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_kasumi_hash_generate_test_case_4),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_kasumi_hash_generate_test_case_5),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_kasumi_hash_generate_test_case_6),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_kasumi_hash_verify_test_case_1),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_kasumi_hash_verify_test_case_2),
13920 TEST_CASE_ST(ut_setup, ut_teardown,
13921 test_kasumi_hash_verify_test_case_3),
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_kasumi_hash_verify_test_case_4),
13924 TEST_CASE_ST(ut_setup, ut_teardown,
13925 test_kasumi_hash_verify_test_case_5),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_null_cipher_only_operation),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_null_auth_only_operation),
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_null_cipher_auth_operation),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_null_auth_cipher_operation),
13937 /** Negative tests */
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13940 TEST_CASE_ST(ut_setup, ut_teardown,
13941 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 authentication_verify_AES128_GMAC_fail_data_corrupt),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13946 TEST_CASE_ST(ut_setup, ut_teardown,
13947 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13950 TEST_CASES_END() /**< NULL terminate unit test array */
13954 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13955 .suite_name = "Crypto NITROX Unit Test Suite",
13956 .setup = testsuite_setup,
13957 .teardown = testsuite_teardown,
13958 .unit_test_cases = {
13959 TEST_CASE_ST(ut_setup, ut_teardown,
13960 test_device_configure_invalid_dev_id),
13961 TEST_CASE_ST(ut_setup, ut_teardown,
13962 test_device_configure_invalid_queue_pair_ids),
13963 TEST_CASE_ST(ut_setup, ut_teardown,
13964 test_AES_chain_nitrox_all),
13966 TEST_CASES_END() /**< NULL terminate unit test array */
13970 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13971 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13972 .setup = testsuite_setup,
13973 .teardown = testsuite_teardown,
13974 .unit_test_cases = {
13975 TEST_CASE_ST(ut_setup, ut_teardown,
13976 test_AES_chain_octeontx2_all),
13977 TEST_CASE_ST(ut_setup, ut_teardown,
13978 test_AES_cipheronly_octeontx2_all),
13979 TEST_CASE_ST(ut_setup, ut_teardown,
13980 test_3DES_chain_octeontx2_all),
13981 TEST_CASE_ST(ut_setup, ut_teardown,
13982 test_3DES_cipheronly_octeontx2_all),
13983 TEST_CASE_ST(ut_setup, ut_teardown,
13984 test_authonly_octeontx2_all),
13986 /** AES GCM Authenticated Encryption */
13987 TEST_CASE_ST(ut_setup, ut_teardown,
13988 test_AES_GCM_authenticated_encryption_test_case_1),
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_AES_GCM_authenticated_encryption_test_case_2),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_AES_GCM_authenticated_encryption_test_case_3),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_AES_GCM_authenticated_encryption_test_case_4),
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 test_AES_GCM_authenticated_encryption_test_case_5),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GCM_authenticated_encryption_test_case_6),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GCM_authenticated_encryption_test_case_7),
14002 /** AES GCM Authenticated Decryption */
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GCM_authenticated_decryption_test_case_1),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GCM_authenticated_decryption_test_case_2),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_AES_GCM_authenticated_decryption_test_case_3),
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_GCM_authenticated_decryption_test_case_4),
14011 TEST_CASE_ST(ut_setup, ut_teardown,
14012 test_AES_GCM_authenticated_decryption_test_case_5),
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_AES_GCM_authenticated_decryption_test_case_6),
14015 TEST_CASE_ST(ut_setup, ut_teardown,
14016 test_AES_GCM_authenticated_decryption_test_case_7),
14017 /** AES GMAC Authentication */
14018 TEST_CASE_ST(ut_setup, ut_teardown,
14019 test_AES_GMAC_authentication_test_case_1),
14020 TEST_CASE_ST(ut_setup, ut_teardown,
14021 test_AES_GMAC_authentication_verify_test_case_1),
14022 TEST_CASE_ST(ut_setup, ut_teardown,
14023 test_AES_GMAC_authentication_test_case_2),
14024 TEST_CASE_ST(ut_setup, ut_teardown,
14025 test_AES_GMAC_authentication_verify_test_case_2),
14026 TEST_CASE_ST(ut_setup, ut_teardown,
14027 test_AES_GMAC_authentication_test_case_3),
14028 TEST_CASE_ST(ut_setup, ut_teardown,
14029 test_AES_GMAC_authentication_verify_test_case_3),
14031 /** SNOW 3G encrypt only (UEA2) */
14032 TEST_CASE_ST(ut_setup, ut_teardown,
14033 test_snow3g_encryption_test_case_1),
14034 TEST_CASE_ST(ut_setup, ut_teardown,
14035 test_snow3g_encryption_test_case_2),
14036 TEST_CASE_ST(ut_setup, ut_teardown,
14037 test_snow3g_encryption_test_case_3),
14038 TEST_CASE_ST(ut_setup, ut_teardown,
14039 test_snow3g_encryption_test_case_4),
14040 TEST_CASE_ST(ut_setup, ut_teardown,
14041 test_snow3g_encryption_test_case_5),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_snow3g_encryption_test_case_1_oop),
14045 TEST_CASE_ST(ut_setup, ut_teardown,
14046 test_snow3g_decryption_test_case_1_oop),
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_snow3g_encryption_test_case_1_oop_sgl),
14050 /** SNOW 3G decrypt only (UEA2) */
14051 TEST_CASE_ST(ut_setup, ut_teardown,
14052 test_snow3g_decryption_test_case_1),
14053 TEST_CASE_ST(ut_setup, ut_teardown,
14054 test_snow3g_decryption_test_case_2),
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 test_snow3g_decryption_test_case_3),
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 test_snow3g_decryption_test_case_4),
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 test_snow3g_decryption_test_case_5),
14062 TEST_CASE_ST(ut_setup, ut_teardown,
14063 test_snow3g_hash_generate_test_case_1),
14064 TEST_CASE_ST(ut_setup, ut_teardown,
14065 test_snow3g_hash_generate_test_case_2),
14066 TEST_CASE_ST(ut_setup, ut_teardown,
14067 test_snow3g_hash_generate_test_case_3),
14068 TEST_CASE_ST(ut_setup, ut_teardown,
14069 test_snow3g_hash_verify_test_case_1),
14070 TEST_CASE_ST(ut_setup, ut_teardown,
14071 test_snow3g_hash_verify_test_case_2),
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_snow3g_hash_verify_test_case_3),
14075 /** ZUC encrypt only (EEA3) */
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_zuc_encryption_test_case_1),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_zuc_encryption_test_case_2),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_zuc_encryption_test_case_3),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_zuc_encryption_test_case_4),
14084 TEST_CASE_ST(ut_setup, ut_teardown,
14085 test_zuc_encryption_test_case_5),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_zuc_hash_generate_test_case_1),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_zuc_hash_generate_test_case_2),
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 test_zuc_hash_generate_test_case_3),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_zuc_hash_generate_test_case_4),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 test_zuc_hash_generate_test_case_5),
14096 TEST_CASE_ST(ut_setup, ut_teardown,
14097 test_zuc_encryption_test_case_6_sgl),
14099 /** KASUMI encrypt only (UEA1) */
14100 TEST_CASE_ST(ut_setup, ut_teardown,
14101 test_kasumi_encryption_test_case_1),
14102 TEST_CASE_ST(ut_setup, ut_teardown,
14103 test_kasumi_encryption_test_case_2),
14104 TEST_CASE_ST(ut_setup, ut_teardown,
14105 test_kasumi_encryption_test_case_3),
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_kasumi_encryption_test_case_4),
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_kasumi_encryption_test_case_5),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_kasumi_encryption_test_case_1_sgl),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_kasumi_encryption_test_case_1_oop_sgl),
14114 /** KASUMI decrypt only (UEA1) */
14115 TEST_CASE_ST(ut_setup, ut_teardown,
14116 test_kasumi_decryption_test_case_1),
14117 TEST_CASE_ST(ut_setup, ut_teardown,
14118 test_kasumi_decryption_test_case_2),
14119 TEST_CASE_ST(ut_setup, ut_teardown,
14120 test_kasumi_decryption_test_case_3),
14121 TEST_CASE_ST(ut_setup, ut_teardown,
14122 test_kasumi_decryption_test_case_4),
14123 TEST_CASE_ST(ut_setup, ut_teardown,
14124 test_kasumi_decryption_test_case_5),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_kasumi_encryption_test_case_1_oop),
14128 TEST_CASE_ST(ut_setup, ut_teardown,
14129 test_kasumi_decryption_test_case_1_oop),
14131 /** KASUMI hash only (UIA1) */
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_kasumi_hash_generate_test_case_1),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_kasumi_hash_generate_test_case_2),
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_kasumi_hash_generate_test_case_3),
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_kasumi_hash_generate_test_case_4),
14140 TEST_CASE_ST(ut_setup, ut_teardown,
14141 test_kasumi_hash_generate_test_case_5),
14142 TEST_CASE_ST(ut_setup, ut_teardown,
14143 test_kasumi_hash_generate_test_case_6),
14144 TEST_CASE_ST(ut_setup, ut_teardown,
14145 test_kasumi_hash_verify_test_case_1),
14146 TEST_CASE_ST(ut_setup, ut_teardown,
14147 test_kasumi_hash_verify_test_case_2),
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_kasumi_hash_verify_test_case_3),
14150 TEST_CASE_ST(ut_setup, ut_teardown,
14151 test_kasumi_hash_verify_test_case_4),
14152 TEST_CASE_ST(ut_setup, ut_teardown,
14153 test_kasumi_hash_verify_test_case_5),
14156 TEST_CASE_ST(ut_setup, ut_teardown,
14157 test_null_cipher_only_operation),
14158 TEST_CASE_ST(ut_setup, ut_teardown,
14159 test_null_auth_only_operation),
14160 TEST_CASE_ST(ut_setup, ut_teardown,
14161 test_null_cipher_auth_operation),
14162 TEST_CASE_ST(ut_setup, ut_teardown,
14163 test_null_auth_cipher_operation),
14165 /** Negative tests */
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14170 TEST_CASE_ST(ut_setup, ut_teardown,
14171 authentication_verify_AES128_GMAC_fail_data_corrupt),
14172 TEST_CASE_ST(ut_setup, ut_teardown,
14173 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14174 TEST_CASE_ST(ut_setup, ut_teardown,
14175 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14178 TEST_CASES_END() /**< NULL terminate unit test array */
14183 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14185 gbl_driver_id = rte_cryptodev_driver_id_get(
14186 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14188 if (gbl_driver_id == -1) {
14189 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14190 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14191 "are enabled in config file to run this testsuite.\n");
14192 return TEST_SKIPPED;
14195 return unit_test_suite_runner(&cryptodev_qat_testsuite);
14199 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14201 gbl_driver_id = rte_cryptodev_driver_id_get(
14202 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14204 if (gbl_driver_id == -1) {
14205 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14206 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14207 "in config file to run this testsuite.\n");
14208 return TEST_FAILED;
14211 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14215 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14217 gbl_driver_id = rte_cryptodev_driver_id_get(
14218 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14220 if (gbl_driver_id == -1) {
14221 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14222 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14223 "in config file to run this testsuite.\n");
14224 return TEST_SKIPPED;
14227 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14231 test_cryptodev_openssl(void)
14233 gbl_driver_id = rte_cryptodev_driver_id_get(
14234 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14236 if (gbl_driver_id == -1) {
14237 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14238 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14239 "in config file to run this testsuite.\n");
14240 return TEST_SKIPPED;
14243 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14247 test_cryptodev_aesni_gcm(void)
14249 gbl_driver_id = rte_cryptodev_driver_id_get(
14250 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14252 if (gbl_driver_id == -1) {
14253 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14254 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14255 "in config file to run this testsuite.\n");
14256 return TEST_SKIPPED;
14259 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14263 test_cryptodev_null(void)
14265 gbl_driver_id = rte_cryptodev_driver_id_get(
14266 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14268 if (gbl_driver_id == -1) {
14269 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14270 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14271 "in config file to run this testsuite.\n");
14272 return TEST_SKIPPED;
14275 return unit_test_suite_runner(&cryptodev_null_testsuite);
14279 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14281 gbl_driver_id = rte_cryptodev_driver_id_get(
14282 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14284 if (gbl_driver_id == -1) {
14285 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14286 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14287 "in config file to run this testsuite.\n");
14288 return TEST_SKIPPED;
14291 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14295 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14297 gbl_driver_id = rte_cryptodev_driver_id_get(
14298 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14300 if (gbl_driver_id == -1) {
14301 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14302 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14303 "in config file to run this testsuite.\n");
14304 return TEST_SKIPPED;
14307 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14311 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14313 gbl_driver_id = rte_cryptodev_driver_id_get(
14314 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14316 if (gbl_driver_id == -1) {
14317 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14318 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14319 "in config file to run this testsuite.\n");
14320 return TEST_SKIPPED;
14323 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14327 test_cryptodev_armv8(void)
14329 gbl_driver_id = rte_cryptodev_driver_id_get(
14330 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14332 if (gbl_driver_id == -1) {
14333 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14334 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14335 "in config file to run this testsuite.\n");
14336 return TEST_SKIPPED;
14339 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14343 test_cryptodev_mrvl(void)
14345 gbl_driver_id = rte_cryptodev_driver_id_get(
14346 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14348 if (gbl_driver_id == -1) {
14349 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14350 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14351 "in config file to run this testsuite.\n");
14352 return TEST_SKIPPED;
14355 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14358 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14361 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14363 gbl_driver_id = rte_cryptodev_driver_id_get(
14364 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14366 if (gbl_driver_id == -1) {
14367 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14368 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14369 "in config file to run this testsuite.\n");
14370 return TEST_SKIPPED;
14373 if (rte_cryptodev_driver_id_get(
14374 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14375 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14376 " enabled in config file to run this testsuite.\n");
14377 return TEST_SKIPPED;
14379 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14382 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14387 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14389 gbl_driver_id = rte_cryptodev_driver_id_get(
14390 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14392 if (gbl_driver_id == -1) {
14393 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14394 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14395 "in config file to run this testsuite.\n");
14396 return TEST_SKIPPED;
14399 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14403 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14405 gbl_driver_id = rte_cryptodev_driver_id_get(
14406 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14408 if (gbl_driver_id == -1) {
14409 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14410 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14411 "in config file to run this testsuite.\n");
14412 return TEST_SKIPPED;
14415 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14419 test_cryptodev_ccp(void)
14421 gbl_driver_id = rte_cryptodev_driver_id_get(
14422 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14424 if (gbl_driver_id == -1) {
14425 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14426 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14427 "in config file to run this testsuite.\n");
14428 return TEST_FAILED;
14431 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14435 test_cryptodev_octeontx(void)
14437 gbl_driver_id = rte_cryptodev_driver_id_get(
14438 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14439 if (gbl_driver_id == -1) {
14440 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14441 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14442 "enabled in config file to run this "
14444 return TEST_FAILED;
14446 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14450 test_cryptodev_octeontx2(void)
14452 gbl_driver_id = rte_cryptodev_driver_id_get(
14453 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14454 if (gbl_driver_id == -1) {
14455 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14456 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14457 "enabled in config file to run this "
14459 return TEST_FAILED;
14461 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14465 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14467 gbl_driver_id = rte_cryptodev_driver_id_get(
14468 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14470 if (gbl_driver_id == -1) {
14471 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14472 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14473 "in config file to run this testsuite.\n");
14474 return TEST_FAILED;
14477 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14481 test_cryptodev_nitrox(void)
14483 gbl_driver_id = rte_cryptodev_driver_id_get(
14484 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14486 if (gbl_driver_id == -1) {
14487 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14488 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14489 "in config file to run this testsuite.\n");
14490 return TEST_FAILED;
14493 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14496 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14497 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14498 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14499 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14500 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14501 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14502 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14503 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14504 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14505 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14506 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14507 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14508 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14509 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14510 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14511 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14512 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14513 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);