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;
2407 /* ***** SNOW 3G Tests ***** */
2409 create_wireless_algo_hash_session(uint8_t dev_id,
2410 const uint8_t *key, const uint8_t key_len,
2411 const uint8_t iv_len, const uint8_t auth_len,
2412 enum rte_crypto_auth_operation op,
2413 enum rte_crypto_auth_algorithm algo)
2415 uint8_t hash_key[key_len];
2418 struct crypto_testsuite_params *ts_params = &testsuite_params;
2419 struct crypto_unittest_params *ut_params = &unittest_params;
2421 memcpy(hash_key, key, key_len);
2423 debug_hexdump(stdout, "key:", key, key_len);
2425 /* Setup Authentication Parameters */
2426 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2427 ut_params->auth_xform.next = NULL;
2429 ut_params->auth_xform.auth.op = op;
2430 ut_params->auth_xform.auth.algo = algo;
2431 ut_params->auth_xform.auth.key.length = key_len;
2432 ut_params->auth_xform.auth.key.data = hash_key;
2433 ut_params->auth_xform.auth.digest_length = auth_len;
2434 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2435 ut_params->auth_xform.auth.iv.length = iv_len;
2436 ut_params->sess = rte_cryptodev_sym_session_create(
2437 ts_params->session_mpool);
2439 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2440 &ut_params->auth_xform,
2441 ts_params->session_priv_mpool);
2442 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2443 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2448 create_wireless_algo_cipher_session(uint8_t dev_id,
2449 enum rte_crypto_cipher_operation op,
2450 enum rte_crypto_cipher_algorithm algo,
2451 const uint8_t *key, const uint8_t key_len,
2454 uint8_t cipher_key[key_len];
2456 struct crypto_testsuite_params *ts_params = &testsuite_params;
2457 struct crypto_unittest_params *ut_params = &unittest_params;
2459 memcpy(cipher_key, key, key_len);
2461 /* Setup Cipher Parameters */
2462 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2463 ut_params->cipher_xform.next = NULL;
2465 ut_params->cipher_xform.cipher.algo = algo;
2466 ut_params->cipher_xform.cipher.op = op;
2467 ut_params->cipher_xform.cipher.key.data = cipher_key;
2468 ut_params->cipher_xform.cipher.key.length = key_len;
2469 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2470 ut_params->cipher_xform.cipher.iv.length = iv_len;
2472 debug_hexdump(stdout, "key:", key, key_len);
2474 /* Create Crypto session */
2475 ut_params->sess = rte_cryptodev_sym_session_create(
2476 ts_params->session_mpool);
2478 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2479 &ut_params->cipher_xform,
2480 ts_params->session_priv_mpool);
2481 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2482 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2487 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2488 unsigned int cipher_len,
2489 unsigned int cipher_offset)
2491 struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 struct crypto_unittest_params *ut_params = &unittest_params;
2494 /* Generate Crypto op data structure */
2495 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2496 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2497 TEST_ASSERT_NOT_NULL(ut_params->op,
2498 "Failed to allocate pktmbuf offload");
2500 /* Set crypto operation data parameters */
2501 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2503 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2505 /* set crypto operation source mbuf */
2506 sym_op->m_src = ut_params->ibuf;
2509 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2511 sym_op->cipher.data.length = cipher_len;
2512 sym_op->cipher.data.offset = cipher_offset;
2517 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2518 unsigned int cipher_len,
2519 unsigned int cipher_offset)
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2524 /* Generate Crypto op data structure */
2525 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2526 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2527 TEST_ASSERT_NOT_NULL(ut_params->op,
2528 "Failed to allocate pktmbuf offload");
2530 /* Set crypto operation data parameters */
2531 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2533 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2535 /* set crypto operation source mbuf */
2536 sym_op->m_src = ut_params->ibuf;
2537 sym_op->m_dst = ut_params->obuf;
2540 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2542 sym_op->cipher.data.length = cipher_len;
2543 sym_op->cipher.data.offset = cipher_offset;
2548 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2549 enum rte_crypto_cipher_operation cipher_op,
2550 enum rte_crypto_auth_operation auth_op,
2551 enum rte_crypto_auth_algorithm auth_algo,
2552 enum rte_crypto_cipher_algorithm cipher_algo,
2553 const uint8_t *key, uint8_t key_len,
2554 uint8_t auth_iv_len, uint8_t auth_len,
2555 uint8_t cipher_iv_len)
2558 uint8_t cipher_auth_key[key_len];
2561 struct crypto_testsuite_params *ts_params = &testsuite_params;
2562 struct crypto_unittest_params *ut_params = &unittest_params;
2564 memcpy(cipher_auth_key, key, key_len);
2566 /* Setup Authentication Parameters */
2567 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2568 ut_params->auth_xform.next = NULL;
2570 ut_params->auth_xform.auth.op = auth_op;
2571 ut_params->auth_xform.auth.algo = auth_algo;
2572 ut_params->auth_xform.auth.key.length = key_len;
2573 /* Hash key = cipher key */
2574 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2575 ut_params->auth_xform.auth.digest_length = auth_len;
2576 /* Auth IV will be after cipher IV */
2577 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2578 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2580 /* Setup Cipher Parameters */
2581 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2582 ut_params->cipher_xform.next = &ut_params->auth_xform;
2584 ut_params->cipher_xform.cipher.algo = cipher_algo;
2585 ut_params->cipher_xform.cipher.op = cipher_op;
2586 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2587 ut_params->cipher_xform.cipher.key.length = key_len;
2588 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2589 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2591 debug_hexdump(stdout, "key:", key, key_len);
2593 /* Create Crypto session*/
2594 ut_params->sess = rte_cryptodev_sym_session_create(
2595 ts_params->session_mpool);
2597 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2598 &ut_params->cipher_xform,
2599 ts_params->session_priv_mpool);
2601 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2602 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2607 create_wireless_cipher_auth_session(uint8_t dev_id,
2608 enum rte_crypto_cipher_operation cipher_op,
2609 enum rte_crypto_auth_operation auth_op,
2610 enum rte_crypto_auth_algorithm auth_algo,
2611 enum rte_crypto_cipher_algorithm cipher_algo,
2612 const struct wireless_test_data *tdata)
2614 const uint8_t key_len = tdata->key.len;
2615 uint8_t cipher_auth_key[key_len];
2618 struct crypto_testsuite_params *ts_params = &testsuite_params;
2619 struct crypto_unittest_params *ut_params = &unittest_params;
2620 const uint8_t *key = tdata->key.data;
2621 const uint8_t auth_len = tdata->digest.len;
2622 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2623 uint8_t auth_iv_len = tdata->auth_iv.len;
2625 memcpy(cipher_auth_key, key, key_len);
2627 /* Setup Authentication Parameters */
2628 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2629 ut_params->auth_xform.next = NULL;
2631 ut_params->auth_xform.auth.op = auth_op;
2632 ut_params->auth_xform.auth.algo = auth_algo;
2633 ut_params->auth_xform.auth.key.length = key_len;
2634 /* Hash key = cipher key */
2635 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2636 ut_params->auth_xform.auth.digest_length = auth_len;
2637 /* Auth IV will be after cipher IV */
2638 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2639 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2641 /* Setup Cipher Parameters */
2642 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2643 ut_params->cipher_xform.next = &ut_params->auth_xform;
2645 ut_params->cipher_xform.cipher.algo = cipher_algo;
2646 ut_params->cipher_xform.cipher.op = cipher_op;
2647 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2648 ut_params->cipher_xform.cipher.key.length = key_len;
2649 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2650 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2653 debug_hexdump(stdout, "key:", key, key_len);
2655 /* Create Crypto session*/
2656 ut_params->sess = rte_cryptodev_sym_session_create(
2657 ts_params->session_mpool);
2659 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2660 &ut_params->cipher_xform,
2661 ts_params->session_priv_mpool);
2663 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2664 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2669 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2670 const struct wireless_test_data *tdata)
2672 return create_wireless_cipher_auth_session(dev_id,
2673 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2674 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2675 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2679 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2680 enum rte_crypto_cipher_operation cipher_op,
2681 enum rte_crypto_auth_operation auth_op,
2682 enum rte_crypto_auth_algorithm auth_algo,
2683 enum rte_crypto_cipher_algorithm cipher_algo,
2684 const uint8_t *key, const uint8_t key_len,
2685 uint8_t auth_iv_len, uint8_t auth_len,
2686 uint8_t cipher_iv_len)
2688 uint8_t auth_cipher_key[key_len];
2690 struct crypto_testsuite_params *ts_params = &testsuite_params;
2691 struct crypto_unittest_params *ut_params = &unittest_params;
2693 memcpy(auth_cipher_key, key, key_len);
2695 /* Setup Authentication Parameters */
2696 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697 ut_params->auth_xform.auth.op = auth_op;
2698 ut_params->auth_xform.next = &ut_params->cipher_xform;
2699 ut_params->auth_xform.auth.algo = auth_algo;
2700 ut_params->auth_xform.auth.key.length = key_len;
2701 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2702 ut_params->auth_xform.auth.digest_length = auth_len;
2703 /* Auth IV will be after cipher IV */
2704 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2705 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2707 /* Setup Cipher Parameters */
2708 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2709 ut_params->cipher_xform.next = NULL;
2710 ut_params->cipher_xform.cipher.algo = cipher_algo;
2711 ut_params->cipher_xform.cipher.op = cipher_op;
2712 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2713 ut_params->cipher_xform.cipher.key.length = key_len;
2714 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2715 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2717 debug_hexdump(stdout, "key:", key, key_len);
2719 /* Create Crypto session*/
2720 ut_params->sess = rte_cryptodev_sym_session_create(
2721 ts_params->session_mpool);
2723 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2724 &ut_params->auth_xform,
2725 ts_params->session_priv_mpool);
2726 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2727 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2733 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2734 unsigned int auth_tag_len,
2735 const uint8_t *iv, unsigned int iv_len,
2736 unsigned int data_pad_len,
2737 enum rte_crypto_auth_operation op,
2738 unsigned int auth_len, unsigned int auth_offset)
2740 struct crypto_testsuite_params *ts_params = &testsuite_params;
2742 struct crypto_unittest_params *ut_params = &unittest_params;
2744 /* Generate Crypto op data structure */
2745 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2746 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2747 TEST_ASSERT_NOT_NULL(ut_params->op,
2748 "Failed to allocate pktmbuf offload");
2750 /* Set crypto operation data parameters */
2751 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2753 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2755 /* set crypto operation source mbuf */
2756 sym_op->m_src = ut_params->ibuf;
2759 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2762 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2763 ut_params->ibuf, auth_tag_len);
2765 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2766 "no room to append auth tag");
2767 ut_params->digest = sym_op->auth.digest.data;
2768 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2769 ut_params->ibuf, data_pad_len);
2770 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2771 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2773 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2775 debug_hexdump(stdout, "digest:",
2776 sym_op->auth.digest.data,
2779 sym_op->auth.data.length = auth_len;
2780 sym_op->auth.data.offset = auth_offset;
2786 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2787 enum rte_crypto_auth_operation op)
2789 struct crypto_testsuite_params *ts_params = &testsuite_params;
2790 struct crypto_unittest_params *ut_params = &unittest_params;
2792 const uint8_t *auth_tag = tdata->digest.data;
2793 const unsigned int auth_tag_len = tdata->digest.len;
2794 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2795 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2797 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2798 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2799 const uint8_t *auth_iv = tdata->auth_iv.data;
2800 const uint8_t auth_iv_len = tdata->auth_iv.len;
2801 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2802 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2804 /* Generate Crypto op data structure */
2805 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2806 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2807 TEST_ASSERT_NOT_NULL(ut_params->op,
2808 "Failed to allocate pktmbuf offload");
2809 /* Set crypto operation data parameters */
2810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2814 /* set crypto operation source mbuf */
2815 sym_op->m_src = ut_params->ibuf;
2818 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2819 ut_params->ibuf, auth_tag_len);
2821 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2822 "no room to append auth tag");
2823 ut_params->digest = sym_op->auth.digest.data;
2824 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2825 ut_params->ibuf, data_pad_len);
2826 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2827 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2829 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2831 debug_hexdump(stdout, "digest:",
2832 sym_op->auth.digest.data,
2835 /* Copy cipher and auth IVs at the end of the crypto operation */
2836 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2838 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2839 iv_ptr += cipher_iv_len;
2840 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2842 sym_op->cipher.data.length = cipher_len;
2843 sym_op->cipher.data.offset = 0;
2844 sym_op->auth.data.length = auth_len;
2845 sym_op->auth.data.offset = 0;
2851 create_zuc_cipher_hash_generate_operation(
2852 const struct wireless_test_data *tdata)
2854 return create_wireless_cipher_hash_operation(tdata,
2855 RTE_CRYPTO_AUTH_OP_GENERATE);
2859 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2860 const unsigned auth_tag_len,
2861 const uint8_t *auth_iv, uint8_t auth_iv_len,
2862 unsigned data_pad_len,
2863 enum rte_crypto_auth_operation op,
2864 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2865 const unsigned cipher_len, const unsigned cipher_offset,
2866 const unsigned auth_len, const unsigned auth_offset)
2868 struct crypto_testsuite_params *ts_params = &testsuite_params;
2869 struct crypto_unittest_params *ut_params = &unittest_params;
2871 /* Generate Crypto op data structure */
2872 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2873 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2874 TEST_ASSERT_NOT_NULL(ut_params->op,
2875 "Failed to allocate pktmbuf offload");
2876 /* Set crypto operation data parameters */
2877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2881 /* set crypto operation source mbuf */
2882 sym_op->m_src = ut_params->ibuf;
2885 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2886 ut_params->ibuf, auth_tag_len);
2888 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2889 "no room to append auth tag");
2890 ut_params->digest = sym_op->auth.digest.data;
2891 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2892 ut_params->ibuf, data_pad_len);
2893 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2894 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2896 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2898 debug_hexdump(stdout, "digest:",
2899 sym_op->auth.digest.data,
2902 /* Copy cipher and auth IVs at the end of the crypto operation */
2903 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2905 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2906 iv_ptr += cipher_iv_len;
2907 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2909 sym_op->cipher.data.length = cipher_len;
2910 sym_op->cipher.data.offset = cipher_offset;
2911 sym_op->auth.data.length = auth_len;
2912 sym_op->auth.data.offset = auth_offset;
2918 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2919 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2920 const uint8_t *auth_iv, uint8_t auth_iv_len,
2921 unsigned int data_pad_len,
2922 unsigned int cipher_len, unsigned int cipher_offset,
2923 unsigned int auth_len, unsigned int auth_offset,
2924 uint8_t op_mode, uint8_t do_sgl)
2926 struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 struct crypto_unittest_params *ut_params = &unittest_params;
2929 /* Generate Crypto op data structure */
2930 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2931 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2932 TEST_ASSERT_NOT_NULL(ut_params->op,
2933 "Failed to allocate pktmbuf offload");
2935 /* Set crypto operation data parameters */
2936 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2938 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2940 /* set crypto operation mbufs */
2941 sym_op->m_src = ut_params->ibuf;
2942 if (op_mode == OUT_OF_PLACE)
2943 sym_op->m_dst = ut_params->obuf;
2947 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2948 (op_mode == IN_PLACE ?
2949 ut_params->ibuf : ut_params->obuf),
2950 uint8_t *, data_pad_len);
2951 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2952 (op_mode == IN_PLACE ?
2953 ut_params->ibuf : ut_params->obuf),
2955 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2957 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2958 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2959 sym_op->m_src : sym_op->m_dst);
2960 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2961 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2962 sgl_buf = sgl_buf->next;
2964 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2965 uint8_t *, remaining_off);
2966 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2968 memset(sym_op->auth.digest.data, 0, remaining_off);
2969 while (sgl_buf->next != NULL) {
2970 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2971 0, rte_pktmbuf_data_len(sgl_buf));
2972 sgl_buf = sgl_buf->next;
2976 /* Copy cipher and auth IVs at the end of the crypto operation */
2977 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2978 ut_params->op, uint8_t *, IV_OFFSET);
2980 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2981 iv_ptr += cipher_iv_len;
2982 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2984 sym_op->cipher.data.length = cipher_len;
2985 sym_op->cipher.data.offset = cipher_offset;
2987 sym_op->auth.data.length = auth_len;
2988 sym_op->auth.data.offset = auth_offset;
2994 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2996 struct crypto_testsuite_params *ts_params = &testsuite_params;
2997 struct crypto_unittest_params *ut_params = &unittest_params;
3000 unsigned plaintext_pad_len;
3001 unsigned plaintext_len;
3004 /* Create SNOW 3G session */
3005 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3006 tdata->key.data, tdata->key.len,
3007 tdata->auth_iv.len, tdata->digest.len,
3008 RTE_CRYPTO_AUTH_OP_GENERATE,
3009 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3013 /* alloc mbuf and set payload */
3014 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3017 rte_pktmbuf_tailroom(ut_params->ibuf));
3019 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3020 /* Append data which is padded to a multiple of */
3021 /* the algorithms block size */
3022 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3023 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3025 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3027 /* Create SNOW 3G operation */
3028 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3029 tdata->auth_iv.data, tdata->auth_iv.len,
3030 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3031 tdata->validAuthLenInBits.len,
3036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3038 ut_params->obuf = ut_params->op->sym->m_src;
3039 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3040 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3041 + plaintext_pad_len;
3044 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3047 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3048 "SNOW 3G Generated auth tag not as expected");
3054 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3056 struct crypto_testsuite_params *ts_params = &testsuite_params;
3057 struct crypto_unittest_params *ut_params = &unittest_params;
3060 unsigned plaintext_pad_len;
3061 unsigned plaintext_len;
3064 /* Create SNOW 3G session */
3065 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3066 tdata->key.data, tdata->key.len,
3067 tdata->auth_iv.len, tdata->digest.len,
3068 RTE_CRYPTO_AUTH_OP_VERIFY,
3069 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3072 /* alloc mbuf and set payload */
3073 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3076 rte_pktmbuf_tailroom(ut_params->ibuf));
3078 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3079 /* Append data which is padded to a multiple of */
3080 /* the algorithms block size */
3081 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3082 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3084 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3086 /* Create SNOW 3G operation */
3087 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3089 tdata->auth_iv.data, tdata->auth_iv.len,
3091 RTE_CRYPTO_AUTH_OP_VERIFY,
3092 tdata->validAuthLenInBits.len,
3097 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3099 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3100 ut_params->obuf = ut_params->op->sym->m_src;
3101 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3102 + plaintext_pad_len;
3105 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3114 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3116 struct crypto_testsuite_params *ts_params = &testsuite_params;
3117 struct crypto_unittest_params *ut_params = &unittest_params;
3120 unsigned plaintext_pad_len;
3121 unsigned plaintext_len;
3124 /* Create KASUMI session */
3125 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3126 tdata->key.data, tdata->key.len,
3127 0, tdata->digest.len,
3128 RTE_CRYPTO_AUTH_OP_GENERATE,
3129 RTE_CRYPTO_AUTH_KASUMI_F9);
3133 /* alloc mbuf and set payload */
3134 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3136 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3137 rte_pktmbuf_tailroom(ut_params->ibuf));
3139 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3140 /* Append data which is padded to a multiple of */
3141 /* the algorithms block size */
3142 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3143 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3145 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3147 /* Create KASUMI operation */
3148 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3150 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3151 tdata->plaintext.len,
3156 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3158 ut_params->obuf = ut_params->op->sym->m_src;
3159 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3160 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3161 + plaintext_pad_len;
3164 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3167 DIGEST_BYTE_LENGTH_KASUMI_F9,
3168 "KASUMI Generated auth tag not as expected");
3174 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3176 struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 struct crypto_unittest_params *ut_params = &unittest_params;
3180 unsigned plaintext_pad_len;
3181 unsigned plaintext_len;
3184 /* Create KASUMI session */
3185 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186 tdata->key.data, tdata->key.len,
3187 0, tdata->digest.len,
3188 RTE_CRYPTO_AUTH_OP_VERIFY,
3189 RTE_CRYPTO_AUTH_KASUMI_F9);
3192 /* alloc mbuf and set payload */
3193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3196 rte_pktmbuf_tailroom(ut_params->ibuf));
3198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3199 /* Append data which is padded to a multiple */
3200 /* of the algorithms block size */
3201 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3204 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3206 /* Create KASUMI operation */
3207 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3211 RTE_CRYPTO_AUTH_OP_VERIFY,
3212 tdata->plaintext.len,
3217 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220 ut_params->obuf = ut_params->op->sym->m_src;
3221 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3222 + plaintext_pad_len;
3225 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3234 test_snow3g_hash_generate_test_case_1(void)
3236 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3240 test_snow3g_hash_generate_test_case_2(void)
3242 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3246 test_snow3g_hash_generate_test_case_3(void)
3248 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3252 test_snow3g_hash_generate_test_case_4(void)
3254 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3258 test_snow3g_hash_generate_test_case_5(void)
3260 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3264 test_snow3g_hash_generate_test_case_6(void)
3266 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3270 test_snow3g_hash_verify_test_case_1(void)
3272 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3277 test_snow3g_hash_verify_test_case_2(void)
3279 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3283 test_snow3g_hash_verify_test_case_3(void)
3285 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3289 test_snow3g_hash_verify_test_case_4(void)
3291 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3295 test_snow3g_hash_verify_test_case_5(void)
3297 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3301 test_snow3g_hash_verify_test_case_6(void)
3303 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3307 test_kasumi_hash_generate_test_case_1(void)
3309 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3313 test_kasumi_hash_generate_test_case_2(void)
3315 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3319 test_kasumi_hash_generate_test_case_3(void)
3321 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3325 test_kasumi_hash_generate_test_case_4(void)
3327 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3331 test_kasumi_hash_generate_test_case_5(void)
3333 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3337 test_kasumi_hash_generate_test_case_6(void)
3339 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3343 test_kasumi_hash_verify_test_case_1(void)
3345 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3349 test_kasumi_hash_verify_test_case_2(void)
3351 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3355 test_kasumi_hash_verify_test_case_3(void)
3357 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3361 test_kasumi_hash_verify_test_case_4(void)
3363 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3367 test_kasumi_hash_verify_test_case_5(void)
3369 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3373 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3375 struct crypto_testsuite_params *ts_params = &testsuite_params;
3376 struct crypto_unittest_params *ut_params = &unittest_params;
3379 uint8_t *plaintext, *ciphertext;
3380 unsigned plaintext_pad_len;
3381 unsigned plaintext_len;
3383 /* Create KASUMI session */
3384 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3385 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3386 RTE_CRYPTO_CIPHER_KASUMI_F8,
3387 tdata->key.data, tdata->key.len,
3388 tdata->cipher_iv.len);
3392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3394 /* Clear mbuf payload */
3395 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3396 rte_pktmbuf_tailroom(ut_params->ibuf));
3398 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3399 /* Append data which is padded to a multiple */
3400 /* of the algorithms block size */
3401 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3402 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3404 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3406 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3408 /* Create KASUMI operation */
3409 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3410 tdata->cipher_iv.len,
3411 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3412 tdata->validCipherOffsetInBits.len);
3416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3420 ut_params->obuf = ut_params->op->sym->m_dst;
3421 if (ut_params->obuf)
3422 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3424 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3426 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3428 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3429 (tdata->validCipherOffsetInBits.len >> 3);
3431 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3433 reference_ciphertext,
3434 tdata->validCipherLenInBits.len,
3435 "KASUMI Ciphertext data not as expected");
3440 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3442 struct crypto_testsuite_params *ts_params = &testsuite_params;
3443 struct crypto_unittest_params *ut_params = &unittest_params;
3447 unsigned int plaintext_pad_len;
3448 unsigned int plaintext_len;
3450 uint8_t buffer[10000];
3451 const uint8_t *ciphertext;
3453 struct rte_cryptodev_info dev_info;
3455 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3457 uint64_t feat_flags = dev_info.feature_flags;
3459 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3460 printf("Device doesn't support in-place scatter-gather. "
3465 /* Create KASUMI session */
3466 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3467 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3468 RTE_CRYPTO_CIPHER_KASUMI_F8,
3469 tdata->key.data, tdata->key.len,
3470 tdata->cipher_iv.len);
3474 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3477 /* Append data which is padded to a multiple */
3478 /* of the algorithms block size */
3479 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3481 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3482 plaintext_pad_len, 10, 0);
3484 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3486 /* Create KASUMI operation */
3487 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3488 tdata->cipher_iv.len,
3489 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3490 tdata->validCipherOffsetInBits.len);
3494 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3496 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3498 ut_params->obuf = ut_params->op->sym->m_dst;
3500 if (ut_params->obuf)
3501 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3502 plaintext_len, buffer);
3504 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3505 tdata->validCipherOffsetInBits.len >> 3,
3506 plaintext_len, buffer);
3509 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3511 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3512 (tdata->validCipherOffsetInBits.len >> 3);
3514 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3516 reference_ciphertext,
3517 tdata->validCipherLenInBits.len,
3518 "KASUMI Ciphertext data not as expected");
3523 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3525 struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 struct crypto_unittest_params *ut_params = &unittest_params;
3529 uint8_t *plaintext, *ciphertext;
3530 unsigned plaintext_pad_len;
3531 unsigned plaintext_len;
3533 /* Create KASUMI session */
3534 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3535 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3536 RTE_CRYPTO_CIPHER_KASUMI_F8,
3537 tdata->key.data, tdata->key.len,
3538 tdata->cipher_iv.len);
3542 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3543 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3545 /* Clear mbuf payload */
3546 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3547 rte_pktmbuf_tailroom(ut_params->ibuf));
3549 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3550 /* Append data which is padded to a multiple */
3551 /* of the algorithms block size */
3552 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3553 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3555 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3556 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3558 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3560 /* Create KASUMI operation */
3561 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3562 tdata->cipher_iv.len,
3563 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3564 tdata->validCipherOffsetInBits.len);
3568 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3570 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3572 ut_params->obuf = ut_params->op->sym->m_dst;
3573 if (ut_params->obuf)
3574 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3576 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3578 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3580 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3581 (tdata->validCipherOffsetInBits.len >> 3);
3583 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3585 reference_ciphertext,
3586 tdata->validCipherLenInBits.len,
3587 "KASUMI Ciphertext data not as expected");
3592 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3594 struct crypto_testsuite_params *ts_params = &testsuite_params;
3595 struct crypto_unittest_params *ut_params = &unittest_params;
3598 unsigned int plaintext_pad_len;
3599 unsigned int plaintext_len;
3601 const uint8_t *ciphertext;
3602 uint8_t buffer[2048];
3604 struct rte_cryptodev_info dev_info;
3606 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3608 uint64_t feat_flags = dev_info.feature_flags;
3609 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3610 printf("Device doesn't support out-of-place scatter-gather "
3611 "in both input and output mbufs. "
3616 /* Create KASUMI session */
3617 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3618 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3619 RTE_CRYPTO_CIPHER_KASUMI_F8,
3620 tdata->key.data, tdata->key.len,
3621 tdata->cipher_iv.len);
3625 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3626 /* Append data which is padded to a multiple */
3627 /* of the algorithms block size */
3628 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3630 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3631 plaintext_pad_len, 10, 0);
3632 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3633 plaintext_pad_len, 3, 0);
3635 /* Append data which is padded to a multiple */
3636 /* of the algorithms block size */
3637 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3639 /* Create KASUMI operation */
3640 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3641 tdata->cipher_iv.len,
3642 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3643 tdata->validCipherOffsetInBits.len);
3647 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3649 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3651 ut_params->obuf = ut_params->op->sym->m_dst;
3652 if (ut_params->obuf)
3653 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3654 plaintext_pad_len, buffer);
3656 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3657 tdata->validCipherOffsetInBits.len >> 3,
3658 plaintext_pad_len, buffer);
3660 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3661 (tdata->validCipherOffsetInBits.len >> 3);
3663 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3665 reference_ciphertext,
3666 tdata->validCipherLenInBits.len,
3667 "KASUMI Ciphertext data not as expected");
3673 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3675 struct crypto_testsuite_params *ts_params = &testsuite_params;
3676 struct crypto_unittest_params *ut_params = &unittest_params;
3679 uint8_t *ciphertext, *plaintext;
3680 unsigned ciphertext_pad_len;
3681 unsigned ciphertext_len;
3683 /* Create KASUMI session */
3684 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3685 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3686 RTE_CRYPTO_CIPHER_KASUMI_F8,
3687 tdata->key.data, tdata->key.len,
3688 tdata->cipher_iv.len);
3692 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3693 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3695 /* Clear mbuf payload */
3696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3697 rte_pktmbuf_tailroom(ut_params->ibuf));
3699 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3700 /* Append data which is padded to a multiple */
3701 /* of the algorithms block size */
3702 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3703 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3704 ciphertext_pad_len);
3705 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3706 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3708 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3710 /* Create KASUMI operation */
3711 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3712 tdata->cipher_iv.len,
3713 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3714 tdata->validCipherOffsetInBits.len);
3718 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3720 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3722 ut_params->obuf = ut_params->op->sym->m_dst;
3723 if (ut_params->obuf)
3724 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3726 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3728 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3730 const uint8_t *reference_plaintext = tdata->plaintext.data +
3731 (tdata->validCipherOffsetInBits.len >> 3);
3733 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3735 reference_plaintext,
3736 tdata->validCipherLenInBits.len,
3737 "KASUMI Plaintext data not as expected");
3742 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3744 struct crypto_testsuite_params *ts_params = &testsuite_params;
3745 struct crypto_unittest_params *ut_params = &unittest_params;
3748 uint8_t *ciphertext, *plaintext;
3749 unsigned ciphertext_pad_len;
3750 unsigned ciphertext_len;
3752 /* Create KASUMI session */
3753 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3754 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3755 RTE_CRYPTO_CIPHER_KASUMI_F8,
3756 tdata->key.data, tdata->key.len,
3757 tdata->cipher_iv.len);
3761 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3763 /* Clear mbuf payload */
3764 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3765 rte_pktmbuf_tailroom(ut_params->ibuf));
3767 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3768 /* Append data which is padded to a multiple */
3769 /* of the algorithms block size */
3770 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3771 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3772 ciphertext_pad_len);
3773 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3775 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3777 /* Create KASUMI operation */
3778 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3779 tdata->cipher_iv.len,
3780 tdata->ciphertext.len,
3781 tdata->validCipherOffsetInBits.len);
3785 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3787 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3789 ut_params->obuf = ut_params->op->sym->m_dst;
3790 if (ut_params->obuf)
3791 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3793 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3795 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3797 const uint8_t *reference_plaintext = tdata->plaintext.data +
3798 (tdata->validCipherOffsetInBits.len >> 3);
3800 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3802 reference_plaintext,
3803 tdata->validCipherLenInBits.len,
3804 "KASUMI Plaintext data not as expected");
3809 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3811 struct crypto_testsuite_params *ts_params = &testsuite_params;
3812 struct crypto_unittest_params *ut_params = &unittest_params;
3815 uint8_t *plaintext, *ciphertext;
3816 unsigned plaintext_pad_len;
3817 unsigned plaintext_len;
3819 /* Create SNOW 3G session */
3820 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3821 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3822 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3823 tdata->key.data, tdata->key.len,
3824 tdata->cipher_iv.len);
3828 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3830 /* Clear mbuf payload */
3831 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3832 rte_pktmbuf_tailroom(ut_params->ibuf));
3834 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3835 /* Append data which is padded to a multiple of */
3836 /* the algorithms block size */
3837 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3838 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3840 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3842 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3844 /* Create SNOW 3G operation */
3845 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3846 tdata->cipher_iv.len,
3847 tdata->validCipherLenInBits.len,
3852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3856 ut_params->obuf = ut_params->op->sym->m_dst;
3857 if (ut_params->obuf)
3858 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3860 ciphertext = plaintext;
3862 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3865 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3867 tdata->ciphertext.data,
3868 tdata->validDataLenInBits.len,
3869 "SNOW 3G Ciphertext data not as expected");
3875 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3877 struct crypto_testsuite_params *ts_params = &testsuite_params;
3878 struct crypto_unittest_params *ut_params = &unittest_params;
3879 uint8_t *plaintext, *ciphertext;
3882 unsigned plaintext_pad_len;
3883 unsigned plaintext_len;
3885 /* Create SNOW 3G session */
3886 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3887 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3888 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3889 tdata->key.data, tdata->key.len,
3890 tdata->cipher_iv.len);
3894 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3895 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3897 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3898 "Failed to allocate input buffer in mempool");
3899 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3900 "Failed to allocate output buffer in mempool");
3902 /* Clear mbuf payload */
3903 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3904 rte_pktmbuf_tailroom(ut_params->ibuf));
3906 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3907 /* Append data which is padded to a multiple of */
3908 /* the algorithms block size */
3909 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3910 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3912 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3913 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3915 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3917 /* Create SNOW 3G operation */
3918 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3919 tdata->cipher_iv.len,
3920 tdata->validCipherLenInBits.len,
3925 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3927 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3929 ut_params->obuf = ut_params->op->sym->m_dst;
3930 if (ut_params->obuf)
3931 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3933 ciphertext = plaintext;
3935 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3938 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3940 tdata->ciphertext.data,
3941 tdata->validDataLenInBits.len,
3942 "SNOW 3G Ciphertext data not as expected");
3947 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3949 struct crypto_testsuite_params *ts_params = &testsuite_params;
3950 struct crypto_unittest_params *ut_params = &unittest_params;
3953 unsigned int plaintext_pad_len;
3954 unsigned int plaintext_len;
3955 uint8_t buffer[10000];
3956 const uint8_t *ciphertext;
3958 struct rte_cryptodev_info dev_info;
3960 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3962 uint64_t feat_flags = dev_info.feature_flags;
3964 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3965 printf("Device doesn't support out-of-place scatter-gather "
3966 "in both input and output mbufs. "
3971 /* Create SNOW 3G session */
3972 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3973 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3974 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3975 tdata->key.data, tdata->key.len,
3976 tdata->cipher_iv.len);
3980 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3981 /* Append data which is padded to a multiple of */
3982 /* the algorithms block size */
3983 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3985 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3986 plaintext_pad_len, 10, 0);
3987 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3988 plaintext_pad_len, 3, 0);
3990 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3991 "Failed to allocate input buffer in mempool");
3992 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3993 "Failed to allocate output buffer in mempool");
3995 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3997 /* Create SNOW 3G operation */
3998 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3999 tdata->cipher_iv.len,
4000 tdata->validCipherLenInBits.len,
4005 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4007 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4009 ut_params->obuf = ut_params->op->sym->m_dst;
4010 if (ut_params->obuf)
4011 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4012 plaintext_len, buffer);
4014 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4015 plaintext_len, buffer);
4017 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4020 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4022 tdata->ciphertext.data,
4023 tdata->validDataLenInBits.len,
4024 "SNOW 3G Ciphertext data not as expected");
4029 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4031 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4033 uint8_t curr_byte, prev_byte;
4034 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4035 uint8_t lower_byte_mask = (1 << offset) - 1;
4038 prev_byte = buffer[0];
4039 buffer[0] >>= offset;
4041 for (i = 1; i < length_in_bytes; i++) {
4042 curr_byte = buffer[i];
4043 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4044 (curr_byte >> offset);
4045 prev_byte = curr_byte;
4050 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4052 struct crypto_testsuite_params *ts_params = &testsuite_params;
4053 struct crypto_unittest_params *ut_params = &unittest_params;
4054 uint8_t *plaintext, *ciphertext;
4056 uint32_t plaintext_len;
4057 uint32_t plaintext_pad_len;
4058 uint8_t extra_offset = 4;
4059 uint8_t *expected_ciphertext_shifted;
4061 /* Create SNOW 3G session */
4062 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4063 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4064 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4065 tdata->key.data, tdata->key.len,
4066 tdata->cipher_iv.len);
4070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4071 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4073 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4074 "Failed to allocate input buffer in mempool");
4075 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4076 "Failed to allocate output buffer in mempool");
4078 /* Clear mbuf payload */
4079 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4080 rte_pktmbuf_tailroom(ut_params->ibuf));
4082 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4084 * Append data which is padded to a
4085 * multiple of the algorithms block size
4087 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4089 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4092 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4094 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4095 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4097 #ifdef RTE_APP_TEST_DEBUG
4098 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4100 /* Create SNOW 3G operation */
4101 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4102 tdata->cipher_iv.len,
4103 tdata->validCipherLenInBits.len,
4108 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4110 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4112 ut_params->obuf = ut_params->op->sym->m_dst;
4113 if (ut_params->obuf)
4114 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4116 ciphertext = plaintext;
4118 #ifdef RTE_APP_TEST_DEBUG
4119 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4122 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4124 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4125 "failed to reserve memory for ciphertext shifted\n");
4127 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4128 ceil_byte_length(tdata->ciphertext.len));
4129 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4132 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4134 expected_ciphertext_shifted,
4135 tdata->validDataLenInBits.len,
4137 "SNOW 3G Ciphertext data not as expected");
4141 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4143 struct crypto_testsuite_params *ts_params = &testsuite_params;
4144 struct crypto_unittest_params *ut_params = &unittest_params;
4148 uint8_t *plaintext, *ciphertext;
4149 unsigned ciphertext_pad_len;
4150 unsigned ciphertext_len;
4152 /* Create SNOW 3G session */
4153 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4154 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4155 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4156 tdata->key.data, tdata->key.len,
4157 tdata->cipher_iv.len);
4161 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4163 /* Clear mbuf payload */
4164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4165 rte_pktmbuf_tailroom(ut_params->ibuf));
4167 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4168 /* Append data which is padded to a multiple of */
4169 /* the algorithms block size */
4170 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4171 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4172 ciphertext_pad_len);
4173 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4175 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4177 /* Create SNOW 3G operation */
4178 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4179 tdata->cipher_iv.len,
4180 tdata->validCipherLenInBits.len,
4181 tdata->cipher.offset_bits);
4185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188 ut_params->obuf = ut_params->op->sym->m_dst;
4189 if (ut_params->obuf)
4190 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4192 plaintext = ciphertext;
4194 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4197 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4198 tdata->plaintext.data,
4199 tdata->validDataLenInBits.len,
4200 "SNOW 3G Plaintext data not as expected");
4204 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4206 struct crypto_testsuite_params *ts_params = &testsuite_params;
4207 struct crypto_unittest_params *ut_params = &unittest_params;
4211 uint8_t *plaintext, *ciphertext;
4212 unsigned ciphertext_pad_len;
4213 unsigned ciphertext_len;
4215 /* Create SNOW 3G session */
4216 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4217 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4218 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4219 tdata->key.data, tdata->key.len,
4220 tdata->cipher_iv.len);
4224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4227 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4228 "Failed to allocate input buffer");
4229 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4230 "Failed to allocate output buffer");
4232 /* Clear mbuf payload */
4233 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4234 rte_pktmbuf_tailroom(ut_params->ibuf));
4236 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4237 rte_pktmbuf_tailroom(ut_params->obuf));
4239 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4240 /* Append data which is padded to a multiple of */
4241 /* the algorithms block size */
4242 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4243 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4244 ciphertext_pad_len);
4245 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4246 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4248 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4250 /* Create SNOW 3G operation */
4251 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4252 tdata->cipher_iv.len,
4253 tdata->validCipherLenInBits.len,
4258 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4260 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4261 ut_params->obuf = ut_params->op->sym->m_dst;
4262 if (ut_params->obuf)
4263 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4265 plaintext = ciphertext;
4267 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4270 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4271 tdata->plaintext.data,
4272 tdata->validDataLenInBits.len,
4273 "SNOW 3G Plaintext data not as expected");
4278 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4280 struct crypto_testsuite_params *ts_params = &testsuite_params;
4281 struct crypto_unittest_params *ut_params = &unittest_params;
4285 uint8_t *plaintext, *ciphertext;
4286 unsigned int plaintext_pad_len;
4287 unsigned int plaintext_len;
4289 struct rte_cryptodev_sym_capability_idx cap_idx;
4291 /* Check if device supports ZUC EEA3 */
4292 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4293 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4295 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4299 /* Check if device supports ZUC EIA3 */
4300 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4301 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4303 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4307 /* Create ZUC session */
4308 retval = create_zuc_cipher_auth_encrypt_generate_session(
4309 ts_params->valid_devs[0],
4313 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4315 /* clear mbuf payload */
4316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4317 rte_pktmbuf_tailroom(ut_params->ibuf));
4319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4320 /* Append data which is padded to a multiple of */
4321 /* the algorithms block size */
4322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4327 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4329 /* Create ZUC operation */
4330 retval = create_zuc_cipher_hash_generate_operation(tdata);
4334 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4336 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4337 ut_params->obuf = ut_params->op->sym->m_src;
4338 if (ut_params->obuf)
4339 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4341 ciphertext = plaintext;
4343 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4345 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4347 tdata->ciphertext.data,
4348 tdata->validDataLenInBits.len,
4349 "ZUC Ciphertext data not as expected");
4351 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4352 + plaintext_pad_len;
4355 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4359 "ZUC Generated auth tag not as expected");
4364 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4366 struct crypto_testsuite_params *ts_params = &testsuite_params;
4367 struct crypto_unittest_params *ut_params = &unittest_params;
4371 uint8_t *plaintext, *ciphertext;
4372 unsigned plaintext_pad_len;
4373 unsigned plaintext_len;
4375 /* Create SNOW 3G session */
4376 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4377 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4378 RTE_CRYPTO_AUTH_OP_GENERATE,
4379 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4380 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4381 tdata->key.data, tdata->key.len,
4382 tdata->auth_iv.len, tdata->digest.len,
4383 tdata->cipher_iv.len);
4386 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4388 /* clear mbuf payload */
4389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4390 rte_pktmbuf_tailroom(ut_params->ibuf));
4392 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4393 /* Append data which is padded to a multiple of */
4394 /* the algorithms block size */
4395 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4396 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4398 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4400 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4402 /* Create SNOW 3G operation */
4403 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4404 tdata->digest.len, tdata->auth_iv.data,
4406 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4407 tdata->cipher_iv.data, tdata->cipher_iv.len,
4408 tdata->validCipherLenInBits.len,
4410 tdata->validAuthLenInBits.len,
4416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4419 ut_params->obuf = ut_params->op->sym->m_src;
4420 if (ut_params->obuf)
4421 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4423 ciphertext = plaintext;
4425 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4429 tdata->ciphertext.data,
4430 tdata->validDataLenInBits.len,
4431 "SNOW 3G Ciphertext data not as expected");
4433 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4434 + plaintext_pad_len;
4437 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4440 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4441 "SNOW 3G Generated auth tag not as expected");
4446 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4447 uint8_t op_mode, uint8_t verify)
4449 struct crypto_testsuite_params *ts_params = &testsuite_params;
4450 struct crypto_unittest_params *ut_params = &unittest_params;
4454 uint8_t *plaintext = NULL, *ciphertext = NULL;
4455 unsigned int plaintext_pad_len;
4456 unsigned int plaintext_len;
4457 unsigned int ciphertext_pad_len;
4458 unsigned int ciphertext_len;
4460 struct rte_cryptodev_info dev_info;
4462 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4464 uint64_t feat_flags = dev_info.feature_flags;
4466 if (op_mode == OUT_OF_PLACE) {
4467 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4468 printf("Device doesn't support digest encrypted.\n");
4473 /* Create SNOW 3G session */
4474 retval = create_wireless_algo_auth_cipher_session(
4475 ts_params->valid_devs[0],
4476 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4477 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4478 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4479 : RTE_CRYPTO_AUTH_OP_GENERATE),
4480 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4481 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4482 tdata->key.data, tdata->key.len,
4483 tdata->auth_iv.len, tdata->digest.len,
4484 tdata->cipher_iv.len);
4489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4490 if (op_mode == OUT_OF_PLACE)
4491 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4493 /* clear mbuf payload */
4494 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4495 rte_pktmbuf_tailroom(ut_params->ibuf));
4496 if (op_mode == OUT_OF_PLACE)
4497 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4498 rte_pktmbuf_tailroom(ut_params->obuf));
4500 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4501 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4502 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4503 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4506 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4507 ciphertext_pad_len);
4508 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4509 if (op_mode == OUT_OF_PLACE)
4510 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4511 debug_hexdump(stdout, "ciphertext:", ciphertext,
4514 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4516 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4517 if (op_mode == OUT_OF_PLACE)
4518 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4519 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4522 /* Create SNOW 3G operation */
4523 retval = create_wireless_algo_auth_cipher_operation(
4525 tdata->cipher_iv.data, tdata->cipher_iv.len,
4526 tdata->auth_iv.data, tdata->auth_iv.len,
4527 (tdata->digest.offset_bytes == 0 ?
4528 (verify ? ciphertext_pad_len : plaintext_pad_len)
4529 : tdata->digest.offset_bytes),
4530 tdata->validCipherLenInBits.len,
4531 tdata->cipher.offset_bits,
4532 tdata->validAuthLenInBits.len,
4533 tdata->auth.offset_bits,
4539 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4542 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4544 ut_params->obuf = (op_mode == IN_PLACE ?
4545 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4548 if (ut_params->obuf)
4549 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4552 plaintext = ciphertext +
4553 (tdata->cipher.offset_bits >> 3);
4555 debug_hexdump(stdout, "plaintext:", plaintext,
4556 (tdata->plaintext.len >> 3) - tdata->digest.len);
4557 debug_hexdump(stdout, "plaintext expected:",
4558 tdata->plaintext.data,
4559 (tdata->plaintext.len >> 3) - tdata->digest.len);
4561 if (ut_params->obuf)
4562 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4565 ciphertext = plaintext;
4567 debug_hexdump(stdout, "ciphertext:", ciphertext,
4569 debug_hexdump(stdout, "ciphertext expected:",
4570 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4572 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4573 + (tdata->digest.offset_bytes == 0 ?
4574 plaintext_pad_len : tdata->digest.offset_bytes);
4576 debug_hexdump(stdout, "digest:", ut_params->digest,
4578 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4584 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4586 tdata->plaintext.data,
4587 tdata->plaintext.len >> 3,
4588 "SNOW 3G Plaintext data not as expected");
4590 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4592 tdata->ciphertext.data,
4593 tdata->validDataLenInBits.len,
4594 "SNOW 3G Ciphertext data not as expected");
4596 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4599 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4600 "SNOW 3G Generated auth tag not as expected");
4606 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4607 uint8_t op_mode, uint8_t verify)
4609 struct crypto_testsuite_params *ts_params = &testsuite_params;
4610 struct crypto_unittest_params *ut_params = &unittest_params;
4614 const uint8_t *plaintext = NULL;
4615 const uint8_t *ciphertext = NULL;
4616 const uint8_t *digest = NULL;
4617 unsigned int plaintext_pad_len;
4618 unsigned int plaintext_len;
4619 unsigned int ciphertext_pad_len;
4620 unsigned int ciphertext_len;
4621 uint8_t buffer[10000];
4622 uint8_t digest_buffer[10000];
4624 struct rte_cryptodev_info dev_info;
4626 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4628 uint64_t feat_flags = dev_info.feature_flags;
4630 if (op_mode == IN_PLACE) {
4631 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4632 printf("Device doesn't support in-place scatter-gather "
4633 "in both input and output mbufs.\n");
4637 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4638 printf("Device doesn't support out-of-place scatter-gather "
4639 "in both input and output mbufs.\n");
4642 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4643 printf("Device doesn't support digest encrypted.\n");
4648 /* Create SNOW 3G session */
4649 retval = create_wireless_algo_auth_cipher_session(
4650 ts_params->valid_devs[0],
4651 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4652 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4653 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4654 : RTE_CRYPTO_AUTH_OP_GENERATE),
4655 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4656 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4657 tdata->key.data, tdata->key.len,
4658 tdata->auth_iv.len, tdata->digest.len,
4659 tdata->cipher_iv.len);
4664 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4665 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4666 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4667 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4669 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4670 plaintext_pad_len, 15, 0);
4671 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4672 "Failed to allocate input buffer in mempool");
4674 if (op_mode == OUT_OF_PLACE) {
4675 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4676 plaintext_pad_len, 15, 0);
4677 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4678 "Failed to allocate output buffer in mempool");
4682 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4683 tdata->ciphertext.data);
4684 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4685 ciphertext_len, buffer);
4686 debug_hexdump(stdout, "ciphertext:", ciphertext,
4689 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4690 tdata->plaintext.data);
4691 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4692 plaintext_len, buffer);
4693 debug_hexdump(stdout, "plaintext:", plaintext,
4696 memset(buffer, 0, sizeof(buffer));
4698 /* Create SNOW 3G operation */
4699 retval = create_wireless_algo_auth_cipher_operation(
4701 tdata->cipher_iv.data, tdata->cipher_iv.len,
4702 tdata->auth_iv.data, tdata->auth_iv.len,
4703 (tdata->digest.offset_bytes == 0 ?
4704 (verify ? ciphertext_pad_len : plaintext_pad_len)
4705 : tdata->digest.offset_bytes),
4706 tdata->validCipherLenInBits.len,
4707 tdata->cipher.offset_bits,
4708 tdata->validAuthLenInBits.len,
4709 tdata->auth.offset_bits,
4715 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4720 ut_params->obuf = (op_mode == IN_PLACE ?
4721 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4724 if (ut_params->obuf)
4725 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4726 plaintext_len, buffer);
4728 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4729 plaintext_len, buffer);
4731 debug_hexdump(stdout, "plaintext:", plaintext,
4732 (tdata->plaintext.len >> 3) - tdata->digest.len);
4733 debug_hexdump(stdout, "plaintext expected:",
4734 tdata->plaintext.data,
4735 (tdata->plaintext.len >> 3) - tdata->digest.len);
4737 if (ut_params->obuf)
4738 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4739 ciphertext_len, buffer);
4741 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4742 ciphertext_len, buffer);
4744 debug_hexdump(stdout, "ciphertext:", ciphertext,
4746 debug_hexdump(stdout, "ciphertext expected:",
4747 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4749 if (ut_params->obuf)
4750 digest = rte_pktmbuf_read(ut_params->obuf,
4751 (tdata->digest.offset_bytes == 0 ?
4752 plaintext_pad_len : tdata->digest.offset_bytes),
4753 tdata->digest.len, digest_buffer);
4755 digest = rte_pktmbuf_read(ut_params->ibuf,
4756 (tdata->digest.offset_bytes == 0 ?
4757 plaintext_pad_len : tdata->digest.offset_bytes),
4758 tdata->digest.len, digest_buffer);
4760 debug_hexdump(stdout, "digest:", digest,
4762 debug_hexdump(stdout, "digest expected:",
4763 tdata->digest.data, tdata->digest.len);
4768 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4770 tdata->plaintext.data,
4771 tdata->plaintext.len >> 3,
4772 "SNOW 3G Plaintext data not as expected");
4774 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4776 tdata->ciphertext.data,
4777 tdata->validDataLenInBits.len,
4778 "SNOW 3G Ciphertext data not as expected");
4780 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4783 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4784 "SNOW 3G Generated auth tag not as expected");
4790 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4791 uint8_t op_mode, uint8_t verify)
4793 struct crypto_testsuite_params *ts_params = &testsuite_params;
4794 struct crypto_unittest_params *ut_params = &unittest_params;
4798 uint8_t *plaintext = NULL, *ciphertext = NULL;
4799 unsigned int plaintext_pad_len;
4800 unsigned int plaintext_len;
4801 unsigned int ciphertext_pad_len;
4802 unsigned int ciphertext_len;
4804 struct rte_cryptodev_info dev_info;
4806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4808 uint64_t feat_flags = dev_info.feature_flags;
4810 if (op_mode == OUT_OF_PLACE) {
4811 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4812 printf("Device doesn't support digest encrypted.\n");
4817 /* Create KASUMI session */
4818 retval = create_wireless_algo_auth_cipher_session(
4819 ts_params->valid_devs[0],
4820 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4821 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4822 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4823 : RTE_CRYPTO_AUTH_OP_GENERATE),
4824 RTE_CRYPTO_AUTH_KASUMI_F9,
4825 RTE_CRYPTO_CIPHER_KASUMI_F8,
4826 tdata->key.data, tdata->key.len,
4827 0, tdata->digest.len,
4828 tdata->cipher_iv.len);
4833 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4834 if (op_mode == OUT_OF_PLACE)
4835 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4837 /* clear mbuf payload */
4838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4839 rte_pktmbuf_tailroom(ut_params->ibuf));
4840 if (op_mode == OUT_OF_PLACE)
4841 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4842 rte_pktmbuf_tailroom(ut_params->obuf));
4844 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4850 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4851 ciphertext_pad_len);
4852 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4853 if (op_mode == OUT_OF_PLACE)
4854 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4855 debug_hexdump(stdout, "ciphertext:", ciphertext,
4858 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4860 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4861 if (op_mode == OUT_OF_PLACE)
4862 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4863 debug_hexdump(stdout, "plaintext:", plaintext,
4867 /* Create KASUMI operation */
4868 retval = create_wireless_algo_auth_cipher_operation(
4870 tdata->cipher_iv.data, tdata->cipher_iv.len,
4872 (tdata->digest.offset_bytes == 0 ?
4873 (verify ? ciphertext_pad_len : plaintext_pad_len)
4874 : tdata->digest.offset_bytes),
4875 tdata->validCipherLenInBits.len,
4876 tdata->validCipherOffsetInBits.len,
4877 tdata->validAuthLenInBits.len,
4884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4887 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4889 ut_params->obuf = (op_mode == IN_PLACE ?
4890 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4894 if (ut_params->obuf)
4895 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4898 plaintext = ciphertext;
4900 debug_hexdump(stdout, "plaintext:", plaintext,
4901 (tdata->plaintext.len >> 3) - tdata->digest.len);
4902 debug_hexdump(stdout, "plaintext expected:",
4903 tdata->plaintext.data,
4904 (tdata->plaintext.len >> 3) - tdata->digest.len);
4906 if (ut_params->obuf)
4907 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4910 ciphertext = plaintext;
4912 debug_hexdump(stdout, "ciphertext:", ciphertext,
4914 debug_hexdump(stdout, "ciphertext expected:",
4915 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4917 ut_params->digest = rte_pktmbuf_mtod(
4918 ut_params->obuf, uint8_t *) +
4919 (tdata->digest.offset_bytes == 0 ?
4920 plaintext_pad_len : tdata->digest.offset_bytes);
4922 debug_hexdump(stdout, "digest:", ut_params->digest,
4924 debug_hexdump(stdout, "digest expected:",
4925 tdata->digest.data, tdata->digest.len);
4930 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4932 tdata->plaintext.data,
4933 tdata->plaintext.len >> 3,
4934 "KASUMI Plaintext data not as expected");
4936 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4938 tdata->ciphertext.data,
4939 tdata->ciphertext.len >> 3,
4940 "KASUMI Ciphertext data not as expected");
4942 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4945 DIGEST_BYTE_LENGTH_KASUMI_F9,
4946 "KASUMI Generated auth tag not as expected");
4952 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4953 uint8_t op_mode, uint8_t verify)
4955 struct crypto_testsuite_params *ts_params = &testsuite_params;
4956 struct crypto_unittest_params *ut_params = &unittest_params;
4960 const uint8_t *plaintext = NULL;
4961 const uint8_t *ciphertext = NULL;
4962 const uint8_t *digest = NULL;
4963 unsigned int plaintext_pad_len;
4964 unsigned int plaintext_len;
4965 unsigned int ciphertext_pad_len;
4966 unsigned int ciphertext_len;
4967 uint8_t buffer[10000];
4968 uint8_t digest_buffer[10000];
4970 struct rte_cryptodev_info dev_info;
4972 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4974 uint64_t feat_flags = dev_info.feature_flags;
4976 if (op_mode == IN_PLACE) {
4977 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4978 printf("Device doesn't support in-place scatter-gather "
4979 "in both input and output mbufs.\n");
4983 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4984 printf("Device doesn't support out-of-place scatter-gather "
4985 "in both input and output mbufs.\n");
4988 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4989 printf("Device doesn't support digest encrypted.\n");
4994 /* Create KASUMI session */
4995 retval = create_wireless_algo_auth_cipher_session(
4996 ts_params->valid_devs[0],
4997 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4998 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4999 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5000 : RTE_CRYPTO_AUTH_OP_GENERATE),
5001 RTE_CRYPTO_AUTH_KASUMI_F9,
5002 RTE_CRYPTO_CIPHER_KASUMI_F8,
5003 tdata->key.data, tdata->key.len,
5004 0, tdata->digest.len,
5005 tdata->cipher_iv.len);
5010 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5011 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5012 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5015 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5016 plaintext_pad_len, 15, 0);
5017 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5018 "Failed to allocate input buffer in mempool");
5020 if (op_mode == OUT_OF_PLACE) {
5021 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5022 plaintext_pad_len, 15, 0);
5023 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5024 "Failed to allocate output buffer in mempool");
5028 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5029 tdata->ciphertext.data);
5030 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5031 ciphertext_len, buffer);
5032 debug_hexdump(stdout, "ciphertext:", ciphertext,
5035 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5036 tdata->plaintext.data);
5037 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5038 plaintext_len, buffer);
5039 debug_hexdump(stdout, "plaintext:", plaintext,
5042 memset(buffer, 0, sizeof(buffer));
5044 /* Create KASUMI operation */
5045 retval = create_wireless_algo_auth_cipher_operation(
5047 tdata->cipher_iv.data, tdata->cipher_iv.len,
5049 (tdata->digest.offset_bytes == 0 ?
5050 (verify ? ciphertext_pad_len : plaintext_pad_len)
5051 : tdata->digest.offset_bytes),
5052 tdata->validCipherLenInBits.len,
5053 tdata->validCipherOffsetInBits.len,
5054 tdata->validAuthLenInBits.len,
5061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5064 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5066 ut_params->obuf = (op_mode == IN_PLACE ?
5067 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5070 if (ut_params->obuf)
5071 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5072 plaintext_len, buffer);
5074 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5075 plaintext_len, buffer);
5077 debug_hexdump(stdout, "plaintext:", plaintext,
5078 (tdata->plaintext.len >> 3) - tdata->digest.len);
5079 debug_hexdump(stdout, "plaintext expected:",
5080 tdata->plaintext.data,
5081 (tdata->plaintext.len >> 3) - tdata->digest.len);
5083 if (ut_params->obuf)
5084 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5085 ciphertext_len, buffer);
5087 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5088 ciphertext_len, buffer);
5090 debug_hexdump(stdout, "ciphertext:", ciphertext,
5092 debug_hexdump(stdout, "ciphertext expected:",
5093 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5095 if (ut_params->obuf)
5096 digest = rte_pktmbuf_read(ut_params->obuf,
5097 (tdata->digest.offset_bytes == 0 ?
5098 plaintext_pad_len : tdata->digest.offset_bytes),
5099 tdata->digest.len, digest_buffer);
5101 digest = rte_pktmbuf_read(ut_params->ibuf,
5102 (tdata->digest.offset_bytes == 0 ?
5103 plaintext_pad_len : tdata->digest.offset_bytes),
5104 tdata->digest.len, digest_buffer);
5106 debug_hexdump(stdout, "digest:", digest,
5108 debug_hexdump(stdout, "digest expected:",
5109 tdata->digest.data, tdata->digest.len);
5114 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5116 tdata->plaintext.data,
5117 tdata->plaintext.len >> 3,
5118 "KASUMI Plaintext data not as expected");
5120 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5122 tdata->ciphertext.data,
5123 tdata->validDataLenInBits.len,
5124 "KASUMI Ciphertext data not as expected");
5126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5129 DIGEST_BYTE_LENGTH_KASUMI_F9,
5130 "KASUMI Generated auth tag not as expected");
5136 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5138 struct crypto_testsuite_params *ts_params = &testsuite_params;
5139 struct crypto_unittest_params *ut_params = &unittest_params;
5143 uint8_t *plaintext, *ciphertext;
5144 unsigned plaintext_pad_len;
5145 unsigned plaintext_len;
5147 /* Create KASUMI session */
5148 retval = create_wireless_algo_cipher_auth_session(
5149 ts_params->valid_devs[0],
5150 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5151 RTE_CRYPTO_AUTH_OP_GENERATE,
5152 RTE_CRYPTO_AUTH_KASUMI_F9,
5153 RTE_CRYPTO_CIPHER_KASUMI_F8,
5154 tdata->key.data, tdata->key.len,
5155 0, tdata->digest.len,
5156 tdata->cipher_iv.len);
5160 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5162 /* clear mbuf payload */
5163 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5164 rte_pktmbuf_tailroom(ut_params->ibuf));
5166 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5167 /* Append data which is padded to a multiple of */
5168 /* the algorithms block size */
5169 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5170 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5172 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5174 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5176 /* Create KASUMI operation */
5177 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5178 tdata->digest.len, NULL, 0,
5179 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5180 tdata->cipher_iv.data, tdata->cipher_iv.len,
5181 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5182 tdata->validCipherOffsetInBits.len,
5183 tdata->validAuthLenInBits.len,
5189 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5193 if (ut_params->op->sym->m_dst)
5194 ut_params->obuf = ut_params->op->sym->m_dst;
5196 ut_params->obuf = ut_params->op->sym->m_src;
5198 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5199 tdata->validCipherOffsetInBits.len >> 3);
5201 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5202 + plaintext_pad_len;
5204 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5205 (tdata->validCipherOffsetInBits.len >> 3);
5207 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5209 reference_ciphertext,
5210 tdata->validCipherLenInBits.len,
5211 "KASUMI Ciphertext data not as expected");
5214 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5217 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5218 "KASUMI Generated auth tag not as expected");
5223 test_zuc_encryption(const struct wireless_test_data *tdata)
5225 struct crypto_testsuite_params *ts_params = &testsuite_params;
5226 struct crypto_unittest_params *ut_params = &unittest_params;
5229 uint8_t *plaintext, *ciphertext;
5230 unsigned plaintext_pad_len;
5231 unsigned plaintext_len;
5233 struct rte_cryptodev_sym_capability_idx cap_idx;
5235 /* Check if device supports ZUC EEA3 */
5236 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5237 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5243 /* Create ZUC session */
5244 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5245 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5246 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5247 tdata->key.data, tdata->key.len,
5248 tdata->cipher_iv.len);
5252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5254 /* Clear mbuf payload */
5255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5256 rte_pktmbuf_tailroom(ut_params->ibuf));
5258 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5259 /* Append data which is padded to a multiple */
5260 /* of the algorithms block size */
5261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5264 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5266 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5268 /* Create ZUC operation */
5269 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5270 tdata->cipher_iv.len,
5271 tdata->plaintext.len,
5276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5280 ut_params->obuf = ut_params->op->sym->m_dst;
5281 if (ut_params->obuf)
5282 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5284 ciphertext = plaintext;
5286 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5289 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5291 tdata->ciphertext.data,
5292 tdata->validCipherLenInBits.len,
5293 "ZUC Ciphertext data not as expected");
5298 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5300 struct crypto_testsuite_params *ts_params = &testsuite_params;
5301 struct crypto_unittest_params *ut_params = &unittest_params;
5305 unsigned int plaintext_pad_len;
5306 unsigned int plaintext_len;
5307 const uint8_t *ciphertext;
5308 uint8_t ciphertext_buffer[2048];
5309 struct rte_cryptodev_info dev_info;
5311 struct rte_cryptodev_sym_capability_idx cap_idx;
5313 /* Check if device supports ZUC EEA3 */
5314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5315 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5317 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5321 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5323 uint64_t feat_flags = dev_info.feature_flags;
5325 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5326 printf("Device doesn't support in-place scatter-gather. "
5331 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5333 /* Append data which is padded to a multiple */
5334 /* of the algorithms block size */
5335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5337 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5338 plaintext_pad_len, 10, 0);
5340 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5341 tdata->plaintext.data);
5343 /* Create ZUC session */
5344 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5345 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5346 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5347 tdata->key.data, tdata->key.len,
5348 tdata->cipher_iv.len);
5352 /* Clear mbuf payload */
5354 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5356 /* Create ZUC operation */
5357 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5358 tdata->cipher_iv.len, tdata->plaintext.len,
5363 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5365 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5367 ut_params->obuf = ut_params->op->sym->m_dst;
5368 if (ut_params->obuf)
5369 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5370 0, plaintext_len, ciphertext_buffer);
5372 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5373 0, plaintext_len, ciphertext_buffer);
5376 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5379 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5381 tdata->ciphertext.data,
5382 tdata->validCipherLenInBits.len,
5383 "ZUC Ciphertext data not as expected");
5389 test_zuc_authentication(const struct wireless_test_data *tdata)
5391 struct crypto_testsuite_params *ts_params = &testsuite_params;
5392 struct crypto_unittest_params *ut_params = &unittest_params;
5395 unsigned plaintext_pad_len;
5396 unsigned plaintext_len;
5399 struct rte_cryptodev_sym_capability_idx cap_idx;
5401 /* Check if device supports ZUC EIA3 */
5402 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5403 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5405 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5409 /* Create ZUC session */
5410 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5411 tdata->key.data, tdata->key.len,
5412 tdata->auth_iv.len, tdata->digest.len,
5413 RTE_CRYPTO_AUTH_OP_GENERATE,
5414 RTE_CRYPTO_AUTH_ZUC_EIA3);
5418 /* alloc mbuf and set payload */
5419 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5421 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5422 rte_pktmbuf_tailroom(ut_params->ibuf));
5424 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5425 /* Append data which is padded to a multiple of */
5426 /* the algorithms block size */
5427 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5428 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5430 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5432 /* Create ZUC operation */
5433 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5434 tdata->auth_iv.data, tdata->auth_iv.len,
5435 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5436 tdata->validAuthLenInBits.len,
5441 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5443 ut_params->obuf = ut_params->op->sym->m_src;
5444 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5445 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5446 + plaintext_pad_len;
5449 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5452 DIGEST_BYTE_LENGTH_KASUMI_F9,
5453 "ZUC Generated auth tag not as expected");
5459 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5460 uint8_t op_mode, uint8_t verify)
5462 struct crypto_testsuite_params *ts_params = &testsuite_params;
5463 struct crypto_unittest_params *ut_params = &unittest_params;
5467 uint8_t *plaintext = NULL, *ciphertext = NULL;
5468 unsigned int plaintext_pad_len;
5469 unsigned int plaintext_len;
5470 unsigned int ciphertext_pad_len;
5471 unsigned int ciphertext_len;
5473 struct rte_cryptodev_info dev_info;
5474 struct rte_cryptodev_sym_capability_idx cap_idx;
5476 /* Check if device supports ZUC EIA3 */
5477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5478 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5480 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5484 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5486 uint64_t feat_flags = dev_info.feature_flags;
5488 if (op_mode == OUT_OF_PLACE) {
5489 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5490 printf("Device doesn't support digest encrypted.\n");
5495 /* Create ZUC session */
5496 retval = create_wireless_algo_auth_cipher_session(
5497 ts_params->valid_devs[0],
5498 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5499 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5500 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5501 : RTE_CRYPTO_AUTH_OP_GENERATE),
5502 RTE_CRYPTO_AUTH_ZUC_EIA3,
5503 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5504 tdata->key.data, tdata->key.len,
5505 tdata->auth_iv.len, tdata->digest.len,
5506 tdata->cipher_iv.len);
5511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5512 if (op_mode == OUT_OF_PLACE)
5513 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5515 /* clear mbuf payload */
5516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5517 rte_pktmbuf_tailroom(ut_params->ibuf));
5518 if (op_mode == OUT_OF_PLACE)
5519 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5520 rte_pktmbuf_tailroom(ut_params->obuf));
5522 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5523 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5524 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5525 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5528 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5529 ciphertext_pad_len);
5530 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5531 if (op_mode == OUT_OF_PLACE)
5532 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5533 debug_hexdump(stdout, "ciphertext:", ciphertext,
5536 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5538 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5539 if (op_mode == OUT_OF_PLACE)
5540 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5541 debug_hexdump(stdout, "plaintext:", plaintext,
5545 /* Create ZUC operation */
5546 retval = create_wireless_algo_auth_cipher_operation(
5548 tdata->cipher_iv.data, tdata->cipher_iv.len,
5549 tdata->auth_iv.data, tdata->auth_iv.len,
5550 (tdata->digest.offset_bytes == 0 ?
5551 (verify ? ciphertext_pad_len : plaintext_pad_len)
5552 : tdata->digest.offset_bytes),
5553 tdata->validCipherLenInBits.len,
5554 tdata->validCipherOffsetInBits.len,
5555 tdata->validAuthLenInBits.len,
5562 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5565 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5567 ut_params->obuf = (op_mode == IN_PLACE ?
5568 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5572 if (ut_params->obuf)
5573 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5576 plaintext = ciphertext;
5578 debug_hexdump(stdout, "plaintext:", plaintext,
5579 (tdata->plaintext.len >> 3) - tdata->digest.len);
5580 debug_hexdump(stdout, "plaintext expected:",
5581 tdata->plaintext.data,
5582 (tdata->plaintext.len >> 3) - tdata->digest.len);
5584 if (ut_params->obuf)
5585 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5588 ciphertext = plaintext;
5590 debug_hexdump(stdout, "ciphertext:", ciphertext,
5592 debug_hexdump(stdout, "ciphertext expected:",
5593 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5595 ut_params->digest = rte_pktmbuf_mtod(
5596 ut_params->obuf, uint8_t *) +
5597 (tdata->digest.offset_bytes == 0 ?
5598 plaintext_pad_len : tdata->digest.offset_bytes);
5600 debug_hexdump(stdout, "digest:", ut_params->digest,
5602 debug_hexdump(stdout, "digest expected:",
5603 tdata->digest.data, tdata->digest.len);
5608 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5610 tdata->plaintext.data,
5611 tdata->plaintext.len >> 3,
5612 "ZUC Plaintext data not as expected");
5614 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5616 tdata->ciphertext.data,
5617 tdata->ciphertext.len >> 3,
5618 "ZUC Ciphertext data not as expected");
5620 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5623 DIGEST_BYTE_LENGTH_KASUMI_F9,
5624 "ZUC Generated auth tag not as expected");
5630 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5631 uint8_t op_mode, uint8_t verify)
5633 struct crypto_testsuite_params *ts_params = &testsuite_params;
5634 struct crypto_unittest_params *ut_params = &unittest_params;
5638 const uint8_t *plaintext = NULL;
5639 const uint8_t *ciphertext = NULL;
5640 const uint8_t *digest = NULL;
5641 unsigned int plaintext_pad_len;
5642 unsigned int plaintext_len;
5643 unsigned int ciphertext_pad_len;
5644 unsigned int ciphertext_len;
5645 uint8_t buffer[10000];
5646 uint8_t digest_buffer[10000];
5648 struct rte_cryptodev_info dev_info;
5649 struct rte_cryptodev_sym_capability_idx cap_idx;
5651 /* Check if device supports ZUC EIA3 */
5652 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5653 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5655 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5659 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5661 uint64_t feat_flags = dev_info.feature_flags;
5663 if (op_mode == IN_PLACE) {
5664 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5665 printf("Device doesn't support in-place scatter-gather "
5666 "in both input and output mbufs.\n");
5670 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5671 printf("Device doesn't support out-of-place scatter-gather "
5672 "in both input and output mbufs.\n");
5675 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5676 printf("Device doesn't support digest encrypted.\n");
5681 /* Create ZUC session */
5682 retval = create_wireless_algo_auth_cipher_session(
5683 ts_params->valid_devs[0],
5684 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5685 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5686 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5687 : RTE_CRYPTO_AUTH_OP_GENERATE),
5688 RTE_CRYPTO_AUTH_ZUC_EIA3,
5689 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5690 tdata->key.data, tdata->key.len,
5691 tdata->auth_iv.len, tdata->digest.len,
5692 tdata->cipher_iv.len);
5697 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5698 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5699 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5700 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5702 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5703 plaintext_pad_len, 15, 0);
5704 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5705 "Failed to allocate input buffer in mempool");
5707 if (op_mode == OUT_OF_PLACE) {
5708 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5709 plaintext_pad_len, 15, 0);
5710 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5711 "Failed to allocate output buffer in mempool");
5715 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5716 tdata->ciphertext.data);
5717 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5718 ciphertext_len, buffer);
5719 debug_hexdump(stdout, "ciphertext:", ciphertext,
5722 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5723 tdata->plaintext.data);
5724 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5725 plaintext_len, buffer);
5726 debug_hexdump(stdout, "plaintext:", plaintext,
5729 memset(buffer, 0, sizeof(buffer));
5731 /* Create ZUC operation */
5732 retval = create_wireless_algo_auth_cipher_operation(
5734 tdata->cipher_iv.data, tdata->cipher_iv.len,
5736 (tdata->digest.offset_bytes == 0 ?
5737 (verify ? ciphertext_pad_len : plaintext_pad_len)
5738 : tdata->digest.offset_bytes),
5739 tdata->validCipherLenInBits.len,
5740 tdata->validCipherOffsetInBits.len,
5741 tdata->validAuthLenInBits.len,
5748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5751 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5753 ut_params->obuf = (op_mode == IN_PLACE ?
5754 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5757 if (ut_params->obuf)
5758 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5759 plaintext_len, buffer);
5761 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5762 plaintext_len, buffer);
5764 debug_hexdump(stdout, "plaintext:", plaintext,
5765 (tdata->plaintext.len >> 3) - tdata->digest.len);
5766 debug_hexdump(stdout, "plaintext expected:",
5767 tdata->plaintext.data,
5768 (tdata->plaintext.len >> 3) - tdata->digest.len);
5770 if (ut_params->obuf)
5771 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5772 ciphertext_len, buffer);
5774 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5775 ciphertext_len, buffer);
5777 debug_hexdump(stdout, "ciphertext:", ciphertext,
5779 debug_hexdump(stdout, "ciphertext expected:",
5780 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5782 if (ut_params->obuf)
5783 digest = rte_pktmbuf_read(ut_params->obuf,
5784 (tdata->digest.offset_bytes == 0 ?
5785 plaintext_pad_len : tdata->digest.offset_bytes),
5786 tdata->digest.len, digest_buffer);
5788 digest = rte_pktmbuf_read(ut_params->ibuf,
5789 (tdata->digest.offset_bytes == 0 ?
5790 plaintext_pad_len : tdata->digest.offset_bytes),
5791 tdata->digest.len, digest_buffer);
5793 debug_hexdump(stdout, "digest:", digest,
5795 debug_hexdump(stdout, "digest expected:",
5796 tdata->digest.data, tdata->digest.len);
5801 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5803 tdata->plaintext.data,
5804 tdata->plaintext.len >> 3,
5805 "ZUC Plaintext data not as expected");
5807 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5809 tdata->ciphertext.data,
5810 tdata->validDataLenInBits.len,
5811 "ZUC Ciphertext data not as expected");
5813 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5816 DIGEST_BYTE_LENGTH_KASUMI_F9,
5817 "ZUC Generated auth tag not as expected");
5823 test_kasumi_encryption_test_case_1(void)
5825 return test_kasumi_encryption(&kasumi_test_case_1);
5829 test_kasumi_encryption_test_case_1_sgl(void)
5831 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5835 test_kasumi_encryption_test_case_1_oop(void)
5837 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5841 test_kasumi_encryption_test_case_1_oop_sgl(void)
5843 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5847 test_kasumi_encryption_test_case_2(void)
5849 return test_kasumi_encryption(&kasumi_test_case_2);
5853 test_kasumi_encryption_test_case_3(void)
5855 return test_kasumi_encryption(&kasumi_test_case_3);
5859 test_kasumi_encryption_test_case_4(void)
5861 return test_kasumi_encryption(&kasumi_test_case_4);
5865 test_kasumi_encryption_test_case_5(void)
5867 return test_kasumi_encryption(&kasumi_test_case_5);
5871 test_kasumi_decryption_test_case_1(void)
5873 return test_kasumi_decryption(&kasumi_test_case_1);
5877 test_kasumi_decryption_test_case_1_oop(void)
5879 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5883 test_kasumi_decryption_test_case_2(void)
5885 return test_kasumi_decryption(&kasumi_test_case_2);
5889 test_kasumi_decryption_test_case_3(void)
5891 return test_kasumi_decryption(&kasumi_test_case_3);
5895 test_kasumi_decryption_test_case_4(void)
5897 return test_kasumi_decryption(&kasumi_test_case_4);
5901 test_kasumi_decryption_test_case_5(void)
5903 return test_kasumi_decryption(&kasumi_test_case_5);
5906 test_snow3g_encryption_test_case_1(void)
5908 return test_snow3g_encryption(&snow3g_test_case_1);
5912 test_snow3g_encryption_test_case_1_oop(void)
5914 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5918 test_snow3g_encryption_test_case_1_oop_sgl(void)
5920 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5925 test_snow3g_encryption_test_case_1_offset_oop(void)
5927 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5931 test_snow3g_encryption_test_case_2(void)
5933 return test_snow3g_encryption(&snow3g_test_case_2);
5937 test_snow3g_encryption_test_case_3(void)
5939 return test_snow3g_encryption(&snow3g_test_case_3);
5943 test_snow3g_encryption_test_case_4(void)
5945 return test_snow3g_encryption(&snow3g_test_case_4);
5949 test_snow3g_encryption_test_case_5(void)
5951 return test_snow3g_encryption(&snow3g_test_case_5);
5955 test_snow3g_decryption_test_case_1(void)
5957 return test_snow3g_decryption(&snow3g_test_case_1);
5961 test_snow3g_decryption_test_case_1_oop(void)
5963 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5967 test_snow3g_decryption_test_case_2(void)
5969 return test_snow3g_decryption(&snow3g_test_case_2);
5973 test_snow3g_decryption_test_case_3(void)
5975 return test_snow3g_decryption(&snow3g_test_case_3);
5979 test_snow3g_decryption_test_case_4(void)
5981 return test_snow3g_decryption(&snow3g_test_case_4);
5985 test_snow3g_decryption_test_case_5(void)
5987 return test_snow3g_decryption(&snow3g_test_case_5);
5991 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5992 * Pattern digest from snow3g_test_data must be allocated as
5993 * 4 last bytes in plaintext.
5996 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5997 struct snow3g_hash_test_data *output)
5999 if ((pattern != NULL) && (output != NULL)) {
6000 output->key.len = pattern->key.len;
6002 memcpy(output->key.data,
6003 pattern->key.data, pattern->key.len);
6005 output->auth_iv.len = pattern->auth_iv.len;
6007 memcpy(output->auth_iv.data,
6008 pattern->auth_iv.data, pattern->auth_iv.len);
6010 output->plaintext.len = pattern->plaintext.len;
6012 memcpy(output->plaintext.data,
6013 pattern->plaintext.data, pattern->plaintext.len >> 3);
6015 output->digest.len = pattern->digest.len;
6017 memcpy(output->digest.data,
6018 &pattern->plaintext.data[pattern->digest.offset_bytes],
6019 pattern->digest.len);
6021 output->validAuthLenInBits.len =
6022 pattern->validAuthLenInBits.len;
6027 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6030 test_snow3g_decryption_with_digest_test_case_1(void)
6032 struct snow3g_hash_test_data snow3g_hash_data;
6035 * Function prepare data for hash veryfication test case.
6036 * Digest is allocated in 4 last bytes in plaintext, pattern.
6038 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6040 return test_snow3g_decryption(&snow3g_test_case_7) &
6041 test_snow3g_authentication_verify(&snow3g_hash_data);
6045 test_snow3g_cipher_auth_test_case_1(void)
6047 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6051 test_snow3g_auth_cipher_test_case_1(void)
6053 return test_snow3g_auth_cipher(
6054 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6058 test_snow3g_auth_cipher_test_case_2(void)
6060 return test_snow3g_auth_cipher(
6061 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6065 test_snow3g_auth_cipher_test_case_2_oop(void)
6067 return test_snow3g_auth_cipher(
6068 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6072 test_snow3g_auth_cipher_part_digest_enc(void)
6074 return test_snow3g_auth_cipher(
6075 &snow3g_auth_cipher_partial_digest_encryption,
6080 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6082 return test_snow3g_auth_cipher(
6083 &snow3g_auth_cipher_partial_digest_encryption,
6088 test_snow3g_auth_cipher_test_case_3_sgl(void)
6090 return test_snow3g_auth_cipher_sgl(
6091 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6095 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6097 return test_snow3g_auth_cipher_sgl(
6098 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6102 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6104 return test_snow3g_auth_cipher_sgl(
6105 &snow3g_auth_cipher_partial_digest_encryption,
6110 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6112 return test_snow3g_auth_cipher_sgl(
6113 &snow3g_auth_cipher_partial_digest_encryption,
6118 test_snow3g_auth_cipher_verify_test_case_1(void)
6120 return test_snow3g_auth_cipher(
6121 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6125 test_snow3g_auth_cipher_verify_test_case_2(void)
6127 return test_snow3g_auth_cipher(
6128 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6132 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6134 return test_snow3g_auth_cipher(
6135 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6139 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6141 return test_snow3g_auth_cipher(
6142 &snow3g_auth_cipher_partial_digest_encryption,
6147 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6149 return test_snow3g_auth_cipher(
6150 &snow3g_auth_cipher_partial_digest_encryption,
6155 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6157 return test_snow3g_auth_cipher_sgl(
6158 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6162 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6164 return test_snow3g_auth_cipher_sgl(
6165 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6169 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6171 return test_snow3g_auth_cipher_sgl(
6172 &snow3g_auth_cipher_partial_digest_encryption,
6177 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6179 return test_snow3g_auth_cipher_sgl(
6180 &snow3g_auth_cipher_partial_digest_encryption,
6185 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6187 return test_snow3g_auth_cipher(
6188 &snow3g_test_case_7, IN_PLACE, 0);
6192 test_kasumi_auth_cipher_test_case_1(void)
6194 return test_kasumi_auth_cipher(
6195 &kasumi_test_case_3, IN_PLACE, 0);
6199 test_kasumi_auth_cipher_test_case_2(void)
6201 return test_kasumi_auth_cipher(
6202 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6206 test_kasumi_auth_cipher_test_case_2_oop(void)
6208 return test_kasumi_auth_cipher(
6209 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6213 test_kasumi_auth_cipher_test_case_2_sgl(void)
6215 return test_kasumi_auth_cipher_sgl(
6216 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6220 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6222 return test_kasumi_auth_cipher_sgl(
6223 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6227 test_kasumi_auth_cipher_verify_test_case_1(void)
6229 return test_kasumi_auth_cipher(
6230 &kasumi_test_case_3, IN_PLACE, 1);
6234 test_kasumi_auth_cipher_verify_test_case_2(void)
6236 return test_kasumi_auth_cipher(
6237 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6241 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6243 return test_kasumi_auth_cipher(
6244 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6248 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6250 return test_kasumi_auth_cipher_sgl(
6251 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6255 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6257 return test_kasumi_auth_cipher_sgl(
6258 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6262 test_kasumi_cipher_auth_test_case_1(void)
6264 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6268 test_zuc_encryption_test_case_1(void)
6270 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6274 test_zuc_encryption_test_case_2(void)
6276 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6280 test_zuc_encryption_test_case_3(void)
6282 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6286 test_zuc_encryption_test_case_4(void)
6288 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6292 test_zuc_encryption_test_case_5(void)
6294 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6298 test_zuc_encryption_test_case_6_sgl(void)
6300 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6304 test_zuc_hash_generate_test_case_1(void)
6306 return test_zuc_authentication(&zuc_test_case_auth_1b);
6310 test_zuc_hash_generate_test_case_2(void)
6312 return test_zuc_authentication(&zuc_test_case_auth_90b);
6316 test_zuc_hash_generate_test_case_3(void)
6318 return test_zuc_authentication(&zuc_test_case_auth_577b);
6322 test_zuc_hash_generate_test_case_4(void)
6324 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6328 test_zuc_hash_generate_test_case_5(void)
6330 return test_zuc_authentication(&zuc_test_auth_5670b);
6334 test_zuc_hash_generate_test_case_6(void)
6336 return test_zuc_authentication(&zuc_test_case_auth_128b);
6340 test_zuc_hash_generate_test_case_7(void)
6342 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6346 test_zuc_hash_generate_test_case_8(void)
6348 return test_zuc_authentication(&zuc_test_case_auth_584b);
6352 test_zuc_cipher_auth_test_case_1(void)
6354 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6358 test_zuc_cipher_auth_test_case_2(void)
6360 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6364 test_zuc_auth_cipher_test_case_1(void)
6366 return test_zuc_auth_cipher(
6367 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6371 test_zuc_auth_cipher_test_case_1_oop(void)
6373 return test_zuc_auth_cipher(
6374 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6378 test_zuc_auth_cipher_test_case_1_sgl(void)
6380 return test_zuc_auth_cipher_sgl(
6381 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6385 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6387 return test_zuc_auth_cipher_sgl(
6388 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6392 test_zuc_auth_cipher_verify_test_case_1(void)
6394 return test_zuc_auth_cipher(
6395 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6399 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6401 return test_zuc_auth_cipher(
6402 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6406 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6408 return test_zuc_auth_cipher_sgl(
6409 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6413 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6415 return test_zuc_auth_cipher_sgl(
6416 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6420 test_3DES_chain_qat_all(void)
6422 struct crypto_testsuite_params *ts_params = &testsuite_params;
6425 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6426 ts_params->op_mpool,
6427 ts_params->session_mpool, ts_params->session_priv_mpool,
6428 ts_params->valid_devs[0],
6429 rte_cryptodev_driver_id_get(
6430 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6431 BLKCIPHER_3DES_CHAIN_TYPE);
6433 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6435 return TEST_SUCCESS;
6439 test_DES_cipheronly_qat_all(void)
6441 struct crypto_testsuite_params *ts_params = &testsuite_params;
6444 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6445 ts_params->op_mpool,
6446 ts_params->session_mpool, ts_params->session_priv_mpool,
6447 ts_params->valid_devs[0],
6448 rte_cryptodev_driver_id_get(
6449 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6450 BLKCIPHER_DES_CIPHERONLY_TYPE);
6452 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6454 return TEST_SUCCESS;
6458 test_DES_cipheronly_openssl_all(void)
6460 struct crypto_testsuite_params *ts_params = &testsuite_params;
6463 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6464 ts_params->op_mpool,
6465 ts_params->session_mpool, ts_params->session_priv_mpool,
6466 ts_params->valid_devs[0],
6467 rte_cryptodev_driver_id_get(
6468 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6469 BLKCIPHER_DES_CIPHERONLY_TYPE);
6471 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6473 return TEST_SUCCESS;
6477 test_DES_docsis_openssl_all(void)
6479 struct crypto_testsuite_params *ts_params = &testsuite_params;
6482 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6483 ts_params->op_mpool,
6484 ts_params->session_mpool, ts_params->session_priv_mpool,
6485 ts_params->valid_devs[0],
6486 rte_cryptodev_driver_id_get(
6487 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6488 BLKCIPHER_DES_DOCSIS_TYPE);
6490 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6492 return TEST_SUCCESS;
6496 test_DES_cipheronly_mb_all(void)
6498 struct crypto_testsuite_params *ts_params = &testsuite_params;
6501 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6502 ts_params->op_mpool,
6503 ts_params->session_mpool, ts_params->session_priv_mpool,
6504 ts_params->valid_devs[0],
6505 rte_cryptodev_driver_id_get(
6506 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6507 BLKCIPHER_DES_CIPHERONLY_TYPE);
6509 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6511 return TEST_SUCCESS;
6514 test_3DES_cipheronly_mb_all(void)
6516 struct crypto_testsuite_params *ts_params = &testsuite_params;
6519 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6520 ts_params->op_mpool,
6521 ts_params->session_mpool, ts_params->session_priv_mpool,
6522 ts_params->valid_devs[0],
6523 rte_cryptodev_driver_id_get(
6524 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6525 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6527 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6529 return TEST_SUCCESS;
6533 test_DES_docsis_mb_all(void)
6535 struct crypto_testsuite_params *ts_params = &testsuite_params;
6538 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6539 ts_params->op_mpool,
6540 ts_params->session_mpool, ts_params->session_priv_mpool,
6541 ts_params->valid_devs[0],
6542 rte_cryptodev_driver_id_get(
6543 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6544 BLKCIPHER_DES_DOCSIS_TYPE);
6546 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6548 return TEST_SUCCESS;
6552 test_3DES_chain_caam_jr_all(void)
6554 struct crypto_testsuite_params *ts_params = &testsuite_params;
6557 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6558 ts_params->op_mpool,
6559 ts_params->session_mpool, ts_params->session_priv_mpool,
6560 ts_params->valid_devs[0],
6561 rte_cryptodev_driver_id_get(
6562 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6563 BLKCIPHER_3DES_CHAIN_TYPE);
6565 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6567 return TEST_SUCCESS;
6571 test_3DES_cipheronly_caam_jr_all(void)
6573 struct crypto_testsuite_params *ts_params = &testsuite_params;
6576 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6577 ts_params->op_mpool,
6578 ts_params->session_mpool, ts_params->session_priv_mpool,
6579 ts_params->valid_devs[0],
6580 rte_cryptodev_driver_id_get(
6581 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6582 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6584 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6586 return TEST_SUCCESS;
6590 test_3DES_chain_dpaa_sec_all(void)
6592 struct crypto_testsuite_params *ts_params = &testsuite_params;
6595 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6596 ts_params->op_mpool,
6597 ts_params->session_mpool, ts_params->session_priv_mpool,
6598 ts_params->valid_devs[0],
6599 rte_cryptodev_driver_id_get(
6600 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6601 BLKCIPHER_3DES_CHAIN_TYPE);
6603 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6605 return TEST_SUCCESS;
6609 test_3DES_cipheronly_dpaa_sec_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_DPAA_SEC_PMD)),
6620 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6622 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6624 return TEST_SUCCESS;
6628 test_3DES_chain_dpaa2_sec_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_DPAA2_SEC_PMD)),
6639 BLKCIPHER_3DES_CHAIN_TYPE);
6641 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6643 return TEST_SUCCESS;
6647 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD)),
6658 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6660 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6662 return TEST_SUCCESS;
6666 test_3DES_chain_ccp_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_CCP_PMD)),
6677 BLKCIPHER_3DES_CHAIN_TYPE);
6679 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6681 return TEST_SUCCESS;
6685 test_3DES_cipheronly_ccp_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_CCP_PMD)),
6696 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6698 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6700 return TEST_SUCCESS;
6704 test_3DES_cipheronly_qat_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_QAT_SYM_PMD)),
6715 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6717 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6719 return TEST_SUCCESS;
6723 test_3DES_chain_openssl_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_OPENSSL_PMD)),
6734 BLKCIPHER_3DES_CHAIN_TYPE);
6736 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6738 return TEST_SUCCESS;
6742 test_3DES_cipheronly_openssl_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_OPENSSL_PMD)),
6753 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6755 TEST_ASSERT_EQUAL(status, 0, "Test failed");
6757 return TEST_SUCCESS;
6760 /* ***** AEAD algorithm Tests ***** */
6763 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6764 enum rte_crypto_aead_operation op,
6765 const uint8_t *key, const uint8_t key_len,
6766 const uint16_t aad_len, const uint8_t auth_len,
6769 uint8_t aead_key[key_len];
6771 struct crypto_testsuite_params *ts_params = &testsuite_params;
6772 struct crypto_unittest_params *ut_params = &unittest_params;
6774 memcpy(aead_key, key, key_len);
6776 /* Setup AEAD Parameters */
6777 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6778 ut_params->aead_xform.next = NULL;
6779 ut_params->aead_xform.aead.algo = algo;
6780 ut_params->aead_xform.aead.op = op;
6781 ut_params->aead_xform.aead.key.data = aead_key;
6782 ut_params->aead_xform.aead.key.length = key_len;
6783 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6784 ut_params->aead_xform.aead.iv.length = iv_len;
6785 ut_params->aead_xform.aead.digest_length = auth_len;
6786 ut_params->aead_xform.aead.aad_length = aad_len;
6788 debug_hexdump(stdout, "key:", key, key_len);
6790 /* Create Crypto session*/
6791 ut_params->sess = rte_cryptodev_sym_session_create(
6792 ts_params->session_mpool);
6794 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6795 &ut_params->aead_xform,
6796 ts_params->session_priv_mpool);
6798 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6804 create_aead_xform(struct rte_crypto_op *op,
6805 enum rte_crypto_aead_algorithm algo,
6806 enum rte_crypto_aead_operation aead_op,
6807 uint8_t *key, const uint8_t key_len,
6808 const uint8_t aad_len, const uint8_t auth_len,
6811 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6812 "failed to allocate space for crypto transform");
6814 struct rte_crypto_sym_op *sym_op = op->sym;
6816 /* Setup AEAD Parameters */
6817 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6818 sym_op->xform->next = NULL;
6819 sym_op->xform->aead.algo = algo;
6820 sym_op->xform->aead.op = aead_op;
6821 sym_op->xform->aead.key.data = key;
6822 sym_op->xform->aead.key.length = key_len;
6823 sym_op->xform->aead.iv.offset = IV_OFFSET;
6824 sym_op->xform->aead.iv.length = iv_len;
6825 sym_op->xform->aead.digest_length = auth_len;
6826 sym_op->xform->aead.aad_length = aad_len;
6828 debug_hexdump(stdout, "key:", key, key_len);
6834 create_aead_operation(enum rte_crypto_aead_operation op,
6835 const struct aead_test_data *tdata)
6837 struct crypto_testsuite_params *ts_params = &testsuite_params;
6838 struct crypto_unittest_params *ut_params = &unittest_params;
6840 uint8_t *plaintext, *ciphertext;
6841 unsigned int aad_pad_len, plaintext_pad_len;
6843 /* Generate Crypto op data structure */
6844 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6845 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6846 TEST_ASSERT_NOT_NULL(ut_params->op,
6847 "Failed to allocate symmetric crypto operation struct");
6849 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6851 /* Append aad data */
6852 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6853 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6854 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6856 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6857 "no room to append aad");
6859 sym_op->aead.aad.phys_addr =
6860 rte_pktmbuf_iova(ut_params->ibuf);
6861 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6862 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6863 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6866 /* Append IV at the end of the crypto operation*/
6867 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6868 uint8_t *, IV_OFFSET);
6870 /* Copy IV 1 byte after the IV pointer, according to the API */
6871 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6872 debug_hexdump(stdout, "iv:", iv_ptr,
6875 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6876 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6878 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6879 "no room to append aad");
6881 sym_op->aead.aad.phys_addr =
6882 rte_pktmbuf_iova(ut_params->ibuf);
6883 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6884 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6887 /* Append IV at the end of the crypto operation*/
6888 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6889 uint8_t *, IV_OFFSET);
6891 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6892 debug_hexdump(stdout, "iv:", iv_ptr,
6896 /* Append plaintext/ciphertext */
6897 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6898 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6899 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6901 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6903 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6904 debug_hexdump(stdout, "plaintext:", plaintext,
6905 tdata->plaintext.len);
6907 if (ut_params->obuf) {
6908 ciphertext = (uint8_t *)rte_pktmbuf_append(
6910 plaintext_pad_len + aad_pad_len);
6911 TEST_ASSERT_NOT_NULL(ciphertext,
6912 "no room to append ciphertext");
6914 memset(ciphertext + aad_pad_len, 0,
6915 tdata->ciphertext.len);
6918 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6919 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6921 TEST_ASSERT_NOT_NULL(ciphertext,
6922 "no room to append ciphertext");
6924 memcpy(ciphertext, tdata->ciphertext.data,
6925 tdata->ciphertext.len);
6926 debug_hexdump(stdout, "ciphertext:", ciphertext,
6927 tdata->ciphertext.len);
6929 if (ut_params->obuf) {
6930 plaintext = (uint8_t *)rte_pktmbuf_append(
6932 plaintext_pad_len + aad_pad_len);
6933 TEST_ASSERT_NOT_NULL(plaintext,
6934 "no room to append plaintext");
6936 memset(plaintext + aad_pad_len, 0,
6937 tdata->plaintext.len);
6941 /* Append digest data */
6942 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6943 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6944 ut_params->obuf ? ut_params->obuf :
6946 tdata->auth_tag.len);
6947 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6948 "no room to append digest");
6949 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6950 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6951 ut_params->obuf ? ut_params->obuf :
6956 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6957 ut_params->ibuf, tdata->auth_tag.len);
6958 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6959 "no room to append digest");
6960 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6962 plaintext_pad_len + aad_pad_len);
6964 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6965 tdata->auth_tag.len);
6966 debug_hexdump(stdout, "digest:",
6967 sym_op->aead.digest.data,
6968 tdata->auth_tag.len);
6971 sym_op->aead.data.length = tdata->plaintext.len;
6972 sym_op->aead.data.offset = aad_pad_len;
6978 test_authenticated_encryption(const struct aead_test_data *tdata)
6980 struct crypto_testsuite_params *ts_params = &testsuite_params;
6981 struct crypto_unittest_params *ut_params = &unittest_params;
6984 uint8_t *ciphertext, *auth_tag;
6985 uint16_t plaintext_pad_len;
6988 /* Create AEAD session */
6989 retval = create_aead_session(ts_params->valid_devs[0],
6991 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6992 tdata->key.data, tdata->key.len,
6993 tdata->aad.len, tdata->auth_tag.len,
6998 if (tdata->aad.len > MBUF_SIZE) {
6999 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7000 /* Populate full size of add data */
7001 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7002 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7006 /* clear mbuf payload */
7007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7008 rte_pktmbuf_tailroom(ut_params->ibuf));
7010 /* Create AEAD operation */
7011 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7015 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7017 ut_params->op->sym->m_src = ut_params->ibuf;
7019 /* Process crypto operation */
7020 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7021 ut_params->op), "failed to process sym crypto op");
7023 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7024 "crypto op processing failed");
7026 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7028 if (ut_params->op->sym->m_dst) {
7029 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7031 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7032 uint8_t *, plaintext_pad_len);
7034 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7036 ut_params->op->sym->cipher.data.offset);
7037 auth_tag = ciphertext + plaintext_pad_len;
7040 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7041 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7044 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7046 tdata->ciphertext.data,
7047 tdata->ciphertext.len,
7048 "Ciphertext data not as expected");
7050 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7052 tdata->auth_tag.data,
7053 tdata->auth_tag.len,
7054 "Generated auth tag not as expected");
7060 #ifdef RTE_LIBRTE_SECURITY
7061 /* Basic algorithm run function for async inplace mode.
7062 * Creates a session from input parameters and runs one operation
7063 * on input_vec. Checks the output of the crypto operation against
7067 test_pdcp_proto(int i, int oop,
7068 enum rte_crypto_cipher_operation opc,
7069 enum rte_crypto_auth_operation opa,
7071 unsigned int input_vec_len,
7072 uint8_t *output_vec,
7073 unsigned int output_vec_len)
7075 struct crypto_testsuite_params *ts_params = &testsuite_params;
7076 struct crypto_unittest_params *ut_params = &unittest_params;
7078 int ret = TEST_SUCCESS;
7080 /* Generate test mbuf data */
7081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7083 /* clear mbuf payload */
7084 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7085 rte_pktmbuf_tailroom(ut_params->ibuf));
7087 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7089 memcpy(plaintext, input_vec, input_vec_len);
7091 /* Out of place support */
7094 * For out-op-place we need to alloc another mbuf
7096 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7097 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7100 /* Set crypto type as IPSEC */
7101 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7103 /* Setup Cipher Parameters */
7104 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7105 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7106 ut_params->cipher_xform.cipher.op = opc;
7107 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7108 ut_params->cipher_xform.cipher.key.length =
7109 pdcp_test_params[i].cipher_key_len;
7110 ut_params->cipher_xform.cipher.iv.length = 0;
7112 /* Setup HMAC Parameters if ICV header is required */
7113 if (pdcp_test_params[i].auth_alg != 0) {
7114 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7115 ut_params->auth_xform.next = NULL;
7116 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7117 ut_params->auth_xform.auth.op = opa;
7118 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7119 ut_params->auth_xform.auth.key.length =
7120 pdcp_test_params[i].auth_key_len;
7122 ut_params->cipher_xform.next = &ut_params->auth_xform;
7124 ut_params->cipher_xform.next = NULL;
7127 struct rte_security_session_conf sess_conf = {
7128 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7129 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7131 .bearer = pdcp_test_bearer[i],
7132 .domain = pdcp_test_params[i].domain,
7133 .pkt_dir = pdcp_test_packet_direction[i],
7134 .sn_size = pdcp_test_data_sn_size[i],
7135 .hfn = pdcp_test_hfn[i],
7136 .hfn_threshold = pdcp_test_hfn_threshold[i],
7138 .crypto_xform = &ut_params->cipher_xform
7141 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7142 rte_cryptodev_get_sec_ctx(
7143 ts_params->valid_devs[0]);
7145 /* Create security session */
7146 ut_params->sec_session = rte_security_session_create(ctx,
7147 &sess_conf, ts_params->session_priv_mpool);
7149 if (!ut_params->sec_session) {
7150 printf("TestCase %s()-%d line %d failed %s: ",
7151 __func__, i, __LINE__, "Failed to allocate session");
7156 /* Generate crypto op data structure */
7157 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7158 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7159 if (!ut_params->op) {
7160 printf("TestCase %s()-%d line %d failed %s: ",
7161 __func__, i, __LINE__,
7162 "Failed to allocate symmetric crypto operation struct");
7167 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7169 /* set crypto operation source mbuf */
7170 ut_params->op->sym->m_src = ut_params->ibuf;
7172 ut_params->op->sym->m_dst = ut_params->obuf;
7174 /* Process crypto operation */
7175 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7177 printf("TestCase %s()-%d line %d failed %s: ",
7178 __func__, i, __LINE__,
7179 "failed to process sym crypto op");
7184 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7185 printf("TestCase %s()-%d line %d failed %s: ",
7186 __func__, i, __LINE__, "crypto op processing failed");
7192 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7195 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7199 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7200 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7201 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7202 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7208 rte_crypto_op_free(ut_params->op);
7209 ut_params->op = NULL;
7211 if (ut_params->sec_session)
7212 rte_security_session_destroy(ctx, ut_params->sec_session);
7213 ut_params->sec_session = NULL;
7215 rte_pktmbuf_free(ut_params->ibuf);
7216 ut_params->ibuf = NULL;
7218 rte_pktmbuf_free(ut_params->obuf);
7219 ut_params->obuf = NULL;
7226 test_pdcp_proto_SGL(int i, int oop,
7227 enum rte_crypto_cipher_operation opc,
7228 enum rte_crypto_auth_operation opa,
7230 unsigned int input_vec_len,
7231 uint8_t *output_vec,
7232 unsigned int output_vec_len,
7234 uint32_t fragsz_oop)
7236 struct crypto_testsuite_params *ts_params = &testsuite_params;
7237 struct crypto_unittest_params *ut_params = &unittest_params;
7239 struct rte_mbuf *buf, *buf_oop = NULL;
7240 int ret = TEST_SUCCESS;
7244 unsigned int trn_data = 0;
7246 if (fragsz > input_vec_len)
7247 fragsz = input_vec_len;
7249 uint16_t plaintext_len = fragsz;
7250 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7252 if (fragsz_oop > output_vec_len)
7253 frag_size_oop = output_vec_len;
7256 if (input_vec_len % fragsz != 0) {
7257 if (input_vec_len / fragsz + 1 > 16)
7259 } else if (input_vec_len / fragsz > 16)
7262 /* Out of place support */
7265 * For out-op-place we need to alloc another mbuf
7267 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7268 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7269 buf_oop = ut_params->obuf;
7272 /* Generate test mbuf data */
7273 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7275 /* clear mbuf payload */
7276 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7277 rte_pktmbuf_tailroom(ut_params->ibuf));
7279 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7281 memcpy(plaintext, input_vec, plaintext_len);
7282 trn_data += plaintext_len;
7284 buf = ut_params->ibuf;
7287 * Loop until no more fragments
7290 while (trn_data < input_vec_len) {
7292 to_trn = (input_vec_len - trn_data < fragsz) ?
7293 (input_vec_len - trn_data) : fragsz;
7295 to_trn_tbl[ecx++] = to_trn;
7297 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7300 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7301 rte_pktmbuf_tailroom(buf));
7304 if (oop && !fragsz_oop) {
7306 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7307 buf_oop = buf_oop->next;
7308 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7309 0, rte_pktmbuf_tailroom(buf_oop));
7310 rte_pktmbuf_append(buf_oop, to_trn);
7313 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7316 memcpy(plaintext, input_vec + trn_data, to_trn);
7320 ut_params->ibuf->nb_segs = segs;
7323 if (fragsz_oop && oop) {
7327 trn_data = frag_size_oop;
7328 while (trn_data < output_vec_len) {
7331 (output_vec_len - trn_data <
7333 (output_vec_len - trn_data) :
7336 to_trn_tbl[ecx++] = to_trn;
7339 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7340 buf_oop = buf_oop->next;
7341 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7342 0, rte_pktmbuf_tailroom(buf_oop));
7343 rte_pktmbuf_append(buf_oop, to_trn);
7347 ut_params->obuf->nb_segs = segs;
7350 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7352 /* Setup Cipher Parameters */
7353 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7354 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7355 ut_params->cipher_xform.cipher.op = opc;
7356 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7357 ut_params->cipher_xform.cipher.key.length =
7358 pdcp_test_params[i].cipher_key_len;
7359 ut_params->cipher_xform.cipher.iv.length = 0;
7361 /* Setup HMAC Parameters if ICV header is required */
7362 if (pdcp_test_params[i].auth_alg != 0) {
7363 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7364 ut_params->auth_xform.next = NULL;
7365 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7366 ut_params->auth_xform.auth.op = opa;
7367 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7368 ut_params->auth_xform.auth.key.length =
7369 pdcp_test_params[i].auth_key_len;
7371 ut_params->cipher_xform.next = &ut_params->auth_xform;
7373 ut_params->cipher_xform.next = NULL;
7376 struct rte_security_session_conf sess_conf = {
7377 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7378 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7380 .bearer = pdcp_test_bearer[i],
7381 .domain = pdcp_test_params[i].domain,
7382 .pkt_dir = pdcp_test_packet_direction[i],
7383 .sn_size = pdcp_test_data_sn_size[i],
7384 .hfn = pdcp_test_hfn[i],
7385 .hfn_threshold = pdcp_test_hfn_threshold[i],
7387 .crypto_xform = &ut_params->cipher_xform
7390 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7391 rte_cryptodev_get_sec_ctx(
7392 ts_params->valid_devs[0]);
7394 /* Create security session */
7395 ut_params->sec_session = rte_security_session_create(ctx,
7396 &sess_conf, ts_params->session_priv_mpool);
7398 if (!ut_params->sec_session) {
7399 printf("TestCase %s()-%d line %d failed %s: ",
7400 __func__, i, __LINE__, "Failed to allocate session");
7405 /* Generate crypto op data structure */
7406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7408 if (!ut_params->op) {
7409 printf("TestCase %s()-%d line %d failed %s: ",
7410 __func__, i, __LINE__,
7411 "Failed to allocate symmetric crypto operation struct");
7416 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7418 /* set crypto operation source mbuf */
7419 ut_params->op->sym->m_src = ut_params->ibuf;
7421 ut_params->op->sym->m_dst = ut_params->obuf;
7423 /* Process crypto operation */
7424 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7426 printf("TestCase %s()-%d line %d failed %s: ",
7427 __func__, i, __LINE__,
7428 "failed to process sym crypto op");
7433 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7434 printf("TestCase %s()-%d line %d failed %s: ",
7435 __func__, i, __LINE__, "crypto op processing failed");
7441 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7444 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7448 fragsz = frag_size_oop;
7449 if (memcmp(ciphertext, output_vec, fragsz)) {
7450 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7451 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7452 rte_hexdump(stdout, "reference", output_vec, fragsz);
7457 buf = ut_params->op->sym->m_src->next;
7459 buf = ut_params->op->sym->m_dst->next;
7461 unsigned int off = fragsz;
7465 ciphertext = rte_pktmbuf_mtod(buf,
7467 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7468 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7469 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7470 rte_hexdump(stdout, "reference", output_vec + off,
7475 off += to_trn_tbl[ecx++];
7479 rte_crypto_op_free(ut_params->op);
7480 ut_params->op = NULL;
7482 if (ut_params->sec_session)
7483 rte_security_session_destroy(ctx, ut_params->sec_session);
7484 ut_params->sec_session = NULL;
7486 rte_pktmbuf_free(ut_params->ibuf);
7487 ut_params->ibuf = NULL;
7489 rte_pktmbuf_free(ut_params->obuf);
7490 ut_params->obuf = NULL;
7497 test_pdcp_proto_cplane_encap(int i)
7499 return test_pdcp_proto(i, 0,
7500 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7501 RTE_CRYPTO_AUTH_OP_GENERATE,
7502 pdcp_test_data_in[i],
7503 pdcp_test_data_in_len[i],
7504 pdcp_test_data_out[i],
7505 pdcp_test_data_in_len[i]+4);
7509 test_pdcp_proto_uplane_encap(int i)
7511 return test_pdcp_proto(i, 0,
7512 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7513 RTE_CRYPTO_AUTH_OP_GENERATE,
7514 pdcp_test_data_in[i],
7515 pdcp_test_data_in_len[i],
7516 pdcp_test_data_out[i],
7517 pdcp_test_data_in_len[i]);
7522 test_pdcp_proto_uplane_encap_with_int(int i)
7524 return test_pdcp_proto(i, 0,
7525 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7526 RTE_CRYPTO_AUTH_OP_GENERATE,
7527 pdcp_test_data_in[i],
7528 pdcp_test_data_in_len[i],
7529 pdcp_test_data_out[i],
7530 pdcp_test_data_in_len[i] + 4);
7534 test_pdcp_proto_cplane_decap(int i)
7536 return test_pdcp_proto(i, 0,
7537 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7538 RTE_CRYPTO_AUTH_OP_VERIFY,
7539 pdcp_test_data_out[i],
7540 pdcp_test_data_in_len[i] + 4,
7541 pdcp_test_data_in[i],
7542 pdcp_test_data_in_len[i]);
7546 test_pdcp_proto_uplane_decap(int i)
7548 return test_pdcp_proto(i, 0,
7549 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7550 RTE_CRYPTO_AUTH_OP_VERIFY,
7551 pdcp_test_data_out[i],
7552 pdcp_test_data_in_len[i],
7553 pdcp_test_data_in[i],
7554 pdcp_test_data_in_len[i]);
7558 test_pdcp_proto_uplane_decap_with_int(int i)
7560 return test_pdcp_proto(i, 0,
7561 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7562 RTE_CRYPTO_AUTH_OP_VERIFY,
7563 pdcp_test_data_out[i],
7564 pdcp_test_data_in_len[i] + 4,
7565 pdcp_test_data_in[i],
7566 pdcp_test_data_in_len[i]);
7570 test_PDCP_PROTO_SGL_in_place_32B(void)
7572 /* i can be used for running any PDCP case
7573 * In this case it is uplane 12-bit AES-SNOW DL encap
7575 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7576 return test_pdcp_proto_SGL(i, IN_PLACE,
7577 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7578 RTE_CRYPTO_AUTH_OP_GENERATE,
7579 pdcp_test_data_in[i],
7580 pdcp_test_data_in_len[i],
7581 pdcp_test_data_out[i],
7582 pdcp_test_data_in_len[i]+4,
7586 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7588 /* i can be used for running any PDCP case
7589 * In this case it is uplane 18-bit NULL-NULL DL encap
7591 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7592 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7593 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7594 RTE_CRYPTO_AUTH_OP_GENERATE,
7595 pdcp_test_data_in[i],
7596 pdcp_test_data_in_len[i],
7597 pdcp_test_data_out[i],
7598 pdcp_test_data_in_len[i]+4,
7602 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7604 /* i can be used for running any PDCP case
7605 * In this case it is uplane 18-bit AES DL encap
7607 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7609 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7610 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7611 RTE_CRYPTO_AUTH_OP_GENERATE,
7612 pdcp_test_data_in[i],
7613 pdcp_test_data_in_len[i],
7614 pdcp_test_data_out[i],
7615 pdcp_test_data_in_len[i],
7619 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7621 /* i can be used for running any PDCP case
7622 * In this case it is cplane 12-bit AES-ZUC DL encap
7624 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7625 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7626 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7627 RTE_CRYPTO_AUTH_OP_GENERATE,
7628 pdcp_test_data_in[i],
7629 pdcp_test_data_in_len[i],
7630 pdcp_test_data_out[i],
7631 pdcp_test_data_in_len[i]+4,
7637 test_AES_GCM_authenticated_encryption_test_case_1(void)
7639 return test_authenticated_encryption(&gcm_test_case_1);
7643 test_AES_GCM_authenticated_encryption_test_case_2(void)
7645 return test_authenticated_encryption(&gcm_test_case_2);
7649 test_AES_GCM_authenticated_encryption_test_case_3(void)
7651 return test_authenticated_encryption(&gcm_test_case_3);
7655 test_AES_GCM_authenticated_encryption_test_case_4(void)
7657 return test_authenticated_encryption(&gcm_test_case_4);
7661 test_AES_GCM_authenticated_encryption_test_case_5(void)
7663 return test_authenticated_encryption(&gcm_test_case_5);
7667 test_AES_GCM_authenticated_encryption_test_case_6(void)
7669 return test_authenticated_encryption(&gcm_test_case_6);
7673 test_AES_GCM_authenticated_encryption_test_case_7(void)
7675 return test_authenticated_encryption(&gcm_test_case_7);
7679 test_AES_GCM_authenticated_encryption_test_case_8(void)
7681 return test_authenticated_encryption(&gcm_test_case_8);
7685 test_AES_GCM_auth_encryption_test_case_192_1(void)
7687 return test_authenticated_encryption(&gcm_test_case_192_1);
7691 test_AES_GCM_auth_encryption_test_case_192_2(void)
7693 return test_authenticated_encryption(&gcm_test_case_192_2);
7697 test_AES_GCM_auth_encryption_test_case_192_3(void)
7699 return test_authenticated_encryption(&gcm_test_case_192_3);
7703 test_AES_GCM_auth_encryption_test_case_192_4(void)
7705 return test_authenticated_encryption(&gcm_test_case_192_4);
7709 test_AES_GCM_auth_encryption_test_case_192_5(void)
7711 return test_authenticated_encryption(&gcm_test_case_192_5);
7715 test_AES_GCM_auth_encryption_test_case_192_6(void)
7717 return test_authenticated_encryption(&gcm_test_case_192_6);
7721 test_AES_GCM_auth_encryption_test_case_192_7(void)
7723 return test_authenticated_encryption(&gcm_test_case_192_7);
7727 test_AES_GCM_auth_encryption_test_case_256_1(void)
7729 return test_authenticated_encryption(&gcm_test_case_256_1);
7733 test_AES_GCM_auth_encryption_test_case_256_2(void)
7735 return test_authenticated_encryption(&gcm_test_case_256_2);
7739 test_AES_GCM_auth_encryption_test_case_256_3(void)
7741 return test_authenticated_encryption(&gcm_test_case_256_3);
7745 test_AES_GCM_auth_encryption_test_case_256_4(void)
7747 return test_authenticated_encryption(&gcm_test_case_256_4);
7751 test_AES_GCM_auth_encryption_test_case_256_5(void)
7753 return test_authenticated_encryption(&gcm_test_case_256_5);
7757 test_AES_GCM_auth_encryption_test_case_256_6(void)
7759 return test_authenticated_encryption(&gcm_test_case_256_6);
7763 test_AES_GCM_auth_encryption_test_case_256_7(void)
7765 return test_authenticated_encryption(&gcm_test_case_256_7);
7769 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7771 return test_authenticated_encryption(&gcm_test_case_aad_1);
7775 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7777 return test_authenticated_encryption(&gcm_test_case_aad_2);
7781 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7783 struct aead_test_data tdata;
7786 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7787 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7788 tdata.iv.data[0] += 1;
7789 res = test_authenticated_encryption(&tdata);
7790 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7791 return TEST_SUCCESS;
7795 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7797 struct aead_test_data tdata;
7800 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7801 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7802 tdata.plaintext.data[0] += 1;
7803 res = test_authenticated_encryption(&tdata);
7804 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7805 return TEST_SUCCESS;
7809 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7811 struct aead_test_data tdata;
7814 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7815 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7816 tdata.ciphertext.data[0] += 1;
7817 res = test_authenticated_encryption(&tdata);
7818 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7819 return TEST_SUCCESS;
7823 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7825 struct aead_test_data tdata;
7828 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7829 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7831 res = test_authenticated_encryption(&tdata);
7832 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7833 return TEST_SUCCESS;
7837 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7839 struct aead_test_data tdata;
7840 uint8_t aad[gcm_test_case_7.aad.len];
7843 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7844 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7845 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7847 tdata.aad.data = aad;
7848 res = test_authenticated_encryption(&tdata);
7849 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7850 return TEST_SUCCESS;
7854 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7856 struct aead_test_data tdata;
7859 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7860 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7861 tdata.auth_tag.data[0] += 1;
7862 res = test_authenticated_encryption(&tdata);
7863 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7864 return TEST_SUCCESS;
7868 test_authenticated_decryption(const struct aead_test_data *tdata)
7870 struct crypto_testsuite_params *ts_params = &testsuite_params;
7871 struct crypto_unittest_params *ut_params = &unittest_params;
7877 /* Create AEAD session */
7878 retval = create_aead_session(ts_params->valid_devs[0],
7880 RTE_CRYPTO_AEAD_OP_DECRYPT,
7881 tdata->key.data, tdata->key.len,
7882 tdata->aad.len, tdata->auth_tag.len,
7887 /* alloc mbuf and set payload */
7888 if (tdata->aad.len > MBUF_SIZE) {
7889 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7890 /* Populate full size of add data */
7891 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7892 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7894 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7896 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7897 rte_pktmbuf_tailroom(ut_params->ibuf));
7899 /* Create AEAD operation */
7900 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7904 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7906 ut_params->op->sym->m_src = ut_params->ibuf;
7908 /* Process crypto operation */
7909 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7910 ut_params->op), "failed to process sym crypto op");
7912 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7913 "crypto op processing failed");
7915 if (ut_params->op->sym->m_dst)
7916 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7919 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7921 ut_params->op->sym->cipher.data.offset);
7923 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7926 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7928 tdata->plaintext.data,
7929 tdata->plaintext.len,
7930 "Plaintext data not as expected");
7932 TEST_ASSERT_EQUAL(ut_params->op->status,
7933 RTE_CRYPTO_OP_STATUS_SUCCESS,
7934 "Authentication failed");
7940 test_AES_GCM_authenticated_decryption_test_case_1(void)
7942 return test_authenticated_decryption(&gcm_test_case_1);
7946 test_AES_GCM_authenticated_decryption_test_case_2(void)
7948 return test_authenticated_decryption(&gcm_test_case_2);
7952 test_AES_GCM_authenticated_decryption_test_case_3(void)
7954 return test_authenticated_decryption(&gcm_test_case_3);
7958 test_AES_GCM_authenticated_decryption_test_case_4(void)
7960 return test_authenticated_decryption(&gcm_test_case_4);
7964 test_AES_GCM_authenticated_decryption_test_case_5(void)
7966 return test_authenticated_decryption(&gcm_test_case_5);
7970 test_AES_GCM_authenticated_decryption_test_case_6(void)
7972 return test_authenticated_decryption(&gcm_test_case_6);
7976 test_AES_GCM_authenticated_decryption_test_case_7(void)
7978 return test_authenticated_decryption(&gcm_test_case_7);
7982 test_AES_GCM_authenticated_decryption_test_case_8(void)
7984 return test_authenticated_decryption(&gcm_test_case_8);
7988 test_AES_GCM_auth_decryption_test_case_192_1(void)
7990 return test_authenticated_decryption(&gcm_test_case_192_1);
7994 test_AES_GCM_auth_decryption_test_case_192_2(void)
7996 return test_authenticated_decryption(&gcm_test_case_192_2);
8000 test_AES_GCM_auth_decryption_test_case_192_3(void)
8002 return test_authenticated_decryption(&gcm_test_case_192_3);
8006 test_AES_GCM_auth_decryption_test_case_192_4(void)
8008 return test_authenticated_decryption(&gcm_test_case_192_4);
8012 test_AES_GCM_auth_decryption_test_case_192_5(void)
8014 return test_authenticated_decryption(&gcm_test_case_192_5);
8018 test_AES_GCM_auth_decryption_test_case_192_6(void)
8020 return test_authenticated_decryption(&gcm_test_case_192_6);
8024 test_AES_GCM_auth_decryption_test_case_192_7(void)
8026 return test_authenticated_decryption(&gcm_test_case_192_7);
8030 test_AES_GCM_auth_decryption_test_case_256_1(void)
8032 return test_authenticated_decryption(&gcm_test_case_256_1);
8036 test_AES_GCM_auth_decryption_test_case_256_2(void)
8038 return test_authenticated_decryption(&gcm_test_case_256_2);
8042 test_AES_GCM_auth_decryption_test_case_256_3(void)
8044 return test_authenticated_decryption(&gcm_test_case_256_3);
8048 test_AES_GCM_auth_decryption_test_case_256_4(void)
8050 return test_authenticated_decryption(&gcm_test_case_256_4);
8054 test_AES_GCM_auth_decryption_test_case_256_5(void)
8056 return test_authenticated_decryption(&gcm_test_case_256_5);
8060 test_AES_GCM_auth_decryption_test_case_256_6(void)
8062 return test_authenticated_decryption(&gcm_test_case_256_6);
8066 test_AES_GCM_auth_decryption_test_case_256_7(void)
8068 return test_authenticated_decryption(&gcm_test_case_256_7);
8072 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8074 return test_authenticated_decryption(&gcm_test_case_aad_1);
8078 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8080 return test_authenticated_decryption(&gcm_test_case_aad_2);
8084 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8086 struct aead_test_data tdata;
8089 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8090 tdata.iv.data[0] += 1;
8091 res = test_authenticated_decryption(&tdata);
8092 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8093 return TEST_SUCCESS;
8097 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8099 struct aead_test_data tdata;
8102 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8103 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8104 tdata.plaintext.data[0] += 1;
8105 res = test_authenticated_decryption(&tdata);
8106 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8107 return TEST_SUCCESS;
8111 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8113 struct aead_test_data tdata;
8116 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8117 tdata.ciphertext.data[0] += 1;
8118 res = test_authenticated_decryption(&tdata);
8119 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8120 return TEST_SUCCESS;
8124 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8126 struct aead_test_data tdata;
8129 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8131 res = test_authenticated_decryption(&tdata);
8132 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8133 return TEST_SUCCESS;
8137 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8139 struct aead_test_data tdata;
8140 uint8_t aad[gcm_test_case_7.aad.len];
8143 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8144 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8146 tdata.aad.data = aad;
8147 res = test_authenticated_decryption(&tdata);
8148 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8149 return TEST_SUCCESS;
8153 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8155 struct aead_test_data tdata;
8158 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8159 tdata.auth_tag.data[0] += 1;
8160 res = test_authenticated_decryption(&tdata);
8161 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8162 return TEST_SUCCESS;
8166 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8168 struct crypto_testsuite_params *ts_params = &testsuite_params;
8169 struct crypto_unittest_params *ut_params = &unittest_params;
8172 uint8_t *ciphertext, *auth_tag;
8173 uint16_t plaintext_pad_len;
8175 /* Create AEAD session */
8176 retval = create_aead_session(ts_params->valid_devs[0],
8178 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8179 tdata->key.data, tdata->key.len,
8180 tdata->aad.len, tdata->auth_tag.len,
8185 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8186 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8188 /* clear mbuf payload */
8189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8190 rte_pktmbuf_tailroom(ut_params->ibuf));
8191 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8192 rte_pktmbuf_tailroom(ut_params->obuf));
8194 /* Create AEAD operation */
8195 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8199 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8201 ut_params->op->sym->m_src = ut_params->ibuf;
8202 ut_params->op->sym->m_dst = ut_params->obuf;
8204 /* Process crypto operation */
8205 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8206 ut_params->op), "failed to process sym crypto op");
8208 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8209 "crypto op processing failed");
8211 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8213 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8214 ut_params->op->sym->cipher.data.offset);
8215 auth_tag = ciphertext + plaintext_pad_len;
8217 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8218 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8223 tdata->ciphertext.data,
8224 tdata->ciphertext.len,
8225 "Ciphertext data not as expected");
8227 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8229 tdata->auth_tag.data,
8230 tdata->auth_tag.len,
8231 "Generated auth tag not as expected");
8238 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8240 return test_authenticated_encryption_oop(&gcm_test_case_5);
8244 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8246 struct crypto_testsuite_params *ts_params = &testsuite_params;
8247 struct crypto_unittest_params *ut_params = &unittest_params;
8252 /* Create AEAD session */
8253 retval = create_aead_session(ts_params->valid_devs[0],
8255 RTE_CRYPTO_AEAD_OP_DECRYPT,
8256 tdata->key.data, tdata->key.len,
8257 tdata->aad.len, tdata->auth_tag.len,
8262 /* alloc mbuf and set payload */
8263 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8264 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8266 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8267 rte_pktmbuf_tailroom(ut_params->ibuf));
8268 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8269 rte_pktmbuf_tailroom(ut_params->obuf));
8271 /* Create AEAD operation */
8272 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8276 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8278 ut_params->op->sym->m_src = ut_params->ibuf;
8279 ut_params->op->sym->m_dst = ut_params->obuf;
8281 /* Process crypto operation */
8282 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8283 ut_params->op), "failed to process sym crypto op");
8285 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8286 "crypto op processing failed");
8288 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8289 ut_params->op->sym->cipher.data.offset);
8291 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8294 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8296 tdata->plaintext.data,
8297 tdata->plaintext.len,
8298 "Plaintext data not as expected");
8300 TEST_ASSERT_EQUAL(ut_params->op->status,
8301 RTE_CRYPTO_OP_STATUS_SUCCESS,
8302 "Authentication failed");
8307 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8309 return test_authenticated_decryption_oop(&gcm_test_case_5);
8313 test_authenticated_encryption_sessionless(
8314 const struct aead_test_data *tdata)
8316 struct crypto_testsuite_params *ts_params = &testsuite_params;
8317 struct crypto_unittest_params *ut_params = &unittest_params;
8320 uint8_t *ciphertext, *auth_tag;
8321 uint16_t plaintext_pad_len;
8322 uint8_t key[tdata->key.len + 1];
8324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8326 /* clear mbuf payload */
8327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8328 rte_pktmbuf_tailroom(ut_params->ibuf));
8330 /* Create AEAD operation */
8331 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8335 /* Create GCM xform */
8336 memcpy(key, tdata->key.data, tdata->key.len);
8337 retval = create_aead_xform(ut_params->op,
8339 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8340 key, tdata->key.len,
8341 tdata->aad.len, tdata->auth_tag.len,
8346 ut_params->op->sym->m_src = ut_params->ibuf;
8348 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8349 RTE_CRYPTO_OP_SESSIONLESS,
8350 "crypto op session type not sessionless");
8352 /* Process crypto operation */
8353 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8354 ut_params->op), "failed to process sym crypto op");
8356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8359 "crypto op status not success");
8361 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8363 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8364 ut_params->op->sym->cipher.data.offset);
8365 auth_tag = ciphertext + plaintext_pad_len;
8367 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8368 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8371 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8373 tdata->ciphertext.data,
8374 tdata->ciphertext.len,
8375 "Ciphertext data not as expected");
8377 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8379 tdata->auth_tag.data,
8380 tdata->auth_tag.len,
8381 "Generated auth tag not as expected");
8388 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8390 return test_authenticated_encryption_sessionless(
8395 test_authenticated_decryption_sessionless(
8396 const struct aead_test_data *tdata)
8398 struct crypto_testsuite_params *ts_params = &testsuite_params;
8399 struct crypto_unittest_params *ut_params = &unittest_params;
8403 uint8_t key[tdata->key.len + 1];
8405 /* alloc mbuf and set payload */
8406 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8408 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8409 rte_pktmbuf_tailroom(ut_params->ibuf));
8411 /* Create AEAD operation */
8412 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8416 /* Create AEAD xform */
8417 memcpy(key, tdata->key.data, tdata->key.len);
8418 retval = create_aead_xform(ut_params->op,
8420 RTE_CRYPTO_AEAD_OP_DECRYPT,
8421 key, tdata->key.len,
8422 tdata->aad.len, tdata->auth_tag.len,
8427 ut_params->op->sym->m_src = ut_params->ibuf;
8429 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8430 RTE_CRYPTO_OP_SESSIONLESS,
8431 "crypto op session type not sessionless");
8433 /* Process crypto operation */
8434 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8435 ut_params->op), "failed to process sym crypto op");
8437 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8439 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8440 "crypto op status not success");
8442 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8443 ut_params->op->sym->cipher.data.offset);
8445 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8448 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8450 tdata->plaintext.data,
8451 tdata->plaintext.len,
8452 "Plaintext data not as expected");
8454 TEST_ASSERT_EQUAL(ut_params->op->status,
8455 RTE_CRYPTO_OP_STATUS_SUCCESS,
8456 "Authentication failed");
8461 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8463 return test_authenticated_decryption_sessionless(
8468 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8470 return test_authenticated_encryption(&ccm_test_case_128_1);
8474 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8476 return test_authenticated_encryption(&ccm_test_case_128_2);
8480 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8482 return test_authenticated_encryption(&ccm_test_case_128_3);
8486 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8488 return test_authenticated_decryption(&ccm_test_case_128_1);
8492 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8494 return test_authenticated_decryption(&ccm_test_case_128_2);
8498 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8500 return test_authenticated_decryption(&ccm_test_case_128_3);
8504 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8506 return test_authenticated_encryption(&ccm_test_case_192_1);
8510 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8512 return test_authenticated_encryption(&ccm_test_case_192_2);
8516 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8518 return test_authenticated_encryption(&ccm_test_case_192_3);
8522 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8524 return test_authenticated_decryption(&ccm_test_case_192_1);
8528 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8530 return test_authenticated_decryption(&ccm_test_case_192_2);
8534 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8536 return test_authenticated_decryption(&ccm_test_case_192_3);
8540 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8542 return test_authenticated_encryption(&ccm_test_case_256_1);
8546 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8548 return test_authenticated_encryption(&ccm_test_case_256_2);
8552 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8554 return test_authenticated_encryption(&ccm_test_case_256_3);
8558 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8560 return test_authenticated_decryption(&ccm_test_case_256_1);
8564 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8566 return test_authenticated_decryption(&ccm_test_case_256_2);
8570 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8572 return test_authenticated_decryption(&ccm_test_case_256_3);
8578 struct crypto_testsuite_params *ts_params = &testsuite_params;
8579 struct rte_cryptodev_stats stats;
8580 struct rte_cryptodev *dev;
8581 cryptodev_stats_get_t temp_pfn;
8583 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8584 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8585 &stats) == -ENODEV),
8586 "rte_cryptodev_stats_get invalid dev failed");
8587 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8588 "rte_cryptodev_stats_get invalid Param failed");
8589 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8590 temp_pfn = dev->dev_ops->stats_get;
8591 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8592 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8594 "rte_cryptodev_stats_get invalid Param failed");
8595 dev->dev_ops->stats_get = temp_pfn;
8597 /* Test expected values */
8599 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8601 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8603 "rte_cryptodev_stats_get failed");
8604 TEST_ASSERT((stats.enqueued_count == 1),
8605 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8606 TEST_ASSERT((stats.dequeued_count == 1),
8607 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8608 TEST_ASSERT((stats.enqueue_err_count == 0),
8609 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8610 TEST_ASSERT((stats.dequeue_err_count == 0),
8611 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8613 /* invalid device but should ignore and not reset device stats*/
8614 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8615 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8617 "rte_cryptodev_stats_get failed");
8618 TEST_ASSERT((stats.enqueued_count == 1),
8619 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8621 /* check that a valid reset clears stats */
8622 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8623 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8625 "rte_cryptodev_stats_get failed");
8626 TEST_ASSERT((stats.enqueued_count == 0),
8627 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8628 TEST_ASSERT((stats.dequeued_count == 0),
8629 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8631 return TEST_SUCCESS;
8634 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8635 struct crypto_unittest_params *ut_params,
8636 enum rte_crypto_auth_operation op,
8637 const struct HMAC_MD5_vector *test_case)
8641 memcpy(key, test_case->key.data, test_case->key.len);
8643 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8644 ut_params->auth_xform.next = NULL;
8645 ut_params->auth_xform.auth.op = op;
8647 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8649 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8650 ut_params->auth_xform.auth.key.length = test_case->key.len;
8651 ut_params->auth_xform.auth.key.data = key;
8653 ut_params->sess = rte_cryptodev_sym_session_create(
8654 ts_params->session_mpool);
8656 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8657 ut_params->sess, &ut_params->auth_xform,
8658 ts_params->session_priv_mpool);
8660 if (ut_params->sess == NULL)
8663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8666 rte_pktmbuf_tailroom(ut_params->ibuf));
8671 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8672 const struct HMAC_MD5_vector *test_case,
8673 uint8_t **plaintext)
8675 uint16_t plaintext_pad_len;
8677 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8679 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8682 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8684 memcpy(*plaintext, test_case->plaintext.data,
8685 test_case->plaintext.len);
8687 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8688 ut_params->ibuf, MD5_DIGEST_LEN);
8689 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8690 "no room to append digest");
8691 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8692 ut_params->ibuf, plaintext_pad_len);
8694 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8695 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8696 test_case->auth_tag.len);
8699 sym_op->auth.data.offset = 0;
8700 sym_op->auth.data.length = test_case->plaintext.len;
8702 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8703 ut_params->op->sym->m_src = ut_params->ibuf;
8709 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8711 uint16_t plaintext_pad_len;
8712 uint8_t *plaintext, *auth_tag;
8714 struct crypto_testsuite_params *ts_params = &testsuite_params;
8715 struct crypto_unittest_params *ut_params = &unittest_params;
8717 if (MD5_HMAC_create_session(ts_params, ut_params,
8718 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8721 /* Generate Crypto op data structure */
8722 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8723 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8724 TEST_ASSERT_NOT_NULL(ut_params->op,
8725 "Failed to allocate symmetric crypto operation struct");
8727 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8730 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8733 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8734 ut_params->op), "failed to process sym crypto op");
8736 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8737 "crypto op processing failed");
8739 if (ut_params->op->sym->m_dst) {
8740 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8741 uint8_t *, plaintext_pad_len);
8743 auth_tag = plaintext + plaintext_pad_len;
8746 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8748 test_case->auth_tag.data,
8749 test_case->auth_tag.len,
8750 "HMAC_MD5 generated tag not as expected");
8752 return TEST_SUCCESS;
8756 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8760 struct crypto_testsuite_params *ts_params = &testsuite_params;
8761 struct crypto_unittest_params *ut_params = &unittest_params;
8763 if (MD5_HMAC_create_session(ts_params, ut_params,
8764 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8768 /* Generate Crypto op data structure */
8769 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8770 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8771 TEST_ASSERT_NOT_NULL(ut_params->op,
8772 "Failed to allocate symmetric crypto operation struct");
8774 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8777 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8778 ut_params->op), "failed to process sym crypto op");
8780 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8781 "HMAC_MD5 crypto op processing failed");
8783 return TEST_SUCCESS;
8787 test_MD5_HMAC_generate_case_1(void)
8789 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8793 test_MD5_HMAC_verify_case_1(void)
8795 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8799 test_MD5_HMAC_generate_case_2(void)
8801 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8805 test_MD5_HMAC_verify_case_2(void)
8807 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8811 test_multi_session(void)
8813 struct crypto_testsuite_params *ts_params = &testsuite_params;
8814 struct crypto_unittest_params *ut_params = &unittest_params;
8816 struct rte_cryptodev_info dev_info;
8817 struct rte_cryptodev_sym_session **sessions;
8821 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8822 aes_cbc_key, hmac_sha512_key);
8825 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8827 sessions = rte_malloc(NULL,
8828 (sizeof(struct rte_cryptodev_sym_session *) *
8829 MAX_NB_SESSIONS) + 1, 0);
8831 /* Create multiple crypto sessions*/
8832 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8834 sessions[i] = rte_cryptodev_sym_session_create(
8835 ts_params->session_mpool);
8837 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8838 sessions[i], &ut_params->auth_xform,
8839 ts_params->session_priv_mpool);
8840 TEST_ASSERT_NOT_NULL(sessions[i],
8841 "Session creation failed at session number %u",
8844 /* Attempt to send a request on each session */
8845 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8849 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8850 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8852 "Failed to perform decrypt on request number %u.", i);
8853 /* free crypto operation structure */
8855 rte_crypto_op_free(ut_params->op);
8858 * free mbuf - both obuf and ibuf are usually the same,
8859 * so check if they point at the same address is necessary,
8860 * to avoid freeing the mbuf twice.
8862 if (ut_params->obuf) {
8863 rte_pktmbuf_free(ut_params->obuf);
8864 if (ut_params->ibuf == ut_params->obuf)
8865 ut_params->ibuf = 0;
8866 ut_params->obuf = 0;
8868 if (ut_params->ibuf) {
8869 rte_pktmbuf_free(ut_params->ibuf);
8870 ut_params->ibuf = 0;
8874 /* Next session create should fail */
8875 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8876 sessions[i], &ut_params->auth_xform,
8877 ts_params->session_priv_mpool);
8878 TEST_ASSERT_NULL(sessions[i],
8879 "Session creation succeeded unexpectedly!");
8881 for (i = 0; i < MAX_NB_SESSIONS; i++) {
8882 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8884 rte_cryptodev_sym_session_free(sessions[i]);
8889 return TEST_SUCCESS;
8892 struct multi_session_params {
8893 struct crypto_unittest_params ut_params;
8894 uint8_t *cipher_key;
8896 const uint8_t *cipher;
8897 const uint8_t *digest;
8901 #define MB_SESSION_NUMBER 3
8904 test_multi_session_random_usage(void)
8906 struct crypto_testsuite_params *ts_params = &testsuite_params;
8907 struct rte_cryptodev_info dev_info;
8908 struct rte_cryptodev_sym_session **sessions;
8910 struct multi_session_params ut_paramz[] = {
8913 .cipher_key = ms_aes_cbc_key0,
8914 .hmac_key = ms_hmac_key0,
8915 .cipher = ms_aes_cbc_cipher0,
8916 .digest = ms_hmac_digest0,
8917 .iv = ms_aes_cbc_iv0
8920 .cipher_key = ms_aes_cbc_key1,
8921 .hmac_key = ms_hmac_key1,
8922 .cipher = ms_aes_cbc_cipher1,
8923 .digest = ms_hmac_digest1,
8924 .iv = ms_aes_cbc_iv1
8927 .cipher_key = ms_aes_cbc_key2,
8928 .hmac_key = ms_hmac_key2,
8929 .cipher = ms_aes_cbc_cipher2,
8930 .digest = ms_hmac_digest2,
8931 .iv = ms_aes_cbc_iv2
8936 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8938 sessions = rte_malloc(NULL,
8939 (sizeof(struct rte_cryptodev_sym_session *)
8940 * MAX_NB_SESSIONS) + 1, 0);
8942 for (i = 0; i < MB_SESSION_NUMBER; i++) {
8943 sessions[i] = rte_cryptodev_sym_session_create(
8944 ts_params->session_mpool);
8946 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
8947 sizeof(struct crypto_unittest_params));
8949 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
8950 &ut_paramz[i].ut_params,
8951 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
8953 /* Create multiple crypto sessions*/
8954 rte_cryptodev_sym_session_init(
8955 ts_params->valid_devs[0],
8957 &ut_paramz[i].ut_params.auth_xform,
8958 ts_params->session_priv_mpool);
8960 TEST_ASSERT_NOT_NULL(sessions[i],
8961 "Session creation failed at session number %u",
8967 for (i = 0; i < 40000; i++) {
8969 j = rand() % MB_SESSION_NUMBER;
8971 TEST_ASSERT_SUCCESS(
8972 test_AES_CBC_HMAC_SHA512_decrypt_perform(
8974 &ut_paramz[j].ut_params,
8975 ts_params, ut_paramz[j].cipher,
8976 ut_paramz[j].digest,
8978 "Failed to perform decrypt on request number %u.", i);
8980 if (ut_paramz[j].ut_params.op)
8981 rte_crypto_op_free(ut_paramz[j].ut_params.op);
8984 * free mbuf - both obuf and ibuf are usually the same,
8985 * so check if they point at the same address is necessary,
8986 * to avoid freeing the mbuf twice.
8988 if (ut_paramz[j].ut_params.obuf) {
8989 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
8990 if (ut_paramz[j].ut_params.ibuf
8991 == ut_paramz[j].ut_params.obuf)
8992 ut_paramz[j].ut_params.ibuf = 0;
8993 ut_paramz[j].ut_params.obuf = 0;
8995 if (ut_paramz[j].ut_params.ibuf) {
8996 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
8997 ut_paramz[j].ut_params.ibuf = 0;
9001 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9002 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9004 rte_cryptodev_sym_session_free(sessions[i]);
9009 return TEST_SUCCESS;
9013 test_null_cipher_only_operation(void)
9015 struct crypto_testsuite_params *ts_params = &testsuite_params;
9016 struct crypto_unittest_params *ut_params = &unittest_params;
9018 /* Generate test mbuf data and space for digest */
9019 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9020 catch_22_quote, QUOTE_512_BYTES, 0);
9022 /* Setup Cipher Parameters */
9023 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9024 ut_params->cipher_xform.next = NULL;
9026 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9027 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9029 ut_params->sess = rte_cryptodev_sym_session_create(
9030 ts_params->session_mpool);
9032 /* Create Crypto session*/
9033 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9035 &ut_params->cipher_xform,
9036 ts_params->session_priv_mpool);
9037 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9039 /* Generate Crypto op data structure */
9040 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9041 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9042 TEST_ASSERT_NOT_NULL(ut_params->op,
9043 "Failed to allocate symmetric crypto operation struct");
9045 /* Set crypto operation data parameters */
9046 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9048 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9050 /* set crypto operation source mbuf */
9051 sym_op->m_src = ut_params->ibuf;
9053 sym_op->cipher.data.offset = 0;
9054 sym_op->cipher.data.length = QUOTE_512_BYTES;
9056 /* Process crypto operation */
9057 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9059 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9061 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9062 "crypto operation processing failed");
9065 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9066 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9069 "Ciphertext data not as expected");
9071 return TEST_SUCCESS;
9073 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9074 0xab, 0xab, 0xab, 0xab,
9075 0xab, 0xab, 0xab, 0xab,
9076 0xab, 0xab, 0xab, 0xab};
9078 test_null_auth_only_operation(void)
9080 struct crypto_testsuite_params *ts_params = &testsuite_params;
9081 struct crypto_unittest_params *ut_params = &unittest_params;
9084 /* Generate test mbuf data and space for digest */
9085 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9086 catch_22_quote, QUOTE_512_BYTES, 0);
9088 /* create a pointer for digest, but don't expect anything to be written
9089 * here in a NULL auth algo so no mbuf append done.
9091 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9093 /* prefill the memory pointed to by digest */
9094 memcpy(digest, orig_data, sizeof(orig_data));
9096 /* Setup HMAC Parameters */
9097 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9098 ut_params->auth_xform.next = NULL;
9100 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9101 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9103 ut_params->sess = rte_cryptodev_sym_session_create(
9104 ts_params->session_mpool);
9106 /* Create Crypto session*/
9107 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9108 ut_params->sess, &ut_params->auth_xform,
9109 ts_params->session_priv_mpool);
9110 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9112 /* Generate Crypto op data structure */
9113 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9114 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9115 TEST_ASSERT_NOT_NULL(ut_params->op,
9116 "Failed to allocate symmetric crypto operation struct");
9118 /* Set crypto operation data parameters */
9119 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9121 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9123 sym_op->m_src = ut_params->ibuf;
9125 sym_op->auth.data.offset = 0;
9126 sym_op->auth.data.length = QUOTE_512_BYTES;
9127 sym_op->auth.digest.data = digest;
9128 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9131 /* Process crypto operation */
9132 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9134 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9136 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9137 "crypto operation processing failed");
9138 /* Make sure memory pointed to by digest hasn't been overwritten */
9139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9143 "Memory at digest ptr overwritten unexpectedly");
9145 return TEST_SUCCESS;
9150 test_null_cipher_auth_operation(void)
9152 struct crypto_testsuite_params *ts_params = &testsuite_params;
9153 struct crypto_unittest_params *ut_params = &unittest_params;
9156 /* Generate test mbuf data and space for digest */
9157 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9158 catch_22_quote, QUOTE_512_BYTES, 0);
9160 /* create a pointer for digest, but don't expect anything to be written
9161 * here in a NULL auth algo so no mbuf append done.
9163 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9165 /* prefill the memory pointed to by digest */
9166 memcpy(digest, orig_data, sizeof(orig_data));
9168 /* Setup Cipher Parameters */
9169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9170 ut_params->cipher_xform.next = &ut_params->auth_xform;
9172 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9173 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9175 /* Setup HMAC Parameters */
9176 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9177 ut_params->auth_xform.next = NULL;
9179 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9180 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9182 ut_params->sess = rte_cryptodev_sym_session_create(
9183 ts_params->session_mpool);
9185 /* Create Crypto session*/
9186 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9187 ut_params->sess, &ut_params->cipher_xform,
9188 ts_params->session_priv_mpool);
9189 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9191 /* Generate Crypto op data structure */
9192 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9193 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9194 TEST_ASSERT_NOT_NULL(ut_params->op,
9195 "Failed to allocate symmetric crypto operation struct");
9197 /* Set crypto operation data parameters */
9198 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9200 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9202 sym_op->m_src = ut_params->ibuf;
9204 sym_op->cipher.data.offset = 0;
9205 sym_op->cipher.data.length = QUOTE_512_BYTES;
9207 sym_op->auth.data.offset = 0;
9208 sym_op->auth.data.length = QUOTE_512_BYTES;
9209 sym_op->auth.digest.data = digest;
9210 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9213 /* Process crypto operation */
9214 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9216 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9218 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9219 "crypto operation processing failed");
9222 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9223 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9226 "Ciphertext data not as expected");
9227 /* Make sure memory pointed to by digest hasn't been overwritten */
9228 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9232 "Memory at digest ptr overwritten unexpectedly");
9234 return TEST_SUCCESS;
9238 test_null_auth_cipher_operation(void)
9240 struct crypto_testsuite_params *ts_params = &testsuite_params;
9241 struct crypto_unittest_params *ut_params = &unittest_params;
9244 /* Generate test mbuf data */
9245 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9246 catch_22_quote, QUOTE_512_BYTES, 0);
9248 /* create a pointer for digest, but don't expect anything to be written
9249 * here in a NULL auth algo so no mbuf append done.
9251 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9253 /* prefill the memory pointed to by digest */
9254 memcpy(digest, orig_data, sizeof(orig_data));
9256 /* Setup Cipher Parameters */
9257 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9258 ut_params->cipher_xform.next = NULL;
9260 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9261 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9263 /* Setup HMAC Parameters */
9264 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9265 ut_params->auth_xform.next = &ut_params->cipher_xform;
9267 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9268 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9270 ut_params->sess = rte_cryptodev_sym_session_create(
9271 ts_params->session_mpool);
9273 /* Create Crypto session*/
9274 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9275 ut_params->sess, &ut_params->cipher_xform,
9276 ts_params->session_priv_mpool);
9277 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9279 /* Generate Crypto op data structure */
9280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9282 TEST_ASSERT_NOT_NULL(ut_params->op,
9283 "Failed to allocate symmetric crypto operation struct");
9285 /* Set crypto operation data parameters */
9286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9290 sym_op->m_src = ut_params->ibuf;
9292 sym_op->cipher.data.offset = 0;
9293 sym_op->cipher.data.length = QUOTE_512_BYTES;
9295 sym_op->auth.data.offset = 0;
9296 sym_op->auth.data.length = QUOTE_512_BYTES;
9297 sym_op->auth.digest.data = digest;
9298 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9301 /* Process crypto operation */
9302 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9304 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9306 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9307 "crypto operation processing failed");
9310 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9311 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9314 "Ciphertext data not as expected");
9315 /* Make sure memory pointed to by digest hasn't been overwritten */
9316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9320 "Memory at digest ptr overwritten unexpectedly");
9322 return TEST_SUCCESS;
9327 test_null_invalid_operation(void)
9329 struct crypto_testsuite_params *ts_params = &testsuite_params;
9330 struct crypto_unittest_params *ut_params = &unittest_params;
9333 /* Setup Cipher Parameters */
9334 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9335 ut_params->cipher_xform.next = NULL;
9337 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9338 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9340 ut_params->sess = rte_cryptodev_sym_session_create(
9341 ts_params->session_mpool);
9343 /* Create Crypto session*/
9344 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9345 ut_params->sess, &ut_params->cipher_xform,
9346 ts_params->session_priv_mpool);
9347 TEST_ASSERT(ret < 0,
9348 "Session creation succeeded unexpectedly");
9351 /* Setup HMAC Parameters */
9352 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9353 ut_params->auth_xform.next = NULL;
9355 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9356 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9358 ut_params->sess = rte_cryptodev_sym_session_create(
9359 ts_params->session_mpool);
9361 /* Create Crypto session*/
9362 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9363 ut_params->sess, &ut_params->auth_xform,
9364 ts_params->session_priv_mpool);
9365 TEST_ASSERT(ret < 0,
9366 "Session creation succeeded unexpectedly");
9368 return TEST_SUCCESS;
9372 #define NULL_BURST_LENGTH (32)
9375 test_null_burst_operation(void)
9377 struct crypto_testsuite_params *ts_params = &testsuite_params;
9378 struct crypto_unittest_params *ut_params = &unittest_params;
9380 unsigned i, burst_len = NULL_BURST_LENGTH;
9382 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9383 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9385 /* Setup Cipher Parameters */
9386 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9387 ut_params->cipher_xform.next = &ut_params->auth_xform;
9389 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9390 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9392 /* Setup HMAC Parameters */
9393 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9394 ut_params->auth_xform.next = NULL;
9396 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9397 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9399 ut_params->sess = rte_cryptodev_sym_session_create(
9400 ts_params->session_mpool);
9402 /* Create Crypto session*/
9403 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9404 ut_params->sess, &ut_params->cipher_xform,
9405 ts_params->session_priv_mpool);
9406 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9408 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9409 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9410 burst_len, "failed to generate burst of crypto ops");
9412 /* Generate an operation for each mbuf in burst */
9413 for (i = 0; i < burst_len; i++) {
9414 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9416 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9418 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9422 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9424 burst[i]->sym->m_src = m;
9427 /* Process crypto operation */
9428 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9429 0, burst, burst_len),
9431 "Error enqueuing burst");
9433 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9434 0, burst_dequeued, burst_len),
9436 "Error dequeuing burst");
9439 for (i = 0; i < burst_len; i++) {
9441 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9442 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9444 "data not as expected");
9446 rte_pktmbuf_free(burst[i]->sym->m_src);
9447 rte_crypto_op_free(burst[i]);
9450 return TEST_SUCCESS;
9454 generate_gmac_large_plaintext(uint8_t *data)
9458 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9459 memcpy(&data[i], &data[0], 32);
9463 create_gmac_operation(enum rte_crypto_auth_operation op,
9464 const struct gmac_test_data *tdata)
9466 struct crypto_testsuite_params *ts_params = &testsuite_params;
9467 struct crypto_unittest_params *ut_params = &unittest_params;
9468 struct rte_crypto_sym_op *sym_op;
9470 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9472 /* Generate Crypto op data structure */
9473 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9474 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9475 TEST_ASSERT_NOT_NULL(ut_params->op,
9476 "Failed to allocate symmetric crypto operation struct");
9478 sym_op = ut_params->op->sym;
9480 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9481 ut_params->ibuf, tdata->gmac_tag.len);
9482 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9483 "no room to append digest");
9485 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9486 ut_params->ibuf, plaintext_pad_len);
9488 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9489 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9490 tdata->gmac_tag.len);
9491 debug_hexdump(stdout, "digest:",
9492 sym_op->auth.digest.data,
9493 tdata->gmac_tag.len);
9496 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9497 uint8_t *, IV_OFFSET);
9499 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9501 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9503 sym_op->cipher.data.length = 0;
9504 sym_op->cipher.data.offset = 0;
9506 sym_op->auth.data.offset = 0;
9507 sym_op->auth.data.length = tdata->plaintext.len;
9512 static int create_gmac_session(uint8_t dev_id,
9513 const struct gmac_test_data *tdata,
9514 enum rte_crypto_auth_operation auth_op)
9516 uint8_t auth_key[tdata->key.len];
9518 struct crypto_testsuite_params *ts_params = &testsuite_params;
9519 struct crypto_unittest_params *ut_params = &unittest_params;
9521 memcpy(auth_key, tdata->key.data, tdata->key.len);
9523 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9524 ut_params->auth_xform.next = NULL;
9526 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9527 ut_params->auth_xform.auth.op = auth_op;
9528 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9529 ut_params->auth_xform.auth.key.length = tdata->key.len;
9530 ut_params->auth_xform.auth.key.data = auth_key;
9531 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9532 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9535 ut_params->sess = rte_cryptodev_sym_session_create(
9536 ts_params->session_mpool);
9538 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9539 &ut_params->auth_xform,
9540 ts_params->session_priv_mpool);
9542 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9548 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9550 struct crypto_testsuite_params *ts_params = &testsuite_params;
9551 struct crypto_unittest_params *ut_params = &unittest_params;
9555 uint8_t *auth_tag, *plaintext;
9556 uint16_t plaintext_pad_len;
9558 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9559 "No GMAC length in the source data");
9561 retval = create_gmac_session(ts_params->valid_devs[0],
9562 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9567 if (tdata->plaintext.len > MBUF_SIZE)
9568 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9571 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9572 "Failed to allocate input buffer in mempool");
9574 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9575 rte_pktmbuf_tailroom(ut_params->ibuf));
9577 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9579 * Runtime generate the large plain text instead of use hard code
9580 * plain text vector. It is done to avoid create huge source file
9581 * with the test vector.
9583 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9584 generate_gmac_large_plaintext(tdata->plaintext.data);
9586 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9588 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9590 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9591 debug_hexdump(stdout, "plaintext:", plaintext,
9592 tdata->plaintext.len);
9594 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9600 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9602 ut_params->op->sym->m_src = ut_params->ibuf;
9604 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9605 ut_params->op), "failed to process sym crypto op");
9607 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9608 "crypto op processing failed");
9610 if (ut_params->op->sym->m_dst) {
9611 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9612 uint8_t *, plaintext_pad_len);
9614 auth_tag = plaintext + plaintext_pad_len;
9617 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9621 tdata->gmac_tag.data,
9622 tdata->gmac_tag.len,
9623 "GMAC Generated auth tag not as expected");
9629 test_AES_GMAC_authentication_test_case_1(void)
9631 return test_AES_GMAC_authentication(&gmac_test_case_1);
9635 test_AES_GMAC_authentication_test_case_2(void)
9637 return test_AES_GMAC_authentication(&gmac_test_case_2);
9641 test_AES_GMAC_authentication_test_case_3(void)
9643 return test_AES_GMAC_authentication(&gmac_test_case_3);
9647 test_AES_GMAC_authentication_test_case_4(void)
9649 return test_AES_GMAC_authentication(&gmac_test_case_4);
9653 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9655 struct crypto_testsuite_params *ts_params = &testsuite_params;
9656 struct crypto_unittest_params *ut_params = &unittest_params;
9658 uint32_t plaintext_pad_len;
9661 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9662 "No GMAC length in the source data");
9664 retval = create_gmac_session(ts_params->valid_devs[0],
9665 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9670 if (tdata->plaintext.len > MBUF_SIZE)
9671 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9673 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9674 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9675 "Failed to allocate input buffer in mempool");
9677 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9678 rte_pktmbuf_tailroom(ut_params->ibuf));
9680 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9683 * Runtime generate the large plain text instead of use hard code
9684 * plain text vector. It is done to avoid create huge source file
9685 * with the test vector.
9687 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9688 generate_gmac_large_plaintext(tdata->plaintext.data);
9690 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9692 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9694 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9695 debug_hexdump(stdout, "plaintext:", plaintext,
9696 tdata->plaintext.len);
9698 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9704 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9706 ut_params->op->sym->m_src = ut_params->ibuf;
9708 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9709 ut_params->op), "failed to process sym crypto op");
9711 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9712 "crypto op processing failed");
9719 test_AES_GMAC_authentication_verify_test_case_1(void)
9721 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9725 test_AES_GMAC_authentication_verify_test_case_2(void)
9727 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9731 test_AES_GMAC_authentication_verify_test_case_3(void)
9733 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
9737 test_AES_GMAC_authentication_verify_test_case_4(void)
9739 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
9742 struct test_crypto_vector {
9743 enum rte_crypto_cipher_algorithm crypto_algo;
9744 unsigned int cipher_offset;
9745 unsigned int cipher_len;
9758 const uint8_t *data;
9763 const uint8_t *data;
9767 enum rte_crypto_auth_algorithm auth_algo;
9768 unsigned int auth_offset;
9776 const uint8_t *data;
9786 static const struct test_crypto_vector
9787 hmac_sha1_test_crypto_vector = {
9788 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9790 .data = plaintext_hash,
9795 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9796 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9797 0xDE, 0xF4, 0xDE, 0xAD
9803 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9804 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9805 0x3F, 0x91, 0x64, 0x59
9811 static const struct test_crypto_vector
9812 aes128_gmac_test_vector = {
9813 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9815 .data = plaintext_hash,
9820 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9821 0x08, 0x09, 0x0A, 0x0B
9827 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9828 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9834 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9835 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9841 static const struct test_crypto_vector
9842 aes128cbc_hmac_sha1_test_vector = {
9843 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9848 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9849 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9855 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9856 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9861 .data = plaintext_hash,
9865 .data = ciphertext512_aes128cbc,
9868 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9872 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9873 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9874 0xDE, 0xF4, 0xDE, 0xAD
9880 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9881 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9882 0x18, 0x8C, 0x1D, 0x32
9888 static const struct test_crypto_vector
9889 aes128cbc_hmac_sha1_aad_test_vector = {
9890 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9891 .cipher_offset = 12,
9895 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9896 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9902 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9903 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9908 .data = plaintext_hash,
9912 .data = ciphertext512_aes128cbc_aad,
9915 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9919 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9920 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9921 0xDE, 0xF4, 0xDE, 0xAD
9927 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
9928 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
9929 0x62, 0x8D, 0x62, 0x65
9936 data_corruption(uint8_t *data)
9942 tag_corruption(uint8_t *data, unsigned int tag_offset)
9944 data[tag_offset] += 1;
9948 create_auth_session(struct crypto_unittest_params *ut_params,
9950 const struct test_crypto_vector *reference,
9951 enum rte_crypto_auth_operation auth_op)
9953 struct crypto_testsuite_params *ts_params = &testsuite_params;
9954 uint8_t auth_key[reference->auth_key.len + 1];
9956 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9958 /* Setup Authentication Parameters */
9959 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9960 ut_params->auth_xform.auth.op = auth_op;
9961 ut_params->auth_xform.next = NULL;
9962 ut_params->auth_xform.auth.algo = reference->auth_algo;
9963 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9964 ut_params->auth_xform.auth.key.data = auth_key;
9965 ut_params->auth_xform.auth.digest_length = reference->digest.len;
9967 /* Create Crypto session*/
9968 ut_params->sess = rte_cryptodev_sym_session_create(
9969 ts_params->session_mpool);
9971 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9972 &ut_params->auth_xform,
9973 ts_params->session_priv_mpool);
9975 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9981 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
9983 const struct test_crypto_vector *reference,
9984 enum rte_crypto_auth_operation auth_op,
9985 enum rte_crypto_cipher_operation cipher_op)
9987 struct crypto_testsuite_params *ts_params = &testsuite_params;
9988 uint8_t cipher_key[reference->cipher_key.len + 1];
9989 uint8_t auth_key[reference->auth_key.len + 1];
9991 memcpy(cipher_key, reference->cipher_key.data,
9992 reference->cipher_key.len);
9993 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9995 /* Setup Authentication Parameters */
9996 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9997 ut_params->auth_xform.auth.op = auth_op;
9998 ut_params->auth_xform.auth.algo = reference->auth_algo;
9999 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10000 ut_params->auth_xform.auth.key.data = auth_key;
10001 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10003 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10004 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10005 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10007 ut_params->auth_xform.next = &ut_params->cipher_xform;
10009 /* Setup Cipher Parameters */
10010 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10011 ut_params->cipher_xform.next = NULL;
10012 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10013 ut_params->cipher_xform.cipher.op = cipher_op;
10014 ut_params->cipher_xform.cipher.key.data = cipher_key;
10015 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10016 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10017 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10020 /* Create Crypto session*/
10021 ut_params->sess = rte_cryptodev_sym_session_create(
10022 ts_params->session_mpool);
10024 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10025 &ut_params->auth_xform,
10026 ts_params->session_priv_mpool);
10028 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10034 create_auth_operation(struct crypto_testsuite_params *ts_params,
10035 struct crypto_unittest_params *ut_params,
10036 const struct test_crypto_vector *reference,
10037 unsigned int auth_generate)
10039 /* Generate Crypto op data structure */
10040 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10041 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10042 TEST_ASSERT_NOT_NULL(ut_params->op,
10043 "Failed to allocate pktmbuf offload");
10045 /* Set crypto operation data parameters */
10046 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10048 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10050 /* set crypto operation source mbuf */
10051 sym_op->m_src = ut_params->ibuf;
10054 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10055 ut_params->ibuf, reference->digest.len);
10057 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10058 "no room to append auth tag");
10060 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10061 ut_params->ibuf, reference->plaintext.len);
10064 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10066 memcpy(sym_op->auth.digest.data,
10067 reference->digest.data,
10068 reference->digest.len);
10070 debug_hexdump(stdout, "digest:",
10071 sym_op->auth.digest.data,
10072 reference->digest.len);
10074 sym_op->auth.data.length = reference->plaintext.len;
10075 sym_op->auth.data.offset = 0;
10081 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10082 struct crypto_unittest_params *ut_params,
10083 const struct test_crypto_vector *reference,
10084 unsigned int auth_generate)
10086 /* Generate Crypto op data structure */
10087 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10088 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10089 TEST_ASSERT_NOT_NULL(ut_params->op,
10090 "Failed to allocate pktmbuf offload");
10092 /* Set crypto operation data parameters */
10093 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10095 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10097 /* set crypto operation source mbuf */
10098 sym_op->m_src = ut_params->ibuf;
10101 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10102 ut_params->ibuf, reference->digest.len);
10104 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10105 "no room to append auth tag");
10107 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10108 ut_params->ibuf, reference->ciphertext.len);
10111 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10113 memcpy(sym_op->auth.digest.data,
10114 reference->digest.data,
10115 reference->digest.len);
10117 debug_hexdump(stdout, "digest:",
10118 sym_op->auth.digest.data,
10119 reference->digest.len);
10121 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10122 reference->iv.data, reference->iv.len);
10124 sym_op->cipher.data.length = 0;
10125 sym_op->cipher.data.offset = 0;
10127 sym_op->auth.data.length = reference->plaintext.len;
10128 sym_op->auth.data.offset = 0;
10134 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10135 struct crypto_unittest_params *ut_params,
10136 const struct test_crypto_vector *reference,
10137 unsigned int auth_generate)
10139 /* Generate Crypto op data structure */
10140 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10141 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10142 TEST_ASSERT_NOT_NULL(ut_params->op,
10143 "Failed to allocate pktmbuf offload");
10145 /* Set crypto operation data parameters */
10146 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10148 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10150 /* set crypto operation source mbuf */
10151 sym_op->m_src = ut_params->ibuf;
10154 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10155 ut_params->ibuf, reference->digest.len);
10157 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10158 "no room to append auth tag");
10160 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10161 ut_params->ibuf, reference->ciphertext.len);
10164 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10166 memcpy(sym_op->auth.digest.data,
10167 reference->digest.data,
10168 reference->digest.len);
10170 debug_hexdump(stdout, "digest:",
10171 sym_op->auth.digest.data,
10172 reference->digest.len);
10174 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10175 reference->iv.data, reference->iv.len);
10177 sym_op->cipher.data.length = reference->cipher_len;
10178 sym_op->cipher.data.offset = reference->cipher_offset;
10180 sym_op->auth.data.length = reference->plaintext.len;
10181 sym_op->auth.data.offset = reference->auth_offset;
10187 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10188 struct crypto_unittest_params *ut_params,
10189 const struct test_crypto_vector *reference)
10191 return create_auth_operation(ts_params, ut_params, reference, 0);
10195 create_auth_verify_GMAC_operation(
10196 struct crypto_testsuite_params *ts_params,
10197 struct crypto_unittest_params *ut_params,
10198 const struct test_crypto_vector *reference)
10200 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10204 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10205 struct crypto_unittest_params *ut_params,
10206 const struct test_crypto_vector *reference)
10208 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10212 test_authentication_verify_fail_when_data_corruption(
10213 struct crypto_testsuite_params *ts_params,
10214 struct crypto_unittest_params *ut_params,
10215 const struct test_crypto_vector *reference,
10216 unsigned int data_corrupted)
10220 uint8_t *plaintext;
10222 /* Create session */
10223 retval = create_auth_session(ut_params,
10224 ts_params->valid_devs[0],
10226 RTE_CRYPTO_AUTH_OP_VERIFY);
10230 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10231 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10232 "Failed to allocate input buffer in mempool");
10234 /* clear mbuf payload */
10235 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10236 rte_pktmbuf_tailroom(ut_params->ibuf));
10238 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10239 reference->plaintext.len);
10240 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10241 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10243 debug_hexdump(stdout, "plaintext:", plaintext,
10244 reference->plaintext.len);
10246 /* Create operation */
10247 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10252 if (data_corrupted)
10253 data_corruption(plaintext);
10255 tag_corruption(plaintext, reference->plaintext.len);
10257 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10260 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10261 RTE_CRYPTO_OP_STATUS_SUCCESS,
10262 "authentication not failed");
10264 ut_params->obuf = ut_params->op->sym->m_src;
10265 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10271 test_authentication_verify_GMAC_fail_when_corruption(
10272 struct crypto_testsuite_params *ts_params,
10273 struct crypto_unittest_params *ut_params,
10274 const struct test_crypto_vector *reference,
10275 unsigned int data_corrupted)
10278 uint8_t *plaintext;
10280 /* Create session */
10281 retval = create_auth_cipher_session(ut_params,
10282 ts_params->valid_devs[0],
10284 RTE_CRYPTO_AUTH_OP_VERIFY,
10285 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10289 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10290 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10291 "Failed to allocate input buffer in mempool");
10293 /* clear mbuf payload */
10294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10295 rte_pktmbuf_tailroom(ut_params->ibuf));
10297 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10298 reference->plaintext.len);
10299 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10300 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10302 debug_hexdump(stdout, "plaintext:", plaintext,
10303 reference->plaintext.len);
10305 /* Create operation */
10306 retval = create_auth_verify_GMAC_operation(ts_params,
10313 if (data_corrupted)
10314 data_corruption(plaintext);
10316 tag_corruption(plaintext, reference->aad.len);
10318 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10320 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10321 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10322 RTE_CRYPTO_OP_STATUS_SUCCESS,
10323 "authentication not failed");
10325 ut_params->obuf = ut_params->op->sym->m_src;
10326 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10332 test_authenticated_decryption_fail_when_corruption(
10333 struct crypto_testsuite_params *ts_params,
10334 struct crypto_unittest_params *ut_params,
10335 const struct test_crypto_vector *reference,
10336 unsigned int data_corrupted)
10340 uint8_t *ciphertext;
10342 /* Create session */
10343 retval = create_auth_cipher_session(ut_params,
10344 ts_params->valid_devs[0],
10346 RTE_CRYPTO_AUTH_OP_VERIFY,
10347 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10352 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10353 "Failed to allocate input buffer in mempool");
10355 /* clear mbuf payload */
10356 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10357 rte_pktmbuf_tailroom(ut_params->ibuf));
10359 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10360 reference->ciphertext.len);
10361 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10362 memcpy(ciphertext, reference->ciphertext.data,
10363 reference->ciphertext.len);
10365 /* Create operation */
10366 retval = create_cipher_auth_verify_operation(ts_params,
10373 if (data_corrupted)
10374 data_corruption(ciphertext);
10376 tag_corruption(ciphertext, reference->ciphertext.len);
10378 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10381 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10382 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10383 RTE_CRYPTO_OP_STATUS_SUCCESS,
10384 "authentication not failed");
10386 ut_params->obuf = ut_params->op->sym->m_src;
10387 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10393 test_authenticated_encryt_with_esn(
10394 struct crypto_testsuite_params *ts_params,
10395 struct crypto_unittest_params *ut_params,
10396 const struct test_crypto_vector *reference)
10400 uint8_t *authciphertext, *plaintext, *auth_tag;
10401 uint16_t plaintext_pad_len;
10402 uint8_t cipher_key[reference->cipher_key.len + 1];
10403 uint8_t auth_key[reference->auth_key.len + 1];
10405 /* Create session */
10406 memcpy(cipher_key, reference->cipher_key.data,
10407 reference->cipher_key.len);
10408 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10410 /* Setup Cipher Parameters */
10411 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10412 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10413 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10414 ut_params->cipher_xform.cipher.key.data = cipher_key;
10415 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10416 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10417 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10419 ut_params->cipher_xform.next = &ut_params->auth_xform;
10421 /* Setup Authentication Parameters */
10422 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10423 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10424 ut_params->auth_xform.auth.algo = reference->auth_algo;
10425 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10426 ut_params->auth_xform.auth.key.data = auth_key;
10427 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10428 ut_params->auth_xform.next = NULL;
10430 /* Create Crypto session*/
10431 ut_params->sess = rte_cryptodev_sym_session_create(
10432 ts_params->session_mpool);
10434 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10436 &ut_params->cipher_xform,
10437 ts_params->session_priv_mpool);
10439 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10441 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10442 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10443 "Failed to allocate input buffer in mempool");
10445 /* clear mbuf payload */
10446 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10447 rte_pktmbuf_tailroom(ut_params->ibuf));
10449 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10450 reference->plaintext.len);
10451 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10452 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10454 /* Create operation */
10455 retval = create_cipher_auth_operation(ts_params,
10462 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10465 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10467 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10468 "crypto op processing failed");
10470 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10472 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10473 ut_params->op->sym->auth.data.offset);
10474 auth_tag = authciphertext + plaintext_pad_len;
10475 debug_hexdump(stdout, "ciphertext:", authciphertext,
10476 reference->ciphertext.len);
10477 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10479 /* Validate obuf */
10480 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10482 reference->ciphertext.data,
10483 reference->ciphertext.len,
10484 "Ciphertext data not as expected");
10486 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10488 reference->digest.data,
10489 reference->digest.len,
10490 "Generated digest not as expected");
10492 return TEST_SUCCESS;
10497 test_authenticated_decrypt_with_esn(
10498 struct crypto_testsuite_params *ts_params,
10499 struct crypto_unittest_params *ut_params,
10500 const struct test_crypto_vector *reference)
10504 uint8_t *ciphertext;
10505 uint8_t cipher_key[reference->cipher_key.len + 1];
10506 uint8_t auth_key[reference->auth_key.len + 1];
10508 /* Create session */
10509 memcpy(cipher_key, reference->cipher_key.data,
10510 reference->cipher_key.len);
10511 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10513 /* Setup Authentication Parameters */
10514 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10515 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10516 ut_params->auth_xform.auth.algo = reference->auth_algo;
10517 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10518 ut_params->auth_xform.auth.key.data = auth_key;
10519 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10520 ut_params->auth_xform.next = &ut_params->cipher_xform;
10522 /* Setup Cipher Parameters */
10523 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10524 ut_params->cipher_xform.next = NULL;
10525 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10526 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10527 ut_params->cipher_xform.cipher.key.data = cipher_key;
10528 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10529 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10530 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10532 /* Create Crypto session*/
10533 ut_params->sess = rte_cryptodev_sym_session_create(
10534 ts_params->session_mpool);
10536 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10538 &ut_params->auth_xform,
10539 ts_params->session_priv_mpool);
10541 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10543 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10544 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10545 "Failed to allocate input buffer in mempool");
10547 /* clear mbuf payload */
10548 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10549 rte_pktmbuf_tailroom(ut_params->ibuf));
10551 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10552 reference->ciphertext.len);
10553 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10554 memcpy(ciphertext, reference->ciphertext.data,
10555 reference->ciphertext.len);
10557 /* Create operation */
10558 retval = create_cipher_auth_verify_operation(ts_params,
10565 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10569 TEST_ASSERT_EQUAL(ut_params->op->status,
10570 RTE_CRYPTO_OP_STATUS_SUCCESS,
10571 "crypto op processing passed");
10573 ut_params->obuf = ut_params->op->sym->m_src;
10574 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10580 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10581 const struct aead_test_data *tdata,
10582 void *digest_mem, uint64_t digest_phys)
10584 struct crypto_testsuite_params *ts_params = &testsuite_params;
10585 struct crypto_unittest_params *ut_params = &unittest_params;
10587 const unsigned int auth_tag_len = tdata->auth_tag.len;
10588 const unsigned int iv_len = tdata->iv.len;
10589 unsigned int aad_len = tdata->aad.len;
10591 /* Generate Crypto op data structure */
10592 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10593 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10594 TEST_ASSERT_NOT_NULL(ut_params->op,
10595 "Failed to allocate symmetric crypto operation struct");
10597 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10599 sym_op->aead.digest.data = digest_mem;
10601 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10602 "no room to append digest");
10604 sym_op->aead.digest.phys_addr = digest_phys;
10606 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10607 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10609 debug_hexdump(stdout, "digest:",
10610 sym_op->aead.digest.data,
10614 /* Append aad data */
10615 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10616 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10617 uint8_t *, IV_OFFSET);
10619 /* Copy IV 1 byte after the IV pointer, according to the API */
10620 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10622 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10624 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10625 ut_params->ibuf, aad_len);
10626 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10627 "no room to prepend aad");
10628 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10631 memset(sym_op->aead.aad.data, 0, aad_len);
10632 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10633 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10635 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10636 debug_hexdump(stdout, "aad:",
10637 sym_op->aead.aad.data, aad_len);
10639 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10640 uint8_t *, IV_OFFSET);
10642 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10644 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10645 ut_params->ibuf, aad_len);
10646 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10647 "no room to prepend aad");
10648 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10651 memset(sym_op->aead.aad.data, 0, aad_len);
10652 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10654 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10655 debug_hexdump(stdout, "aad:",
10656 sym_op->aead.aad.data, aad_len);
10659 sym_op->aead.data.length = tdata->plaintext.len;
10660 sym_op->aead.data.offset = aad_len;
10665 #define SGL_MAX_NO 16
10668 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10669 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10671 struct crypto_testsuite_params *ts_params = &testsuite_params;
10672 struct crypto_unittest_params *ut_params = &unittest_params;
10673 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10676 int to_trn_tbl[SGL_MAX_NO];
10678 unsigned int trn_data = 0;
10679 uint8_t *plaintext, *ciphertext, *auth_tag;
10681 if (fragsz > tdata->plaintext.len)
10682 fragsz = tdata->plaintext.len;
10684 uint16_t plaintext_len = fragsz;
10685 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
10687 if (fragsz_oop > tdata->plaintext.len)
10688 frag_size_oop = tdata->plaintext.len;
10691 void *digest_mem = NULL;
10693 uint32_t prepend_len = tdata->aad.len;
10695 if (tdata->plaintext.len % fragsz != 0) {
10696 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
10699 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
10704 * For out-op-place we need to alloc another mbuf
10707 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10708 rte_pktmbuf_append(ut_params->obuf,
10709 frag_size_oop + prepend_len);
10710 buf_oop = ut_params->obuf;
10713 /* Create AEAD session */
10714 retval = create_aead_session(ts_params->valid_devs[0],
10716 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10717 tdata->key.data, tdata->key.len,
10718 tdata->aad.len, tdata->auth_tag.len,
10723 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10725 /* clear mbuf payload */
10726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10727 rte_pktmbuf_tailroom(ut_params->ibuf));
10729 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10732 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10734 trn_data += plaintext_len;
10736 buf = ut_params->ibuf;
10739 * Loop until no more fragments
10742 while (trn_data < tdata->plaintext.len) {
10744 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10745 (tdata->plaintext.len - trn_data) : fragsz;
10747 to_trn_tbl[ecx++] = to_trn;
10749 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10752 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10753 rte_pktmbuf_tailroom(buf));
10756 if (oop && !fragsz_oop) {
10757 buf_last_oop = buf_oop->next =
10758 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10759 buf_oop = buf_oop->next;
10760 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10761 0, rte_pktmbuf_tailroom(buf_oop));
10762 rte_pktmbuf_append(buf_oop, to_trn);
10765 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10768 memcpy(plaintext, tdata->plaintext.data + trn_data,
10770 trn_data += to_trn;
10771 if (trn_data == tdata->plaintext.len) {
10774 digest_mem = rte_pktmbuf_append(buf_oop,
10775 tdata->auth_tag.len);
10777 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10778 tdata->auth_tag.len);
10782 uint64_t digest_phys = 0;
10784 ut_params->ibuf->nb_segs = segs;
10787 if (fragsz_oop && oop) {
10791 if (frag_size_oop == tdata->plaintext.len) {
10792 digest_mem = rte_pktmbuf_append(ut_params->obuf,
10793 tdata->auth_tag.len);
10795 digest_phys = rte_pktmbuf_iova_offset(
10797 tdata->plaintext.len + prepend_len);
10800 trn_data = frag_size_oop;
10801 while (trn_data < tdata->plaintext.len) {
10804 (tdata->plaintext.len - trn_data <
10806 (tdata->plaintext.len - trn_data) :
10809 to_trn_tbl[ecx++] = to_trn;
10811 buf_last_oop = buf_oop->next =
10812 rte_pktmbuf_alloc(ts_params->mbuf_pool);
10813 buf_oop = buf_oop->next;
10814 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10815 0, rte_pktmbuf_tailroom(buf_oop));
10816 rte_pktmbuf_append(buf_oop, to_trn);
10818 trn_data += to_trn;
10820 if (trn_data == tdata->plaintext.len) {
10821 digest_mem = rte_pktmbuf_append(buf_oop,
10822 tdata->auth_tag.len);
10826 ut_params->obuf->nb_segs = segs;
10830 * Place digest at the end of the last buffer
10833 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
10834 if (oop && buf_last_oop)
10835 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
10837 if (!digest_mem && !oop) {
10838 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10839 + tdata->auth_tag.len);
10840 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
10841 tdata->plaintext.len);
10844 /* Create AEAD operation */
10845 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
10846 tdata, digest_mem, digest_phys);
10851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10853 ut_params->op->sym->m_src = ut_params->ibuf;
10855 ut_params->op->sym->m_dst = ut_params->obuf;
10857 /* Process crypto operation */
10858 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10859 ut_params->op), "failed to process sym crypto op");
10861 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10862 "crypto op processing failed");
10865 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10866 uint8_t *, prepend_len);
10868 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10869 uint8_t *, prepend_len);
10873 fragsz = fragsz_oop;
10875 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10877 tdata->ciphertext.data,
10879 "Ciphertext data not as expected");
10881 buf = ut_params->op->sym->m_src->next;
10883 buf = ut_params->op->sym->m_dst->next;
10885 unsigned int off = fragsz;
10889 ciphertext = rte_pktmbuf_mtod(buf,
10892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10894 tdata->ciphertext.data + off,
10896 "Ciphertext data not as expected");
10898 off += to_trn_tbl[ecx++];
10902 auth_tag = digest_mem;
10903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10905 tdata->auth_tag.data,
10906 tdata->auth_tag.len,
10907 "Generated auth tag not as expected");
10913 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
10915 return test_authenticated_encryption_SGL(
10916 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
10920 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
10922 return test_authenticated_encryption_SGL(
10923 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
10927 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
10929 return test_authenticated_encryption_SGL(
10930 &gcm_test_case_8, OUT_OF_PLACE, 400,
10931 gcm_test_case_8.plaintext.len);
10935 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
10938 return test_authenticated_encryption_SGL(
10939 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
10943 test_authentication_verify_fail_when_data_corrupted(
10944 struct crypto_testsuite_params *ts_params,
10945 struct crypto_unittest_params *ut_params,
10946 const struct test_crypto_vector *reference)
10948 return test_authentication_verify_fail_when_data_corruption(
10949 ts_params, ut_params, reference, 1);
10953 test_authentication_verify_fail_when_tag_corrupted(
10954 struct crypto_testsuite_params *ts_params,
10955 struct crypto_unittest_params *ut_params,
10956 const struct test_crypto_vector *reference)
10958 return test_authentication_verify_fail_when_data_corruption(
10959 ts_params, ut_params, reference, 0);
10963 test_authentication_verify_GMAC_fail_when_data_corrupted(
10964 struct crypto_testsuite_params *ts_params,
10965 struct crypto_unittest_params *ut_params,
10966 const struct test_crypto_vector *reference)
10968 return test_authentication_verify_GMAC_fail_when_corruption(
10969 ts_params, ut_params, reference, 1);
10973 test_authentication_verify_GMAC_fail_when_tag_corrupted(
10974 struct crypto_testsuite_params *ts_params,
10975 struct crypto_unittest_params *ut_params,
10976 const struct test_crypto_vector *reference)
10978 return test_authentication_verify_GMAC_fail_when_corruption(
10979 ts_params, ut_params, reference, 0);
10983 test_authenticated_decryption_fail_when_data_corrupted(
10984 struct crypto_testsuite_params *ts_params,
10985 struct crypto_unittest_params *ut_params,
10986 const struct test_crypto_vector *reference)
10988 return test_authenticated_decryption_fail_when_corruption(
10989 ts_params, ut_params, reference, 1);
10993 test_authenticated_decryption_fail_when_tag_corrupted(
10994 struct crypto_testsuite_params *ts_params,
10995 struct crypto_unittest_params *ut_params,
10996 const struct test_crypto_vector *reference)
10998 return test_authenticated_decryption_fail_when_corruption(
10999 ts_params, ut_params, reference, 0);
11003 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11005 return test_authentication_verify_fail_when_data_corrupted(
11006 &testsuite_params, &unittest_params,
11007 &hmac_sha1_test_crypto_vector);
11011 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11013 return test_authentication_verify_fail_when_tag_corrupted(
11014 &testsuite_params, &unittest_params,
11015 &hmac_sha1_test_crypto_vector);
11019 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11021 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11022 &testsuite_params, &unittest_params,
11023 &aes128_gmac_test_vector);
11027 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11029 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11030 &testsuite_params, &unittest_params,
11031 &aes128_gmac_test_vector);
11035 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11037 return test_authenticated_decryption_fail_when_data_corrupted(
11040 &aes128cbc_hmac_sha1_test_vector);
11044 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11046 return test_authenticated_decryption_fail_when_tag_corrupted(
11049 &aes128cbc_hmac_sha1_test_vector);
11053 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11055 return test_authenticated_encryt_with_esn(
11058 &aes128cbc_hmac_sha1_aad_test_vector);
11062 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11064 return test_authenticated_decrypt_with_esn(
11067 &aes128cbc_hmac_sha1_aad_test_vector);
11070 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11072 /* global AESNI slave IDs for the scheduler test */
11073 uint8_t aesni_ids[2];
11076 test_scheduler_attach_slave_op(void)
11078 struct crypto_testsuite_params *ts_params = &testsuite_params;
11079 uint8_t sched_id = ts_params->valid_devs[0];
11080 uint32_t nb_devs, i, nb_devs_attached = 0;
11082 char vdev_name[32];
11084 /* create 2 AESNI_MB if necessary */
11085 nb_devs = rte_cryptodev_device_count_by_driver(
11086 rte_cryptodev_driver_id_get(
11087 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11089 for (i = nb_devs; i < 2; i++) {
11090 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11091 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11093 ret = rte_vdev_init(vdev_name, NULL);
11095 TEST_ASSERT(ret == 0,
11096 "Failed to create instance %u of"
11098 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11102 /* attach 2 AESNI_MB cdevs */
11103 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11105 struct rte_cryptodev_info info;
11106 unsigned int session_size;
11108 rte_cryptodev_info_get(i, &info);
11109 if (info.driver_id != rte_cryptodev_driver_id_get(
11110 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11113 session_size = rte_cryptodev_sym_get_private_session_size(i);
11115 * Create the session mempool again, since now there are new devices
11116 * to use the mempool.
11118 if (ts_params->session_mpool) {
11119 rte_mempool_free(ts_params->session_mpool);
11120 ts_params->session_mpool = NULL;
11122 if (ts_params->session_priv_mpool) {
11123 rte_mempool_free(ts_params->session_priv_mpool);
11124 ts_params->session_priv_mpool = NULL;
11127 if (info.sym.max_nb_sessions != 0 &&
11128 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11129 RTE_LOG(ERR, USER1,
11130 "Device does not support "
11131 "at least %u sessions\n",
11133 return TEST_FAILED;
11136 * Create mempool with maximum number of sessions,
11137 * to include the session headers
11139 if (ts_params->session_mpool == NULL) {
11140 ts_params->session_mpool =
11141 rte_cryptodev_sym_session_pool_create(
11143 MAX_NB_SESSIONS, 0, 0, 0,
11145 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11146 "session mempool allocation failed");
11150 * Create mempool with maximum number of sessions,
11151 * to include device specific session private data
11153 if (ts_params->session_priv_mpool == NULL) {
11154 ts_params->session_priv_mpool = rte_mempool_create(
11155 "test_sess_mp_priv",
11158 0, 0, NULL, NULL, NULL,
11159 NULL, SOCKET_ID_ANY,
11162 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11163 "session mempool allocation failed");
11166 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11167 ts_params->qp_conf.mp_session_private =
11168 ts_params->session_priv_mpool;
11170 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11173 TEST_ASSERT(ret == 0,
11174 "Failed to attach device %u of pmd : %s", i,
11175 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11177 aesni_ids[nb_devs_attached] = (uint8_t)i;
11179 nb_devs_attached++;
11186 test_scheduler_detach_slave_op(void)
11188 struct crypto_testsuite_params *ts_params = &testsuite_params;
11189 uint8_t sched_id = ts_params->valid_devs[0];
11193 for (i = 0; i < 2; i++) {
11194 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11196 TEST_ASSERT(ret == 0,
11197 "Failed to detach device %u", aesni_ids[i]);
11204 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11206 struct crypto_testsuite_params *ts_params = &testsuite_params;
11207 uint8_t sched_id = ts_params->valid_devs[0];
11209 return rte_cryptodev_scheduler_mode_set(sched_id,
11214 test_scheduler_mode_roundrobin_op(void)
11216 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11217 0, "Failed to set roundrobin mode");
11223 test_scheduler_mode_multicore_op(void)
11225 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11226 0, "Failed to set multicore mode");
11232 test_scheduler_mode_failover_op(void)
11234 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11235 0, "Failed to set failover mode");
11241 test_scheduler_mode_pkt_size_distr_op(void)
11243 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11244 0, "Failed to set pktsize mode");
11249 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11250 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11251 .setup = testsuite_setup,
11252 .teardown = testsuite_teardown,
11253 .unit_test_cases = {
11255 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11256 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11257 TEST_CASE_ST(ut_setup, ut_teardown,
11258 test_AES_chain_scheduler_all),
11259 TEST_CASE_ST(ut_setup, ut_teardown,
11260 test_AES_cipheronly_scheduler_all),
11261 TEST_CASE_ST(ut_setup, ut_teardown,
11262 test_authonly_scheduler_all),
11263 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11266 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11267 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11268 TEST_CASE_ST(ut_setup, ut_teardown,
11269 test_AES_chain_scheduler_all),
11270 TEST_CASE_ST(ut_setup, ut_teardown,
11271 test_AES_cipheronly_scheduler_all),
11272 TEST_CASE_ST(ut_setup, ut_teardown,
11273 test_authonly_scheduler_all),
11274 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11277 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11278 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11279 TEST_CASE_ST(ut_setup, ut_teardown,
11280 test_AES_chain_scheduler_all),
11281 TEST_CASE_ST(ut_setup, ut_teardown,
11282 test_AES_cipheronly_scheduler_all),
11283 TEST_CASE_ST(ut_setup, ut_teardown,
11284 test_authonly_scheduler_all),
11285 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11288 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11289 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11290 TEST_CASE_ST(ut_setup, ut_teardown,
11291 test_AES_chain_scheduler_all),
11292 TEST_CASE_ST(ut_setup, ut_teardown,
11293 test_AES_cipheronly_scheduler_all),
11294 TEST_CASE_ST(ut_setup, ut_teardown,
11295 test_authonly_scheduler_all),
11296 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11298 TEST_CASES_END() /**< NULL terminate unit test array */
11302 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11304 static struct unit_test_suite cryptodev_qat_testsuite = {
11305 .suite_name = "Crypto QAT Unit Test Suite",
11306 .setup = testsuite_setup,
11307 .teardown = testsuite_teardown,
11308 .unit_test_cases = {
11309 TEST_CASE_ST(ut_setup, ut_teardown,
11310 test_device_configure_invalid_dev_id),
11311 TEST_CASE_ST(ut_setup, ut_teardown,
11312 test_device_configure_invalid_queue_pair_ids),
11313 TEST_CASE_ST(ut_setup, ut_teardown,
11314 test_queue_pair_descriptor_setup),
11315 TEST_CASE_ST(ut_setup, ut_teardown,
11316 test_multi_session),
11318 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11319 TEST_CASE_ST(ut_setup, ut_teardown,
11320 test_AES_cipheronly_qat_all),
11321 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11322 TEST_CASE_ST(ut_setup, ut_teardown,
11323 test_3DES_cipheronly_qat_all),
11324 TEST_CASE_ST(ut_setup, ut_teardown,
11325 test_DES_cipheronly_qat_all),
11326 TEST_CASE_ST(ut_setup, ut_teardown,
11327 test_AES_docsis_qat_all),
11328 TEST_CASE_ST(ut_setup, ut_teardown,
11329 test_DES_docsis_qat_all),
11330 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11331 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11333 /** AES CCM Authenticated Encryption 128 bits key */
11334 TEST_CASE_ST(ut_setup, ut_teardown,
11335 test_AES_CCM_authenticated_encryption_test_case_128_1),
11336 TEST_CASE_ST(ut_setup, ut_teardown,
11337 test_AES_CCM_authenticated_encryption_test_case_128_2),
11338 TEST_CASE_ST(ut_setup, ut_teardown,
11339 test_AES_CCM_authenticated_encryption_test_case_128_3),
11341 /** AES CCM Authenticated Decryption 128 bits key*/
11342 TEST_CASE_ST(ut_setup, ut_teardown,
11343 test_AES_CCM_authenticated_decryption_test_case_128_1),
11344 TEST_CASE_ST(ut_setup, ut_teardown,
11345 test_AES_CCM_authenticated_decryption_test_case_128_2),
11346 TEST_CASE_ST(ut_setup, ut_teardown,
11347 test_AES_CCM_authenticated_decryption_test_case_128_3),
11349 /** AES GCM Authenticated Encryption */
11350 TEST_CASE_ST(ut_setup, ut_teardown,
11351 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11352 TEST_CASE_ST(ut_setup, ut_teardown,
11353 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11354 TEST_CASE_ST(ut_setup, ut_teardown,
11355 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11356 TEST_CASE_ST(ut_setup, ut_teardown,
11357 test_AES_GCM_authenticated_encryption_test_case_1),
11358 TEST_CASE_ST(ut_setup, ut_teardown,
11359 test_AES_GCM_authenticated_encryption_test_case_2),
11360 TEST_CASE_ST(ut_setup, ut_teardown,
11361 test_AES_GCM_authenticated_encryption_test_case_3),
11362 TEST_CASE_ST(ut_setup, ut_teardown,
11363 test_AES_GCM_authenticated_encryption_test_case_4),
11364 TEST_CASE_ST(ut_setup, ut_teardown,
11365 test_AES_GCM_authenticated_encryption_test_case_5),
11366 TEST_CASE_ST(ut_setup, ut_teardown,
11367 test_AES_GCM_authenticated_encryption_test_case_6),
11368 TEST_CASE_ST(ut_setup, ut_teardown,
11369 test_AES_GCM_authenticated_encryption_test_case_7),
11370 TEST_CASE_ST(ut_setup, ut_teardown,
11371 test_AES_GCM_authenticated_encryption_test_case_8),
11373 /** AES GCM Authenticated Decryption */
11374 TEST_CASE_ST(ut_setup, ut_teardown,
11375 test_AES_GCM_authenticated_decryption_test_case_1),
11376 TEST_CASE_ST(ut_setup, ut_teardown,
11377 test_AES_GCM_authenticated_decryption_test_case_2),
11378 TEST_CASE_ST(ut_setup, ut_teardown,
11379 test_AES_GCM_authenticated_decryption_test_case_3),
11380 TEST_CASE_ST(ut_setup, ut_teardown,
11381 test_AES_GCM_authenticated_decryption_test_case_4),
11382 TEST_CASE_ST(ut_setup, ut_teardown,
11383 test_AES_GCM_authenticated_decryption_test_case_5),
11384 TEST_CASE_ST(ut_setup, ut_teardown,
11385 test_AES_GCM_authenticated_decryption_test_case_6),
11386 TEST_CASE_ST(ut_setup, ut_teardown,
11387 test_AES_GCM_authenticated_decryption_test_case_7),
11388 TEST_CASE_ST(ut_setup, ut_teardown,
11389 test_AES_GCM_authenticated_decryption_test_case_8),
11391 /** AES GCM Authenticated Encryption 192 bits key */
11392 TEST_CASE_ST(ut_setup, ut_teardown,
11393 test_AES_GCM_auth_encryption_test_case_192_1),
11394 TEST_CASE_ST(ut_setup, ut_teardown,
11395 test_AES_GCM_auth_encryption_test_case_192_2),
11396 TEST_CASE_ST(ut_setup, ut_teardown,
11397 test_AES_GCM_auth_encryption_test_case_192_3),
11398 TEST_CASE_ST(ut_setup, ut_teardown,
11399 test_AES_GCM_auth_encryption_test_case_192_4),
11400 TEST_CASE_ST(ut_setup, ut_teardown,
11401 test_AES_GCM_auth_encryption_test_case_192_5),
11402 TEST_CASE_ST(ut_setup, ut_teardown,
11403 test_AES_GCM_auth_encryption_test_case_192_6),
11404 TEST_CASE_ST(ut_setup, ut_teardown,
11405 test_AES_GCM_auth_encryption_test_case_192_7),
11407 /** AES GCM Authenticated Decryption 192 bits key */
11408 TEST_CASE_ST(ut_setup, ut_teardown,
11409 test_AES_GCM_auth_decryption_test_case_192_1),
11410 TEST_CASE_ST(ut_setup, ut_teardown,
11411 test_AES_GCM_auth_decryption_test_case_192_2),
11412 TEST_CASE_ST(ut_setup, ut_teardown,
11413 test_AES_GCM_auth_decryption_test_case_192_3),
11414 TEST_CASE_ST(ut_setup, ut_teardown,
11415 test_AES_GCM_auth_decryption_test_case_192_4),
11416 TEST_CASE_ST(ut_setup, ut_teardown,
11417 test_AES_GCM_auth_decryption_test_case_192_5),
11418 TEST_CASE_ST(ut_setup, ut_teardown,
11419 test_AES_GCM_auth_decryption_test_case_192_6),
11420 TEST_CASE_ST(ut_setup, ut_teardown,
11421 test_AES_GCM_auth_decryption_test_case_192_7),
11423 /** AES GCM Authenticated Encryption 256 bits key */
11424 TEST_CASE_ST(ut_setup, ut_teardown,
11425 test_AES_GCM_auth_encryption_test_case_256_1),
11426 TEST_CASE_ST(ut_setup, ut_teardown,
11427 test_AES_GCM_auth_encryption_test_case_256_2),
11428 TEST_CASE_ST(ut_setup, ut_teardown,
11429 test_AES_GCM_auth_encryption_test_case_256_3),
11430 TEST_CASE_ST(ut_setup, ut_teardown,
11431 test_AES_GCM_auth_encryption_test_case_256_4),
11432 TEST_CASE_ST(ut_setup, ut_teardown,
11433 test_AES_GCM_auth_encryption_test_case_256_5),
11434 TEST_CASE_ST(ut_setup, ut_teardown,
11435 test_AES_GCM_auth_encryption_test_case_256_6),
11436 TEST_CASE_ST(ut_setup, ut_teardown,
11437 test_AES_GCM_auth_encryption_test_case_256_7),
11439 /** AES GCM Authenticated Decryption 256 bits key */
11440 TEST_CASE_ST(ut_setup, ut_teardown,
11441 test_AES_GCM_auth_decryption_test_case_256_1),
11442 TEST_CASE_ST(ut_setup, ut_teardown,
11443 test_AES_GCM_auth_decryption_test_case_256_2),
11444 TEST_CASE_ST(ut_setup, ut_teardown,
11445 test_AES_GCM_auth_decryption_test_case_256_3),
11446 TEST_CASE_ST(ut_setup, ut_teardown,
11447 test_AES_GCM_auth_decryption_test_case_256_4),
11448 TEST_CASE_ST(ut_setup, ut_teardown,
11449 test_AES_GCM_auth_decryption_test_case_256_5),
11450 TEST_CASE_ST(ut_setup, ut_teardown,
11451 test_AES_GCM_auth_decryption_test_case_256_6),
11452 TEST_CASE_ST(ut_setup, ut_teardown,
11453 test_AES_GCM_auth_decryption_test_case_256_7),
11455 /** AES GMAC Authentication */
11456 TEST_CASE_ST(ut_setup, ut_teardown,
11457 test_AES_GMAC_authentication_test_case_1),
11458 TEST_CASE_ST(ut_setup, ut_teardown,
11459 test_AES_GMAC_authentication_verify_test_case_1),
11460 TEST_CASE_ST(ut_setup, ut_teardown,
11461 test_AES_GMAC_authentication_test_case_2),
11462 TEST_CASE_ST(ut_setup, ut_teardown,
11463 test_AES_GMAC_authentication_verify_test_case_2),
11464 TEST_CASE_ST(ut_setup, ut_teardown,
11465 test_AES_GMAC_authentication_test_case_3),
11466 TEST_CASE_ST(ut_setup, ut_teardown,
11467 test_AES_GMAC_authentication_verify_test_case_3),
11469 /** SNOW 3G encrypt only (UEA2) */
11470 TEST_CASE_ST(ut_setup, ut_teardown,
11471 test_snow3g_encryption_test_case_1),
11472 TEST_CASE_ST(ut_setup, ut_teardown,
11473 test_snow3g_encryption_test_case_2),
11474 TEST_CASE_ST(ut_setup, ut_teardown,
11475 test_snow3g_encryption_test_case_3),
11476 TEST_CASE_ST(ut_setup, ut_teardown,
11477 test_snow3g_encryption_test_case_4),
11478 TEST_CASE_ST(ut_setup, ut_teardown,
11479 test_snow3g_encryption_test_case_5),
11481 TEST_CASE_ST(ut_setup, ut_teardown,
11482 test_snow3g_encryption_test_case_1_oop),
11483 TEST_CASE_ST(ut_setup, ut_teardown,
11484 test_snow3g_decryption_test_case_1_oop),
11486 /** SNOW 3G generate auth, then encrypt (UEA2) */
11487 TEST_CASE_ST(ut_setup, ut_teardown,
11488 test_snow3g_auth_cipher_test_case_1),
11489 TEST_CASE_ST(ut_setup, ut_teardown,
11490 test_snow3g_auth_cipher_test_case_2),
11491 TEST_CASE_ST(ut_setup, ut_teardown,
11492 test_snow3g_auth_cipher_test_case_2_oop),
11493 TEST_CASE_ST(ut_setup, ut_teardown,
11494 test_snow3g_auth_cipher_part_digest_enc),
11495 TEST_CASE_ST(ut_setup, ut_teardown,
11496 test_snow3g_auth_cipher_part_digest_enc_oop),
11497 TEST_CASE_ST(ut_setup, ut_teardown,
11498 test_snow3g_auth_cipher_test_case_3_sgl),
11499 TEST_CASE_ST(ut_setup, ut_teardown,
11500 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11501 TEST_CASE_ST(ut_setup, ut_teardown,
11502 test_snow3g_auth_cipher_part_digest_enc_sgl),
11503 TEST_CASE_ST(ut_setup, ut_teardown,
11504 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11506 /** SNOW 3G decrypt (UEA2), then verify auth */
11507 TEST_CASE_ST(ut_setup, ut_teardown,
11508 test_snow3g_auth_cipher_verify_test_case_1),
11509 TEST_CASE_ST(ut_setup, ut_teardown,
11510 test_snow3g_auth_cipher_verify_test_case_2),
11511 TEST_CASE_ST(ut_setup, ut_teardown,
11512 test_snow3g_auth_cipher_verify_test_case_2_oop),
11513 TEST_CASE_ST(ut_setup, ut_teardown,
11514 test_snow3g_auth_cipher_verify_part_digest_enc),
11515 TEST_CASE_ST(ut_setup, ut_teardown,
11516 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11517 TEST_CASE_ST(ut_setup, ut_teardown,
11518 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11519 TEST_CASE_ST(ut_setup, ut_teardown,
11520 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11521 TEST_CASE_ST(ut_setup, ut_teardown,
11522 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11523 TEST_CASE_ST(ut_setup, ut_teardown,
11524 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11526 /** SNOW 3G decrypt only (UEA2) */
11527 TEST_CASE_ST(ut_setup, ut_teardown,
11528 test_snow3g_decryption_test_case_1),
11529 TEST_CASE_ST(ut_setup, ut_teardown,
11530 test_snow3g_decryption_test_case_2),
11531 TEST_CASE_ST(ut_setup, ut_teardown,
11532 test_snow3g_decryption_test_case_3),
11533 TEST_CASE_ST(ut_setup, ut_teardown,
11534 test_snow3g_decryption_test_case_4),
11535 TEST_CASE_ST(ut_setup, ut_teardown,
11536 test_snow3g_decryption_test_case_5),
11537 TEST_CASE_ST(ut_setup, ut_teardown,
11538 test_snow3g_decryption_with_digest_test_case_1),
11539 TEST_CASE_ST(ut_setup, ut_teardown,
11540 test_snow3g_hash_generate_test_case_1),
11541 TEST_CASE_ST(ut_setup, ut_teardown,
11542 test_snow3g_hash_generate_test_case_2),
11543 TEST_CASE_ST(ut_setup, ut_teardown,
11544 test_snow3g_hash_generate_test_case_3),
11545 TEST_CASE_ST(ut_setup, ut_teardown,
11546 test_snow3g_hash_verify_test_case_1),
11547 TEST_CASE_ST(ut_setup, ut_teardown,
11548 test_snow3g_hash_verify_test_case_2),
11549 TEST_CASE_ST(ut_setup, ut_teardown,
11550 test_snow3g_hash_verify_test_case_3),
11551 TEST_CASE_ST(ut_setup, ut_teardown,
11552 test_snow3g_cipher_auth_test_case_1),
11553 TEST_CASE_ST(ut_setup, ut_teardown,
11554 test_snow3g_auth_cipher_with_digest_test_case_1),
11556 /** ZUC encrypt only (EEA3) */
11557 TEST_CASE_ST(ut_setup, ut_teardown,
11558 test_zuc_encryption_test_case_1),
11559 TEST_CASE_ST(ut_setup, ut_teardown,
11560 test_zuc_encryption_test_case_2),
11561 TEST_CASE_ST(ut_setup, ut_teardown,
11562 test_zuc_encryption_test_case_3),
11563 TEST_CASE_ST(ut_setup, ut_teardown,
11564 test_zuc_encryption_test_case_4),
11565 TEST_CASE_ST(ut_setup, ut_teardown,
11566 test_zuc_encryption_test_case_5),
11568 /** ZUC authenticate (EIA3) */
11569 TEST_CASE_ST(ut_setup, ut_teardown,
11570 test_zuc_hash_generate_test_case_6),
11571 TEST_CASE_ST(ut_setup, ut_teardown,
11572 test_zuc_hash_generate_test_case_7),
11573 TEST_CASE_ST(ut_setup, ut_teardown,
11574 test_zuc_hash_generate_test_case_8),
11576 /** ZUC alg-chain (EEA3/EIA3) */
11577 TEST_CASE_ST(ut_setup, ut_teardown,
11578 test_zuc_cipher_auth_test_case_1),
11579 TEST_CASE_ST(ut_setup, ut_teardown,
11580 test_zuc_cipher_auth_test_case_2),
11582 /** ZUC generate auth, then encrypt (EEA3) */
11583 TEST_CASE_ST(ut_setup, ut_teardown,
11584 test_zuc_auth_cipher_test_case_1),
11585 TEST_CASE_ST(ut_setup, ut_teardown,
11586 test_zuc_auth_cipher_test_case_1_oop),
11587 TEST_CASE_ST(ut_setup, ut_teardown,
11588 test_zuc_auth_cipher_test_case_1_sgl),
11589 TEST_CASE_ST(ut_setup, ut_teardown,
11590 test_zuc_auth_cipher_test_case_1_oop_sgl),
11592 /** ZUC decrypt (EEA3), then verify auth */
11593 TEST_CASE_ST(ut_setup, ut_teardown,
11594 test_zuc_auth_cipher_verify_test_case_1),
11595 TEST_CASE_ST(ut_setup, ut_teardown,
11596 test_zuc_auth_cipher_verify_test_case_1_oop),
11597 TEST_CASE_ST(ut_setup, ut_teardown,
11598 test_zuc_auth_cipher_verify_test_case_1_sgl),
11599 TEST_CASE_ST(ut_setup, ut_teardown,
11600 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
11602 /** HMAC_MD5 Authentication */
11603 TEST_CASE_ST(ut_setup, ut_teardown,
11604 test_MD5_HMAC_generate_case_1),
11605 TEST_CASE_ST(ut_setup, ut_teardown,
11606 test_MD5_HMAC_verify_case_1),
11607 TEST_CASE_ST(ut_setup, ut_teardown,
11608 test_MD5_HMAC_generate_case_2),
11609 TEST_CASE_ST(ut_setup, ut_teardown,
11610 test_MD5_HMAC_verify_case_2),
11612 /** NULL algo tests done in chain_all,
11613 * cipheronly and authonly suites
11616 /** KASUMI tests */
11617 TEST_CASE_ST(ut_setup, ut_teardown,
11618 test_kasumi_hash_generate_test_case_1),
11619 TEST_CASE_ST(ut_setup, ut_teardown,
11620 test_kasumi_hash_generate_test_case_2),
11621 TEST_CASE_ST(ut_setup, ut_teardown,
11622 test_kasumi_hash_generate_test_case_3),
11623 TEST_CASE_ST(ut_setup, ut_teardown,
11624 test_kasumi_hash_generate_test_case_4),
11625 TEST_CASE_ST(ut_setup, ut_teardown,
11626 test_kasumi_hash_generate_test_case_5),
11627 TEST_CASE_ST(ut_setup, ut_teardown,
11628 test_kasumi_hash_generate_test_case_6),
11630 TEST_CASE_ST(ut_setup, ut_teardown,
11631 test_kasumi_hash_verify_test_case_1),
11632 TEST_CASE_ST(ut_setup, ut_teardown,
11633 test_kasumi_hash_verify_test_case_2),
11634 TEST_CASE_ST(ut_setup, ut_teardown,
11635 test_kasumi_hash_verify_test_case_3),
11636 TEST_CASE_ST(ut_setup, ut_teardown,
11637 test_kasumi_hash_verify_test_case_4),
11638 TEST_CASE_ST(ut_setup, ut_teardown,
11639 test_kasumi_hash_verify_test_case_5),
11641 TEST_CASE_ST(ut_setup, ut_teardown,
11642 test_kasumi_encryption_test_case_1),
11643 TEST_CASE_ST(ut_setup, ut_teardown,
11644 test_kasumi_encryption_test_case_3),
11645 TEST_CASE_ST(ut_setup, ut_teardown,
11646 test_kasumi_cipher_auth_test_case_1),
11648 /** KASUMI generate auth, then encrypt (F8) */
11649 TEST_CASE_ST(ut_setup, ut_teardown,
11650 test_kasumi_auth_cipher_test_case_1),
11651 TEST_CASE_ST(ut_setup, ut_teardown,
11652 test_kasumi_auth_cipher_test_case_2),
11653 TEST_CASE_ST(ut_setup, ut_teardown,
11654 test_kasumi_auth_cipher_test_case_2_oop),
11655 TEST_CASE_ST(ut_setup, ut_teardown,
11656 test_kasumi_auth_cipher_test_case_2_sgl),
11657 TEST_CASE_ST(ut_setup, ut_teardown,
11658 test_kasumi_auth_cipher_test_case_2_oop_sgl),
11660 /** KASUMI decrypt (F8), then verify auth */
11661 TEST_CASE_ST(ut_setup, ut_teardown,
11662 test_kasumi_auth_cipher_verify_test_case_1),
11663 TEST_CASE_ST(ut_setup, ut_teardown,
11664 test_kasumi_auth_cipher_verify_test_case_2),
11665 TEST_CASE_ST(ut_setup, ut_teardown,
11666 test_kasumi_auth_cipher_verify_test_case_2_oop),
11667 TEST_CASE_ST(ut_setup, ut_teardown,
11668 test_kasumi_auth_cipher_verify_test_case_2_sgl),
11669 TEST_CASE_ST(ut_setup, ut_teardown,
11670 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11672 /** Negative tests */
11673 TEST_CASE_ST(ut_setup, ut_teardown,
11674 authentication_verify_HMAC_SHA1_fail_data_corrupt),
11675 TEST_CASE_ST(ut_setup, ut_teardown,
11676 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11677 TEST_CASE_ST(ut_setup, ut_teardown,
11678 test_AES_GCM_auth_encryption_fail_iv_corrupt),
11679 TEST_CASE_ST(ut_setup, ut_teardown,
11680 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
11681 TEST_CASE_ST(ut_setup, ut_teardown,
11682 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
11683 TEST_CASE_ST(ut_setup, ut_teardown,
11684 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
11685 TEST_CASE_ST(ut_setup, ut_teardown,
11686 test_AES_GCM_auth_encryption_fail_aad_corrupt),
11687 TEST_CASE_ST(ut_setup, ut_teardown,
11688 test_AES_GCM_auth_encryption_fail_tag_corrupt),
11689 TEST_CASE_ST(ut_setup, ut_teardown,
11690 test_AES_GCM_auth_decryption_fail_iv_corrupt),
11691 TEST_CASE_ST(ut_setup, ut_teardown,
11692 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
11693 TEST_CASE_ST(ut_setup, ut_teardown,
11694 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
11695 TEST_CASE_ST(ut_setup, ut_teardown,
11696 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
11697 TEST_CASE_ST(ut_setup, ut_teardown,
11698 test_AES_GCM_auth_decryption_fail_aad_corrupt),
11699 TEST_CASE_ST(ut_setup, ut_teardown,
11700 test_AES_GCM_auth_decryption_fail_tag_corrupt),
11701 TEST_CASE_ST(ut_setup, ut_teardown,
11702 authentication_verify_AES128_GMAC_fail_data_corrupt),
11703 TEST_CASE_ST(ut_setup, ut_teardown,
11704 authentication_verify_AES128_GMAC_fail_tag_corrupt),
11705 TEST_CASE_ST(ut_setup, ut_teardown,
11706 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11707 TEST_CASE_ST(ut_setup, ut_teardown,
11708 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11710 TEST_CASES_END() /**< NULL terminate unit test array */
11714 static struct unit_test_suite cryptodev_virtio_testsuite = {
11715 .suite_name = "Crypto VIRTIO Unit Test Suite",
11716 .setup = testsuite_setup,
11717 .teardown = testsuite_teardown,
11718 .unit_test_cases = {
11719 TEST_CASE_ST(ut_setup, ut_teardown,
11720 test_AES_cipheronly_virtio_all),
11722 TEST_CASES_END() /**< NULL terminate unit test array */
11726 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
11727 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
11728 .setup = testsuite_setup,
11729 .teardown = testsuite_teardown,
11730 .unit_test_cases = {
11731 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
11732 TEST_CASE_ST(ut_setup, ut_teardown,
11733 test_AES_GCM_authenticated_encryption_test_case_1),
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 test_AES_GCM_authenticated_encryption_test_case_2),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_AES_GCM_authenticated_encryption_test_case_3),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_AES_GCM_authenticated_encryption_test_case_4),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_AES_GCM_authenticated_encryption_test_case_5),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 test_AES_GCM_authenticated_encryption_test_case_6),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_AES_GCM_authenticated_encryption_test_case_7),
11747 /** AES GCM Authenticated Decryption */
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_AES_GCM_authenticated_decryption_test_case_1),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_AES_GCM_authenticated_decryption_test_case_2),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_AES_GCM_authenticated_decryption_test_case_3),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_AES_GCM_authenticated_decryption_test_case_4),
11756 TEST_CASE_ST(ut_setup, ut_teardown,
11757 test_AES_GCM_authenticated_decryption_test_case_5),
11758 TEST_CASE_ST(ut_setup, ut_teardown,
11759 test_AES_GCM_authenticated_decryption_test_case_6),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_AES_GCM_authenticated_decryption_test_case_7),
11763 /** AES GCM Authenticated Encryption 192 bits key */
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_GCM_auth_encryption_test_case_192_1),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_GCM_auth_encryption_test_case_192_2),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_AES_GCM_auth_encryption_test_case_192_3),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_GCM_auth_encryption_test_case_192_4),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_GCM_auth_encryption_test_case_192_5),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_auth_encryption_test_case_192_6),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_GCM_auth_encryption_test_case_192_7),
11779 /** AES GCM Authenticated Decryption 192 bits key */
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_auth_decryption_test_case_192_1),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_auth_decryption_test_case_192_2),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_GCM_auth_decryption_test_case_192_3),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_auth_decryption_test_case_192_4),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_GCM_auth_decryption_test_case_192_5),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_GCM_auth_decryption_test_case_192_6),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_GCM_auth_decryption_test_case_192_7),
11795 /** AES GCM Authenticated Encryption 256 bits key */
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_GCM_auth_encryption_test_case_256_1),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_GCM_auth_encryption_test_case_256_2),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_AES_GCM_auth_encryption_test_case_256_3),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_AES_GCM_auth_encryption_test_case_256_4),
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_GCM_auth_encryption_test_case_256_5),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_GCM_auth_encryption_test_case_256_6),
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_AES_GCM_auth_encryption_test_case_256_7),
11811 /** AES GCM Authenticated Decryption 256 bits key */
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GCM_auth_decryption_test_case_256_1),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_GCM_auth_decryption_test_case_256_2),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GCM_auth_decryption_test_case_256_3),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GCM_auth_decryption_test_case_256_4),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_GCM_auth_decryption_test_case_256_5),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_GCM_auth_decryption_test_case_256_6),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_AES_GCM_auth_decryption_test_case_256_7),
11827 /** AES GCM Authenticated Encryption big aad size */
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_auth_encryption_test_case_aad_1),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_GCM_auth_encryption_test_case_aad_2),
11833 /** AES GCM Authenticated Decryption big aad size */
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_auth_decryption_test_case_aad_1),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_GCM_auth_decryption_test_case_aad_2),
11839 /** Session-less tests */
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11845 /** AES GMAC Authentication */
11846 TEST_CASE_ST(ut_setup, ut_teardown,
11847 test_AES_GMAC_authentication_test_case_1),
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GMAC_authentication_verify_test_case_1),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GMAC_authentication_test_case_2),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_GMAC_authentication_verify_test_case_2),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_GMAC_authentication_test_case_3),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_AES_GMAC_authentication_verify_test_case_3),
11858 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
11860 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
11861 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
11862 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
11863 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_DES_cipheronly_mb_all),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_DES_docsis_mb_all),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_3DES_cipheronly_mb_all),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_CCM_authenticated_encryption_test_case_128_1),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_AES_CCM_authenticated_decryption_test_case_128_1),
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_AES_CCM_authenticated_encryption_test_case_128_2),
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_CCM_authenticated_decryption_test_case_128_2),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_CCM_authenticated_encryption_test_case_128_3),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_AES_CCM_authenticated_decryption_test_case_128_3),
11883 TEST_CASES_END() /**< NULL terminate unit test array */
11887 static struct unit_test_suite cryptodev_openssl_testsuite = {
11888 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
11889 .setup = testsuite_setup,
11890 .teardown = testsuite_teardown,
11891 .unit_test_cases = {
11892 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_multi_session_random_usage),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_chain_openssl_all),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_cipheronly_openssl_all),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_3DES_chain_openssl_all),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_3DES_cipheronly_openssl_all),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_DES_cipheronly_openssl_all),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_DES_docsis_openssl_all),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_authonly_openssl_all),
11910 /** AES GCM Authenticated Encryption */
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_authenticated_encryption_test_case_1),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_authenticated_encryption_test_case_2),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_authenticated_encryption_test_case_3),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_authenticated_encryption_test_case_4),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_authenticated_encryption_test_case_5),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_authenticated_encryption_test_case_6),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_authenticated_encryption_test_case_7),
11926 /** AES GCM Authenticated Decryption */
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_authenticated_decryption_test_case_1),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_authenticated_decryption_test_case_2),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_authenticated_decryption_test_case_3),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_authenticated_decryption_test_case_4),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_authenticated_decryption_test_case_5),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_authenticated_decryption_test_case_6),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_authenticated_decryption_test_case_7),
11943 /** AES GCM Authenticated Encryption 192 bits key */
11944 TEST_CASE_ST(ut_setup, ut_teardown,
11945 test_AES_GCM_auth_encryption_test_case_192_1),
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_AES_GCM_auth_encryption_test_case_192_2),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GCM_auth_encryption_test_case_192_3),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_GCM_auth_encryption_test_case_192_4),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_GCM_auth_encryption_test_case_192_5),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GCM_auth_encryption_test_case_192_6),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_GCM_auth_encryption_test_case_192_7),
11959 /** AES GCM Authenticated Decryption 192 bits key */
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_GCM_auth_decryption_test_case_192_1),
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 test_AES_GCM_auth_decryption_test_case_192_2),
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_AES_GCM_auth_decryption_test_case_192_3),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_AES_GCM_auth_decryption_test_case_192_4),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_AES_GCM_auth_decryption_test_case_192_5),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_AES_GCM_auth_decryption_test_case_192_6),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_AES_GCM_auth_decryption_test_case_192_7),
11975 /** AES GCM Authenticated Encryption 256 bits key */
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_AES_GCM_auth_encryption_test_case_256_1),
11978 TEST_CASE_ST(ut_setup, ut_teardown,
11979 test_AES_GCM_auth_encryption_test_case_256_2),
11980 TEST_CASE_ST(ut_setup, ut_teardown,
11981 test_AES_GCM_auth_encryption_test_case_256_3),
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_AES_GCM_auth_encryption_test_case_256_4),
11984 TEST_CASE_ST(ut_setup, ut_teardown,
11985 test_AES_GCM_auth_encryption_test_case_256_5),
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_AES_GCM_auth_encryption_test_case_256_6),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_AES_GCM_auth_encryption_test_case_256_7),
11991 /** AES GCM Authenticated Decryption 256 bits key */
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_AES_GCM_auth_decryption_test_case_256_1),
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_AES_GCM_auth_decryption_test_case_256_2),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_AES_GCM_auth_decryption_test_case_256_3),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_AES_GCM_auth_decryption_test_case_256_4),
12000 TEST_CASE_ST(ut_setup, ut_teardown,
12001 test_AES_GCM_auth_decryption_test_case_256_5),
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_AES_GCM_auth_decryption_test_case_256_6),
12004 TEST_CASE_ST(ut_setup, ut_teardown,
12005 test_AES_GCM_auth_decryption_test_case_256_7),
12007 /** AES GMAC Authentication */
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_AES_GMAC_authentication_test_case_1),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_AES_GMAC_authentication_verify_test_case_1),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_AES_GMAC_authentication_test_case_2),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_AES_GMAC_authentication_verify_test_case_2),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_AES_GMAC_authentication_test_case_3),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_AES_GMAC_authentication_verify_test_case_3),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_AES_GMAC_authentication_test_case_4),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_AES_GMAC_authentication_verify_test_case_4),
12025 /** AES CCM Authenticated Encryption 128 bits key */
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_AES_CCM_authenticated_encryption_test_case_128_1),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_AES_CCM_authenticated_encryption_test_case_128_2),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_AES_CCM_authenticated_encryption_test_case_128_3),
12033 /** AES CCM Authenticated Decryption 128 bits key*/
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_AES_CCM_authenticated_decryption_test_case_128_1),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_AES_CCM_authenticated_decryption_test_case_128_2),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_AES_CCM_authenticated_decryption_test_case_128_3),
12041 /** AES CCM Authenticated Encryption 192 bits key */
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_AES_CCM_authenticated_encryption_test_case_192_1),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_AES_CCM_authenticated_encryption_test_case_192_2),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_AES_CCM_authenticated_encryption_test_case_192_3),
12049 /** AES CCM Authenticated Decryption 192 bits key*/
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_AES_CCM_authenticated_decryption_test_case_192_1),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_AES_CCM_authenticated_decryption_test_case_192_2),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_AES_CCM_authenticated_decryption_test_case_192_3),
12057 /** AES CCM Authenticated Encryption 256 bits key */
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_AES_CCM_authenticated_encryption_test_case_256_1),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_AES_CCM_authenticated_encryption_test_case_256_2),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_AES_CCM_authenticated_encryption_test_case_256_3),
12065 /** AES CCM Authenticated Decryption 256 bits key*/
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_AES_CCM_authenticated_decryption_test_case_256_1),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_AES_CCM_authenticated_decryption_test_case_256_2),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_AES_CCM_authenticated_decryption_test_case_256_3),
12073 /** Scatter-Gather */
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12077 /** Negative tests */
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 authentication_verify_AES128_GMAC_fail_data_corrupt),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12098 TEST_CASES_END() /**< NULL terminate unit test array */
12102 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12103 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12104 .setup = testsuite_setup,
12105 .teardown = testsuite_teardown,
12106 .unit_test_cases = {
12107 /** AES GCM Authenticated Encryption */
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_AES_GCM_authenticated_encryption_test_case_1),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_AES_GCM_authenticated_encryption_test_case_2),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_AES_GCM_authenticated_encryption_test_case_3),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_AES_GCM_authenticated_encryption_test_case_4),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_AES_GCM_authenticated_encryption_test_case_5),
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_AES_GCM_authenticated_encryption_test_case_6),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_AES_GCM_authenticated_encryption_test_case_7),
12123 /** AES GCM Authenticated Decryption */
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_AES_GCM_authenticated_decryption_test_case_1),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_AES_GCM_authenticated_decryption_test_case_2),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_AES_GCM_authenticated_decryption_test_case_3),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_AES_GCM_authenticated_decryption_test_case_4),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_AES_GCM_authenticated_decryption_test_case_5),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_AES_GCM_authenticated_decryption_test_case_6),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_AES_GCM_authenticated_decryption_test_case_7),
12139 /** AES GCM Authenticated Encryption 192 bits key */
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_AES_GCM_auth_encryption_test_case_192_1),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_AES_GCM_auth_encryption_test_case_192_2),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_AES_GCM_auth_encryption_test_case_192_3),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_AES_GCM_auth_encryption_test_case_192_4),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_AES_GCM_auth_encryption_test_case_192_5),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_AES_GCM_auth_encryption_test_case_192_6),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_AES_GCM_auth_encryption_test_case_192_7),
12155 /** AES GCM Authenticated Decryption 192 bits key */
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_AES_GCM_auth_decryption_test_case_192_1),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_AES_GCM_auth_decryption_test_case_192_2),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_AES_GCM_auth_decryption_test_case_192_3),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_AES_GCM_auth_decryption_test_case_192_4),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_AES_GCM_auth_decryption_test_case_192_5),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_AES_GCM_auth_decryption_test_case_192_6),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_AES_GCM_auth_decryption_test_case_192_7),
12171 /** AES GCM Authenticated Encryption 256 bits key */
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_AES_GCM_auth_encryption_test_case_256_1),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_AES_GCM_auth_encryption_test_case_256_2),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_AES_GCM_auth_encryption_test_case_256_3),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_AES_GCM_auth_encryption_test_case_256_4),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_AES_GCM_auth_encryption_test_case_256_5),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_AES_GCM_auth_encryption_test_case_256_6),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_AES_GCM_auth_encryption_test_case_256_7),
12187 /** AES GCM Authenticated Decryption 256 bits key */
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_AES_GCM_auth_decryption_test_case_256_1),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_AES_GCM_auth_decryption_test_case_256_2),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_AES_GCM_auth_decryption_test_case_256_3),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_AES_GCM_auth_decryption_test_case_256_4),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_AES_GCM_auth_decryption_test_case_256_5),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_AES_GCM_auth_decryption_test_case_256_6),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_AES_GCM_auth_decryption_test_case_256_7),
12203 /** AES GCM Authenticated Encryption big aad size */
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_AES_GCM_auth_encryption_test_case_aad_1),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_AES_GCM_auth_encryption_test_case_aad_2),
12209 /** AES GCM Authenticated Decryption big aad size */
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_AES_GCM_auth_decryption_test_case_aad_1),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_AES_GCM_auth_decryption_test_case_aad_2),
12215 /** AES GMAC Authentication */
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_AES_GMAC_authentication_test_case_1),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_AES_GMAC_authentication_verify_test_case_1),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_AES_GMAC_authentication_test_case_3),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_AES_GMAC_authentication_verify_test_case_3),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_AES_GMAC_authentication_test_case_4),
12226 TEST_CASE_ST(ut_setup, ut_teardown,
12227 test_AES_GMAC_authentication_verify_test_case_4),
12229 /** Negative tests */
12230 TEST_CASE_ST(ut_setup, ut_teardown,
12231 authentication_verify_AES128_GMAC_fail_data_corrupt),
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12235 /** Out of place tests */
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12241 /** Session-less tests */
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12247 /** Scatter-Gather */
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12251 TEST_CASES_END() /**< NULL terminate unit test array */
12255 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12256 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12257 .setup = testsuite_setup,
12258 .teardown = testsuite_teardown,
12259 .unit_test_cases = {
12260 /** KASUMI encrypt only (UEA1) */
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_kasumi_encryption_test_case_1),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_kasumi_encryption_test_case_1_sgl),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_kasumi_encryption_test_case_2),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_kasumi_encryption_test_case_3),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_kasumi_encryption_test_case_4),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_kasumi_encryption_test_case_5),
12273 /** KASUMI decrypt only (UEA1) */
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_kasumi_decryption_test_case_1),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_kasumi_decryption_test_case_2),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_kasumi_decryption_test_case_3),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_kasumi_decryption_test_case_4),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_kasumi_decryption_test_case_5),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_kasumi_encryption_test_case_1_oop),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_kasumi_encryption_test_case_1_oop_sgl),
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_kasumi_decryption_test_case_1_oop),
12294 /** KASUMI hash only (UIA1) */
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_kasumi_hash_generate_test_case_1),
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_kasumi_hash_generate_test_case_2),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_kasumi_hash_generate_test_case_3),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_kasumi_hash_generate_test_case_4),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_kasumi_hash_generate_test_case_5),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_kasumi_hash_generate_test_case_6),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_kasumi_hash_verify_test_case_1),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_kasumi_hash_verify_test_case_2),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_kasumi_hash_verify_test_case_3),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_kasumi_hash_verify_test_case_4),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_kasumi_hash_verify_test_case_5),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_kasumi_cipher_auth_test_case_1),
12320 /** KASUMI generate auth, then encrypt (F8) */
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_kasumi_auth_cipher_test_case_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_kasumi_auth_cipher_test_case_2),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_kasumi_auth_cipher_test_case_2_oop),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_kasumi_auth_cipher_test_case_2_sgl),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12332 /** KASUMI decrypt (F8), then verify auth */
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_kasumi_auth_cipher_verify_test_case_1),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_kasumi_auth_cipher_verify_test_case_2),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_kasumi_auth_cipher_verify_test_case_2_oop),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12343 TEST_CASES_END() /**< NULL terminate unit test array */
12346 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12347 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12348 .setup = testsuite_setup,
12349 .teardown = testsuite_teardown,
12350 .unit_test_cases = {
12351 /** SNOW 3G encrypt only (UEA2) */
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_snow3g_encryption_test_case_1),
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_snow3g_encryption_test_case_2),
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_snow3g_encryption_test_case_3),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_snow3g_encryption_test_case_4),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_snow3g_encryption_test_case_5),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_snow3g_auth_cipher_with_digest_test_case_1),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_snow3g_encryption_test_case_1_oop),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_snow3g_encryption_test_case_1_oop_sgl),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_snow3g_decryption_test_case_1_oop),
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_snow3g_encryption_test_case_1_offset_oop),
12375 /** SNOW 3G decrypt only (UEA2) */
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_snow3g_decryption_test_case_1),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 test_snow3g_decryption_test_case_2),
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_snow3g_decryption_test_case_3),
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_snow3g_decryption_test_case_4),
12384 TEST_CASE_ST(ut_setup, ut_teardown,
12385 test_snow3g_decryption_test_case_5),
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_snow3g_decryption_with_digest_test_case_1),
12388 TEST_CASE_ST(ut_setup, ut_teardown,
12389 test_snow3g_hash_generate_test_case_1),
12390 TEST_CASE_ST(ut_setup, ut_teardown,
12391 test_snow3g_hash_generate_test_case_2),
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_snow3g_hash_generate_test_case_3),
12394 /* Tests with buffers which length is not byte-aligned */
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_snow3g_hash_generate_test_case_4),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_snow3g_hash_generate_test_case_5),
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_snow3g_hash_generate_test_case_6),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_snow3g_hash_verify_test_case_1),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_snow3g_hash_verify_test_case_2),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_snow3g_hash_verify_test_case_3),
12407 /* Tests with buffers which length is not byte-aligned */
12408 TEST_CASE_ST(ut_setup, ut_teardown,
12409 test_snow3g_hash_verify_test_case_4),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_snow3g_hash_verify_test_case_5),
12412 TEST_CASE_ST(ut_setup, ut_teardown,
12413 test_snow3g_hash_verify_test_case_6),
12414 TEST_CASE_ST(ut_setup, ut_teardown,
12415 test_snow3g_cipher_auth_test_case_1),
12417 /** SNOW 3G generate auth, then encrypt (UEA2) */
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_snow3g_auth_cipher_test_case_1),
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_snow3g_auth_cipher_test_case_2),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_snow3g_auth_cipher_test_case_2_oop),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_snow3g_auth_cipher_part_digest_enc),
12426 TEST_CASE_ST(ut_setup, ut_teardown,
12427 test_snow3g_auth_cipher_part_digest_enc_oop),
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_snow3g_auth_cipher_test_case_3_sgl),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12432 TEST_CASE_ST(ut_setup, ut_teardown,
12433 test_snow3g_auth_cipher_part_digest_enc_sgl),
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12437 /** SNOW 3G decrypt (UEA2), then verify auth */
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_snow3g_auth_cipher_verify_test_case_1),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_snow3g_auth_cipher_verify_test_case_2),
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_snow3g_auth_cipher_verify_test_case_2_oop),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_snow3g_auth_cipher_verify_part_digest_enc),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12457 TEST_CASES_END() /**< NULL terminate unit test array */
12461 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
12462 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
12463 .setup = testsuite_setup,
12464 .teardown = testsuite_teardown,
12465 .unit_test_cases = {
12466 /** ZUC encrypt only (EEA3) */
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_zuc_encryption_test_case_1),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_zuc_encryption_test_case_2),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_zuc_encryption_test_case_3),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_zuc_encryption_test_case_4),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_zuc_encryption_test_case_5),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_zuc_hash_generate_test_case_1),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_zuc_hash_generate_test_case_2),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_zuc_hash_generate_test_case_3),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_zuc_hash_generate_test_case_4),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_zuc_hash_generate_test_case_5),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_zuc_encryption_test_case_6_sgl),
12489 TEST_CASES_END() /**< NULL terminate unit test array */
12493 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12494 .suite_name = "Crypto CAAM JR Unit Test Suite",
12495 .setup = testsuite_setup,
12496 .teardown = testsuite_teardown,
12497 .unit_test_cases = {
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_device_configure_invalid_dev_id),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_multi_session),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_chain_caam_jr_all),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_3DES_chain_caam_jr_all),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_cipheronly_caam_jr_all),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_3DES_cipheronly_caam_jr_all),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_authonly_caam_jr_all),
12514 TEST_CASES_END() /**< NULL terminate unit test array */
12518 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12519 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12520 .setup = testsuite_setup,
12521 .teardown = testsuite_teardown,
12522 .unit_test_cases = {
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_device_configure_invalid_dev_id),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_multi_session),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_chain_dpaa_sec_all),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_3DES_chain_dpaa_sec_all),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_cipheronly_dpaa_sec_all),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_3DES_cipheronly_dpaa_sec_all),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_authonly_dpaa_sec_all),
12539 #ifdef RTE_LIBRTE_SECURITY
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_PDCP_PROTO_cplane_encap_all),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_PDCP_PROTO_cplane_decap_all),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_PDCP_PROTO_uplane_encap_all),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_PDCP_PROTO_uplane_decap_all),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_PDCP_PROTO_SGL_in_place_32B),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_PDCP_PROTO_SGL_oop_32B_128B),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_PDCP_PROTO_SGL_oop_32B_40B),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_PDCP_PROTO_SGL_oop_128B_32B),
12561 /** AES GCM Authenticated Encryption */
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_AES_GCM_authenticated_encryption_test_case_1),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_AES_GCM_authenticated_encryption_test_case_2),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_AES_GCM_authenticated_encryption_test_case_3),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_AES_GCM_authenticated_encryption_test_case_4),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_AES_GCM_authenticated_encryption_test_case_5),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_AES_GCM_authenticated_encryption_test_case_6),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_AES_GCM_authenticated_encryption_test_case_7),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_AES_GCM_authenticated_encryption_test_case_8),
12587 /** AES GCM Authenticated Decryption */
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_AES_GCM_authenticated_decryption_test_case_1),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_AES_GCM_authenticated_decryption_test_case_2),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_AES_GCM_authenticated_decryption_test_case_3),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_AES_GCM_authenticated_decryption_test_case_4),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_AES_GCM_authenticated_decryption_test_case_5),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_AES_GCM_authenticated_decryption_test_case_6),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_AES_GCM_authenticated_decryption_test_case_7),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_AES_GCM_authenticated_decryption_test_case_8),
12605 /** AES GCM Authenticated Encryption 192 bits key */
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_AES_GCM_auth_encryption_test_case_192_1),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_AES_GCM_auth_encryption_test_case_192_2),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_AES_GCM_auth_encryption_test_case_192_3),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_AES_GCM_auth_encryption_test_case_192_4),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_AES_GCM_auth_encryption_test_case_192_5),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_AES_GCM_auth_encryption_test_case_192_6),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_AES_GCM_auth_encryption_test_case_192_7),
12621 /** AES GCM Authenticated Decryption 192 bits key */
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_AES_GCM_auth_decryption_test_case_192_1),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_AES_GCM_auth_decryption_test_case_192_2),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_AES_GCM_auth_decryption_test_case_192_3),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_AES_GCM_auth_decryption_test_case_192_4),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_AES_GCM_auth_decryption_test_case_192_5),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_GCM_auth_decryption_test_case_192_6),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_auth_decryption_test_case_192_7),
12637 /** AES GCM Authenticated Encryption 256 bits key */
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_auth_encryption_test_case_256_1),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_GCM_auth_encryption_test_case_256_2),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_auth_encryption_test_case_256_3),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_GCM_auth_encryption_test_case_256_4),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_auth_encryption_test_case_256_5),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_encryption_test_case_256_6),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_encryption_test_case_256_7),
12653 /** AES GCM Authenticated Decryption 256 bits key */
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_auth_decryption_test_case_256_1),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_AES_GCM_auth_decryption_test_case_256_2),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 test_AES_GCM_auth_decryption_test_case_256_3),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 test_AES_GCM_auth_decryption_test_case_256_4),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 test_AES_GCM_auth_decryption_test_case_256_5),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 test_AES_GCM_auth_decryption_test_case_256_6),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_AES_GCM_auth_decryption_test_case_256_7),
12669 /** Out of place tests */
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12672 TEST_CASE_ST(ut_setup, ut_teardown,
12673 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12675 /** SNOW 3G encrypt only (UEA2) */
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 test_snow3g_encryption_test_case_1),
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 test_snow3g_encryption_test_case_2),
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_snow3g_encryption_test_case_3),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_snow3g_encryption_test_case_4),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_snow3g_encryption_test_case_5),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_snow3g_encryption_test_case_1_oop),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_snow3g_encryption_test_case_1_oop_sgl),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_snow3g_decryption_test_case_1_oop),
12694 /** SNOW 3G decrypt only (UEA2) */
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_snow3g_decryption_test_case_1),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_snow3g_decryption_test_case_2),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_snow3g_decryption_test_case_3),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_snow3g_decryption_test_case_4),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_snow3g_decryption_test_case_5),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_snow3g_hash_generate_test_case_1),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_snow3g_hash_generate_test_case_2),
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_snow3g_hash_generate_test_case_3),
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_snow3g_hash_verify_test_case_1),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_snow3g_hash_verify_test_case_2),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_snow3g_hash_verify_test_case_3),
12719 /** ZUC encrypt only (EEA3) */
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_zuc_encryption_test_case_1),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_zuc_encryption_test_case_2),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_zuc_encryption_test_case_3),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 test_zuc_encryption_test_case_4),
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 test_zuc_encryption_test_case_5),
12731 /** ZUC authenticate (EIA3) */
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_zuc_hash_generate_test_case_6),
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_zuc_hash_generate_test_case_7),
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_zuc_hash_generate_test_case_8),
12739 /** Negative tests */
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12744 TEST_CASE_ST(ut_setup, ut_teardown,
12745 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12779 TEST_CASES_END() /**< NULL terminate unit test array */
12783 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12784 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12785 .setup = testsuite_setup,
12786 .teardown = testsuite_teardown,
12787 .unit_test_cases = {
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_device_configure_invalid_dev_id),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_multi_session),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_chain_dpaa2_sec_all),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_3DES_chain_dpaa2_sec_all),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_AES_cipheronly_dpaa2_sec_all),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_3DES_cipheronly_dpaa2_sec_all),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_authonly_dpaa2_sec_all),
12803 #ifdef RTE_LIBRTE_SECURITY
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_PDCP_PROTO_cplane_encap_all),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_PDCP_PROTO_cplane_decap_all),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_PDCP_PROTO_uplane_encap_all),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_PDCP_PROTO_uplane_decap_all),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_PDCP_PROTO_SGL_in_place_32B),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_PDCP_PROTO_SGL_oop_32B_128B),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_PDCP_PROTO_SGL_oop_32B_40B),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_PDCP_PROTO_SGL_oop_128B_32B),
12825 /** AES GCM Authenticated Encryption */
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_AES_GCM_authenticated_encryption_test_case_1),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_AES_GCM_authenticated_encryption_test_case_2),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_AES_GCM_authenticated_encryption_test_case_3),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_AES_GCM_authenticated_encryption_test_case_4),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_AES_GCM_authenticated_encryption_test_case_5),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_AES_GCM_authenticated_encryption_test_case_6),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_AES_GCM_authenticated_encryption_test_case_7),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_AES_GCM_authenticated_encryption_test_case_8),
12851 /** AES GCM Authenticated Decryption */
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_AES_GCM_authenticated_decryption_test_case_1),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_AES_GCM_authenticated_decryption_test_case_2),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_AES_GCM_authenticated_decryption_test_case_3),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_AES_GCM_authenticated_decryption_test_case_4),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_AES_GCM_authenticated_decryption_test_case_5),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_AES_GCM_authenticated_decryption_test_case_6),
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 test_AES_GCM_authenticated_decryption_test_case_7),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_AES_GCM_authenticated_decryption_test_case_8),
12869 /** AES GCM Authenticated Encryption 192 bits key */
12870 TEST_CASE_ST(ut_setup, ut_teardown,
12871 test_AES_GCM_auth_encryption_test_case_192_1),
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_AES_GCM_auth_encryption_test_case_192_2),
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_AES_GCM_auth_encryption_test_case_192_3),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_AES_GCM_auth_encryption_test_case_192_4),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_AES_GCM_auth_encryption_test_case_192_5),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_AES_GCM_auth_encryption_test_case_192_6),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_AES_GCM_auth_encryption_test_case_192_7),
12885 /** AES GCM Authenticated Decryption 192 bits key */
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_AES_GCM_auth_decryption_test_case_192_1),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_AES_GCM_auth_decryption_test_case_192_2),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_AES_GCM_auth_decryption_test_case_192_3),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_AES_GCM_auth_decryption_test_case_192_4),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_AES_GCM_auth_decryption_test_case_192_5),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_AES_GCM_auth_decryption_test_case_192_6),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_AES_GCM_auth_decryption_test_case_192_7),
12901 /** AES GCM Authenticated Encryption 256 bits key */
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_AES_GCM_auth_encryption_test_case_256_1),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_AES_GCM_auth_encryption_test_case_256_2),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_AES_GCM_auth_encryption_test_case_256_3),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_AES_GCM_auth_encryption_test_case_256_4),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 test_AES_GCM_auth_encryption_test_case_256_5),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_AES_GCM_auth_encryption_test_case_256_6),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_AES_GCM_auth_encryption_test_case_256_7),
12917 /** AES GCM Authenticated Decryption 256 bits key */
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_AES_GCM_auth_decryption_test_case_256_1),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_AES_GCM_auth_decryption_test_case_256_2),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_AES_GCM_auth_decryption_test_case_256_3),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 test_AES_GCM_auth_decryption_test_case_256_4),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_AES_GCM_auth_decryption_test_case_256_5),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_AES_GCM_auth_decryption_test_case_256_6),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_AES_GCM_auth_decryption_test_case_256_7),
12933 /** Out of place tests */
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12939 /** SNOW 3G encrypt only (UEA2) */
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 test_snow3g_encryption_test_case_1),
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 test_snow3g_encryption_test_case_2),
12944 TEST_CASE_ST(ut_setup, ut_teardown,
12945 test_snow3g_encryption_test_case_3),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_snow3g_encryption_test_case_4),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_snow3g_encryption_test_case_5),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_snow3g_encryption_test_case_1_oop),
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_snow3g_encryption_test_case_1_oop_sgl),
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 test_snow3g_decryption_test_case_1_oop),
12958 /** SNOW 3G decrypt only (UEA2) */
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_snow3g_decryption_test_case_1),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_snow3g_decryption_test_case_2),
12963 TEST_CASE_ST(ut_setup, ut_teardown,
12964 test_snow3g_decryption_test_case_3),
12965 TEST_CASE_ST(ut_setup, ut_teardown,
12966 test_snow3g_decryption_test_case_4),
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_snow3g_decryption_test_case_5),
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_snow3g_hash_generate_test_case_1),
12972 TEST_CASE_ST(ut_setup, ut_teardown,
12973 test_snow3g_hash_generate_test_case_2),
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 test_snow3g_hash_generate_test_case_3),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_snow3g_hash_verify_test_case_1),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_snow3g_hash_verify_test_case_2),
12980 TEST_CASE_ST(ut_setup, ut_teardown,
12981 test_snow3g_hash_verify_test_case_3),
12983 /** ZUC encrypt only (EEA3) */
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_zuc_encryption_test_case_1),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_zuc_encryption_test_case_2),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_zuc_encryption_test_case_3),
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 test_zuc_encryption_test_case_4),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_zuc_encryption_test_case_5),
12995 /** ZUC authenticate (EIA3) */
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_zuc_hash_generate_test_case_6),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_zuc_hash_generate_test_case_7),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_zuc_hash_generate_test_case_8),
13003 /** HMAC_MD5 Authentication */
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_MD5_HMAC_generate_case_1),
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_MD5_HMAC_verify_case_1),
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_MD5_HMAC_generate_case_2),
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_MD5_HMAC_verify_case_2),
13013 /** Negative tests */
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13054 TEST_CASES_END() /**< NULL terminate unit test array */
13058 static struct unit_test_suite cryptodev_null_testsuite = {
13059 .suite_name = "Crypto Device NULL Unit Test Suite",
13060 .setup = testsuite_setup,
13061 .teardown = testsuite_teardown,
13062 .unit_test_cases = {
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_null_invalid_operation),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_null_burst_operation),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_AES_chain_null_all),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_AES_cipheronly_null_all),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_authonly_null_all),
13074 TEST_CASES_END() /**< NULL terminate unit test array */
13078 static struct unit_test_suite cryptodev_armv8_testsuite = {
13079 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13080 .setup = testsuite_setup,
13081 .teardown = testsuite_teardown,
13082 .unit_test_cases = {
13083 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13085 /** Negative tests */
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13091 TEST_CASES_END() /**< NULL terminate unit test array */
13095 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13096 .suite_name = "Crypto Device Marvell Component Test Suite",
13097 .setup = testsuite_setup,
13098 .teardown = testsuite_teardown,
13099 .unit_test_cases = {
13100 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13101 TEST_CASE_ST(ut_setup, ut_teardown,
13102 test_multi_session_random_usage),
13103 TEST_CASE_ST(ut_setup, ut_teardown,
13104 test_AES_chain_mrvl_all),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_AES_cipheronly_mrvl_all),
13107 TEST_CASE_ST(ut_setup, ut_teardown,
13108 test_authonly_mrvl_all),
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_3DES_chain_mrvl_all),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_3DES_cipheronly_mrvl_all),
13114 /** Negative tests */
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13124 TEST_CASES_END() /**< NULL terminate unit test array */
13128 static struct unit_test_suite cryptodev_ccp_testsuite = {
13129 .suite_name = "Crypto Device CCP Unit Test Suite",
13130 .setup = testsuite_setup,
13131 .teardown = testsuite_teardown,
13132 .unit_test_cases = {
13133 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_multi_session_random_usage),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_AES_chain_ccp_all),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_AES_cipheronly_ccp_all),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_3DES_chain_ccp_all),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_3DES_cipheronly_ccp_all),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_authonly_ccp_all),
13147 /** Negative tests */
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13157 TEST_CASES_END() /**< NULL terminate unit test array */
13161 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13162 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13163 .setup = testsuite_setup,
13164 .teardown = testsuite_teardown,
13165 .unit_test_cases = {
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_chain_octeontx_all),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_cipheronly_octeontx_all),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_3DES_chain_octeontx_all),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_3DES_cipheronly_octeontx_all),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_authonly_octeontx_all),
13177 /** AES GCM Authenticated Encryption */
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GCM_authenticated_encryption_test_case_1),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GCM_authenticated_encryption_test_case_2),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GCM_authenticated_encryption_test_case_3),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GCM_authenticated_encryption_test_case_4),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_AES_GCM_authenticated_encryption_test_case_5),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GCM_authenticated_encryption_test_case_6),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GCM_authenticated_encryption_test_case_7),
13193 /** AES GCM Authenticated Decryption */
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_AES_GCM_authenticated_decryption_test_case_1),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_AES_GCM_authenticated_decryption_test_case_2),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_AES_GCM_authenticated_decryption_test_case_3),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_AES_GCM_authenticated_decryption_test_case_4),
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 test_AES_GCM_authenticated_decryption_test_case_5),
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_AES_GCM_authenticated_decryption_test_case_6),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_AES_GCM_authenticated_decryption_test_case_7),
13208 /** AES GMAC Authentication */
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_AES_GMAC_authentication_test_case_1),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 test_AES_GMAC_authentication_verify_test_case_1),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_AES_GMAC_authentication_test_case_2),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 test_AES_GMAC_authentication_verify_test_case_2),
13217 TEST_CASE_ST(ut_setup, ut_teardown,
13218 test_AES_GMAC_authentication_test_case_3),
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 test_AES_GMAC_authentication_verify_test_case_3),
13222 /** SNOW 3G encrypt only (UEA2) */
13223 TEST_CASE_ST(ut_setup, ut_teardown,
13224 test_snow3g_encryption_test_case_1),
13225 TEST_CASE_ST(ut_setup, ut_teardown,
13226 test_snow3g_encryption_test_case_2),
13227 TEST_CASE_ST(ut_setup, ut_teardown,
13228 test_snow3g_encryption_test_case_3),
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_snow3g_encryption_test_case_4),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_snow3g_encryption_test_case_5),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_snow3g_encryption_test_case_1_oop),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_snow3g_decryption_test_case_1_oop),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_snow3g_encryption_test_case_1_oop_sgl),
13241 /** SNOW 3G decrypt only (UEA2) */
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_snow3g_decryption_test_case_1),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_snow3g_decryption_test_case_2),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_snow3g_decryption_test_case_3),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_snow3g_decryption_test_case_4),
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_snow3g_decryption_test_case_5),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_snow3g_hash_generate_test_case_1),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_snow3g_hash_generate_test_case_2),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_snow3g_hash_generate_test_case_3),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_snow3g_hash_verify_test_case_1),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_snow3g_hash_verify_test_case_2),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_snow3g_hash_verify_test_case_3),
13266 /** ZUC encrypt only (EEA3) */
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_zuc_encryption_test_case_1),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_zuc_encryption_test_case_2),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_zuc_encryption_test_case_3),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_zuc_encryption_test_case_4),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_zuc_encryption_test_case_5),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_zuc_hash_generate_test_case_1),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_zuc_hash_generate_test_case_2),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_zuc_hash_generate_test_case_3),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_zuc_hash_generate_test_case_4),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_zuc_hash_generate_test_case_5),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_zuc_encryption_test_case_6_sgl),
13290 /** KASUMI encrypt only (UEA1) */
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_kasumi_encryption_test_case_1),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_kasumi_encryption_test_case_2),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_kasumi_encryption_test_case_3),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_kasumi_encryption_test_case_4),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_kasumi_encryption_test_case_5),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_kasumi_encryption_test_case_1_sgl),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_kasumi_encryption_test_case_1_oop_sgl),
13305 /** KASUMI decrypt only (UEA1) */
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_kasumi_decryption_test_case_1),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_kasumi_decryption_test_case_2),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_kasumi_decryption_test_case_3),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_kasumi_decryption_test_case_4),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_kasumi_decryption_test_case_5),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_kasumi_encryption_test_case_1_oop),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_kasumi_decryption_test_case_1_oop),
13322 /** KASUMI hash only (UIA1) */
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_kasumi_hash_generate_test_case_1),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_kasumi_hash_generate_test_case_2),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_kasumi_hash_generate_test_case_3),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_kasumi_hash_generate_test_case_4),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_kasumi_hash_generate_test_case_5),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_kasumi_hash_generate_test_case_6),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_kasumi_hash_verify_test_case_1),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_kasumi_hash_verify_test_case_2),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_kasumi_hash_verify_test_case_3),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_kasumi_hash_verify_test_case_4),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_kasumi_hash_verify_test_case_5),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_null_cipher_only_operation),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_null_auth_only_operation),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_null_cipher_auth_operation),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_null_auth_cipher_operation),
13356 /** Negative tests */
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 authentication_verify_AES128_GMAC_fail_data_corrupt),
13363 TEST_CASE_ST(ut_setup, ut_teardown,
13364 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13365 TEST_CASE_ST(ut_setup, ut_teardown,
13366 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13367 TEST_CASE_ST(ut_setup, ut_teardown,
13368 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13369 TEST_CASES_END() /**< NULL terminate unit test array */
13373 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13374 .suite_name = "Crypto NITROX Unit Test Suite",
13375 .setup = testsuite_setup,
13376 .teardown = testsuite_teardown,
13377 .unit_test_cases = {
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_device_configure_invalid_dev_id),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_device_configure_invalid_queue_pair_ids),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_AES_chain_nitrox_all),
13385 TEST_CASES_END() /**< NULL terminate unit test array */
13390 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13392 gbl_driver_id = rte_cryptodev_driver_id_get(
13393 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13395 if (gbl_driver_id == -1) {
13396 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13397 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13398 "are enabled in config file to run this testsuite.\n");
13399 return TEST_SKIPPED;
13402 return unit_test_suite_runner(&cryptodev_qat_testsuite);
13406 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13408 gbl_driver_id = rte_cryptodev_driver_id_get(
13409 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13411 if (gbl_driver_id == -1) {
13412 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13413 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13414 "in config file to run this testsuite.\n");
13415 return TEST_FAILED;
13418 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13422 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13424 gbl_driver_id = rte_cryptodev_driver_id_get(
13425 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13427 if (gbl_driver_id == -1) {
13428 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13429 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13430 "in config file to run this testsuite.\n");
13431 return TEST_SKIPPED;
13434 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
13438 test_cryptodev_openssl(void)
13440 gbl_driver_id = rte_cryptodev_driver_id_get(
13441 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13443 if (gbl_driver_id == -1) {
13444 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13445 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13446 "in config file to run this testsuite.\n");
13447 return TEST_SKIPPED;
13450 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
13454 test_cryptodev_aesni_gcm(void)
13456 gbl_driver_id = rte_cryptodev_driver_id_get(
13457 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13459 if (gbl_driver_id == -1) {
13460 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13461 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13462 "in config file to run this testsuite.\n");
13463 return TEST_SKIPPED;
13466 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
13470 test_cryptodev_null(void)
13472 gbl_driver_id = rte_cryptodev_driver_id_get(
13473 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13475 if (gbl_driver_id == -1) {
13476 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13477 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13478 "in config file to run this testsuite.\n");
13479 return TEST_SKIPPED;
13482 return unit_test_suite_runner(&cryptodev_null_testsuite);
13486 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13488 gbl_driver_id = rte_cryptodev_driver_id_get(
13489 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13491 if (gbl_driver_id == -1) {
13492 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13493 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13494 "in config file to run this testsuite.\n");
13495 return TEST_SKIPPED;
13498 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
13502 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13504 gbl_driver_id = rte_cryptodev_driver_id_get(
13505 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13507 if (gbl_driver_id == -1) {
13508 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13509 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13510 "in config file to run this testsuite.\n");
13511 return TEST_SKIPPED;
13514 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
13518 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13520 gbl_driver_id = rte_cryptodev_driver_id_get(
13521 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13523 if (gbl_driver_id == -1) {
13524 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13525 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13526 "in config file to run this testsuite.\n");
13527 return TEST_SKIPPED;
13530 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
13534 test_cryptodev_armv8(void)
13536 gbl_driver_id = rte_cryptodev_driver_id_get(
13537 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13539 if (gbl_driver_id == -1) {
13540 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13541 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13542 "in config file to run this testsuite.\n");
13543 return TEST_SKIPPED;
13546 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13550 test_cryptodev_mrvl(void)
13552 gbl_driver_id = rte_cryptodev_driver_id_get(
13553 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13555 if (gbl_driver_id == -1) {
13556 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13557 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13558 "in config file to run this testsuite.\n");
13559 return TEST_SKIPPED;
13562 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13565 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13568 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13570 gbl_driver_id = rte_cryptodev_driver_id_get(
13571 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13573 if (gbl_driver_id == -1) {
13574 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13575 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13576 "in config file to run this testsuite.\n");
13577 return TEST_SKIPPED;
13580 if (rte_cryptodev_driver_id_get(
13581 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13582 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13583 " enabled in config file to run this testsuite.\n");
13584 return TEST_SKIPPED;
13586 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13589 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13594 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13596 gbl_driver_id = rte_cryptodev_driver_id_get(
13597 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13599 if (gbl_driver_id == -1) {
13600 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13601 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13602 "in config file to run this testsuite.\n");
13603 return TEST_SKIPPED;
13606 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13610 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13612 gbl_driver_id = rte_cryptodev_driver_id_get(
13613 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13615 if (gbl_driver_id == -1) {
13616 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13617 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13618 "in config file to run this testsuite.\n");
13619 return TEST_SKIPPED;
13622 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13626 test_cryptodev_ccp(void)
13628 gbl_driver_id = rte_cryptodev_driver_id_get(
13629 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13631 if (gbl_driver_id == -1) {
13632 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13633 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13634 "in config file to run this testsuite.\n");
13635 return TEST_FAILED;
13638 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13642 test_cryptodev_octeontx(void)
13644 gbl_driver_id = rte_cryptodev_driver_id_get(
13645 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13646 if (gbl_driver_id == -1) {
13647 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13648 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13649 "enabled in config file to run this "
13651 return TEST_FAILED;
13653 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13657 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13659 gbl_driver_id = rte_cryptodev_driver_id_get(
13660 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13662 if (gbl_driver_id == -1) {
13663 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13664 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13665 "in config file to run this testsuite.\n");
13666 return TEST_FAILED;
13669 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13673 test_cryptodev_nitrox(void)
13675 gbl_driver_id = rte_cryptodev_driver_id_get(
13676 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13678 if (gbl_driver_id == -1) {
13679 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13680 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13681 "in config file to run this testsuite.\n");
13682 return TEST_FAILED;
13685 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13688 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13689 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13690 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13691 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13692 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13693 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13694 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13695 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13696 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13697 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13698 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13699 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13700 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13701 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13702 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13703 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13704 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);