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 #ifdef RTE_LIBRTE_SECURITY
42 #include "test_cryptodev_security_pdcp_test_vectors.h"
43 #include "test_cryptodev_security_pdcp_test_func.h"
46 #define VDEV_ARGS_SIZE 100
47 #define MAX_NB_SESSIONS 4
50 #define OUT_OF_PLACE 1
52 static int gbl_driver_id;
54 struct crypto_testsuite_params {
55 struct rte_mempool *mbuf_pool;
56 struct rte_mempool *large_mbuf_pool;
57 struct rte_mempool *op_mpool;
58 struct rte_mempool *session_mpool;
59 struct rte_mempool *session_priv_mpool;
60 struct rte_cryptodev_config conf;
61 struct rte_cryptodev_qp_conf qp_conf;
63 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
64 uint8_t valid_dev_count;
67 struct crypto_unittest_params {
68 struct rte_crypto_sym_xform cipher_xform;
69 struct rte_crypto_sym_xform auth_xform;
70 struct rte_crypto_sym_xform aead_xform;
73 struct rte_cryptodev_sym_session *sess;
74 struct rte_security_session *sec_session;
76 enum rte_security_session_action_type type;
77 struct rte_crypto_op *op;
79 struct rte_mbuf *obuf, *ibuf;
84 #define ALIGN_POW2_ROUNDUP(num, align) \
85 (((num) + (align) - 1) & ~((align) - 1))
88 * Forward declarations.
91 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
92 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
96 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
97 struct crypto_unittest_params *ut_params,
98 struct crypto_testsuite_params *ts_param,
99 const uint8_t *cipher,
100 const uint8_t *digest,
103 static struct rte_mbuf *
104 setup_test_string(struct rte_mempool *mpool,
105 const char *string, size_t len, uint8_t blocksize)
107 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
108 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
110 memset(m->buf_addr, 0, m->buf_len);
112 char *dst = rte_pktmbuf_append(m, t_len);
119 rte_memcpy(dst, string, t_len);
121 memset(dst, 0, t_len);
127 /* Get number of bytes in X bits (rounding up) */
129 ceil_byte_length(uint32_t num_bits)
132 return ((num_bits >> 3) + 1);
134 return (num_bits >> 3);
137 static struct rte_crypto_op *
138 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
140 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
141 printf("Error sending packet for encryption");
147 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
153 static struct crypto_testsuite_params testsuite_params = { NULL };
154 static struct crypto_unittest_params unittest_params;
157 testsuite_setup(void)
159 struct crypto_testsuite_params *ts_params = &testsuite_params;
160 struct rte_cryptodev_info info;
161 uint32_t i = 0, nb_devs, dev_id;
165 memset(ts_params, 0, sizeof(*ts_params));
167 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
168 if (ts_params->mbuf_pool == NULL) {
169 /* Not already created so create */
170 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
172 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
174 if (ts_params->mbuf_pool == NULL) {
175 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
180 ts_params->large_mbuf_pool = rte_mempool_lookup(
181 "CRYPTO_LARGE_MBUFPOOL");
182 if (ts_params->large_mbuf_pool == NULL) {
183 /* Not already created so create */
184 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
185 "CRYPTO_LARGE_MBUFPOOL",
188 if (ts_params->large_mbuf_pool == NULL) {
190 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
195 ts_params->op_mpool = rte_crypto_op_pool_create(
196 "MBUF_CRYPTO_SYM_OP_POOL",
197 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
198 NUM_MBUFS, MBUF_CACHE_SIZE,
200 sizeof(struct rte_crypto_sym_xform) +
203 if (ts_params->op_mpool == NULL) {
204 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
208 /* Create an AESNI MB device if required */
209 if (gbl_driver_id == rte_cryptodev_driver_id_get(
210 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
211 nb_devs = rte_cryptodev_device_count_by_driver(
212 rte_cryptodev_driver_id_get(
213 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
216 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
218 TEST_ASSERT(ret == 0,
219 "Failed to create instance of"
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
225 /* Create an AESNI GCM device if required */
226 if (gbl_driver_id == rte_cryptodev_driver_id_get(
227 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
228 nb_devs = rte_cryptodev_device_count_by_driver(
229 rte_cryptodev_driver_id_get(
230 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
232 TEST_ASSERT_SUCCESS(rte_vdev_init(
233 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
234 "Failed to create instance of"
236 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
240 /* Create a SNOW 3G device if required */
241 if (gbl_driver_id == rte_cryptodev_driver_id_get(
242 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
243 nb_devs = rte_cryptodev_device_count_by_driver(
244 rte_cryptodev_driver_id_get(
245 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
247 TEST_ASSERT_SUCCESS(rte_vdev_init(
248 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
249 "Failed to create instance of"
251 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
255 /* Create a KASUMI device if required */
256 if (gbl_driver_id == rte_cryptodev_driver_id_get(
257 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
258 nb_devs = rte_cryptodev_device_count_by_driver(
259 rte_cryptodev_driver_id_get(
260 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
262 TEST_ASSERT_SUCCESS(rte_vdev_init(
263 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
264 "Failed to create instance of"
266 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
270 /* Create a ZUC device if required */
271 if (gbl_driver_id == rte_cryptodev_driver_id_get(
272 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
273 nb_devs = rte_cryptodev_device_count_by_driver(
274 rte_cryptodev_driver_id_get(
275 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
277 TEST_ASSERT_SUCCESS(rte_vdev_init(
278 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
279 "Failed to create instance of"
281 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
285 /* Create a NULL device if required */
286 if (gbl_driver_id == rte_cryptodev_driver_id_get(
287 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
288 nb_devs = rte_cryptodev_device_count_by_driver(
289 rte_cryptodev_driver_id_get(
290 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
293 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
295 TEST_ASSERT(ret == 0,
296 "Failed to create instance of"
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
302 /* Create an OPENSSL device if required */
303 if (gbl_driver_id == rte_cryptodev_driver_id_get(
304 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
305 nb_devs = rte_cryptodev_device_count_by_driver(
306 rte_cryptodev_driver_id_get(
307 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
310 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
313 TEST_ASSERT(ret == 0, "Failed to create "
314 "instance of pmd : %s",
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
319 /* Create a ARMv8 device if required */
320 if (gbl_driver_id == rte_cryptodev_driver_id_get(
321 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
322 nb_devs = rte_cryptodev_device_count_by_driver(
323 rte_cryptodev_driver_id_get(
324 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
327 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
330 TEST_ASSERT(ret == 0, "Failed to create "
331 "instance of pmd : %s",
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
336 /* Create a MVSAM device if required */
337 if (gbl_driver_id == rte_cryptodev_driver_id_get(
338 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
339 nb_devs = rte_cryptodev_device_count_by_driver(
340 rte_cryptodev_driver_id_get(
341 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
344 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
347 TEST_ASSERT(ret == 0, "Failed to create "
348 "instance of pmd : %s",
349 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
353 /* Create an CCP device if required */
354 if (gbl_driver_id == rte_cryptodev_driver_id_get(
355 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
356 nb_devs = rte_cryptodev_device_count_by_driver(
357 rte_cryptodev_driver_id_get(
358 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
361 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
364 TEST_ASSERT(ret == 0, "Failed to create "
365 "instance of pmd : %s",
366 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
370 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
371 char vdev_args[VDEV_ARGS_SIZE] = {""};
372 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
373 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
374 uint16_t slave_core_count = 0;
375 uint16_t socket_id = 0;
377 if (gbl_driver_id == rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
380 /* Identify the Slave Cores
381 * Use 2 slave cores for the device args
383 RTE_LCORE_FOREACH_SLAVE(i) {
384 if (slave_core_count > 1)
386 snprintf(vdev_args, sizeof(vdev_args),
387 "%s%d", temp_str, i);
388 strcpy(temp_str, vdev_args);
389 strlcat(temp_str, ";", sizeof(temp_str));
391 socket_id = rte_lcore_to_socket_id(i);
393 if (slave_core_count != 2) {
395 "Cryptodev scheduler test require at least "
396 "two slave cores to run. "
397 "Please use the correct coremask.\n");
400 strcpy(temp_str, vdev_args);
401 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
402 temp_str, socket_id);
403 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
404 nb_devs = rte_cryptodev_device_count_by_driver(
405 rte_cryptodev_driver_id_get(
406 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
409 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
411 TEST_ASSERT(ret == 0,
412 "Failed to create instance %u of"
414 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
417 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
419 nb_devs = rte_cryptodev_count();
421 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
425 /* Create list of valid crypto devs */
426 for (i = 0; i < nb_devs; i++) {
427 rte_cryptodev_info_get(i, &info);
428 if (info.driver_id == gbl_driver_id)
429 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
432 if (ts_params->valid_dev_count < 1)
435 /* Set up all the qps on the first of the valid devices found */
437 dev_id = ts_params->valid_devs[0];
439 rte_cryptodev_info_get(dev_id, &info);
441 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
442 ts_params->conf.socket_id = SOCKET_ID_ANY;
443 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
445 unsigned int session_size =
446 rte_cryptodev_sym_get_private_session_size(dev_id);
449 * Create mempool with maximum number of sessions * 2,
450 * to include the session headers
452 if (info.sym.max_nb_sessions != 0 &&
453 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
454 RTE_LOG(ERR, USER1, "Device does not support "
455 "at least %u sessions\n",
460 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
461 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
463 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
464 "session mempool allocation failed");
466 ts_params->session_priv_mpool = rte_mempool_create(
470 0, 0, NULL, NULL, NULL,
473 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
474 "session mempool allocation failed");
478 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
480 "Failed to configure cryptodev %u with %u qps",
481 dev_id, ts_params->conf.nb_queue_pairs);
483 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
484 ts_params->qp_conf.mp_session = ts_params->session_mpool;
485 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
487 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
488 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
489 dev_id, qp_id, &ts_params->qp_conf,
490 rte_cryptodev_socket_id(dev_id)),
491 "Failed to setup queue pair %u on cryptodev %u",
499 testsuite_teardown(void)
501 struct crypto_testsuite_params *ts_params = &testsuite_params;
503 if (ts_params->mbuf_pool != NULL) {
504 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
505 rte_mempool_avail_count(ts_params->mbuf_pool));
508 if (ts_params->op_mpool != NULL) {
509 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
510 rte_mempool_avail_count(ts_params->op_mpool));
513 /* Free session mempools */
514 if (ts_params->session_priv_mpool != NULL) {
515 rte_mempool_free(ts_params->session_priv_mpool);
516 ts_params->session_priv_mpool = NULL;
519 if (ts_params->session_mpool != NULL) {
520 rte_mempool_free(ts_params->session_mpool);
521 ts_params->session_mpool = NULL;
528 struct crypto_testsuite_params *ts_params = &testsuite_params;
529 struct crypto_unittest_params *ut_params = &unittest_params;
533 /* Clear unit test parameters before running test */
534 memset(ut_params, 0, sizeof(*ut_params));
536 /* Reconfigure device to default parameters */
537 ts_params->conf.socket_id = SOCKET_ID_ANY;
538 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
539 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
540 ts_params->qp_conf.mp_session = ts_params->session_mpool;
541 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
543 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
545 "Failed to configure cryptodev %u",
546 ts_params->valid_devs[0]);
548 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
549 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
550 ts_params->valid_devs[0], qp_id,
552 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
553 "Failed to setup queue pair %u on cryptodev %u",
554 qp_id, ts_params->valid_devs[0]);
558 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
560 /* Start the device */
561 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
562 "Failed to start cryptodev %u",
563 ts_params->valid_devs[0]);
571 struct crypto_testsuite_params *ts_params = &testsuite_params;
572 struct crypto_unittest_params *ut_params = &unittest_params;
573 struct rte_cryptodev_stats stats;
575 /* free crypto session structure */
576 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
577 if (ut_params->sec_session) {
578 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
579 (ts_params->valid_devs[0]),
580 ut_params->sec_session);
581 ut_params->sec_session = NULL;
584 if (ut_params->sess) {
585 rte_cryptodev_sym_session_clear(
586 ts_params->valid_devs[0],
588 rte_cryptodev_sym_session_free(ut_params->sess);
589 ut_params->sess = NULL;
593 /* free crypto operation structure */
595 rte_crypto_op_free(ut_params->op);
598 * free mbuf - both obuf and ibuf are usually the same,
599 * so check if they point at the same address is necessary,
600 * to avoid freeing the mbuf twice.
602 if (ut_params->obuf) {
603 rte_pktmbuf_free(ut_params->obuf);
604 if (ut_params->ibuf == ut_params->obuf)
608 if (ut_params->ibuf) {
609 rte_pktmbuf_free(ut_params->ibuf);
613 if (ts_params->mbuf_pool != NULL)
614 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
615 rte_mempool_avail_count(ts_params->mbuf_pool));
617 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
619 /* Stop the device */
620 rte_cryptodev_stop(ts_params->valid_devs[0]);
624 test_device_configure_invalid_dev_id(void)
626 struct crypto_testsuite_params *ts_params = &testsuite_params;
627 uint16_t dev_id, num_devs = 0;
629 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
630 "Need at least %d devices for test", 1);
632 /* valid dev_id values */
633 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
635 /* Stop the device in case it's started so it can be configured */
636 rte_cryptodev_stop(dev_id);
638 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
639 "Failed test for rte_cryptodev_configure: "
640 "invalid dev_num %u", dev_id);
642 /* invalid dev_id values */
645 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
646 "Failed test for rte_cryptodev_configure: "
647 "invalid dev_num %u", dev_id);
651 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 "Failed test for rte_cryptodev_configure:"
653 "invalid dev_num %u", dev_id);
659 test_device_configure_invalid_queue_pair_ids(void)
661 struct crypto_testsuite_params *ts_params = &testsuite_params;
662 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
664 /* Stop the device in case it's started so it can be configured */
665 rte_cryptodev_stop(ts_params->valid_devs[0]);
667 /* valid - one queue pairs */
668 ts_params->conf.nb_queue_pairs = 1;
670 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
672 "Failed to configure cryptodev: dev_id %u, qp_id %u",
673 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
676 /* valid - max value queue pairs */
677 ts_params->conf.nb_queue_pairs = orig_nb_qps;
679 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
681 "Failed to configure cryptodev: dev_id %u, qp_id %u",
682 ts_params->valid_devs[0],
683 ts_params->conf.nb_queue_pairs);
686 /* invalid - zero queue pairs */
687 ts_params->conf.nb_queue_pairs = 0;
689 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
691 "Failed test for rte_cryptodev_configure, dev_id %u,"
693 ts_params->valid_devs[0],
694 ts_params->conf.nb_queue_pairs);
697 /* invalid - max value supported by field queue pairs */
698 ts_params->conf.nb_queue_pairs = UINT16_MAX;
700 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
702 "Failed test for rte_cryptodev_configure, dev_id %u,"
704 ts_params->valid_devs[0],
705 ts_params->conf.nb_queue_pairs);
708 /* invalid - max value + 1 queue pairs */
709 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
711 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
713 "Failed test for rte_cryptodev_configure, dev_id %u,"
715 ts_params->valid_devs[0],
716 ts_params->conf.nb_queue_pairs);
718 /* revert to original testsuite value */
719 ts_params->conf.nb_queue_pairs = orig_nb_qps;
725 test_queue_pair_descriptor_setup(void)
727 struct crypto_testsuite_params *ts_params = &testsuite_params;
728 struct rte_cryptodev_info dev_info;
729 struct rte_cryptodev_qp_conf qp_conf = {
730 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
735 /* Stop the device in case it's started so it can be configured */
736 rte_cryptodev_stop(ts_params->valid_devs[0]);
739 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
741 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
743 "Failed to configure cryptodev %u",
744 ts_params->valid_devs[0]);
747 * Test various ring sizes on this device. memzones can't be
748 * freed so are re-used if ring is released and re-created.
750 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
751 qp_conf.mp_session = ts_params->session_mpool;
752 qp_conf.mp_session_private = ts_params->session_priv_mpool;
754 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
755 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
756 ts_params->valid_devs[0], qp_id, &qp_conf,
757 rte_cryptodev_socket_id(
758 ts_params->valid_devs[0])),
760 "rte_cryptodev_queue_pair_setup: num_inflights "
761 "%u on qp %u on cryptodev %u",
762 qp_conf.nb_descriptors, qp_id,
763 ts_params->valid_devs[0]);
766 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
768 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
769 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
770 ts_params->valid_devs[0], qp_id, &qp_conf,
771 rte_cryptodev_socket_id(
772 ts_params->valid_devs[0])),
774 " rte_cryptodev_queue_pair_setup: num_inflights"
775 " %u on qp %u on cryptodev %u",
776 qp_conf.nb_descriptors, qp_id,
777 ts_params->valid_devs[0]);
780 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
782 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
783 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0], qp_id, &qp_conf,
785 rte_cryptodev_socket_id(
786 ts_params->valid_devs[0])),
788 "rte_cryptodev_queue_pair_setup: num_inflights"
789 " %u on qp %u on cryptodev %u",
790 qp_conf.nb_descriptors, qp_id,
791 ts_params->valid_devs[0]);
794 /* invalid number of descriptors - max supported + 2 */
795 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
797 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
798 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
799 ts_params->valid_devs[0], qp_id, &qp_conf,
800 rte_cryptodev_socket_id(
801 ts_params->valid_devs[0])),
802 "Unexpectedly passed test for "
803 "rte_cryptodev_queue_pair_setup:"
804 "num_inflights %u on qp %u on cryptodev %u",
805 qp_conf.nb_descriptors, qp_id,
806 ts_params->valid_devs[0]);
809 /* invalid number of descriptors - max value of parameter */
810 qp_conf.nb_descriptors = UINT32_MAX-1;
812 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
813 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
814 ts_params->valid_devs[0], qp_id, &qp_conf,
815 rte_cryptodev_socket_id(
816 ts_params->valid_devs[0])),
817 "Unexpectedly passed test for "
818 "rte_cryptodev_queue_pair_setup:"
819 "num_inflights %u on qp %u on cryptodev %u",
820 qp_conf.nb_descriptors, qp_id,
821 ts_params->valid_devs[0]);
824 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
826 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
827 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
828 ts_params->valid_devs[0], qp_id, &qp_conf,
829 rte_cryptodev_socket_id(
830 ts_params->valid_devs[0])),
832 " rte_cryptodev_queue_pair_setup:"
833 "num_inflights %u on qp %u on cryptodev %u",
834 qp_conf.nb_descriptors, qp_id,
835 ts_params->valid_devs[0]);
838 /* invalid number of descriptors - max supported + 1 */
839 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
841 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
842 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
843 ts_params->valid_devs[0], qp_id, &qp_conf,
844 rte_cryptodev_socket_id(
845 ts_params->valid_devs[0])),
846 "Unexpectedly passed test for "
847 "rte_cryptodev_queue_pair_setup:"
848 "num_inflights %u on qp %u on cryptodev %u",
849 qp_conf.nb_descriptors, qp_id,
850 ts_params->valid_devs[0]);
853 /* test invalid queue pair id */
854 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
856 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
858 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
859 ts_params->valid_devs[0],
861 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
862 "Failed test for rte_cryptodev_queue_pair_setup:"
863 "invalid qp %u on cryptodev %u",
864 qp_id, ts_params->valid_devs[0]);
866 qp_id = 0xffff; /*invalid*/
868 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
869 ts_params->valid_devs[0],
871 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
872 "Failed test for rte_cryptodev_queue_pair_setup:"
873 "invalid qp %u on cryptodev %u",
874 qp_id, ts_params->valid_devs[0]);
879 /* ***** Plaintext data for tests ***** */
881 const char catch_22_quote_1[] =
882 "There was only one catch and that was Catch-22, which "
883 "specified that a concern for one's safety in the face of "
884 "dangers that were real and immediate was the process of a "
885 "rational mind. Orr was crazy and could be grounded. All he "
886 "had to do was ask; and as soon as he did, he would no longer "
887 "be crazy and would have to fly more missions. Orr would be "
888 "crazy to fly more missions and sane if he didn't, but if he "
889 "was sane he had to fly them. If he flew them he was crazy "
890 "and didn't have to; but if he didn't want to he was sane and "
891 "had to. Yossarian was moved very deeply by the absolute "
892 "simplicity of this clause of Catch-22 and let out a "
893 "respectful whistle. \"That's some catch, that Catch-22\", he "
894 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
896 const char catch_22_quote[] =
897 "What a lousy earth! He wondered how many people were "
898 "destitute that same night even in his own prosperous country, "
899 "how many homes were shanties, how many husbands were drunk "
900 "and wives socked, and how many children were bullied, abused, "
901 "or abandoned. How many families hungered for food they could "
902 "not afford to buy? How many hearts were broken? How many "
903 "suicides would take place that same night, how many people "
904 "would go insane? How many cockroaches and landlords would "
905 "triumph? How many winners were losers, successes failures, "
906 "and rich men poor men? How many wise guys were stupid? How "
907 "many happy endings were unhappy endings? How many honest men "
908 "were liars, brave men cowards, loyal men traitors, how many "
909 "sainted men were corrupt, how many people in positions of "
910 "trust had sold their souls to bodyguards, how many had never "
911 "had souls? How many straight-and-narrow paths were crooked "
912 "paths? How many best families were worst families and how "
913 "many good people were bad people? When you added them all up "
914 "and then subtracted, you might be left with only the children, "
915 "and perhaps with Albert Einstein and an old violinist or "
916 "sculptor somewhere.";
918 #define QUOTE_480_BYTES (480)
919 #define QUOTE_512_BYTES (512)
920 #define QUOTE_768_BYTES (768)
921 #define QUOTE_1024_BYTES (1024)
925 /* ***** SHA1 Hash Tests ***** */
927 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
929 static uint8_t hmac_sha1_key[] = {
930 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
931 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
932 0xDE, 0xF4, 0xDE, 0xAD };
934 /* ***** SHA224 Hash Tests ***** */
936 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
939 /* ***** AES-CBC Cipher Tests ***** */
941 #define CIPHER_KEY_LENGTH_AES_CBC (16)
942 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
944 static uint8_t aes_cbc_key[] = {
945 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
946 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
948 static uint8_t aes_cbc_iv[] = {
949 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
950 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
953 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
955 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
956 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
957 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
958 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
959 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
960 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
961 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
962 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
963 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
964 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
965 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
966 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
967 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
968 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
969 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
970 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
971 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
972 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
973 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
974 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
975 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
976 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
977 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
978 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
979 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
980 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
981 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
982 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
983 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
984 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
985 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
986 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
987 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
988 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
989 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
990 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
991 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
992 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
993 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
994 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
995 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
996 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
997 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
998 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
999 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1000 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1001 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1002 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1003 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1004 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1005 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1006 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1007 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1008 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1009 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1010 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1011 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1012 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1013 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1014 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1015 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1016 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1017 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1018 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1019 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1022 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1023 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1024 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1025 0x18, 0x8c, 0x1d, 0x32
1029 /* Multisession Vector context Test */
1030 /*Begin Session 0 */
1031 static uint8_t ms_aes_cbc_key0[] = {
1032 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1033 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1036 static uint8_t ms_aes_cbc_iv0[] = {
1037 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1038 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1041 static const uint8_t ms_aes_cbc_cipher0[] = {
1042 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1043 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1044 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1045 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1046 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1047 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1048 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1049 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1050 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1051 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1052 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1053 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1054 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1055 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1056 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1057 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1058 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1059 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1060 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1061 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1062 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1063 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1064 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1065 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1066 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1067 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1068 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1069 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1070 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1071 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1072 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1073 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1074 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1075 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1076 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1077 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1078 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1079 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1080 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1081 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1082 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1083 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1084 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1085 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1086 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1087 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1088 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1089 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1090 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1091 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1092 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1093 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1094 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1095 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1096 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1097 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1098 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1099 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1100 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1101 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1102 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1103 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1104 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1105 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1109 static uint8_t ms_hmac_key0[] = {
1110 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1111 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1112 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1113 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1114 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1115 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1116 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1117 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1120 static const uint8_t ms_hmac_digest0[] = {
1121 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1122 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1123 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1124 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1125 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1126 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1127 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1128 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1132 /* Begin session 1 */
1134 static uint8_t ms_aes_cbc_key1[] = {
1135 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1136 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1139 static uint8_t ms_aes_cbc_iv1[] = {
1140 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1141 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1144 static const uint8_t ms_aes_cbc_cipher1[] = {
1145 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1146 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1147 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1148 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1149 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1150 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1151 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1152 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1153 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1154 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1155 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1156 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1157 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1158 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1159 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1160 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1161 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1162 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1163 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1164 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1165 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1166 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1167 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1168 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1169 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1170 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1171 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1172 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1173 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1174 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1175 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1176 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1177 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1178 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1179 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1180 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1181 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1182 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1183 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1184 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1185 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1186 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1187 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1188 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1189 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1190 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1191 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1192 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1193 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1194 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1195 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1196 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1197 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1198 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1199 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1200 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1201 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1202 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1203 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1204 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1205 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1206 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1207 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1208 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1212 static uint8_t ms_hmac_key1[] = {
1213 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1214 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1215 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1216 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1217 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1218 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1219 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1220 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1223 static const uint8_t ms_hmac_digest1[] = {
1224 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1225 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1226 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1227 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1228 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1229 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1230 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1231 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1234 /* Begin Session 2 */
1235 static uint8_t ms_aes_cbc_key2[] = {
1236 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1237 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1240 static uint8_t ms_aes_cbc_iv2[] = {
1241 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1242 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1245 static const uint8_t ms_aes_cbc_cipher2[] = {
1246 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1247 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1248 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1249 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1250 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1251 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1252 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1253 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1254 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1255 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1256 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1257 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1258 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1259 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1260 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1261 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1262 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1263 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1264 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1265 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1266 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1267 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1268 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1269 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1270 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1271 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1272 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1273 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1274 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1275 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1276 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1277 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1278 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1279 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1280 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1281 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1282 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1283 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1284 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1285 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1286 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1287 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1288 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1289 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1290 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1291 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1292 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1293 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1294 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1295 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1296 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1297 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1298 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1299 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1300 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1301 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1302 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1303 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1304 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1305 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1306 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1307 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1308 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1309 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1312 static uint8_t ms_hmac_key2[] = {
1313 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1314 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1315 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1316 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1317 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1318 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1319 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1320 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1323 static const uint8_t ms_hmac_digest2[] = {
1324 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1325 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1326 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1327 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1328 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1329 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1330 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1331 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1338 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1340 struct crypto_testsuite_params *ts_params = &testsuite_params;
1341 struct crypto_unittest_params *ut_params = &unittest_params;
1343 /* Generate test mbuf data and space for digest */
1344 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1345 catch_22_quote, QUOTE_512_BYTES, 0);
1347 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1348 DIGEST_BYTE_LENGTH_SHA1);
1349 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1351 /* Setup Cipher Parameters */
1352 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1353 ut_params->cipher_xform.next = &ut_params->auth_xform;
1355 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1356 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1357 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1358 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1359 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1360 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1362 /* Setup HMAC Parameters */
1363 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1365 ut_params->auth_xform.next = NULL;
1367 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1368 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1369 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1370 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1371 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1373 ut_params->sess = rte_cryptodev_sym_session_create(
1374 ts_params->session_mpool);
1376 /* Create crypto session*/
1377 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1378 ut_params->sess, &ut_params->cipher_xform,
1379 ts_params->session_priv_mpool);
1380 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1382 /* Generate crypto op data structure */
1383 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1384 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1385 TEST_ASSERT_NOT_NULL(ut_params->op,
1386 "Failed to allocate symmetric crypto operation struct");
1388 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1390 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1392 /* set crypto operation source mbuf */
1393 sym_op->m_src = ut_params->ibuf;
1395 /* Set crypto operation authentication parameters */
1396 sym_op->auth.digest.data = ut_params->digest;
1397 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1398 ut_params->ibuf, QUOTE_512_BYTES);
1400 sym_op->auth.data.offset = 0;
1401 sym_op->auth.data.length = QUOTE_512_BYTES;
1403 /* Copy IV at the end of the crypto operation */
1404 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1405 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1407 /* Set crypto operation cipher parameters */
1408 sym_op->cipher.data.offset = 0;
1409 sym_op->cipher.data.length = QUOTE_512_BYTES;
1411 /* Process crypto operation */
1412 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1413 ut_params->op), "failed to process sym crypto op");
1415 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1416 "crypto op processing failed");
1419 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1422 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1423 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1425 "ciphertext data not as expected");
1427 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1429 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1430 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1431 gbl_driver_id == rte_cryptodev_driver_id_get(
1432 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1433 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1434 DIGEST_BYTE_LENGTH_SHA1,
1435 "Generated digest data not as expected");
1437 return TEST_SUCCESS;
1440 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1442 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1444 static uint8_t hmac_sha512_key[] = {
1445 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1446 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1447 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1448 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1449 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1450 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1451 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1452 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1454 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1455 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1456 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1457 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1458 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1459 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1460 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1461 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1462 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1467 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1468 struct crypto_unittest_params *ut_params,
1469 uint8_t *cipher_key,
1473 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1474 struct crypto_unittest_params *ut_params,
1475 struct crypto_testsuite_params *ts_params,
1476 const uint8_t *cipher,
1477 const uint8_t *digest,
1482 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1483 struct crypto_unittest_params *ut_params,
1484 uint8_t *cipher_key,
1488 /* Setup Cipher Parameters */
1489 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1490 ut_params->cipher_xform.next = NULL;
1492 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1493 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1494 ut_params->cipher_xform.cipher.key.data = cipher_key;
1495 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1496 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1497 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1499 /* Setup HMAC Parameters */
1500 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1501 ut_params->auth_xform.next = &ut_params->cipher_xform;
1503 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1504 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1505 ut_params->auth_xform.auth.key.data = hmac_key;
1506 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1507 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1509 return TEST_SUCCESS;
1514 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1515 struct crypto_unittest_params *ut_params,
1516 struct crypto_testsuite_params *ts_params,
1517 const uint8_t *cipher,
1518 const uint8_t *digest,
1521 /* Generate test mbuf data and digest */
1522 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1525 QUOTE_512_BYTES, 0);
1527 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1528 DIGEST_BYTE_LENGTH_SHA512);
1529 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1531 rte_memcpy(ut_params->digest,
1533 DIGEST_BYTE_LENGTH_SHA512);
1535 /* Generate Crypto op data structure */
1536 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1537 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1538 TEST_ASSERT_NOT_NULL(ut_params->op,
1539 "Failed to allocate symmetric crypto operation struct");
1541 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1543 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1545 /* set crypto operation source mbuf */
1546 sym_op->m_src = ut_params->ibuf;
1548 sym_op->auth.digest.data = ut_params->digest;
1549 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1550 ut_params->ibuf, QUOTE_512_BYTES);
1552 sym_op->auth.data.offset = 0;
1553 sym_op->auth.data.length = QUOTE_512_BYTES;
1555 /* Copy IV at the end of the crypto operation */
1556 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1557 iv, CIPHER_IV_LENGTH_AES_CBC);
1559 sym_op->cipher.data.offset = 0;
1560 sym_op->cipher.data.length = QUOTE_512_BYTES;
1562 /* Process crypto operation */
1563 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1564 ut_params->op), "failed to process sym crypto op");
1566 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1567 "crypto op processing failed");
1569 ut_params->obuf = ut_params->op->sym->m_src;
1572 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1573 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1576 "Plaintext data not as expected");
1579 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1580 "Digest verification failed");
1582 return TEST_SUCCESS;
1586 test_AES_cipheronly_mb_all(void)
1588 struct crypto_testsuite_params *ts_params = &testsuite_params;
1591 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1592 ts_params->op_mpool,
1593 ts_params->session_mpool, ts_params->session_priv_mpool,
1594 ts_params->valid_devs[0],
1595 rte_cryptodev_driver_id_get(
1596 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1597 BLKCIPHER_AES_CIPHERONLY_TYPE);
1599 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1601 return TEST_SUCCESS;
1605 test_AES_docsis_mb_all(void)
1607 struct crypto_testsuite_params *ts_params = &testsuite_params;
1610 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1611 ts_params->op_mpool,
1612 ts_params->session_mpool, ts_params->session_priv_mpool,
1613 ts_params->valid_devs[0],
1614 rte_cryptodev_driver_id_get(
1615 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1616 BLKCIPHER_AES_DOCSIS_TYPE);
1618 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1620 return TEST_SUCCESS;
1624 test_AES_docsis_qat_all(void)
1626 struct crypto_testsuite_params *ts_params = &testsuite_params;
1629 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1630 ts_params->op_mpool,
1631 ts_params->session_mpool, ts_params->session_priv_mpool,
1632 ts_params->valid_devs[0],
1633 rte_cryptodev_driver_id_get(
1634 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1635 BLKCIPHER_AES_DOCSIS_TYPE);
1637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1639 return TEST_SUCCESS;
1643 test_DES_docsis_qat_all(void)
1645 struct crypto_testsuite_params *ts_params = &testsuite_params;
1648 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1649 ts_params->op_mpool,
1650 ts_params->session_mpool, ts_params->session_priv_mpool,
1651 ts_params->valid_devs[0],
1652 rte_cryptodev_driver_id_get(
1653 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1654 BLKCIPHER_DES_DOCSIS_TYPE);
1656 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1658 return TEST_SUCCESS;
1662 test_authonly_mb_all(void)
1664 struct crypto_testsuite_params *ts_params = &testsuite_params;
1667 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1668 ts_params->op_mpool,
1669 ts_params->session_mpool, ts_params->session_priv_mpool,
1670 ts_params->valid_devs[0],
1671 rte_cryptodev_driver_id_get(
1672 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1673 BLKCIPHER_AUTHONLY_TYPE);
1675 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1677 return TEST_SUCCESS;
1681 test_authonly_qat_all(void)
1683 struct crypto_testsuite_params *ts_params = &testsuite_params;
1686 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1687 ts_params->op_mpool,
1688 ts_params->session_mpool, ts_params->session_priv_mpool,
1689 ts_params->valid_devs[0],
1690 rte_cryptodev_driver_id_get(
1691 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1692 BLKCIPHER_AUTHONLY_TYPE);
1694 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1696 return TEST_SUCCESS;
1700 test_AES_chain_null_all(void)
1702 struct crypto_testsuite_params *ts_params = &testsuite_params;
1705 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1706 ts_params->op_mpool,
1707 ts_params->session_mpool, ts_params->session_priv_mpool,
1708 ts_params->valid_devs[0],
1709 rte_cryptodev_driver_id_get(
1710 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1711 BLKCIPHER_AES_CHAIN_TYPE);
1713 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1715 return TEST_SUCCESS;
1719 test_AES_cipheronly_null_all(void)
1721 struct crypto_testsuite_params *ts_params = &testsuite_params;
1724 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1725 ts_params->op_mpool,
1726 ts_params->session_mpool, ts_params->session_priv_mpool,
1727 ts_params->valid_devs[0],
1728 rte_cryptodev_driver_id_get(
1729 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1730 BLKCIPHER_AES_CIPHERONLY_TYPE);
1732 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1734 return TEST_SUCCESS;
1738 test_authonly_null_all(void)
1740 struct crypto_testsuite_params *ts_params = &testsuite_params;
1743 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1744 ts_params->op_mpool,
1745 ts_params->session_mpool, ts_params->session_priv_mpool,
1746 ts_params->valid_devs[0],
1747 rte_cryptodev_driver_id_get(
1748 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1749 BLKCIPHER_AUTHONLY_TYPE);
1751 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1753 return TEST_SUCCESS;
1757 test_AES_chain_mb_all(void)
1759 struct crypto_testsuite_params *ts_params = &testsuite_params;
1762 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1763 ts_params->op_mpool,
1764 ts_params->session_mpool, ts_params->session_priv_mpool,
1765 ts_params->valid_devs[0],
1766 rte_cryptodev_driver_id_get(
1767 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1768 BLKCIPHER_AES_CHAIN_TYPE);
1770 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1772 return TEST_SUCCESS;
1775 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1778 test_AES_cipheronly_scheduler_all(void)
1780 struct crypto_testsuite_params *ts_params = &testsuite_params;
1783 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1784 ts_params->op_mpool,
1785 ts_params->session_mpool, ts_params->session_priv_mpool,
1786 ts_params->valid_devs[0],
1787 rte_cryptodev_driver_id_get(
1788 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1789 BLKCIPHER_AES_CIPHERONLY_TYPE);
1791 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1793 return TEST_SUCCESS;
1797 test_AES_chain_scheduler_all(void)
1799 struct crypto_testsuite_params *ts_params = &testsuite_params;
1802 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1803 ts_params->op_mpool,
1804 ts_params->session_mpool, ts_params->session_priv_mpool,
1805 ts_params->valid_devs[0],
1806 rte_cryptodev_driver_id_get(
1807 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1808 BLKCIPHER_AES_CHAIN_TYPE);
1810 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1812 return TEST_SUCCESS;
1816 test_authonly_scheduler_all(void)
1818 struct crypto_testsuite_params *ts_params = &testsuite_params;
1821 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1822 ts_params->op_mpool,
1823 ts_params->session_mpool, ts_params->session_priv_mpool,
1824 ts_params->valid_devs[0],
1825 rte_cryptodev_driver_id_get(
1826 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1827 BLKCIPHER_AUTHONLY_TYPE);
1829 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1831 return TEST_SUCCESS;
1834 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1837 test_AES_chain_openssl_all(void)
1839 struct crypto_testsuite_params *ts_params = &testsuite_params;
1842 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1843 ts_params->op_mpool,
1844 ts_params->session_mpool, ts_params->session_priv_mpool,
1845 ts_params->valid_devs[0],
1846 rte_cryptodev_driver_id_get(
1847 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1848 BLKCIPHER_AES_CHAIN_TYPE);
1850 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1852 return TEST_SUCCESS;
1856 test_AES_cipheronly_openssl_all(void)
1858 struct crypto_testsuite_params *ts_params = &testsuite_params;
1861 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1862 ts_params->op_mpool,
1863 ts_params->session_mpool, ts_params->session_priv_mpool,
1864 ts_params->valid_devs[0],
1865 rte_cryptodev_driver_id_get(
1866 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1867 BLKCIPHER_AES_CIPHERONLY_TYPE);
1869 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1871 return TEST_SUCCESS;
1875 test_AES_chain_ccp_all(void)
1877 struct crypto_testsuite_params *ts_params = &testsuite_params;
1880 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1881 ts_params->op_mpool,
1882 ts_params->session_mpool, ts_params->session_priv_mpool,
1883 ts_params->valid_devs[0],
1884 rte_cryptodev_driver_id_get(
1885 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1886 BLKCIPHER_AES_CHAIN_TYPE);
1888 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1890 return TEST_SUCCESS;
1894 test_AES_cipheronly_ccp_all(void)
1896 struct crypto_testsuite_params *ts_params = &testsuite_params;
1899 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1900 ts_params->op_mpool,
1901 ts_params->session_mpool, ts_params->session_priv_mpool,
1902 ts_params->valid_devs[0],
1903 rte_cryptodev_driver_id_get(
1904 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1905 BLKCIPHER_AES_CIPHERONLY_TYPE);
1907 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1909 return TEST_SUCCESS;
1913 test_AES_chain_qat_all(void)
1915 struct crypto_testsuite_params *ts_params = &testsuite_params;
1918 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1919 ts_params->op_mpool,
1920 ts_params->session_mpool, ts_params->session_priv_mpool,
1921 ts_params->valid_devs[0],
1922 rte_cryptodev_driver_id_get(
1923 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1924 BLKCIPHER_AES_CHAIN_TYPE);
1926 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1928 return TEST_SUCCESS;
1932 test_AES_cipheronly_qat_all(void)
1934 struct crypto_testsuite_params *ts_params = &testsuite_params;
1937 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1938 ts_params->op_mpool,
1939 ts_params->session_mpool, ts_params->session_priv_mpool,
1940 ts_params->valid_devs[0],
1941 rte_cryptodev_driver_id_get(
1942 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1943 BLKCIPHER_AES_CIPHERONLY_TYPE);
1945 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1947 return TEST_SUCCESS;
1951 test_AES_cipheronly_virtio_all(void)
1953 struct crypto_testsuite_params *ts_params = &testsuite_params;
1956 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1957 ts_params->op_mpool,
1958 ts_params->session_mpool, ts_params->session_priv_mpool,
1959 ts_params->valid_devs[0],
1960 rte_cryptodev_driver_id_get(
1961 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1962 BLKCIPHER_AES_CIPHERONLY_TYPE);
1964 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1966 return TEST_SUCCESS;
1970 test_AES_chain_caam_jr_all(void)
1972 struct crypto_testsuite_params *ts_params = &testsuite_params;
1975 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1976 ts_params->op_mpool,
1977 ts_params->session_mpool, ts_params->session_priv_mpool,
1978 ts_params->valid_devs[0],
1979 rte_cryptodev_driver_id_get(
1980 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1981 BLKCIPHER_AES_CHAIN_TYPE);
1983 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1985 return TEST_SUCCESS;
1989 test_AES_cipheronly_caam_jr_all(void)
1991 struct crypto_testsuite_params *ts_params = &testsuite_params;
1994 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1995 ts_params->op_mpool,
1996 ts_params->session_mpool, ts_params->session_priv_mpool,
1997 ts_params->valid_devs[0],
1998 rte_cryptodev_driver_id_get(
1999 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2000 BLKCIPHER_AES_CIPHERONLY_TYPE);
2002 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2004 return TEST_SUCCESS;
2008 test_authonly_caam_jr_all(void)
2010 struct crypto_testsuite_params *ts_params = &testsuite_params;
2013 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2014 ts_params->op_mpool,
2015 ts_params->session_mpool, ts_params->session_priv_mpool,
2016 ts_params->valid_devs[0],
2017 rte_cryptodev_driver_id_get(
2018 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2019 BLKCIPHER_AUTHONLY_TYPE);
2021 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2023 return TEST_SUCCESS;
2028 test_AES_chain_dpaa_sec_all(void)
2030 struct crypto_testsuite_params *ts_params = &testsuite_params;
2033 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2034 ts_params->op_mpool,
2035 ts_params->session_mpool, ts_params->session_priv_mpool,
2036 ts_params->valid_devs[0],
2037 rte_cryptodev_driver_id_get(
2038 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2039 BLKCIPHER_AES_CHAIN_TYPE);
2041 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2043 return TEST_SUCCESS;
2047 test_AES_cipheronly_dpaa_sec_all(void)
2049 struct crypto_testsuite_params *ts_params = &testsuite_params;
2052 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2053 ts_params->op_mpool,
2054 ts_params->session_mpool, ts_params->session_priv_mpool,
2055 ts_params->valid_devs[0],
2056 rte_cryptodev_driver_id_get(
2057 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2058 BLKCIPHER_AES_CIPHERONLY_TYPE);
2060 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2062 return TEST_SUCCESS;
2066 test_authonly_dpaa_sec_all(void)
2068 struct crypto_testsuite_params *ts_params = &testsuite_params;
2071 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2072 ts_params->op_mpool,
2073 ts_params->session_mpool, ts_params->session_priv_mpool,
2074 ts_params->valid_devs[0],
2075 rte_cryptodev_driver_id_get(
2076 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2077 BLKCIPHER_AUTHONLY_TYPE);
2079 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2081 return TEST_SUCCESS;
2085 test_AES_chain_dpaa2_sec_all(void)
2087 struct crypto_testsuite_params *ts_params = &testsuite_params;
2090 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2091 ts_params->op_mpool,
2092 ts_params->session_mpool, ts_params->session_priv_mpool,
2093 ts_params->valid_devs[0],
2094 rte_cryptodev_driver_id_get(
2095 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2096 BLKCIPHER_AES_CHAIN_TYPE);
2098 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2100 return TEST_SUCCESS;
2104 test_AES_cipheronly_dpaa2_sec_all(void)
2106 struct crypto_testsuite_params *ts_params = &testsuite_params;
2109 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2110 ts_params->op_mpool,
2111 ts_params->session_mpool, ts_params->session_priv_mpool,
2112 ts_params->valid_devs[0],
2113 rte_cryptodev_driver_id_get(
2114 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2115 BLKCIPHER_AES_CIPHERONLY_TYPE);
2117 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2119 return TEST_SUCCESS;
2123 test_authonly_dpaa2_sec_all(void)
2125 struct crypto_testsuite_params *ts_params = &testsuite_params;
2128 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2129 ts_params->op_mpool,
2130 ts_params->session_mpool, ts_params->session_priv_mpool,
2131 ts_params->valid_devs[0],
2132 rte_cryptodev_driver_id_get(
2133 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2134 BLKCIPHER_AUTHONLY_TYPE);
2136 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2138 return TEST_SUCCESS;
2142 test_authonly_openssl_all(void)
2144 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2148 ts_params->op_mpool,
2149 ts_params->session_mpool, ts_params->session_priv_mpool,
2150 ts_params->valid_devs[0],
2151 rte_cryptodev_driver_id_get(
2152 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2153 BLKCIPHER_AUTHONLY_TYPE);
2155 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2157 return TEST_SUCCESS;
2161 test_authonly_ccp_all(void)
2163 struct crypto_testsuite_params *ts_params = &testsuite_params;
2166 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2167 ts_params->op_mpool,
2168 ts_params->session_mpool, ts_params->session_priv_mpool,
2169 ts_params->valid_devs[0],
2170 rte_cryptodev_driver_id_get(
2171 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2172 BLKCIPHER_AUTHONLY_TYPE);
2174 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2176 return TEST_SUCCESS;
2180 test_AES_chain_armv8_all(void)
2182 struct crypto_testsuite_params *ts_params = &testsuite_params;
2185 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2186 ts_params->op_mpool,
2187 ts_params->session_mpool, ts_params->session_priv_mpool,
2188 ts_params->valid_devs[0],
2189 rte_cryptodev_driver_id_get(
2190 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2191 BLKCIPHER_AES_CHAIN_TYPE);
2193 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2195 return TEST_SUCCESS;
2199 test_AES_chain_mrvl_all(void)
2201 struct crypto_testsuite_params *ts_params = &testsuite_params;
2204 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2205 ts_params->op_mpool,
2206 ts_params->session_mpool, ts_params->session_priv_mpool,
2207 ts_params->valid_devs[0],
2208 rte_cryptodev_driver_id_get(
2209 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2210 BLKCIPHER_AES_CHAIN_TYPE);
2212 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2214 return TEST_SUCCESS;
2218 test_AES_cipheronly_mrvl_all(void)
2220 struct crypto_testsuite_params *ts_params = &testsuite_params;
2223 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2224 ts_params->op_mpool,
2225 ts_params->session_mpool, ts_params->session_priv_mpool,
2226 ts_params->valid_devs[0],
2227 rte_cryptodev_driver_id_get(
2228 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2229 BLKCIPHER_AES_CIPHERONLY_TYPE);
2231 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2233 return TEST_SUCCESS;
2237 test_authonly_mrvl_all(void)
2239 struct crypto_testsuite_params *ts_params = &testsuite_params;
2242 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2243 ts_params->op_mpool,
2244 ts_params->session_mpool, ts_params->session_priv_mpool,
2245 ts_params->valid_devs[0],
2246 rte_cryptodev_driver_id_get(
2247 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2248 BLKCIPHER_AUTHONLY_TYPE);
2250 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2252 return TEST_SUCCESS;
2256 test_3DES_chain_mrvl_all(void)
2258 struct crypto_testsuite_params *ts_params = &testsuite_params;
2261 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2262 ts_params->op_mpool,
2263 ts_params->session_mpool, ts_params->session_priv_mpool,
2264 ts_params->valid_devs[0],
2265 rte_cryptodev_driver_id_get(
2266 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2267 BLKCIPHER_3DES_CHAIN_TYPE);
2269 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2271 return TEST_SUCCESS;
2275 test_3DES_cipheronly_mrvl_all(void)
2277 struct crypto_testsuite_params *ts_params = &testsuite_params;
2280 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2281 ts_params->op_mpool,
2282 ts_params->session_mpool, ts_params->session_priv_mpool,
2283 ts_params->valid_devs[0],
2284 rte_cryptodev_driver_id_get(
2285 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2286 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2288 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2290 return TEST_SUCCESS;
2294 test_AES_chain_octeontx_all(void)
2296 struct crypto_testsuite_params *ts_params = &testsuite_params;
2299 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2300 ts_params->op_mpool, ts_params->session_mpool,
2301 ts_params->session_priv_mpool,
2302 ts_params->valid_devs[0],
2303 rte_cryptodev_driver_id_get(
2304 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2305 BLKCIPHER_AES_CHAIN_TYPE);
2307 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2309 return TEST_SUCCESS;
2313 test_AES_cipheronly_octeontx_all(void)
2315 struct crypto_testsuite_params *ts_params = &testsuite_params;
2318 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2319 ts_params->op_mpool, ts_params->session_mpool,
2320 ts_params->session_priv_mpool,
2321 ts_params->valid_devs[0],
2322 rte_cryptodev_driver_id_get(
2323 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2324 BLKCIPHER_AES_CIPHERONLY_TYPE);
2326 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2328 return TEST_SUCCESS;
2332 test_3DES_chain_octeontx_all(void)
2334 struct crypto_testsuite_params *ts_params = &testsuite_params;
2337 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2338 ts_params->op_mpool, ts_params->session_mpool,
2339 ts_params->session_priv_mpool,
2340 ts_params->valid_devs[0],
2341 rte_cryptodev_driver_id_get(
2342 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2343 BLKCIPHER_3DES_CHAIN_TYPE);
2345 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2347 return TEST_SUCCESS;
2351 test_AES_chain_nitrox_all(void)
2353 struct crypto_testsuite_params *ts_params = &testsuite_params;
2356 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2357 ts_params->op_mpool,
2358 ts_params->session_mpool, ts_params->session_priv_mpool,
2359 ts_params->valid_devs[0],
2360 rte_cryptodev_driver_id_get(
2361 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2362 BLKCIPHER_AES_CHAIN_TYPE);
2364 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2366 return TEST_SUCCESS;
2370 test_3DES_cipheronly_octeontx_all(void)
2372 struct crypto_testsuite_params *ts_params = &testsuite_params;
2375 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2376 ts_params->op_mpool, ts_params->session_mpool,
2377 ts_params->session_priv_mpool,
2378 ts_params->valid_devs[0],
2379 rte_cryptodev_driver_id_get(
2380 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2381 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2383 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2385 return TEST_SUCCESS;
2389 test_authonly_octeontx_all(void)
2391 struct crypto_testsuite_params *ts_params = &testsuite_params;
2394 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2395 ts_params->op_mpool, ts_params->session_mpool,
2396 ts_params->session_priv_mpool,
2397 ts_params->valid_devs[0],
2398 rte_cryptodev_driver_id_get(
2399 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2400 BLKCIPHER_AUTHONLY_TYPE);
2402 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2404 return TEST_SUCCESS;
2408 test_AES_chain_octeontx2_all(void)
2410 struct crypto_testsuite_params *ts_params = &testsuite_params;
2413 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2414 ts_params->op_mpool, ts_params->session_mpool,
2415 ts_params->session_priv_mpool,
2416 ts_params->valid_devs[0],
2417 rte_cryptodev_driver_id_get(
2418 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2419 BLKCIPHER_AES_CHAIN_TYPE);
2421 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2423 return TEST_SUCCESS;
2427 test_AES_cipheronly_octeontx2_all(void)
2429 struct crypto_testsuite_params *ts_params = &testsuite_params;
2432 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2433 ts_params->op_mpool, ts_params->session_mpool,
2434 ts_params->session_priv_mpool,
2435 ts_params->valid_devs[0],
2436 rte_cryptodev_driver_id_get(
2437 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2438 BLKCIPHER_AES_CIPHERONLY_TYPE);
2440 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2442 return TEST_SUCCESS;
2446 test_3DES_chain_octeontx2_all(void)
2448 struct crypto_testsuite_params *ts_params = &testsuite_params;
2451 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2452 ts_params->op_mpool, ts_params->session_mpool,
2453 ts_params->session_priv_mpool,
2454 ts_params->valid_devs[0],
2455 rte_cryptodev_driver_id_get(
2456 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2457 BLKCIPHER_3DES_CHAIN_TYPE);
2459 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2461 return TEST_SUCCESS;
2465 test_3DES_cipheronly_octeontx2_all(void)
2467 struct crypto_testsuite_params *ts_params = &testsuite_params;
2470 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2471 ts_params->op_mpool, ts_params->session_mpool,
2472 ts_params->session_priv_mpool,
2473 ts_params->valid_devs[0],
2474 rte_cryptodev_driver_id_get(
2475 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2476 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2478 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2480 return TEST_SUCCESS;
2484 test_authonly_octeontx2_all(void)
2486 struct crypto_testsuite_params *ts_params = &testsuite_params;
2489 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2490 ts_params->op_mpool, ts_params->session_mpool,
2491 ts_params->session_priv_mpool,
2492 ts_params->valid_devs[0],
2493 rte_cryptodev_driver_id_get(
2494 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2495 BLKCIPHER_AUTHONLY_TYPE);
2497 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2499 return TEST_SUCCESS;
2502 /* ***** SNOW 3G Tests ***** */
2504 create_wireless_algo_hash_session(uint8_t dev_id,
2505 const uint8_t *key, const uint8_t key_len,
2506 const uint8_t iv_len, const uint8_t auth_len,
2507 enum rte_crypto_auth_operation op,
2508 enum rte_crypto_auth_algorithm algo)
2510 uint8_t hash_key[key_len];
2513 struct crypto_testsuite_params *ts_params = &testsuite_params;
2514 struct crypto_unittest_params *ut_params = &unittest_params;
2516 memcpy(hash_key, key, key_len);
2518 debug_hexdump(stdout, "key:", key, key_len);
2520 /* Setup Authentication Parameters */
2521 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2522 ut_params->auth_xform.next = NULL;
2524 ut_params->auth_xform.auth.op = op;
2525 ut_params->auth_xform.auth.algo = algo;
2526 ut_params->auth_xform.auth.key.length = key_len;
2527 ut_params->auth_xform.auth.key.data = hash_key;
2528 ut_params->auth_xform.auth.digest_length = auth_len;
2529 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2530 ut_params->auth_xform.auth.iv.length = iv_len;
2531 ut_params->sess = rte_cryptodev_sym_session_create(
2532 ts_params->session_mpool);
2534 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2535 &ut_params->auth_xform,
2536 ts_params->session_priv_mpool);
2537 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2538 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2543 create_wireless_algo_cipher_session(uint8_t dev_id,
2544 enum rte_crypto_cipher_operation op,
2545 enum rte_crypto_cipher_algorithm algo,
2546 const uint8_t *key, const uint8_t key_len,
2549 uint8_t cipher_key[key_len];
2551 struct crypto_testsuite_params *ts_params = &testsuite_params;
2552 struct crypto_unittest_params *ut_params = &unittest_params;
2554 memcpy(cipher_key, key, key_len);
2556 /* Setup Cipher Parameters */
2557 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2558 ut_params->cipher_xform.next = NULL;
2560 ut_params->cipher_xform.cipher.algo = algo;
2561 ut_params->cipher_xform.cipher.op = op;
2562 ut_params->cipher_xform.cipher.key.data = cipher_key;
2563 ut_params->cipher_xform.cipher.key.length = key_len;
2564 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2565 ut_params->cipher_xform.cipher.iv.length = iv_len;
2567 debug_hexdump(stdout, "key:", key, key_len);
2569 /* Create Crypto session */
2570 ut_params->sess = rte_cryptodev_sym_session_create(
2571 ts_params->session_mpool);
2573 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2574 &ut_params->cipher_xform,
2575 ts_params->session_priv_mpool);
2576 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2577 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2582 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2583 unsigned int cipher_len,
2584 unsigned int cipher_offset)
2586 struct crypto_testsuite_params *ts_params = &testsuite_params;
2587 struct crypto_unittest_params *ut_params = &unittest_params;
2589 /* Generate Crypto op data structure */
2590 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2591 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2592 TEST_ASSERT_NOT_NULL(ut_params->op,
2593 "Failed to allocate pktmbuf offload");
2595 /* Set crypto operation data parameters */
2596 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2598 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2600 /* set crypto operation source mbuf */
2601 sym_op->m_src = ut_params->ibuf;
2604 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2606 sym_op->cipher.data.length = cipher_len;
2607 sym_op->cipher.data.offset = cipher_offset;
2612 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2613 unsigned int cipher_len,
2614 unsigned int cipher_offset)
2616 struct crypto_testsuite_params *ts_params = &testsuite_params;
2617 struct crypto_unittest_params *ut_params = &unittest_params;
2619 /* Generate Crypto op data structure */
2620 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2621 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2622 TEST_ASSERT_NOT_NULL(ut_params->op,
2623 "Failed to allocate pktmbuf offload");
2625 /* Set crypto operation data parameters */
2626 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2628 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630 /* set crypto operation source mbuf */
2631 sym_op->m_src = ut_params->ibuf;
2632 sym_op->m_dst = ut_params->obuf;
2635 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2637 sym_op->cipher.data.length = cipher_len;
2638 sym_op->cipher.data.offset = cipher_offset;
2643 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2644 enum rte_crypto_cipher_operation cipher_op,
2645 enum rte_crypto_auth_operation auth_op,
2646 enum rte_crypto_auth_algorithm auth_algo,
2647 enum rte_crypto_cipher_algorithm cipher_algo,
2648 const uint8_t *key, uint8_t key_len,
2649 uint8_t auth_iv_len, uint8_t auth_len,
2650 uint8_t cipher_iv_len)
2653 uint8_t cipher_auth_key[key_len];
2656 struct crypto_testsuite_params *ts_params = &testsuite_params;
2657 struct crypto_unittest_params *ut_params = &unittest_params;
2659 memcpy(cipher_auth_key, key, key_len);
2661 /* Setup Authentication Parameters */
2662 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2663 ut_params->auth_xform.next = NULL;
2665 ut_params->auth_xform.auth.op = auth_op;
2666 ut_params->auth_xform.auth.algo = auth_algo;
2667 ut_params->auth_xform.auth.key.length = key_len;
2668 /* Hash key = cipher key */
2669 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2670 ut_params->auth_xform.auth.digest_length = auth_len;
2671 /* Auth IV will be after cipher IV */
2672 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2673 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2675 /* Setup Cipher Parameters */
2676 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2677 ut_params->cipher_xform.next = &ut_params->auth_xform;
2679 ut_params->cipher_xform.cipher.algo = cipher_algo;
2680 ut_params->cipher_xform.cipher.op = cipher_op;
2681 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2682 ut_params->cipher_xform.cipher.key.length = key_len;
2683 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2684 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2686 debug_hexdump(stdout, "key:", key, key_len);
2688 /* Create Crypto session*/
2689 ut_params->sess = rte_cryptodev_sym_session_create(
2690 ts_params->session_mpool);
2692 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2693 &ut_params->cipher_xform,
2694 ts_params->session_priv_mpool);
2696 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2697 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2702 create_wireless_cipher_auth_session(uint8_t dev_id,
2703 enum rte_crypto_cipher_operation cipher_op,
2704 enum rte_crypto_auth_operation auth_op,
2705 enum rte_crypto_auth_algorithm auth_algo,
2706 enum rte_crypto_cipher_algorithm cipher_algo,
2707 const struct wireless_test_data *tdata)
2709 const uint8_t key_len = tdata->key.len;
2710 uint8_t cipher_auth_key[key_len];
2713 struct crypto_testsuite_params *ts_params = &testsuite_params;
2714 struct crypto_unittest_params *ut_params = &unittest_params;
2715 const uint8_t *key = tdata->key.data;
2716 const uint8_t auth_len = tdata->digest.len;
2717 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2718 uint8_t auth_iv_len = tdata->auth_iv.len;
2720 memcpy(cipher_auth_key, key, key_len);
2722 /* Setup Authentication Parameters */
2723 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2724 ut_params->auth_xform.next = NULL;
2726 ut_params->auth_xform.auth.op = auth_op;
2727 ut_params->auth_xform.auth.algo = auth_algo;
2728 ut_params->auth_xform.auth.key.length = key_len;
2729 /* Hash key = cipher key */
2730 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2731 ut_params->auth_xform.auth.digest_length = auth_len;
2732 /* Auth IV will be after cipher IV */
2733 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2734 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2736 /* Setup Cipher Parameters */
2737 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2738 ut_params->cipher_xform.next = &ut_params->auth_xform;
2740 ut_params->cipher_xform.cipher.algo = cipher_algo;
2741 ut_params->cipher_xform.cipher.op = cipher_op;
2742 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2743 ut_params->cipher_xform.cipher.key.length = key_len;
2744 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2745 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2748 debug_hexdump(stdout, "key:", key, key_len);
2750 /* Create Crypto session*/
2751 ut_params->sess = rte_cryptodev_sym_session_create(
2752 ts_params->session_mpool);
2754 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2755 &ut_params->cipher_xform,
2756 ts_params->session_priv_mpool);
2758 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2759 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2764 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2765 const struct wireless_test_data *tdata)
2767 return create_wireless_cipher_auth_session(dev_id,
2768 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2769 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2770 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2774 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2775 enum rte_crypto_cipher_operation cipher_op,
2776 enum rte_crypto_auth_operation auth_op,
2777 enum rte_crypto_auth_algorithm auth_algo,
2778 enum rte_crypto_cipher_algorithm cipher_algo,
2779 const uint8_t *key, const uint8_t key_len,
2780 uint8_t auth_iv_len, uint8_t auth_len,
2781 uint8_t cipher_iv_len)
2783 uint8_t auth_cipher_key[key_len];
2785 struct crypto_testsuite_params *ts_params = &testsuite_params;
2786 struct crypto_unittest_params *ut_params = &unittest_params;
2788 memcpy(auth_cipher_key, key, key_len);
2790 /* Setup Authentication Parameters */
2791 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2792 ut_params->auth_xform.auth.op = auth_op;
2793 ut_params->auth_xform.next = &ut_params->cipher_xform;
2794 ut_params->auth_xform.auth.algo = auth_algo;
2795 ut_params->auth_xform.auth.key.length = key_len;
2796 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2797 ut_params->auth_xform.auth.digest_length = auth_len;
2798 /* Auth IV will be after cipher IV */
2799 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2800 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2802 /* Setup Cipher Parameters */
2803 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2804 ut_params->cipher_xform.next = NULL;
2805 ut_params->cipher_xform.cipher.algo = cipher_algo;
2806 ut_params->cipher_xform.cipher.op = cipher_op;
2807 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2808 ut_params->cipher_xform.cipher.key.length = key_len;
2809 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2810 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2812 debug_hexdump(stdout, "key:", key, key_len);
2814 /* Create Crypto session*/
2815 ut_params->sess = rte_cryptodev_sym_session_create(
2816 ts_params->session_mpool);
2818 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2819 &ut_params->auth_xform,
2820 ts_params->session_priv_mpool);
2821 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2822 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2828 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2829 unsigned int auth_tag_len,
2830 const uint8_t *iv, unsigned int iv_len,
2831 unsigned int data_pad_len,
2832 enum rte_crypto_auth_operation op,
2833 unsigned int auth_len, unsigned int auth_offset)
2835 struct crypto_testsuite_params *ts_params = &testsuite_params;
2837 struct crypto_unittest_params *ut_params = &unittest_params;
2839 /* Generate Crypto op data structure */
2840 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2841 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2842 TEST_ASSERT_NOT_NULL(ut_params->op,
2843 "Failed to allocate pktmbuf offload");
2845 /* Set crypto operation data parameters */
2846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2848 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2850 /* set crypto operation source mbuf */
2851 sym_op->m_src = ut_params->ibuf;
2854 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2857 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2858 ut_params->ibuf, auth_tag_len);
2860 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2861 "no room to append auth tag");
2862 ut_params->digest = sym_op->auth.digest.data;
2863 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2864 ut_params->ibuf, data_pad_len);
2865 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2866 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2868 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2870 debug_hexdump(stdout, "digest:",
2871 sym_op->auth.digest.data,
2874 sym_op->auth.data.length = auth_len;
2875 sym_op->auth.data.offset = auth_offset;
2881 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2882 enum rte_crypto_auth_operation op)
2884 struct crypto_testsuite_params *ts_params = &testsuite_params;
2885 struct crypto_unittest_params *ut_params = &unittest_params;
2887 const uint8_t *auth_tag = tdata->digest.data;
2888 const unsigned int auth_tag_len = tdata->digest.len;
2889 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2890 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2892 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2893 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2894 const uint8_t *auth_iv = tdata->auth_iv.data;
2895 const uint8_t auth_iv_len = tdata->auth_iv.len;
2896 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2897 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2899 /* Generate Crypto op data structure */
2900 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2901 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2902 TEST_ASSERT_NOT_NULL(ut_params->op,
2903 "Failed to allocate pktmbuf offload");
2904 /* Set crypto operation data parameters */
2905 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2907 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2909 /* set crypto operation source mbuf */
2910 sym_op->m_src = ut_params->ibuf;
2913 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2914 ut_params->ibuf, auth_tag_len);
2916 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2917 "no room to append auth tag");
2918 ut_params->digest = sym_op->auth.digest.data;
2919 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2920 ut_params->ibuf, data_pad_len);
2921 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2922 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2924 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2926 debug_hexdump(stdout, "digest:",
2927 sym_op->auth.digest.data,
2930 /* Copy cipher and auth IVs at the end of the crypto operation */
2931 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2933 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2934 iv_ptr += cipher_iv_len;
2935 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2937 sym_op->cipher.data.length = cipher_len;
2938 sym_op->cipher.data.offset = 0;
2939 sym_op->auth.data.length = auth_len;
2940 sym_op->auth.data.offset = 0;
2946 create_zuc_cipher_hash_generate_operation(
2947 const struct wireless_test_data *tdata)
2949 return create_wireless_cipher_hash_operation(tdata,
2950 RTE_CRYPTO_AUTH_OP_GENERATE);
2954 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2955 const unsigned auth_tag_len,
2956 const uint8_t *auth_iv, uint8_t auth_iv_len,
2957 unsigned data_pad_len,
2958 enum rte_crypto_auth_operation op,
2959 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2960 const unsigned cipher_len, const unsigned cipher_offset,
2961 const unsigned auth_len, const unsigned auth_offset)
2963 struct crypto_testsuite_params *ts_params = &testsuite_params;
2964 struct crypto_unittest_params *ut_params = &unittest_params;
2966 /* Generate Crypto op data structure */
2967 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2968 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2969 TEST_ASSERT_NOT_NULL(ut_params->op,
2970 "Failed to allocate pktmbuf offload");
2971 /* Set crypto operation data parameters */
2972 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2974 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2976 /* set crypto operation source mbuf */
2977 sym_op->m_src = ut_params->ibuf;
2980 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2981 ut_params->ibuf, auth_tag_len);
2983 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2984 "no room to append auth tag");
2985 ut_params->digest = sym_op->auth.digest.data;
2986 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2987 ut_params->ibuf, data_pad_len);
2988 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2989 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2991 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2993 debug_hexdump(stdout, "digest:",
2994 sym_op->auth.digest.data,
2997 /* Copy cipher and auth IVs at the end of the crypto operation */
2998 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3000 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3001 iv_ptr += cipher_iv_len;
3002 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3004 sym_op->cipher.data.length = cipher_len;
3005 sym_op->cipher.data.offset = cipher_offset;
3006 sym_op->auth.data.length = auth_len;
3007 sym_op->auth.data.offset = auth_offset;
3013 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
3014 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3015 const uint8_t *auth_iv, uint8_t auth_iv_len,
3016 unsigned int data_pad_len,
3017 unsigned int cipher_len, unsigned int cipher_offset,
3018 unsigned int auth_len, unsigned int auth_offset,
3019 uint8_t op_mode, uint8_t do_sgl)
3021 struct crypto_testsuite_params *ts_params = &testsuite_params;
3022 struct crypto_unittest_params *ut_params = &unittest_params;
3024 /* Generate Crypto op data structure */
3025 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3026 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3027 TEST_ASSERT_NOT_NULL(ut_params->op,
3028 "Failed to allocate pktmbuf offload");
3030 /* Set crypto operation data parameters */
3031 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3033 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3035 /* set crypto operation mbufs */
3036 sym_op->m_src = ut_params->ibuf;
3037 if (op_mode == OUT_OF_PLACE)
3038 sym_op->m_dst = ut_params->obuf;
3042 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3043 (op_mode == IN_PLACE ?
3044 ut_params->ibuf : ut_params->obuf),
3045 uint8_t *, data_pad_len);
3046 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3047 (op_mode == IN_PLACE ?
3048 ut_params->ibuf : ut_params->obuf),
3050 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3052 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3053 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3054 sym_op->m_src : sym_op->m_dst);
3055 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3056 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3057 sgl_buf = sgl_buf->next;
3059 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3060 uint8_t *, remaining_off);
3061 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3063 memset(sym_op->auth.digest.data, 0, remaining_off);
3064 while (sgl_buf->next != NULL) {
3065 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3066 0, rte_pktmbuf_data_len(sgl_buf));
3067 sgl_buf = sgl_buf->next;
3071 /* Copy cipher and auth IVs at the end of the crypto operation */
3072 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3073 ut_params->op, uint8_t *, IV_OFFSET);
3075 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3076 iv_ptr += cipher_iv_len;
3077 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3079 sym_op->cipher.data.length = cipher_len;
3080 sym_op->cipher.data.offset = cipher_offset;
3082 sym_op->auth.data.length = auth_len;
3083 sym_op->auth.data.offset = auth_offset;
3089 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3091 struct crypto_testsuite_params *ts_params = &testsuite_params;
3092 struct crypto_unittest_params *ut_params = &unittest_params;
3095 unsigned plaintext_pad_len;
3096 unsigned plaintext_len;
3099 /* Create SNOW 3G session */
3100 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3101 tdata->key.data, tdata->key.len,
3102 tdata->auth_iv.len, tdata->digest.len,
3103 RTE_CRYPTO_AUTH_OP_GENERATE,
3104 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3108 /* alloc mbuf and set payload */
3109 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3112 rte_pktmbuf_tailroom(ut_params->ibuf));
3114 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3115 /* Append data which is padded to a multiple of */
3116 /* the algorithms block size */
3117 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3118 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3120 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3122 /* Create SNOW 3G operation */
3123 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3124 tdata->auth_iv.data, tdata->auth_iv.len,
3125 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3126 tdata->validAuthLenInBits.len,
3131 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3133 ut_params->obuf = ut_params->op->sym->m_src;
3134 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3135 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3136 + plaintext_pad_len;
3139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3142 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3143 "SNOW 3G Generated auth tag not as expected");
3149 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3151 struct crypto_testsuite_params *ts_params = &testsuite_params;
3152 struct crypto_unittest_params *ut_params = &unittest_params;
3155 unsigned plaintext_pad_len;
3156 unsigned plaintext_len;
3159 /* Create SNOW 3G session */
3160 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3161 tdata->key.data, tdata->key.len,
3162 tdata->auth_iv.len, tdata->digest.len,
3163 RTE_CRYPTO_AUTH_OP_VERIFY,
3164 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3167 /* alloc mbuf and set payload */
3168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3170 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3171 rte_pktmbuf_tailroom(ut_params->ibuf));
3173 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3174 /* Append data which is padded to a multiple of */
3175 /* the algorithms block size */
3176 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3177 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3179 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3181 /* Create SNOW 3G operation */
3182 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3184 tdata->auth_iv.data, tdata->auth_iv.len,
3186 RTE_CRYPTO_AUTH_OP_VERIFY,
3187 tdata->validAuthLenInBits.len,
3192 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3194 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3195 ut_params->obuf = ut_params->op->sym->m_src;
3196 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3197 + plaintext_pad_len;
3200 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3209 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3211 struct crypto_testsuite_params *ts_params = &testsuite_params;
3212 struct crypto_unittest_params *ut_params = &unittest_params;
3215 unsigned plaintext_pad_len;
3216 unsigned plaintext_len;
3219 /* Create KASUMI session */
3220 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3221 tdata->key.data, tdata->key.len,
3222 0, tdata->digest.len,
3223 RTE_CRYPTO_AUTH_OP_GENERATE,
3224 RTE_CRYPTO_AUTH_KASUMI_F9);
3228 /* alloc mbuf and set payload */
3229 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3231 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3232 rte_pktmbuf_tailroom(ut_params->ibuf));
3234 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3235 /* Append data which is padded to a multiple of */
3236 /* the algorithms block size */
3237 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3238 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3240 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3242 /* Create KASUMI operation */
3243 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3245 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3246 tdata->plaintext.len,
3251 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3253 ut_params->obuf = ut_params->op->sym->m_src;
3254 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3255 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3256 + plaintext_pad_len;
3259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3262 DIGEST_BYTE_LENGTH_KASUMI_F9,
3263 "KASUMI Generated auth tag not as expected");
3269 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3271 struct crypto_testsuite_params *ts_params = &testsuite_params;
3272 struct crypto_unittest_params *ut_params = &unittest_params;
3275 unsigned plaintext_pad_len;
3276 unsigned plaintext_len;
3279 /* Create KASUMI session */
3280 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3281 tdata->key.data, tdata->key.len,
3282 0, tdata->digest.len,
3283 RTE_CRYPTO_AUTH_OP_VERIFY,
3284 RTE_CRYPTO_AUTH_KASUMI_F9);
3287 /* alloc mbuf and set payload */
3288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3290 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3291 rte_pktmbuf_tailroom(ut_params->ibuf));
3293 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3294 /* Append data which is padded to a multiple */
3295 /* of the algorithms block size */
3296 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3297 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3299 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3301 /* Create KASUMI operation */
3302 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3306 RTE_CRYPTO_AUTH_OP_VERIFY,
3307 tdata->plaintext.len,
3312 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3314 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3315 ut_params->obuf = ut_params->op->sym->m_src;
3316 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3317 + plaintext_pad_len;
3320 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3329 test_snow3g_hash_generate_test_case_1(void)
3331 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3335 test_snow3g_hash_generate_test_case_2(void)
3337 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3341 test_snow3g_hash_generate_test_case_3(void)
3343 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3347 test_snow3g_hash_generate_test_case_4(void)
3349 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3353 test_snow3g_hash_generate_test_case_5(void)
3355 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3359 test_snow3g_hash_generate_test_case_6(void)
3361 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3365 test_snow3g_hash_verify_test_case_1(void)
3367 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3372 test_snow3g_hash_verify_test_case_2(void)
3374 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3378 test_snow3g_hash_verify_test_case_3(void)
3380 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3384 test_snow3g_hash_verify_test_case_4(void)
3386 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3390 test_snow3g_hash_verify_test_case_5(void)
3392 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3396 test_snow3g_hash_verify_test_case_6(void)
3398 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3402 test_kasumi_hash_generate_test_case_1(void)
3404 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3408 test_kasumi_hash_generate_test_case_2(void)
3410 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3414 test_kasumi_hash_generate_test_case_3(void)
3416 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3420 test_kasumi_hash_generate_test_case_4(void)
3422 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3426 test_kasumi_hash_generate_test_case_5(void)
3428 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3432 test_kasumi_hash_generate_test_case_6(void)
3434 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3438 test_kasumi_hash_verify_test_case_1(void)
3440 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3444 test_kasumi_hash_verify_test_case_2(void)
3446 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3450 test_kasumi_hash_verify_test_case_3(void)
3452 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3456 test_kasumi_hash_verify_test_case_4(void)
3458 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3462 test_kasumi_hash_verify_test_case_5(void)
3464 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3468 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3470 struct crypto_testsuite_params *ts_params = &testsuite_params;
3471 struct crypto_unittest_params *ut_params = &unittest_params;
3474 uint8_t *plaintext, *ciphertext;
3475 unsigned plaintext_pad_len;
3476 unsigned plaintext_len;
3478 /* Create KASUMI session */
3479 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3480 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3481 RTE_CRYPTO_CIPHER_KASUMI_F8,
3482 tdata->key.data, tdata->key.len,
3483 tdata->cipher_iv.len);
3487 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3489 /* Clear mbuf payload */
3490 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3491 rte_pktmbuf_tailroom(ut_params->ibuf));
3493 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3494 /* Append data which is padded to a multiple */
3495 /* of the algorithms block size */
3496 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3497 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3499 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3501 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3503 /* Create KASUMI operation */
3504 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3505 tdata->cipher_iv.len,
3506 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3507 tdata->validCipherOffsetInBits.len);
3511 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3513 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3515 ut_params->obuf = ut_params->op->sym->m_dst;
3516 if (ut_params->obuf)
3517 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3519 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3521 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3523 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3524 (tdata->validCipherOffsetInBits.len >> 3);
3526 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3528 reference_ciphertext,
3529 tdata->validCipherLenInBits.len,
3530 "KASUMI Ciphertext data not as expected");
3535 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3537 struct crypto_testsuite_params *ts_params = &testsuite_params;
3538 struct crypto_unittest_params *ut_params = &unittest_params;
3542 unsigned int plaintext_pad_len;
3543 unsigned int plaintext_len;
3545 uint8_t buffer[10000];
3546 const uint8_t *ciphertext;
3548 struct rte_cryptodev_info dev_info;
3550 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3552 uint64_t feat_flags = dev_info.feature_flags;
3554 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3555 printf("Device doesn't support in-place scatter-gather. "
3560 /* Create KASUMI session */
3561 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3562 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3563 RTE_CRYPTO_CIPHER_KASUMI_F8,
3564 tdata->key.data, tdata->key.len,
3565 tdata->cipher_iv.len);
3569 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3572 /* Append data which is padded to a multiple */
3573 /* of the algorithms block size */
3574 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3576 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3577 plaintext_pad_len, 10, 0);
3579 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3581 /* Create KASUMI operation */
3582 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3583 tdata->cipher_iv.len,
3584 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3585 tdata->validCipherOffsetInBits.len);
3589 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3591 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3593 ut_params->obuf = ut_params->op->sym->m_dst;
3595 if (ut_params->obuf)
3596 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3597 plaintext_len, buffer);
3599 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3600 tdata->validCipherOffsetInBits.len >> 3,
3601 plaintext_len, buffer);
3604 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3606 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3607 (tdata->validCipherOffsetInBits.len >> 3);
3609 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3611 reference_ciphertext,
3612 tdata->validCipherLenInBits.len,
3613 "KASUMI Ciphertext data not as expected");
3618 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3620 struct crypto_testsuite_params *ts_params = &testsuite_params;
3621 struct crypto_unittest_params *ut_params = &unittest_params;
3624 uint8_t *plaintext, *ciphertext;
3625 unsigned plaintext_pad_len;
3626 unsigned plaintext_len;
3628 /* Create KASUMI session */
3629 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3630 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3631 RTE_CRYPTO_CIPHER_KASUMI_F8,
3632 tdata->key.data, tdata->key.len,
3633 tdata->cipher_iv.len);
3637 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3638 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3640 /* Clear mbuf payload */
3641 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3642 rte_pktmbuf_tailroom(ut_params->ibuf));
3644 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3645 /* Append data which is padded to a multiple */
3646 /* of the algorithms block size */
3647 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3648 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3650 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3651 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3653 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3655 /* Create KASUMI operation */
3656 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3657 tdata->cipher_iv.len,
3658 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3659 tdata->validCipherOffsetInBits.len);
3663 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3665 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3667 ut_params->obuf = ut_params->op->sym->m_dst;
3668 if (ut_params->obuf)
3669 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3671 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3673 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3675 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3676 (tdata->validCipherOffsetInBits.len >> 3);
3678 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3680 reference_ciphertext,
3681 tdata->validCipherLenInBits.len,
3682 "KASUMI Ciphertext data not as expected");
3687 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3689 struct crypto_testsuite_params *ts_params = &testsuite_params;
3690 struct crypto_unittest_params *ut_params = &unittest_params;
3693 unsigned int plaintext_pad_len;
3694 unsigned int plaintext_len;
3696 const uint8_t *ciphertext;
3697 uint8_t buffer[2048];
3699 struct rte_cryptodev_info dev_info;
3701 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3703 uint64_t feat_flags = dev_info.feature_flags;
3704 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3705 printf("Device doesn't support out-of-place scatter-gather "
3706 "in both input and output mbufs. "
3711 /* Create KASUMI session */
3712 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3713 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3714 RTE_CRYPTO_CIPHER_KASUMI_F8,
3715 tdata->key.data, tdata->key.len,
3716 tdata->cipher_iv.len);
3720 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3721 /* Append data which is padded to a multiple */
3722 /* of the algorithms block size */
3723 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3725 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3726 plaintext_pad_len, 10, 0);
3727 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3728 plaintext_pad_len, 3, 0);
3730 /* Append data which is padded to a multiple */
3731 /* of the algorithms block size */
3732 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3734 /* Create KASUMI operation */
3735 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3736 tdata->cipher_iv.len,
3737 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3738 tdata->validCipherOffsetInBits.len);
3742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3744 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3746 ut_params->obuf = ut_params->op->sym->m_dst;
3747 if (ut_params->obuf)
3748 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3749 plaintext_pad_len, buffer);
3751 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3752 tdata->validCipherOffsetInBits.len >> 3,
3753 plaintext_pad_len, buffer);
3755 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3756 (tdata->validCipherOffsetInBits.len >> 3);
3758 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3760 reference_ciphertext,
3761 tdata->validCipherLenInBits.len,
3762 "KASUMI Ciphertext data not as expected");
3768 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3770 struct crypto_testsuite_params *ts_params = &testsuite_params;
3771 struct crypto_unittest_params *ut_params = &unittest_params;
3774 uint8_t *ciphertext, *plaintext;
3775 unsigned ciphertext_pad_len;
3776 unsigned ciphertext_len;
3778 /* Create KASUMI session */
3779 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3780 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3781 RTE_CRYPTO_CIPHER_KASUMI_F8,
3782 tdata->key.data, tdata->key.len,
3783 tdata->cipher_iv.len);
3787 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3788 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3790 /* Clear mbuf payload */
3791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3792 rte_pktmbuf_tailroom(ut_params->ibuf));
3794 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3795 /* Append data which is padded to a multiple */
3796 /* of the algorithms block size */
3797 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3798 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3799 ciphertext_pad_len);
3800 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3801 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3803 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3805 /* Create KASUMI operation */
3806 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3807 tdata->cipher_iv.len,
3808 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3809 tdata->validCipherOffsetInBits.len);
3813 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3815 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3817 ut_params->obuf = ut_params->op->sym->m_dst;
3818 if (ut_params->obuf)
3819 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3821 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3823 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3825 const uint8_t *reference_plaintext = tdata->plaintext.data +
3826 (tdata->validCipherOffsetInBits.len >> 3);
3828 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3830 reference_plaintext,
3831 tdata->validCipherLenInBits.len,
3832 "KASUMI Plaintext data not as expected");
3837 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3839 struct crypto_testsuite_params *ts_params = &testsuite_params;
3840 struct crypto_unittest_params *ut_params = &unittest_params;
3843 uint8_t *ciphertext, *plaintext;
3844 unsigned ciphertext_pad_len;
3845 unsigned ciphertext_len;
3847 /* Create KASUMI session */
3848 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3849 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3850 RTE_CRYPTO_CIPHER_KASUMI_F8,
3851 tdata->key.data, tdata->key.len,
3852 tdata->cipher_iv.len);
3856 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3858 /* Clear mbuf payload */
3859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3860 rte_pktmbuf_tailroom(ut_params->ibuf));
3862 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3863 /* Append data which is padded to a multiple */
3864 /* of the algorithms block size */
3865 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3866 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3867 ciphertext_pad_len);
3868 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3870 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3872 /* Create KASUMI operation */
3873 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3874 tdata->cipher_iv.len,
3875 tdata->ciphertext.len,
3876 tdata->validCipherOffsetInBits.len);
3880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3884 ut_params->obuf = ut_params->op->sym->m_dst;
3885 if (ut_params->obuf)
3886 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3888 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3890 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3892 const uint8_t *reference_plaintext = tdata->plaintext.data +
3893 (tdata->validCipherOffsetInBits.len >> 3);
3895 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3897 reference_plaintext,
3898 tdata->validCipherLenInBits.len,
3899 "KASUMI Plaintext data not as expected");
3904 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3906 struct crypto_testsuite_params *ts_params = &testsuite_params;
3907 struct crypto_unittest_params *ut_params = &unittest_params;
3910 uint8_t *plaintext, *ciphertext;
3911 unsigned plaintext_pad_len;
3912 unsigned plaintext_len;
3914 /* Create SNOW 3G session */
3915 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3916 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3917 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3918 tdata->key.data, tdata->key.len,
3919 tdata->cipher_iv.len);
3923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3925 /* Clear mbuf payload */
3926 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3927 rte_pktmbuf_tailroom(ut_params->ibuf));
3929 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3930 /* Append data which is padded to a multiple of */
3931 /* the algorithms block size */
3932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3933 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3935 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3937 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3939 /* Create SNOW 3G operation */
3940 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3941 tdata->cipher_iv.len,
3942 tdata->validCipherLenInBits.len,
3947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3951 ut_params->obuf = ut_params->op->sym->m_dst;
3952 if (ut_params->obuf)
3953 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3955 ciphertext = plaintext;
3957 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3960 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3962 tdata->ciphertext.data,
3963 tdata->validDataLenInBits.len,
3964 "SNOW 3G Ciphertext data not as expected");
3970 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3972 struct crypto_testsuite_params *ts_params = &testsuite_params;
3973 struct crypto_unittest_params *ut_params = &unittest_params;
3974 uint8_t *plaintext, *ciphertext;
3977 unsigned plaintext_pad_len;
3978 unsigned plaintext_len;
3980 /* Create SNOW 3G session */
3981 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3982 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3983 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3984 tdata->key.data, tdata->key.len,
3985 tdata->cipher_iv.len);
3989 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3990 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3992 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3993 "Failed to allocate input buffer in mempool");
3994 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3995 "Failed to allocate output buffer in mempool");
3997 /* Clear mbuf payload */
3998 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3999 rte_pktmbuf_tailroom(ut_params->ibuf));
4001 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4002 /* Append data which is padded to a multiple of */
4003 /* the algorithms block size */
4004 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4005 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4007 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4008 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4010 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4012 /* Create SNOW 3G operation */
4013 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4014 tdata->cipher_iv.len,
4015 tdata->validCipherLenInBits.len,
4020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4024 ut_params->obuf = ut_params->op->sym->m_dst;
4025 if (ut_params->obuf)
4026 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4028 ciphertext = plaintext;
4030 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4035 tdata->ciphertext.data,
4036 tdata->validDataLenInBits.len,
4037 "SNOW 3G Ciphertext data not as expected");
4042 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4044 struct crypto_testsuite_params *ts_params = &testsuite_params;
4045 struct crypto_unittest_params *ut_params = &unittest_params;
4048 unsigned int plaintext_pad_len;
4049 unsigned int plaintext_len;
4050 uint8_t buffer[10000];
4051 const uint8_t *ciphertext;
4053 struct rte_cryptodev_info dev_info;
4055 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4057 uint64_t feat_flags = dev_info.feature_flags;
4059 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4060 printf("Device doesn't support out-of-place scatter-gather "
4061 "in both input and output mbufs. "
4066 /* Create SNOW 3G session */
4067 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4068 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4069 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4070 tdata->key.data, tdata->key.len,
4071 tdata->cipher_iv.len);
4075 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4076 /* Append data which is padded to a multiple of */
4077 /* the algorithms block size */
4078 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4080 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4081 plaintext_pad_len, 10, 0);
4082 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4083 plaintext_pad_len, 3, 0);
4085 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4086 "Failed to allocate input buffer in mempool");
4087 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4088 "Failed to allocate output buffer in mempool");
4090 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4092 /* Create SNOW 3G operation */
4093 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4094 tdata->cipher_iv.len,
4095 tdata->validCipherLenInBits.len,
4100 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4102 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4104 ut_params->obuf = ut_params->op->sym->m_dst;
4105 if (ut_params->obuf)
4106 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4107 plaintext_len, buffer);
4109 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4110 plaintext_len, buffer);
4112 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4115 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4117 tdata->ciphertext.data,
4118 tdata->validDataLenInBits.len,
4119 "SNOW 3G Ciphertext data not as expected");
4124 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4126 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4128 uint8_t curr_byte, prev_byte;
4129 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4130 uint8_t lower_byte_mask = (1 << offset) - 1;
4133 prev_byte = buffer[0];
4134 buffer[0] >>= offset;
4136 for (i = 1; i < length_in_bytes; i++) {
4137 curr_byte = buffer[i];
4138 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4139 (curr_byte >> offset);
4140 prev_byte = curr_byte;
4145 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4147 struct crypto_testsuite_params *ts_params = &testsuite_params;
4148 struct crypto_unittest_params *ut_params = &unittest_params;
4149 uint8_t *plaintext, *ciphertext;
4151 uint32_t plaintext_len;
4152 uint32_t plaintext_pad_len;
4153 uint8_t extra_offset = 4;
4154 uint8_t *expected_ciphertext_shifted;
4156 /* Create SNOW 3G session */
4157 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4158 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4159 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4160 tdata->key.data, tdata->key.len,
4161 tdata->cipher_iv.len);
4165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4166 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4168 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4169 "Failed to allocate input buffer in mempool");
4170 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4171 "Failed to allocate output buffer in mempool");
4173 /* Clear mbuf payload */
4174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4175 rte_pktmbuf_tailroom(ut_params->ibuf));
4177 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4179 * Append data which is padded to a
4180 * multiple of the algorithms block size
4182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4184 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4187 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4189 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4190 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4192 #ifdef RTE_APP_TEST_DEBUG
4193 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4195 /* Create SNOW 3G operation */
4196 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4197 tdata->cipher_iv.len,
4198 tdata->validCipherLenInBits.len,
4203 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4207 ut_params->obuf = ut_params->op->sym->m_dst;
4208 if (ut_params->obuf)
4209 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4211 ciphertext = plaintext;
4213 #ifdef RTE_APP_TEST_DEBUG
4214 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4217 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4219 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4220 "failed to reserve memory for ciphertext shifted\n");
4222 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4223 ceil_byte_length(tdata->ciphertext.len));
4224 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4229 expected_ciphertext_shifted,
4230 tdata->validDataLenInBits.len,
4232 "SNOW 3G Ciphertext data not as expected");
4236 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4238 struct crypto_testsuite_params *ts_params = &testsuite_params;
4239 struct crypto_unittest_params *ut_params = &unittest_params;
4243 uint8_t *plaintext, *ciphertext;
4244 unsigned ciphertext_pad_len;
4245 unsigned ciphertext_len;
4247 /* Create SNOW 3G session */
4248 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4249 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4250 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4251 tdata->key.data, tdata->key.len,
4252 tdata->cipher_iv.len);
4256 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4258 /* Clear mbuf payload */
4259 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4260 rte_pktmbuf_tailroom(ut_params->ibuf));
4262 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4263 /* Append data which is padded to a multiple of */
4264 /* the algorithms block size */
4265 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4266 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4267 ciphertext_pad_len);
4268 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4270 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4272 /* Create SNOW 3G operation */
4273 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4274 tdata->cipher_iv.len,
4275 tdata->validCipherLenInBits.len,
4276 tdata->cipher.offset_bits);
4280 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4282 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4283 ut_params->obuf = ut_params->op->sym->m_dst;
4284 if (ut_params->obuf)
4285 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4287 plaintext = ciphertext;
4289 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4293 tdata->plaintext.data,
4294 tdata->validDataLenInBits.len,
4295 "SNOW 3G Plaintext data not as expected");
4299 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4301 struct crypto_testsuite_params *ts_params = &testsuite_params;
4302 struct crypto_unittest_params *ut_params = &unittest_params;
4306 uint8_t *plaintext, *ciphertext;
4307 unsigned ciphertext_pad_len;
4308 unsigned ciphertext_len;
4310 /* Create SNOW 3G session */
4311 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4312 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4313 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4314 tdata->key.data, tdata->key.len,
4315 tdata->cipher_iv.len);
4319 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4320 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4322 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4323 "Failed to allocate input buffer");
4324 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4325 "Failed to allocate output buffer");
4327 /* Clear mbuf payload */
4328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4329 rte_pktmbuf_tailroom(ut_params->ibuf));
4331 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4332 rte_pktmbuf_tailroom(ut_params->obuf));
4334 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4335 /* Append data which is padded to a multiple of */
4336 /* the algorithms block size */
4337 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4338 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4339 ciphertext_pad_len);
4340 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4343 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4345 /* Create SNOW 3G operation */
4346 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4347 tdata->cipher_iv.len,
4348 tdata->validCipherLenInBits.len,
4353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4356 ut_params->obuf = ut_params->op->sym->m_dst;
4357 if (ut_params->obuf)
4358 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4360 plaintext = ciphertext;
4362 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4365 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4366 tdata->plaintext.data,
4367 tdata->validDataLenInBits.len,
4368 "SNOW 3G Plaintext data not as expected");
4373 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4375 struct crypto_testsuite_params *ts_params = &testsuite_params;
4376 struct crypto_unittest_params *ut_params = &unittest_params;
4380 uint8_t *plaintext, *ciphertext;
4381 unsigned int plaintext_pad_len;
4382 unsigned int plaintext_len;
4384 struct rte_cryptodev_sym_capability_idx cap_idx;
4386 /* Check if device supports ZUC EEA3 */
4387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4390 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4394 /* Check if device supports ZUC EIA3 */
4395 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4396 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4398 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4402 /* Create ZUC session */
4403 retval = create_zuc_cipher_auth_encrypt_generate_session(
4404 ts_params->valid_devs[0],
4408 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4410 /* clear mbuf payload */
4411 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4412 rte_pktmbuf_tailroom(ut_params->ibuf));
4414 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4415 /* Append data which is padded to a multiple of */
4416 /* the algorithms block size */
4417 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4418 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4420 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4422 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4424 /* Create ZUC operation */
4425 retval = create_zuc_cipher_hash_generate_operation(tdata);
4429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4432 ut_params->obuf = ut_params->op->sym->m_src;
4433 if (ut_params->obuf)
4434 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4436 ciphertext = plaintext;
4438 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4442 tdata->ciphertext.data,
4443 tdata->validDataLenInBits.len,
4444 "ZUC Ciphertext data not as expected");
4446 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4447 + plaintext_pad_len;
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4454 "ZUC Generated auth tag not as expected");
4459 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4461 struct crypto_testsuite_params *ts_params = &testsuite_params;
4462 struct crypto_unittest_params *ut_params = &unittest_params;
4466 uint8_t *plaintext, *ciphertext;
4467 unsigned plaintext_pad_len;
4468 unsigned plaintext_len;
4470 /* Create SNOW 3G session */
4471 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4472 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4473 RTE_CRYPTO_AUTH_OP_GENERATE,
4474 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4475 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4476 tdata->key.data, tdata->key.len,
4477 tdata->auth_iv.len, tdata->digest.len,
4478 tdata->cipher_iv.len);
4481 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4483 /* clear mbuf payload */
4484 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4485 rte_pktmbuf_tailroom(ut_params->ibuf));
4487 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4488 /* Append data which is padded to a multiple of */
4489 /* the algorithms block size */
4490 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4491 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4493 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4495 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4497 /* Create SNOW 3G operation */
4498 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4499 tdata->digest.len, tdata->auth_iv.data,
4501 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4502 tdata->cipher_iv.data, tdata->cipher_iv.len,
4503 tdata->validCipherLenInBits.len,
4505 tdata->validAuthLenInBits.len,
4511 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4513 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4514 ut_params->obuf = ut_params->op->sym->m_src;
4515 if (ut_params->obuf)
4516 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4518 ciphertext = plaintext;
4520 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4524 tdata->ciphertext.data,
4525 tdata->validDataLenInBits.len,
4526 "SNOW 3G Ciphertext data not as expected");
4528 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4529 + plaintext_pad_len;
4532 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4535 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4536 "SNOW 3G Generated auth tag not as expected");
4541 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4542 uint8_t op_mode, uint8_t verify)
4544 struct crypto_testsuite_params *ts_params = &testsuite_params;
4545 struct crypto_unittest_params *ut_params = &unittest_params;
4549 uint8_t *plaintext = NULL, *ciphertext = NULL;
4550 unsigned int plaintext_pad_len;
4551 unsigned int plaintext_len;
4552 unsigned int ciphertext_pad_len;
4553 unsigned int ciphertext_len;
4555 struct rte_cryptodev_info dev_info;
4557 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4559 uint64_t feat_flags = dev_info.feature_flags;
4561 if (op_mode == OUT_OF_PLACE) {
4562 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4563 printf("Device doesn't support digest encrypted.\n");
4568 /* Create SNOW 3G session */
4569 retval = create_wireless_algo_auth_cipher_session(
4570 ts_params->valid_devs[0],
4571 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4572 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4573 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4574 : RTE_CRYPTO_AUTH_OP_GENERATE),
4575 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4576 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4577 tdata->key.data, tdata->key.len,
4578 tdata->auth_iv.len, tdata->digest.len,
4579 tdata->cipher_iv.len);
4584 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4585 if (op_mode == OUT_OF_PLACE)
4586 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4588 /* clear mbuf payload */
4589 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4590 rte_pktmbuf_tailroom(ut_params->ibuf));
4591 if (op_mode == OUT_OF_PLACE)
4592 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4593 rte_pktmbuf_tailroom(ut_params->obuf));
4595 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4596 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4597 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4598 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4601 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4602 ciphertext_pad_len);
4603 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4604 if (op_mode == OUT_OF_PLACE)
4605 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4606 debug_hexdump(stdout, "ciphertext:", ciphertext,
4609 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4611 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4612 if (op_mode == OUT_OF_PLACE)
4613 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4614 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4617 /* Create SNOW 3G operation */
4618 retval = create_wireless_algo_auth_cipher_operation(
4620 tdata->cipher_iv.data, tdata->cipher_iv.len,
4621 tdata->auth_iv.data, tdata->auth_iv.len,
4622 (tdata->digest.offset_bytes == 0 ?
4623 (verify ? ciphertext_pad_len : plaintext_pad_len)
4624 : tdata->digest.offset_bytes),
4625 tdata->validCipherLenInBits.len,
4626 tdata->cipher.offset_bits,
4627 tdata->validAuthLenInBits.len,
4628 tdata->auth.offset_bits,
4634 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4637 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4639 ut_params->obuf = (op_mode == IN_PLACE ?
4640 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4643 if (ut_params->obuf)
4644 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4647 plaintext = ciphertext +
4648 (tdata->cipher.offset_bits >> 3);
4650 debug_hexdump(stdout, "plaintext:", plaintext,
4651 (tdata->plaintext.len >> 3) - tdata->digest.len);
4652 debug_hexdump(stdout, "plaintext expected:",
4653 tdata->plaintext.data,
4654 (tdata->plaintext.len >> 3) - tdata->digest.len);
4656 if (ut_params->obuf)
4657 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4660 ciphertext = plaintext;
4662 debug_hexdump(stdout, "ciphertext:", ciphertext,
4664 debug_hexdump(stdout, "ciphertext expected:",
4665 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4667 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4668 + (tdata->digest.offset_bytes == 0 ?
4669 plaintext_pad_len : tdata->digest.offset_bytes);
4671 debug_hexdump(stdout, "digest:", ut_params->digest,
4673 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4679 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4681 tdata->plaintext.data,
4682 tdata->plaintext.len >> 3,
4683 "SNOW 3G Plaintext data not as expected");
4685 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4687 tdata->ciphertext.data,
4688 tdata->validDataLenInBits.len,
4689 "SNOW 3G Ciphertext data not as expected");
4691 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4694 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4695 "SNOW 3G Generated auth tag not as expected");
4701 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4702 uint8_t op_mode, uint8_t verify)
4704 struct crypto_testsuite_params *ts_params = &testsuite_params;
4705 struct crypto_unittest_params *ut_params = &unittest_params;
4709 const uint8_t *plaintext = NULL;
4710 const uint8_t *ciphertext = NULL;
4711 const uint8_t *digest = NULL;
4712 unsigned int plaintext_pad_len;
4713 unsigned int plaintext_len;
4714 unsigned int ciphertext_pad_len;
4715 unsigned int ciphertext_len;
4716 uint8_t buffer[10000];
4717 uint8_t digest_buffer[10000];
4719 struct rte_cryptodev_info dev_info;
4721 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4723 uint64_t feat_flags = dev_info.feature_flags;
4725 if (op_mode == IN_PLACE) {
4726 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4727 printf("Device doesn't support in-place scatter-gather "
4728 "in both input and output mbufs.\n");
4732 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4733 printf("Device doesn't support out-of-place scatter-gather "
4734 "in both input and output mbufs.\n");
4737 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4738 printf("Device doesn't support digest encrypted.\n");
4743 /* Create SNOW 3G session */
4744 retval = create_wireless_algo_auth_cipher_session(
4745 ts_params->valid_devs[0],
4746 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4747 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4748 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4749 : RTE_CRYPTO_AUTH_OP_GENERATE),
4750 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4751 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4752 tdata->key.data, tdata->key.len,
4753 tdata->auth_iv.len, tdata->digest.len,
4754 tdata->cipher_iv.len);
4759 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4760 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4761 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4762 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4764 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4765 plaintext_pad_len, 15, 0);
4766 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4767 "Failed to allocate input buffer in mempool");
4769 if (op_mode == OUT_OF_PLACE) {
4770 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4771 plaintext_pad_len, 15, 0);
4772 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4773 "Failed to allocate output buffer in mempool");
4777 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4778 tdata->ciphertext.data);
4779 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4780 ciphertext_len, buffer);
4781 debug_hexdump(stdout, "ciphertext:", ciphertext,
4784 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4785 tdata->plaintext.data);
4786 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4787 plaintext_len, buffer);
4788 debug_hexdump(stdout, "plaintext:", plaintext,
4791 memset(buffer, 0, sizeof(buffer));
4793 /* Create SNOW 3G operation */
4794 retval = create_wireless_algo_auth_cipher_operation(
4796 tdata->cipher_iv.data, tdata->cipher_iv.len,
4797 tdata->auth_iv.data, tdata->auth_iv.len,
4798 (tdata->digest.offset_bytes == 0 ?
4799 (verify ? ciphertext_pad_len : plaintext_pad_len)
4800 : tdata->digest.offset_bytes),
4801 tdata->validCipherLenInBits.len,
4802 tdata->cipher.offset_bits,
4803 tdata->validAuthLenInBits.len,
4804 tdata->auth.offset_bits,
4810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4813 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4815 ut_params->obuf = (op_mode == IN_PLACE ?
4816 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4819 if (ut_params->obuf)
4820 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4821 plaintext_len, buffer);
4823 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4824 plaintext_len, buffer);
4826 debug_hexdump(stdout, "plaintext:", plaintext,
4827 (tdata->plaintext.len >> 3) - tdata->digest.len);
4828 debug_hexdump(stdout, "plaintext expected:",
4829 tdata->plaintext.data,
4830 (tdata->plaintext.len >> 3) - tdata->digest.len);
4832 if (ut_params->obuf)
4833 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4834 ciphertext_len, buffer);
4836 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4837 ciphertext_len, buffer);
4839 debug_hexdump(stdout, "ciphertext:", ciphertext,
4841 debug_hexdump(stdout, "ciphertext expected:",
4842 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4844 if (ut_params->obuf)
4845 digest = rte_pktmbuf_read(ut_params->obuf,
4846 (tdata->digest.offset_bytes == 0 ?
4847 plaintext_pad_len : tdata->digest.offset_bytes),
4848 tdata->digest.len, digest_buffer);
4850 digest = rte_pktmbuf_read(ut_params->ibuf,
4851 (tdata->digest.offset_bytes == 0 ?
4852 plaintext_pad_len : tdata->digest.offset_bytes),
4853 tdata->digest.len, digest_buffer);
4855 debug_hexdump(stdout, "digest:", digest,
4857 debug_hexdump(stdout, "digest expected:",
4858 tdata->digest.data, tdata->digest.len);
4863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4865 tdata->plaintext.data,
4866 tdata->plaintext.len >> 3,
4867 "SNOW 3G Plaintext data not as expected");
4869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4871 tdata->ciphertext.data,
4872 tdata->validDataLenInBits.len,
4873 "SNOW 3G Ciphertext data not as expected");
4875 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4878 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4879 "SNOW 3G Generated auth tag not as expected");
4885 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4886 uint8_t op_mode, uint8_t verify)
4888 struct crypto_testsuite_params *ts_params = &testsuite_params;
4889 struct crypto_unittest_params *ut_params = &unittest_params;
4893 uint8_t *plaintext = NULL, *ciphertext = NULL;
4894 unsigned int plaintext_pad_len;
4895 unsigned int plaintext_len;
4896 unsigned int ciphertext_pad_len;
4897 unsigned int ciphertext_len;
4899 struct rte_cryptodev_info dev_info;
4901 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4903 uint64_t feat_flags = dev_info.feature_flags;
4905 if (op_mode == OUT_OF_PLACE) {
4906 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4907 printf("Device doesn't support digest encrypted.\n");
4912 /* Create KASUMI session */
4913 retval = create_wireless_algo_auth_cipher_session(
4914 ts_params->valid_devs[0],
4915 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4916 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4917 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4918 : RTE_CRYPTO_AUTH_OP_GENERATE),
4919 RTE_CRYPTO_AUTH_KASUMI_F9,
4920 RTE_CRYPTO_CIPHER_KASUMI_F8,
4921 tdata->key.data, tdata->key.len,
4922 0, tdata->digest.len,
4923 tdata->cipher_iv.len);
4928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4929 if (op_mode == OUT_OF_PLACE)
4930 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4932 /* clear mbuf payload */
4933 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4934 rte_pktmbuf_tailroom(ut_params->ibuf));
4935 if (op_mode == OUT_OF_PLACE)
4936 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4937 rte_pktmbuf_tailroom(ut_params->obuf));
4939 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4940 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4941 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4942 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4945 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4946 ciphertext_pad_len);
4947 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4948 if (op_mode == OUT_OF_PLACE)
4949 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4950 debug_hexdump(stdout, "ciphertext:", ciphertext,
4953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4955 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4956 if (op_mode == OUT_OF_PLACE)
4957 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4958 debug_hexdump(stdout, "plaintext:", plaintext,
4962 /* Create KASUMI operation */
4963 retval = create_wireless_algo_auth_cipher_operation(
4965 tdata->cipher_iv.data, tdata->cipher_iv.len,
4967 (tdata->digest.offset_bytes == 0 ?
4968 (verify ? ciphertext_pad_len : plaintext_pad_len)
4969 : tdata->digest.offset_bytes),
4970 tdata->validCipherLenInBits.len,
4971 tdata->validCipherOffsetInBits.len,
4972 tdata->validAuthLenInBits.len,
4979 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4982 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4984 ut_params->obuf = (op_mode == IN_PLACE ?
4985 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4989 if (ut_params->obuf)
4990 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4993 plaintext = ciphertext;
4995 debug_hexdump(stdout, "plaintext:", plaintext,
4996 (tdata->plaintext.len >> 3) - tdata->digest.len);
4997 debug_hexdump(stdout, "plaintext expected:",
4998 tdata->plaintext.data,
4999 (tdata->plaintext.len >> 3) - tdata->digest.len);
5001 if (ut_params->obuf)
5002 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5005 ciphertext = plaintext;
5007 debug_hexdump(stdout, "ciphertext:", ciphertext,
5009 debug_hexdump(stdout, "ciphertext expected:",
5010 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5012 ut_params->digest = rte_pktmbuf_mtod(
5013 ut_params->obuf, uint8_t *) +
5014 (tdata->digest.offset_bytes == 0 ?
5015 plaintext_pad_len : tdata->digest.offset_bytes);
5017 debug_hexdump(stdout, "digest:", ut_params->digest,
5019 debug_hexdump(stdout, "digest expected:",
5020 tdata->digest.data, tdata->digest.len);
5025 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5027 tdata->plaintext.data,
5028 tdata->plaintext.len >> 3,
5029 "KASUMI Plaintext data not as expected");
5031 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5033 tdata->ciphertext.data,
5034 tdata->ciphertext.len >> 3,
5035 "KASUMI Ciphertext data not as expected");
5037 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5040 DIGEST_BYTE_LENGTH_KASUMI_F9,
5041 "KASUMI Generated auth tag not as expected");
5047 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5048 uint8_t op_mode, uint8_t verify)
5050 struct crypto_testsuite_params *ts_params = &testsuite_params;
5051 struct crypto_unittest_params *ut_params = &unittest_params;
5055 const uint8_t *plaintext = NULL;
5056 const uint8_t *ciphertext = NULL;
5057 const uint8_t *digest = NULL;
5058 unsigned int plaintext_pad_len;
5059 unsigned int plaintext_len;
5060 unsigned int ciphertext_pad_len;
5061 unsigned int ciphertext_len;
5062 uint8_t buffer[10000];
5063 uint8_t digest_buffer[10000];
5065 struct rte_cryptodev_info dev_info;
5067 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5069 uint64_t feat_flags = dev_info.feature_flags;
5071 if (op_mode == IN_PLACE) {
5072 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5073 printf("Device doesn't support in-place scatter-gather "
5074 "in both input and output mbufs.\n");
5078 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5079 printf("Device doesn't support out-of-place scatter-gather "
5080 "in both input and output mbufs.\n");
5083 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5084 printf("Device doesn't support digest encrypted.\n");
5089 /* Create KASUMI session */
5090 retval = create_wireless_algo_auth_cipher_session(
5091 ts_params->valid_devs[0],
5092 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5093 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5094 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5095 : RTE_CRYPTO_AUTH_OP_GENERATE),
5096 RTE_CRYPTO_AUTH_KASUMI_F9,
5097 RTE_CRYPTO_CIPHER_KASUMI_F8,
5098 tdata->key.data, tdata->key.len,
5099 0, tdata->digest.len,
5100 tdata->cipher_iv.len);
5105 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5106 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5107 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5110 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5111 plaintext_pad_len, 15, 0);
5112 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5113 "Failed to allocate input buffer in mempool");
5115 if (op_mode == OUT_OF_PLACE) {
5116 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5117 plaintext_pad_len, 15, 0);
5118 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5119 "Failed to allocate output buffer in mempool");
5123 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5124 tdata->ciphertext.data);
5125 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5126 ciphertext_len, buffer);
5127 debug_hexdump(stdout, "ciphertext:", ciphertext,
5130 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5131 tdata->plaintext.data);
5132 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5133 plaintext_len, buffer);
5134 debug_hexdump(stdout, "plaintext:", plaintext,
5137 memset(buffer, 0, sizeof(buffer));
5139 /* Create KASUMI operation */
5140 retval = create_wireless_algo_auth_cipher_operation(
5142 tdata->cipher_iv.data, tdata->cipher_iv.len,
5144 (tdata->digest.offset_bytes == 0 ?
5145 (verify ? ciphertext_pad_len : plaintext_pad_len)
5146 : tdata->digest.offset_bytes),
5147 tdata->validCipherLenInBits.len,
5148 tdata->validCipherOffsetInBits.len,
5149 tdata->validAuthLenInBits.len,
5156 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5159 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5161 ut_params->obuf = (op_mode == IN_PLACE ?
5162 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5165 if (ut_params->obuf)
5166 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5167 plaintext_len, buffer);
5169 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5170 plaintext_len, buffer);
5172 debug_hexdump(stdout, "plaintext:", plaintext,
5173 (tdata->plaintext.len >> 3) - tdata->digest.len);
5174 debug_hexdump(stdout, "plaintext expected:",
5175 tdata->plaintext.data,
5176 (tdata->plaintext.len >> 3) - tdata->digest.len);
5178 if (ut_params->obuf)
5179 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5180 ciphertext_len, buffer);
5182 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5183 ciphertext_len, buffer);
5185 debug_hexdump(stdout, "ciphertext:", ciphertext,
5187 debug_hexdump(stdout, "ciphertext expected:",
5188 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5190 if (ut_params->obuf)
5191 digest = rte_pktmbuf_read(ut_params->obuf,
5192 (tdata->digest.offset_bytes == 0 ?
5193 plaintext_pad_len : tdata->digest.offset_bytes),
5194 tdata->digest.len, digest_buffer);
5196 digest = rte_pktmbuf_read(ut_params->ibuf,
5197 (tdata->digest.offset_bytes == 0 ?
5198 plaintext_pad_len : tdata->digest.offset_bytes),
5199 tdata->digest.len, digest_buffer);
5201 debug_hexdump(stdout, "digest:", digest,
5203 debug_hexdump(stdout, "digest expected:",
5204 tdata->digest.data, tdata->digest.len);
5209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5211 tdata->plaintext.data,
5212 tdata->plaintext.len >> 3,
5213 "KASUMI Plaintext data not as expected");
5215 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5217 tdata->ciphertext.data,
5218 tdata->validDataLenInBits.len,
5219 "KASUMI Ciphertext data not as expected");
5221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5224 DIGEST_BYTE_LENGTH_KASUMI_F9,
5225 "KASUMI Generated auth tag not as expected");
5231 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5233 struct crypto_testsuite_params *ts_params = &testsuite_params;
5234 struct crypto_unittest_params *ut_params = &unittest_params;
5238 uint8_t *plaintext, *ciphertext;
5239 unsigned plaintext_pad_len;
5240 unsigned plaintext_len;
5242 /* Create KASUMI session */
5243 retval = create_wireless_algo_cipher_auth_session(
5244 ts_params->valid_devs[0],
5245 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5246 RTE_CRYPTO_AUTH_OP_GENERATE,
5247 RTE_CRYPTO_AUTH_KASUMI_F9,
5248 RTE_CRYPTO_CIPHER_KASUMI_F8,
5249 tdata->key.data, tdata->key.len,
5250 0, tdata->digest.len,
5251 tdata->cipher_iv.len);
5255 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5257 /* clear mbuf payload */
5258 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5259 rte_pktmbuf_tailroom(ut_params->ibuf));
5261 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5262 /* Append data which is padded to a multiple of */
5263 /* the algorithms block size */
5264 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5265 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5267 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5269 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5271 /* Create KASUMI operation */
5272 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5273 tdata->digest.len, NULL, 0,
5274 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5275 tdata->cipher_iv.data, tdata->cipher_iv.len,
5276 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5277 tdata->validCipherOffsetInBits.len,
5278 tdata->validAuthLenInBits.len,
5284 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5286 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5288 if (ut_params->op->sym->m_dst)
5289 ut_params->obuf = ut_params->op->sym->m_dst;
5291 ut_params->obuf = ut_params->op->sym->m_src;
5293 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5294 tdata->validCipherOffsetInBits.len >> 3);
5296 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5297 + plaintext_pad_len;
5299 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5300 (tdata->validCipherOffsetInBits.len >> 3);
5302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5304 reference_ciphertext,
5305 tdata->validCipherLenInBits.len,
5306 "KASUMI Ciphertext data not as expected");
5309 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5312 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5313 "KASUMI Generated auth tag not as expected");
5318 test_zuc_encryption(const struct wireless_test_data *tdata)
5320 struct crypto_testsuite_params *ts_params = &testsuite_params;
5321 struct crypto_unittest_params *ut_params = &unittest_params;
5324 uint8_t *plaintext, *ciphertext;
5325 unsigned plaintext_pad_len;
5326 unsigned plaintext_len;
5328 struct rte_cryptodev_sym_capability_idx cap_idx;
5330 /* Check if device supports ZUC EEA3 */
5331 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5332 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5334 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5338 /* Create ZUC session */
5339 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5340 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5341 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5342 tdata->key.data, tdata->key.len,
5343 tdata->cipher_iv.len);
5347 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5349 /* Clear mbuf payload */
5350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5351 rte_pktmbuf_tailroom(ut_params->ibuf));
5353 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5354 /* Append data which is padded to a multiple */
5355 /* of the algorithms block size */
5356 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5359 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5361 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5363 /* Create ZUC operation */
5364 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5365 tdata->cipher_iv.len,
5366 tdata->plaintext.len,
5371 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5373 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5375 ut_params->obuf = ut_params->op->sym->m_dst;
5376 if (ut_params->obuf)
5377 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5379 ciphertext = plaintext;
5381 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5384 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5386 tdata->ciphertext.data,
5387 tdata->validCipherLenInBits.len,
5388 "ZUC Ciphertext data not as expected");
5393 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5395 struct crypto_testsuite_params *ts_params = &testsuite_params;
5396 struct crypto_unittest_params *ut_params = &unittest_params;
5400 unsigned int plaintext_pad_len;
5401 unsigned int plaintext_len;
5402 const uint8_t *ciphertext;
5403 uint8_t ciphertext_buffer[2048];
5404 struct rte_cryptodev_info dev_info;
5406 struct rte_cryptodev_sym_capability_idx cap_idx;
5408 /* Check if device supports ZUC EEA3 */
5409 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5410 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5412 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5416 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5418 uint64_t feat_flags = dev_info.feature_flags;
5420 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5421 printf("Device doesn't support in-place scatter-gather. "
5426 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5428 /* Append data which is padded to a multiple */
5429 /* of the algorithms block size */
5430 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5432 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5433 plaintext_pad_len, 10, 0);
5435 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5436 tdata->plaintext.data);
5438 /* Create ZUC session */
5439 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5440 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5441 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5442 tdata->key.data, tdata->key.len,
5443 tdata->cipher_iv.len);
5447 /* Clear mbuf payload */
5449 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5451 /* Create ZUC operation */
5452 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5453 tdata->cipher_iv.len, tdata->plaintext.len,
5458 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5462 ut_params->obuf = ut_params->op->sym->m_dst;
5463 if (ut_params->obuf)
5464 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5465 0, plaintext_len, ciphertext_buffer);
5467 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5468 0, plaintext_len, ciphertext_buffer);
5471 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5474 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5476 tdata->ciphertext.data,
5477 tdata->validCipherLenInBits.len,
5478 "ZUC Ciphertext data not as expected");
5484 test_zuc_authentication(const struct wireless_test_data *tdata)
5486 struct crypto_testsuite_params *ts_params = &testsuite_params;
5487 struct crypto_unittest_params *ut_params = &unittest_params;
5490 unsigned plaintext_pad_len;
5491 unsigned plaintext_len;
5494 struct rte_cryptodev_sym_capability_idx cap_idx;
5496 /* Check if device supports ZUC EIA3 */
5497 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5498 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5500 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5504 /* Create ZUC session */
5505 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5506 tdata->key.data, tdata->key.len,
5507 tdata->auth_iv.len, tdata->digest.len,
5508 RTE_CRYPTO_AUTH_OP_GENERATE,
5509 RTE_CRYPTO_AUTH_ZUC_EIA3);
5513 /* alloc mbuf and set payload */
5514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5517 rte_pktmbuf_tailroom(ut_params->ibuf));
5519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5520 /* Append data which is padded to a multiple of */
5521 /* the algorithms block size */
5522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5523 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5527 /* Create ZUC operation */
5528 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5529 tdata->auth_iv.data, tdata->auth_iv.len,
5530 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5531 tdata->validAuthLenInBits.len,
5536 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5538 ut_params->obuf = ut_params->op->sym->m_src;
5539 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5540 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5541 + plaintext_pad_len;
5544 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5547 DIGEST_BYTE_LENGTH_KASUMI_F9,
5548 "ZUC Generated auth tag not as expected");
5554 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5555 uint8_t op_mode, uint8_t verify)
5557 struct crypto_testsuite_params *ts_params = &testsuite_params;
5558 struct crypto_unittest_params *ut_params = &unittest_params;
5562 uint8_t *plaintext = NULL, *ciphertext = NULL;
5563 unsigned int plaintext_pad_len;
5564 unsigned int plaintext_len;
5565 unsigned int ciphertext_pad_len;
5566 unsigned int ciphertext_len;
5568 struct rte_cryptodev_info dev_info;
5569 struct rte_cryptodev_sym_capability_idx cap_idx;
5571 /* Check if device supports ZUC EIA3 */
5572 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5573 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5575 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5579 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5581 uint64_t feat_flags = dev_info.feature_flags;
5583 if (op_mode == OUT_OF_PLACE) {
5584 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5585 printf("Device doesn't support digest encrypted.\n");
5590 /* Create ZUC session */
5591 retval = create_wireless_algo_auth_cipher_session(
5592 ts_params->valid_devs[0],
5593 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5594 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5595 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5596 : RTE_CRYPTO_AUTH_OP_GENERATE),
5597 RTE_CRYPTO_AUTH_ZUC_EIA3,
5598 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5599 tdata->key.data, tdata->key.len,
5600 tdata->auth_iv.len, tdata->digest.len,
5601 tdata->cipher_iv.len);
5606 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5607 if (op_mode == OUT_OF_PLACE)
5608 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5610 /* clear mbuf payload */
5611 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5612 rte_pktmbuf_tailroom(ut_params->ibuf));
5613 if (op_mode == OUT_OF_PLACE)
5614 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5615 rte_pktmbuf_tailroom(ut_params->obuf));
5617 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5618 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5619 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5620 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5623 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5624 ciphertext_pad_len);
5625 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5626 if (op_mode == OUT_OF_PLACE)
5627 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5628 debug_hexdump(stdout, "ciphertext:", ciphertext,
5631 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5633 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5634 if (op_mode == OUT_OF_PLACE)
5635 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5636 debug_hexdump(stdout, "plaintext:", plaintext,
5640 /* Create ZUC operation */
5641 retval = create_wireless_algo_auth_cipher_operation(
5643 tdata->cipher_iv.data, tdata->cipher_iv.len,
5644 tdata->auth_iv.data, tdata->auth_iv.len,
5645 (tdata->digest.offset_bytes == 0 ?
5646 (verify ? ciphertext_pad_len : plaintext_pad_len)
5647 : tdata->digest.offset_bytes),
5648 tdata->validCipherLenInBits.len,
5649 tdata->validCipherOffsetInBits.len,
5650 tdata->validAuthLenInBits.len,
5657 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5660 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5662 ut_params->obuf = (op_mode == IN_PLACE ?
5663 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5667 if (ut_params->obuf)
5668 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5671 plaintext = ciphertext;
5673 debug_hexdump(stdout, "plaintext:", plaintext,
5674 (tdata->plaintext.len >> 3) - tdata->digest.len);
5675 debug_hexdump(stdout, "plaintext expected:",
5676 tdata->plaintext.data,
5677 (tdata->plaintext.len >> 3) - tdata->digest.len);
5679 if (ut_params->obuf)
5680 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5683 ciphertext = plaintext;
5685 debug_hexdump(stdout, "ciphertext:", ciphertext,
5687 debug_hexdump(stdout, "ciphertext expected:",
5688 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5690 ut_params->digest = rte_pktmbuf_mtod(
5691 ut_params->obuf, uint8_t *) +
5692 (tdata->digest.offset_bytes == 0 ?
5693 plaintext_pad_len : tdata->digest.offset_bytes);
5695 debug_hexdump(stdout, "digest:", ut_params->digest,
5697 debug_hexdump(stdout, "digest expected:",
5698 tdata->digest.data, tdata->digest.len);
5703 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5705 tdata->plaintext.data,
5706 tdata->plaintext.len >> 3,
5707 "ZUC Plaintext data not as expected");
5709 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5711 tdata->ciphertext.data,
5712 tdata->ciphertext.len >> 3,
5713 "ZUC Ciphertext data not as expected");
5715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5718 DIGEST_BYTE_LENGTH_KASUMI_F9,
5719 "ZUC Generated auth tag not as expected");
5725 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5726 uint8_t op_mode, uint8_t verify)
5728 struct crypto_testsuite_params *ts_params = &testsuite_params;
5729 struct crypto_unittest_params *ut_params = &unittest_params;
5733 const uint8_t *plaintext = NULL;
5734 const uint8_t *ciphertext = NULL;
5735 const uint8_t *digest = NULL;
5736 unsigned int plaintext_pad_len;
5737 unsigned int plaintext_len;
5738 unsigned int ciphertext_pad_len;
5739 unsigned int ciphertext_len;
5740 uint8_t buffer[10000];
5741 uint8_t digest_buffer[10000];
5743 struct rte_cryptodev_info dev_info;
5744 struct rte_cryptodev_sym_capability_idx cap_idx;
5746 /* Check if device supports ZUC EIA3 */
5747 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5748 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5750 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5754 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5756 uint64_t feat_flags = dev_info.feature_flags;
5758 if (op_mode == IN_PLACE) {
5759 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5760 printf("Device doesn't support in-place scatter-gather "
5761 "in both input and output mbufs.\n");
5765 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5766 printf("Device doesn't support out-of-place scatter-gather "
5767 "in both input and output mbufs.\n");
5770 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5771 printf("Device doesn't support digest encrypted.\n");
5776 /* Create ZUC session */
5777 retval = create_wireless_algo_auth_cipher_session(
5778 ts_params->valid_devs[0],
5779 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5780 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5781 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5782 : RTE_CRYPTO_AUTH_OP_GENERATE),
5783 RTE_CRYPTO_AUTH_ZUC_EIA3,
5784 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5785 tdata->key.data, tdata->key.len,
5786 tdata->auth_iv.len, tdata->digest.len,
5787 tdata->cipher_iv.len);
5792 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5793 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5794 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5795 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5797 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5798 plaintext_pad_len, 15, 0);
5799 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5800 "Failed to allocate input buffer in mempool");
5802 if (op_mode == OUT_OF_PLACE) {
5803 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5804 plaintext_pad_len, 15, 0);
5805 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5806 "Failed to allocate output buffer in mempool");
5810 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5811 tdata->ciphertext.data);
5812 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5813 ciphertext_len, buffer);
5814 debug_hexdump(stdout, "ciphertext:", ciphertext,
5817 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5818 tdata->plaintext.data);
5819 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5820 plaintext_len, buffer);
5821 debug_hexdump(stdout, "plaintext:", plaintext,
5824 memset(buffer, 0, sizeof(buffer));
5826 /* Create ZUC operation */
5827 retval = create_wireless_algo_auth_cipher_operation(
5829 tdata->cipher_iv.data, tdata->cipher_iv.len,
5831 (tdata->digest.offset_bytes == 0 ?
5832 (verify ? ciphertext_pad_len : plaintext_pad_len)
5833 : tdata->digest.offset_bytes),
5834 tdata->validCipherLenInBits.len,
5835 tdata->validCipherOffsetInBits.len,
5836 tdata->validAuthLenInBits.len,
5843 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5846 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5848 ut_params->obuf = (op_mode == IN_PLACE ?
5849 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5852 if (ut_params->obuf)
5853 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5854 plaintext_len, buffer);
5856 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5857 plaintext_len, buffer);
5859 debug_hexdump(stdout, "plaintext:", plaintext,
5860 (tdata->plaintext.len >> 3) - tdata->digest.len);
5861 debug_hexdump(stdout, "plaintext expected:",
5862 tdata->plaintext.data,
5863 (tdata->plaintext.len >> 3) - tdata->digest.len);
5865 if (ut_params->obuf)
5866 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5867 ciphertext_len, buffer);
5869 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5870 ciphertext_len, buffer);
5872 debug_hexdump(stdout, "ciphertext:", ciphertext,
5874 debug_hexdump(stdout, "ciphertext expected:",
5875 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5877 if (ut_params->obuf)
5878 digest = rte_pktmbuf_read(ut_params->obuf,
5879 (tdata->digest.offset_bytes == 0 ?
5880 plaintext_pad_len : tdata->digest.offset_bytes),
5881 tdata->digest.len, digest_buffer);
5883 digest = rte_pktmbuf_read(ut_params->ibuf,
5884 (tdata->digest.offset_bytes == 0 ?
5885 plaintext_pad_len : tdata->digest.offset_bytes),
5886 tdata->digest.len, digest_buffer);
5888 debug_hexdump(stdout, "digest:", digest,
5890 debug_hexdump(stdout, "digest expected:",
5891 tdata->digest.data, tdata->digest.len);
5896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5898 tdata->plaintext.data,
5899 tdata->plaintext.len >> 3,
5900 "ZUC Plaintext data not as expected");
5902 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5904 tdata->ciphertext.data,
5905 tdata->validDataLenInBits.len,
5906 "ZUC Ciphertext data not as expected");
5908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5911 DIGEST_BYTE_LENGTH_KASUMI_F9,
5912 "ZUC Generated auth tag not as expected");
5918 test_kasumi_encryption_test_case_1(void)
5920 return test_kasumi_encryption(&kasumi_test_case_1);
5924 test_kasumi_encryption_test_case_1_sgl(void)
5926 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5930 test_kasumi_encryption_test_case_1_oop(void)
5932 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5936 test_kasumi_encryption_test_case_1_oop_sgl(void)
5938 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5942 test_kasumi_encryption_test_case_2(void)
5944 return test_kasumi_encryption(&kasumi_test_case_2);
5948 test_kasumi_encryption_test_case_3(void)
5950 return test_kasumi_encryption(&kasumi_test_case_3);
5954 test_kasumi_encryption_test_case_4(void)
5956 return test_kasumi_encryption(&kasumi_test_case_4);
5960 test_kasumi_encryption_test_case_5(void)
5962 return test_kasumi_encryption(&kasumi_test_case_5);
5966 test_kasumi_decryption_test_case_1(void)
5968 return test_kasumi_decryption(&kasumi_test_case_1);
5972 test_kasumi_decryption_test_case_1_oop(void)
5974 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5978 test_kasumi_decryption_test_case_2(void)
5980 return test_kasumi_decryption(&kasumi_test_case_2);
5984 test_kasumi_decryption_test_case_3(void)
5986 return test_kasumi_decryption(&kasumi_test_case_3);
5990 test_kasumi_decryption_test_case_4(void)
5992 return test_kasumi_decryption(&kasumi_test_case_4);
5996 test_kasumi_decryption_test_case_5(void)
5998 return test_kasumi_decryption(&kasumi_test_case_5);
6001 test_snow3g_encryption_test_case_1(void)
6003 return test_snow3g_encryption(&snow3g_test_case_1);
6007 test_snow3g_encryption_test_case_1_oop(void)
6009 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6013 test_snow3g_encryption_test_case_1_oop_sgl(void)
6015 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6020 test_snow3g_encryption_test_case_1_offset_oop(void)
6022 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6026 test_snow3g_encryption_test_case_2(void)
6028 return test_snow3g_encryption(&snow3g_test_case_2);
6032 test_snow3g_encryption_test_case_3(void)
6034 return test_snow3g_encryption(&snow3g_test_case_3);
6038 test_snow3g_encryption_test_case_4(void)
6040 return test_snow3g_encryption(&snow3g_test_case_4);
6044 test_snow3g_encryption_test_case_5(void)
6046 return test_snow3g_encryption(&snow3g_test_case_5);
6050 test_snow3g_decryption_test_case_1(void)
6052 return test_snow3g_decryption(&snow3g_test_case_1);
6056 test_snow3g_decryption_test_case_1_oop(void)
6058 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6062 test_snow3g_decryption_test_case_2(void)
6064 return test_snow3g_decryption(&snow3g_test_case_2);
6068 test_snow3g_decryption_test_case_3(void)
6070 return test_snow3g_decryption(&snow3g_test_case_3);
6074 test_snow3g_decryption_test_case_4(void)
6076 return test_snow3g_decryption(&snow3g_test_case_4);
6080 test_snow3g_decryption_test_case_5(void)
6082 return test_snow3g_decryption(&snow3g_test_case_5);
6086 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6087 * Pattern digest from snow3g_test_data must be allocated as
6088 * 4 last bytes in plaintext.
6091 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6092 struct snow3g_hash_test_data *output)
6094 if ((pattern != NULL) && (output != NULL)) {
6095 output->key.len = pattern->key.len;
6097 memcpy(output->key.data,
6098 pattern->key.data, pattern->key.len);
6100 output->auth_iv.len = pattern->auth_iv.len;
6102 memcpy(output->auth_iv.data,
6103 pattern->auth_iv.data, pattern->auth_iv.len);
6105 output->plaintext.len = pattern->plaintext.len;
6107 memcpy(output->plaintext.data,
6108 pattern->plaintext.data, pattern->plaintext.len >> 3);
6110 output->digest.len = pattern->digest.len;
6112 memcpy(output->digest.data,
6113 &pattern->plaintext.data[pattern->digest.offset_bytes],
6114 pattern->digest.len);
6116 output->validAuthLenInBits.len =
6117 pattern->validAuthLenInBits.len;
6122 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6125 test_snow3g_decryption_with_digest_test_case_1(void)
6127 struct snow3g_hash_test_data snow3g_hash_data;
6130 * Function prepare data for hash veryfication test case.
6131 * Digest is allocated in 4 last bytes in plaintext, pattern.
6133 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6135 return test_snow3g_decryption(&snow3g_test_case_7) &
6136 test_snow3g_authentication_verify(&snow3g_hash_data);
6140 test_snow3g_cipher_auth_test_case_1(void)
6142 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6146 test_snow3g_auth_cipher_test_case_1(void)
6148 return test_snow3g_auth_cipher(
6149 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6153 test_snow3g_auth_cipher_test_case_2(void)
6155 return test_snow3g_auth_cipher(
6156 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6160 test_snow3g_auth_cipher_test_case_2_oop(void)
6162 return test_snow3g_auth_cipher(
6163 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6167 test_snow3g_auth_cipher_part_digest_enc(void)
6169 return test_snow3g_auth_cipher(
6170 &snow3g_auth_cipher_partial_digest_encryption,
6175 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6177 return test_snow3g_auth_cipher(
6178 &snow3g_auth_cipher_partial_digest_encryption,
6183 test_snow3g_auth_cipher_test_case_3_sgl(void)
6185 return test_snow3g_auth_cipher_sgl(
6186 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6190 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6192 return test_snow3g_auth_cipher_sgl(
6193 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6197 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6199 return test_snow3g_auth_cipher_sgl(
6200 &snow3g_auth_cipher_partial_digest_encryption,
6205 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6207 return test_snow3g_auth_cipher_sgl(
6208 &snow3g_auth_cipher_partial_digest_encryption,
6213 test_snow3g_auth_cipher_verify_test_case_1(void)
6215 return test_snow3g_auth_cipher(
6216 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6220 test_snow3g_auth_cipher_verify_test_case_2(void)
6222 return test_snow3g_auth_cipher(
6223 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6227 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6229 return test_snow3g_auth_cipher(
6230 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6234 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6236 return test_snow3g_auth_cipher(
6237 &snow3g_auth_cipher_partial_digest_encryption,
6242 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6244 return test_snow3g_auth_cipher(
6245 &snow3g_auth_cipher_partial_digest_encryption,
6250 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6252 return test_snow3g_auth_cipher_sgl(
6253 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6257 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6259 return test_snow3g_auth_cipher_sgl(
6260 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6264 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6266 return test_snow3g_auth_cipher_sgl(
6267 &snow3g_auth_cipher_partial_digest_encryption,
6272 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6274 return test_snow3g_auth_cipher_sgl(
6275 &snow3g_auth_cipher_partial_digest_encryption,
6280 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6282 return test_snow3g_auth_cipher(
6283 &snow3g_test_case_7, IN_PLACE, 0);
6287 test_kasumi_auth_cipher_test_case_1(void)
6289 return test_kasumi_auth_cipher(
6290 &kasumi_test_case_3, IN_PLACE, 0);
6294 test_kasumi_auth_cipher_test_case_2(void)
6296 return test_kasumi_auth_cipher(
6297 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6301 test_kasumi_auth_cipher_test_case_2_oop(void)
6303 return test_kasumi_auth_cipher(
6304 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6308 test_kasumi_auth_cipher_test_case_2_sgl(void)
6310 return test_kasumi_auth_cipher_sgl(
6311 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6315 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6317 return test_kasumi_auth_cipher_sgl(
6318 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6322 test_kasumi_auth_cipher_verify_test_case_1(void)
6324 return test_kasumi_auth_cipher(
6325 &kasumi_test_case_3, IN_PLACE, 1);
6329 test_kasumi_auth_cipher_verify_test_case_2(void)
6331 return test_kasumi_auth_cipher(
6332 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6336 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6338 return test_kasumi_auth_cipher(
6339 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6343 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6345 return test_kasumi_auth_cipher_sgl(
6346 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6350 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6352 return test_kasumi_auth_cipher_sgl(
6353 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6357 test_kasumi_cipher_auth_test_case_1(void)
6359 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6363 test_zuc_encryption_test_case_1(void)
6365 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6369 test_zuc_encryption_test_case_2(void)
6371 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6375 test_zuc_encryption_test_case_3(void)
6377 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6381 test_zuc_encryption_test_case_4(void)
6383 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6387 test_zuc_encryption_test_case_5(void)
6389 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6393 test_zuc_encryption_test_case_6_sgl(void)
6395 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6399 test_zuc_hash_generate_test_case_1(void)
6401 return test_zuc_authentication(&zuc_test_case_auth_1b);
6405 test_zuc_hash_generate_test_case_2(void)
6407 return test_zuc_authentication(&zuc_test_case_auth_90b);
6411 test_zuc_hash_generate_test_case_3(void)
6413 return test_zuc_authentication(&zuc_test_case_auth_577b);
6417 test_zuc_hash_generate_test_case_4(void)
6419 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6423 test_zuc_hash_generate_test_case_5(void)
6425 return test_zuc_authentication(&zuc_test_auth_5670b);
6429 test_zuc_hash_generate_test_case_6(void)
6431 return test_zuc_authentication(&zuc_test_case_auth_128b);
6435 test_zuc_hash_generate_test_case_7(void)
6437 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6441 test_zuc_hash_generate_test_case_8(void)
6443 return test_zuc_authentication(&zuc_test_case_auth_584b);
6447 test_zuc_cipher_auth_test_case_1(void)
6449 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6453 test_zuc_cipher_auth_test_case_2(void)
6455 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6459 test_zuc_auth_cipher_test_case_1(void)
6461 return test_zuc_auth_cipher(
6462 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6466 test_zuc_auth_cipher_test_case_1_oop(void)
6468 return test_zuc_auth_cipher(
6469 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6473 test_zuc_auth_cipher_test_case_1_sgl(void)
6475 return test_zuc_auth_cipher_sgl(
6476 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6480 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6482 return test_zuc_auth_cipher_sgl(
6483 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6487 test_zuc_auth_cipher_verify_test_case_1(void)
6489 return test_zuc_auth_cipher(
6490 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6494 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6496 return test_zuc_auth_cipher(
6497 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6501 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6503 return test_zuc_auth_cipher_sgl(
6504 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6508 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6510 return test_zuc_auth_cipher_sgl(
6511 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6515 test_3DES_chain_qat_all(void)
6517 struct crypto_testsuite_params *ts_params = &testsuite_params;
6520 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6521 ts_params->op_mpool,
6522 ts_params->session_mpool, ts_params->session_priv_mpool,
6523 ts_params->valid_devs[0],
6524 rte_cryptodev_driver_id_get(
6525 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6526 BLKCIPHER_3DES_CHAIN_TYPE);
6528 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6530 return TEST_SUCCESS;
6534 test_DES_cipheronly_qat_all(void)
6536 struct crypto_testsuite_params *ts_params = &testsuite_params;
6539 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6540 ts_params->op_mpool,
6541 ts_params->session_mpool, ts_params->session_priv_mpool,
6542 ts_params->valid_devs[0],
6543 rte_cryptodev_driver_id_get(
6544 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6545 BLKCIPHER_DES_CIPHERONLY_TYPE);
6547 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6549 return TEST_SUCCESS;
6553 test_DES_cipheronly_openssl_all(void)
6555 struct crypto_testsuite_params *ts_params = &testsuite_params;
6558 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6559 ts_params->op_mpool,
6560 ts_params->session_mpool, ts_params->session_priv_mpool,
6561 ts_params->valid_devs[0],
6562 rte_cryptodev_driver_id_get(
6563 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6564 BLKCIPHER_DES_CIPHERONLY_TYPE);
6566 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6568 return TEST_SUCCESS;
6572 test_DES_docsis_openssl_all(void)
6574 struct crypto_testsuite_params *ts_params = &testsuite_params;
6577 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6578 ts_params->op_mpool,
6579 ts_params->session_mpool, ts_params->session_priv_mpool,
6580 ts_params->valid_devs[0],
6581 rte_cryptodev_driver_id_get(
6582 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6583 BLKCIPHER_DES_DOCSIS_TYPE);
6585 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6587 return TEST_SUCCESS;
6591 test_DES_cipheronly_mb_all(void)
6593 struct crypto_testsuite_params *ts_params = &testsuite_params;
6596 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6597 ts_params->op_mpool,
6598 ts_params->session_mpool, ts_params->session_priv_mpool,
6599 ts_params->valid_devs[0],
6600 rte_cryptodev_driver_id_get(
6601 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6602 BLKCIPHER_DES_CIPHERONLY_TYPE);
6604 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6606 return TEST_SUCCESS;
6609 test_3DES_cipheronly_mb_all(void)
6611 struct crypto_testsuite_params *ts_params = &testsuite_params;
6614 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6615 ts_params->op_mpool,
6616 ts_params->session_mpool, ts_params->session_priv_mpool,
6617 ts_params->valid_devs[0],
6618 rte_cryptodev_driver_id_get(
6619 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6620 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6622 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6624 return TEST_SUCCESS;
6628 test_DES_docsis_mb_all(void)
6630 struct crypto_testsuite_params *ts_params = &testsuite_params;
6633 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6634 ts_params->op_mpool,
6635 ts_params->session_mpool, ts_params->session_priv_mpool,
6636 ts_params->valid_devs[0],
6637 rte_cryptodev_driver_id_get(
6638 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6639 BLKCIPHER_DES_DOCSIS_TYPE);
6641 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6643 return TEST_SUCCESS;
6647 test_3DES_chain_caam_jr_all(void)
6649 struct crypto_testsuite_params *ts_params = &testsuite_params;
6652 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6653 ts_params->op_mpool,
6654 ts_params->session_mpool, ts_params->session_priv_mpool,
6655 ts_params->valid_devs[0],
6656 rte_cryptodev_driver_id_get(
6657 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6658 BLKCIPHER_3DES_CHAIN_TYPE);
6660 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6662 return TEST_SUCCESS;
6666 test_3DES_cipheronly_caam_jr_all(void)
6668 struct crypto_testsuite_params *ts_params = &testsuite_params;
6671 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6672 ts_params->op_mpool,
6673 ts_params->session_mpool, ts_params->session_priv_mpool,
6674 ts_params->valid_devs[0],
6675 rte_cryptodev_driver_id_get(
6676 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6677 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6679 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6681 return TEST_SUCCESS;
6685 test_3DES_chain_dpaa_sec_all(void)
6687 struct crypto_testsuite_params *ts_params = &testsuite_params;
6690 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6691 ts_params->op_mpool,
6692 ts_params->session_mpool, ts_params->session_priv_mpool,
6693 ts_params->valid_devs[0],
6694 rte_cryptodev_driver_id_get(
6695 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6696 BLKCIPHER_3DES_CHAIN_TYPE);
6698 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6700 return TEST_SUCCESS;
6704 test_3DES_cipheronly_dpaa_sec_all(void)
6706 struct crypto_testsuite_params *ts_params = &testsuite_params;
6709 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6710 ts_params->op_mpool,
6711 ts_params->session_mpool, ts_params->session_priv_mpool,
6712 ts_params->valid_devs[0],
6713 rte_cryptodev_driver_id_get(
6714 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6715 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6717 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6719 return TEST_SUCCESS;
6723 test_3DES_chain_dpaa2_sec_all(void)
6725 struct crypto_testsuite_params *ts_params = &testsuite_params;
6728 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6729 ts_params->op_mpool,
6730 ts_params->session_mpool, ts_params->session_priv_mpool,
6731 ts_params->valid_devs[0],
6732 rte_cryptodev_driver_id_get(
6733 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6734 BLKCIPHER_3DES_CHAIN_TYPE);
6736 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6738 return TEST_SUCCESS;
6742 test_3DES_cipheronly_dpaa2_sec_all(void)
6744 struct crypto_testsuite_params *ts_params = &testsuite_params;
6747 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6748 ts_params->op_mpool,
6749 ts_params->session_mpool, ts_params->session_priv_mpool,
6750 ts_params->valid_devs[0],
6751 rte_cryptodev_driver_id_get(
6752 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
6753 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6755 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6757 return TEST_SUCCESS;
6761 test_3DES_chain_ccp_all(void)
6763 struct crypto_testsuite_params *ts_params = &testsuite_params;
6766 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6767 ts_params->op_mpool,
6768 ts_params->session_mpool, ts_params->session_priv_mpool,
6769 ts_params->valid_devs[0],
6770 rte_cryptodev_driver_id_get(
6771 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6772 BLKCIPHER_3DES_CHAIN_TYPE);
6774 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6776 return TEST_SUCCESS;
6780 test_3DES_cipheronly_ccp_all(void)
6782 struct crypto_testsuite_params *ts_params = &testsuite_params;
6785 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6786 ts_params->op_mpool,
6787 ts_params->session_mpool, ts_params->session_priv_mpool,
6788 ts_params->valid_devs[0],
6789 rte_cryptodev_driver_id_get(
6790 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
6791 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6793 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6795 return TEST_SUCCESS;
6799 test_3DES_cipheronly_qat_all(void)
6801 struct crypto_testsuite_params *ts_params = &testsuite_params;
6804 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6805 ts_params->op_mpool,
6806 ts_params->session_mpool, ts_params->session_priv_mpool,
6807 ts_params->valid_devs[0],
6808 rte_cryptodev_driver_id_get(
6809 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6810 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6812 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6814 return TEST_SUCCESS;
6818 test_3DES_chain_openssl_all(void)
6820 struct crypto_testsuite_params *ts_params = &testsuite_params;
6823 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6824 ts_params->op_mpool,
6825 ts_params->session_mpool, ts_params->session_priv_mpool,
6826 ts_params->valid_devs[0],
6827 rte_cryptodev_driver_id_get(
6828 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6829 BLKCIPHER_3DES_CHAIN_TYPE);
6831 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6833 return TEST_SUCCESS;
6837 test_3DES_cipheronly_openssl_all(void)
6839 struct crypto_testsuite_params *ts_params = &testsuite_params;
6842 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6843 ts_params->op_mpool,
6844 ts_params->session_mpool, ts_params->session_priv_mpool,
6845 ts_params->valid_devs[0],
6846 rte_cryptodev_driver_id_get(
6847 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6848 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6850 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6852 return TEST_SUCCESS;
6855 /* ***** AEAD algorithm Tests ***** */
6858 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6859 enum rte_crypto_aead_operation op,
6860 const uint8_t *key, const uint8_t key_len,
6861 const uint16_t aad_len, const uint8_t auth_len,
6864 uint8_t aead_key[key_len];
6866 struct crypto_testsuite_params *ts_params = &testsuite_params;
6867 struct crypto_unittest_params *ut_params = &unittest_params;
6869 memcpy(aead_key, key, key_len);
6871 /* Setup AEAD Parameters */
6872 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6873 ut_params->aead_xform.next = NULL;
6874 ut_params->aead_xform.aead.algo = algo;
6875 ut_params->aead_xform.aead.op = op;
6876 ut_params->aead_xform.aead.key.data = aead_key;
6877 ut_params->aead_xform.aead.key.length = key_len;
6878 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6879 ut_params->aead_xform.aead.iv.length = iv_len;
6880 ut_params->aead_xform.aead.digest_length = auth_len;
6881 ut_params->aead_xform.aead.aad_length = aad_len;
6883 debug_hexdump(stdout, "key:", key, key_len);
6885 /* Create Crypto session*/
6886 ut_params->sess = rte_cryptodev_sym_session_create(
6887 ts_params->session_mpool);
6889 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6890 &ut_params->aead_xform,
6891 ts_params->session_priv_mpool);
6893 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6899 create_aead_xform(struct rte_crypto_op *op,
6900 enum rte_crypto_aead_algorithm algo,
6901 enum rte_crypto_aead_operation aead_op,
6902 uint8_t *key, const uint8_t key_len,
6903 const uint8_t aad_len, const uint8_t auth_len,
6906 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6907 "failed to allocate space for crypto transform");
6909 struct rte_crypto_sym_op *sym_op = op->sym;
6911 /* Setup AEAD Parameters */
6912 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6913 sym_op->xform->next = NULL;
6914 sym_op->xform->aead.algo = algo;
6915 sym_op->xform->aead.op = aead_op;
6916 sym_op->xform->aead.key.data = key;
6917 sym_op->xform->aead.key.length = key_len;
6918 sym_op->xform->aead.iv.offset = IV_OFFSET;
6919 sym_op->xform->aead.iv.length = iv_len;
6920 sym_op->xform->aead.digest_length = auth_len;
6921 sym_op->xform->aead.aad_length = aad_len;
6923 debug_hexdump(stdout, "key:", key, key_len);
6929 create_aead_operation(enum rte_crypto_aead_operation op,
6930 const struct aead_test_data *tdata)
6932 struct crypto_testsuite_params *ts_params = &testsuite_params;
6933 struct crypto_unittest_params *ut_params = &unittest_params;
6935 uint8_t *plaintext, *ciphertext;
6936 unsigned int aad_pad_len, plaintext_pad_len;
6938 /* Generate Crypto op data structure */
6939 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6940 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6941 TEST_ASSERT_NOT_NULL(ut_params->op,
6942 "Failed to allocate symmetric crypto operation struct");
6944 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6946 /* Append aad data */
6947 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6948 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6949 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6951 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6952 "no room to append aad");
6954 sym_op->aead.aad.phys_addr =
6955 rte_pktmbuf_iova(ut_params->ibuf);
6956 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6957 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6958 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6961 /* Append IV at the end of the crypto operation*/
6962 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6963 uint8_t *, IV_OFFSET);
6965 /* Copy IV 1 byte after the IV pointer, according to the API */
6966 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6967 debug_hexdump(stdout, "iv:", iv_ptr,
6970 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6971 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6973 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6974 "no room to append aad");
6976 sym_op->aead.aad.phys_addr =
6977 rte_pktmbuf_iova(ut_params->ibuf);
6978 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6979 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6982 /* Append IV at the end of the crypto operation*/
6983 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6984 uint8_t *, IV_OFFSET);
6986 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6987 debug_hexdump(stdout, "iv:", iv_ptr,
6991 /* Append plaintext/ciphertext */
6992 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6993 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6994 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6996 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6998 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6999 debug_hexdump(stdout, "plaintext:", plaintext,
7000 tdata->plaintext.len);
7002 if (ut_params->obuf) {
7003 ciphertext = (uint8_t *)rte_pktmbuf_append(
7005 plaintext_pad_len + aad_pad_len);
7006 TEST_ASSERT_NOT_NULL(ciphertext,
7007 "no room to append ciphertext");
7009 memset(ciphertext + aad_pad_len, 0,
7010 tdata->ciphertext.len);
7013 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7014 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7016 TEST_ASSERT_NOT_NULL(ciphertext,
7017 "no room to append ciphertext");
7019 memcpy(ciphertext, tdata->ciphertext.data,
7020 tdata->ciphertext.len);
7021 debug_hexdump(stdout, "ciphertext:", ciphertext,
7022 tdata->ciphertext.len);
7024 if (ut_params->obuf) {
7025 plaintext = (uint8_t *)rte_pktmbuf_append(
7027 plaintext_pad_len + aad_pad_len);
7028 TEST_ASSERT_NOT_NULL(plaintext,
7029 "no room to append plaintext");
7031 memset(plaintext + aad_pad_len, 0,
7032 tdata->plaintext.len);
7036 /* Append digest data */
7037 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7038 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7039 ut_params->obuf ? ut_params->obuf :
7041 tdata->auth_tag.len);
7042 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7043 "no room to append digest");
7044 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7045 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7046 ut_params->obuf ? ut_params->obuf :
7051 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7052 ut_params->ibuf, tdata->auth_tag.len);
7053 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7054 "no room to append digest");
7055 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7057 plaintext_pad_len + aad_pad_len);
7059 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7060 tdata->auth_tag.len);
7061 debug_hexdump(stdout, "digest:",
7062 sym_op->aead.digest.data,
7063 tdata->auth_tag.len);
7066 sym_op->aead.data.length = tdata->plaintext.len;
7067 sym_op->aead.data.offset = aad_pad_len;
7073 test_authenticated_encryption(const struct aead_test_data *tdata)
7075 struct crypto_testsuite_params *ts_params = &testsuite_params;
7076 struct crypto_unittest_params *ut_params = &unittest_params;
7079 uint8_t *ciphertext, *auth_tag;
7080 uint16_t plaintext_pad_len;
7083 /* Create AEAD session */
7084 retval = create_aead_session(ts_params->valid_devs[0],
7086 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7087 tdata->key.data, tdata->key.len,
7088 tdata->aad.len, tdata->auth_tag.len,
7093 if (tdata->aad.len > MBUF_SIZE) {
7094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7095 /* Populate full size of add data */
7096 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7097 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7099 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7101 /* clear mbuf payload */
7102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7103 rte_pktmbuf_tailroom(ut_params->ibuf));
7105 /* Create AEAD operation */
7106 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7110 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7112 ut_params->op->sym->m_src = ut_params->ibuf;
7114 /* Process crypto operation */
7115 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7116 ut_params->op), "failed to process sym crypto op");
7118 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7119 "crypto op processing failed");
7121 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7123 if (ut_params->op->sym->m_dst) {
7124 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7126 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7127 uint8_t *, plaintext_pad_len);
7129 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7131 ut_params->op->sym->cipher.data.offset);
7132 auth_tag = ciphertext + plaintext_pad_len;
7135 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7136 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7141 tdata->ciphertext.data,
7142 tdata->ciphertext.len,
7143 "Ciphertext data not as expected");
7145 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7147 tdata->auth_tag.data,
7148 tdata->auth_tag.len,
7149 "Generated auth tag not as expected");
7155 #ifdef RTE_LIBRTE_SECURITY
7156 /* Basic algorithm run function for async inplace mode.
7157 * Creates a session from input parameters and runs one operation
7158 * on input_vec. Checks the output of the crypto operation against
7162 test_pdcp_proto(int i, int oop,
7163 enum rte_crypto_cipher_operation opc,
7164 enum rte_crypto_auth_operation opa,
7166 unsigned int input_vec_len,
7167 uint8_t *output_vec,
7168 unsigned int output_vec_len)
7170 struct crypto_testsuite_params *ts_params = &testsuite_params;
7171 struct crypto_unittest_params *ut_params = &unittest_params;
7173 int ret = TEST_SUCCESS;
7175 /* Generate test mbuf data */
7176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7178 /* clear mbuf payload */
7179 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7180 rte_pktmbuf_tailroom(ut_params->ibuf));
7182 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7184 memcpy(plaintext, input_vec, input_vec_len);
7186 /* Out of place support */
7189 * For out-op-place we need to alloc another mbuf
7191 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7192 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7195 /* Set crypto type as IPSEC */
7196 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7198 /* Setup Cipher Parameters */
7199 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7200 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7201 ut_params->cipher_xform.cipher.op = opc;
7202 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7203 ut_params->cipher_xform.cipher.key.length =
7204 pdcp_test_params[i].cipher_key_len;
7205 ut_params->cipher_xform.cipher.iv.length = 0;
7207 /* Setup HMAC Parameters if ICV header is required */
7208 if (pdcp_test_params[i].auth_alg != 0) {
7209 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7210 ut_params->auth_xform.next = NULL;
7211 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7212 ut_params->auth_xform.auth.op = opa;
7213 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7214 ut_params->auth_xform.auth.key.length =
7215 pdcp_test_params[i].auth_key_len;
7217 ut_params->cipher_xform.next = &ut_params->auth_xform;
7219 ut_params->cipher_xform.next = NULL;
7222 struct rte_security_session_conf sess_conf = {
7223 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7224 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7226 .bearer = pdcp_test_bearer[i],
7227 .domain = pdcp_test_params[i].domain,
7228 .pkt_dir = pdcp_test_packet_direction[i],
7229 .sn_size = pdcp_test_data_sn_size[i],
7230 .hfn = pdcp_test_hfn[i],
7231 .hfn_threshold = pdcp_test_hfn_threshold[i],
7233 .crypto_xform = &ut_params->cipher_xform
7236 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7237 rte_cryptodev_get_sec_ctx(
7238 ts_params->valid_devs[0]);
7240 /* Create security session */
7241 ut_params->sec_session = rte_security_session_create(ctx,
7242 &sess_conf, ts_params->session_priv_mpool);
7244 if (!ut_params->sec_session) {
7245 printf("TestCase %s()-%d line %d failed %s: ",
7246 __func__, i, __LINE__, "Failed to allocate session");
7251 /* Generate crypto op data structure */
7252 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7253 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7254 if (!ut_params->op) {
7255 printf("TestCase %s()-%d line %d failed %s: ",
7256 __func__, i, __LINE__,
7257 "Failed to allocate symmetric crypto operation struct");
7262 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7264 /* set crypto operation source mbuf */
7265 ut_params->op->sym->m_src = ut_params->ibuf;
7267 ut_params->op->sym->m_dst = ut_params->obuf;
7269 /* Process crypto operation */
7270 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7272 printf("TestCase %s()-%d line %d failed %s: ",
7273 __func__, i, __LINE__,
7274 "failed to process sym crypto op");
7279 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7280 printf("TestCase %s()-%d line %d failed %s: ",
7281 __func__, i, __LINE__, "crypto op processing failed");
7287 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7290 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7294 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7295 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7296 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7297 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7303 rte_crypto_op_free(ut_params->op);
7304 ut_params->op = NULL;
7306 if (ut_params->sec_session)
7307 rte_security_session_destroy(ctx, ut_params->sec_session);
7308 ut_params->sec_session = NULL;
7310 rte_pktmbuf_free(ut_params->ibuf);
7311 ut_params->ibuf = NULL;
7313 rte_pktmbuf_free(ut_params->obuf);
7314 ut_params->obuf = NULL;
7321 test_pdcp_proto_SGL(int i, int oop,
7322 enum rte_crypto_cipher_operation opc,
7323 enum rte_crypto_auth_operation opa,
7325 unsigned int input_vec_len,
7326 uint8_t *output_vec,
7327 unsigned int output_vec_len,
7329 uint32_t fragsz_oop)
7331 struct crypto_testsuite_params *ts_params = &testsuite_params;
7332 struct crypto_unittest_params *ut_params = &unittest_params;
7334 struct rte_mbuf *buf, *buf_oop = NULL;
7335 int ret = TEST_SUCCESS;
7339 unsigned int trn_data = 0;
7341 if (fragsz > input_vec_len)
7342 fragsz = input_vec_len;
7344 uint16_t plaintext_len = fragsz;
7345 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7347 if (fragsz_oop > output_vec_len)
7348 frag_size_oop = output_vec_len;
7351 if (input_vec_len % fragsz != 0) {
7352 if (input_vec_len / fragsz + 1 > 16)
7354 } else if (input_vec_len / fragsz > 16)
7357 /* Out of place support */
7360 * For out-op-place we need to alloc another mbuf
7362 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7363 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7364 buf_oop = ut_params->obuf;
7367 /* Generate test mbuf data */
7368 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7370 /* clear mbuf payload */
7371 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7372 rte_pktmbuf_tailroom(ut_params->ibuf));
7374 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7376 memcpy(plaintext, input_vec, plaintext_len);
7377 trn_data += plaintext_len;
7379 buf = ut_params->ibuf;
7382 * Loop until no more fragments
7385 while (trn_data < input_vec_len) {
7387 to_trn = (input_vec_len - trn_data < fragsz) ?
7388 (input_vec_len - trn_data) : fragsz;
7390 to_trn_tbl[ecx++] = to_trn;
7392 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7395 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7396 rte_pktmbuf_tailroom(buf));
7399 if (oop && !fragsz_oop) {
7401 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7402 buf_oop = buf_oop->next;
7403 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7404 0, rte_pktmbuf_tailroom(buf_oop));
7405 rte_pktmbuf_append(buf_oop, to_trn);
7408 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7411 memcpy(plaintext, input_vec + trn_data, to_trn);
7415 ut_params->ibuf->nb_segs = segs;
7418 if (fragsz_oop && oop) {
7422 trn_data = frag_size_oop;
7423 while (trn_data < output_vec_len) {
7426 (output_vec_len - trn_data <
7428 (output_vec_len - trn_data) :
7431 to_trn_tbl[ecx++] = to_trn;
7434 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7435 buf_oop = buf_oop->next;
7436 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7437 0, rte_pktmbuf_tailroom(buf_oop));
7438 rte_pktmbuf_append(buf_oop, to_trn);
7442 ut_params->obuf->nb_segs = segs;
7445 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7447 /* Setup Cipher Parameters */
7448 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7449 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7450 ut_params->cipher_xform.cipher.op = opc;
7451 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7452 ut_params->cipher_xform.cipher.key.length =
7453 pdcp_test_params[i].cipher_key_len;
7454 ut_params->cipher_xform.cipher.iv.length = 0;
7456 /* Setup HMAC Parameters if ICV header is required */
7457 if (pdcp_test_params[i].auth_alg != 0) {
7458 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7459 ut_params->auth_xform.next = NULL;
7460 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7461 ut_params->auth_xform.auth.op = opa;
7462 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7463 ut_params->auth_xform.auth.key.length =
7464 pdcp_test_params[i].auth_key_len;
7466 ut_params->cipher_xform.next = &ut_params->auth_xform;
7468 ut_params->cipher_xform.next = NULL;
7471 struct rte_security_session_conf sess_conf = {
7472 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7473 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7475 .bearer = pdcp_test_bearer[i],
7476 .domain = pdcp_test_params[i].domain,
7477 .pkt_dir = pdcp_test_packet_direction[i],
7478 .sn_size = pdcp_test_data_sn_size[i],
7479 .hfn = pdcp_test_hfn[i],
7480 .hfn_threshold = pdcp_test_hfn_threshold[i],
7482 .crypto_xform = &ut_params->cipher_xform
7485 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7486 rte_cryptodev_get_sec_ctx(
7487 ts_params->valid_devs[0]);
7489 /* Create security session */
7490 ut_params->sec_session = rte_security_session_create(ctx,
7491 &sess_conf, ts_params->session_priv_mpool);
7493 if (!ut_params->sec_session) {
7494 printf("TestCase %s()-%d line %d failed %s: ",
7495 __func__, i, __LINE__, "Failed to allocate session");
7500 /* Generate crypto op data structure */
7501 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7502 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7503 if (!ut_params->op) {
7504 printf("TestCase %s()-%d line %d failed %s: ",
7505 __func__, i, __LINE__,
7506 "Failed to allocate symmetric crypto operation struct");
7511 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7513 /* set crypto operation source mbuf */
7514 ut_params->op->sym->m_src = ut_params->ibuf;
7516 ut_params->op->sym->m_dst = ut_params->obuf;
7518 /* Process crypto operation */
7519 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7521 printf("TestCase %s()-%d line %d failed %s: ",
7522 __func__, i, __LINE__,
7523 "failed to process sym crypto op");
7528 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7529 printf("TestCase %s()-%d line %d failed %s: ",
7530 __func__, i, __LINE__, "crypto op processing failed");
7536 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7539 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7543 fragsz = frag_size_oop;
7544 if (memcmp(ciphertext, output_vec, fragsz)) {
7545 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7546 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7547 rte_hexdump(stdout, "reference", output_vec, fragsz);
7552 buf = ut_params->op->sym->m_src->next;
7554 buf = ut_params->op->sym->m_dst->next;
7556 unsigned int off = fragsz;
7560 ciphertext = rte_pktmbuf_mtod(buf,
7562 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7563 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7564 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7565 rte_hexdump(stdout, "reference", output_vec + off,
7570 off += to_trn_tbl[ecx++];
7574 rte_crypto_op_free(ut_params->op);
7575 ut_params->op = NULL;
7577 if (ut_params->sec_session)
7578 rte_security_session_destroy(ctx, ut_params->sec_session);
7579 ut_params->sec_session = NULL;
7581 rte_pktmbuf_free(ut_params->ibuf);
7582 ut_params->ibuf = NULL;
7584 rte_pktmbuf_free(ut_params->obuf);
7585 ut_params->obuf = NULL;
7592 test_pdcp_proto_cplane_encap(int i)
7594 return test_pdcp_proto(i, 0,
7595 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7596 RTE_CRYPTO_AUTH_OP_GENERATE,
7597 pdcp_test_data_in[i],
7598 pdcp_test_data_in_len[i],
7599 pdcp_test_data_out[i],
7600 pdcp_test_data_in_len[i]+4);
7604 test_pdcp_proto_uplane_encap(int i)
7606 return test_pdcp_proto(i, 0,
7607 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7608 RTE_CRYPTO_AUTH_OP_GENERATE,
7609 pdcp_test_data_in[i],
7610 pdcp_test_data_in_len[i],
7611 pdcp_test_data_out[i],
7612 pdcp_test_data_in_len[i]);
7617 test_pdcp_proto_uplane_encap_with_int(int i)
7619 return test_pdcp_proto(i, 0,
7620 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7621 RTE_CRYPTO_AUTH_OP_GENERATE,
7622 pdcp_test_data_in[i],
7623 pdcp_test_data_in_len[i],
7624 pdcp_test_data_out[i],
7625 pdcp_test_data_in_len[i] + 4);
7629 test_pdcp_proto_cplane_decap(int i)
7631 return test_pdcp_proto(i, 0,
7632 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7633 RTE_CRYPTO_AUTH_OP_VERIFY,
7634 pdcp_test_data_out[i],
7635 pdcp_test_data_in_len[i] + 4,
7636 pdcp_test_data_in[i],
7637 pdcp_test_data_in_len[i]);
7641 test_pdcp_proto_uplane_decap(int i)
7643 return test_pdcp_proto(i, 0,
7644 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7645 RTE_CRYPTO_AUTH_OP_VERIFY,
7646 pdcp_test_data_out[i],
7647 pdcp_test_data_in_len[i],
7648 pdcp_test_data_in[i],
7649 pdcp_test_data_in_len[i]);
7653 test_pdcp_proto_uplane_decap_with_int(int i)
7655 return test_pdcp_proto(i, 0,
7656 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7657 RTE_CRYPTO_AUTH_OP_VERIFY,
7658 pdcp_test_data_out[i],
7659 pdcp_test_data_in_len[i] + 4,
7660 pdcp_test_data_in[i],
7661 pdcp_test_data_in_len[i]);
7665 test_PDCP_PROTO_SGL_in_place_32B(void)
7667 /* i can be used for running any PDCP case
7668 * In this case it is uplane 12-bit AES-SNOW DL encap
7670 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7671 return test_pdcp_proto_SGL(i, IN_PLACE,
7672 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7673 RTE_CRYPTO_AUTH_OP_GENERATE,
7674 pdcp_test_data_in[i],
7675 pdcp_test_data_in_len[i],
7676 pdcp_test_data_out[i],
7677 pdcp_test_data_in_len[i]+4,
7681 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7683 /* i can be used for running any PDCP case
7684 * In this case it is uplane 18-bit NULL-NULL DL encap
7686 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7687 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7688 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7689 RTE_CRYPTO_AUTH_OP_GENERATE,
7690 pdcp_test_data_in[i],
7691 pdcp_test_data_in_len[i],
7692 pdcp_test_data_out[i],
7693 pdcp_test_data_in_len[i]+4,
7697 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7699 /* i can be used for running any PDCP case
7700 * In this case it is uplane 18-bit AES DL encap
7702 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7704 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7705 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7706 RTE_CRYPTO_AUTH_OP_GENERATE,
7707 pdcp_test_data_in[i],
7708 pdcp_test_data_in_len[i],
7709 pdcp_test_data_out[i],
7710 pdcp_test_data_in_len[i],
7714 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7716 /* i can be used for running any PDCP case
7717 * In this case it is cplane 12-bit AES-ZUC DL encap
7719 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7720 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7721 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7722 RTE_CRYPTO_AUTH_OP_GENERATE,
7723 pdcp_test_data_in[i],
7724 pdcp_test_data_in_len[i],
7725 pdcp_test_data_out[i],
7726 pdcp_test_data_in_len[i]+4,
7732 test_AES_GCM_authenticated_encryption_test_case_1(void)
7734 return test_authenticated_encryption(&gcm_test_case_1);
7738 test_AES_GCM_authenticated_encryption_test_case_2(void)
7740 return test_authenticated_encryption(&gcm_test_case_2);
7744 test_AES_GCM_authenticated_encryption_test_case_3(void)
7746 return test_authenticated_encryption(&gcm_test_case_3);
7750 test_AES_GCM_authenticated_encryption_test_case_4(void)
7752 return test_authenticated_encryption(&gcm_test_case_4);
7756 test_AES_GCM_authenticated_encryption_test_case_5(void)
7758 return test_authenticated_encryption(&gcm_test_case_5);
7762 test_AES_GCM_authenticated_encryption_test_case_6(void)
7764 return test_authenticated_encryption(&gcm_test_case_6);
7768 test_AES_GCM_authenticated_encryption_test_case_7(void)
7770 return test_authenticated_encryption(&gcm_test_case_7);
7774 test_AES_GCM_authenticated_encryption_test_case_8(void)
7776 return test_authenticated_encryption(&gcm_test_case_8);
7780 test_AES_GCM_auth_encryption_test_case_192_1(void)
7782 return test_authenticated_encryption(&gcm_test_case_192_1);
7786 test_AES_GCM_auth_encryption_test_case_192_2(void)
7788 return test_authenticated_encryption(&gcm_test_case_192_2);
7792 test_AES_GCM_auth_encryption_test_case_192_3(void)
7794 return test_authenticated_encryption(&gcm_test_case_192_3);
7798 test_AES_GCM_auth_encryption_test_case_192_4(void)
7800 return test_authenticated_encryption(&gcm_test_case_192_4);
7804 test_AES_GCM_auth_encryption_test_case_192_5(void)
7806 return test_authenticated_encryption(&gcm_test_case_192_5);
7810 test_AES_GCM_auth_encryption_test_case_192_6(void)
7812 return test_authenticated_encryption(&gcm_test_case_192_6);
7816 test_AES_GCM_auth_encryption_test_case_192_7(void)
7818 return test_authenticated_encryption(&gcm_test_case_192_7);
7822 test_AES_GCM_auth_encryption_test_case_256_1(void)
7824 return test_authenticated_encryption(&gcm_test_case_256_1);
7828 test_AES_GCM_auth_encryption_test_case_256_2(void)
7830 return test_authenticated_encryption(&gcm_test_case_256_2);
7834 test_AES_GCM_auth_encryption_test_case_256_3(void)
7836 return test_authenticated_encryption(&gcm_test_case_256_3);
7840 test_AES_GCM_auth_encryption_test_case_256_4(void)
7842 return test_authenticated_encryption(&gcm_test_case_256_4);
7846 test_AES_GCM_auth_encryption_test_case_256_5(void)
7848 return test_authenticated_encryption(&gcm_test_case_256_5);
7852 test_AES_GCM_auth_encryption_test_case_256_6(void)
7854 return test_authenticated_encryption(&gcm_test_case_256_6);
7858 test_AES_GCM_auth_encryption_test_case_256_7(void)
7860 return test_authenticated_encryption(&gcm_test_case_256_7);
7864 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7866 return test_authenticated_encryption(&gcm_test_case_aad_1);
7870 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7872 return test_authenticated_encryption(&gcm_test_case_aad_2);
7876 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7878 struct aead_test_data tdata;
7881 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7882 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7883 tdata.iv.data[0] += 1;
7884 res = test_authenticated_encryption(&tdata);
7885 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7886 return TEST_SUCCESS;
7890 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7892 struct aead_test_data tdata;
7895 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7896 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7897 tdata.plaintext.data[0] += 1;
7898 res = test_authenticated_encryption(&tdata);
7899 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7900 return TEST_SUCCESS;
7904 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7906 struct aead_test_data tdata;
7909 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7910 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7911 tdata.ciphertext.data[0] += 1;
7912 res = test_authenticated_encryption(&tdata);
7913 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7914 return TEST_SUCCESS;
7918 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7920 struct aead_test_data tdata;
7923 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7924 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7926 res = test_authenticated_encryption(&tdata);
7927 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7928 return TEST_SUCCESS;
7932 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7934 struct aead_test_data tdata;
7935 uint8_t aad[gcm_test_case_7.aad.len];
7938 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7939 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7940 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7942 tdata.aad.data = aad;
7943 res = test_authenticated_encryption(&tdata);
7944 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7945 return TEST_SUCCESS;
7949 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7951 struct aead_test_data tdata;
7954 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7955 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7956 tdata.auth_tag.data[0] += 1;
7957 res = test_authenticated_encryption(&tdata);
7958 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7959 return TEST_SUCCESS;
7963 test_authenticated_decryption(const struct aead_test_data *tdata)
7965 struct crypto_testsuite_params *ts_params = &testsuite_params;
7966 struct crypto_unittest_params *ut_params = &unittest_params;
7972 /* Create AEAD session */
7973 retval = create_aead_session(ts_params->valid_devs[0],
7975 RTE_CRYPTO_AEAD_OP_DECRYPT,
7976 tdata->key.data, tdata->key.len,
7977 tdata->aad.len, tdata->auth_tag.len,
7982 /* alloc mbuf and set payload */
7983 if (tdata->aad.len > MBUF_SIZE) {
7984 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7985 /* Populate full size of add data */
7986 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7987 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7989 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7992 rte_pktmbuf_tailroom(ut_params->ibuf));
7994 /* Create AEAD operation */
7995 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7999 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8001 ut_params->op->sym->m_src = ut_params->ibuf;
8003 /* Process crypto operation */
8004 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8005 ut_params->op), "failed to process sym crypto op");
8007 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8008 "crypto op processing failed");
8010 if (ut_params->op->sym->m_dst)
8011 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8014 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8016 ut_params->op->sym->cipher.data.offset);
8018 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8021 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8023 tdata->plaintext.data,
8024 tdata->plaintext.len,
8025 "Plaintext data not as expected");
8027 TEST_ASSERT_EQUAL(ut_params->op->status,
8028 RTE_CRYPTO_OP_STATUS_SUCCESS,
8029 "Authentication failed");
8035 test_AES_GCM_authenticated_decryption_test_case_1(void)
8037 return test_authenticated_decryption(&gcm_test_case_1);
8041 test_AES_GCM_authenticated_decryption_test_case_2(void)
8043 return test_authenticated_decryption(&gcm_test_case_2);
8047 test_AES_GCM_authenticated_decryption_test_case_3(void)
8049 return test_authenticated_decryption(&gcm_test_case_3);
8053 test_AES_GCM_authenticated_decryption_test_case_4(void)
8055 return test_authenticated_decryption(&gcm_test_case_4);
8059 test_AES_GCM_authenticated_decryption_test_case_5(void)
8061 return test_authenticated_decryption(&gcm_test_case_5);
8065 test_AES_GCM_authenticated_decryption_test_case_6(void)
8067 return test_authenticated_decryption(&gcm_test_case_6);
8071 test_AES_GCM_authenticated_decryption_test_case_7(void)
8073 return test_authenticated_decryption(&gcm_test_case_7);
8077 test_AES_GCM_authenticated_decryption_test_case_8(void)
8079 return test_authenticated_decryption(&gcm_test_case_8);
8083 test_AES_GCM_auth_decryption_test_case_192_1(void)
8085 return test_authenticated_decryption(&gcm_test_case_192_1);
8089 test_AES_GCM_auth_decryption_test_case_192_2(void)
8091 return test_authenticated_decryption(&gcm_test_case_192_2);
8095 test_AES_GCM_auth_decryption_test_case_192_3(void)
8097 return test_authenticated_decryption(&gcm_test_case_192_3);
8101 test_AES_GCM_auth_decryption_test_case_192_4(void)
8103 return test_authenticated_decryption(&gcm_test_case_192_4);
8107 test_AES_GCM_auth_decryption_test_case_192_5(void)
8109 return test_authenticated_decryption(&gcm_test_case_192_5);
8113 test_AES_GCM_auth_decryption_test_case_192_6(void)
8115 return test_authenticated_decryption(&gcm_test_case_192_6);
8119 test_AES_GCM_auth_decryption_test_case_192_7(void)
8121 return test_authenticated_decryption(&gcm_test_case_192_7);
8125 test_AES_GCM_auth_decryption_test_case_256_1(void)
8127 return test_authenticated_decryption(&gcm_test_case_256_1);
8131 test_AES_GCM_auth_decryption_test_case_256_2(void)
8133 return test_authenticated_decryption(&gcm_test_case_256_2);
8137 test_AES_GCM_auth_decryption_test_case_256_3(void)
8139 return test_authenticated_decryption(&gcm_test_case_256_3);
8143 test_AES_GCM_auth_decryption_test_case_256_4(void)
8145 return test_authenticated_decryption(&gcm_test_case_256_4);
8149 test_AES_GCM_auth_decryption_test_case_256_5(void)
8151 return test_authenticated_decryption(&gcm_test_case_256_5);
8155 test_AES_GCM_auth_decryption_test_case_256_6(void)
8157 return test_authenticated_decryption(&gcm_test_case_256_6);
8161 test_AES_GCM_auth_decryption_test_case_256_7(void)
8163 return test_authenticated_decryption(&gcm_test_case_256_7);
8167 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8169 return test_authenticated_decryption(&gcm_test_case_aad_1);
8173 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8175 return test_authenticated_decryption(&gcm_test_case_aad_2);
8179 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8181 struct aead_test_data tdata;
8184 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8185 tdata.iv.data[0] += 1;
8186 res = test_authenticated_decryption(&tdata);
8187 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8188 return TEST_SUCCESS;
8192 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8194 struct aead_test_data tdata;
8197 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8198 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8199 tdata.plaintext.data[0] += 1;
8200 res = test_authenticated_decryption(&tdata);
8201 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8202 return TEST_SUCCESS;
8206 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8208 struct aead_test_data tdata;
8211 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8212 tdata.ciphertext.data[0] += 1;
8213 res = test_authenticated_decryption(&tdata);
8214 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8215 return TEST_SUCCESS;
8219 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8221 struct aead_test_data tdata;
8224 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8226 res = test_authenticated_decryption(&tdata);
8227 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8228 return TEST_SUCCESS;
8232 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8234 struct aead_test_data tdata;
8235 uint8_t aad[gcm_test_case_7.aad.len];
8238 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8239 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8241 tdata.aad.data = aad;
8242 res = test_authenticated_decryption(&tdata);
8243 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8244 return TEST_SUCCESS;
8248 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8250 struct aead_test_data tdata;
8253 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8254 tdata.auth_tag.data[0] += 1;
8255 res = test_authenticated_decryption(&tdata);
8256 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8257 return TEST_SUCCESS;
8261 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8263 struct crypto_testsuite_params *ts_params = &testsuite_params;
8264 struct crypto_unittest_params *ut_params = &unittest_params;
8267 uint8_t *ciphertext, *auth_tag;
8268 uint16_t plaintext_pad_len;
8270 /* Create AEAD session */
8271 retval = create_aead_session(ts_params->valid_devs[0],
8273 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8274 tdata->key.data, tdata->key.len,
8275 tdata->aad.len, tdata->auth_tag.len,
8280 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8281 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8283 /* clear mbuf payload */
8284 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8285 rte_pktmbuf_tailroom(ut_params->ibuf));
8286 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8287 rte_pktmbuf_tailroom(ut_params->obuf));
8289 /* Create AEAD operation */
8290 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8294 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8296 ut_params->op->sym->m_src = ut_params->ibuf;
8297 ut_params->op->sym->m_dst = ut_params->obuf;
8299 /* Process crypto operation */
8300 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8301 ut_params->op), "failed to process sym crypto op");
8303 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8304 "crypto op processing failed");
8306 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8308 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8309 ut_params->op->sym->cipher.data.offset);
8310 auth_tag = ciphertext + plaintext_pad_len;
8312 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8313 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8318 tdata->ciphertext.data,
8319 tdata->ciphertext.len,
8320 "Ciphertext data not as expected");
8322 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8324 tdata->auth_tag.data,
8325 tdata->auth_tag.len,
8326 "Generated auth tag not as expected");
8333 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8335 return test_authenticated_encryption_oop(&gcm_test_case_5);
8339 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8341 struct crypto_testsuite_params *ts_params = &testsuite_params;
8342 struct crypto_unittest_params *ut_params = &unittest_params;
8347 /* Create AEAD session */
8348 retval = create_aead_session(ts_params->valid_devs[0],
8350 RTE_CRYPTO_AEAD_OP_DECRYPT,
8351 tdata->key.data, tdata->key.len,
8352 tdata->aad.len, tdata->auth_tag.len,
8357 /* alloc mbuf and set payload */
8358 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8359 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8361 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8362 rte_pktmbuf_tailroom(ut_params->ibuf));
8363 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8364 rte_pktmbuf_tailroom(ut_params->obuf));
8366 /* Create AEAD operation */
8367 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8371 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8373 ut_params->op->sym->m_src = ut_params->ibuf;
8374 ut_params->op->sym->m_dst = ut_params->obuf;
8376 /* Process crypto operation */
8377 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8378 ut_params->op), "failed to process sym crypto op");
8380 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8381 "crypto op processing failed");
8383 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8384 ut_params->op->sym->cipher.data.offset);
8386 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8389 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8391 tdata->plaintext.data,
8392 tdata->plaintext.len,
8393 "Plaintext data not as expected");
8395 TEST_ASSERT_EQUAL(ut_params->op->status,
8396 RTE_CRYPTO_OP_STATUS_SUCCESS,
8397 "Authentication failed");
8402 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8404 return test_authenticated_decryption_oop(&gcm_test_case_5);
8408 test_authenticated_encryption_sessionless(
8409 const struct aead_test_data *tdata)
8411 struct crypto_testsuite_params *ts_params = &testsuite_params;
8412 struct crypto_unittest_params *ut_params = &unittest_params;
8415 uint8_t *ciphertext, *auth_tag;
8416 uint16_t plaintext_pad_len;
8417 uint8_t key[tdata->key.len + 1];
8419 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8421 /* clear mbuf payload */
8422 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8423 rte_pktmbuf_tailroom(ut_params->ibuf));
8425 /* Create AEAD operation */
8426 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8430 /* Create GCM xform */
8431 memcpy(key, tdata->key.data, tdata->key.len);
8432 retval = create_aead_xform(ut_params->op,
8434 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8435 key, tdata->key.len,
8436 tdata->aad.len, tdata->auth_tag.len,
8441 ut_params->op->sym->m_src = ut_params->ibuf;
8443 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8444 RTE_CRYPTO_OP_SESSIONLESS,
8445 "crypto op session type not sessionless");
8447 /* Process crypto operation */
8448 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8449 ut_params->op), "failed to process sym crypto op");
8451 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8453 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8454 "crypto op status not success");
8456 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8458 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8459 ut_params->op->sym->cipher.data.offset);
8460 auth_tag = ciphertext + plaintext_pad_len;
8462 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8463 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8466 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8468 tdata->ciphertext.data,
8469 tdata->ciphertext.len,
8470 "Ciphertext data not as expected");
8472 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8474 tdata->auth_tag.data,
8475 tdata->auth_tag.len,
8476 "Generated auth tag not as expected");
8483 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8485 return test_authenticated_encryption_sessionless(
8490 test_authenticated_decryption_sessionless(
8491 const struct aead_test_data *tdata)
8493 struct crypto_testsuite_params *ts_params = &testsuite_params;
8494 struct crypto_unittest_params *ut_params = &unittest_params;
8498 uint8_t key[tdata->key.len + 1];
8500 /* alloc mbuf and set payload */
8501 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8503 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8504 rte_pktmbuf_tailroom(ut_params->ibuf));
8506 /* Create AEAD operation */
8507 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8511 /* Create AEAD xform */
8512 memcpy(key, tdata->key.data, tdata->key.len);
8513 retval = create_aead_xform(ut_params->op,
8515 RTE_CRYPTO_AEAD_OP_DECRYPT,
8516 key, tdata->key.len,
8517 tdata->aad.len, tdata->auth_tag.len,
8522 ut_params->op->sym->m_src = ut_params->ibuf;
8524 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8525 RTE_CRYPTO_OP_SESSIONLESS,
8526 "crypto op session type not sessionless");
8528 /* Process crypto operation */
8529 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8530 ut_params->op), "failed to process sym crypto op");
8532 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8534 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8535 "crypto op status not success");
8537 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8538 ut_params->op->sym->cipher.data.offset);
8540 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8543 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8545 tdata->plaintext.data,
8546 tdata->plaintext.len,
8547 "Plaintext data not as expected");
8549 TEST_ASSERT_EQUAL(ut_params->op->status,
8550 RTE_CRYPTO_OP_STATUS_SUCCESS,
8551 "Authentication failed");
8556 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8558 return test_authenticated_decryption_sessionless(
8563 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8565 return test_authenticated_encryption(&ccm_test_case_128_1);
8569 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8571 return test_authenticated_encryption(&ccm_test_case_128_2);
8575 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8577 return test_authenticated_encryption(&ccm_test_case_128_3);
8581 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8583 return test_authenticated_decryption(&ccm_test_case_128_1);
8587 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8589 return test_authenticated_decryption(&ccm_test_case_128_2);
8593 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8595 return test_authenticated_decryption(&ccm_test_case_128_3);
8599 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8601 return test_authenticated_encryption(&ccm_test_case_192_1);
8605 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8607 return test_authenticated_encryption(&ccm_test_case_192_2);
8611 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8613 return test_authenticated_encryption(&ccm_test_case_192_3);
8617 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8619 return test_authenticated_decryption(&ccm_test_case_192_1);
8623 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8625 return test_authenticated_decryption(&ccm_test_case_192_2);
8629 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8631 return test_authenticated_decryption(&ccm_test_case_192_3);
8635 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8637 return test_authenticated_encryption(&ccm_test_case_256_1);
8641 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8643 return test_authenticated_encryption(&ccm_test_case_256_2);
8647 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8649 return test_authenticated_encryption(&ccm_test_case_256_3);
8653 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8655 return test_authenticated_decryption(&ccm_test_case_256_1);
8659 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8661 return test_authenticated_decryption(&ccm_test_case_256_2);
8665 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8667 return test_authenticated_decryption(&ccm_test_case_256_3);
8673 struct crypto_testsuite_params *ts_params = &testsuite_params;
8674 struct rte_cryptodev_stats stats;
8675 struct rte_cryptodev *dev;
8676 cryptodev_stats_get_t temp_pfn;
8678 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8679 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8680 &stats) == -ENODEV),
8681 "rte_cryptodev_stats_get invalid dev failed");
8682 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8683 "rte_cryptodev_stats_get invalid Param failed");
8684 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8685 temp_pfn = dev->dev_ops->stats_get;
8686 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8687 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8689 "rte_cryptodev_stats_get invalid Param failed");
8690 dev->dev_ops->stats_get = temp_pfn;
8692 /* Test expected values */
8694 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8696 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8698 "rte_cryptodev_stats_get failed");
8699 TEST_ASSERT((stats.enqueued_count == 1),
8700 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8701 TEST_ASSERT((stats.dequeued_count == 1),
8702 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8703 TEST_ASSERT((stats.enqueue_err_count == 0),
8704 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8705 TEST_ASSERT((stats.dequeue_err_count == 0),
8706 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8708 /* invalid device but should ignore and not reset device stats*/
8709 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8710 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8712 "rte_cryptodev_stats_get failed");
8713 TEST_ASSERT((stats.enqueued_count == 1),
8714 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8716 /* check that a valid reset clears stats */
8717 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8718 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8720 "rte_cryptodev_stats_get failed");
8721 TEST_ASSERT((stats.enqueued_count == 0),
8722 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8723 TEST_ASSERT((stats.dequeued_count == 0),
8724 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8726 return TEST_SUCCESS;
8729 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8730 struct crypto_unittest_params *ut_params,
8731 enum rte_crypto_auth_operation op,
8732 const struct HMAC_MD5_vector *test_case)
8736 memcpy(key, test_case->key.data, test_case->key.len);
8738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8739 ut_params->auth_xform.next = NULL;
8740 ut_params->auth_xform.auth.op = op;
8742 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8744 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8745 ut_params->auth_xform.auth.key.length = test_case->key.len;
8746 ut_params->auth_xform.auth.key.data = key;
8748 ut_params->sess = rte_cryptodev_sym_session_create(
8749 ts_params->session_mpool);
8751 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8752 ut_params->sess, &ut_params->auth_xform,
8753 ts_params->session_priv_mpool);
8755 if (ut_params->sess == NULL)
8758 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8760 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8761 rte_pktmbuf_tailroom(ut_params->ibuf));
8766 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8767 const struct HMAC_MD5_vector *test_case,
8768 uint8_t **plaintext)
8770 uint16_t plaintext_pad_len;
8772 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8774 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8777 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8779 memcpy(*plaintext, test_case->plaintext.data,
8780 test_case->plaintext.len);
8782 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8783 ut_params->ibuf, MD5_DIGEST_LEN);
8784 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8785 "no room to append digest");
8786 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8787 ut_params->ibuf, plaintext_pad_len);
8789 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8790 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8791 test_case->auth_tag.len);
8794 sym_op->auth.data.offset = 0;
8795 sym_op->auth.data.length = test_case->plaintext.len;
8797 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8798 ut_params->op->sym->m_src = ut_params->ibuf;
8804 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8806 uint16_t plaintext_pad_len;
8807 uint8_t *plaintext, *auth_tag;
8809 struct crypto_testsuite_params *ts_params = &testsuite_params;
8810 struct crypto_unittest_params *ut_params = &unittest_params;
8812 if (MD5_HMAC_create_session(ts_params, ut_params,
8813 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8816 /* Generate Crypto op data structure */
8817 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8818 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8819 TEST_ASSERT_NOT_NULL(ut_params->op,
8820 "Failed to allocate symmetric crypto operation struct");
8822 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8825 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8828 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8829 ut_params->op), "failed to process sym crypto op");
8831 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8832 "crypto op processing failed");
8834 if (ut_params->op->sym->m_dst) {
8835 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8836 uint8_t *, plaintext_pad_len);
8838 auth_tag = plaintext + plaintext_pad_len;
8841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8843 test_case->auth_tag.data,
8844 test_case->auth_tag.len,
8845 "HMAC_MD5 generated tag not as expected");
8847 return TEST_SUCCESS;
8851 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8855 struct crypto_testsuite_params *ts_params = &testsuite_params;
8856 struct crypto_unittest_params *ut_params = &unittest_params;
8858 if (MD5_HMAC_create_session(ts_params, ut_params,
8859 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8863 /* Generate Crypto op data structure */
8864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8866 TEST_ASSERT_NOT_NULL(ut_params->op,
8867 "Failed to allocate symmetric crypto operation struct");
8869 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8872 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8873 ut_params->op), "failed to process sym crypto op");
8875 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8876 "HMAC_MD5 crypto op processing failed");
8878 return TEST_SUCCESS;
8882 test_MD5_HMAC_generate_case_1(void)
8884 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8888 test_MD5_HMAC_verify_case_1(void)
8890 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8894 test_MD5_HMAC_generate_case_2(void)
8896 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8900 test_MD5_HMAC_verify_case_2(void)
8902 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8906 test_multi_session(void)
8908 struct crypto_testsuite_params *ts_params = &testsuite_params;
8909 struct crypto_unittest_params *ut_params = &unittest_params;
8911 struct rte_cryptodev_info dev_info;
8912 struct rte_cryptodev_sym_session **sessions;
8916 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8917 aes_cbc_key, hmac_sha512_key);
8920 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8922 sessions = rte_malloc(NULL,
8923 (sizeof(struct rte_cryptodev_sym_session *) *
8924 MAX_NB_SESSIONS) + 1, 0);
8926 /* Create multiple crypto sessions*/
8927 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8929 sessions[i] = rte_cryptodev_sym_session_create(
8930 ts_params->session_mpool);
8932 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8933 sessions[i], &ut_params->auth_xform,
8934 ts_params->session_priv_mpool);
8935 TEST_ASSERT_NOT_NULL(sessions[i],
8936 "Session creation failed at session number %u",
8939 /* Attempt to send a request on each session */
8940 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8944 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8945 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8947 "Failed to perform decrypt on request number %u.", i);
8948 /* free crypto operation structure */
8950 rte_crypto_op_free(ut_params->op);
8953 * free mbuf - both obuf and ibuf are usually the same,
8954 * so check if they point at the same address is necessary,
8955 * to avoid freeing the mbuf twice.
8957 if (ut_params->obuf) {
8958 rte_pktmbuf_free(ut_params->obuf);
8959 if (ut_params->ibuf == ut_params->obuf)
8960 ut_params->ibuf = 0;
8961 ut_params->obuf = 0;
8963 if (ut_params->ibuf) {
8964 rte_pktmbuf_free(ut_params->ibuf);
8965 ut_params->ibuf = 0;
8969 /* Next session create should fail */
8970 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8971 sessions[i], &ut_params->auth_xform,
8972 ts_params->session_priv_mpool);
8973 TEST_ASSERT_NULL(sessions[i],
8974 "Session creation succeeded unexpectedly!");
8976 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8977 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8979 rte_cryptodev_sym_session_free(sessions[i]);
8984 return TEST_SUCCESS;
8987 struct multi_session_params {
8988 struct crypto_unittest_params ut_params;
8989 uint8_t *cipher_key;
8991 const uint8_t *cipher;
8992 const uint8_t *digest;
8996 #define MB_SESSION_NUMBER 3
8999 test_multi_session_random_usage(void)
9001 struct crypto_testsuite_params *ts_params = &testsuite_params;
9002 struct rte_cryptodev_info dev_info;
9003 struct rte_cryptodev_sym_session **sessions;
9005 struct multi_session_params ut_paramz[] = {
9008 .cipher_key = ms_aes_cbc_key0,
9009 .hmac_key = ms_hmac_key0,
9010 .cipher = ms_aes_cbc_cipher0,
9011 .digest = ms_hmac_digest0,
9012 .iv = ms_aes_cbc_iv0
9015 .cipher_key = ms_aes_cbc_key1,
9016 .hmac_key = ms_hmac_key1,
9017 .cipher = ms_aes_cbc_cipher1,
9018 .digest = ms_hmac_digest1,
9019 .iv = ms_aes_cbc_iv1
9022 .cipher_key = ms_aes_cbc_key2,
9023 .hmac_key = ms_hmac_key2,
9024 .cipher = ms_aes_cbc_cipher2,
9025 .digest = ms_hmac_digest2,
9026 .iv = ms_aes_cbc_iv2
9031 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9033 sessions = rte_malloc(NULL,
9034 (sizeof(struct rte_cryptodev_sym_session *)
9035 * MAX_NB_SESSIONS) + 1, 0);
9037 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9038 sessions[i] = rte_cryptodev_sym_session_create(
9039 ts_params->session_mpool);
9041 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9042 sizeof(struct crypto_unittest_params));
9044 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9045 &ut_paramz[i].ut_params,
9046 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9048 /* Create multiple crypto sessions*/
9049 rte_cryptodev_sym_session_init(
9050 ts_params->valid_devs[0],
9052 &ut_paramz[i].ut_params.auth_xform,
9053 ts_params->session_priv_mpool);
9055 TEST_ASSERT_NOT_NULL(sessions[i],
9056 "Session creation failed at session number %u",
9062 for (i = 0; i < 40000; i++) {
9064 j = rand() % MB_SESSION_NUMBER;
9066 TEST_ASSERT_SUCCESS(
9067 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9069 &ut_paramz[j].ut_params,
9070 ts_params, ut_paramz[j].cipher,
9071 ut_paramz[j].digest,
9073 "Failed to perform decrypt on request number %u.", i);
9075 if (ut_paramz[j].ut_params.op)
9076 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9079 * free mbuf - both obuf and ibuf are usually the same,
9080 * so check if they point at the same address is necessary,
9081 * to avoid freeing the mbuf twice.
9083 if (ut_paramz[j].ut_params.obuf) {
9084 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9085 if (ut_paramz[j].ut_params.ibuf
9086 == ut_paramz[j].ut_params.obuf)
9087 ut_paramz[j].ut_params.ibuf = 0;
9088 ut_paramz[j].ut_params.obuf = 0;
9090 if (ut_paramz[j].ut_params.ibuf) {
9091 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9092 ut_paramz[j].ut_params.ibuf = 0;
9096 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9097 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9099 rte_cryptodev_sym_session_free(sessions[i]);
9104 return TEST_SUCCESS;
9108 test_null_cipher_only_operation(void)
9110 struct crypto_testsuite_params *ts_params = &testsuite_params;
9111 struct crypto_unittest_params *ut_params = &unittest_params;
9113 /* Generate test mbuf data and space for digest */
9114 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9115 catch_22_quote, QUOTE_512_BYTES, 0);
9117 /* Setup Cipher Parameters */
9118 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9119 ut_params->cipher_xform.next = NULL;
9121 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9122 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9124 ut_params->sess = rte_cryptodev_sym_session_create(
9125 ts_params->session_mpool);
9127 /* Create Crypto session*/
9128 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9130 &ut_params->cipher_xform,
9131 ts_params->session_priv_mpool);
9132 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9134 /* Generate Crypto op data structure */
9135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9137 TEST_ASSERT_NOT_NULL(ut_params->op,
9138 "Failed to allocate symmetric crypto operation struct");
9140 /* Set crypto operation data parameters */
9141 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9145 /* set crypto operation source mbuf */
9146 sym_op->m_src = ut_params->ibuf;
9148 sym_op->cipher.data.offset = 0;
9149 sym_op->cipher.data.length = QUOTE_512_BYTES;
9151 /* Process crypto operation */
9152 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9154 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9156 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9157 "crypto operation processing failed");
9160 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9161 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9164 "Ciphertext data not as expected");
9166 return TEST_SUCCESS;
9168 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9169 0xab, 0xab, 0xab, 0xab,
9170 0xab, 0xab, 0xab, 0xab,
9171 0xab, 0xab, 0xab, 0xab};
9173 test_null_auth_only_operation(void)
9175 struct crypto_testsuite_params *ts_params = &testsuite_params;
9176 struct crypto_unittest_params *ut_params = &unittest_params;
9179 /* Generate test mbuf data and space for digest */
9180 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9181 catch_22_quote, QUOTE_512_BYTES, 0);
9183 /* create a pointer for digest, but don't expect anything to be written
9184 * here in a NULL auth algo so no mbuf append done.
9186 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9188 /* prefill the memory pointed to by digest */
9189 memcpy(digest, orig_data, sizeof(orig_data));
9191 /* Setup HMAC Parameters */
9192 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9193 ut_params->auth_xform.next = NULL;
9195 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9196 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9198 ut_params->sess = rte_cryptodev_sym_session_create(
9199 ts_params->session_mpool);
9201 /* Create Crypto session*/
9202 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9203 ut_params->sess, &ut_params->auth_xform,
9204 ts_params->session_priv_mpool);
9205 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9207 /* Generate Crypto op data structure */
9208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9210 TEST_ASSERT_NOT_NULL(ut_params->op,
9211 "Failed to allocate symmetric crypto operation struct");
9213 /* Set crypto operation data parameters */
9214 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9216 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9218 sym_op->m_src = ut_params->ibuf;
9220 sym_op->auth.data.offset = 0;
9221 sym_op->auth.data.length = QUOTE_512_BYTES;
9222 sym_op->auth.digest.data = digest;
9223 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9226 /* Process crypto operation */
9227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9229 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9231 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9232 "crypto operation processing failed");
9233 /* Make sure memory pointed to by digest hasn't been overwritten */
9234 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9238 "Memory at digest ptr overwritten unexpectedly");
9240 return TEST_SUCCESS;
9245 test_null_cipher_auth_operation(void)
9247 struct crypto_testsuite_params *ts_params = &testsuite_params;
9248 struct crypto_unittest_params *ut_params = &unittest_params;
9251 /* Generate test mbuf data and space for digest */
9252 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9253 catch_22_quote, QUOTE_512_BYTES, 0);
9255 /* create a pointer for digest, but don't expect anything to be written
9256 * here in a NULL auth algo so no mbuf append done.
9258 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9260 /* prefill the memory pointed to by digest */
9261 memcpy(digest, orig_data, sizeof(orig_data));
9263 /* Setup Cipher Parameters */
9264 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9265 ut_params->cipher_xform.next = &ut_params->auth_xform;
9267 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9268 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9270 /* Setup HMAC Parameters */
9271 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9272 ut_params->auth_xform.next = NULL;
9274 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9275 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9277 ut_params->sess = rte_cryptodev_sym_session_create(
9278 ts_params->session_mpool);
9280 /* Create Crypto session*/
9281 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9282 ut_params->sess, &ut_params->cipher_xform,
9283 ts_params->session_priv_mpool);
9284 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9286 /* Generate Crypto op data structure */
9287 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9288 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9289 TEST_ASSERT_NOT_NULL(ut_params->op,
9290 "Failed to allocate symmetric crypto operation struct");
9292 /* Set crypto operation data parameters */
9293 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9295 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9297 sym_op->m_src = ut_params->ibuf;
9299 sym_op->cipher.data.offset = 0;
9300 sym_op->cipher.data.length = QUOTE_512_BYTES;
9302 sym_op->auth.data.offset = 0;
9303 sym_op->auth.data.length = QUOTE_512_BYTES;
9304 sym_op->auth.digest.data = digest;
9305 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9308 /* Process crypto operation */
9309 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9311 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9313 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9314 "crypto operation processing failed");
9317 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9318 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9321 "Ciphertext data not as expected");
9322 /* Make sure memory pointed to by digest hasn't been overwritten */
9323 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9327 "Memory at digest ptr overwritten unexpectedly");
9329 return TEST_SUCCESS;
9333 test_null_auth_cipher_operation(void)
9335 struct crypto_testsuite_params *ts_params = &testsuite_params;
9336 struct crypto_unittest_params *ut_params = &unittest_params;
9339 /* Generate test mbuf data */
9340 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9341 catch_22_quote, QUOTE_512_BYTES, 0);
9343 /* create a pointer for digest, but don't expect anything to be written
9344 * here in a NULL auth algo so no mbuf append done.
9346 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9348 /* prefill the memory pointed to by digest */
9349 memcpy(digest, orig_data, sizeof(orig_data));
9351 /* Setup Cipher Parameters */
9352 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9353 ut_params->cipher_xform.next = NULL;
9355 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9356 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9358 /* Setup HMAC Parameters */
9359 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9360 ut_params->auth_xform.next = &ut_params->cipher_xform;
9362 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9363 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9365 ut_params->sess = rte_cryptodev_sym_session_create(
9366 ts_params->session_mpool);
9368 /* Create Crypto session*/
9369 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9370 ut_params->sess, &ut_params->cipher_xform,
9371 ts_params->session_priv_mpool);
9372 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9374 /* Generate Crypto op data structure */
9375 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9376 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9377 TEST_ASSERT_NOT_NULL(ut_params->op,
9378 "Failed to allocate symmetric crypto operation struct");
9380 /* Set crypto operation data parameters */
9381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9383 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9385 sym_op->m_src = ut_params->ibuf;
9387 sym_op->cipher.data.offset = 0;
9388 sym_op->cipher.data.length = QUOTE_512_BYTES;
9390 sym_op->auth.data.offset = 0;
9391 sym_op->auth.data.length = QUOTE_512_BYTES;
9392 sym_op->auth.digest.data = digest;
9393 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9396 /* Process crypto operation */
9397 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9399 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9401 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9402 "crypto operation processing failed");
9405 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9406 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9409 "Ciphertext data not as expected");
9410 /* Make sure memory pointed to by digest hasn't been overwritten */
9411 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9415 "Memory at digest ptr overwritten unexpectedly");
9417 return TEST_SUCCESS;
9422 test_null_invalid_operation(void)
9424 struct crypto_testsuite_params *ts_params = &testsuite_params;
9425 struct crypto_unittest_params *ut_params = &unittest_params;
9428 /* Setup Cipher Parameters */
9429 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9430 ut_params->cipher_xform.next = NULL;
9432 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9433 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9435 ut_params->sess = rte_cryptodev_sym_session_create(
9436 ts_params->session_mpool);
9438 /* Create Crypto session*/
9439 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9440 ut_params->sess, &ut_params->cipher_xform,
9441 ts_params->session_priv_mpool);
9442 TEST_ASSERT(ret < 0,
9443 "Session creation succeeded unexpectedly");
9446 /* Setup HMAC Parameters */
9447 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9448 ut_params->auth_xform.next = NULL;
9450 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9451 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9453 ut_params->sess = rte_cryptodev_sym_session_create(
9454 ts_params->session_mpool);
9456 /* Create Crypto session*/
9457 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9458 ut_params->sess, &ut_params->auth_xform,
9459 ts_params->session_priv_mpool);
9460 TEST_ASSERT(ret < 0,
9461 "Session creation succeeded unexpectedly");
9463 return TEST_SUCCESS;
9467 #define NULL_BURST_LENGTH (32)
9470 test_null_burst_operation(void)
9472 struct crypto_testsuite_params *ts_params = &testsuite_params;
9473 struct crypto_unittest_params *ut_params = &unittest_params;
9475 unsigned i, burst_len = NULL_BURST_LENGTH;
9477 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9478 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9480 /* Setup Cipher Parameters */
9481 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9482 ut_params->cipher_xform.next = &ut_params->auth_xform;
9484 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9485 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9487 /* Setup HMAC Parameters */
9488 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9489 ut_params->auth_xform.next = NULL;
9491 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9492 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9494 ut_params->sess = rte_cryptodev_sym_session_create(
9495 ts_params->session_mpool);
9497 /* Create Crypto session*/
9498 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9499 ut_params->sess, &ut_params->cipher_xform,
9500 ts_params->session_priv_mpool);
9501 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9503 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9504 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9505 burst_len, "failed to generate burst of crypto ops");
9507 /* Generate an operation for each mbuf in burst */
9508 for (i = 0; i < burst_len; i++) {
9509 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9511 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9513 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9517 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9519 burst[i]->sym->m_src = m;
9522 /* Process crypto operation */
9523 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9524 0, burst, burst_len),
9526 "Error enqueuing burst");
9528 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9529 0, burst_dequeued, burst_len),
9531 "Error dequeuing burst");
9534 for (i = 0; i < burst_len; i++) {
9536 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9537 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9539 "data not as expected");
9541 rte_pktmbuf_free(burst[i]->sym->m_src);
9542 rte_crypto_op_free(burst[i]);
9545 return TEST_SUCCESS;
9549 generate_gmac_large_plaintext(uint8_t *data)
9553 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9554 memcpy(&data[i], &data[0], 32);
9558 create_gmac_operation(enum rte_crypto_auth_operation op,
9559 const struct gmac_test_data *tdata)
9561 struct crypto_testsuite_params *ts_params = &testsuite_params;
9562 struct crypto_unittest_params *ut_params = &unittest_params;
9563 struct rte_crypto_sym_op *sym_op;
9565 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9567 /* Generate Crypto op data structure */
9568 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9569 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9570 TEST_ASSERT_NOT_NULL(ut_params->op,
9571 "Failed to allocate symmetric crypto operation struct");
9573 sym_op = ut_params->op->sym;
9575 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9576 ut_params->ibuf, tdata->gmac_tag.len);
9577 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9578 "no room to append digest");
9580 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9581 ut_params->ibuf, plaintext_pad_len);
9583 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9584 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9585 tdata->gmac_tag.len);
9586 debug_hexdump(stdout, "digest:",
9587 sym_op->auth.digest.data,
9588 tdata->gmac_tag.len);
9591 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9592 uint8_t *, IV_OFFSET);
9594 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9596 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9598 sym_op->cipher.data.length = 0;
9599 sym_op->cipher.data.offset = 0;
9601 sym_op->auth.data.offset = 0;
9602 sym_op->auth.data.length = tdata->plaintext.len;
9607 static int create_gmac_session(uint8_t dev_id,
9608 const struct gmac_test_data *tdata,
9609 enum rte_crypto_auth_operation auth_op)
9611 uint8_t auth_key[tdata->key.len];
9613 struct crypto_testsuite_params *ts_params = &testsuite_params;
9614 struct crypto_unittest_params *ut_params = &unittest_params;
9616 memcpy(auth_key, tdata->key.data, tdata->key.len);
9618 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9619 ut_params->auth_xform.next = NULL;
9621 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9622 ut_params->auth_xform.auth.op = auth_op;
9623 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9624 ut_params->auth_xform.auth.key.length = tdata->key.len;
9625 ut_params->auth_xform.auth.key.data = auth_key;
9626 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9627 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9630 ut_params->sess = rte_cryptodev_sym_session_create(
9631 ts_params->session_mpool);
9633 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9634 &ut_params->auth_xform,
9635 ts_params->session_priv_mpool);
9637 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9643 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9645 struct crypto_testsuite_params *ts_params = &testsuite_params;
9646 struct crypto_unittest_params *ut_params = &unittest_params;
9650 uint8_t *auth_tag, *plaintext;
9651 uint16_t plaintext_pad_len;
9653 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9654 "No GMAC length in the source data");
9656 retval = create_gmac_session(ts_params->valid_devs[0],
9657 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9662 if (tdata->plaintext.len > MBUF_SIZE)
9663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9665 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9666 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9667 "Failed to allocate input buffer in mempool");
9669 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9670 rte_pktmbuf_tailroom(ut_params->ibuf));
9672 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9674 * Runtime generate the large plain text instead of use hard code
9675 * plain text vector. It is done to avoid create huge source file
9676 * with the test vector.
9678 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9679 generate_gmac_large_plaintext(tdata->plaintext.data);
9681 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9683 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9685 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9686 debug_hexdump(stdout, "plaintext:", plaintext,
9687 tdata->plaintext.len);
9689 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9695 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9697 ut_params->op->sym->m_src = ut_params->ibuf;
9699 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9700 ut_params->op), "failed to process sym crypto op");
9702 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9703 "crypto op processing failed");
9705 if (ut_params->op->sym->m_dst) {
9706 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9707 uint8_t *, plaintext_pad_len);
9709 auth_tag = plaintext + plaintext_pad_len;
9712 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9714 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9716 tdata->gmac_tag.data,
9717 tdata->gmac_tag.len,
9718 "GMAC Generated auth tag not as expected");
9724 test_AES_GMAC_authentication_test_case_1(void)
9726 return test_AES_GMAC_authentication(&gmac_test_case_1);
9730 test_AES_GMAC_authentication_test_case_2(void)
9732 return test_AES_GMAC_authentication(&gmac_test_case_2);
9736 test_AES_GMAC_authentication_test_case_3(void)
9738 return test_AES_GMAC_authentication(&gmac_test_case_3);
9742 test_AES_GMAC_authentication_test_case_4(void)
9744 return test_AES_GMAC_authentication(&gmac_test_case_4);
9748 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9750 struct crypto_testsuite_params *ts_params = &testsuite_params;
9751 struct crypto_unittest_params *ut_params = &unittest_params;
9753 uint32_t plaintext_pad_len;
9756 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9757 "No GMAC length in the source data");
9759 retval = create_gmac_session(ts_params->valid_devs[0],
9760 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9765 if (tdata->plaintext.len > MBUF_SIZE)
9766 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9768 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9769 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9770 "Failed to allocate input buffer in mempool");
9772 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9773 rte_pktmbuf_tailroom(ut_params->ibuf));
9775 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9778 * Runtime generate the large plain text instead of use hard code
9779 * plain text vector. It is done to avoid create huge source file
9780 * with the test vector.
9782 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9783 generate_gmac_large_plaintext(tdata->plaintext.data);
9785 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9787 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9789 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9790 debug_hexdump(stdout, "plaintext:", plaintext,
9791 tdata->plaintext.len);
9793 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9799 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9801 ut_params->op->sym->m_src = ut_params->ibuf;
9803 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9804 ut_params->op), "failed to process sym crypto op");
9806 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9807 "crypto op processing failed");
9814 test_AES_GMAC_authentication_verify_test_case_1(void)
9816 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9820 test_AES_GMAC_authentication_verify_test_case_2(void)
9822 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9826 test_AES_GMAC_authentication_verify_test_case_3(void)
9828 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
9832 test_AES_GMAC_authentication_verify_test_case_4(void)
9834 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
9837 struct test_crypto_vector {
9838 enum rte_crypto_cipher_algorithm crypto_algo;
9839 unsigned int cipher_offset;
9840 unsigned int cipher_len;
9853 const uint8_t *data;
9858 const uint8_t *data;
9862 enum rte_crypto_auth_algorithm auth_algo;
9863 unsigned int auth_offset;
9871 const uint8_t *data;
9881 static const struct test_crypto_vector
9882 hmac_sha1_test_crypto_vector = {
9883 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9885 .data = plaintext_hash,
9890 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9891 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9892 0xDE, 0xF4, 0xDE, 0xAD
9898 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9899 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9900 0x3F, 0x91, 0x64, 0x59
9906 static const struct test_crypto_vector
9907 aes128_gmac_test_vector = {
9908 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9910 .data = plaintext_hash,
9915 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9916 0x08, 0x09, 0x0A, 0x0B
9922 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9923 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9929 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9930 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9936 static const struct test_crypto_vector
9937 aes128cbc_hmac_sha1_test_vector = {
9938 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9943 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9944 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9950 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9951 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9956 .data = plaintext_hash,
9960 .data = ciphertext512_aes128cbc,
9963 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9967 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9968 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9969 0xDE, 0xF4, 0xDE, 0xAD
9975 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9976 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9977 0x18, 0x8C, 0x1D, 0x32
9983 static const struct test_crypto_vector
9984 aes128cbc_hmac_sha1_aad_test_vector = {
9985 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9986 .cipher_offset = 12,
9990 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9991 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9997 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9998 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10003 .data = plaintext_hash,
10007 .data = ciphertext512_aes128cbc_aad,
10010 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10014 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10015 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10016 0xDE, 0xF4, 0xDE, 0xAD
10022 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10023 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10024 0x62, 0x8D, 0x62, 0x65
10031 data_corruption(uint8_t *data)
10037 tag_corruption(uint8_t *data, unsigned int tag_offset)
10039 data[tag_offset] += 1;
10043 create_auth_session(struct crypto_unittest_params *ut_params,
10045 const struct test_crypto_vector *reference,
10046 enum rte_crypto_auth_operation auth_op)
10048 struct crypto_testsuite_params *ts_params = &testsuite_params;
10049 uint8_t auth_key[reference->auth_key.len + 1];
10051 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10053 /* Setup Authentication Parameters */
10054 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10055 ut_params->auth_xform.auth.op = auth_op;
10056 ut_params->auth_xform.next = NULL;
10057 ut_params->auth_xform.auth.algo = reference->auth_algo;
10058 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10059 ut_params->auth_xform.auth.key.data = auth_key;
10060 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10062 /* Create Crypto session*/
10063 ut_params->sess = rte_cryptodev_sym_session_create(
10064 ts_params->session_mpool);
10066 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10067 &ut_params->auth_xform,
10068 ts_params->session_priv_mpool);
10070 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10076 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10078 const struct test_crypto_vector *reference,
10079 enum rte_crypto_auth_operation auth_op,
10080 enum rte_crypto_cipher_operation cipher_op)
10082 struct crypto_testsuite_params *ts_params = &testsuite_params;
10083 uint8_t cipher_key[reference->cipher_key.len + 1];
10084 uint8_t auth_key[reference->auth_key.len + 1];
10086 memcpy(cipher_key, reference->cipher_key.data,
10087 reference->cipher_key.len);
10088 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10090 /* Setup Authentication Parameters */
10091 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10092 ut_params->auth_xform.auth.op = auth_op;
10093 ut_params->auth_xform.auth.algo = reference->auth_algo;
10094 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10095 ut_params->auth_xform.auth.key.data = auth_key;
10096 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10098 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10099 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10100 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10102 ut_params->auth_xform.next = &ut_params->cipher_xform;
10104 /* Setup Cipher Parameters */
10105 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10106 ut_params->cipher_xform.next = NULL;
10107 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10108 ut_params->cipher_xform.cipher.op = cipher_op;
10109 ut_params->cipher_xform.cipher.key.data = cipher_key;
10110 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10111 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10112 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10115 /* Create Crypto session*/
10116 ut_params->sess = rte_cryptodev_sym_session_create(
10117 ts_params->session_mpool);
10119 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10120 &ut_params->auth_xform,
10121 ts_params->session_priv_mpool);
10123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10129 create_auth_operation(struct crypto_testsuite_params *ts_params,
10130 struct crypto_unittest_params *ut_params,
10131 const struct test_crypto_vector *reference,
10132 unsigned int auth_generate)
10134 /* Generate Crypto op data structure */
10135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10137 TEST_ASSERT_NOT_NULL(ut_params->op,
10138 "Failed to allocate pktmbuf offload");
10140 /* Set crypto operation data parameters */
10141 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10145 /* set crypto operation source mbuf */
10146 sym_op->m_src = ut_params->ibuf;
10149 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10150 ut_params->ibuf, reference->digest.len);
10152 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10153 "no room to append auth tag");
10155 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10156 ut_params->ibuf, reference->plaintext.len);
10159 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10161 memcpy(sym_op->auth.digest.data,
10162 reference->digest.data,
10163 reference->digest.len);
10165 debug_hexdump(stdout, "digest:",
10166 sym_op->auth.digest.data,
10167 reference->digest.len);
10169 sym_op->auth.data.length = reference->plaintext.len;
10170 sym_op->auth.data.offset = 0;
10176 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10177 struct crypto_unittest_params *ut_params,
10178 const struct test_crypto_vector *reference,
10179 unsigned int auth_generate)
10181 /* Generate Crypto op data structure */
10182 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10183 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10184 TEST_ASSERT_NOT_NULL(ut_params->op,
10185 "Failed to allocate pktmbuf offload");
10187 /* Set crypto operation data parameters */
10188 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10190 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10192 /* set crypto operation source mbuf */
10193 sym_op->m_src = ut_params->ibuf;
10196 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10197 ut_params->ibuf, reference->digest.len);
10199 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10200 "no room to append auth tag");
10202 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10203 ut_params->ibuf, reference->ciphertext.len);
10206 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10208 memcpy(sym_op->auth.digest.data,
10209 reference->digest.data,
10210 reference->digest.len);
10212 debug_hexdump(stdout, "digest:",
10213 sym_op->auth.digest.data,
10214 reference->digest.len);
10216 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10217 reference->iv.data, reference->iv.len);
10219 sym_op->cipher.data.length = 0;
10220 sym_op->cipher.data.offset = 0;
10222 sym_op->auth.data.length = reference->plaintext.len;
10223 sym_op->auth.data.offset = 0;
10229 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10230 struct crypto_unittest_params *ut_params,
10231 const struct test_crypto_vector *reference,
10232 unsigned int auth_generate)
10234 /* Generate Crypto op data structure */
10235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10237 TEST_ASSERT_NOT_NULL(ut_params->op,
10238 "Failed to allocate pktmbuf offload");
10240 /* Set crypto operation data parameters */
10241 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10243 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10245 /* set crypto operation source mbuf */
10246 sym_op->m_src = ut_params->ibuf;
10249 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10250 ut_params->ibuf, reference->digest.len);
10252 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10253 "no room to append auth tag");
10255 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10256 ut_params->ibuf, reference->ciphertext.len);
10259 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10261 memcpy(sym_op->auth.digest.data,
10262 reference->digest.data,
10263 reference->digest.len);
10265 debug_hexdump(stdout, "digest:",
10266 sym_op->auth.digest.data,
10267 reference->digest.len);
10269 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10270 reference->iv.data, reference->iv.len);
10272 sym_op->cipher.data.length = reference->cipher_len;
10273 sym_op->cipher.data.offset = reference->cipher_offset;
10275 sym_op->auth.data.length = reference->plaintext.len;
10276 sym_op->auth.data.offset = reference->auth_offset;
10282 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10283 struct crypto_unittest_params *ut_params,
10284 const struct test_crypto_vector *reference)
10286 return create_auth_operation(ts_params, ut_params, reference, 0);
10290 create_auth_verify_GMAC_operation(
10291 struct crypto_testsuite_params *ts_params,
10292 struct crypto_unittest_params *ut_params,
10293 const struct test_crypto_vector *reference)
10295 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10299 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10300 struct crypto_unittest_params *ut_params,
10301 const struct test_crypto_vector *reference)
10303 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10307 test_authentication_verify_fail_when_data_corruption(
10308 struct crypto_testsuite_params *ts_params,
10309 struct crypto_unittest_params *ut_params,
10310 const struct test_crypto_vector *reference,
10311 unsigned int data_corrupted)
10315 uint8_t *plaintext;
10317 /* Create session */
10318 retval = create_auth_session(ut_params,
10319 ts_params->valid_devs[0],
10321 RTE_CRYPTO_AUTH_OP_VERIFY);
10325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10326 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10327 "Failed to allocate input buffer in mempool");
10329 /* clear mbuf payload */
10330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10331 rte_pktmbuf_tailroom(ut_params->ibuf));
10333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10334 reference->plaintext.len);
10335 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10336 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10338 debug_hexdump(stdout, "plaintext:", plaintext,
10339 reference->plaintext.len);
10341 /* Create operation */
10342 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10347 if (data_corrupted)
10348 data_corruption(plaintext);
10350 tag_corruption(plaintext, reference->plaintext.len);
10352 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10354 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10355 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10356 RTE_CRYPTO_OP_STATUS_SUCCESS,
10357 "authentication not failed");
10359 ut_params->obuf = ut_params->op->sym->m_src;
10360 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10366 test_authentication_verify_GMAC_fail_when_corruption(
10367 struct crypto_testsuite_params *ts_params,
10368 struct crypto_unittest_params *ut_params,
10369 const struct test_crypto_vector *reference,
10370 unsigned int data_corrupted)
10373 uint8_t *plaintext;
10375 /* Create session */
10376 retval = create_auth_cipher_session(ut_params,
10377 ts_params->valid_devs[0],
10379 RTE_CRYPTO_AUTH_OP_VERIFY,
10380 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10385 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10386 "Failed to allocate input buffer in mempool");
10388 /* clear mbuf payload */
10389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10390 rte_pktmbuf_tailroom(ut_params->ibuf));
10392 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10393 reference->plaintext.len);
10394 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10395 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10397 debug_hexdump(stdout, "plaintext:", plaintext,
10398 reference->plaintext.len);
10400 /* Create operation */
10401 retval = create_auth_verify_GMAC_operation(ts_params,
10408 if (data_corrupted)
10409 data_corruption(plaintext);
10411 tag_corruption(plaintext, reference->aad.len);
10413 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10415 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10416 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10417 RTE_CRYPTO_OP_STATUS_SUCCESS,
10418 "authentication not failed");
10420 ut_params->obuf = ut_params->op->sym->m_src;
10421 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10427 test_authenticated_decryption_fail_when_corruption(
10428 struct crypto_testsuite_params *ts_params,
10429 struct crypto_unittest_params *ut_params,
10430 const struct test_crypto_vector *reference,
10431 unsigned int data_corrupted)
10435 uint8_t *ciphertext;
10437 /* Create session */
10438 retval = create_auth_cipher_session(ut_params,
10439 ts_params->valid_devs[0],
10441 RTE_CRYPTO_AUTH_OP_VERIFY,
10442 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10446 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10447 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10448 "Failed to allocate input buffer in mempool");
10450 /* clear mbuf payload */
10451 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10452 rte_pktmbuf_tailroom(ut_params->ibuf));
10454 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10455 reference->ciphertext.len);
10456 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10457 memcpy(ciphertext, reference->ciphertext.data,
10458 reference->ciphertext.len);
10460 /* Create operation */
10461 retval = create_cipher_auth_verify_operation(ts_params,
10468 if (data_corrupted)
10469 data_corruption(ciphertext);
10471 tag_corruption(ciphertext, reference->ciphertext.len);
10473 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10476 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10477 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10478 RTE_CRYPTO_OP_STATUS_SUCCESS,
10479 "authentication not failed");
10481 ut_params->obuf = ut_params->op->sym->m_src;
10482 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10488 test_authenticated_encryt_with_esn(
10489 struct crypto_testsuite_params *ts_params,
10490 struct crypto_unittest_params *ut_params,
10491 const struct test_crypto_vector *reference)
10495 uint8_t *authciphertext, *plaintext, *auth_tag;
10496 uint16_t plaintext_pad_len;
10497 uint8_t cipher_key[reference->cipher_key.len + 1];
10498 uint8_t auth_key[reference->auth_key.len + 1];
10500 /* Create session */
10501 memcpy(cipher_key, reference->cipher_key.data,
10502 reference->cipher_key.len);
10503 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10505 /* Setup Cipher Parameters */
10506 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10507 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10508 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10509 ut_params->cipher_xform.cipher.key.data = cipher_key;
10510 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10511 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10512 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10514 ut_params->cipher_xform.next = &ut_params->auth_xform;
10516 /* Setup Authentication Parameters */
10517 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10518 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10519 ut_params->auth_xform.auth.algo = reference->auth_algo;
10520 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10521 ut_params->auth_xform.auth.key.data = auth_key;
10522 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10523 ut_params->auth_xform.next = NULL;
10525 /* Create Crypto session*/
10526 ut_params->sess = rte_cryptodev_sym_session_create(
10527 ts_params->session_mpool);
10529 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10531 &ut_params->cipher_xform,
10532 ts_params->session_priv_mpool);
10534 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10536 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10537 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10538 "Failed to allocate input buffer in mempool");
10540 /* clear mbuf payload */
10541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10542 rte_pktmbuf_tailroom(ut_params->ibuf));
10544 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10545 reference->plaintext.len);
10546 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10547 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10549 /* Create operation */
10550 retval = create_cipher_auth_operation(ts_params,
10557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10560 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10562 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10563 "crypto op processing failed");
10565 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10567 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10568 ut_params->op->sym->auth.data.offset);
10569 auth_tag = authciphertext + plaintext_pad_len;
10570 debug_hexdump(stdout, "ciphertext:", authciphertext,
10571 reference->ciphertext.len);
10572 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10574 /* Validate obuf */
10575 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10577 reference->ciphertext.data,
10578 reference->ciphertext.len,
10579 "Ciphertext data not as expected");
10581 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10583 reference->digest.data,
10584 reference->digest.len,
10585 "Generated digest not as expected");
10587 return TEST_SUCCESS;
10592 test_authenticated_decrypt_with_esn(
10593 struct crypto_testsuite_params *ts_params,
10594 struct crypto_unittest_params *ut_params,
10595 const struct test_crypto_vector *reference)
10599 uint8_t *ciphertext;
10600 uint8_t cipher_key[reference->cipher_key.len + 1];
10601 uint8_t auth_key[reference->auth_key.len + 1];
10603 /* Create session */
10604 memcpy(cipher_key, reference->cipher_key.data,
10605 reference->cipher_key.len);
10606 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10608 /* Setup Authentication Parameters */
10609 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10610 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10611 ut_params->auth_xform.auth.algo = reference->auth_algo;
10612 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10613 ut_params->auth_xform.auth.key.data = auth_key;
10614 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10615 ut_params->auth_xform.next = &ut_params->cipher_xform;
10617 /* Setup Cipher Parameters */
10618 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10619 ut_params->cipher_xform.next = NULL;
10620 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10621 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10622 ut_params->cipher_xform.cipher.key.data = cipher_key;
10623 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10624 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10625 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10627 /* Create Crypto session*/
10628 ut_params->sess = rte_cryptodev_sym_session_create(
10629 ts_params->session_mpool);
10631 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10633 &ut_params->auth_xform,
10634 ts_params->session_priv_mpool);
10636 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10638 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10639 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10640 "Failed to allocate input buffer in mempool");
10642 /* clear mbuf payload */
10643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10644 rte_pktmbuf_tailroom(ut_params->ibuf));
10646 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10647 reference->ciphertext.len);
10648 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10649 memcpy(ciphertext, reference->ciphertext.data,
10650 reference->ciphertext.len);
10652 /* Create operation */
10653 retval = create_cipher_auth_verify_operation(ts_params,
10660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10663 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10664 TEST_ASSERT_EQUAL(ut_params->op->status,
10665 RTE_CRYPTO_OP_STATUS_SUCCESS,
10666 "crypto op processing passed");
10668 ut_params->obuf = ut_params->op->sym->m_src;
10669 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10675 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10676 const struct aead_test_data *tdata,
10677 void *digest_mem, uint64_t digest_phys)
10679 struct crypto_testsuite_params *ts_params = &testsuite_params;
10680 struct crypto_unittest_params *ut_params = &unittest_params;
10682 const unsigned int auth_tag_len = tdata->auth_tag.len;
10683 const unsigned int iv_len = tdata->iv.len;
10684 unsigned int aad_len = tdata->aad.len;
10686 /* Generate Crypto op data structure */
10687 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10688 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10689 TEST_ASSERT_NOT_NULL(ut_params->op,
10690 "Failed to allocate symmetric crypto operation struct");
10692 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10694 sym_op->aead.digest.data = digest_mem;
10696 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10697 "no room to append digest");
10699 sym_op->aead.digest.phys_addr = digest_phys;
10701 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10702 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10704 debug_hexdump(stdout, "digest:",
10705 sym_op->aead.digest.data,
10709 /* Append aad data */
10710 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10711 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10712 uint8_t *, IV_OFFSET);
10714 /* Copy IV 1 byte after the IV pointer, according to the API */
10715 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10717 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10719 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10720 ut_params->ibuf, aad_len);
10721 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10722 "no room to prepend aad");
10723 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10726 memset(sym_op->aead.aad.data, 0, aad_len);
10727 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10728 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10730 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10731 debug_hexdump(stdout, "aad:",
10732 sym_op->aead.aad.data, aad_len);
10734 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10735 uint8_t *, IV_OFFSET);
10737 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10739 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10740 ut_params->ibuf, aad_len);
10741 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10742 "no room to prepend aad");
10743 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10746 memset(sym_op->aead.aad.data, 0, aad_len);
10747 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10749 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10750 debug_hexdump(stdout, "aad:",
10751 sym_op->aead.aad.data, aad_len);
10754 sym_op->aead.data.length = tdata->plaintext.len;
10755 sym_op->aead.data.offset = aad_len;
10760 #define SGL_MAX_NO 16
10763 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10764 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10766 struct crypto_testsuite_params *ts_params = &testsuite_params;
10767 struct crypto_unittest_params *ut_params = &unittest_params;
10768 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10771 int to_trn_tbl[SGL_MAX_NO];
10773 unsigned int trn_data = 0;
10774 uint8_t *plaintext, *ciphertext, *auth_tag;
10776 if (fragsz > tdata->plaintext.len)
10777 fragsz = tdata->plaintext.len;
10779 uint16_t plaintext_len = fragsz;
10780 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
10782 if (fragsz_oop > tdata->plaintext.len)
10783 frag_size_oop = tdata->plaintext.len;
10786 void *digest_mem = NULL;
10788 uint32_t prepend_len = tdata->aad.len;
10790 if (tdata->plaintext.len % fragsz != 0) {
10791 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
10794 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
10799 * For out-op-place we need to alloc another mbuf
10802 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10803 rte_pktmbuf_append(ut_params->obuf,
10804 frag_size_oop + prepend_len);
10805 buf_oop = ut_params->obuf;
10808 /* Create AEAD session */
10809 retval = create_aead_session(ts_params->valid_devs[0],
10811 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10812 tdata->key.data, tdata->key.len,
10813 tdata->aad.len, tdata->auth_tag.len,
10818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10820 /* clear mbuf payload */
10821 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10822 rte_pktmbuf_tailroom(ut_params->ibuf));
10824 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10827 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10829 trn_data += plaintext_len;
10831 buf = ut_params->ibuf;
10834 * Loop until no more fragments
10837 while (trn_data < tdata->plaintext.len) {
10839 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10840 (tdata->plaintext.len - trn_data) : fragsz;
10842 to_trn_tbl[ecx++] = to_trn;
10844 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10847 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10848 rte_pktmbuf_tailroom(buf));
10851 if (oop && !fragsz_oop) {
10852 buf_last_oop = buf_oop->next =
10853 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10854 buf_oop = buf_oop->next;
10855 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10856 0, rte_pktmbuf_tailroom(buf_oop));
10857 rte_pktmbuf_append(buf_oop, to_trn);
10860 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10863 memcpy(plaintext, tdata->plaintext.data + trn_data,
10865 trn_data += to_trn;
10866 if (trn_data == tdata->plaintext.len) {
10869 digest_mem = rte_pktmbuf_append(buf_oop,
10870 tdata->auth_tag.len);
10872 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10873 tdata->auth_tag.len);
10877 uint64_t digest_phys = 0;
10879 ut_params->ibuf->nb_segs = segs;
10882 if (fragsz_oop && oop) {
10886 if (frag_size_oop == tdata->plaintext.len) {
10887 digest_mem = rte_pktmbuf_append(ut_params->obuf,
10888 tdata->auth_tag.len);
10890 digest_phys = rte_pktmbuf_iova_offset(
10892 tdata->plaintext.len + prepend_len);
10895 trn_data = frag_size_oop;
10896 while (trn_data < tdata->plaintext.len) {
10899 (tdata->plaintext.len - trn_data <
10901 (tdata->plaintext.len - trn_data) :
10904 to_trn_tbl[ecx++] = to_trn;
10906 buf_last_oop = buf_oop->next =
10907 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10908 buf_oop = buf_oop->next;
10909 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10910 0, rte_pktmbuf_tailroom(buf_oop));
10911 rte_pktmbuf_append(buf_oop, to_trn);
10913 trn_data += to_trn;
10915 if (trn_data == tdata->plaintext.len) {
10916 digest_mem = rte_pktmbuf_append(buf_oop,
10917 tdata->auth_tag.len);
10921 ut_params->obuf->nb_segs = segs;
10925 * Place digest at the end of the last buffer
10928 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
10929 if (oop && buf_last_oop)
10930 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
10932 if (!digest_mem && !oop) {
10933 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10934 + tdata->auth_tag.len);
10935 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
10936 tdata->plaintext.len);
10939 /* Create AEAD operation */
10940 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
10941 tdata, digest_mem, digest_phys);
10946 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10948 ut_params->op->sym->m_src = ut_params->ibuf;
10950 ut_params->op->sym->m_dst = ut_params->obuf;
10952 /* Process crypto operation */
10953 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10954 ut_params->op), "failed to process sym crypto op");
10956 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10957 "crypto op processing failed");
10960 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10961 uint8_t *, prepend_len);
10963 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10964 uint8_t *, prepend_len);
10968 fragsz = fragsz_oop;
10970 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10972 tdata->ciphertext.data,
10974 "Ciphertext data not as expected");
10976 buf = ut_params->op->sym->m_src->next;
10978 buf = ut_params->op->sym->m_dst->next;
10980 unsigned int off = fragsz;
10984 ciphertext = rte_pktmbuf_mtod(buf,
10987 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10989 tdata->ciphertext.data + off,
10991 "Ciphertext data not as expected");
10993 off += to_trn_tbl[ecx++];
10997 auth_tag = digest_mem;
10998 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11000 tdata->auth_tag.data,
11001 tdata->auth_tag.len,
11002 "Generated auth tag not as expected");
11008 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11010 return test_authenticated_encryption_SGL(
11011 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11015 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11017 return test_authenticated_encryption_SGL(
11018 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11022 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11024 return test_authenticated_encryption_SGL(
11025 &gcm_test_case_8, OUT_OF_PLACE, 400,
11026 gcm_test_case_8.plaintext.len);
11030 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11033 return test_authenticated_encryption_SGL(
11034 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11038 test_authentication_verify_fail_when_data_corrupted(
11039 struct crypto_testsuite_params *ts_params,
11040 struct crypto_unittest_params *ut_params,
11041 const struct test_crypto_vector *reference)
11043 return test_authentication_verify_fail_when_data_corruption(
11044 ts_params, ut_params, reference, 1);
11048 test_authentication_verify_fail_when_tag_corrupted(
11049 struct crypto_testsuite_params *ts_params,
11050 struct crypto_unittest_params *ut_params,
11051 const struct test_crypto_vector *reference)
11053 return test_authentication_verify_fail_when_data_corruption(
11054 ts_params, ut_params, reference, 0);
11058 test_authentication_verify_GMAC_fail_when_data_corrupted(
11059 struct crypto_testsuite_params *ts_params,
11060 struct crypto_unittest_params *ut_params,
11061 const struct test_crypto_vector *reference)
11063 return test_authentication_verify_GMAC_fail_when_corruption(
11064 ts_params, ut_params, reference, 1);
11068 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11069 struct crypto_testsuite_params *ts_params,
11070 struct crypto_unittest_params *ut_params,
11071 const struct test_crypto_vector *reference)
11073 return test_authentication_verify_GMAC_fail_when_corruption(
11074 ts_params, ut_params, reference, 0);
11078 test_authenticated_decryption_fail_when_data_corrupted(
11079 struct crypto_testsuite_params *ts_params,
11080 struct crypto_unittest_params *ut_params,
11081 const struct test_crypto_vector *reference)
11083 return test_authenticated_decryption_fail_when_corruption(
11084 ts_params, ut_params, reference, 1);
11088 test_authenticated_decryption_fail_when_tag_corrupted(
11089 struct crypto_testsuite_params *ts_params,
11090 struct crypto_unittest_params *ut_params,
11091 const struct test_crypto_vector *reference)
11093 return test_authenticated_decryption_fail_when_corruption(
11094 ts_params, ut_params, reference, 0);
11098 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11100 return test_authentication_verify_fail_when_data_corrupted(
11101 &testsuite_params, &unittest_params,
11102 &hmac_sha1_test_crypto_vector);
11106 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11108 return test_authentication_verify_fail_when_tag_corrupted(
11109 &testsuite_params, &unittest_params,
11110 &hmac_sha1_test_crypto_vector);
11114 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11116 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11117 &testsuite_params, &unittest_params,
11118 &aes128_gmac_test_vector);
11122 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11124 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11125 &testsuite_params, &unittest_params,
11126 &aes128_gmac_test_vector);
11130 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11132 return test_authenticated_decryption_fail_when_data_corrupted(
11135 &aes128cbc_hmac_sha1_test_vector);
11139 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11141 return test_authenticated_decryption_fail_when_tag_corrupted(
11144 &aes128cbc_hmac_sha1_test_vector);
11148 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11150 return test_authenticated_encryt_with_esn(
11153 &aes128cbc_hmac_sha1_aad_test_vector);
11157 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11159 return test_authenticated_decrypt_with_esn(
11162 &aes128cbc_hmac_sha1_aad_test_vector);
11165 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11167 /* global AESNI slave IDs for the scheduler test */
11168 uint8_t aesni_ids[2];
11171 test_scheduler_attach_slave_op(void)
11173 struct crypto_testsuite_params *ts_params = &testsuite_params;
11174 uint8_t sched_id = ts_params->valid_devs[0];
11175 uint32_t nb_devs, i, nb_devs_attached = 0;
11177 char vdev_name[32];
11179 /* create 2 AESNI_MB if necessary */
11180 nb_devs = rte_cryptodev_device_count_by_driver(
11181 rte_cryptodev_driver_id_get(
11182 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11184 for (i = nb_devs; i < 2; i++) {
11185 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11186 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11188 ret = rte_vdev_init(vdev_name, NULL);
11190 TEST_ASSERT(ret == 0,
11191 "Failed to create instance %u of"
11193 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11197 /* attach 2 AESNI_MB cdevs */
11198 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11200 struct rte_cryptodev_info info;
11201 unsigned int session_size;
11203 rte_cryptodev_info_get(i, &info);
11204 if (info.driver_id != rte_cryptodev_driver_id_get(
11205 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11208 session_size = rte_cryptodev_sym_get_private_session_size(i);
11210 * Create the session mempool again, since now there are new devices
11211 * to use the mempool.
11213 if (ts_params->session_mpool) {
11214 rte_mempool_free(ts_params->session_mpool);
11215 ts_params->session_mpool = NULL;
11217 if (ts_params->session_priv_mpool) {
11218 rte_mempool_free(ts_params->session_priv_mpool);
11219 ts_params->session_priv_mpool = NULL;
11222 if (info.sym.max_nb_sessions != 0 &&
11223 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11224 RTE_LOG(ERR, USER1,
11225 "Device does not support "
11226 "at least %u sessions\n",
11228 return TEST_FAILED;
11231 * Create mempool with maximum number of sessions,
11232 * to include the session headers
11234 if (ts_params->session_mpool == NULL) {
11235 ts_params->session_mpool =
11236 rte_cryptodev_sym_session_pool_create(
11238 MAX_NB_SESSIONS, 0, 0, 0,
11240 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11241 "session mempool allocation failed");
11245 * Create mempool with maximum number of sessions,
11246 * to include device specific session private data
11248 if (ts_params->session_priv_mpool == NULL) {
11249 ts_params->session_priv_mpool = rte_mempool_create(
11250 "test_sess_mp_priv",
11253 0, 0, NULL, NULL, NULL,
11254 NULL, SOCKET_ID_ANY,
11257 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11258 "session mempool allocation failed");
11261 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11262 ts_params->qp_conf.mp_session_private =
11263 ts_params->session_priv_mpool;
11265 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11268 TEST_ASSERT(ret == 0,
11269 "Failed to attach device %u of pmd : %s", i,
11270 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11272 aesni_ids[nb_devs_attached] = (uint8_t)i;
11274 nb_devs_attached++;
11281 test_scheduler_detach_slave_op(void)
11283 struct crypto_testsuite_params *ts_params = &testsuite_params;
11284 uint8_t sched_id = ts_params->valid_devs[0];
11288 for (i = 0; i < 2; i++) {
11289 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11291 TEST_ASSERT(ret == 0,
11292 "Failed to detach device %u", aesni_ids[i]);
11299 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11301 struct crypto_testsuite_params *ts_params = &testsuite_params;
11302 uint8_t sched_id = ts_params->valid_devs[0];
11304 return rte_cryptodev_scheduler_mode_set(sched_id,
11309 test_scheduler_mode_roundrobin_op(void)
11311 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11312 0, "Failed to set roundrobin mode");
11318 test_scheduler_mode_multicore_op(void)
11320 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11321 0, "Failed to set multicore mode");
11327 test_scheduler_mode_failover_op(void)
11329 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11330 0, "Failed to set failover mode");
11336 test_scheduler_mode_pkt_size_distr_op(void)
11338 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11339 0, "Failed to set pktsize mode");
11344 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11345 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11346 .setup = testsuite_setup,
11347 .teardown = testsuite_teardown,
11348 .unit_test_cases = {
11350 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11351 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11352 TEST_CASE_ST(ut_setup, ut_teardown,
11353 test_AES_chain_scheduler_all),
11354 TEST_CASE_ST(ut_setup, ut_teardown,
11355 test_AES_cipheronly_scheduler_all),
11356 TEST_CASE_ST(ut_setup, ut_teardown,
11357 test_authonly_scheduler_all),
11358 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11361 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11362 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11363 TEST_CASE_ST(ut_setup, ut_teardown,
11364 test_AES_chain_scheduler_all),
11365 TEST_CASE_ST(ut_setup, ut_teardown,
11366 test_AES_cipheronly_scheduler_all),
11367 TEST_CASE_ST(ut_setup, ut_teardown,
11368 test_authonly_scheduler_all),
11369 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11372 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11373 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11374 TEST_CASE_ST(ut_setup, ut_teardown,
11375 test_AES_chain_scheduler_all),
11376 TEST_CASE_ST(ut_setup, ut_teardown,
11377 test_AES_cipheronly_scheduler_all),
11378 TEST_CASE_ST(ut_setup, ut_teardown,
11379 test_authonly_scheduler_all),
11380 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11383 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11384 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11385 TEST_CASE_ST(ut_setup, ut_teardown,
11386 test_AES_chain_scheduler_all),
11387 TEST_CASE_ST(ut_setup, ut_teardown,
11388 test_AES_cipheronly_scheduler_all),
11389 TEST_CASE_ST(ut_setup, ut_teardown,
11390 test_authonly_scheduler_all),
11391 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11393 TEST_CASES_END() /**< NULL terminate unit test array */
11397 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11399 static struct unit_test_suite cryptodev_qat_testsuite = {
11400 .suite_name = "Crypto QAT Unit Test Suite",
11401 .setup = testsuite_setup,
11402 .teardown = testsuite_teardown,
11403 .unit_test_cases = {
11404 TEST_CASE_ST(ut_setup, ut_teardown,
11405 test_device_configure_invalid_dev_id),
11406 TEST_CASE_ST(ut_setup, ut_teardown,
11407 test_device_configure_invalid_queue_pair_ids),
11408 TEST_CASE_ST(ut_setup, ut_teardown,
11409 test_queue_pair_descriptor_setup),
11410 TEST_CASE_ST(ut_setup, ut_teardown,
11411 test_multi_session),
11413 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11414 TEST_CASE_ST(ut_setup, ut_teardown,
11415 test_AES_cipheronly_qat_all),
11416 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11417 TEST_CASE_ST(ut_setup, ut_teardown,
11418 test_3DES_cipheronly_qat_all),
11419 TEST_CASE_ST(ut_setup, ut_teardown,
11420 test_DES_cipheronly_qat_all),
11421 TEST_CASE_ST(ut_setup, ut_teardown,
11422 test_AES_docsis_qat_all),
11423 TEST_CASE_ST(ut_setup, ut_teardown,
11424 test_DES_docsis_qat_all),
11425 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11426 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11428 /** AES CCM Authenticated Encryption 128 bits key */
11429 TEST_CASE_ST(ut_setup, ut_teardown,
11430 test_AES_CCM_authenticated_encryption_test_case_128_1),
11431 TEST_CASE_ST(ut_setup, ut_teardown,
11432 test_AES_CCM_authenticated_encryption_test_case_128_2),
11433 TEST_CASE_ST(ut_setup, ut_teardown,
11434 test_AES_CCM_authenticated_encryption_test_case_128_3),
11436 /** AES CCM Authenticated Decryption 128 bits key*/
11437 TEST_CASE_ST(ut_setup, ut_teardown,
11438 test_AES_CCM_authenticated_decryption_test_case_128_1),
11439 TEST_CASE_ST(ut_setup, ut_teardown,
11440 test_AES_CCM_authenticated_decryption_test_case_128_2),
11441 TEST_CASE_ST(ut_setup, ut_teardown,
11442 test_AES_CCM_authenticated_decryption_test_case_128_3),
11444 /** AES GCM Authenticated Encryption */
11445 TEST_CASE_ST(ut_setup, ut_teardown,
11446 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11447 TEST_CASE_ST(ut_setup, ut_teardown,
11448 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11449 TEST_CASE_ST(ut_setup, ut_teardown,
11450 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11451 TEST_CASE_ST(ut_setup, ut_teardown,
11452 test_AES_GCM_authenticated_encryption_test_case_1),
11453 TEST_CASE_ST(ut_setup, ut_teardown,
11454 test_AES_GCM_authenticated_encryption_test_case_2),
11455 TEST_CASE_ST(ut_setup, ut_teardown,
11456 test_AES_GCM_authenticated_encryption_test_case_3),
11457 TEST_CASE_ST(ut_setup, ut_teardown,
11458 test_AES_GCM_authenticated_encryption_test_case_4),
11459 TEST_CASE_ST(ut_setup, ut_teardown,
11460 test_AES_GCM_authenticated_encryption_test_case_5),
11461 TEST_CASE_ST(ut_setup, ut_teardown,
11462 test_AES_GCM_authenticated_encryption_test_case_6),
11463 TEST_CASE_ST(ut_setup, ut_teardown,
11464 test_AES_GCM_authenticated_encryption_test_case_7),
11465 TEST_CASE_ST(ut_setup, ut_teardown,
11466 test_AES_GCM_authenticated_encryption_test_case_8),
11468 /** AES GCM Authenticated Decryption */
11469 TEST_CASE_ST(ut_setup, ut_teardown,
11470 test_AES_GCM_authenticated_decryption_test_case_1),
11471 TEST_CASE_ST(ut_setup, ut_teardown,
11472 test_AES_GCM_authenticated_decryption_test_case_2),
11473 TEST_CASE_ST(ut_setup, ut_teardown,
11474 test_AES_GCM_authenticated_decryption_test_case_3),
11475 TEST_CASE_ST(ut_setup, ut_teardown,
11476 test_AES_GCM_authenticated_decryption_test_case_4),
11477 TEST_CASE_ST(ut_setup, ut_teardown,
11478 test_AES_GCM_authenticated_decryption_test_case_5),
11479 TEST_CASE_ST(ut_setup, ut_teardown,
11480 test_AES_GCM_authenticated_decryption_test_case_6),
11481 TEST_CASE_ST(ut_setup, ut_teardown,
11482 test_AES_GCM_authenticated_decryption_test_case_7),
11483 TEST_CASE_ST(ut_setup, ut_teardown,
11484 test_AES_GCM_authenticated_decryption_test_case_8),
11486 /** AES GCM Authenticated Encryption 192 bits key */
11487 TEST_CASE_ST(ut_setup, ut_teardown,
11488 test_AES_GCM_auth_encryption_test_case_192_1),
11489 TEST_CASE_ST(ut_setup, ut_teardown,
11490 test_AES_GCM_auth_encryption_test_case_192_2),
11491 TEST_CASE_ST(ut_setup, ut_teardown,
11492 test_AES_GCM_auth_encryption_test_case_192_3),
11493 TEST_CASE_ST(ut_setup, ut_teardown,
11494 test_AES_GCM_auth_encryption_test_case_192_4),
11495 TEST_CASE_ST(ut_setup, ut_teardown,
11496 test_AES_GCM_auth_encryption_test_case_192_5),
11497 TEST_CASE_ST(ut_setup, ut_teardown,
11498 test_AES_GCM_auth_encryption_test_case_192_6),
11499 TEST_CASE_ST(ut_setup, ut_teardown,
11500 test_AES_GCM_auth_encryption_test_case_192_7),
11502 /** AES GCM Authenticated Decryption 192 bits key */
11503 TEST_CASE_ST(ut_setup, ut_teardown,
11504 test_AES_GCM_auth_decryption_test_case_192_1),
11505 TEST_CASE_ST(ut_setup, ut_teardown,
11506 test_AES_GCM_auth_decryption_test_case_192_2),
11507 TEST_CASE_ST(ut_setup, ut_teardown,
11508 test_AES_GCM_auth_decryption_test_case_192_3),
11509 TEST_CASE_ST(ut_setup, ut_teardown,
11510 test_AES_GCM_auth_decryption_test_case_192_4),
11511 TEST_CASE_ST(ut_setup, ut_teardown,
11512 test_AES_GCM_auth_decryption_test_case_192_5),
11513 TEST_CASE_ST(ut_setup, ut_teardown,
11514 test_AES_GCM_auth_decryption_test_case_192_6),
11515 TEST_CASE_ST(ut_setup, ut_teardown,
11516 test_AES_GCM_auth_decryption_test_case_192_7),
11518 /** AES GCM Authenticated Encryption 256 bits key */
11519 TEST_CASE_ST(ut_setup, ut_teardown,
11520 test_AES_GCM_auth_encryption_test_case_256_1),
11521 TEST_CASE_ST(ut_setup, ut_teardown,
11522 test_AES_GCM_auth_encryption_test_case_256_2),
11523 TEST_CASE_ST(ut_setup, ut_teardown,
11524 test_AES_GCM_auth_encryption_test_case_256_3),
11525 TEST_CASE_ST(ut_setup, ut_teardown,
11526 test_AES_GCM_auth_encryption_test_case_256_4),
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_AES_GCM_auth_encryption_test_case_256_5),
11529 TEST_CASE_ST(ut_setup, ut_teardown,
11530 test_AES_GCM_auth_encryption_test_case_256_6),
11531 TEST_CASE_ST(ut_setup, ut_teardown,
11532 test_AES_GCM_auth_encryption_test_case_256_7),
11534 /** AES GCM Authenticated Decryption 256 bits key */
11535 TEST_CASE_ST(ut_setup, ut_teardown,
11536 test_AES_GCM_auth_decryption_test_case_256_1),
11537 TEST_CASE_ST(ut_setup, ut_teardown,
11538 test_AES_GCM_auth_decryption_test_case_256_2),
11539 TEST_CASE_ST(ut_setup, ut_teardown,
11540 test_AES_GCM_auth_decryption_test_case_256_3),
11541 TEST_CASE_ST(ut_setup, ut_teardown,
11542 test_AES_GCM_auth_decryption_test_case_256_4),
11543 TEST_CASE_ST(ut_setup, ut_teardown,
11544 test_AES_GCM_auth_decryption_test_case_256_5),
11545 TEST_CASE_ST(ut_setup, ut_teardown,
11546 test_AES_GCM_auth_decryption_test_case_256_6),
11547 TEST_CASE_ST(ut_setup, ut_teardown,
11548 test_AES_GCM_auth_decryption_test_case_256_7),
11550 /** AES GMAC Authentication */
11551 TEST_CASE_ST(ut_setup, ut_teardown,
11552 test_AES_GMAC_authentication_test_case_1),
11553 TEST_CASE_ST(ut_setup, ut_teardown,
11554 test_AES_GMAC_authentication_verify_test_case_1),
11555 TEST_CASE_ST(ut_setup, ut_teardown,
11556 test_AES_GMAC_authentication_test_case_2),
11557 TEST_CASE_ST(ut_setup, ut_teardown,
11558 test_AES_GMAC_authentication_verify_test_case_2),
11559 TEST_CASE_ST(ut_setup, ut_teardown,
11560 test_AES_GMAC_authentication_test_case_3),
11561 TEST_CASE_ST(ut_setup, ut_teardown,
11562 test_AES_GMAC_authentication_verify_test_case_3),
11564 /** SNOW 3G encrypt only (UEA2) */
11565 TEST_CASE_ST(ut_setup, ut_teardown,
11566 test_snow3g_encryption_test_case_1),
11567 TEST_CASE_ST(ut_setup, ut_teardown,
11568 test_snow3g_encryption_test_case_2),
11569 TEST_CASE_ST(ut_setup, ut_teardown,
11570 test_snow3g_encryption_test_case_3),
11571 TEST_CASE_ST(ut_setup, ut_teardown,
11572 test_snow3g_encryption_test_case_4),
11573 TEST_CASE_ST(ut_setup, ut_teardown,
11574 test_snow3g_encryption_test_case_5),
11576 TEST_CASE_ST(ut_setup, ut_teardown,
11577 test_snow3g_encryption_test_case_1_oop),
11578 TEST_CASE_ST(ut_setup, ut_teardown,
11579 test_snow3g_decryption_test_case_1_oop),
11581 /** SNOW 3G generate auth, then encrypt (UEA2) */
11582 TEST_CASE_ST(ut_setup, ut_teardown,
11583 test_snow3g_auth_cipher_test_case_1),
11584 TEST_CASE_ST(ut_setup, ut_teardown,
11585 test_snow3g_auth_cipher_test_case_2),
11586 TEST_CASE_ST(ut_setup, ut_teardown,
11587 test_snow3g_auth_cipher_test_case_2_oop),
11588 TEST_CASE_ST(ut_setup, ut_teardown,
11589 test_snow3g_auth_cipher_part_digest_enc),
11590 TEST_CASE_ST(ut_setup, ut_teardown,
11591 test_snow3g_auth_cipher_part_digest_enc_oop),
11592 TEST_CASE_ST(ut_setup, ut_teardown,
11593 test_snow3g_auth_cipher_test_case_3_sgl),
11594 TEST_CASE_ST(ut_setup, ut_teardown,
11595 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11596 TEST_CASE_ST(ut_setup, ut_teardown,
11597 test_snow3g_auth_cipher_part_digest_enc_sgl),
11598 TEST_CASE_ST(ut_setup, ut_teardown,
11599 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11601 /** SNOW 3G decrypt (UEA2), then verify auth */
11602 TEST_CASE_ST(ut_setup, ut_teardown,
11603 test_snow3g_auth_cipher_verify_test_case_1),
11604 TEST_CASE_ST(ut_setup, ut_teardown,
11605 test_snow3g_auth_cipher_verify_test_case_2),
11606 TEST_CASE_ST(ut_setup, ut_teardown,
11607 test_snow3g_auth_cipher_verify_test_case_2_oop),
11608 TEST_CASE_ST(ut_setup, ut_teardown,
11609 test_snow3g_auth_cipher_verify_part_digest_enc),
11610 TEST_CASE_ST(ut_setup, ut_teardown,
11611 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11612 TEST_CASE_ST(ut_setup, ut_teardown,
11613 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11614 TEST_CASE_ST(ut_setup, ut_teardown,
11615 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11616 TEST_CASE_ST(ut_setup, ut_teardown,
11617 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11618 TEST_CASE_ST(ut_setup, ut_teardown,
11619 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11621 /** SNOW 3G decrypt only (UEA2) */
11622 TEST_CASE_ST(ut_setup, ut_teardown,
11623 test_snow3g_decryption_test_case_1),
11624 TEST_CASE_ST(ut_setup, ut_teardown,
11625 test_snow3g_decryption_test_case_2),
11626 TEST_CASE_ST(ut_setup, ut_teardown,
11627 test_snow3g_decryption_test_case_3),
11628 TEST_CASE_ST(ut_setup, ut_teardown,
11629 test_snow3g_decryption_test_case_4),
11630 TEST_CASE_ST(ut_setup, ut_teardown,
11631 test_snow3g_decryption_test_case_5),
11632 TEST_CASE_ST(ut_setup, ut_teardown,
11633 test_snow3g_decryption_with_digest_test_case_1),
11634 TEST_CASE_ST(ut_setup, ut_teardown,
11635 test_snow3g_hash_generate_test_case_1),
11636 TEST_CASE_ST(ut_setup, ut_teardown,
11637 test_snow3g_hash_generate_test_case_2),
11638 TEST_CASE_ST(ut_setup, ut_teardown,
11639 test_snow3g_hash_generate_test_case_3),
11640 TEST_CASE_ST(ut_setup, ut_teardown,
11641 test_snow3g_hash_verify_test_case_1),
11642 TEST_CASE_ST(ut_setup, ut_teardown,
11643 test_snow3g_hash_verify_test_case_2),
11644 TEST_CASE_ST(ut_setup, ut_teardown,
11645 test_snow3g_hash_verify_test_case_3),
11646 TEST_CASE_ST(ut_setup, ut_teardown,
11647 test_snow3g_cipher_auth_test_case_1),
11648 TEST_CASE_ST(ut_setup, ut_teardown,
11649 test_snow3g_auth_cipher_with_digest_test_case_1),
11651 /** ZUC encrypt only (EEA3) */
11652 TEST_CASE_ST(ut_setup, ut_teardown,
11653 test_zuc_encryption_test_case_1),
11654 TEST_CASE_ST(ut_setup, ut_teardown,
11655 test_zuc_encryption_test_case_2),
11656 TEST_CASE_ST(ut_setup, ut_teardown,
11657 test_zuc_encryption_test_case_3),
11658 TEST_CASE_ST(ut_setup, ut_teardown,
11659 test_zuc_encryption_test_case_4),
11660 TEST_CASE_ST(ut_setup, ut_teardown,
11661 test_zuc_encryption_test_case_5),
11663 /** ZUC authenticate (EIA3) */
11664 TEST_CASE_ST(ut_setup, ut_teardown,
11665 test_zuc_hash_generate_test_case_6),
11666 TEST_CASE_ST(ut_setup, ut_teardown,
11667 test_zuc_hash_generate_test_case_7),
11668 TEST_CASE_ST(ut_setup, ut_teardown,
11669 test_zuc_hash_generate_test_case_8),
11671 /** ZUC alg-chain (EEA3/EIA3) */
11672 TEST_CASE_ST(ut_setup, ut_teardown,
11673 test_zuc_cipher_auth_test_case_1),
11674 TEST_CASE_ST(ut_setup, ut_teardown,
11675 test_zuc_cipher_auth_test_case_2),
11677 /** ZUC generate auth, then encrypt (EEA3) */
11678 TEST_CASE_ST(ut_setup, ut_teardown,
11679 test_zuc_auth_cipher_test_case_1),
11680 TEST_CASE_ST(ut_setup, ut_teardown,
11681 test_zuc_auth_cipher_test_case_1_oop),
11682 TEST_CASE_ST(ut_setup, ut_teardown,
11683 test_zuc_auth_cipher_test_case_1_sgl),
11684 TEST_CASE_ST(ut_setup, ut_teardown,
11685 test_zuc_auth_cipher_test_case_1_oop_sgl),
11687 /** ZUC decrypt (EEA3), then verify auth */
11688 TEST_CASE_ST(ut_setup, ut_teardown,
11689 test_zuc_auth_cipher_verify_test_case_1),
11690 TEST_CASE_ST(ut_setup, ut_teardown,
11691 test_zuc_auth_cipher_verify_test_case_1_oop),
11692 TEST_CASE_ST(ut_setup, ut_teardown,
11693 test_zuc_auth_cipher_verify_test_case_1_sgl),
11694 TEST_CASE_ST(ut_setup, ut_teardown,
11695 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
11697 /** HMAC_MD5 Authentication */
11698 TEST_CASE_ST(ut_setup, ut_teardown,
11699 test_MD5_HMAC_generate_case_1),
11700 TEST_CASE_ST(ut_setup, ut_teardown,
11701 test_MD5_HMAC_verify_case_1),
11702 TEST_CASE_ST(ut_setup, ut_teardown,
11703 test_MD5_HMAC_generate_case_2),
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_MD5_HMAC_verify_case_2),
11707 /** NULL algo tests done in chain_all,
11708 * cipheronly and authonly suites
11711 /** KASUMI tests */
11712 TEST_CASE_ST(ut_setup, ut_teardown,
11713 test_kasumi_hash_generate_test_case_1),
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 test_kasumi_hash_generate_test_case_2),
11716 TEST_CASE_ST(ut_setup, ut_teardown,
11717 test_kasumi_hash_generate_test_case_3),
11718 TEST_CASE_ST(ut_setup, ut_teardown,
11719 test_kasumi_hash_generate_test_case_4),
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 test_kasumi_hash_generate_test_case_5),
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_kasumi_hash_generate_test_case_6),
11725 TEST_CASE_ST(ut_setup, ut_teardown,
11726 test_kasumi_hash_verify_test_case_1),
11727 TEST_CASE_ST(ut_setup, ut_teardown,
11728 test_kasumi_hash_verify_test_case_2),
11729 TEST_CASE_ST(ut_setup, ut_teardown,
11730 test_kasumi_hash_verify_test_case_3),
11731 TEST_CASE_ST(ut_setup, ut_teardown,
11732 test_kasumi_hash_verify_test_case_4),
11733 TEST_CASE_ST(ut_setup, ut_teardown,
11734 test_kasumi_hash_verify_test_case_5),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_kasumi_encryption_test_case_1),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_kasumi_encryption_test_case_3),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_kasumi_cipher_auth_test_case_1),
11743 /** KASUMI generate auth, then encrypt (F8) */
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_kasumi_auth_cipher_test_case_1),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_kasumi_auth_cipher_test_case_2),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_kasumi_auth_cipher_test_case_2_oop),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_kasumi_auth_cipher_test_case_2_sgl),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11755 /** KASUMI decrypt (F8), then verify auth */
11756 TEST_CASE_ST(ut_setup, ut_teardown,
11757 test_kasumi_auth_cipher_verify_test_case_1),
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_kasumi_auth_cipher_verify_test_case_2),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_kasumi_auth_cipher_verify_test_case_2_oop),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11767 /** Negative tests */
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_GCM_auth_encryption_fail_iv_corrupt),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_auth_encryption_fail_aad_corrupt),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_auth_encryption_fail_tag_corrupt),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_GCM_auth_decryption_fail_iv_corrupt),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_GCM_auth_decryption_fail_aad_corrupt),
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_AES_GCM_auth_decryption_fail_tag_corrupt),
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 authentication_verify_AES128_GMAC_fail_data_corrupt),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11805 TEST_CASES_END() /**< NULL terminate unit test array */
11809 static struct unit_test_suite cryptodev_virtio_testsuite = {
11810 .suite_name = "Crypto VIRTIO Unit Test Suite",
11811 .setup = testsuite_setup,
11812 .teardown = testsuite_teardown,
11813 .unit_test_cases = {
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_cipheronly_virtio_all),
11817 TEST_CASES_END() /**< NULL terminate unit test array */
11821 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
11822 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
11823 .setup = testsuite_setup,
11824 .teardown = testsuite_teardown,
11825 .unit_test_cases = {
11826 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_GCM_authenticated_encryption_test_case_1),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_GCM_authenticated_encryption_test_case_2),
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_GCM_authenticated_encryption_test_case_3),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_GCM_authenticated_encryption_test_case_4),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_GCM_authenticated_encryption_test_case_5),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_GCM_authenticated_encryption_test_case_6),
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_GCM_authenticated_encryption_test_case_7),
11842 /** AES GCM Authenticated Decryption */
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_GCM_authenticated_decryption_test_case_1),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_GCM_authenticated_decryption_test_case_2),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_GCM_authenticated_decryption_test_case_3),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_GCM_authenticated_decryption_test_case_4),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_GCM_authenticated_decryption_test_case_5),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_GCM_authenticated_decryption_test_case_6),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_GCM_authenticated_decryption_test_case_7),
11858 /** AES GCM Authenticated Encryption 192 bits key */
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_auth_encryption_test_case_192_1),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_auth_encryption_test_case_192_2),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_auth_encryption_test_case_192_3),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_auth_encryption_test_case_192_4),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_auth_encryption_test_case_192_5),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_auth_encryption_test_case_192_6),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_auth_encryption_test_case_192_7),
11874 /** AES GCM Authenticated Decryption 192 bits key */
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_auth_decryption_test_case_192_1),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_auth_decryption_test_case_192_2),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_auth_decryption_test_case_192_3),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_auth_decryption_test_case_192_4),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_auth_decryption_test_case_192_5),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_auth_decryption_test_case_192_6),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_auth_decryption_test_case_192_7),
11890 /** AES GCM Authenticated Encryption 256 bits key */
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_auth_encryption_test_case_256_1),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_auth_encryption_test_case_256_2),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_auth_encryption_test_case_256_3),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_auth_encryption_test_case_256_4),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_auth_encryption_test_case_256_5),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_auth_encryption_test_case_256_6),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_auth_encryption_test_case_256_7),
11906 /** AES GCM Authenticated Decryption 256 bits key */
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_decryption_test_case_256_1),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_decryption_test_case_256_2),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_decryption_test_case_256_3),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_decryption_test_case_256_4),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_decryption_test_case_256_5),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_decryption_test_case_256_6),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_auth_decryption_test_case_256_7),
11922 /** AES GCM Authenticated Encryption big aad size */
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_encryption_test_case_aad_1),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_encryption_test_case_aad_2),
11928 /** AES GCM Authenticated Decryption big aad size */
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_decryption_test_case_aad_1),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_decryption_test_case_aad_2),
11934 /** Session-less tests */
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11940 /** AES GMAC Authentication */
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GMAC_authentication_test_case_1),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GMAC_authentication_verify_test_case_1),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GMAC_authentication_test_case_2),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GMAC_authentication_verify_test_case_2),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GMAC_authentication_test_case_3),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GMAC_authentication_verify_test_case_3),
11953 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
11955 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
11956 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
11957 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
11958 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_DES_cipheronly_mb_all),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_DES_docsis_mb_all),
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_3DES_cipheronly_mb_all),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_CCM_authenticated_encryption_test_case_128_1),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_CCM_authenticated_decryption_test_case_128_1),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_CCM_authenticated_encryption_test_case_128_2),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_CCM_authenticated_decryption_test_case_128_2),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_CCM_authenticated_encryption_test_case_128_3),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_CCM_authenticated_decryption_test_case_128_3),
11978 TEST_CASES_END() /**< NULL terminate unit test array */
11982 static struct unit_test_suite cryptodev_openssl_testsuite = {
11983 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
11984 .setup = testsuite_setup,
11985 .teardown = testsuite_teardown,
11986 .unit_test_cases = {
11987 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_multi_session_random_usage),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_AES_chain_openssl_all),
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_AES_cipheronly_openssl_all),
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_3DES_chain_openssl_all),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_3DES_cipheronly_openssl_all),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_DES_cipheronly_openssl_all),
12000 TEST_CASE_ST(ut_setup, ut_teardown,
12001 test_DES_docsis_openssl_all),
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_authonly_openssl_all),
12005 /** AES GCM Authenticated Encryption */
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_AES_GCM_authenticated_encryption_test_case_1),
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_AES_GCM_authenticated_encryption_test_case_2),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_AES_GCM_authenticated_encryption_test_case_3),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_AES_GCM_authenticated_encryption_test_case_4),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_AES_GCM_authenticated_encryption_test_case_5),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_AES_GCM_authenticated_encryption_test_case_6),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_AES_GCM_authenticated_encryption_test_case_7),
12021 /** AES GCM Authenticated Decryption */
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_AES_GCM_authenticated_decryption_test_case_1),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_AES_GCM_authenticated_decryption_test_case_2),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_AES_GCM_authenticated_decryption_test_case_3),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_AES_GCM_authenticated_decryption_test_case_4),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_AES_GCM_authenticated_decryption_test_case_5),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_AES_GCM_authenticated_decryption_test_case_6),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_AES_GCM_authenticated_decryption_test_case_7),
12038 /** AES GCM Authenticated Encryption 192 bits key */
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_AES_GCM_auth_encryption_test_case_192_1),
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_AES_GCM_auth_encryption_test_case_192_2),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_AES_GCM_auth_encryption_test_case_192_3),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_AES_GCM_auth_encryption_test_case_192_4),
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_AES_GCM_auth_encryption_test_case_192_5),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_AES_GCM_auth_encryption_test_case_192_6),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_AES_GCM_auth_encryption_test_case_192_7),
12054 /** AES GCM Authenticated Decryption 192 bits key */
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_AES_GCM_auth_decryption_test_case_192_1),
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_AES_GCM_auth_decryption_test_case_192_2),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_AES_GCM_auth_decryption_test_case_192_3),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_AES_GCM_auth_decryption_test_case_192_4),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_AES_GCM_auth_decryption_test_case_192_5),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_AES_GCM_auth_decryption_test_case_192_6),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_AES_GCM_auth_decryption_test_case_192_7),
12070 /** AES GCM Authenticated Encryption 256 bits key */
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_AES_GCM_auth_encryption_test_case_256_1),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_AES_GCM_auth_encryption_test_case_256_2),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_AES_GCM_auth_encryption_test_case_256_3),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_AES_GCM_auth_encryption_test_case_256_4),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_AES_GCM_auth_encryption_test_case_256_5),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_AES_GCM_auth_encryption_test_case_256_6),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_AES_GCM_auth_encryption_test_case_256_7),
12086 /** AES GCM Authenticated Decryption 256 bits key */
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_AES_GCM_auth_decryption_test_case_256_1),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_AES_GCM_auth_decryption_test_case_256_2),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_AES_GCM_auth_decryption_test_case_256_3),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_AES_GCM_auth_decryption_test_case_256_4),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_AES_GCM_auth_decryption_test_case_256_5),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_AES_GCM_auth_decryption_test_case_256_6),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_AES_GCM_auth_decryption_test_case_256_7),
12102 /** AES GMAC Authentication */
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_AES_GMAC_authentication_test_case_1),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_AES_GMAC_authentication_verify_test_case_1),
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_AES_GMAC_authentication_test_case_2),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_AES_GMAC_authentication_verify_test_case_2),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_AES_GMAC_authentication_test_case_3),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_AES_GMAC_authentication_verify_test_case_3),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_AES_GMAC_authentication_test_case_4),
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_AES_GMAC_authentication_verify_test_case_4),
12120 /** AES CCM Authenticated Encryption 128 bits key */
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_AES_CCM_authenticated_encryption_test_case_128_1),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_AES_CCM_authenticated_encryption_test_case_128_2),
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_AES_CCM_authenticated_encryption_test_case_128_3),
12128 /** AES CCM Authenticated Decryption 128 bits key*/
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_AES_CCM_authenticated_decryption_test_case_128_1),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_AES_CCM_authenticated_decryption_test_case_128_2),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_AES_CCM_authenticated_decryption_test_case_128_3),
12136 /** AES CCM Authenticated Encryption 192 bits key */
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_AES_CCM_authenticated_encryption_test_case_192_1),
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_AES_CCM_authenticated_encryption_test_case_192_2),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_AES_CCM_authenticated_encryption_test_case_192_3),
12144 /** AES CCM Authenticated Decryption 192 bits key*/
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_AES_CCM_authenticated_decryption_test_case_192_1),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_AES_CCM_authenticated_decryption_test_case_192_2),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_AES_CCM_authenticated_decryption_test_case_192_3),
12152 /** AES CCM Authenticated Encryption 256 bits key */
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_AES_CCM_authenticated_encryption_test_case_256_1),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_AES_CCM_authenticated_encryption_test_case_256_2),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_AES_CCM_authenticated_encryption_test_case_256_3),
12160 /** AES CCM Authenticated Decryption 256 bits key*/
12161 TEST_CASE_ST(ut_setup, ut_teardown,
12162 test_AES_CCM_authenticated_decryption_test_case_256_1),
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_AES_CCM_authenticated_decryption_test_case_256_2),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_AES_CCM_authenticated_decryption_test_case_256_3),
12168 /** Scatter-Gather */
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12172 /** Negative tests */
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 authentication_verify_AES128_GMAC_fail_data_corrupt),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12193 TEST_CASES_END() /**< NULL terminate unit test array */
12197 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12198 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12199 .setup = testsuite_setup,
12200 .teardown = testsuite_teardown,
12201 .unit_test_cases = {
12202 /** AES GCM Authenticated Encryption */
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_AES_GCM_authenticated_encryption_test_case_1),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_AES_GCM_authenticated_encryption_test_case_2),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_AES_GCM_authenticated_encryption_test_case_3),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_AES_GCM_authenticated_encryption_test_case_4),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_AES_GCM_authenticated_encryption_test_case_5),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_AES_GCM_authenticated_encryption_test_case_6),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_AES_GCM_authenticated_encryption_test_case_7),
12218 /** AES GCM Authenticated Decryption */
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_AES_GCM_authenticated_decryption_test_case_1),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_AES_GCM_authenticated_decryption_test_case_2),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_AES_GCM_authenticated_decryption_test_case_3),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_AES_GCM_authenticated_decryption_test_case_4),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_AES_GCM_authenticated_decryption_test_case_5),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_AES_GCM_authenticated_decryption_test_case_6),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_AES_GCM_authenticated_decryption_test_case_7),
12234 /** AES GCM Authenticated Encryption 192 bits key */
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_auth_encryption_test_case_192_1),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_auth_encryption_test_case_192_2),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_auth_encryption_test_case_192_3),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_auth_encryption_test_case_192_4),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_auth_encryption_test_case_192_5),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_encryption_test_case_192_6),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_encryption_test_case_192_7),
12250 /** AES GCM Authenticated Decryption 192 bits key */
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_decryption_test_case_192_1),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_decryption_test_case_192_2),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_decryption_test_case_192_3),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_decryption_test_case_192_4),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_decryption_test_case_192_5),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_decryption_test_case_192_6),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_decryption_test_case_192_7),
12266 /** AES GCM Authenticated Encryption 256 bits key */
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_encryption_test_case_256_1),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_encryption_test_case_256_2),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_AES_GCM_auth_encryption_test_case_256_3),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_AES_GCM_auth_encryption_test_case_256_4),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_AES_GCM_auth_encryption_test_case_256_5),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_AES_GCM_auth_encryption_test_case_256_6),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_AES_GCM_auth_encryption_test_case_256_7),
12282 /** AES GCM Authenticated Decryption 256 bits key */
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_AES_GCM_auth_decryption_test_case_256_1),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_AES_GCM_auth_decryption_test_case_256_2),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_AES_GCM_auth_decryption_test_case_256_3),
12289 TEST_CASE_ST(ut_setup, ut_teardown,
12290 test_AES_GCM_auth_decryption_test_case_256_4),
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_AES_GCM_auth_decryption_test_case_256_5),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_GCM_auth_decryption_test_case_256_6),
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_AES_GCM_auth_decryption_test_case_256_7),
12298 /** AES GCM Authenticated Encryption big aad size */
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_AES_GCM_auth_encryption_test_case_aad_1),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_AES_GCM_auth_encryption_test_case_aad_2),
12304 /** AES GCM Authenticated Decryption big aad size */
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_AES_GCM_auth_decryption_test_case_aad_1),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_AES_GCM_auth_decryption_test_case_aad_2),
12310 /** AES GMAC Authentication */
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_AES_GMAC_authentication_test_case_1),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_AES_GMAC_authentication_verify_test_case_1),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_AES_GMAC_authentication_test_case_3),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_AES_GMAC_authentication_verify_test_case_3),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_AES_GMAC_authentication_test_case_4),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_GMAC_authentication_verify_test_case_4),
12324 /** Negative tests */
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 authentication_verify_AES128_GMAC_fail_data_corrupt),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12330 /** Out of place tests */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12336 /** Session-less tests */
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12342 /** Scatter-Gather */
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12346 TEST_CASES_END() /**< NULL terminate unit test array */
12350 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12351 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12352 .setup = testsuite_setup,
12353 .teardown = testsuite_teardown,
12354 .unit_test_cases = {
12355 /** KASUMI encrypt only (UEA1) */
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_kasumi_encryption_test_case_1),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_kasumi_encryption_test_case_1_sgl),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_kasumi_encryption_test_case_2),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_kasumi_encryption_test_case_3),
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_kasumi_encryption_test_case_4),
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_kasumi_encryption_test_case_5),
12368 /** KASUMI decrypt only (UEA1) */
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_kasumi_decryption_test_case_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_kasumi_decryption_test_case_2),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_kasumi_decryption_test_case_3),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_kasumi_decryption_test_case_4),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_kasumi_decryption_test_case_5),
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_kasumi_encryption_test_case_1_oop),
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_kasumi_encryption_test_case_1_oop_sgl),
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_kasumi_decryption_test_case_1_oop),
12389 /** KASUMI hash only (UIA1) */
12390 TEST_CASE_ST(ut_setup, ut_teardown,
12391 test_kasumi_hash_generate_test_case_1),
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_kasumi_hash_generate_test_case_2),
12394 TEST_CASE_ST(ut_setup, ut_teardown,
12395 test_kasumi_hash_generate_test_case_3),
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 test_kasumi_hash_generate_test_case_4),
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_kasumi_hash_generate_test_case_5),
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_kasumi_hash_generate_test_case_6),
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_kasumi_hash_verify_test_case_1),
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_kasumi_hash_verify_test_case_2),
12406 TEST_CASE_ST(ut_setup, ut_teardown,
12407 test_kasumi_hash_verify_test_case_3),
12408 TEST_CASE_ST(ut_setup, ut_teardown,
12409 test_kasumi_hash_verify_test_case_4),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_kasumi_hash_verify_test_case_5),
12412 TEST_CASE_ST(ut_setup, ut_teardown,
12413 test_kasumi_cipher_auth_test_case_1),
12415 /** KASUMI generate auth, then encrypt (F8) */
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_kasumi_auth_cipher_test_case_1),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_kasumi_auth_cipher_test_case_2),
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_kasumi_auth_cipher_test_case_2_oop),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_kasumi_auth_cipher_test_case_2_sgl),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12427 /** KASUMI decrypt (F8), then verify auth */
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_kasumi_auth_cipher_verify_test_case_1),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 test_kasumi_auth_cipher_verify_test_case_2),
12432 TEST_CASE_ST(ut_setup, ut_teardown,
12433 test_kasumi_auth_cipher_verify_test_case_2_oop),
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12436 TEST_CASE_ST(ut_setup, ut_teardown,
12437 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12438 TEST_CASES_END() /**< NULL terminate unit test array */
12441 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12442 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12443 .setup = testsuite_setup,
12444 .teardown = testsuite_teardown,
12445 .unit_test_cases = {
12446 /** SNOW 3G encrypt only (UEA2) */
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_snow3g_encryption_test_case_1),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_snow3g_encryption_test_case_2),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_snow3g_encryption_test_case_3),
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_snow3g_encryption_test_case_4),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_snow3g_encryption_test_case_5),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_snow3g_auth_cipher_with_digest_test_case_1),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_snow3g_encryption_test_case_1_oop),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_snow3g_encryption_test_case_1_oop_sgl),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_snow3g_decryption_test_case_1_oop),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_snow3g_encryption_test_case_1_offset_oop),
12470 /** SNOW 3G decrypt only (UEA2) */
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_snow3g_decryption_test_case_1),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_snow3g_decryption_test_case_2),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_snow3g_decryption_test_case_3),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_snow3g_decryption_test_case_4),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_snow3g_decryption_test_case_5),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_snow3g_decryption_with_digest_test_case_1),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_snow3g_hash_generate_test_case_1),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_snow3g_hash_generate_test_case_2),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_snow3g_hash_generate_test_case_3),
12489 /* Tests with buffers which length is not byte-aligned */
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_snow3g_hash_generate_test_case_4),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_snow3g_hash_generate_test_case_5),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_snow3g_hash_generate_test_case_6),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_snow3g_hash_verify_test_case_1),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_snow3g_hash_verify_test_case_2),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_snow3g_hash_verify_test_case_3),
12502 /* Tests with buffers which length is not byte-aligned */
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_snow3g_hash_verify_test_case_4),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_snow3g_hash_verify_test_case_5),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_snow3g_hash_verify_test_case_6),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_snow3g_cipher_auth_test_case_1),
12512 /** SNOW 3G generate auth, then encrypt (UEA2) */
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_snow3g_auth_cipher_test_case_1),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_snow3g_auth_cipher_test_case_2),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_snow3g_auth_cipher_test_case_2_oop),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_snow3g_auth_cipher_part_digest_enc),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_snow3g_auth_cipher_part_digest_enc_oop),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_snow3g_auth_cipher_test_case_3_sgl),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_snow3g_auth_cipher_part_digest_enc_sgl),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12532 /** SNOW 3G decrypt (UEA2), then verify auth */
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_snow3g_auth_cipher_verify_test_case_1),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_snow3g_auth_cipher_verify_test_case_2),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_snow3g_auth_cipher_verify_test_case_2_oop),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_snow3g_auth_cipher_verify_part_digest_enc),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12552 TEST_CASES_END() /**< NULL terminate unit test array */
12556 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
12557 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
12558 .setup = testsuite_setup,
12559 .teardown = testsuite_teardown,
12560 .unit_test_cases = {
12561 /** ZUC encrypt only (EEA3) */
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_zuc_encryption_test_case_1),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_zuc_encryption_test_case_2),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_zuc_encryption_test_case_3),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_zuc_encryption_test_case_4),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_zuc_encryption_test_case_5),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_zuc_hash_generate_test_case_1),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_zuc_hash_generate_test_case_2),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_zuc_hash_generate_test_case_3),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_zuc_hash_generate_test_case_4),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_zuc_hash_generate_test_case_5),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_zuc_encryption_test_case_6_sgl),
12584 TEST_CASES_END() /**< NULL terminate unit test array */
12588 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12589 .suite_name = "Crypto CAAM JR Unit Test Suite",
12590 .setup = testsuite_setup,
12591 .teardown = testsuite_teardown,
12592 .unit_test_cases = {
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_device_configure_invalid_dev_id),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_multi_session),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_AES_chain_caam_jr_all),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_3DES_chain_caam_jr_all),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_AES_cipheronly_caam_jr_all),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_3DES_cipheronly_caam_jr_all),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_authonly_caam_jr_all),
12609 TEST_CASES_END() /**< NULL terminate unit test array */
12613 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12614 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12615 .setup = testsuite_setup,
12616 .teardown = testsuite_teardown,
12617 .unit_test_cases = {
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_device_configure_invalid_dev_id),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_multi_session),
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_AES_chain_dpaa_sec_all),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_3DES_chain_dpaa_sec_all),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_AES_cipheronly_dpaa_sec_all),
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_3DES_cipheronly_dpaa_sec_all),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_authonly_dpaa_sec_all),
12634 #ifdef RTE_LIBRTE_SECURITY
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_PDCP_PROTO_cplane_encap_all),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_PDCP_PROTO_cplane_decap_all),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_PDCP_PROTO_uplane_encap_all),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_PDCP_PROTO_uplane_decap_all),
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_PDCP_PROTO_SGL_in_place_32B),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 test_PDCP_PROTO_SGL_oop_32B_128B),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 test_PDCP_PROTO_SGL_oop_32B_40B),
12653 TEST_CASE_ST(ut_setup, ut_teardown,
12654 test_PDCP_PROTO_SGL_oop_128B_32B),
12656 /** AES GCM Authenticated Encryption */
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_AES_GCM_authenticated_encryption_test_case_1),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 test_AES_GCM_authenticated_encryption_test_case_2),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_AES_GCM_authenticated_encryption_test_case_3),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_AES_GCM_authenticated_encryption_test_case_4),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_AES_GCM_authenticated_encryption_test_case_5),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_AES_GCM_authenticated_encryption_test_case_6),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_AES_GCM_authenticated_encryption_test_case_7),
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_AES_GCM_authenticated_encryption_test_case_8),
12682 /** AES GCM Authenticated Decryption */
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 test_AES_GCM_authenticated_decryption_test_case_1),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_AES_GCM_authenticated_decryption_test_case_2),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_AES_GCM_authenticated_decryption_test_case_3),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_AES_GCM_authenticated_decryption_test_case_4),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_AES_GCM_authenticated_decryption_test_case_5),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_AES_GCM_authenticated_decryption_test_case_6),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_AES_GCM_authenticated_decryption_test_case_7),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_AES_GCM_authenticated_decryption_test_case_8),
12700 /** AES GCM Authenticated Encryption 192 bits key */
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_AES_GCM_auth_encryption_test_case_192_1),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_AES_GCM_auth_encryption_test_case_192_2),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_AES_GCM_auth_encryption_test_case_192_3),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_AES_GCM_auth_encryption_test_case_192_4),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_auth_encryption_test_case_192_5),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_AES_GCM_auth_encryption_test_case_192_6),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_auth_encryption_test_case_192_7),
12716 /** AES GCM Authenticated Decryption 192 bits key */
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_auth_decryption_test_case_192_1),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_auth_decryption_test_case_192_2),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_auth_decryption_test_case_192_3),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_auth_decryption_test_case_192_4),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_auth_decryption_test_case_192_5),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_auth_decryption_test_case_192_6),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_auth_decryption_test_case_192_7),
12732 /** AES GCM Authenticated Encryption 256 bits key */
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_auth_encryption_test_case_256_1),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_auth_encryption_test_case_256_2),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_AES_GCM_auth_encryption_test_case_256_3),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_auth_encryption_test_case_256_4),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_auth_encryption_test_case_256_5),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_auth_encryption_test_case_256_6),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_auth_encryption_test_case_256_7),
12748 /** AES GCM Authenticated Decryption 256 bits key */
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_auth_decryption_test_case_256_1),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_auth_decryption_test_case_256_2),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_auth_decryption_test_case_256_3),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_auth_decryption_test_case_256_4),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_decryption_test_case_256_5),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_decryption_test_case_256_6),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_decryption_test_case_256_7),
12764 /** Out of place tests */
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12770 /** SNOW 3G encrypt only (UEA2) */
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_snow3g_encryption_test_case_1),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_snow3g_encryption_test_case_2),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_snow3g_encryption_test_case_3),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_snow3g_encryption_test_case_4),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_snow3g_encryption_test_case_5),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_snow3g_encryption_test_case_1_oop),
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_snow3g_encryption_test_case_1_oop_sgl),
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_snow3g_decryption_test_case_1_oop),
12789 /** SNOW 3G decrypt only (UEA2) */
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_snow3g_decryption_test_case_1),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_snow3g_decryption_test_case_2),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_snow3g_decryption_test_case_3),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_snow3g_decryption_test_case_4),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_snow3g_decryption_test_case_5),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_snow3g_hash_generate_test_case_1),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_snow3g_hash_generate_test_case_2),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_snow3g_hash_generate_test_case_3),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_snow3g_hash_verify_test_case_1),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_snow3g_hash_verify_test_case_2),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_snow3g_hash_verify_test_case_3),
12814 /** ZUC encrypt only (EEA3) */
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_zuc_encryption_test_case_1),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_zuc_encryption_test_case_2),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_zuc_encryption_test_case_3),
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 test_zuc_encryption_test_case_4),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_zuc_encryption_test_case_5),
12826 /** ZUC authenticate (EIA3) */
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_zuc_hash_generate_test_case_6),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_zuc_hash_generate_test_case_7),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_zuc_hash_generate_test_case_8),
12834 /** Negative tests */
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12847 TEST_CASE_ST(ut_setup, ut_teardown,
12848 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12874 TEST_CASES_END() /**< NULL terminate unit test array */
12878 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12879 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12880 .setup = testsuite_setup,
12881 .teardown = testsuite_teardown,
12882 .unit_test_cases = {
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_device_configure_invalid_dev_id),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_multi_session),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_AES_chain_dpaa2_sec_all),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_3DES_chain_dpaa2_sec_all),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_AES_cipheronly_dpaa2_sec_all),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_3DES_cipheronly_dpaa2_sec_all),
12895 TEST_CASE_ST(ut_setup, ut_teardown,
12896 test_authonly_dpaa2_sec_all),
12898 #ifdef RTE_LIBRTE_SECURITY
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_PDCP_PROTO_cplane_encap_all),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_PDCP_PROTO_cplane_decap_all),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_PDCP_PROTO_uplane_encap_all),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_PDCP_PROTO_uplane_decap_all),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_PDCP_PROTO_SGL_in_place_32B),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_PDCP_PROTO_SGL_oop_32B_128B),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_PDCP_PROTO_SGL_oop_32B_40B),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_PDCP_PROTO_SGL_oop_128B_32B),
12920 /** AES GCM Authenticated Encryption */
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12929 TEST_CASE_ST(ut_setup, ut_teardown,
12930 test_AES_GCM_authenticated_encryption_test_case_1),
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 test_AES_GCM_authenticated_encryption_test_case_2),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_AES_GCM_authenticated_encryption_test_case_3),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 test_AES_GCM_authenticated_encryption_test_case_4),
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 test_AES_GCM_authenticated_encryption_test_case_5),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_AES_GCM_authenticated_encryption_test_case_6),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_AES_GCM_authenticated_encryption_test_case_7),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_AES_GCM_authenticated_encryption_test_case_8),
12946 /** AES GCM Authenticated Decryption */
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 test_AES_GCM_authenticated_decryption_test_case_1),
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 test_AES_GCM_authenticated_decryption_test_case_2),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_AES_GCM_authenticated_decryption_test_case_3),
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_AES_GCM_authenticated_decryption_test_case_4),
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 test_AES_GCM_authenticated_decryption_test_case_5),
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_AES_GCM_authenticated_decryption_test_case_6),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_AES_GCM_authenticated_decryption_test_case_7),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_AES_GCM_authenticated_decryption_test_case_8),
12964 /** AES GCM Authenticated Encryption 192 bits key */
12965 TEST_CASE_ST(ut_setup, ut_teardown,
12966 test_AES_GCM_auth_encryption_test_case_192_1),
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_AES_GCM_auth_encryption_test_case_192_2),
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_AES_GCM_auth_encryption_test_case_192_3),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_AES_GCM_auth_encryption_test_case_192_4),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_AES_GCM_auth_encryption_test_case_192_5),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 test_AES_GCM_auth_encryption_test_case_192_6),
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 test_AES_GCM_auth_encryption_test_case_192_7),
12980 /** AES GCM Authenticated Decryption 192 bits key */
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 test_AES_GCM_auth_decryption_test_case_192_1),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 test_AES_GCM_auth_decryption_test_case_192_2),
12985 TEST_CASE_ST(ut_setup, ut_teardown,
12986 test_AES_GCM_auth_decryption_test_case_192_3),
12987 TEST_CASE_ST(ut_setup, ut_teardown,
12988 test_AES_GCM_auth_decryption_test_case_192_4),
12989 TEST_CASE_ST(ut_setup, ut_teardown,
12990 test_AES_GCM_auth_decryption_test_case_192_5),
12991 TEST_CASE_ST(ut_setup, ut_teardown,
12992 test_AES_GCM_auth_decryption_test_case_192_6),
12993 TEST_CASE_ST(ut_setup, ut_teardown,
12994 test_AES_GCM_auth_decryption_test_case_192_7),
12996 /** AES GCM Authenticated Encryption 256 bits key */
12997 TEST_CASE_ST(ut_setup, ut_teardown,
12998 test_AES_GCM_auth_encryption_test_case_256_1),
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_AES_GCM_auth_encryption_test_case_256_2),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_AES_GCM_auth_encryption_test_case_256_3),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_AES_GCM_auth_encryption_test_case_256_4),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_AES_GCM_auth_encryption_test_case_256_5),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_AES_GCM_auth_encryption_test_case_256_6),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_AES_GCM_auth_encryption_test_case_256_7),
13012 /** AES GCM Authenticated Decryption 256 bits key */
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_AES_GCM_auth_decryption_test_case_256_1),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_auth_decryption_test_case_256_2),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_auth_decryption_test_case_256_3),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_auth_decryption_test_case_256_4),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_auth_decryption_test_case_256_5),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_auth_decryption_test_case_256_6),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_AES_GCM_auth_decryption_test_case_256_7),
13028 /** Out of place tests */
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13034 /** SNOW 3G encrypt only (UEA2) */
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_snow3g_encryption_test_case_1),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_snow3g_encryption_test_case_2),
13039 TEST_CASE_ST(ut_setup, ut_teardown,
13040 test_snow3g_encryption_test_case_3),
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_snow3g_encryption_test_case_4),
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 test_snow3g_encryption_test_case_5),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_snow3g_encryption_test_case_1_oop),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_snow3g_encryption_test_case_1_oop_sgl),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_snow3g_decryption_test_case_1_oop),
13053 /** SNOW 3G decrypt only (UEA2) */
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_snow3g_decryption_test_case_1),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_snow3g_decryption_test_case_2),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_snow3g_decryption_test_case_3),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_snow3g_decryption_test_case_4),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_snow3g_decryption_test_case_5),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_snow3g_hash_generate_test_case_1),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_snow3g_hash_generate_test_case_2),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_snow3g_hash_generate_test_case_3),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_snow3g_hash_verify_test_case_1),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_snow3g_hash_verify_test_case_2),
13075 TEST_CASE_ST(ut_setup, ut_teardown,
13076 test_snow3g_hash_verify_test_case_3),
13078 /** ZUC encrypt only (EEA3) */
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_zuc_encryption_test_case_1),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_zuc_encryption_test_case_2),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_zuc_encryption_test_case_3),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_zuc_encryption_test_case_4),
13087 TEST_CASE_ST(ut_setup, ut_teardown,
13088 test_zuc_encryption_test_case_5),
13090 /** ZUC authenticate (EIA3) */
13091 TEST_CASE_ST(ut_setup, ut_teardown,
13092 test_zuc_hash_generate_test_case_6),
13093 TEST_CASE_ST(ut_setup, ut_teardown,
13094 test_zuc_hash_generate_test_case_7),
13095 TEST_CASE_ST(ut_setup, ut_teardown,
13096 test_zuc_hash_generate_test_case_8),
13098 /** HMAC_MD5 Authentication */
13099 TEST_CASE_ST(ut_setup, ut_teardown,
13100 test_MD5_HMAC_generate_case_1),
13101 TEST_CASE_ST(ut_setup, ut_teardown,
13102 test_MD5_HMAC_verify_case_1),
13103 TEST_CASE_ST(ut_setup, ut_teardown,
13104 test_MD5_HMAC_generate_case_2),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_MD5_HMAC_verify_case_2),
13108 /** Negative tests */
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13113 TEST_CASE_ST(ut_setup, ut_teardown,
13114 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13149 TEST_CASES_END() /**< NULL terminate unit test array */
13153 static struct unit_test_suite cryptodev_null_testsuite = {
13154 .suite_name = "Crypto Device NULL Unit Test Suite",
13155 .setup = testsuite_setup,
13156 .teardown = testsuite_teardown,
13157 .unit_test_cases = {
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_null_invalid_operation),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_null_burst_operation),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_chain_null_all),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_cipheronly_null_all),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_authonly_null_all),
13169 TEST_CASES_END() /**< NULL terminate unit test array */
13173 static struct unit_test_suite cryptodev_armv8_testsuite = {
13174 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13175 .setup = testsuite_setup,
13176 .teardown = testsuite_teardown,
13177 .unit_test_cases = {
13178 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13180 /** Negative tests */
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13186 TEST_CASES_END() /**< NULL terminate unit test array */
13190 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13191 .suite_name = "Crypto Device Marvell Component Test Suite",
13192 .setup = testsuite_setup,
13193 .teardown = testsuite_teardown,
13194 .unit_test_cases = {
13195 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_multi_session_random_usage),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_AES_chain_mrvl_all),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_AES_cipheronly_mrvl_all),
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 test_authonly_mrvl_all),
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_3DES_chain_mrvl_all),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_3DES_cipheronly_mrvl_all),
13209 /** Negative tests */
13210 TEST_CASE_ST(ut_setup, ut_teardown,
13211 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13219 TEST_CASES_END() /**< NULL terminate unit test array */
13223 static struct unit_test_suite cryptodev_ccp_testsuite = {
13224 .suite_name = "Crypto Device CCP Unit Test Suite",
13225 .setup = testsuite_setup,
13226 .teardown = testsuite_teardown,
13227 .unit_test_cases = {
13228 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_multi_session_random_usage),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_AES_chain_ccp_all),
13233 TEST_CASE_ST(ut_setup, ut_teardown,
13234 test_AES_cipheronly_ccp_all),
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_3DES_chain_ccp_all),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_3DES_cipheronly_ccp_all),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_authonly_ccp_all),
13242 /** Negative tests */
13243 TEST_CASE_ST(ut_setup, ut_teardown,
13244 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13247 TEST_CASE_ST(ut_setup, ut_teardown,
13248 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13252 TEST_CASES_END() /**< NULL terminate unit test array */
13256 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13257 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13258 .setup = testsuite_setup,
13259 .teardown = testsuite_teardown,
13260 .unit_test_cases = {
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_AES_chain_octeontx_all),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_AES_cipheronly_octeontx_all),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_3DES_chain_octeontx_all),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_3DES_cipheronly_octeontx_all),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_authonly_octeontx_all),
13272 /** AES GCM Authenticated Encryption */
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_AES_GCM_authenticated_encryption_test_case_1),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_AES_GCM_authenticated_encryption_test_case_2),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_AES_GCM_authenticated_encryption_test_case_3),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_AES_GCM_authenticated_encryption_test_case_4),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_AES_GCM_authenticated_encryption_test_case_5),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_AES_GCM_authenticated_encryption_test_case_6),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_AES_GCM_authenticated_encryption_test_case_7),
13288 /** AES GCM Authenticated Decryption */
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_AES_GCM_authenticated_decryption_test_case_1),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_AES_GCM_authenticated_decryption_test_case_2),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_AES_GCM_authenticated_decryption_test_case_3),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_AES_GCM_authenticated_decryption_test_case_4),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_AES_GCM_authenticated_decryption_test_case_5),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_AES_GCM_authenticated_decryption_test_case_6),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_AES_GCM_authenticated_decryption_test_case_7),
13303 /** AES GMAC Authentication */
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_AES_GMAC_authentication_test_case_1),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_AES_GMAC_authentication_verify_test_case_1),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_AES_GMAC_authentication_test_case_2),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_AES_GMAC_authentication_verify_test_case_2),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_AES_GMAC_authentication_test_case_3),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_AES_GMAC_authentication_verify_test_case_3),
13317 /** SNOW 3G encrypt only (UEA2) */
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_snow3g_encryption_test_case_1),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_snow3g_encryption_test_case_2),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_snow3g_encryption_test_case_3),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_snow3g_encryption_test_case_4),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_snow3g_encryption_test_case_5),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_snow3g_encryption_test_case_1_oop),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_snow3g_decryption_test_case_1_oop),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_snow3g_encryption_test_case_1_oop_sgl),
13336 /** SNOW 3G decrypt only (UEA2) */
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_snow3g_decryption_test_case_1),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_snow3g_decryption_test_case_2),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_snow3g_decryption_test_case_3),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_snow3g_decryption_test_case_4),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_snow3g_decryption_test_case_5),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_snow3g_hash_generate_test_case_1),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_snow3g_hash_generate_test_case_2),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_snow3g_hash_generate_test_case_3),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_snow3g_hash_verify_test_case_1),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_snow3g_hash_verify_test_case_2),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_snow3g_hash_verify_test_case_3),
13361 /** ZUC encrypt only (EEA3) */
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_zuc_encryption_test_case_1),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_zuc_encryption_test_case_2),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_zuc_encryption_test_case_3),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_zuc_encryption_test_case_4),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_zuc_encryption_test_case_5),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_zuc_hash_generate_test_case_1),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_zuc_hash_generate_test_case_2),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_zuc_hash_generate_test_case_3),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_zuc_hash_generate_test_case_4),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_zuc_hash_generate_test_case_5),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_zuc_encryption_test_case_6_sgl),
13385 /** KASUMI encrypt only (UEA1) */
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_kasumi_encryption_test_case_1),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_kasumi_encryption_test_case_2),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_kasumi_encryption_test_case_3),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_kasumi_encryption_test_case_4),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_kasumi_encryption_test_case_5),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_kasumi_encryption_test_case_1_sgl),
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_kasumi_encryption_test_case_1_oop_sgl),
13400 /** KASUMI decrypt only (UEA1) */
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_kasumi_decryption_test_case_1),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_kasumi_decryption_test_case_2),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_kasumi_decryption_test_case_3),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_kasumi_decryption_test_case_4),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_kasumi_decryption_test_case_5),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_kasumi_encryption_test_case_1_oop),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_kasumi_decryption_test_case_1_oop),
13417 /** KASUMI hash only (UIA1) */
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_kasumi_hash_generate_test_case_1),
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_kasumi_hash_generate_test_case_2),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_kasumi_hash_generate_test_case_3),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_kasumi_hash_generate_test_case_4),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_kasumi_hash_generate_test_case_5),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_kasumi_hash_generate_test_case_6),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_kasumi_hash_verify_test_case_1),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_kasumi_hash_verify_test_case_2),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_kasumi_hash_verify_test_case_3),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_kasumi_hash_verify_test_case_4),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_kasumi_hash_verify_test_case_5),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_null_cipher_only_operation),
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_null_auth_only_operation),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_null_cipher_auth_operation),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_null_auth_cipher_operation),
13451 /** Negative tests */
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 authentication_verify_AES128_GMAC_fail_data_corrupt),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13460 TEST_CASE_ST(ut_setup, ut_teardown,
13461 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13464 TEST_CASES_END() /**< NULL terminate unit test array */
13468 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13469 .suite_name = "Crypto NITROX Unit Test Suite",
13470 .setup = testsuite_setup,
13471 .teardown = testsuite_teardown,
13472 .unit_test_cases = {
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_device_configure_invalid_dev_id),
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_device_configure_invalid_queue_pair_ids),
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_AES_chain_nitrox_all),
13480 TEST_CASES_END() /**< NULL terminate unit test array */
13484 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13485 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13486 .setup = testsuite_setup,
13487 .teardown = testsuite_teardown,
13488 .unit_test_cases = {
13489 TEST_CASE_ST(ut_setup, ut_teardown,
13490 test_AES_chain_octeontx2_all),
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_AES_cipheronly_octeontx2_all),
13493 TEST_CASE_ST(ut_setup, ut_teardown,
13494 test_3DES_chain_octeontx2_all),
13495 TEST_CASE_ST(ut_setup, ut_teardown,
13496 test_3DES_cipheronly_octeontx2_all),
13497 TEST_CASE_ST(ut_setup, ut_teardown,
13498 test_authonly_octeontx2_all),
13500 /** AES GCM Authenticated Encryption */
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_AES_GCM_authenticated_encryption_test_case_1),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GCM_authenticated_encryption_test_case_2),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_AES_GCM_authenticated_encryption_test_case_3),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_AES_GCM_authenticated_encryption_test_case_4),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GCM_authenticated_encryption_test_case_5),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_AES_GCM_authenticated_encryption_test_case_6),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_AES_GCM_authenticated_encryption_test_case_7),
13516 /** AES GCM Authenticated Decryption */
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_AES_GCM_authenticated_decryption_test_case_1),
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_AES_GCM_authenticated_decryption_test_case_2),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_AES_GCM_authenticated_decryption_test_case_3),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_AES_GCM_authenticated_decryption_test_case_4),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_AES_GCM_authenticated_decryption_test_case_5),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_AES_GCM_authenticated_decryption_test_case_6),
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_AES_GCM_authenticated_decryption_test_case_7),
13531 /** AES GMAC Authentication */
13532 TEST_CASE_ST(ut_setup, ut_teardown,
13533 test_AES_GMAC_authentication_test_case_1),
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_AES_GMAC_authentication_verify_test_case_1),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_AES_GMAC_authentication_test_case_2),
13538 TEST_CASE_ST(ut_setup, ut_teardown,
13539 test_AES_GMAC_authentication_verify_test_case_2),
13540 TEST_CASE_ST(ut_setup, ut_teardown,
13541 test_AES_GMAC_authentication_test_case_3),
13542 TEST_CASE_ST(ut_setup, ut_teardown,
13543 test_AES_GMAC_authentication_verify_test_case_3),
13545 /** SNOW 3G encrypt only (UEA2) */
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_snow3g_encryption_test_case_1),
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 test_snow3g_encryption_test_case_2),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_snow3g_encryption_test_case_3),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_snow3g_encryption_test_case_4),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_encryption_test_case_5),
13557 TEST_CASE_ST(ut_setup, ut_teardown,
13558 test_snow3g_encryption_test_case_1_oop),
13559 TEST_CASE_ST(ut_setup, ut_teardown,
13560 test_snow3g_decryption_test_case_1_oop),
13561 TEST_CASE_ST(ut_setup, ut_teardown,
13562 test_snow3g_encryption_test_case_1_oop_sgl),
13564 /** SNOW 3G decrypt only (UEA2) */
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_snow3g_decryption_test_case_1),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_snow3g_decryption_test_case_2),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_snow3g_decryption_test_case_3),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_snow3g_decryption_test_case_4),
13573 TEST_CASE_ST(ut_setup, ut_teardown,
13574 test_snow3g_decryption_test_case_5),
13576 TEST_CASE_ST(ut_setup, ut_teardown,
13577 test_snow3g_hash_generate_test_case_1),
13578 TEST_CASE_ST(ut_setup, ut_teardown,
13579 test_snow3g_hash_generate_test_case_2),
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_snow3g_hash_generate_test_case_3),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_snow3g_hash_verify_test_case_1),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_snow3g_hash_verify_test_case_2),
13586 TEST_CASE_ST(ut_setup, ut_teardown,
13587 test_snow3g_hash_verify_test_case_3),
13589 /** ZUC encrypt only (EEA3) */
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_zuc_encryption_test_case_1),
13592 TEST_CASE_ST(ut_setup, ut_teardown,
13593 test_zuc_encryption_test_case_2),
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_zuc_encryption_test_case_3),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_zuc_encryption_test_case_4),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_zuc_encryption_test_case_5),
13600 TEST_CASE_ST(ut_setup, ut_teardown,
13601 test_zuc_hash_generate_test_case_1),
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_zuc_hash_generate_test_case_2),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_zuc_hash_generate_test_case_3),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_zuc_hash_generate_test_case_4),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_zuc_hash_generate_test_case_5),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_zuc_encryption_test_case_6_sgl),
13613 /** KASUMI encrypt only (UEA1) */
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 test_kasumi_encryption_test_case_1),
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 test_kasumi_encryption_test_case_2),
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 test_kasumi_encryption_test_case_3),
13620 TEST_CASE_ST(ut_setup, ut_teardown,
13621 test_kasumi_encryption_test_case_4),
13622 TEST_CASE_ST(ut_setup, ut_teardown,
13623 test_kasumi_encryption_test_case_5),
13624 TEST_CASE_ST(ut_setup, ut_teardown,
13625 test_kasumi_encryption_test_case_1_sgl),
13626 TEST_CASE_ST(ut_setup, ut_teardown,
13627 test_kasumi_encryption_test_case_1_oop_sgl),
13628 /** KASUMI decrypt only (UEA1) */
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_kasumi_decryption_test_case_1),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_kasumi_decryption_test_case_2),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 test_kasumi_decryption_test_case_3),
13635 TEST_CASE_ST(ut_setup, ut_teardown,
13636 test_kasumi_decryption_test_case_4),
13637 TEST_CASE_ST(ut_setup, ut_teardown,
13638 test_kasumi_decryption_test_case_5),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 test_kasumi_encryption_test_case_1_oop),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 test_kasumi_decryption_test_case_1_oop),
13645 /** KASUMI hash only (UIA1) */
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_kasumi_hash_generate_test_case_1),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_kasumi_hash_generate_test_case_2),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 test_kasumi_hash_generate_test_case_3),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_kasumi_hash_generate_test_case_4),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_kasumi_hash_generate_test_case_5),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_kasumi_hash_generate_test_case_6),
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_kasumi_hash_verify_test_case_1),
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_kasumi_hash_verify_test_case_2),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_kasumi_hash_verify_test_case_3),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_kasumi_hash_verify_test_case_4),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 test_kasumi_hash_verify_test_case_5),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_null_cipher_only_operation),
13672 TEST_CASE_ST(ut_setup, ut_teardown,
13673 test_null_auth_only_operation),
13674 TEST_CASE_ST(ut_setup, ut_teardown,
13675 test_null_cipher_auth_operation),
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 test_null_auth_cipher_operation),
13679 /** Negative tests */
13680 TEST_CASE_ST(ut_setup, ut_teardown,
13681 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13682 TEST_CASE_ST(ut_setup, ut_teardown,
13683 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13684 TEST_CASE_ST(ut_setup, ut_teardown,
13685 authentication_verify_AES128_GMAC_fail_data_corrupt),
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13690 TEST_CASE_ST(ut_setup, ut_teardown,
13691 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13692 TEST_CASES_END() /**< NULL terminate unit test array */
13697 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13699 gbl_driver_id = rte_cryptodev_driver_id_get(
13700 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13702 if (gbl_driver_id == -1) {
13703 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13704 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13705 "are enabled in config file to run this testsuite.\n");
13706 return TEST_SKIPPED;
13709 return unit_test_suite_runner(&cryptodev_qat_testsuite);
13713 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13715 gbl_driver_id = rte_cryptodev_driver_id_get(
13716 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13718 if (gbl_driver_id == -1) {
13719 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13720 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13721 "in config file to run this testsuite.\n");
13722 return TEST_FAILED;
13725 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13729 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13731 gbl_driver_id = rte_cryptodev_driver_id_get(
13732 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13734 if (gbl_driver_id == -1) {
13735 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13736 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13737 "in config file to run this testsuite.\n");
13738 return TEST_SKIPPED;
13741 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
13745 test_cryptodev_openssl(void)
13747 gbl_driver_id = rte_cryptodev_driver_id_get(
13748 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13750 if (gbl_driver_id == -1) {
13751 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13752 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13753 "in config file to run this testsuite.\n");
13754 return TEST_SKIPPED;
13757 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
13761 test_cryptodev_aesni_gcm(void)
13763 gbl_driver_id = rte_cryptodev_driver_id_get(
13764 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13766 if (gbl_driver_id == -1) {
13767 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13768 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13769 "in config file to run this testsuite.\n");
13770 return TEST_SKIPPED;
13773 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
13777 test_cryptodev_null(void)
13779 gbl_driver_id = rte_cryptodev_driver_id_get(
13780 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13782 if (gbl_driver_id == -1) {
13783 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13784 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13785 "in config file to run this testsuite.\n");
13786 return TEST_SKIPPED;
13789 return unit_test_suite_runner(&cryptodev_null_testsuite);
13793 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13795 gbl_driver_id = rte_cryptodev_driver_id_get(
13796 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13798 if (gbl_driver_id == -1) {
13799 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13800 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13801 "in config file to run this testsuite.\n");
13802 return TEST_SKIPPED;
13805 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
13809 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13811 gbl_driver_id = rte_cryptodev_driver_id_get(
13812 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13814 if (gbl_driver_id == -1) {
13815 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13816 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13817 "in config file to run this testsuite.\n");
13818 return TEST_SKIPPED;
13821 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
13825 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13827 gbl_driver_id = rte_cryptodev_driver_id_get(
13828 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13830 if (gbl_driver_id == -1) {
13831 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13832 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13833 "in config file to run this testsuite.\n");
13834 return TEST_SKIPPED;
13837 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
13841 test_cryptodev_armv8(void)
13843 gbl_driver_id = rte_cryptodev_driver_id_get(
13844 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13846 if (gbl_driver_id == -1) {
13847 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13848 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13849 "in config file to run this testsuite.\n");
13850 return TEST_SKIPPED;
13853 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13857 test_cryptodev_mrvl(void)
13859 gbl_driver_id = rte_cryptodev_driver_id_get(
13860 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13862 if (gbl_driver_id == -1) {
13863 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13864 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13865 "in config file to run this testsuite.\n");
13866 return TEST_SKIPPED;
13869 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13872 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13875 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13877 gbl_driver_id = rte_cryptodev_driver_id_get(
13878 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13880 if (gbl_driver_id == -1) {
13881 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13882 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13883 "in config file to run this testsuite.\n");
13884 return TEST_SKIPPED;
13887 if (rte_cryptodev_driver_id_get(
13888 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13889 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13890 " enabled in config file to run this testsuite.\n");
13891 return TEST_SKIPPED;
13893 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13896 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13901 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13903 gbl_driver_id = rte_cryptodev_driver_id_get(
13904 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13906 if (gbl_driver_id == -1) {
13907 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13908 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13909 "in config file to run this testsuite.\n");
13910 return TEST_SKIPPED;
13913 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13917 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13919 gbl_driver_id = rte_cryptodev_driver_id_get(
13920 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13922 if (gbl_driver_id == -1) {
13923 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13924 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13925 "in config file to run this testsuite.\n");
13926 return TEST_SKIPPED;
13929 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13933 test_cryptodev_ccp(void)
13935 gbl_driver_id = rte_cryptodev_driver_id_get(
13936 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13938 if (gbl_driver_id == -1) {
13939 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13940 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13941 "in config file to run this testsuite.\n");
13942 return TEST_FAILED;
13945 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13949 test_cryptodev_octeontx(void)
13951 gbl_driver_id = rte_cryptodev_driver_id_get(
13952 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13953 if (gbl_driver_id == -1) {
13954 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13955 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13956 "enabled in config file to run this "
13958 return TEST_FAILED;
13960 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13964 test_cryptodev_octeontx2(void)
13966 gbl_driver_id = rte_cryptodev_driver_id_get(
13967 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13968 if (gbl_driver_id == -1) {
13969 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13970 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13971 "enabled in config file to run this "
13973 return TEST_FAILED;
13975 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13979 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13981 gbl_driver_id = rte_cryptodev_driver_id_get(
13982 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13984 if (gbl_driver_id == -1) {
13985 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13986 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13987 "in config file to run this testsuite.\n");
13988 return TEST_FAILED;
13991 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13995 test_cryptodev_nitrox(void)
13997 gbl_driver_id = rte_cryptodev_driver_id_get(
13998 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14000 if (gbl_driver_id == -1) {
14001 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14002 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14003 "in config file to run this testsuite.\n");
14004 return TEST_FAILED;
14007 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14010 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14011 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14012 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14013 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14014 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14015 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14016 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14017 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14018 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14019 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14020 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14021 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14022 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14023 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14024 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14025 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14026 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14027 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);