1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 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>
19 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
20 #include <rte_cryptodev_scheduler.h>
21 #include <rte_cryptodev_scheduler_operations.h>
24 #include <rte_lcore.h>
27 #include "test_cryptodev.h"
29 #include "test_cryptodev_blockcipher.h"
30 #include "test_cryptodev_aes_test_vectors.h"
31 #include "test_cryptodev_des_test_vectors.h"
32 #include "test_cryptodev_hash_test_vectors.h"
33 #include "test_cryptodev_kasumi_test_vectors.h"
34 #include "test_cryptodev_kasumi_hash_test_vectors.h"
35 #include "test_cryptodev_snow3g_test_vectors.h"
36 #include "test_cryptodev_snow3g_hash_test_vectors.h"
37 #include "test_cryptodev_zuc_test_vectors.h"
38 #include "test_cryptodev_aead_test_vectors.h"
39 #include "test_cryptodev_hmac_test_vectors.h"
41 #define VDEV_ARGS_SIZE 100
42 #define MAX_NB_SESSIONS 4
44 static int gbl_driver_id;
46 struct crypto_testsuite_params {
47 struct rte_mempool *mbuf_pool;
48 struct rte_mempool *large_mbuf_pool;
49 struct rte_mempool *op_mpool;
50 struct rte_mempool *session_mpool;
51 struct rte_mempool *session_priv_mpool;
52 struct rte_cryptodev_config conf;
53 struct rte_cryptodev_qp_conf qp_conf;
55 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
56 uint8_t valid_dev_count;
59 struct crypto_unittest_params {
60 struct rte_crypto_sym_xform cipher_xform;
61 struct rte_crypto_sym_xform auth_xform;
62 struct rte_crypto_sym_xform aead_xform;
64 struct rte_cryptodev_sym_session *sess;
66 struct rte_crypto_op *op;
68 struct rte_mbuf *obuf, *ibuf;
73 #define ALIGN_POW2_ROUNDUP(num, align) \
74 (((num) + (align) - 1) & ~((align) - 1))
77 * Forward declarations.
80 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
81 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
85 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
86 struct crypto_unittest_params *ut_params,
87 struct crypto_testsuite_params *ts_param,
88 const uint8_t *cipher,
89 const uint8_t *digest,
92 static struct rte_mbuf *
93 setup_test_string(struct rte_mempool *mpool,
94 const char *string, size_t len, uint8_t blocksize)
96 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
97 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
99 memset(m->buf_addr, 0, m->buf_len);
101 char *dst = rte_pktmbuf_append(m, t_len);
108 rte_memcpy(dst, string, t_len);
110 memset(dst, 0, t_len);
116 /* Get number of bytes in X bits (rounding up) */
118 ceil_byte_length(uint32_t num_bits)
121 return ((num_bits >> 3) + 1);
123 return (num_bits >> 3);
126 static struct rte_crypto_op *
127 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
129 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
130 printf("Error sending packet for encryption");
136 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
142 static struct crypto_testsuite_params testsuite_params = { NULL };
143 static struct crypto_unittest_params unittest_params;
146 testsuite_setup(void)
148 struct crypto_testsuite_params *ts_params = &testsuite_params;
149 struct rte_cryptodev_info info;
150 uint32_t i = 0, nb_devs, dev_id;
154 memset(ts_params, 0, sizeof(*ts_params));
156 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
157 if (ts_params->mbuf_pool == NULL) {
158 /* Not already created so create */
159 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
161 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
163 if (ts_params->mbuf_pool == NULL) {
164 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
169 ts_params->large_mbuf_pool = rte_mempool_lookup(
170 "CRYPTO_LARGE_MBUFPOOL");
171 if (ts_params->large_mbuf_pool == NULL) {
172 /* Not already created so create */
173 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
174 "CRYPTO_LARGE_MBUFPOOL",
177 if (ts_params->large_mbuf_pool == NULL) {
179 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
184 ts_params->op_mpool = rte_crypto_op_pool_create(
185 "MBUF_CRYPTO_SYM_OP_POOL",
186 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
187 NUM_MBUFS, MBUF_CACHE_SIZE,
189 sizeof(struct rte_crypto_sym_xform) +
192 if (ts_params->op_mpool == NULL) {
193 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
197 /* Create an AESNI MB device if required */
198 if (gbl_driver_id == rte_cryptodev_driver_id_get(
199 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
200 nb_devs = rte_cryptodev_device_count_by_driver(
201 rte_cryptodev_driver_id_get(
202 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
205 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
207 TEST_ASSERT(ret == 0,
208 "Failed to create instance of"
210 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
214 /* Create an AESNI GCM device if required */
215 if (gbl_driver_id == rte_cryptodev_driver_id_get(
216 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
217 nb_devs = rte_cryptodev_device_count_by_driver(
218 rte_cryptodev_driver_id_get(
219 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
221 TEST_ASSERT_SUCCESS(rte_vdev_init(
222 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
223 "Failed to create instance of"
225 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
229 /* Create a SNOW 3G device if required */
230 if (gbl_driver_id == rte_cryptodev_driver_id_get(
231 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
232 nb_devs = rte_cryptodev_device_count_by_driver(
233 rte_cryptodev_driver_id_get(
234 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
236 TEST_ASSERT_SUCCESS(rte_vdev_init(
237 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
238 "Failed to create instance of"
240 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
244 /* Create a KASUMI device if required */
245 if (gbl_driver_id == rte_cryptodev_driver_id_get(
246 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
247 nb_devs = rte_cryptodev_device_count_by_driver(
248 rte_cryptodev_driver_id_get(
249 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
251 TEST_ASSERT_SUCCESS(rte_vdev_init(
252 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
253 "Failed to create instance of"
255 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
259 /* Create a ZUC device if required */
260 if (gbl_driver_id == rte_cryptodev_driver_id_get(
261 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
262 nb_devs = rte_cryptodev_device_count_by_driver(
263 rte_cryptodev_driver_id_get(
264 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
266 TEST_ASSERT_SUCCESS(rte_vdev_init(
267 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
268 "Failed to create instance of"
270 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
274 /* Create a NULL device if required */
275 if (gbl_driver_id == rte_cryptodev_driver_id_get(
276 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
277 nb_devs = rte_cryptodev_device_count_by_driver(
278 rte_cryptodev_driver_id_get(
279 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
282 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
284 TEST_ASSERT(ret == 0,
285 "Failed to create instance of"
287 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
291 /* Create an OPENSSL device if required */
292 if (gbl_driver_id == rte_cryptodev_driver_id_get(
293 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
294 nb_devs = rte_cryptodev_device_count_by_driver(
295 rte_cryptodev_driver_id_get(
296 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
299 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
302 TEST_ASSERT(ret == 0, "Failed to create "
303 "instance of pmd : %s",
304 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
308 /* Create a ARMv8 device if required */
309 if (gbl_driver_id == rte_cryptodev_driver_id_get(
310 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
311 nb_devs = rte_cryptodev_device_count_by_driver(
312 rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
316 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
319 TEST_ASSERT(ret == 0, "Failed to create "
320 "instance of pmd : %s",
321 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
325 /* Create a MVSAM device if required */
326 if (gbl_driver_id == rte_cryptodev_driver_id_get(
327 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
328 nb_devs = rte_cryptodev_device_count_by_driver(
329 rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
333 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
336 TEST_ASSERT(ret == 0, "Failed to create "
337 "instance of pmd : %s",
338 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
342 /* Create an CCP device if required */
343 if (gbl_driver_id == rte_cryptodev_driver_id_get(
344 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
345 nb_devs = rte_cryptodev_device_count_by_driver(
346 rte_cryptodev_driver_id_get(
347 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
350 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
353 TEST_ASSERT(ret == 0, "Failed to create "
354 "instance of pmd : %s",
355 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
359 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
360 char vdev_args[VDEV_ARGS_SIZE] = {""};
361 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
362 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
363 uint16_t slave_core_count = 0;
364 uint16_t socket_id = 0;
366 if (gbl_driver_id == rte_cryptodev_driver_id_get(
367 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
369 /* Identify the Slave Cores
370 * Use 2 slave cores for the device args
372 RTE_LCORE_FOREACH_SLAVE(i) {
373 if (slave_core_count > 1)
375 snprintf(vdev_args, sizeof(vdev_args),
376 "%s%d", temp_str, i);
377 strcpy(temp_str, vdev_args);
378 strcat(temp_str, ";");
380 socket_id = lcore_config[i].socket_id;
382 if (slave_core_count != 2) {
384 "Cryptodev scheduler test require at least "
385 "two slave cores to run. "
386 "Please use the correct coremask.\n");
389 strcpy(temp_str, vdev_args);
390 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
391 temp_str, socket_id);
392 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
393 nb_devs = rte_cryptodev_device_count_by_driver(
394 rte_cryptodev_driver_id_get(
395 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
398 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
400 TEST_ASSERT(ret == 0,
401 "Failed to create instance %u of"
403 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
406 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
408 nb_devs = rte_cryptodev_count();
410 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
414 /* Create list of valid crypto devs */
415 for (i = 0; i < nb_devs; i++) {
416 rte_cryptodev_info_get(i, &info);
417 if (info.driver_id == gbl_driver_id)
418 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
421 if (ts_params->valid_dev_count < 1)
424 /* Set up all the qps on the first of the valid devices found */
426 dev_id = ts_params->valid_devs[0];
428 rte_cryptodev_info_get(dev_id, &info);
430 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
431 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 unsigned int session_size =
434 rte_cryptodev_sym_get_private_session_size(dev_id);
437 * Create mempool with maximum number of sessions * 2,
438 * to include the session headers
440 if (info.sym.max_nb_sessions != 0 &&
441 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
442 RTE_LOG(ERR, USER1, "Device does not support "
443 "at least %u sessions\n",
448 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
449 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
451 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
452 "session mempool allocation failed");
454 ts_params->session_priv_mpool = rte_mempool_create(
458 0, 0, NULL, NULL, NULL,
461 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
462 "session mempool allocation failed");
466 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
468 "Failed to configure cryptodev %u with %u qps",
469 dev_id, ts_params->conf.nb_queue_pairs);
471 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
472 ts_params->qp_conf.mp_session = ts_params->session_mpool;
473 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
475 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 dev_id, qp_id, &ts_params->qp_conf,
478 rte_cryptodev_socket_id(dev_id)),
479 "Failed to setup queue pair %u on cryptodev %u",
487 testsuite_teardown(void)
489 struct crypto_testsuite_params *ts_params = &testsuite_params;
491 if (ts_params->mbuf_pool != NULL) {
492 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
493 rte_mempool_avail_count(ts_params->mbuf_pool));
496 if (ts_params->op_mpool != NULL) {
497 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
498 rte_mempool_avail_count(ts_params->op_mpool));
501 /* Free session mempools */
502 if (ts_params->session_priv_mpool != NULL) {
503 rte_mempool_free(ts_params->session_priv_mpool);
504 ts_params->session_priv_mpool = NULL;
507 if (ts_params->session_mpool != NULL) {
508 rte_mempool_free(ts_params->session_mpool);
509 ts_params->session_mpool = NULL;
516 struct crypto_testsuite_params *ts_params = &testsuite_params;
517 struct crypto_unittest_params *ut_params = &unittest_params;
521 /* Clear unit test parameters before running test */
522 memset(ut_params, 0, sizeof(*ut_params));
524 /* Reconfigure device to default parameters */
525 ts_params->conf.socket_id = SOCKET_ID_ANY;
526 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
527 ts_params->qp_conf.mp_session = ts_params->session_mpool;
528 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
530 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
532 "Failed to configure cryptodev %u",
533 ts_params->valid_devs[0]);
535 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
536 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
537 ts_params->valid_devs[0], qp_id,
539 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
540 "Failed to setup queue pair %u on cryptodev %u",
541 qp_id, ts_params->valid_devs[0]);
545 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
547 /* Start the device */
548 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
549 "Failed to start cryptodev %u",
550 ts_params->valid_devs[0]);
558 struct crypto_testsuite_params *ts_params = &testsuite_params;
559 struct crypto_unittest_params *ut_params = &unittest_params;
560 struct rte_cryptodev_stats stats;
562 /* free crypto session structure */
563 if (ut_params->sess) {
564 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
566 rte_cryptodev_sym_session_free(ut_params->sess);
567 ut_params->sess = NULL;
570 /* free crypto operation structure */
572 rte_crypto_op_free(ut_params->op);
575 * free mbuf - both obuf and ibuf are usually the same,
576 * so check if they point at the same address is necessary,
577 * to avoid freeing the mbuf twice.
579 if (ut_params->obuf) {
580 rte_pktmbuf_free(ut_params->obuf);
581 if (ut_params->ibuf == ut_params->obuf)
585 if (ut_params->ibuf) {
586 rte_pktmbuf_free(ut_params->ibuf);
590 if (ts_params->mbuf_pool != NULL)
591 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
592 rte_mempool_avail_count(ts_params->mbuf_pool));
594 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
596 /* Stop the device */
597 rte_cryptodev_stop(ts_params->valid_devs[0]);
601 test_device_configure_invalid_dev_id(void)
603 struct crypto_testsuite_params *ts_params = &testsuite_params;
604 uint16_t dev_id, num_devs = 0;
606 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
607 "Need at least %d devices for test", 1);
609 /* valid dev_id values */
610 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
612 /* Stop the device in case it's started so it can be configured */
613 rte_cryptodev_stop(dev_id);
615 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
616 "Failed test for rte_cryptodev_configure: "
617 "invalid dev_num %u", dev_id);
619 /* invalid dev_id values */
622 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
623 "Failed test for rte_cryptodev_configure: "
624 "invalid dev_num %u", dev_id);
628 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
629 "Failed test for rte_cryptodev_configure:"
630 "invalid dev_num %u", dev_id);
636 test_device_configure_invalid_queue_pair_ids(void)
638 struct crypto_testsuite_params *ts_params = &testsuite_params;
639 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
641 /* Stop the device in case it's started so it can be configured */
642 rte_cryptodev_stop(ts_params->valid_devs[0]);
644 /* valid - one queue pairs */
645 ts_params->conf.nb_queue_pairs = 1;
647 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
649 "Failed to configure cryptodev: dev_id %u, qp_id %u",
650 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
653 /* valid - max value queue pairs */
654 ts_params->conf.nb_queue_pairs = orig_nb_qps;
656 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
658 "Failed to configure cryptodev: dev_id %u, qp_id %u",
659 ts_params->valid_devs[0],
660 ts_params->conf.nb_queue_pairs);
663 /* invalid - zero queue pairs */
664 ts_params->conf.nb_queue_pairs = 0;
666 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
668 "Failed test for rte_cryptodev_configure, dev_id %u,"
670 ts_params->valid_devs[0],
671 ts_params->conf.nb_queue_pairs);
674 /* invalid - max value supported by field queue pairs */
675 ts_params->conf.nb_queue_pairs = UINT16_MAX;
677 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
679 "Failed test for rte_cryptodev_configure, dev_id %u,"
681 ts_params->valid_devs[0],
682 ts_params->conf.nb_queue_pairs);
685 /* invalid - max value + 1 queue pairs */
686 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
688 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
690 "Failed test for rte_cryptodev_configure, dev_id %u,"
692 ts_params->valid_devs[0],
693 ts_params->conf.nb_queue_pairs);
695 /* revert to original testsuite value */
696 ts_params->conf.nb_queue_pairs = orig_nb_qps;
702 test_queue_pair_descriptor_setup(void)
704 struct crypto_testsuite_params *ts_params = &testsuite_params;
705 struct rte_cryptodev_info dev_info;
706 struct rte_cryptodev_qp_conf qp_conf = {
707 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
712 /* Stop the device in case it's started so it can be configured */
713 rte_cryptodev_stop(ts_params->valid_devs[0]);
716 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
718 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
720 "Failed to configure cryptodev %u",
721 ts_params->valid_devs[0]);
724 * Test various ring sizes on this device. memzones can't be
725 * freed so are re-used if ring is released and re-created.
727 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
728 qp_conf.mp_session = ts_params->session_mpool;
729 qp_conf.mp_session_private = ts_params->session_priv_mpool;
731 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
732 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
733 ts_params->valid_devs[0], qp_id, &qp_conf,
734 rte_cryptodev_socket_id(
735 ts_params->valid_devs[0])),
737 "rte_cryptodev_queue_pair_setup: num_inflights "
738 "%u on qp %u on cryptodev %u",
739 qp_conf.nb_descriptors, qp_id,
740 ts_params->valid_devs[0]);
743 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
745 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
746 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
747 ts_params->valid_devs[0], qp_id, &qp_conf,
748 rte_cryptodev_socket_id(
749 ts_params->valid_devs[0])),
751 " rte_cryptodev_queue_pair_setup: num_inflights"
752 " %u on qp %u on cryptodev %u",
753 qp_conf.nb_descriptors, qp_id,
754 ts_params->valid_devs[0]);
757 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
759 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
760 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
761 ts_params->valid_devs[0], qp_id, &qp_conf,
762 rte_cryptodev_socket_id(
763 ts_params->valid_devs[0])),
765 "rte_cryptodev_queue_pair_setup: num_inflights"
766 " %u on qp %u on cryptodev %u",
767 qp_conf.nb_descriptors, qp_id,
768 ts_params->valid_devs[0]);
771 /* invalid number of descriptors - max supported + 2 */
772 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
774 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
775 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
776 ts_params->valid_devs[0], qp_id, &qp_conf,
777 rte_cryptodev_socket_id(
778 ts_params->valid_devs[0])),
779 "Unexpectedly passed test for "
780 "rte_cryptodev_queue_pair_setup:"
781 "num_inflights %u on qp %u on cryptodev %u",
782 qp_conf.nb_descriptors, qp_id,
783 ts_params->valid_devs[0]);
786 /* invalid number of descriptors - max value of parameter */
787 qp_conf.nb_descriptors = UINT32_MAX-1;
789 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
790 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
791 ts_params->valid_devs[0], qp_id, &qp_conf,
792 rte_cryptodev_socket_id(
793 ts_params->valid_devs[0])),
794 "Unexpectedly passed test for "
795 "rte_cryptodev_queue_pair_setup:"
796 "num_inflights %u on qp %u on cryptodev %u",
797 qp_conf.nb_descriptors, qp_id,
798 ts_params->valid_devs[0]);
801 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
803 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
804 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
805 ts_params->valid_devs[0], qp_id, &qp_conf,
806 rte_cryptodev_socket_id(
807 ts_params->valid_devs[0])),
809 " rte_cryptodev_queue_pair_setup:"
810 "num_inflights %u on qp %u on cryptodev %u",
811 qp_conf.nb_descriptors, qp_id,
812 ts_params->valid_devs[0]);
815 /* invalid number of descriptors - max supported + 1 */
816 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
818 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
819 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
820 ts_params->valid_devs[0], qp_id, &qp_conf,
821 rte_cryptodev_socket_id(
822 ts_params->valid_devs[0])),
823 "Unexpectedly passed test for "
824 "rte_cryptodev_queue_pair_setup:"
825 "num_inflights %u on qp %u on cryptodev %u",
826 qp_conf.nb_descriptors, qp_id,
827 ts_params->valid_devs[0]);
830 /* test invalid queue pair id */
831 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
833 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
835 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
836 ts_params->valid_devs[0],
838 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
839 "Failed test for rte_cryptodev_queue_pair_setup:"
840 "invalid qp %u on cryptodev %u",
841 qp_id, ts_params->valid_devs[0]);
843 qp_id = 0xffff; /*invalid*/
845 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
846 ts_params->valid_devs[0],
848 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
849 "Failed test for rte_cryptodev_queue_pair_setup:"
850 "invalid qp %u on cryptodev %u",
851 qp_id, ts_params->valid_devs[0]);
856 /* ***** Plaintext data for tests ***** */
858 const char catch_22_quote_1[] =
859 "There was only one catch and that was Catch-22, which "
860 "specified that a concern for one's safety in the face of "
861 "dangers that were real and immediate was the process of a "
862 "rational mind. Orr was crazy and could be grounded. All he "
863 "had to do was ask; and as soon as he did, he would no longer "
864 "be crazy and would have to fly more missions. Orr would be "
865 "crazy to fly more missions and sane if he didn't, but if he "
866 "was sane he had to fly them. If he flew them he was crazy "
867 "and didn't have to; but if he didn't want to he was sane and "
868 "had to. Yossarian was moved very deeply by the absolute "
869 "simplicity of this clause of Catch-22 and let out a "
870 "respectful whistle. \"That's some catch, that Catch-22\", he "
871 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
873 const char catch_22_quote[] =
874 "What a lousy earth! He wondered how many people were "
875 "destitute that same night even in his own prosperous country, "
876 "how many homes were shanties, how many husbands were drunk "
877 "and wives socked, and how many children were bullied, abused, "
878 "or abandoned. How many families hungered for food they could "
879 "not afford to buy? How many hearts were broken? How many "
880 "suicides would take place that same night, how many people "
881 "would go insane? How many cockroaches and landlords would "
882 "triumph? How many winners were losers, successes failures, "
883 "and rich men poor men? How many wise guys were stupid? How "
884 "many happy endings were unhappy endings? How many honest men "
885 "were liars, brave men cowards, loyal men traitors, how many "
886 "sainted men were corrupt, how many people in positions of "
887 "trust had sold their souls to bodyguards, how many had never "
888 "had souls? How many straight-and-narrow paths were crooked "
889 "paths? How many best families were worst families and how "
890 "many good people were bad people? When you added them all up "
891 "and then subtracted, you might be left with only the children, "
892 "and perhaps with Albert Einstein and an old violinist or "
893 "sculptor somewhere.";
895 #define QUOTE_480_BYTES (480)
896 #define QUOTE_512_BYTES (512)
897 #define QUOTE_768_BYTES (768)
898 #define QUOTE_1024_BYTES (1024)
902 /* ***** SHA1 Hash Tests ***** */
904 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
906 static uint8_t hmac_sha1_key[] = {
907 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
908 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
909 0xDE, 0xF4, 0xDE, 0xAD };
911 /* ***** SHA224 Hash Tests ***** */
913 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
916 /* ***** AES-CBC Cipher Tests ***** */
918 #define CIPHER_KEY_LENGTH_AES_CBC (16)
919 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
921 static uint8_t aes_cbc_key[] = {
922 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
923 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
925 static uint8_t aes_cbc_iv[] = {
926 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
927 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
930 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
932 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
933 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
934 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
935 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
936 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
937 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
938 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
939 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
940 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
941 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
942 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
943 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
944 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
945 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
946 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
947 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
948 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
949 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
950 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
951 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
952 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
953 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
954 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
955 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
956 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
957 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
958 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
959 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
960 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
961 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
962 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
963 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
964 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
965 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
966 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
967 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
968 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
969 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
970 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
971 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
972 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
973 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
974 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
975 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
976 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
977 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
978 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
979 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
980 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
981 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
982 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
983 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
984 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
985 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
986 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
987 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
988 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
989 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
990 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
991 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
992 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
993 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
994 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
995 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
996 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
999 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1000 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1001 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1002 0x18, 0x8c, 0x1d, 0x32
1006 /* Multisession Vector context Test */
1007 /*Begin Session 0 */
1008 static uint8_t ms_aes_cbc_key0[] = {
1009 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1010 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1013 static uint8_t ms_aes_cbc_iv0[] = {
1014 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1015 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1018 static const uint8_t ms_aes_cbc_cipher0[] = {
1019 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1020 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1021 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1022 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1023 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1024 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1025 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1026 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1027 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1028 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1029 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1030 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1031 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1032 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1033 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1034 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1035 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1036 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1037 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1038 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1039 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1040 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1041 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1042 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1043 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1044 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1045 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1046 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1047 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1048 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1049 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1050 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1051 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1052 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1053 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1054 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1055 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1056 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1057 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1058 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1059 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1060 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1061 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1062 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1063 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1064 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1065 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1066 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1067 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1068 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1069 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1070 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1071 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1072 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1073 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1074 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1075 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1076 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1077 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1078 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1079 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1080 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1081 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1082 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1086 static uint8_t ms_hmac_key0[] = {
1087 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1088 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1089 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1090 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1091 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1092 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1093 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1094 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1097 static const uint8_t ms_hmac_digest0[] = {
1098 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1099 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1100 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1101 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1102 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1103 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1104 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1105 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1109 /* Begin session 1 */
1111 static uint8_t ms_aes_cbc_key1[] = {
1112 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1113 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1116 static uint8_t ms_aes_cbc_iv1[] = {
1117 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1118 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1121 static const uint8_t ms_aes_cbc_cipher1[] = {
1122 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1123 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1124 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1125 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1126 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1127 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1128 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1129 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1130 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1131 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1132 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1133 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1134 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1135 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1136 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1137 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1138 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1139 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1140 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1141 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1142 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1143 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1144 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1145 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1146 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1147 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1148 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1149 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1150 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1151 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1152 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1153 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1154 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1155 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1156 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1157 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1158 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1159 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1160 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1161 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1162 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1163 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1164 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1165 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1166 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1167 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1168 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1169 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1170 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1171 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1172 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1173 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1174 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1175 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1176 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1177 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1178 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1179 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1180 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1181 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1182 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1183 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1184 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1185 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1189 static uint8_t ms_hmac_key1[] = {
1190 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1191 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1192 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1193 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1194 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1195 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1196 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1197 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1200 static const uint8_t ms_hmac_digest1[] = {
1201 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1202 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1203 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1204 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1205 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1206 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1207 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1208 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1211 /* Begin Session 2 */
1212 static uint8_t ms_aes_cbc_key2[] = {
1213 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1214 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1217 static uint8_t ms_aes_cbc_iv2[] = {
1218 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1219 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1222 static const uint8_t ms_aes_cbc_cipher2[] = {
1223 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1224 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1225 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1226 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1227 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1228 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1229 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1230 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1231 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1232 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1233 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1234 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1235 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1236 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1237 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1238 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1239 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1240 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1241 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1242 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1243 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1244 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1245 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1246 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1247 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1248 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1249 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1250 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1251 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1252 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1253 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1254 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1255 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1256 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1257 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1258 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1259 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1260 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1261 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1262 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1263 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1264 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1265 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1266 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1267 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1268 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1269 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1270 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1271 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1272 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1273 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1274 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1275 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1276 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1277 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1278 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1279 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1280 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1281 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1282 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1283 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1284 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1285 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1286 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1289 static uint8_t ms_hmac_key2[] = {
1290 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1291 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1292 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1293 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1294 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1295 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1296 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1297 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1300 static const uint8_t ms_hmac_digest2[] = {
1301 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1302 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1303 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1304 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1305 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1306 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1307 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1308 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1315 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1317 struct crypto_testsuite_params *ts_params = &testsuite_params;
1318 struct crypto_unittest_params *ut_params = &unittest_params;
1320 /* Generate test mbuf data and space for digest */
1321 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1322 catch_22_quote, QUOTE_512_BYTES, 0);
1324 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1325 DIGEST_BYTE_LENGTH_SHA1);
1326 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1328 /* Setup Cipher Parameters */
1329 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1330 ut_params->cipher_xform.next = &ut_params->auth_xform;
1332 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1333 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1334 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1335 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1336 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1337 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1339 /* Setup HMAC Parameters */
1340 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1342 ut_params->auth_xform.next = NULL;
1344 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1345 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1346 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1347 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1348 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1350 ut_params->sess = rte_cryptodev_sym_session_create(
1351 ts_params->session_mpool);
1353 /* Create crypto session*/
1354 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1355 ut_params->sess, &ut_params->cipher_xform,
1356 ts_params->session_priv_mpool);
1357 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1359 /* Generate crypto op data structure */
1360 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1361 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1362 TEST_ASSERT_NOT_NULL(ut_params->op,
1363 "Failed to allocate symmetric crypto operation struct");
1365 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1367 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1369 /* set crypto operation source mbuf */
1370 sym_op->m_src = ut_params->ibuf;
1372 /* Set crypto operation authentication parameters */
1373 sym_op->auth.digest.data = ut_params->digest;
1374 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1375 ut_params->ibuf, QUOTE_512_BYTES);
1377 sym_op->auth.data.offset = 0;
1378 sym_op->auth.data.length = QUOTE_512_BYTES;
1380 /* Copy IV at the end of the crypto operation */
1381 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1382 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1384 /* Set crypto operation cipher parameters */
1385 sym_op->cipher.data.offset = 0;
1386 sym_op->cipher.data.length = QUOTE_512_BYTES;
1388 /* Process crypto operation */
1389 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1390 ut_params->op), "failed to process sym crypto op");
1392 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1393 "crypto op processing failed");
1396 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1399 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1400 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1402 "ciphertext data not as expected");
1404 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1406 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1407 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1408 gbl_driver_id == rte_cryptodev_driver_id_get(
1409 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1410 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1411 DIGEST_BYTE_LENGTH_SHA1,
1412 "Generated digest data not as expected");
1414 return TEST_SUCCESS;
1417 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1419 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1421 static uint8_t hmac_sha512_key[] = {
1422 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1423 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1424 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1425 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1426 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1427 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1428 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1429 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1431 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1432 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1433 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1434 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1435 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1436 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1437 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1438 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1439 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1444 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1445 struct crypto_unittest_params *ut_params,
1446 uint8_t *cipher_key,
1450 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1451 struct crypto_unittest_params *ut_params,
1452 struct crypto_testsuite_params *ts_params,
1453 const uint8_t *cipher,
1454 const uint8_t *digest,
1459 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1460 struct crypto_unittest_params *ut_params,
1461 uint8_t *cipher_key,
1465 /* Setup Cipher Parameters */
1466 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1467 ut_params->cipher_xform.next = NULL;
1469 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1470 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1471 ut_params->cipher_xform.cipher.key.data = cipher_key;
1472 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1473 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1474 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1476 /* Setup HMAC Parameters */
1477 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1478 ut_params->auth_xform.next = &ut_params->cipher_xform;
1480 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1481 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1482 ut_params->auth_xform.auth.key.data = hmac_key;
1483 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1484 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1486 return TEST_SUCCESS;
1491 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1492 struct crypto_unittest_params *ut_params,
1493 struct crypto_testsuite_params *ts_params,
1494 const uint8_t *cipher,
1495 const uint8_t *digest,
1498 /* Generate test mbuf data and digest */
1499 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1502 QUOTE_512_BYTES, 0);
1504 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1505 DIGEST_BYTE_LENGTH_SHA512);
1506 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1508 rte_memcpy(ut_params->digest,
1510 DIGEST_BYTE_LENGTH_SHA512);
1512 /* Generate Crypto op data structure */
1513 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1514 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1515 TEST_ASSERT_NOT_NULL(ut_params->op,
1516 "Failed to allocate symmetric crypto operation struct");
1518 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1520 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1522 /* set crypto operation source mbuf */
1523 sym_op->m_src = ut_params->ibuf;
1525 sym_op->auth.digest.data = ut_params->digest;
1526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1527 ut_params->ibuf, QUOTE_512_BYTES);
1529 sym_op->auth.data.offset = 0;
1530 sym_op->auth.data.length = QUOTE_512_BYTES;
1532 /* Copy IV at the end of the crypto operation */
1533 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1534 iv, CIPHER_IV_LENGTH_AES_CBC);
1536 sym_op->cipher.data.offset = 0;
1537 sym_op->cipher.data.length = QUOTE_512_BYTES;
1539 /* Process crypto operation */
1540 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1541 ut_params->op), "failed to process sym crypto op");
1543 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1544 "crypto op processing failed");
1546 ut_params->obuf = ut_params->op->sym->m_src;
1549 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1550 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1553 "Plaintext data not as expected");
1556 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1557 "Digest verification failed");
1559 return TEST_SUCCESS;
1563 test_AES_cipheronly_mb_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool,
1570 ts_params->session_mpool, ts_params->session_priv_mpool,
1571 ts_params->valid_devs[0],
1572 rte_cryptodev_driver_id_get(
1573 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1574 BLKCIPHER_AES_CIPHERONLY_TYPE);
1576 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1578 return TEST_SUCCESS;
1582 test_AES_docsis_mb_all(void)
1584 struct crypto_testsuite_params *ts_params = &testsuite_params;
1587 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1588 ts_params->op_mpool,
1589 ts_params->session_mpool, ts_params->session_priv_mpool,
1590 ts_params->valid_devs[0],
1591 rte_cryptodev_driver_id_get(
1592 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1593 BLKCIPHER_AES_DOCSIS_TYPE);
1595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 return TEST_SUCCESS;
1601 test_AES_docsis_qat_all(void)
1603 struct crypto_testsuite_params *ts_params = &testsuite_params;
1606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 ts_params->op_mpool,
1608 ts_params->session_mpool, ts_params->session_priv_mpool,
1609 ts_params->valid_devs[0],
1610 rte_cryptodev_driver_id_get(
1611 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1612 BLKCIPHER_AES_DOCSIS_TYPE);
1614 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1616 return TEST_SUCCESS;
1620 test_DES_docsis_qat_all(void)
1622 struct crypto_testsuite_params *ts_params = &testsuite_params;
1625 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1626 ts_params->op_mpool,
1627 ts_params->session_mpool, ts_params->session_priv_mpool,
1628 ts_params->valid_devs[0],
1629 rte_cryptodev_driver_id_get(
1630 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1631 BLKCIPHER_DES_DOCSIS_TYPE);
1633 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1635 return TEST_SUCCESS;
1639 test_authonly_mb_all(void)
1641 struct crypto_testsuite_params *ts_params = &testsuite_params;
1644 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1645 ts_params->op_mpool,
1646 ts_params->session_mpool, ts_params->session_priv_mpool,
1647 ts_params->valid_devs[0],
1648 rte_cryptodev_driver_id_get(
1649 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1650 BLKCIPHER_AUTHONLY_TYPE);
1652 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1654 return TEST_SUCCESS;
1658 test_authonly_qat_all(void)
1660 struct crypto_testsuite_params *ts_params = &testsuite_params;
1663 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1664 ts_params->op_mpool,
1665 ts_params->session_mpool, ts_params->session_priv_mpool,
1666 ts_params->valid_devs[0],
1667 rte_cryptodev_driver_id_get(
1668 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1669 BLKCIPHER_AUTHONLY_TYPE);
1671 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1673 return TEST_SUCCESS;
1676 test_AES_chain_mb_all(void)
1678 struct crypto_testsuite_params *ts_params = &testsuite_params;
1681 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1682 ts_params->op_mpool,
1683 ts_params->session_mpool, ts_params->session_priv_mpool,
1684 ts_params->valid_devs[0],
1685 rte_cryptodev_driver_id_get(
1686 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1687 BLKCIPHER_AES_CHAIN_TYPE);
1689 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1691 return TEST_SUCCESS;
1694 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1697 test_AES_cipheronly_scheduler_all(void)
1699 struct crypto_testsuite_params *ts_params = &testsuite_params;
1702 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1703 ts_params->op_mpool,
1704 ts_params->session_mpool, ts_params->session_priv_mpool,
1705 ts_params->valid_devs[0],
1706 rte_cryptodev_driver_id_get(
1707 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1708 BLKCIPHER_AES_CIPHERONLY_TYPE);
1710 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1712 return TEST_SUCCESS;
1716 test_AES_chain_scheduler_all(void)
1718 struct crypto_testsuite_params *ts_params = &testsuite_params;
1721 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1722 ts_params->op_mpool,
1723 ts_params->session_mpool, ts_params->session_priv_mpool,
1724 ts_params->valid_devs[0],
1725 rte_cryptodev_driver_id_get(
1726 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1727 BLKCIPHER_AES_CHAIN_TYPE);
1729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1731 return TEST_SUCCESS;
1735 test_authonly_scheduler_all(void)
1737 struct crypto_testsuite_params *ts_params = &testsuite_params;
1740 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1741 ts_params->op_mpool,
1742 ts_params->session_mpool, ts_params->session_priv_mpool,
1743 ts_params->valid_devs[0],
1744 rte_cryptodev_driver_id_get(
1745 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1746 BLKCIPHER_AUTHONLY_TYPE);
1748 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1750 return TEST_SUCCESS;
1753 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1756 test_AES_chain_openssl_all(void)
1758 struct crypto_testsuite_params *ts_params = &testsuite_params;
1761 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1762 ts_params->op_mpool,
1763 ts_params->session_mpool, ts_params->session_priv_mpool,
1764 ts_params->valid_devs[0],
1765 rte_cryptodev_driver_id_get(
1766 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1767 BLKCIPHER_AES_CHAIN_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1775 test_AES_cipheronly_openssl_all(void)
1777 struct crypto_testsuite_params *ts_params = &testsuite_params;
1780 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1781 ts_params->op_mpool,
1782 ts_params->session_mpool, ts_params->session_priv_mpool,
1783 ts_params->valid_devs[0],
1784 rte_cryptodev_driver_id_get(
1785 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1786 BLKCIPHER_AES_CIPHERONLY_TYPE);
1788 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1790 return TEST_SUCCESS;
1794 test_AES_chain_ccp_all(void)
1796 struct crypto_testsuite_params *ts_params = &testsuite_params;
1799 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1800 ts_params->op_mpool,
1801 ts_params->session_mpool, ts_params->session_priv_mpool,
1802 ts_params->valid_devs[0],
1803 rte_cryptodev_driver_id_get(
1804 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1805 BLKCIPHER_AES_CHAIN_TYPE);
1807 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1809 return TEST_SUCCESS;
1813 test_AES_cipheronly_ccp_all(void)
1815 struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1819 ts_params->op_mpool,
1820 ts_params->session_mpool, ts_params->session_priv_mpool,
1821 ts_params->valid_devs[0],
1822 rte_cryptodev_driver_id_get(
1823 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1824 BLKCIPHER_AES_CIPHERONLY_TYPE);
1826 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1828 return TEST_SUCCESS;
1832 test_AES_chain_qat_all(void)
1834 struct crypto_testsuite_params *ts_params = &testsuite_params;
1837 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1838 ts_params->op_mpool,
1839 ts_params->session_mpool, ts_params->session_priv_mpool,
1840 ts_params->valid_devs[0],
1841 rte_cryptodev_driver_id_get(
1842 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1843 BLKCIPHER_AES_CHAIN_TYPE);
1845 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1847 return TEST_SUCCESS;
1851 test_AES_cipheronly_qat_all(void)
1853 struct crypto_testsuite_params *ts_params = &testsuite_params;
1856 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1857 ts_params->op_mpool,
1858 ts_params->session_mpool, ts_params->session_priv_mpool,
1859 ts_params->valid_devs[0],
1860 rte_cryptodev_driver_id_get(
1861 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1862 BLKCIPHER_AES_CIPHERONLY_TYPE);
1864 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1866 return TEST_SUCCESS;
1870 test_AES_cipheronly_virtio_all(void)
1872 struct crypto_testsuite_params *ts_params = &testsuite_params;
1875 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1876 ts_params->op_mpool,
1877 ts_params->session_mpool, ts_params->session_priv_mpool,
1878 ts_params->valid_devs[0],
1879 rte_cryptodev_driver_id_get(
1880 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1881 BLKCIPHER_AES_CIPHERONLY_TYPE);
1883 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1885 return TEST_SUCCESS;
1889 test_AES_chain_caam_jr_all(void)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1894 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1895 ts_params->op_mpool,
1896 ts_params->session_mpool, ts_params->session_priv_mpool,
1897 ts_params->valid_devs[0],
1898 rte_cryptodev_driver_id_get(
1899 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1900 BLKCIPHER_AES_CHAIN_TYPE);
1902 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1904 return TEST_SUCCESS;
1908 test_AES_cipheronly_caam_jr_all(void)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1913 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1914 ts_params->op_mpool,
1915 ts_params->session_mpool, ts_params->session_priv_mpool,
1916 ts_params->valid_devs[0],
1917 rte_cryptodev_driver_id_get(
1918 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1919 BLKCIPHER_AES_CIPHERONLY_TYPE);
1921 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1923 return TEST_SUCCESS;
1927 test_authonly_caam_jr_all(void)
1929 struct crypto_testsuite_params *ts_params = &testsuite_params;
1932 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1933 ts_params->op_mpool,
1934 ts_params->session_mpool, ts_params->session_priv_mpool,
1935 ts_params->valid_devs[0],
1936 rte_cryptodev_driver_id_get(
1937 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1938 BLKCIPHER_AUTHONLY_TYPE);
1940 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1942 return TEST_SUCCESS;
1947 test_AES_chain_dpaa_sec_all(void)
1949 struct crypto_testsuite_params *ts_params = &testsuite_params;
1952 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1953 ts_params->op_mpool,
1954 ts_params->session_mpool, ts_params->session_priv_mpool,
1955 ts_params->valid_devs[0],
1956 rte_cryptodev_driver_id_get(
1957 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1958 BLKCIPHER_AES_CHAIN_TYPE);
1960 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1962 return TEST_SUCCESS;
1966 test_AES_cipheronly_dpaa_sec_all(void)
1968 struct crypto_testsuite_params *ts_params = &testsuite_params;
1971 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1972 ts_params->op_mpool,
1973 ts_params->session_mpool, ts_params->session_priv_mpool,
1974 ts_params->valid_devs[0],
1975 rte_cryptodev_driver_id_get(
1976 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1977 BLKCIPHER_AES_CIPHERONLY_TYPE);
1979 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1981 return TEST_SUCCESS;
1985 test_authonly_dpaa_sec_all(void)
1987 struct crypto_testsuite_params *ts_params = &testsuite_params;
1990 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1991 ts_params->op_mpool,
1992 ts_params->session_mpool, ts_params->session_priv_mpool,
1993 ts_params->valid_devs[0],
1994 rte_cryptodev_driver_id_get(
1995 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1996 BLKCIPHER_AUTHONLY_TYPE);
1998 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2000 return TEST_SUCCESS;
2004 test_AES_chain_dpaa2_sec_all(void)
2006 struct crypto_testsuite_params *ts_params = &testsuite_params;
2009 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2010 ts_params->op_mpool,
2011 ts_params->session_mpool, ts_params->session_priv_mpool,
2012 ts_params->valid_devs[0],
2013 rte_cryptodev_driver_id_get(
2014 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2015 BLKCIPHER_AES_CHAIN_TYPE);
2017 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2019 return TEST_SUCCESS;
2023 test_AES_cipheronly_dpaa2_sec_all(void)
2025 struct crypto_testsuite_params *ts_params = &testsuite_params;
2028 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2029 ts_params->op_mpool,
2030 ts_params->session_mpool, ts_params->session_priv_mpool,
2031 ts_params->valid_devs[0],
2032 rte_cryptodev_driver_id_get(
2033 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2034 BLKCIPHER_AES_CIPHERONLY_TYPE);
2036 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2038 return TEST_SUCCESS;
2042 test_authonly_dpaa2_sec_all(void)
2044 struct crypto_testsuite_params *ts_params = &testsuite_params;
2047 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2048 ts_params->op_mpool,
2049 ts_params->session_mpool, ts_params->session_priv_mpool,
2050 ts_params->valid_devs[0],
2051 rte_cryptodev_driver_id_get(
2052 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2053 BLKCIPHER_AUTHONLY_TYPE);
2055 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2057 return TEST_SUCCESS;
2061 test_authonly_openssl_all(void)
2063 struct crypto_testsuite_params *ts_params = &testsuite_params;
2066 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2067 ts_params->op_mpool,
2068 ts_params->session_mpool, ts_params->session_priv_mpool,
2069 ts_params->valid_devs[0],
2070 rte_cryptodev_driver_id_get(
2071 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2072 BLKCIPHER_AUTHONLY_TYPE);
2074 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2076 return TEST_SUCCESS;
2080 test_authonly_ccp_all(void)
2082 struct crypto_testsuite_params *ts_params = &testsuite_params;
2085 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2086 ts_params->op_mpool,
2087 ts_params->session_mpool, ts_params->session_priv_mpool,
2088 ts_params->valid_devs[0],
2089 rte_cryptodev_driver_id_get(
2090 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2091 BLKCIPHER_AUTHONLY_TYPE);
2093 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2095 return TEST_SUCCESS;
2099 test_AES_chain_armv8_all(void)
2101 struct crypto_testsuite_params *ts_params = &testsuite_params;
2104 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2105 ts_params->op_mpool,
2106 ts_params->session_mpool, ts_params->session_priv_mpool,
2107 ts_params->valid_devs[0],
2108 rte_cryptodev_driver_id_get(
2109 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2110 BLKCIPHER_AES_CHAIN_TYPE);
2112 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2114 return TEST_SUCCESS;
2118 test_AES_chain_mrvl_all(void)
2120 struct crypto_testsuite_params *ts_params = &testsuite_params;
2123 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2124 ts_params->op_mpool,
2125 ts_params->session_mpool, ts_params->session_priv_mpool,
2126 ts_params->valid_devs[0],
2127 rte_cryptodev_driver_id_get(
2128 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2129 BLKCIPHER_AES_CHAIN_TYPE);
2131 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2133 return TEST_SUCCESS;
2137 test_AES_cipheronly_mrvl_all(void)
2139 struct crypto_testsuite_params *ts_params = &testsuite_params;
2142 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2143 ts_params->op_mpool,
2144 ts_params->session_mpool, ts_params->session_priv_mpool,
2145 ts_params->valid_devs[0],
2146 rte_cryptodev_driver_id_get(
2147 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2148 BLKCIPHER_AES_CIPHERONLY_TYPE);
2150 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2152 return TEST_SUCCESS;
2156 test_authonly_mrvl_all(void)
2158 struct crypto_testsuite_params *ts_params = &testsuite_params;
2161 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2162 ts_params->op_mpool,
2163 ts_params->session_mpool, ts_params->session_priv_mpool,
2164 ts_params->valid_devs[0],
2165 rte_cryptodev_driver_id_get(
2166 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2167 BLKCIPHER_AUTHONLY_TYPE);
2169 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2171 return TEST_SUCCESS;
2175 test_3DES_chain_mrvl_all(void)
2177 struct crypto_testsuite_params *ts_params = &testsuite_params;
2180 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2181 ts_params->op_mpool,
2182 ts_params->session_mpool, ts_params->session_priv_mpool,
2183 ts_params->valid_devs[0],
2184 rte_cryptodev_driver_id_get(
2185 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2186 BLKCIPHER_3DES_CHAIN_TYPE);
2188 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2190 return TEST_SUCCESS;
2194 test_3DES_cipheronly_mrvl_all(void)
2196 struct crypto_testsuite_params *ts_params = &testsuite_params;
2199 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2200 ts_params->op_mpool,
2201 ts_params->session_mpool, ts_params->session_priv_mpool,
2202 ts_params->valid_devs[0],
2203 rte_cryptodev_driver_id_get(
2204 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2205 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2207 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2209 return TEST_SUCCESS;
2213 test_AES_chain_octeontx_all(void)
2215 struct crypto_testsuite_params *ts_params = &testsuite_params;
2218 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2219 ts_params->op_mpool, ts_params->session_mpool,
2220 ts_params->session_priv_mpool,
2221 ts_params->valid_devs[0],
2222 rte_cryptodev_driver_id_get(
2223 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2224 BLKCIPHER_AES_CHAIN_TYPE);
2226 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2228 return TEST_SUCCESS;
2232 test_AES_cipheronly_octeontx_all(void)
2234 struct crypto_testsuite_params *ts_params = &testsuite_params;
2237 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2238 ts_params->op_mpool, ts_params->session_mpool,
2239 ts_params->session_priv_mpool,
2240 ts_params->valid_devs[0],
2241 rte_cryptodev_driver_id_get(
2242 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2243 BLKCIPHER_AES_CIPHERONLY_TYPE);
2245 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2247 return TEST_SUCCESS;
2251 test_3DES_chain_octeontx_all(void)
2253 struct crypto_testsuite_params *ts_params = &testsuite_params;
2256 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2257 ts_params->op_mpool, ts_params->session_mpool,
2258 ts_params->session_priv_mpool,
2259 ts_params->valid_devs[0],
2260 rte_cryptodev_driver_id_get(
2261 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2262 BLKCIPHER_3DES_CHAIN_TYPE);
2264 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2266 return TEST_SUCCESS;
2270 test_3DES_cipheronly_octeontx_all(void)
2272 struct crypto_testsuite_params *ts_params = &testsuite_params;
2275 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2276 ts_params->op_mpool, ts_params->session_mpool,
2277 ts_params->session_priv_mpool,
2278 ts_params->valid_devs[0],
2279 rte_cryptodev_driver_id_get(
2280 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2281 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2283 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2285 return TEST_SUCCESS;
2289 test_authonly_octeontx_all(void)
2291 struct crypto_testsuite_params *ts_params = &testsuite_params;
2294 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2295 ts_params->op_mpool, ts_params->session_mpool,
2296 ts_params->session_priv_mpool,
2297 ts_params->valid_devs[0],
2298 rte_cryptodev_driver_id_get(
2299 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2300 BLKCIPHER_AUTHONLY_TYPE);
2302 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2304 return TEST_SUCCESS;
2307 /* ***** SNOW 3G Tests ***** */
2309 create_wireless_algo_hash_session(uint8_t dev_id,
2310 const uint8_t *key, const uint8_t key_len,
2311 const uint8_t iv_len, const uint8_t auth_len,
2312 enum rte_crypto_auth_operation op,
2313 enum rte_crypto_auth_algorithm algo)
2315 uint8_t hash_key[key_len];
2317 struct crypto_testsuite_params *ts_params = &testsuite_params;
2318 struct crypto_unittest_params *ut_params = &unittest_params;
2320 memcpy(hash_key, key, key_len);
2322 debug_hexdump(stdout, "key:", key, key_len);
2324 /* Setup Authentication Parameters */
2325 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2326 ut_params->auth_xform.next = NULL;
2328 ut_params->auth_xform.auth.op = op;
2329 ut_params->auth_xform.auth.algo = algo;
2330 ut_params->auth_xform.auth.key.length = key_len;
2331 ut_params->auth_xform.auth.key.data = hash_key;
2332 ut_params->auth_xform.auth.digest_length = auth_len;
2333 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2334 ut_params->auth_xform.auth.iv.length = iv_len;
2335 ut_params->sess = rte_cryptodev_sym_session_create(
2336 ts_params->session_mpool);
2338 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2339 &ut_params->auth_xform,
2340 ts_params->session_priv_mpool);
2341 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2346 create_wireless_algo_cipher_session(uint8_t dev_id,
2347 enum rte_crypto_cipher_operation op,
2348 enum rte_crypto_cipher_algorithm algo,
2349 const uint8_t *key, const uint8_t key_len,
2352 uint8_t cipher_key[key_len];
2354 struct crypto_testsuite_params *ts_params = &testsuite_params;
2355 struct crypto_unittest_params *ut_params = &unittest_params;
2357 memcpy(cipher_key, key, key_len);
2359 /* Setup Cipher Parameters */
2360 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2361 ut_params->cipher_xform.next = NULL;
2363 ut_params->cipher_xform.cipher.algo = algo;
2364 ut_params->cipher_xform.cipher.op = op;
2365 ut_params->cipher_xform.cipher.key.data = cipher_key;
2366 ut_params->cipher_xform.cipher.key.length = key_len;
2367 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2368 ut_params->cipher_xform.cipher.iv.length = iv_len;
2370 debug_hexdump(stdout, "key:", key, key_len);
2372 /* Create Crypto session */
2373 ut_params->sess = rte_cryptodev_sym_session_create(
2374 ts_params->session_mpool);
2376 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2377 &ut_params->cipher_xform,
2378 ts_params->session_priv_mpool);
2379 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2384 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2385 unsigned int cipher_len,
2386 unsigned int cipher_offset)
2388 struct crypto_testsuite_params *ts_params = &testsuite_params;
2389 struct crypto_unittest_params *ut_params = &unittest_params;
2391 /* Generate Crypto op data structure */
2392 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2393 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2394 TEST_ASSERT_NOT_NULL(ut_params->op,
2395 "Failed to allocate pktmbuf offload");
2397 /* Set crypto operation data parameters */
2398 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2400 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2402 /* set crypto operation source mbuf */
2403 sym_op->m_src = ut_params->ibuf;
2406 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2408 sym_op->cipher.data.length = cipher_len;
2409 sym_op->cipher.data.offset = cipher_offset;
2414 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2415 unsigned int cipher_len,
2416 unsigned int cipher_offset)
2418 struct crypto_testsuite_params *ts_params = &testsuite_params;
2419 struct crypto_unittest_params *ut_params = &unittest_params;
2421 /* Generate Crypto op data structure */
2422 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2423 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2424 TEST_ASSERT_NOT_NULL(ut_params->op,
2425 "Failed to allocate pktmbuf offload");
2427 /* Set crypto operation data parameters */
2428 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2430 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2432 /* set crypto operation source mbuf */
2433 sym_op->m_src = ut_params->ibuf;
2434 sym_op->m_dst = ut_params->obuf;
2437 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2439 sym_op->cipher.data.length = cipher_len;
2440 sym_op->cipher.data.offset = cipher_offset;
2445 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2446 enum rte_crypto_cipher_operation cipher_op,
2447 enum rte_crypto_auth_operation auth_op,
2448 enum rte_crypto_auth_algorithm auth_algo,
2449 enum rte_crypto_cipher_algorithm cipher_algo,
2450 const uint8_t *key, uint8_t key_len,
2451 uint8_t auth_iv_len, uint8_t auth_len,
2452 uint8_t cipher_iv_len)
2455 uint8_t cipher_auth_key[key_len];
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2460 memcpy(cipher_auth_key, key, key_len);
2462 /* Setup Authentication Parameters */
2463 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2464 ut_params->auth_xform.next = NULL;
2466 ut_params->auth_xform.auth.op = auth_op;
2467 ut_params->auth_xform.auth.algo = auth_algo;
2468 ut_params->auth_xform.auth.key.length = key_len;
2469 /* Hash key = cipher key */
2470 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2471 ut_params->auth_xform.auth.digest_length = auth_len;
2472 /* Auth IV will be after cipher IV */
2473 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2474 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2476 /* Setup Cipher Parameters */
2477 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2478 ut_params->cipher_xform.next = &ut_params->auth_xform;
2480 ut_params->cipher_xform.cipher.algo = cipher_algo;
2481 ut_params->cipher_xform.cipher.op = cipher_op;
2482 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2483 ut_params->cipher_xform.cipher.key.length = key_len;
2484 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2485 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2487 debug_hexdump(stdout, "key:", key, key_len);
2489 /* Create Crypto session*/
2490 ut_params->sess = rte_cryptodev_sym_session_create(
2491 ts_params->session_mpool);
2493 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2494 &ut_params->cipher_xform,
2495 ts_params->session_priv_mpool);
2497 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2502 create_wireless_cipher_auth_session(uint8_t dev_id,
2503 enum rte_crypto_cipher_operation cipher_op,
2504 enum rte_crypto_auth_operation auth_op,
2505 enum rte_crypto_auth_algorithm auth_algo,
2506 enum rte_crypto_cipher_algorithm cipher_algo,
2507 const struct wireless_test_data *tdata)
2509 const uint8_t key_len = tdata->key.len;
2510 uint8_t cipher_auth_key[key_len];
2512 struct crypto_testsuite_params *ts_params = &testsuite_params;
2513 struct crypto_unittest_params *ut_params = &unittest_params;
2514 const uint8_t *key = tdata->key.data;
2515 const uint8_t auth_len = tdata->digest.len;
2516 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2517 uint8_t auth_iv_len = tdata->auth_iv.len;
2519 memcpy(cipher_auth_key, key, key_len);
2521 /* Setup Authentication Parameters */
2522 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2523 ut_params->auth_xform.next = NULL;
2525 ut_params->auth_xform.auth.op = auth_op;
2526 ut_params->auth_xform.auth.algo = auth_algo;
2527 ut_params->auth_xform.auth.key.length = key_len;
2528 /* Hash key = cipher key */
2529 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2530 ut_params->auth_xform.auth.digest_length = auth_len;
2531 /* Auth IV will be after cipher IV */
2532 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2533 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2535 /* Setup Cipher Parameters */
2536 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2537 ut_params->cipher_xform.next = &ut_params->auth_xform;
2539 ut_params->cipher_xform.cipher.algo = cipher_algo;
2540 ut_params->cipher_xform.cipher.op = cipher_op;
2541 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2542 ut_params->cipher_xform.cipher.key.length = key_len;
2543 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2544 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2547 debug_hexdump(stdout, "key:", key, key_len);
2549 /* Create Crypto session*/
2550 ut_params->sess = rte_cryptodev_sym_session_create(
2551 ts_params->session_mpool);
2553 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2554 &ut_params->cipher_xform,
2555 ts_params->session_priv_mpool);
2557 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2562 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2563 const struct wireless_test_data *tdata)
2565 return create_wireless_cipher_auth_session(dev_id,
2566 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2567 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2568 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2572 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2573 enum rte_crypto_cipher_operation cipher_op,
2574 enum rte_crypto_auth_operation auth_op,
2575 enum rte_crypto_auth_algorithm auth_algo,
2576 enum rte_crypto_cipher_algorithm cipher_algo,
2577 const uint8_t *key, const uint8_t key_len,
2578 uint8_t auth_iv_len, uint8_t auth_len,
2579 uint8_t cipher_iv_len)
2581 uint8_t auth_cipher_key[key_len];
2583 struct crypto_testsuite_params *ts_params = &testsuite_params;
2584 struct crypto_unittest_params *ut_params = &unittest_params;
2586 memcpy(auth_cipher_key, key, key_len);
2588 /* Setup Authentication Parameters */
2589 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2590 ut_params->auth_xform.auth.op = auth_op;
2591 ut_params->auth_xform.next = &ut_params->cipher_xform;
2592 ut_params->auth_xform.auth.algo = auth_algo;
2593 ut_params->auth_xform.auth.key.length = key_len;
2594 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2595 ut_params->auth_xform.auth.digest_length = auth_len;
2596 /* Auth IV will be after cipher IV */
2597 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2598 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2600 /* Setup Cipher Parameters */
2601 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2602 ut_params->cipher_xform.next = NULL;
2603 ut_params->cipher_xform.cipher.algo = cipher_algo;
2604 ut_params->cipher_xform.cipher.op = cipher_op;
2605 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2606 ut_params->cipher_xform.cipher.key.length = key_len;
2607 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2608 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2610 debug_hexdump(stdout, "key:", key, key_len);
2612 /* Create Crypto session*/
2613 ut_params->sess = rte_cryptodev_sym_session_create(
2614 ts_params->session_mpool);
2616 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2617 &ut_params->auth_xform,
2618 ts_params->session_priv_mpool);
2620 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2626 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2627 unsigned int auth_tag_len,
2628 const uint8_t *iv, unsigned int iv_len,
2629 unsigned int data_pad_len,
2630 enum rte_crypto_auth_operation op,
2631 unsigned int auth_len, unsigned int auth_offset)
2633 struct crypto_testsuite_params *ts_params = &testsuite_params;
2635 struct crypto_unittest_params *ut_params = &unittest_params;
2637 /* Generate Crypto op data structure */
2638 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2639 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2640 TEST_ASSERT_NOT_NULL(ut_params->op,
2641 "Failed to allocate pktmbuf offload");
2643 /* Set crypto operation data parameters */
2644 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2646 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2648 /* set crypto operation source mbuf */
2649 sym_op->m_src = ut_params->ibuf;
2652 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2655 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2656 ut_params->ibuf, auth_tag_len);
2658 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2659 "no room to append auth tag");
2660 ut_params->digest = sym_op->auth.digest.data;
2661 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2662 ut_params->ibuf, data_pad_len);
2663 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2664 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2666 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2668 debug_hexdump(stdout, "digest:",
2669 sym_op->auth.digest.data,
2672 sym_op->auth.data.length = auth_len;
2673 sym_op->auth.data.offset = auth_offset;
2679 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2680 enum rte_crypto_auth_operation op)
2682 struct crypto_testsuite_params *ts_params = &testsuite_params;
2683 struct crypto_unittest_params *ut_params = &unittest_params;
2685 const uint8_t *auth_tag = tdata->digest.data;
2686 const unsigned int auth_tag_len = tdata->digest.len;
2687 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2688 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2690 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2691 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2692 const uint8_t *auth_iv = tdata->auth_iv.data;
2693 const uint8_t auth_iv_len = tdata->auth_iv.len;
2694 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2695 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2697 /* Generate Crypto op data structure */
2698 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2699 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2700 TEST_ASSERT_NOT_NULL(ut_params->op,
2701 "Failed to allocate pktmbuf offload");
2702 /* Set crypto operation data parameters */
2703 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2705 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2707 /* set crypto operation source mbuf */
2708 sym_op->m_src = ut_params->ibuf;
2711 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2712 ut_params->ibuf, auth_tag_len);
2714 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2715 "no room to append auth tag");
2716 ut_params->digest = sym_op->auth.digest.data;
2717 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2718 ut_params->ibuf, data_pad_len);
2719 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2720 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2722 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2724 debug_hexdump(stdout, "digest:",
2725 sym_op->auth.digest.data,
2728 /* Copy cipher and auth IVs at the end of the crypto operation */
2729 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2731 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2732 iv_ptr += cipher_iv_len;
2733 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2735 sym_op->cipher.data.length = cipher_len;
2736 sym_op->cipher.data.offset = 0;
2737 sym_op->auth.data.length = auth_len;
2738 sym_op->auth.data.offset = 0;
2744 create_zuc_cipher_hash_generate_operation(
2745 const struct wireless_test_data *tdata)
2747 return create_wireless_cipher_hash_operation(tdata,
2748 RTE_CRYPTO_AUTH_OP_GENERATE);
2752 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2753 const unsigned auth_tag_len,
2754 const uint8_t *auth_iv, uint8_t auth_iv_len,
2755 unsigned data_pad_len,
2756 enum rte_crypto_auth_operation op,
2757 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2758 const unsigned cipher_len, const unsigned cipher_offset,
2759 const unsigned auth_len, const unsigned auth_offset)
2761 struct crypto_testsuite_params *ts_params = &testsuite_params;
2762 struct crypto_unittest_params *ut_params = &unittest_params;
2764 /* Generate Crypto op data structure */
2765 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2766 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2767 TEST_ASSERT_NOT_NULL(ut_params->op,
2768 "Failed to allocate pktmbuf offload");
2769 /* Set crypto operation data parameters */
2770 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2772 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2774 /* set crypto operation source mbuf */
2775 sym_op->m_src = ut_params->ibuf;
2778 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2779 ut_params->ibuf, auth_tag_len);
2781 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2782 "no room to append auth tag");
2783 ut_params->digest = sym_op->auth.digest.data;
2784 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2785 ut_params->ibuf, data_pad_len);
2786 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2787 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2789 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2791 debug_hexdump(stdout, "digest:",
2792 sym_op->auth.digest.data,
2795 /* Copy cipher and auth IVs at the end of the crypto operation */
2796 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2798 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2799 iv_ptr += cipher_iv_len;
2800 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2802 sym_op->cipher.data.length = cipher_len;
2803 sym_op->cipher.data.offset = cipher_offset;
2804 sym_op->auth.data.length = auth_len;
2805 sym_op->auth.data.offset = auth_offset;
2811 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2812 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2813 const uint8_t *auth_iv, uint8_t auth_iv_len,
2814 unsigned int data_pad_len,
2815 unsigned int cipher_len, unsigned int cipher_offset,
2816 unsigned int auth_len, unsigned int auth_offset)
2818 struct crypto_testsuite_params *ts_params = &testsuite_params;
2819 struct crypto_unittest_params *ut_params = &unittest_params;
2821 /* Generate Crypto op data structure */
2822 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2823 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2824 TEST_ASSERT_NOT_NULL(ut_params->op,
2825 "Failed to allocate pktmbuf offload");
2827 /* Set crypto operation data parameters */
2828 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2830 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2832 /* set crypto operation source mbuf */
2833 sym_op->m_src = ut_params->ibuf;
2836 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2837 ut_params->ibuf, auth_tag_len);
2839 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2840 "no room to append auth tag");
2842 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2843 ut_params->ibuf, data_pad_len);
2845 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2847 debug_hexdump(stdout, "digest:",
2848 sym_op->auth.digest.data,
2851 /* Copy cipher and auth IVs at the end of the crypto operation */
2852 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2854 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2855 iv_ptr += cipher_iv_len;
2856 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2858 sym_op->cipher.data.length = cipher_len;
2859 sym_op->cipher.data.offset = cipher_offset;
2861 sym_op->auth.data.length = auth_len;
2862 sym_op->auth.data.offset = auth_offset;
2868 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2870 struct crypto_testsuite_params *ts_params = &testsuite_params;
2871 struct crypto_unittest_params *ut_params = &unittest_params;
2874 unsigned plaintext_pad_len;
2875 unsigned plaintext_len;
2878 /* Create SNOW 3G session */
2879 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2880 tdata->key.data, tdata->key.len,
2881 tdata->auth_iv.len, tdata->digest.len,
2882 RTE_CRYPTO_AUTH_OP_GENERATE,
2883 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2887 /* alloc mbuf and set payload */
2888 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2890 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2891 rte_pktmbuf_tailroom(ut_params->ibuf));
2893 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2894 /* Append data which is padded to a multiple of */
2895 /* the algorithms block size */
2896 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2897 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2899 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2901 /* Create SNOW 3G operation */
2902 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2903 tdata->auth_iv.data, tdata->auth_iv.len,
2904 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2905 tdata->validAuthLenInBits.len,
2910 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2912 ut_params->obuf = ut_params->op->sym->m_src;
2913 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2914 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2915 + plaintext_pad_len;
2918 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2921 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2922 "SNOW 3G Generated auth tag not as expected");
2928 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2930 struct crypto_testsuite_params *ts_params = &testsuite_params;
2931 struct crypto_unittest_params *ut_params = &unittest_params;
2934 unsigned plaintext_pad_len;
2935 unsigned plaintext_len;
2938 /* Create SNOW 3G session */
2939 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2940 tdata->key.data, tdata->key.len,
2941 tdata->auth_iv.len, tdata->digest.len,
2942 RTE_CRYPTO_AUTH_OP_VERIFY,
2943 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2946 /* alloc mbuf and set payload */
2947 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2950 rte_pktmbuf_tailroom(ut_params->ibuf));
2952 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2953 /* Append data which is padded to a multiple of */
2954 /* the algorithms block size */
2955 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2956 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2958 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2960 /* Create SNOW 3G operation */
2961 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2963 tdata->auth_iv.data, tdata->auth_iv.len,
2965 RTE_CRYPTO_AUTH_OP_VERIFY,
2966 tdata->validAuthLenInBits.len,
2971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2974 ut_params->obuf = ut_params->op->sym->m_src;
2975 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2976 + plaintext_pad_len;
2979 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2988 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2990 struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 struct crypto_unittest_params *ut_params = &unittest_params;
2994 unsigned plaintext_pad_len;
2995 unsigned plaintext_len;
2998 /* Create KASUMI session */
2999 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3000 tdata->key.data, tdata->key.len,
3001 0, tdata->digest.len,
3002 RTE_CRYPTO_AUTH_OP_GENERATE,
3003 RTE_CRYPTO_AUTH_KASUMI_F9);
3007 /* alloc mbuf and set payload */
3008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3010 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3011 rte_pktmbuf_tailroom(ut_params->ibuf));
3013 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3014 /* Append data which is padded to a multiple of */
3015 /* the algorithms block size */
3016 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3017 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3019 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3021 /* Create KASUMI operation */
3022 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3024 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3025 tdata->plaintext.len,
3030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3032 ut_params->obuf = ut_params->op->sym->m_src;
3033 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3034 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3035 + plaintext_pad_len;
3038 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3041 DIGEST_BYTE_LENGTH_KASUMI_F9,
3042 "KASUMI Generated auth tag not as expected");
3048 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3050 struct crypto_testsuite_params *ts_params = &testsuite_params;
3051 struct crypto_unittest_params *ut_params = &unittest_params;
3054 unsigned plaintext_pad_len;
3055 unsigned plaintext_len;
3058 /* Create KASUMI session */
3059 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3060 tdata->key.data, tdata->key.len,
3061 0, tdata->digest.len,
3062 RTE_CRYPTO_AUTH_OP_VERIFY,
3063 RTE_CRYPTO_AUTH_KASUMI_F9);
3066 /* alloc mbuf and set payload */
3067 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3069 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3070 rte_pktmbuf_tailroom(ut_params->ibuf));
3072 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3073 /* Append data which is padded to a multiple */
3074 /* of the algorithms block size */
3075 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3076 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3078 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3080 /* Create KASUMI operation */
3081 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3085 RTE_CRYPTO_AUTH_OP_VERIFY,
3086 tdata->plaintext.len,
3091 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3093 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3094 ut_params->obuf = ut_params->op->sym->m_src;
3095 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3096 + plaintext_pad_len;
3099 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3108 test_snow3g_hash_generate_test_case_1(void)
3110 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3114 test_snow3g_hash_generate_test_case_2(void)
3116 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3120 test_snow3g_hash_generate_test_case_3(void)
3122 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3126 test_snow3g_hash_generate_test_case_4(void)
3128 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3132 test_snow3g_hash_generate_test_case_5(void)
3134 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3138 test_snow3g_hash_generate_test_case_6(void)
3140 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3144 test_snow3g_hash_verify_test_case_1(void)
3146 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3151 test_snow3g_hash_verify_test_case_2(void)
3153 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3157 test_snow3g_hash_verify_test_case_3(void)
3159 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3163 test_snow3g_hash_verify_test_case_4(void)
3165 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3169 test_snow3g_hash_verify_test_case_5(void)
3171 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3175 test_snow3g_hash_verify_test_case_6(void)
3177 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3181 test_kasumi_hash_generate_test_case_1(void)
3183 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3187 test_kasumi_hash_generate_test_case_2(void)
3189 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3193 test_kasumi_hash_generate_test_case_3(void)
3195 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3199 test_kasumi_hash_generate_test_case_4(void)
3201 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3205 test_kasumi_hash_generate_test_case_5(void)
3207 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3211 test_kasumi_hash_generate_test_case_6(void)
3213 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3217 test_kasumi_hash_verify_test_case_1(void)
3219 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3223 test_kasumi_hash_verify_test_case_2(void)
3225 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3229 test_kasumi_hash_verify_test_case_3(void)
3231 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3235 test_kasumi_hash_verify_test_case_4(void)
3237 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3241 test_kasumi_hash_verify_test_case_5(void)
3243 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3247 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3249 struct crypto_testsuite_params *ts_params = &testsuite_params;
3250 struct crypto_unittest_params *ut_params = &unittest_params;
3253 uint8_t *plaintext, *ciphertext;
3254 unsigned plaintext_pad_len;
3255 unsigned plaintext_len;
3257 /* Create KASUMI session */
3258 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3259 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3260 RTE_CRYPTO_CIPHER_KASUMI_F8,
3261 tdata->key.data, tdata->key.len,
3262 tdata->cipher_iv.len);
3266 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3268 /* Clear mbuf payload */
3269 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3270 rte_pktmbuf_tailroom(ut_params->ibuf));
3272 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3273 /* Append data which is padded to a multiple */
3274 /* of the algorithms block size */
3275 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3276 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3278 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3280 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3282 /* Create KASUMI operation */
3283 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3284 tdata->cipher_iv.len,
3285 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3286 tdata->validCipherOffsetInBits.len);
3290 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3292 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3294 ut_params->obuf = ut_params->op->sym->m_dst;
3295 if (ut_params->obuf)
3296 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3298 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3300 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3302 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3303 (tdata->validCipherOffsetInBits.len >> 3);
3305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3307 reference_ciphertext,
3308 tdata->validCipherLenInBits.len,
3309 "KASUMI Ciphertext data not as expected");
3314 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3316 struct crypto_testsuite_params *ts_params = &testsuite_params;
3317 struct crypto_unittest_params *ut_params = &unittest_params;
3321 unsigned int plaintext_pad_len;
3322 unsigned int plaintext_len;
3324 uint8_t buffer[10000];
3325 const uint8_t *ciphertext;
3327 struct rte_cryptodev_info dev_info;
3329 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3331 uint64_t feat_flags = dev_info.feature_flags;
3333 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3334 printf("Device doesn't support in-place scatter-gather. "
3339 /* Create KASUMI session */
3340 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3341 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3342 RTE_CRYPTO_CIPHER_KASUMI_F8,
3343 tdata->key.data, tdata->key.len,
3344 tdata->cipher_iv.len);
3348 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3351 /* Append data which is padded to a multiple */
3352 /* of the algorithms block size */
3353 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3355 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3356 plaintext_pad_len, 10, 0);
3358 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3360 /* Create KASUMI operation */
3361 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3362 tdata->cipher_iv.len,
3363 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3364 tdata->validCipherOffsetInBits.len);
3368 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3370 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3372 ut_params->obuf = ut_params->op->sym->m_dst;
3374 if (ut_params->obuf)
3375 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3376 plaintext_len, buffer);
3378 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3379 tdata->validCipherOffsetInBits.len >> 3,
3380 plaintext_len, buffer);
3383 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3385 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3386 (tdata->validCipherOffsetInBits.len >> 3);
3388 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3390 reference_ciphertext,
3391 tdata->validCipherLenInBits.len,
3392 "KASUMI Ciphertext data not as expected");
3397 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3399 struct crypto_testsuite_params *ts_params = &testsuite_params;
3400 struct crypto_unittest_params *ut_params = &unittest_params;
3403 uint8_t *plaintext, *ciphertext;
3404 unsigned plaintext_pad_len;
3405 unsigned plaintext_len;
3407 /* Create KASUMI session */
3408 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3409 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3410 RTE_CRYPTO_CIPHER_KASUMI_F8,
3411 tdata->key.data, tdata->key.len,
3412 tdata->cipher_iv.len);
3416 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3417 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3419 /* Clear mbuf payload */
3420 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3421 rte_pktmbuf_tailroom(ut_params->ibuf));
3423 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3424 /* Append data which is padded to a multiple */
3425 /* of the algorithms block size */
3426 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3429 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3430 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3432 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3434 /* Create KASUMI operation */
3435 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3436 tdata->cipher_iv.len,
3437 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3438 tdata->validCipherOffsetInBits.len);
3442 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3444 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3446 ut_params->obuf = ut_params->op->sym->m_dst;
3447 if (ut_params->obuf)
3448 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3450 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3452 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3454 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3455 (tdata->validCipherOffsetInBits.len >> 3);
3457 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3459 reference_ciphertext,
3460 tdata->validCipherLenInBits.len,
3461 "KASUMI Ciphertext data not as expected");
3466 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3468 struct crypto_testsuite_params *ts_params = &testsuite_params;
3469 struct crypto_unittest_params *ut_params = &unittest_params;
3472 unsigned int plaintext_pad_len;
3473 unsigned int plaintext_len;
3475 const uint8_t *ciphertext;
3476 uint8_t buffer[2048];
3478 struct rte_cryptodev_info dev_info;
3480 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3482 uint64_t feat_flags = dev_info.feature_flags;
3483 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3484 printf("Device doesn't support out-of-place scatter-gather "
3485 "in both input and output mbufs. "
3490 /* Create KASUMI session */
3491 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3492 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3493 RTE_CRYPTO_CIPHER_KASUMI_F8,
3494 tdata->key.data, tdata->key.len,
3495 tdata->cipher_iv.len);
3499 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3500 /* Append data which is padded to a multiple */
3501 /* of the algorithms block size */
3502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3504 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3505 plaintext_pad_len, 10, 0);
3506 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3507 plaintext_pad_len, 3, 0);
3509 /* Append data which is padded to a multiple */
3510 /* of the algorithms block size */
3511 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3513 /* Create KASUMI operation */
3514 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3515 tdata->cipher_iv.len,
3516 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3517 tdata->validCipherOffsetInBits.len);
3521 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3525 ut_params->obuf = ut_params->op->sym->m_dst;
3526 if (ut_params->obuf)
3527 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3528 plaintext_pad_len, buffer);
3530 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3531 tdata->validCipherOffsetInBits.len >> 3,
3532 plaintext_pad_len, buffer);
3534 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3535 (tdata->validCipherOffsetInBits.len >> 3);
3537 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3539 reference_ciphertext,
3540 tdata->validCipherLenInBits.len,
3541 "KASUMI Ciphertext data not as expected");
3547 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3549 struct crypto_testsuite_params *ts_params = &testsuite_params;
3550 struct crypto_unittest_params *ut_params = &unittest_params;
3553 uint8_t *ciphertext, *plaintext;
3554 unsigned ciphertext_pad_len;
3555 unsigned ciphertext_len;
3557 /* Create KASUMI session */
3558 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3559 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3560 RTE_CRYPTO_CIPHER_KASUMI_F8,
3561 tdata->key.data, tdata->key.len,
3562 tdata->cipher_iv.len);
3566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3567 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3569 /* Clear mbuf payload */
3570 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3571 rte_pktmbuf_tailroom(ut_params->ibuf));
3573 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3574 /* Append data which is padded to a multiple */
3575 /* of the algorithms block size */
3576 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3577 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3578 ciphertext_pad_len);
3579 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3580 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3582 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3584 /* Create KASUMI operation */
3585 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3586 tdata->cipher_iv.len,
3587 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3588 tdata->validCipherOffsetInBits.len);
3592 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3594 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3596 ut_params->obuf = ut_params->op->sym->m_dst;
3597 if (ut_params->obuf)
3598 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3600 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3602 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3604 const uint8_t *reference_plaintext = tdata->plaintext.data +
3605 (tdata->validCipherOffsetInBits.len >> 3);
3607 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3609 reference_plaintext,
3610 tdata->validCipherLenInBits.len,
3611 "KASUMI Plaintext data not as expected");
3616 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3618 struct crypto_testsuite_params *ts_params = &testsuite_params;
3619 struct crypto_unittest_params *ut_params = &unittest_params;
3622 uint8_t *ciphertext, *plaintext;
3623 unsigned ciphertext_pad_len;
3624 unsigned ciphertext_len;
3626 /* Create KASUMI session */
3627 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3628 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3629 RTE_CRYPTO_CIPHER_KASUMI_F8,
3630 tdata->key.data, tdata->key.len,
3631 tdata->cipher_iv.len);
3635 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 /* Clear mbuf payload */
3638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639 rte_pktmbuf_tailroom(ut_params->ibuf));
3641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642 /* Append data which is padded to a multiple */
3643 /* of the algorithms block size */
3644 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3645 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 ciphertext_pad_len);
3647 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3649 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3651 /* Create KASUMI operation */
3652 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3653 tdata->cipher_iv.len,
3654 tdata->ciphertext.len,
3655 tdata->validCipherOffsetInBits.len);
3659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3663 ut_params->obuf = ut_params->op->sym->m_dst;
3664 if (ut_params->obuf)
3665 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3667 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3669 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3671 const uint8_t *reference_plaintext = tdata->plaintext.data +
3672 (tdata->validCipherOffsetInBits.len >> 3);
3674 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3676 reference_plaintext,
3677 tdata->validCipherLenInBits.len,
3678 "KASUMI Plaintext data not as expected");
3683 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3685 struct crypto_testsuite_params *ts_params = &testsuite_params;
3686 struct crypto_unittest_params *ut_params = &unittest_params;
3689 uint8_t *plaintext, *ciphertext;
3690 unsigned plaintext_pad_len;
3691 unsigned plaintext_len;
3693 /* Create SNOW 3G session */
3694 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3695 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3696 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3697 tdata->key.data, tdata->key.len,
3698 tdata->cipher_iv.len);
3702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3704 /* Clear mbuf payload */
3705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3706 rte_pktmbuf_tailroom(ut_params->ibuf));
3708 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3709 /* Append data which is padded to a multiple of */
3710 /* the algorithms block size */
3711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3712 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3714 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3716 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3718 /* Create SNOW 3G operation */
3719 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3720 tdata->cipher_iv.len,
3721 tdata->validCipherLenInBits.len,
3726 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3728 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3730 ut_params->obuf = ut_params->op->sym->m_dst;
3731 if (ut_params->obuf)
3732 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3734 ciphertext = plaintext;
3736 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3739 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3741 tdata->ciphertext.data,
3742 tdata->validDataLenInBits.len,
3743 "SNOW 3G Ciphertext data not as expected");
3749 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3751 struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 struct crypto_unittest_params *ut_params = &unittest_params;
3753 uint8_t *plaintext, *ciphertext;
3756 unsigned plaintext_pad_len;
3757 unsigned plaintext_len;
3759 /* Create SNOW 3G session */
3760 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3761 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3762 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3763 tdata->key.data, tdata->key.len,
3764 tdata->cipher_iv.len);
3768 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3769 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3771 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3772 "Failed to allocate input buffer in mempool");
3773 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3774 "Failed to allocate output buffer in mempool");
3776 /* Clear mbuf payload */
3777 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3778 rte_pktmbuf_tailroom(ut_params->ibuf));
3780 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3781 /* Append data which is padded to a multiple of */
3782 /* the algorithms block size */
3783 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3784 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3786 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3787 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3789 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3791 /* Create SNOW 3G operation */
3792 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3793 tdata->cipher_iv.len,
3794 tdata->validCipherLenInBits.len,
3799 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3801 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3803 ut_params->obuf = ut_params->op->sym->m_dst;
3804 if (ut_params->obuf)
3805 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3807 ciphertext = plaintext;
3809 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3812 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3814 tdata->ciphertext.data,
3815 tdata->validDataLenInBits.len,
3816 "SNOW 3G Ciphertext data not as expected");
3821 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3823 struct crypto_testsuite_params *ts_params = &testsuite_params;
3824 struct crypto_unittest_params *ut_params = &unittest_params;
3827 unsigned int plaintext_pad_len;
3828 unsigned int plaintext_len;
3829 uint8_t buffer[10000];
3830 const uint8_t *ciphertext;
3832 struct rte_cryptodev_info dev_info;
3834 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3836 uint64_t feat_flags = dev_info.feature_flags;
3838 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3839 printf("Device doesn't support out-of-place scatter-gather "
3840 "in both input and output mbufs. "
3845 /* Create SNOW 3G session */
3846 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3847 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3848 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3849 tdata->key.data, tdata->key.len,
3850 tdata->cipher_iv.len);
3854 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3855 /* Append data which is padded to a multiple of */
3856 /* the algorithms block size */
3857 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3859 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3860 plaintext_pad_len, 10, 0);
3861 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3862 plaintext_pad_len, 3, 0);
3864 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3865 "Failed to allocate input buffer in mempool");
3866 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3867 "Failed to allocate output buffer in mempool");
3869 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3871 /* Create SNOW 3G operation */
3872 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3873 tdata->cipher_iv.len,
3874 tdata->validCipherLenInBits.len,
3879 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3881 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3883 ut_params->obuf = ut_params->op->sym->m_dst;
3884 if (ut_params->obuf)
3885 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3886 plaintext_len, buffer);
3888 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3889 plaintext_len, buffer);
3891 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3896 tdata->ciphertext.data,
3897 tdata->validDataLenInBits.len,
3898 "SNOW 3G Ciphertext data not as expected");
3903 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3905 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3907 uint8_t curr_byte, prev_byte;
3908 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3909 uint8_t lower_byte_mask = (1 << offset) - 1;
3912 prev_byte = buffer[0];
3913 buffer[0] >>= offset;
3915 for (i = 1; i < length_in_bytes; i++) {
3916 curr_byte = buffer[i];
3917 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3918 (curr_byte >> offset);
3919 prev_byte = curr_byte;
3924 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3926 struct crypto_testsuite_params *ts_params = &testsuite_params;
3927 struct crypto_unittest_params *ut_params = &unittest_params;
3928 uint8_t *plaintext, *ciphertext;
3930 uint32_t plaintext_len;
3931 uint32_t plaintext_pad_len;
3932 uint8_t extra_offset = 4;
3933 uint8_t *expected_ciphertext_shifted;
3935 /* Create SNOW 3G session */
3936 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3938 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3939 tdata->key.data, tdata->key.len,
3940 tdata->cipher_iv.len);
3944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3945 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3947 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3948 "Failed to allocate input buffer in mempool");
3949 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3950 "Failed to allocate output buffer in mempool");
3952 /* Clear mbuf payload */
3953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 rte_pktmbuf_tailroom(ut_params->ibuf));
3956 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3958 * Append data which is padded to a
3959 * multiple of the algorithms block size
3961 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3963 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3966 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3968 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3969 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3971 #ifdef RTE_APP_TEST_DEBUG
3972 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3974 /* Create SNOW 3G operation */
3975 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3976 tdata->cipher_iv.len,
3977 tdata->validCipherLenInBits.len,
3982 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3984 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3986 ut_params->obuf = ut_params->op->sym->m_dst;
3987 if (ut_params->obuf)
3988 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3990 ciphertext = plaintext;
3992 #ifdef RTE_APP_TEST_DEBUG
3993 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3996 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3998 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3999 "failed to reserve memory for ciphertext shifted\n");
4001 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4002 ceil_byte_length(tdata->ciphertext.len));
4003 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4006 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4008 expected_ciphertext_shifted,
4009 tdata->validDataLenInBits.len,
4011 "SNOW 3G Ciphertext data not as expected");
4015 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4017 struct crypto_testsuite_params *ts_params = &testsuite_params;
4018 struct crypto_unittest_params *ut_params = &unittest_params;
4022 uint8_t *plaintext, *ciphertext;
4023 unsigned ciphertext_pad_len;
4024 unsigned ciphertext_len;
4026 /* Create SNOW 3G session */
4027 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4028 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4029 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4030 tdata->key.data, tdata->key.len,
4031 tdata->cipher_iv.len);
4035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4037 /* Clear mbuf payload */
4038 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4039 rte_pktmbuf_tailroom(ut_params->ibuf));
4041 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4042 /* Append data which is padded to a multiple of */
4043 /* the algorithms block size */
4044 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4045 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 ciphertext_pad_len);
4047 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4049 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4051 /* Create SNOW 3G operation */
4052 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4053 tdata->cipher_iv.len,
4054 tdata->validCipherLenInBits.len,
4059 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4061 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4062 ut_params->obuf = ut_params->op->sym->m_dst;
4063 if (ut_params->obuf)
4064 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4066 plaintext = ciphertext;
4068 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4071 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4072 tdata->plaintext.data,
4073 tdata->validDataLenInBits.len,
4074 "SNOW 3G Plaintext data not as expected");
4078 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4080 struct crypto_testsuite_params *ts_params = &testsuite_params;
4081 struct crypto_unittest_params *ut_params = &unittest_params;
4085 uint8_t *plaintext, *ciphertext;
4086 unsigned ciphertext_pad_len;
4087 unsigned ciphertext_len;
4089 /* Create SNOW 3G session */
4090 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4091 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4092 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4093 tdata->key.data, tdata->key.len,
4094 tdata->cipher_iv.len);
4098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4099 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4101 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4102 "Failed to allocate input buffer");
4103 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4104 "Failed to allocate output buffer");
4106 /* Clear mbuf payload */
4107 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4108 rte_pktmbuf_tailroom(ut_params->ibuf));
4110 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4111 rte_pktmbuf_tailroom(ut_params->obuf));
4113 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4114 /* Append data which is padded to a multiple of */
4115 /* the algorithms block size */
4116 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4117 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4118 ciphertext_pad_len);
4119 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4120 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4122 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4124 /* Create SNOW 3G operation */
4125 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4126 tdata->cipher_iv.len,
4127 tdata->validCipherLenInBits.len,
4132 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4134 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4135 ut_params->obuf = ut_params->op->sym->m_dst;
4136 if (ut_params->obuf)
4137 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4139 plaintext = ciphertext;
4141 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4144 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4145 tdata->plaintext.data,
4146 tdata->validDataLenInBits.len,
4147 "SNOW 3G Plaintext data not as expected");
4152 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4159 uint8_t *plaintext, *ciphertext;
4160 unsigned int plaintext_pad_len;
4161 unsigned int plaintext_len;
4163 struct rte_cryptodev_sym_capability_idx cap_idx;
4165 /* Check if device supports ZUC EEA3 */
4166 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4167 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4169 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4173 /* Check if device supports ZUC EIA3 */
4174 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4175 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4177 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4181 /* Create ZUC session */
4182 retval = create_zuc_cipher_auth_encrypt_generate_session(
4183 ts_params->valid_devs[0],
4187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4189 /* clear mbuf payload */
4190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4191 rte_pktmbuf_tailroom(ut_params->ibuf));
4193 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4194 /* Append data which is padded to a multiple of */
4195 /* the algorithms block size */
4196 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4197 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4199 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4201 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4203 /* Create ZUC operation */
4204 retval = create_zuc_cipher_hash_generate_operation(tdata);
4208 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4210 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4211 ut_params->obuf = ut_params->op->sym->m_src;
4212 if (ut_params->obuf)
4213 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4215 ciphertext = plaintext;
4217 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4219 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4221 tdata->ciphertext.data,
4222 tdata->validDataLenInBits.len,
4223 "ZUC Ciphertext data not as expected");
4225 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4226 + plaintext_pad_len;
4229 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4233 "ZUC Generated auth tag not as expected");
4238 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4240 struct crypto_testsuite_params *ts_params = &testsuite_params;
4241 struct crypto_unittest_params *ut_params = &unittest_params;
4245 uint8_t *plaintext, *ciphertext;
4246 unsigned plaintext_pad_len;
4247 unsigned plaintext_len;
4249 /* Create SNOW 3G session */
4250 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4251 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4252 RTE_CRYPTO_AUTH_OP_GENERATE,
4253 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4254 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4255 tdata->key.data, tdata->key.len,
4256 tdata->auth_iv.len, tdata->digest.len,
4257 tdata->cipher_iv.len);
4260 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4262 /* clear mbuf payload */
4263 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4264 rte_pktmbuf_tailroom(ut_params->ibuf));
4266 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4267 /* Append data which is padded to a multiple of */
4268 /* the algorithms block size */
4269 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4270 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4272 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4274 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4276 /* Create SNOW 3G operation */
4277 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4278 tdata->digest.len, tdata->auth_iv.data,
4280 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4281 tdata->cipher_iv.data, tdata->cipher_iv.len,
4282 tdata->validCipherLenInBits.len,
4284 tdata->validAuthLenInBits.len,
4290 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4292 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4293 ut_params->obuf = ut_params->op->sym->m_src;
4294 if (ut_params->obuf)
4295 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4297 ciphertext = plaintext;
4299 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4301 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4303 tdata->ciphertext.data,
4304 tdata->validDataLenInBits.len,
4305 "SNOW 3G Ciphertext data not as expected");
4307 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4308 + plaintext_pad_len;
4311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4314 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4315 "SNOW 3G Generated auth tag not as expected");
4319 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4321 struct crypto_testsuite_params *ts_params = &testsuite_params;
4322 struct crypto_unittest_params *ut_params = &unittest_params;
4326 uint8_t *plaintext, *ciphertext;
4327 unsigned plaintext_pad_len;
4328 unsigned plaintext_len;
4330 /* Create SNOW 3G session */
4331 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4332 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4333 RTE_CRYPTO_AUTH_OP_GENERATE,
4334 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 tdata->key.data, tdata->key.len,
4337 tdata->auth_iv.len, tdata->digest.len,
4338 tdata->cipher_iv.len);
4342 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4344 /* clear mbuf payload */
4345 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4346 rte_pktmbuf_tailroom(ut_params->ibuf));
4348 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4349 /* Append data which is padded to a multiple of */
4350 /* the algorithms block size */
4351 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4352 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4354 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4356 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4358 /* Create SNOW 3G operation */
4359 retval = create_wireless_algo_auth_cipher_operation(
4361 tdata->cipher_iv.data, tdata->cipher_iv.len,
4362 tdata->auth_iv.data, tdata->auth_iv.len,
4364 tdata->validCipherLenInBits.len,
4366 tdata->validAuthLenInBits.len,
4372 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4374 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4375 ut_params->obuf = ut_params->op->sym->m_src;
4376 if (ut_params->obuf)
4377 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4379 ciphertext = plaintext;
4381 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4382 + plaintext_pad_len;
4383 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4386 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4388 tdata->ciphertext.data,
4389 tdata->validDataLenInBits.len,
4390 "SNOW 3G Ciphertext data not as expected");
4393 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4396 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4397 "SNOW 3G Generated auth tag not as expected");
4402 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4404 struct crypto_testsuite_params *ts_params = &testsuite_params;
4405 struct crypto_unittest_params *ut_params = &unittest_params;
4409 uint8_t *plaintext, *ciphertext;
4410 unsigned plaintext_pad_len;
4411 unsigned plaintext_len;
4413 /* Create KASUMI session */
4414 retval = create_wireless_algo_auth_cipher_session(
4415 ts_params->valid_devs[0],
4416 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4417 RTE_CRYPTO_AUTH_OP_GENERATE,
4418 RTE_CRYPTO_AUTH_KASUMI_F9,
4419 RTE_CRYPTO_CIPHER_KASUMI_F8,
4420 tdata->key.data, tdata->key.len,
4421 0, tdata->digest.len,
4422 tdata->cipher_iv.len);
4425 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4427 /* clear mbuf payload */
4428 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4429 rte_pktmbuf_tailroom(ut_params->ibuf));
4431 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4432 /* Append data which is padded to a multiple of */
4433 /* the algorithms block size */
4434 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4435 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4437 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4439 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4441 /* Create KASUMI operation */
4442 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4443 tdata->cipher_iv.data, tdata->cipher_iv.len,
4446 tdata->validCipherLenInBits.len,
4447 tdata->validCipherOffsetInBits.len,
4448 tdata->validAuthLenInBits.len,
4455 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4458 if (ut_params->op->sym->m_dst)
4459 ut_params->obuf = ut_params->op->sym->m_dst;
4461 ut_params->obuf = ut_params->op->sym->m_src;
4463 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4464 tdata->validCipherOffsetInBits.len >> 3);
4466 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4467 (tdata->validCipherOffsetInBits.len >> 3);
4469 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4471 reference_ciphertext,
4472 tdata->validCipherLenInBits.len,
4473 "KASUMI Ciphertext data not as expected");
4474 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4475 + plaintext_pad_len;
4478 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4481 DIGEST_BYTE_LENGTH_KASUMI_F9,
4482 "KASUMI Generated auth tag not as expected");
4487 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4489 struct crypto_testsuite_params *ts_params = &testsuite_params;
4490 struct crypto_unittest_params *ut_params = &unittest_params;
4494 uint8_t *plaintext, *ciphertext;
4495 unsigned plaintext_pad_len;
4496 unsigned plaintext_len;
4498 /* Create KASUMI session */
4499 retval = create_wireless_algo_cipher_auth_session(
4500 ts_params->valid_devs[0],
4501 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4502 RTE_CRYPTO_AUTH_OP_GENERATE,
4503 RTE_CRYPTO_AUTH_KASUMI_F9,
4504 RTE_CRYPTO_CIPHER_KASUMI_F8,
4505 tdata->key.data, tdata->key.len,
4506 0, tdata->digest.len,
4507 tdata->cipher_iv.len);
4511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4513 /* clear mbuf payload */
4514 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4515 rte_pktmbuf_tailroom(ut_params->ibuf));
4517 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4518 /* Append data which is padded to a multiple of */
4519 /* the algorithms block size */
4520 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4521 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4523 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4525 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4527 /* Create KASUMI operation */
4528 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4529 tdata->digest.len, NULL, 0,
4530 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4531 tdata->cipher_iv.data, tdata->cipher_iv.len,
4532 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4533 tdata->validCipherOffsetInBits.len,
4534 tdata->validAuthLenInBits.len,
4540 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4542 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4544 if (ut_params->op->sym->m_dst)
4545 ut_params->obuf = ut_params->op->sym->m_dst;
4547 ut_params->obuf = ut_params->op->sym->m_src;
4549 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4550 tdata->validCipherOffsetInBits.len >> 3);
4552 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4553 + plaintext_pad_len;
4555 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4556 (tdata->validCipherOffsetInBits.len >> 3);
4558 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4560 reference_ciphertext,
4561 tdata->validCipherLenInBits.len,
4562 "KASUMI Ciphertext data not as expected");
4565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4568 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4569 "KASUMI Generated auth tag not as expected");
4574 test_zuc_encryption(const struct wireless_test_data *tdata)
4576 struct crypto_testsuite_params *ts_params = &testsuite_params;
4577 struct crypto_unittest_params *ut_params = &unittest_params;
4580 uint8_t *plaintext, *ciphertext;
4581 unsigned plaintext_pad_len;
4582 unsigned plaintext_len;
4584 struct rte_cryptodev_sym_capability_idx cap_idx;
4586 /* Check if device supports ZUC EEA3 */
4587 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4588 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4590 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4594 /* Create ZUC session */
4595 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4596 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4597 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4598 tdata->key.data, tdata->key.len,
4599 tdata->cipher_iv.len);
4603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605 /* Clear mbuf payload */
4606 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4607 rte_pktmbuf_tailroom(ut_params->ibuf));
4609 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4610 /* Append data which is padded to a multiple */
4611 /* of the algorithms block size */
4612 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4613 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4615 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4617 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4619 /* Create ZUC operation */
4620 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4621 tdata->cipher_iv.len,
4622 tdata->plaintext.len,
4627 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4629 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4631 ut_params->obuf = ut_params->op->sym->m_dst;
4632 if (ut_params->obuf)
4633 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4635 ciphertext = plaintext;
4637 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4640 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4642 tdata->ciphertext.data,
4643 tdata->validCipherLenInBits.len,
4644 "ZUC Ciphertext data not as expected");
4649 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4651 struct crypto_testsuite_params *ts_params = &testsuite_params;
4652 struct crypto_unittest_params *ut_params = &unittest_params;
4656 unsigned int plaintext_pad_len;
4657 unsigned int plaintext_len;
4658 const uint8_t *ciphertext;
4659 uint8_t ciphertext_buffer[2048];
4660 struct rte_cryptodev_info dev_info;
4662 struct rte_cryptodev_sym_capability_idx cap_idx;
4664 /* Check if device supports ZUC EEA3 */
4665 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4666 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4674 uint64_t feat_flags = dev_info.feature_flags;
4676 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4677 printf("Device doesn't support in-place scatter-gather. "
4682 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4684 /* Append data which is padded to a multiple */
4685 /* of the algorithms block size */
4686 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4688 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4689 plaintext_pad_len, 10, 0);
4691 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4692 tdata->plaintext.data);
4694 /* Create ZUC session */
4695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4697 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4698 tdata->key.data, tdata->key.len,
4699 tdata->cipher_iv.len);
4703 /* Clear mbuf payload */
4705 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4707 /* Create ZUC operation */
4708 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4709 tdata->cipher_iv.len, tdata->plaintext.len,
4714 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4716 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4718 ut_params->obuf = ut_params->op->sym->m_dst;
4719 if (ut_params->obuf)
4720 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4721 0, plaintext_len, ciphertext_buffer);
4723 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4724 0, plaintext_len, ciphertext_buffer);
4727 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4730 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4732 tdata->ciphertext.data,
4733 tdata->validCipherLenInBits.len,
4734 "ZUC Ciphertext data not as expected");
4740 test_zuc_authentication(const struct wireless_test_data *tdata)
4742 struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 struct crypto_unittest_params *ut_params = &unittest_params;
4746 unsigned plaintext_pad_len;
4747 unsigned plaintext_len;
4750 struct rte_cryptodev_sym_capability_idx cap_idx;
4752 /* Check if device supports ZUC EIA3 */
4753 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4754 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4756 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4760 /* Create ZUC session */
4761 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4762 tdata->key.data, tdata->key.len,
4763 tdata->auth_iv.len, tdata->digest.len,
4764 RTE_CRYPTO_AUTH_OP_GENERATE,
4765 RTE_CRYPTO_AUTH_ZUC_EIA3);
4769 /* alloc mbuf and set payload */
4770 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4772 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4773 rte_pktmbuf_tailroom(ut_params->ibuf));
4775 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4776 /* Append data which is padded to a multiple of */
4777 /* the algorithms block size */
4778 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4779 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4781 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4783 /* Create ZUC operation */
4784 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4785 tdata->auth_iv.data, tdata->auth_iv.len,
4786 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4787 tdata->validAuthLenInBits.len,
4792 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4794 ut_params->obuf = ut_params->op->sym->m_src;
4795 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4796 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4797 + plaintext_pad_len;
4800 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4803 DIGEST_BYTE_LENGTH_KASUMI_F9,
4804 "ZUC Generated auth tag not as expected");
4810 test_kasumi_encryption_test_case_1(void)
4812 return test_kasumi_encryption(&kasumi_test_case_1);
4816 test_kasumi_encryption_test_case_1_sgl(void)
4818 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4822 test_kasumi_encryption_test_case_1_oop(void)
4824 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4828 test_kasumi_encryption_test_case_1_oop_sgl(void)
4830 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4834 test_kasumi_encryption_test_case_2(void)
4836 return test_kasumi_encryption(&kasumi_test_case_2);
4840 test_kasumi_encryption_test_case_3(void)
4842 return test_kasumi_encryption(&kasumi_test_case_3);
4846 test_kasumi_encryption_test_case_4(void)
4848 return test_kasumi_encryption(&kasumi_test_case_4);
4852 test_kasumi_encryption_test_case_5(void)
4854 return test_kasumi_encryption(&kasumi_test_case_5);
4858 test_kasumi_decryption_test_case_1(void)
4860 return test_kasumi_decryption(&kasumi_test_case_1);
4864 test_kasumi_decryption_test_case_1_oop(void)
4866 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4870 test_kasumi_decryption_test_case_2(void)
4872 return test_kasumi_decryption(&kasumi_test_case_2);
4876 test_kasumi_decryption_test_case_3(void)
4878 return test_kasumi_decryption(&kasumi_test_case_3);
4882 test_kasumi_decryption_test_case_4(void)
4884 return test_kasumi_decryption(&kasumi_test_case_4);
4888 test_kasumi_decryption_test_case_5(void)
4890 return test_kasumi_decryption(&kasumi_test_case_5);
4893 test_snow3g_encryption_test_case_1(void)
4895 return test_snow3g_encryption(&snow3g_test_case_1);
4899 test_snow3g_encryption_test_case_1_oop(void)
4901 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4905 test_snow3g_encryption_test_case_1_oop_sgl(void)
4907 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4912 test_snow3g_encryption_test_case_1_offset_oop(void)
4914 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4918 test_snow3g_encryption_test_case_2(void)
4920 return test_snow3g_encryption(&snow3g_test_case_2);
4924 test_snow3g_encryption_test_case_3(void)
4926 return test_snow3g_encryption(&snow3g_test_case_3);
4930 test_snow3g_encryption_test_case_4(void)
4932 return test_snow3g_encryption(&snow3g_test_case_4);
4936 test_snow3g_encryption_test_case_5(void)
4938 return test_snow3g_encryption(&snow3g_test_case_5);
4942 test_snow3g_decryption_test_case_1(void)
4944 return test_snow3g_decryption(&snow3g_test_case_1);
4948 test_snow3g_decryption_test_case_1_oop(void)
4950 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4954 test_snow3g_decryption_test_case_2(void)
4956 return test_snow3g_decryption(&snow3g_test_case_2);
4960 test_snow3g_decryption_test_case_3(void)
4962 return test_snow3g_decryption(&snow3g_test_case_3);
4966 test_snow3g_decryption_test_case_4(void)
4968 return test_snow3g_decryption(&snow3g_test_case_4);
4972 test_snow3g_decryption_test_case_5(void)
4974 return test_snow3g_decryption(&snow3g_test_case_5);
4977 test_snow3g_cipher_auth_test_case_1(void)
4979 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4983 test_snow3g_auth_cipher_test_case_1(void)
4985 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4989 test_kasumi_auth_cipher_test_case_1(void)
4991 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4995 test_kasumi_cipher_auth_test_case_1(void)
4997 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5001 test_zuc_encryption_test_case_1(void)
5003 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5007 test_zuc_encryption_test_case_2(void)
5009 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5013 test_zuc_encryption_test_case_3(void)
5015 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5019 test_zuc_encryption_test_case_4(void)
5021 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5025 test_zuc_encryption_test_case_5(void)
5027 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5031 test_zuc_encryption_test_case_6_sgl(void)
5033 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5037 test_zuc_hash_generate_test_case_1(void)
5039 return test_zuc_authentication(&zuc_test_case_auth_1b);
5043 test_zuc_hash_generate_test_case_2(void)
5045 return test_zuc_authentication(&zuc_test_case_auth_90b);
5049 test_zuc_hash_generate_test_case_3(void)
5051 return test_zuc_authentication(&zuc_test_case_auth_577b);
5055 test_zuc_hash_generate_test_case_4(void)
5057 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5061 test_zuc_hash_generate_test_case_5(void)
5063 return test_zuc_authentication(&zuc_test_auth_5670b);
5067 test_zuc_hash_generate_test_case_6(void)
5069 return test_zuc_authentication(&zuc_test_case_auth_128b);
5073 test_zuc_hash_generate_test_case_7(void)
5075 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5079 test_zuc_hash_generate_test_case_8(void)
5081 return test_zuc_authentication(&zuc_test_case_auth_584b);
5085 test_zuc_cipher_auth_test_case_1(void)
5087 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5091 test_zuc_cipher_auth_test_case_2(void)
5093 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5097 test_3DES_chain_qat_all(void)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5102 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5103 ts_params->op_mpool,
5104 ts_params->session_mpool, ts_params->session_priv_mpool,
5105 ts_params->valid_devs[0],
5106 rte_cryptodev_driver_id_get(
5107 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5108 BLKCIPHER_3DES_CHAIN_TYPE);
5110 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5112 return TEST_SUCCESS;
5116 test_DES_cipheronly_qat_all(void)
5118 struct crypto_testsuite_params *ts_params = &testsuite_params;
5121 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5122 ts_params->op_mpool,
5123 ts_params->session_mpool, ts_params->session_priv_mpool,
5124 ts_params->valid_devs[0],
5125 rte_cryptodev_driver_id_get(
5126 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5127 BLKCIPHER_DES_CIPHERONLY_TYPE);
5129 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5131 return TEST_SUCCESS;
5135 test_DES_cipheronly_openssl_all(void)
5137 struct crypto_testsuite_params *ts_params = &testsuite_params;
5140 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5141 ts_params->op_mpool,
5142 ts_params->session_mpool, ts_params->session_priv_mpool,
5143 ts_params->valid_devs[0],
5144 rte_cryptodev_driver_id_get(
5145 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5146 BLKCIPHER_DES_CIPHERONLY_TYPE);
5148 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5150 return TEST_SUCCESS;
5154 test_DES_docsis_openssl_all(void)
5156 struct crypto_testsuite_params *ts_params = &testsuite_params;
5159 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5160 ts_params->op_mpool,
5161 ts_params->session_mpool, ts_params->session_priv_mpool,
5162 ts_params->valid_devs[0],
5163 rte_cryptodev_driver_id_get(
5164 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5165 BLKCIPHER_DES_DOCSIS_TYPE);
5167 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5169 return TEST_SUCCESS;
5173 test_DES_cipheronly_mb_all(void)
5175 struct crypto_testsuite_params *ts_params = &testsuite_params;
5178 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5179 ts_params->op_mpool,
5180 ts_params->session_mpool, ts_params->session_priv_mpool,
5181 ts_params->valid_devs[0],
5182 rte_cryptodev_driver_id_get(
5183 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5184 BLKCIPHER_DES_CIPHERONLY_TYPE);
5186 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5188 return TEST_SUCCESS;
5191 test_3DES_cipheronly_mb_all(void)
5193 struct crypto_testsuite_params *ts_params = &testsuite_params;
5196 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5197 ts_params->op_mpool,
5198 ts_params->session_mpool, ts_params->session_priv_mpool,
5199 ts_params->valid_devs[0],
5200 rte_cryptodev_driver_id_get(
5201 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5202 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5204 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5206 return TEST_SUCCESS;
5210 test_DES_docsis_mb_all(void)
5212 struct crypto_testsuite_params *ts_params = &testsuite_params;
5215 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5216 ts_params->op_mpool,
5217 ts_params->session_mpool, ts_params->session_priv_mpool,
5218 ts_params->valid_devs[0],
5219 rte_cryptodev_driver_id_get(
5220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5221 BLKCIPHER_DES_DOCSIS_TYPE);
5223 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5225 return TEST_SUCCESS;
5229 test_3DES_chain_caam_jr_all(void)
5231 struct crypto_testsuite_params *ts_params = &testsuite_params;
5234 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5235 ts_params->op_mpool,
5236 ts_params->session_mpool, ts_params->session_priv_mpool,
5237 ts_params->valid_devs[0],
5238 rte_cryptodev_driver_id_get(
5239 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5240 BLKCIPHER_3DES_CHAIN_TYPE);
5242 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5244 return TEST_SUCCESS;
5248 test_3DES_cipheronly_caam_jr_all(void)
5250 struct crypto_testsuite_params *ts_params = &testsuite_params;
5253 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5254 ts_params->op_mpool,
5255 ts_params->session_mpool, ts_params->session_priv_mpool,
5256 ts_params->valid_devs[0],
5257 rte_cryptodev_driver_id_get(
5258 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5259 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5261 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5263 return TEST_SUCCESS;
5267 test_3DES_chain_dpaa_sec_all(void)
5269 struct crypto_testsuite_params *ts_params = &testsuite_params;
5272 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5273 ts_params->op_mpool,
5274 ts_params->session_mpool, ts_params->session_priv_mpool,
5275 ts_params->valid_devs[0],
5276 rte_cryptodev_driver_id_get(
5277 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5278 BLKCIPHER_3DES_CHAIN_TYPE);
5280 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5282 return TEST_SUCCESS;
5286 test_3DES_cipheronly_dpaa_sec_all(void)
5288 struct crypto_testsuite_params *ts_params = &testsuite_params;
5291 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5292 ts_params->op_mpool,
5293 ts_params->session_mpool, ts_params->session_priv_mpool,
5294 ts_params->valid_devs[0],
5295 rte_cryptodev_driver_id_get(
5296 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5297 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5299 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5301 return TEST_SUCCESS;
5305 test_3DES_chain_dpaa2_sec_all(void)
5307 struct crypto_testsuite_params *ts_params = &testsuite_params;
5310 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5311 ts_params->op_mpool,
5312 ts_params->session_mpool, ts_params->session_priv_mpool,
5313 ts_params->valid_devs[0],
5314 rte_cryptodev_driver_id_get(
5315 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5316 BLKCIPHER_3DES_CHAIN_TYPE);
5318 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5320 return TEST_SUCCESS;
5324 test_3DES_cipheronly_dpaa2_sec_all(void)
5326 struct crypto_testsuite_params *ts_params = &testsuite_params;
5329 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5330 ts_params->op_mpool,
5331 ts_params->session_mpool, ts_params->session_priv_mpool,
5332 ts_params->valid_devs[0],
5333 rte_cryptodev_driver_id_get(
5334 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5335 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5337 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5339 return TEST_SUCCESS;
5343 test_3DES_chain_ccp_all(void)
5345 struct crypto_testsuite_params *ts_params = &testsuite_params;
5348 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5349 ts_params->op_mpool,
5350 ts_params->session_mpool, ts_params->session_priv_mpool,
5351 ts_params->valid_devs[0],
5352 rte_cryptodev_driver_id_get(
5353 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5354 BLKCIPHER_3DES_CHAIN_TYPE);
5356 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5358 return TEST_SUCCESS;
5362 test_3DES_cipheronly_ccp_all(void)
5364 struct crypto_testsuite_params *ts_params = &testsuite_params;
5367 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5368 ts_params->op_mpool,
5369 ts_params->session_mpool, ts_params->session_priv_mpool,
5370 ts_params->valid_devs[0],
5371 rte_cryptodev_driver_id_get(
5372 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5373 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5375 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5377 return TEST_SUCCESS;
5381 test_3DES_cipheronly_qat_all(void)
5383 struct crypto_testsuite_params *ts_params = &testsuite_params;
5386 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5387 ts_params->op_mpool,
5388 ts_params->session_mpool, ts_params->session_priv_mpool,
5389 ts_params->valid_devs[0],
5390 rte_cryptodev_driver_id_get(
5391 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5392 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5394 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5396 return TEST_SUCCESS;
5400 test_3DES_chain_openssl_all(void)
5402 struct crypto_testsuite_params *ts_params = &testsuite_params;
5405 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5406 ts_params->op_mpool,
5407 ts_params->session_mpool, ts_params->session_priv_mpool,
5408 ts_params->valid_devs[0],
5409 rte_cryptodev_driver_id_get(
5410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5411 BLKCIPHER_3DES_CHAIN_TYPE);
5413 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5415 return TEST_SUCCESS;
5419 test_3DES_cipheronly_openssl_all(void)
5421 struct crypto_testsuite_params *ts_params = &testsuite_params;
5424 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5425 ts_params->op_mpool,
5426 ts_params->session_mpool, ts_params->session_priv_mpool,
5427 ts_params->valid_devs[0],
5428 rte_cryptodev_driver_id_get(
5429 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5430 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5432 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5434 return TEST_SUCCESS;
5437 /* ***** AEAD algorithm Tests ***** */
5440 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5441 enum rte_crypto_aead_operation op,
5442 const uint8_t *key, const uint8_t key_len,
5443 const uint16_t aad_len, const uint8_t auth_len,
5446 uint8_t aead_key[key_len];
5448 struct crypto_testsuite_params *ts_params = &testsuite_params;
5449 struct crypto_unittest_params *ut_params = &unittest_params;
5451 memcpy(aead_key, key, key_len);
5453 /* Setup AEAD Parameters */
5454 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5455 ut_params->aead_xform.next = NULL;
5456 ut_params->aead_xform.aead.algo = algo;
5457 ut_params->aead_xform.aead.op = op;
5458 ut_params->aead_xform.aead.key.data = aead_key;
5459 ut_params->aead_xform.aead.key.length = key_len;
5460 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5461 ut_params->aead_xform.aead.iv.length = iv_len;
5462 ut_params->aead_xform.aead.digest_length = auth_len;
5463 ut_params->aead_xform.aead.aad_length = aad_len;
5465 debug_hexdump(stdout, "key:", key, key_len);
5467 /* Create Crypto session*/
5468 ut_params->sess = rte_cryptodev_sym_session_create(
5469 ts_params->session_mpool);
5471 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5472 &ut_params->aead_xform,
5473 ts_params->session_priv_mpool);
5475 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5481 create_aead_xform(struct rte_crypto_op *op,
5482 enum rte_crypto_aead_algorithm algo,
5483 enum rte_crypto_aead_operation aead_op,
5484 uint8_t *key, const uint8_t key_len,
5485 const uint8_t aad_len, const uint8_t auth_len,
5488 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5489 "failed to allocate space for crypto transform");
5491 struct rte_crypto_sym_op *sym_op = op->sym;
5493 /* Setup AEAD Parameters */
5494 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5495 sym_op->xform->next = NULL;
5496 sym_op->xform->aead.algo = algo;
5497 sym_op->xform->aead.op = aead_op;
5498 sym_op->xform->aead.key.data = key;
5499 sym_op->xform->aead.key.length = key_len;
5500 sym_op->xform->aead.iv.offset = IV_OFFSET;
5501 sym_op->xform->aead.iv.length = iv_len;
5502 sym_op->xform->aead.digest_length = auth_len;
5503 sym_op->xform->aead.aad_length = aad_len;
5505 debug_hexdump(stdout, "key:", key, key_len);
5511 create_aead_operation(enum rte_crypto_aead_operation op,
5512 const struct aead_test_data *tdata)
5514 struct crypto_testsuite_params *ts_params = &testsuite_params;
5515 struct crypto_unittest_params *ut_params = &unittest_params;
5517 uint8_t *plaintext, *ciphertext;
5518 unsigned int aad_pad_len, plaintext_pad_len;
5520 /* Generate Crypto op data structure */
5521 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5522 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5523 TEST_ASSERT_NOT_NULL(ut_params->op,
5524 "Failed to allocate symmetric crypto operation struct");
5526 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5528 /* Append aad data */
5529 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5530 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5531 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5533 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5534 "no room to append aad");
5536 sym_op->aead.aad.phys_addr =
5537 rte_pktmbuf_iova(ut_params->ibuf);
5538 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5539 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5540 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5543 /* Append IV at the end of the crypto operation*/
5544 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5545 uint8_t *, IV_OFFSET);
5547 /* Copy IV 1 byte after the IV pointer, according to the API */
5548 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5549 debug_hexdump(stdout, "iv:", iv_ptr,
5552 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5553 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5555 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5556 "no room to append aad");
5558 sym_op->aead.aad.phys_addr =
5559 rte_pktmbuf_iova(ut_params->ibuf);
5560 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5561 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5564 /* Append IV at the end of the crypto operation*/
5565 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5566 uint8_t *, IV_OFFSET);
5568 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5569 debug_hexdump(stdout, "iv:", iv_ptr,
5573 /* Append plaintext/ciphertext */
5574 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5575 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5576 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5578 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5580 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5581 debug_hexdump(stdout, "plaintext:", plaintext,
5582 tdata->plaintext.len);
5584 if (ut_params->obuf) {
5585 ciphertext = (uint8_t *)rte_pktmbuf_append(
5587 plaintext_pad_len + aad_pad_len);
5588 TEST_ASSERT_NOT_NULL(ciphertext,
5589 "no room to append ciphertext");
5591 memset(ciphertext + aad_pad_len, 0,
5592 tdata->ciphertext.len);
5595 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5596 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5598 TEST_ASSERT_NOT_NULL(ciphertext,
5599 "no room to append ciphertext");
5601 memcpy(ciphertext, tdata->ciphertext.data,
5602 tdata->ciphertext.len);
5603 debug_hexdump(stdout, "ciphertext:", ciphertext,
5604 tdata->ciphertext.len);
5606 if (ut_params->obuf) {
5607 plaintext = (uint8_t *)rte_pktmbuf_append(
5609 plaintext_pad_len + aad_pad_len);
5610 TEST_ASSERT_NOT_NULL(plaintext,
5611 "no room to append plaintext");
5613 memset(plaintext + aad_pad_len, 0,
5614 tdata->plaintext.len);
5618 /* Append digest data */
5619 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5620 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5621 ut_params->obuf ? ut_params->obuf :
5623 tdata->auth_tag.len);
5624 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5625 "no room to append digest");
5626 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5627 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5628 ut_params->obuf ? ut_params->obuf :
5633 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5634 ut_params->ibuf, tdata->auth_tag.len);
5635 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5636 "no room to append digest");
5637 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5639 plaintext_pad_len + aad_pad_len);
5641 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5642 tdata->auth_tag.len);
5643 debug_hexdump(stdout, "digest:",
5644 sym_op->aead.digest.data,
5645 tdata->auth_tag.len);
5648 sym_op->aead.data.length = tdata->plaintext.len;
5649 sym_op->aead.data.offset = aad_pad_len;
5655 test_authenticated_encryption(const struct aead_test_data *tdata)
5657 struct crypto_testsuite_params *ts_params = &testsuite_params;
5658 struct crypto_unittest_params *ut_params = &unittest_params;
5661 uint8_t *ciphertext, *auth_tag;
5662 uint16_t plaintext_pad_len;
5665 /* Create AEAD session */
5666 retval = create_aead_session(ts_params->valid_devs[0],
5668 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5669 tdata->key.data, tdata->key.len,
5670 tdata->aad.len, tdata->auth_tag.len,
5675 if (tdata->aad.len > MBUF_SIZE) {
5676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5677 /* Populate full size of add data */
5678 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5679 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5683 /* clear mbuf payload */
5684 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5685 rte_pktmbuf_tailroom(ut_params->ibuf));
5687 /* Create AEAD operation */
5688 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5692 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5694 ut_params->op->sym->m_src = ut_params->ibuf;
5696 /* Process crypto operation */
5697 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5698 ut_params->op), "failed to process sym crypto op");
5700 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5701 "crypto op processing failed");
5703 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5705 if (ut_params->op->sym->m_dst) {
5706 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5708 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5709 uint8_t *, plaintext_pad_len);
5711 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5713 ut_params->op->sym->cipher.data.offset);
5714 auth_tag = ciphertext + plaintext_pad_len;
5717 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5718 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5721 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5723 tdata->ciphertext.data,
5724 tdata->ciphertext.len,
5725 "Ciphertext data not as expected");
5727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5729 tdata->auth_tag.data,
5730 tdata->auth_tag.len,
5731 "Generated auth tag not as expected");
5738 test_AES_GCM_authenticated_encryption_test_case_1(void)
5740 return test_authenticated_encryption(&gcm_test_case_1);
5744 test_AES_GCM_authenticated_encryption_test_case_2(void)
5746 return test_authenticated_encryption(&gcm_test_case_2);
5750 test_AES_GCM_authenticated_encryption_test_case_3(void)
5752 return test_authenticated_encryption(&gcm_test_case_3);
5756 test_AES_GCM_authenticated_encryption_test_case_4(void)
5758 return test_authenticated_encryption(&gcm_test_case_4);
5762 test_AES_GCM_authenticated_encryption_test_case_5(void)
5764 return test_authenticated_encryption(&gcm_test_case_5);
5768 test_AES_GCM_authenticated_encryption_test_case_6(void)
5770 return test_authenticated_encryption(&gcm_test_case_6);
5774 test_AES_GCM_authenticated_encryption_test_case_7(void)
5776 return test_authenticated_encryption(&gcm_test_case_7);
5780 test_AES_GCM_auth_encryption_test_case_192_1(void)
5782 return test_authenticated_encryption(&gcm_test_case_192_1);
5786 test_AES_GCM_auth_encryption_test_case_192_2(void)
5788 return test_authenticated_encryption(&gcm_test_case_192_2);
5792 test_AES_GCM_auth_encryption_test_case_192_3(void)
5794 return test_authenticated_encryption(&gcm_test_case_192_3);
5798 test_AES_GCM_auth_encryption_test_case_192_4(void)
5800 return test_authenticated_encryption(&gcm_test_case_192_4);
5804 test_AES_GCM_auth_encryption_test_case_192_5(void)
5806 return test_authenticated_encryption(&gcm_test_case_192_5);
5810 test_AES_GCM_auth_encryption_test_case_192_6(void)
5812 return test_authenticated_encryption(&gcm_test_case_192_6);
5816 test_AES_GCM_auth_encryption_test_case_192_7(void)
5818 return test_authenticated_encryption(&gcm_test_case_192_7);
5822 test_AES_GCM_auth_encryption_test_case_256_1(void)
5824 return test_authenticated_encryption(&gcm_test_case_256_1);
5828 test_AES_GCM_auth_encryption_test_case_256_2(void)
5830 return test_authenticated_encryption(&gcm_test_case_256_2);
5834 test_AES_GCM_auth_encryption_test_case_256_3(void)
5836 return test_authenticated_encryption(&gcm_test_case_256_3);
5840 test_AES_GCM_auth_encryption_test_case_256_4(void)
5842 return test_authenticated_encryption(&gcm_test_case_256_4);
5846 test_AES_GCM_auth_encryption_test_case_256_5(void)
5848 return test_authenticated_encryption(&gcm_test_case_256_5);
5852 test_AES_GCM_auth_encryption_test_case_256_6(void)
5854 return test_authenticated_encryption(&gcm_test_case_256_6);
5858 test_AES_GCM_auth_encryption_test_case_256_7(void)
5860 return test_authenticated_encryption(&gcm_test_case_256_7);
5864 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5866 return test_authenticated_encryption(&gcm_test_case_aad_1);
5870 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5872 return test_authenticated_encryption(&gcm_test_case_aad_2);
5876 test_authenticated_decryption(const struct aead_test_data *tdata)
5878 struct crypto_testsuite_params *ts_params = &testsuite_params;
5879 struct crypto_unittest_params *ut_params = &unittest_params;
5885 /* Create AEAD session */
5886 retval = create_aead_session(ts_params->valid_devs[0],
5888 RTE_CRYPTO_AEAD_OP_DECRYPT,
5889 tdata->key.data, tdata->key.len,
5890 tdata->aad.len, tdata->auth_tag.len,
5895 /* alloc mbuf and set payload */
5896 if (tdata->aad.len > MBUF_SIZE) {
5897 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5898 /* Populate full size of add data */
5899 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5900 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5904 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5905 rte_pktmbuf_tailroom(ut_params->ibuf));
5907 /* Create AEAD operation */
5908 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5914 ut_params->op->sym->m_src = ut_params->ibuf;
5916 /* Process crypto operation */
5917 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5918 ut_params->op), "failed to process sym crypto op");
5920 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5921 "crypto op processing failed");
5923 if (ut_params->op->sym->m_dst)
5924 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5927 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5929 ut_params->op->sym->cipher.data.offset);
5931 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5934 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5936 tdata->plaintext.data,
5937 tdata->plaintext.len,
5938 "Plaintext data not as expected");
5940 TEST_ASSERT_EQUAL(ut_params->op->status,
5941 RTE_CRYPTO_OP_STATUS_SUCCESS,
5942 "Authentication failed");
5947 test_AES_GCM_authenticated_decryption_test_case_1(void)
5949 return test_authenticated_decryption(&gcm_test_case_1);
5953 test_AES_GCM_authenticated_decryption_test_case_2(void)
5955 return test_authenticated_decryption(&gcm_test_case_2);
5959 test_AES_GCM_authenticated_decryption_test_case_3(void)
5961 return test_authenticated_decryption(&gcm_test_case_3);
5965 test_AES_GCM_authenticated_decryption_test_case_4(void)
5967 return test_authenticated_decryption(&gcm_test_case_4);
5971 test_AES_GCM_authenticated_decryption_test_case_5(void)
5973 return test_authenticated_decryption(&gcm_test_case_5);
5977 test_AES_GCM_authenticated_decryption_test_case_6(void)
5979 return test_authenticated_decryption(&gcm_test_case_6);
5983 test_AES_GCM_authenticated_decryption_test_case_7(void)
5985 return test_authenticated_decryption(&gcm_test_case_7);
5989 test_AES_GCM_auth_decryption_test_case_192_1(void)
5991 return test_authenticated_decryption(&gcm_test_case_192_1);
5995 test_AES_GCM_auth_decryption_test_case_192_2(void)
5997 return test_authenticated_decryption(&gcm_test_case_192_2);
6001 test_AES_GCM_auth_decryption_test_case_192_3(void)
6003 return test_authenticated_decryption(&gcm_test_case_192_3);
6007 test_AES_GCM_auth_decryption_test_case_192_4(void)
6009 return test_authenticated_decryption(&gcm_test_case_192_4);
6013 test_AES_GCM_auth_decryption_test_case_192_5(void)
6015 return test_authenticated_decryption(&gcm_test_case_192_5);
6019 test_AES_GCM_auth_decryption_test_case_192_6(void)
6021 return test_authenticated_decryption(&gcm_test_case_192_6);
6025 test_AES_GCM_auth_decryption_test_case_192_7(void)
6027 return test_authenticated_decryption(&gcm_test_case_192_7);
6031 test_AES_GCM_auth_decryption_test_case_256_1(void)
6033 return test_authenticated_decryption(&gcm_test_case_256_1);
6037 test_AES_GCM_auth_decryption_test_case_256_2(void)
6039 return test_authenticated_decryption(&gcm_test_case_256_2);
6043 test_AES_GCM_auth_decryption_test_case_256_3(void)
6045 return test_authenticated_decryption(&gcm_test_case_256_3);
6049 test_AES_GCM_auth_decryption_test_case_256_4(void)
6051 return test_authenticated_decryption(&gcm_test_case_256_4);
6055 test_AES_GCM_auth_decryption_test_case_256_5(void)
6057 return test_authenticated_decryption(&gcm_test_case_256_5);
6061 test_AES_GCM_auth_decryption_test_case_256_6(void)
6063 return test_authenticated_decryption(&gcm_test_case_256_6);
6067 test_AES_GCM_auth_decryption_test_case_256_7(void)
6069 return test_authenticated_decryption(&gcm_test_case_256_7);
6073 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6075 return test_authenticated_decryption(&gcm_test_case_aad_1);
6079 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6081 return test_authenticated_decryption(&gcm_test_case_aad_2);
6085 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6087 struct crypto_testsuite_params *ts_params = &testsuite_params;
6088 struct crypto_unittest_params *ut_params = &unittest_params;
6091 uint8_t *ciphertext, *auth_tag;
6092 uint16_t plaintext_pad_len;
6094 /* Create AEAD session */
6095 retval = create_aead_session(ts_params->valid_devs[0],
6097 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6098 tdata->key.data, tdata->key.len,
6099 tdata->aad.len, tdata->auth_tag.len,
6104 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6105 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6107 /* clear mbuf payload */
6108 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6109 rte_pktmbuf_tailroom(ut_params->ibuf));
6110 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6111 rte_pktmbuf_tailroom(ut_params->obuf));
6113 /* Create AEAD operation */
6114 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6118 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6120 ut_params->op->sym->m_src = ut_params->ibuf;
6121 ut_params->op->sym->m_dst = ut_params->obuf;
6123 /* Process crypto operation */
6124 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6125 ut_params->op), "failed to process sym crypto op");
6127 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6128 "crypto op processing failed");
6130 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6132 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6133 ut_params->op->sym->cipher.data.offset);
6134 auth_tag = ciphertext + plaintext_pad_len;
6136 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6137 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6140 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6142 tdata->ciphertext.data,
6143 tdata->ciphertext.len,
6144 "Ciphertext data not as expected");
6146 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6148 tdata->auth_tag.data,
6149 tdata->auth_tag.len,
6150 "Generated auth tag not as expected");
6157 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6159 return test_authenticated_encryption_oop(&gcm_test_case_5);
6163 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6165 struct crypto_testsuite_params *ts_params = &testsuite_params;
6166 struct crypto_unittest_params *ut_params = &unittest_params;
6171 /* Create AEAD session */
6172 retval = create_aead_session(ts_params->valid_devs[0],
6174 RTE_CRYPTO_AEAD_OP_DECRYPT,
6175 tdata->key.data, tdata->key.len,
6176 tdata->aad.len, tdata->auth_tag.len,
6181 /* alloc mbuf and set payload */
6182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6183 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6185 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6186 rte_pktmbuf_tailroom(ut_params->ibuf));
6187 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6188 rte_pktmbuf_tailroom(ut_params->obuf));
6190 /* Create AEAD operation */
6191 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6195 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6197 ut_params->op->sym->m_src = ut_params->ibuf;
6198 ut_params->op->sym->m_dst = ut_params->obuf;
6200 /* Process crypto operation */
6201 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6202 ut_params->op), "failed to process sym crypto op");
6204 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6205 "crypto op processing failed");
6207 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6208 ut_params->op->sym->cipher.data.offset);
6210 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6213 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6215 tdata->plaintext.data,
6216 tdata->plaintext.len,
6217 "Plaintext data not as expected");
6219 TEST_ASSERT_EQUAL(ut_params->op->status,
6220 RTE_CRYPTO_OP_STATUS_SUCCESS,
6221 "Authentication failed");
6226 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6228 return test_authenticated_decryption_oop(&gcm_test_case_5);
6232 test_authenticated_encryption_sessionless(
6233 const struct aead_test_data *tdata)
6235 struct crypto_testsuite_params *ts_params = &testsuite_params;
6236 struct crypto_unittest_params *ut_params = &unittest_params;
6239 uint8_t *ciphertext, *auth_tag;
6240 uint16_t plaintext_pad_len;
6241 uint8_t key[tdata->key.len + 1];
6243 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6245 /* clear mbuf payload */
6246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6247 rte_pktmbuf_tailroom(ut_params->ibuf));
6249 /* Create AEAD operation */
6250 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6254 /* Create GCM xform */
6255 memcpy(key, tdata->key.data, tdata->key.len);
6256 retval = create_aead_xform(ut_params->op,
6258 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6259 key, tdata->key.len,
6260 tdata->aad.len, tdata->auth_tag.len,
6265 ut_params->op->sym->m_src = ut_params->ibuf;
6267 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6268 RTE_CRYPTO_OP_SESSIONLESS,
6269 "crypto op session type not sessionless");
6271 /* Process crypto operation */
6272 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6273 ut_params->op), "failed to process sym crypto op");
6275 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6277 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6278 "crypto op status not success");
6280 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6282 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6283 ut_params->op->sym->cipher.data.offset);
6284 auth_tag = ciphertext + plaintext_pad_len;
6286 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6287 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6290 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6292 tdata->ciphertext.data,
6293 tdata->ciphertext.len,
6294 "Ciphertext data not as expected");
6296 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6298 tdata->auth_tag.data,
6299 tdata->auth_tag.len,
6300 "Generated auth tag not as expected");
6307 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6309 return test_authenticated_encryption_sessionless(
6314 test_authenticated_decryption_sessionless(
6315 const struct aead_test_data *tdata)
6317 struct crypto_testsuite_params *ts_params = &testsuite_params;
6318 struct crypto_unittest_params *ut_params = &unittest_params;
6322 uint8_t key[tdata->key.len + 1];
6324 /* alloc mbuf and set payload */
6325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6328 rte_pktmbuf_tailroom(ut_params->ibuf));
6330 /* Create AEAD operation */
6331 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6335 /* Create AEAD xform */
6336 memcpy(key, tdata->key.data, tdata->key.len);
6337 retval = create_aead_xform(ut_params->op,
6339 RTE_CRYPTO_AEAD_OP_DECRYPT,
6340 key, tdata->key.len,
6341 tdata->aad.len, tdata->auth_tag.len,
6346 ut_params->op->sym->m_src = ut_params->ibuf;
6348 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6349 RTE_CRYPTO_OP_SESSIONLESS,
6350 "crypto op session type not sessionless");
6352 /* Process crypto operation */
6353 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6354 ut_params->op), "failed to process sym crypto op");
6356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6359 "crypto op status not success");
6361 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6362 ut_params->op->sym->cipher.data.offset);
6364 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6367 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6369 tdata->plaintext.data,
6370 tdata->plaintext.len,
6371 "Plaintext data not as expected");
6373 TEST_ASSERT_EQUAL(ut_params->op->status,
6374 RTE_CRYPTO_OP_STATUS_SUCCESS,
6375 "Authentication failed");
6380 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6382 return test_authenticated_decryption_sessionless(
6387 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6389 return test_authenticated_encryption(&ccm_test_case_128_1);
6393 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6395 return test_authenticated_encryption(&ccm_test_case_128_2);
6399 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6401 return test_authenticated_encryption(&ccm_test_case_128_3);
6405 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6407 return test_authenticated_decryption(&ccm_test_case_128_1);
6411 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6413 return test_authenticated_decryption(&ccm_test_case_128_2);
6417 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6419 return test_authenticated_decryption(&ccm_test_case_128_3);
6423 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6425 return test_authenticated_encryption(&ccm_test_case_192_1);
6429 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6431 return test_authenticated_encryption(&ccm_test_case_192_2);
6435 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6437 return test_authenticated_encryption(&ccm_test_case_192_3);
6441 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6443 return test_authenticated_decryption(&ccm_test_case_192_1);
6447 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6449 return test_authenticated_decryption(&ccm_test_case_192_2);
6453 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6455 return test_authenticated_decryption(&ccm_test_case_192_3);
6459 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6461 return test_authenticated_encryption(&ccm_test_case_256_1);
6465 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6467 return test_authenticated_encryption(&ccm_test_case_256_2);
6471 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6473 return test_authenticated_encryption(&ccm_test_case_256_3);
6477 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6479 return test_authenticated_decryption(&ccm_test_case_256_1);
6483 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6485 return test_authenticated_decryption(&ccm_test_case_256_2);
6489 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6491 return test_authenticated_decryption(&ccm_test_case_256_3);
6497 struct crypto_testsuite_params *ts_params = &testsuite_params;
6498 struct rte_cryptodev_stats stats;
6499 struct rte_cryptodev *dev;
6500 cryptodev_stats_get_t temp_pfn;
6502 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6503 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6504 &stats) == -ENODEV),
6505 "rte_cryptodev_stats_get invalid dev failed");
6506 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6507 "rte_cryptodev_stats_get invalid Param failed");
6508 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6509 temp_pfn = dev->dev_ops->stats_get;
6510 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6511 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6513 "rte_cryptodev_stats_get invalid Param failed");
6514 dev->dev_ops->stats_get = temp_pfn;
6516 /* Test expected values */
6518 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6520 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6522 "rte_cryptodev_stats_get failed");
6523 TEST_ASSERT((stats.enqueued_count == 1),
6524 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6525 TEST_ASSERT((stats.dequeued_count == 1),
6526 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6527 TEST_ASSERT((stats.enqueue_err_count == 0),
6528 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6529 TEST_ASSERT((stats.dequeue_err_count == 0),
6530 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6532 /* invalid device but should ignore and not reset device stats*/
6533 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6534 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6536 "rte_cryptodev_stats_get failed");
6537 TEST_ASSERT((stats.enqueued_count == 1),
6538 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6540 /* check that a valid reset clears stats */
6541 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6542 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6544 "rte_cryptodev_stats_get failed");
6545 TEST_ASSERT((stats.enqueued_count == 0),
6546 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6547 TEST_ASSERT((stats.dequeued_count == 0),
6548 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6550 return TEST_SUCCESS;
6553 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6554 struct crypto_unittest_params *ut_params,
6555 enum rte_crypto_auth_operation op,
6556 const struct HMAC_MD5_vector *test_case)
6560 memcpy(key, test_case->key.data, test_case->key.len);
6562 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6563 ut_params->auth_xform.next = NULL;
6564 ut_params->auth_xform.auth.op = op;
6566 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6568 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6569 ut_params->auth_xform.auth.key.length = test_case->key.len;
6570 ut_params->auth_xform.auth.key.data = key;
6572 ut_params->sess = rte_cryptodev_sym_session_create(
6573 ts_params->session_mpool);
6575 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6576 ut_params->sess, &ut_params->auth_xform,
6577 ts_params->session_priv_mpool);
6579 if (ut_params->sess == NULL)
6582 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6584 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6585 rte_pktmbuf_tailroom(ut_params->ibuf));
6590 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6591 const struct HMAC_MD5_vector *test_case,
6592 uint8_t **plaintext)
6594 uint16_t plaintext_pad_len;
6596 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6598 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6601 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6603 memcpy(*plaintext, test_case->plaintext.data,
6604 test_case->plaintext.len);
6606 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6607 ut_params->ibuf, MD5_DIGEST_LEN);
6608 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6609 "no room to append digest");
6610 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6611 ut_params->ibuf, plaintext_pad_len);
6613 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6614 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6615 test_case->auth_tag.len);
6618 sym_op->auth.data.offset = 0;
6619 sym_op->auth.data.length = test_case->plaintext.len;
6621 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6622 ut_params->op->sym->m_src = ut_params->ibuf;
6628 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6630 uint16_t plaintext_pad_len;
6631 uint8_t *plaintext, *auth_tag;
6633 struct crypto_testsuite_params *ts_params = &testsuite_params;
6634 struct crypto_unittest_params *ut_params = &unittest_params;
6636 if (MD5_HMAC_create_session(ts_params, ut_params,
6637 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6640 /* Generate Crypto op data structure */
6641 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6642 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6643 TEST_ASSERT_NOT_NULL(ut_params->op,
6644 "Failed to allocate symmetric crypto operation struct");
6646 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6649 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6652 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6653 ut_params->op), "failed to process sym crypto op");
6655 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6656 "crypto op processing failed");
6658 if (ut_params->op->sym->m_dst) {
6659 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6660 uint8_t *, plaintext_pad_len);
6662 auth_tag = plaintext + plaintext_pad_len;
6665 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6667 test_case->auth_tag.data,
6668 test_case->auth_tag.len,
6669 "HMAC_MD5 generated tag not as expected");
6671 return TEST_SUCCESS;
6675 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6679 struct crypto_testsuite_params *ts_params = &testsuite_params;
6680 struct crypto_unittest_params *ut_params = &unittest_params;
6682 if (MD5_HMAC_create_session(ts_params, ut_params,
6683 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6687 /* Generate Crypto op data structure */
6688 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6689 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6690 TEST_ASSERT_NOT_NULL(ut_params->op,
6691 "Failed to allocate symmetric crypto operation struct");
6693 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6696 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6697 ut_params->op), "failed to process sym crypto op");
6699 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6700 "HMAC_MD5 crypto op processing failed");
6702 return TEST_SUCCESS;
6706 test_MD5_HMAC_generate_case_1(void)
6708 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6712 test_MD5_HMAC_verify_case_1(void)
6714 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6718 test_MD5_HMAC_generate_case_2(void)
6720 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6724 test_MD5_HMAC_verify_case_2(void)
6726 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6730 test_multi_session(void)
6732 struct crypto_testsuite_params *ts_params = &testsuite_params;
6733 struct crypto_unittest_params *ut_params = &unittest_params;
6735 struct rte_cryptodev_info dev_info;
6736 struct rte_cryptodev_sym_session **sessions;
6740 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6741 aes_cbc_key, hmac_sha512_key);
6744 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6746 sessions = rte_malloc(NULL,
6747 (sizeof(struct rte_cryptodev_sym_session *) *
6748 MAX_NB_SESSIONS) + 1, 0);
6750 /* Create multiple crypto sessions*/
6751 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6753 sessions[i] = rte_cryptodev_sym_session_create(
6754 ts_params->session_mpool);
6756 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6757 sessions[i], &ut_params->auth_xform,
6758 ts_params->session_priv_mpool);
6759 TEST_ASSERT_NOT_NULL(sessions[i],
6760 "Session creation failed at session number %u",
6763 /* Attempt to send a request on each session */
6764 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6768 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6769 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6771 "Failed to perform decrypt on request number %u.", i);
6772 /* free crypto operation structure */
6774 rte_crypto_op_free(ut_params->op);
6777 * free mbuf - both obuf and ibuf are usually the same,
6778 * so check if they point at the same address is necessary,
6779 * to avoid freeing the mbuf twice.
6781 if (ut_params->obuf) {
6782 rte_pktmbuf_free(ut_params->obuf);
6783 if (ut_params->ibuf == ut_params->obuf)
6784 ut_params->ibuf = 0;
6785 ut_params->obuf = 0;
6787 if (ut_params->ibuf) {
6788 rte_pktmbuf_free(ut_params->ibuf);
6789 ut_params->ibuf = 0;
6793 /* Next session create should fail */
6794 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6795 sessions[i], &ut_params->auth_xform,
6796 ts_params->session_priv_mpool);
6797 TEST_ASSERT_NULL(sessions[i],
6798 "Session creation succeeded unexpectedly!");
6800 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6801 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6803 rte_cryptodev_sym_session_free(sessions[i]);
6808 return TEST_SUCCESS;
6811 struct multi_session_params {
6812 struct crypto_unittest_params ut_params;
6813 uint8_t *cipher_key;
6815 const uint8_t *cipher;
6816 const uint8_t *digest;
6820 #define MB_SESSION_NUMBER 3
6823 test_multi_session_random_usage(void)
6825 struct crypto_testsuite_params *ts_params = &testsuite_params;
6826 struct rte_cryptodev_info dev_info;
6827 struct rte_cryptodev_sym_session **sessions;
6829 struct multi_session_params ut_paramz[] = {
6832 .cipher_key = ms_aes_cbc_key0,
6833 .hmac_key = ms_hmac_key0,
6834 .cipher = ms_aes_cbc_cipher0,
6835 .digest = ms_hmac_digest0,
6836 .iv = ms_aes_cbc_iv0
6839 .cipher_key = ms_aes_cbc_key1,
6840 .hmac_key = ms_hmac_key1,
6841 .cipher = ms_aes_cbc_cipher1,
6842 .digest = ms_hmac_digest1,
6843 .iv = ms_aes_cbc_iv1
6846 .cipher_key = ms_aes_cbc_key2,
6847 .hmac_key = ms_hmac_key2,
6848 .cipher = ms_aes_cbc_cipher2,
6849 .digest = ms_hmac_digest2,
6850 .iv = ms_aes_cbc_iv2
6855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6857 sessions = rte_malloc(NULL,
6858 (sizeof(struct rte_cryptodev_sym_session *)
6859 * MAX_NB_SESSIONS) + 1, 0);
6861 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6862 sessions[i] = rte_cryptodev_sym_session_create(
6863 ts_params->session_mpool);
6865 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6866 sizeof(struct crypto_unittest_params));
6868 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6869 &ut_paramz[i].ut_params,
6870 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6872 /* Create multiple crypto sessions*/
6873 rte_cryptodev_sym_session_init(
6874 ts_params->valid_devs[0],
6876 &ut_paramz[i].ut_params.auth_xform,
6877 ts_params->session_priv_mpool);
6879 TEST_ASSERT_NOT_NULL(sessions[i],
6880 "Session creation failed at session number %u",
6886 for (i = 0; i < 40000; i++) {
6888 j = rand() % MB_SESSION_NUMBER;
6890 TEST_ASSERT_SUCCESS(
6891 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6893 &ut_paramz[j].ut_params,
6894 ts_params, ut_paramz[j].cipher,
6895 ut_paramz[j].digest,
6897 "Failed to perform decrypt on request number %u.", i);
6899 if (ut_paramz[j].ut_params.op)
6900 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6903 * free mbuf - both obuf and ibuf are usually the same,
6904 * so check if they point at the same address is necessary,
6905 * to avoid freeing the mbuf twice.
6907 if (ut_paramz[j].ut_params.obuf) {
6908 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6909 if (ut_paramz[j].ut_params.ibuf
6910 == ut_paramz[j].ut_params.obuf)
6911 ut_paramz[j].ut_params.ibuf = 0;
6912 ut_paramz[j].ut_params.obuf = 0;
6914 if (ut_paramz[j].ut_params.ibuf) {
6915 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6916 ut_paramz[j].ut_params.ibuf = 0;
6920 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6921 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6923 rte_cryptodev_sym_session_free(sessions[i]);
6928 return TEST_SUCCESS;
6932 test_null_cipher_only_operation(void)
6934 struct crypto_testsuite_params *ts_params = &testsuite_params;
6935 struct crypto_unittest_params *ut_params = &unittest_params;
6937 /* Generate test mbuf data and space for digest */
6938 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6939 catch_22_quote, QUOTE_512_BYTES, 0);
6941 /* Setup Cipher Parameters */
6942 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6943 ut_params->cipher_xform.next = NULL;
6945 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6946 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6948 ut_params->sess = rte_cryptodev_sym_session_create(
6949 ts_params->session_mpool);
6951 /* Create Crypto session*/
6952 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6954 &ut_params->cipher_xform,
6955 ts_params->session_priv_mpool);
6956 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6958 /* Generate Crypto op data structure */
6959 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6960 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6961 TEST_ASSERT_NOT_NULL(ut_params->op,
6962 "Failed to allocate symmetric crypto operation struct");
6964 /* Set crypto operation data parameters */
6965 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6967 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6969 /* set crypto operation source mbuf */
6970 sym_op->m_src = ut_params->ibuf;
6972 sym_op->cipher.data.offset = 0;
6973 sym_op->cipher.data.length = QUOTE_512_BYTES;
6975 /* Process crypto operation */
6976 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6978 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6980 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6981 "crypto operation processing failed");
6984 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6985 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6988 "Ciphertext data not as expected");
6990 return TEST_SUCCESS;
6992 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6993 0xab, 0xab, 0xab, 0xab,
6994 0xab, 0xab, 0xab, 0xab,
6995 0xab, 0xab, 0xab, 0xab};
6997 test_null_auth_only_operation(void)
6999 struct crypto_testsuite_params *ts_params = &testsuite_params;
7000 struct crypto_unittest_params *ut_params = &unittest_params;
7003 /* Generate test mbuf data and space for digest */
7004 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7005 catch_22_quote, QUOTE_512_BYTES, 0);
7007 /* create a pointer for digest, but don't expect anything to be written
7008 * here in a NULL auth algo so no mbuf append done.
7010 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7012 /* prefill the memory pointed to by digest */
7013 memcpy(digest, orig_data, sizeof(orig_data));
7015 /* Setup HMAC Parameters */
7016 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7017 ut_params->auth_xform.next = NULL;
7019 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7020 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7022 ut_params->sess = rte_cryptodev_sym_session_create(
7023 ts_params->session_mpool);
7025 /* Create Crypto session*/
7026 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7027 ut_params->sess, &ut_params->auth_xform,
7028 ts_params->session_priv_mpool);
7029 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7031 /* Generate Crypto op data structure */
7032 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7033 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7034 TEST_ASSERT_NOT_NULL(ut_params->op,
7035 "Failed to allocate symmetric crypto operation struct");
7037 /* Set crypto operation data parameters */
7038 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7040 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7042 sym_op->m_src = ut_params->ibuf;
7044 sym_op->auth.data.offset = 0;
7045 sym_op->auth.data.length = QUOTE_512_BYTES;
7046 sym_op->auth.digest.data = digest;
7047 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7050 /* Process crypto operation */
7051 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7053 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7055 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7056 "crypto operation processing failed");
7057 /* Make sure memory pointed to by digest hasn't been overwritten */
7058 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7062 "Memory at digest ptr overwritten unexpectedly");
7064 return TEST_SUCCESS;
7069 test_null_cipher_auth_operation(void)
7071 struct crypto_testsuite_params *ts_params = &testsuite_params;
7072 struct crypto_unittest_params *ut_params = &unittest_params;
7075 /* Generate test mbuf data and space for digest */
7076 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7077 catch_22_quote, QUOTE_512_BYTES, 0);
7079 /* create a pointer for digest, but don't expect anything to be written
7080 * here in a NULL auth algo so no mbuf append done.
7082 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7084 /* prefill the memory pointed to by digest */
7085 memcpy(digest, orig_data, sizeof(orig_data));
7087 /* Setup Cipher Parameters */
7088 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7089 ut_params->cipher_xform.next = &ut_params->auth_xform;
7091 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7092 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7094 /* Setup HMAC Parameters */
7095 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7096 ut_params->auth_xform.next = NULL;
7098 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7099 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7101 ut_params->sess = rte_cryptodev_sym_session_create(
7102 ts_params->session_mpool);
7104 /* Create Crypto session*/
7105 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7106 ut_params->sess, &ut_params->cipher_xform,
7107 ts_params->session_priv_mpool);
7108 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7110 /* Generate Crypto op data structure */
7111 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7112 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7113 TEST_ASSERT_NOT_NULL(ut_params->op,
7114 "Failed to allocate symmetric crypto operation struct");
7116 /* Set crypto operation data parameters */
7117 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7119 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7121 sym_op->m_src = ut_params->ibuf;
7123 sym_op->cipher.data.offset = 0;
7124 sym_op->cipher.data.length = QUOTE_512_BYTES;
7126 sym_op->auth.data.offset = 0;
7127 sym_op->auth.data.length = QUOTE_512_BYTES;
7128 sym_op->auth.digest.data = digest;
7129 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7132 /* Process crypto operation */
7133 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7135 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7137 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7138 "crypto operation processing failed");
7141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7142 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7145 "Ciphertext data not as expected");
7146 /* Make sure memory pointed to by digest hasn't been overwritten */
7147 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7151 "Memory at digest ptr overwritten unexpectedly");
7153 return TEST_SUCCESS;
7157 test_null_auth_cipher_operation(void)
7159 struct crypto_testsuite_params *ts_params = &testsuite_params;
7160 struct crypto_unittest_params *ut_params = &unittest_params;
7163 /* Generate test mbuf data */
7164 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7165 catch_22_quote, QUOTE_512_BYTES, 0);
7167 /* create a pointer for digest, but don't expect anything to be written
7168 * here in a NULL auth algo so no mbuf append done.
7170 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7172 /* prefill the memory pointed to by digest */
7173 memcpy(digest, orig_data, sizeof(orig_data));
7175 /* Setup Cipher Parameters */
7176 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7177 ut_params->cipher_xform.next = NULL;
7179 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7180 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7182 /* Setup HMAC Parameters */
7183 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7184 ut_params->auth_xform.next = &ut_params->cipher_xform;
7186 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7187 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7189 ut_params->sess = rte_cryptodev_sym_session_create(
7190 ts_params->session_mpool);
7192 /* Create Crypto session*/
7193 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7194 ut_params->sess, &ut_params->cipher_xform,
7195 ts_params->session_priv_mpool);
7196 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7198 /* Generate Crypto op data structure */
7199 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7200 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7201 TEST_ASSERT_NOT_NULL(ut_params->op,
7202 "Failed to allocate symmetric crypto operation struct");
7204 /* Set crypto operation data parameters */
7205 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7207 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7209 sym_op->m_src = ut_params->ibuf;
7211 sym_op->cipher.data.offset = 0;
7212 sym_op->cipher.data.length = QUOTE_512_BYTES;
7214 sym_op->auth.data.offset = 0;
7215 sym_op->auth.data.length = QUOTE_512_BYTES;
7216 sym_op->auth.digest.data = digest;
7217 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7220 /* Process crypto operation */
7221 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7223 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7225 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7226 "crypto operation processing failed");
7229 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7230 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7233 "Ciphertext data not as expected");
7234 /* Make sure memory pointed to by digest hasn't been overwritten */
7235 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7239 "Memory at digest ptr overwritten unexpectedly");
7241 return TEST_SUCCESS;
7246 test_null_invalid_operation(void)
7248 struct crypto_testsuite_params *ts_params = &testsuite_params;
7249 struct crypto_unittest_params *ut_params = &unittest_params;
7252 /* Setup Cipher Parameters */
7253 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7254 ut_params->cipher_xform.next = NULL;
7256 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7257 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7259 ut_params->sess = rte_cryptodev_sym_session_create(
7260 ts_params->session_mpool);
7262 /* Create Crypto session*/
7263 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7264 ut_params->sess, &ut_params->cipher_xform,
7265 ts_params->session_priv_mpool);
7266 TEST_ASSERT(ret < 0,
7267 "Session creation succeeded unexpectedly");
7270 /* Setup HMAC Parameters */
7271 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7272 ut_params->auth_xform.next = NULL;
7274 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7275 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7277 ut_params->sess = rte_cryptodev_sym_session_create(
7278 ts_params->session_mpool);
7280 /* Create Crypto session*/
7281 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7282 ut_params->sess, &ut_params->auth_xform,
7283 ts_params->session_priv_mpool);
7284 TEST_ASSERT(ret < 0,
7285 "Session creation succeeded unexpectedly");
7287 return TEST_SUCCESS;
7291 #define NULL_BURST_LENGTH (32)
7294 test_null_burst_operation(void)
7296 struct crypto_testsuite_params *ts_params = &testsuite_params;
7297 struct crypto_unittest_params *ut_params = &unittest_params;
7299 unsigned i, burst_len = NULL_BURST_LENGTH;
7301 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7302 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7304 /* Setup Cipher Parameters */
7305 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7306 ut_params->cipher_xform.next = &ut_params->auth_xform;
7308 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7309 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7311 /* Setup HMAC Parameters */
7312 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7313 ut_params->auth_xform.next = NULL;
7315 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7316 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7318 ut_params->sess = rte_cryptodev_sym_session_create(
7319 ts_params->session_mpool);
7321 /* Create Crypto session*/
7322 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7323 ut_params->sess, &ut_params->cipher_xform,
7324 ts_params->session_priv_mpool);
7325 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7327 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7328 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7329 burst_len, "failed to generate burst of crypto ops");
7331 /* Generate an operation for each mbuf in burst */
7332 for (i = 0; i < burst_len; i++) {
7333 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7335 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7337 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7341 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7343 burst[i]->sym->m_src = m;
7346 /* Process crypto operation */
7347 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7348 0, burst, burst_len),
7350 "Error enqueuing burst");
7352 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7353 0, burst_dequeued, burst_len),
7355 "Error dequeuing burst");
7358 for (i = 0; i < burst_len; i++) {
7360 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7361 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7363 "data not as expected");
7365 rte_pktmbuf_free(burst[i]->sym->m_src);
7366 rte_crypto_op_free(burst[i]);
7369 return TEST_SUCCESS;
7373 generate_gmac_large_plaintext(uint8_t *data)
7377 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7378 memcpy(&data[i], &data[0], 32);
7382 create_gmac_operation(enum rte_crypto_auth_operation op,
7383 const struct gmac_test_data *tdata)
7385 struct crypto_testsuite_params *ts_params = &testsuite_params;
7386 struct crypto_unittest_params *ut_params = &unittest_params;
7387 struct rte_crypto_sym_op *sym_op;
7389 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7391 /* Generate Crypto op data structure */
7392 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7393 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7394 TEST_ASSERT_NOT_NULL(ut_params->op,
7395 "Failed to allocate symmetric crypto operation struct");
7397 sym_op = ut_params->op->sym;
7399 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7400 ut_params->ibuf, tdata->gmac_tag.len);
7401 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7402 "no room to append digest");
7404 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7405 ut_params->ibuf, plaintext_pad_len);
7407 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7408 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7409 tdata->gmac_tag.len);
7410 debug_hexdump(stdout, "digest:",
7411 sym_op->auth.digest.data,
7412 tdata->gmac_tag.len);
7415 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7416 uint8_t *, IV_OFFSET);
7418 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7420 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7422 sym_op->cipher.data.length = 0;
7423 sym_op->cipher.data.offset = 0;
7425 sym_op->auth.data.offset = 0;
7426 sym_op->auth.data.length = tdata->plaintext.len;
7431 static int create_gmac_session(uint8_t dev_id,
7432 const struct gmac_test_data *tdata,
7433 enum rte_crypto_auth_operation auth_op)
7435 uint8_t auth_key[tdata->key.len];
7437 struct crypto_testsuite_params *ts_params = &testsuite_params;
7438 struct crypto_unittest_params *ut_params = &unittest_params;
7440 memcpy(auth_key, tdata->key.data, tdata->key.len);
7442 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7443 ut_params->auth_xform.next = NULL;
7445 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7446 ut_params->auth_xform.auth.op = auth_op;
7447 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7448 ut_params->auth_xform.auth.key.length = tdata->key.len;
7449 ut_params->auth_xform.auth.key.data = auth_key;
7450 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7451 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7454 ut_params->sess = rte_cryptodev_sym_session_create(
7455 ts_params->session_mpool);
7457 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7458 &ut_params->auth_xform,
7459 ts_params->session_priv_mpool);
7461 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7467 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7469 struct crypto_testsuite_params *ts_params = &testsuite_params;
7470 struct crypto_unittest_params *ut_params = &unittest_params;
7474 uint8_t *auth_tag, *plaintext;
7475 uint16_t plaintext_pad_len;
7477 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7478 "No GMAC length in the source data");
7480 retval = create_gmac_session(ts_params->valid_devs[0],
7481 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7486 if (tdata->plaintext.len > MBUF_SIZE)
7487 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7490 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7491 "Failed to allocate input buffer in mempool");
7493 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7494 rte_pktmbuf_tailroom(ut_params->ibuf));
7496 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7498 * Runtime generate the large plain text instead of use hard code
7499 * plain text vector. It is done to avoid create huge source file
7500 * with the test vector.
7502 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7503 generate_gmac_large_plaintext(tdata->plaintext.data);
7505 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7507 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7509 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7510 debug_hexdump(stdout, "plaintext:", plaintext,
7511 tdata->plaintext.len);
7513 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7521 ut_params->op->sym->m_src = ut_params->ibuf;
7523 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7524 ut_params->op), "failed to process sym crypto op");
7526 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7527 "crypto op processing failed");
7529 if (ut_params->op->sym->m_dst) {
7530 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7531 uint8_t *, plaintext_pad_len);
7533 auth_tag = plaintext + plaintext_pad_len;
7536 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7538 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7540 tdata->gmac_tag.data,
7541 tdata->gmac_tag.len,
7542 "GMAC Generated auth tag not as expected");
7548 test_AES_GMAC_authentication_test_case_1(void)
7550 return test_AES_GMAC_authentication(&gmac_test_case_1);
7554 test_AES_GMAC_authentication_test_case_2(void)
7556 return test_AES_GMAC_authentication(&gmac_test_case_2);
7560 test_AES_GMAC_authentication_test_case_3(void)
7562 return test_AES_GMAC_authentication(&gmac_test_case_3);
7566 test_AES_GMAC_authentication_test_case_4(void)
7568 return test_AES_GMAC_authentication(&gmac_test_case_4);
7572 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7574 struct crypto_testsuite_params *ts_params = &testsuite_params;
7575 struct crypto_unittest_params *ut_params = &unittest_params;
7577 uint32_t plaintext_pad_len;
7580 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7581 "No GMAC length in the source data");
7583 retval = create_gmac_session(ts_params->valid_devs[0],
7584 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7589 if (tdata->plaintext.len > MBUF_SIZE)
7590 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7592 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7593 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7594 "Failed to allocate input buffer in mempool");
7596 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7597 rte_pktmbuf_tailroom(ut_params->ibuf));
7599 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7602 * Runtime generate the large plain text instead of use hard code
7603 * plain text vector. It is done to avoid create huge source file
7604 * with the test vector.
7606 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7607 generate_gmac_large_plaintext(tdata->plaintext.data);
7609 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7611 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7613 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7614 debug_hexdump(stdout, "plaintext:", plaintext,
7615 tdata->plaintext.len);
7617 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7623 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7625 ut_params->op->sym->m_src = ut_params->ibuf;
7627 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7628 ut_params->op), "failed to process sym crypto op");
7630 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7631 "crypto op processing failed");
7638 test_AES_GMAC_authentication_verify_test_case_1(void)
7640 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7644 test_AES_GMAC_authentication_verify_test_case_2(void)
7646 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7650 test_AES_GMAC_authentication_verify_test_case_3(void)
7652 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7656 test_AES_GMAC_authentication_verify_test_case_4(void)
7658 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7661 struct test_crypto_vector {
7662 enum rte_crypto_cipher_algorithm crypto_algo;
7675 const uint8_t *data;
7680 const uint8_t *data;
7684 enum rte_crypto_auth_algorithm auth_algo;
7692 const uint8_t *data;
7702 static const struct test_crypto_vector
7703 hmac_sha1_test_crypto_vector = {
7704 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7706 .data = plaintext_hash,
7711 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7712 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7713 0xDE, 0xF4, 0xDE, 0xAD
7719 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7720 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7721 0x3F, 0x91, 0x64, 0x59
7727 static const struct test_crypto_vector
7728 aes128_gmac_test_vector = {
7729 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7731 .data = plaintext_hash,
7736 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7737 0x08, 0x09, 0x0A, 0x0B
7743 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7744 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7750 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7751 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7757 static const struct test_crypto_vector
7758 aes128cbc_hmac_sha1_test_vector = {
7759 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7762 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7763 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7769 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7770 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7775 .data = plaintext_hash,
7779 .data = ciphertext512_aes128cbc,
7782 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7785 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7786 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7787 0xDE, 0xF4, 0xDE, 0xAD
7793 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7794 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7795 0x18, 0x8C, 0x1D, 0x32
7802 data_corruption(uint8_t *data)
7808 tag_corruption(uint8_t *data, unsigned int tag_offset)
7810 data[tag_offset] += 1;
7814 create_auth_session(struct crypto_unittest_params *ut_params,
7816 const struct test_crypto_vector *reference,
7817 enum rte_crypto_auth_operation auth_op)
7819 struct crypto_testsuite_params *ts_params = &testsuite_params;
7820 uint8_t auth_key[reference->auth_key.len + 1];
7822 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7824 /* Setup Authentication Parameters */
7825 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7826 ut_params->auth_xform.auth.op = auth_op;
7827 ut_params->auth_xform.next = NULL;
7828 ut_params->auth_xform.auth.algo = reference->auth_algo;
7829 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7830 ut_params->auth_xform.auth.key.data = auth_key;
7831 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7833 /* Create Crypto session*/
7834 ut_params->sess = rte_cryptodev_sym_session_create(
7835 ts_params->session_mpool);
7837 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7838 &ut_params->auth_xform,
7839 ts_params->session_priv_mpool);
7841 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7847 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7849 const struct test_crypto_vector *reference,
7850 enum rte_crypto_auth_operation auth_op,
7851 enum rte_crypto_cipher_operation cipher_op)
7853 struct crypto_testsuite_params *ts_params = &testsuite_params;
7854 uint8_t cipher_key[reference->cipher_key.len + 1];
7855 uint8_t auth_key[reference->auth_key.len + 1];
7857 memcpy(cipher_key, reference->cipher_key.data,
7858 reference->cipher_key.len);
7859 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7861 /* Setup Authentication Parameters */
7862 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7863 ut_params->auth_xform.auth.op = auth_op;
7864 ut_params->auth_xform.auth.algo = reference->auth_algo;
7865 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7866 ut_params->auth_xform.auth.key.data = auth_key;
7867 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7869 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7870 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7871 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7873 ut_params->auth_xform.next = &ut_params->cipher_xform;
7875 /* Setup Cipher Parameters */
7876 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7877 ut_params->cipher_xform.next = NULL;
7878 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7879 ut_params->cipher_xform.cipher.op = cipher_op;
7880 ut_params->cipher_xform.cipher.key.data = cipher_key;
7881 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7882 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7883 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7886 /* Create Crypto session*/
7887 ut_params->sess = rte_cryptodev_sym_session_create(
7888 ts_params->session_mpool);
7890 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7891 &ut_params->auth_xform,
7892 ts_params->session_priv_mpool);
7894 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7900 create_auth_operation(struct crypto_testsuite_params *ts_params,
7901 struct crypto_unittest_params *ut_params,
7902 const struct test_crypto_vector *reference,
7903 unsigned int auth_generate)
7905 /* Generate Crypto op data structure */
7906 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7907 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7908 TEST_ASSERT_NOT_NULL(ut_params->op,
7909 "Failed to allocate pktmbuf offload");
7911 /* Set crypto operation data parameters */
7912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7914 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7916 /* set crypto operation source mbuf */
7917 sym_op->m_src = ut_params->ibuf;
7920 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7921 ut_params->ibuf, reference->digest.len);
7923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7924 "no room to append auth tag");
7926 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7927 ut_params->ibuf, reference->plaintext.len);
7930 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7932 memcpy(sym_op->auth.digest.data,
7933 reference->digest.data,
7934 reference->digest.len);
7936 debug_hexdump(stdout, "digest:",
7937 sym_op->auth.digest.data,
7938 reference->digest.len);
7940 sym_op->auth.data.length = reference->plaintext.len;
7941 sym_op->auth.data.offset = 0;
7947 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7948 struct crypto_unittest_params *ut_params,
7949 const struct test_crypto_vector *reference,
7950 unsigned int auth_generate)
7952 /* Generate Crypto op data structure */
7953 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7954 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7955 TEST_ASSERT_NOT_NULL(ut_params->op,
7956 "Failed to allocate pktmbuf offload");
7958 /* Set crypto operation data parameters */
7959 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7961 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7963 /* set crypto operation source mbuf */
7964 sym_op->m_src = ut_params->ibuf;
7967 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7968 ut_params->ibuf, reference->digest.len);
7970 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7971 "no room to append auth tag");
7973 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7974 ut_params->ibuf, reference->ciphertext.len);
7977 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7979 memcpy(sym_op->auth.digest.data,
7980 reference->digest.data,
7981 reference->digest.len);
7983 debug_hexdump(stdout, "digest:",
7984 sym_op->auth.digest.data,
7985 reference->digest.len);
7987 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7988 reference->iv.data, reference->iv.len);
7990 sym_op->cipher.data.length = 0;
7991 sym_op->cipher.data.offset = 0;
7993 sym_op->auth.data.length = reference->plaintext.len;
7994 sym_op->auth.data.offset = 0;
8000 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8001 struct crypto_unittest_params *ut_params,
8002 const struct test_crypto_vector *reference,
8003 unsigned int auth_generate)
8005 /* Generate Crypto op data structure */
8006 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8007 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8008 TEST_ASSERT_NOT_NULL(ut_params->op,
8009 "Failed to allocate pktmbuf offload");
8011 /* Set crypto operation data parameters */
8012 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8014 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8016 /* set crypto operation source mbuf */
8017 sym_op->m_src = ut_params->ibuf;
8020 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8021 ut_params->ibuf, reference->digest.len);
8023 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8024 "no room to append auth tag");
8026 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8027 ut_params->ibuf, reference->ciphertext.len);
8030 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8032 memcpy(sym_op->auth.digest.data,
8033 reference->digest.data,
8034 reference->digest.len);
8036 debug_hexdump(stdout, "digest:",
8037 sym_op->auth.digest.data,
8038 reference->digest.len);
8040 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8041 reference->iv.data, reference->iv.len);
8043 sym_op->cipher.data.length = reference->ciphertext.len;
8044 sym_op->cipher.data.offset = 0;
8046 sym_op->auth.data.length = reference->ciphertext.len;
8047 sym_op->auth.data.offset = 0;
8053 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8054 struct crypto_unittest_params *ut_params,
8055 const struct test_crypto_vector *reference)
8057 return create_auth_operation(ts_params, ut_params, reference, 0);
8061 create_auth_verify_GMAC_operation(
8062 struct crypto_testsuite_params *ts_params,
8063 struct crypto_unittest_params *ut_params,
8064 const struct test_crypto_vector *reference)
8066 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8070 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8071 struct crypto_unittest_params *ut_params,
8072 const struct test_crypto_vector *reference)
8074 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8078 test_authentication_verify_fail_when_data_corruption(
8079 struct crypto_testsuite_params *ts_params,
8080 struct crypto_unittest_params *ut_params,
8081 const struct test_crypto_vector *reference,
8082 unsigned int data_corrupted)
8088 /* Create session */
8089 retval = create_auth_session(ut_params,
8090 ts_params->valid_devs[0],
8092 RTE_CRYPTO_AUTH_OP_VERIFY);
8096 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8097 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8098 "Failed to allocate input buffer in mempool");
8100 /* clear mbuf payload */
8101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8102 rte_pktmbuf_tailroom(ut_params->ibuf));
8104 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8105 reference->plaintext.len);
8106 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8107 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8109 debug_hexdump(stdout, "plaintext:", plaintext,
8110 reference->plaintext.len);
8112 /* Create operation */
8113 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8119 data_corruption(plaintext);
8121 tag_corruption(plaintext, reference->plaintext.len);
8123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8126 TEST_ASSERT_EQUAL(ut_params->op->status,
8127 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8128 "authentication not failed");
8130 ut_params->obuf = ut_params->op->sym->m_src;
8131 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8137 test_authentication_verify_GMAC_fail_when_corruption(
8138 struct crypto_testsuite_params *ts_params,
8139 struct crypto_unittest_params *ut_params,
8140 const struct test_crypto_vector *reference,
8141 unsigned int data_corrupted)
8146 /* Create session */
8147 retval = create_auth_cipher_session(ut_params,
8148 ts_params->valid_devs[0],
8150 RTE_CRYPTO_AUTH_OP_VERIFY,
8151 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8157 "Failed to allocate input buffer in mempool");
8159 /* clear mbuf payload */
8160 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8161 rte_pktmbuf_tailroom(ut_params->ibuf));
8163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8164 reference->plaintext.len);
8165 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8166 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8168 debug_hexdump(stdout, "plaintext:", plaintext,
8169 reference->plaintext.len);
8171 /* Create operation */
8172 retval = create_auth_verify_GMAC_operation(ts_params,
8180 data_corruption(plaintext);
8182 tag_corruption(plaintext, reference->aad.len);
8184 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8186 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8187 TEST_ASSERT_EQUAL(ut_params->op->status,
8188 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8189 "authentication not failed");
8191 ut_params->obuf = ut_params->op->sym->m_src;
8192 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8198 test_authenticated_decryption_fail_when_corruption(
8199 struct crypto_testsuite_params *ts_params,
8200 struct crypto_unittest_params *ut_params,
8201 const struct test_crypto_vector *reference,
8202 unsigned int data_corrupted)
8206 uint8_t *ciphertext;
8208 /* Create session */
8209 retval = create_auth_cipher_session(ut_params,
8210 ts_params->valid_devs[0],
8212 RTE_CRYPTO_AUTH_OP_VERIFY,
8213 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8218 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8219 "Failed to allocate input buffer in mempool");
8221 /* clear mbuf payload */
8222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8223 rte_pktmbuf_tailroom(ut_params->ibuf));
8225 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8226 reference->ciphertext.len);
8227 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8228 memcpy(ciphertext, reference->ciphertext.data,
8229 reference->ciphertext.len);
8231 /* Create operation */
8232 retval = create_cipher_auth_verify_operation(ts_params,
8240 data_corruption(ciphertext);
8242 tag_corruption(ciphertext, reference->ciphertext.len);
8244 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8248 TEST_ASSERT_EQUAL(ut_params->op->status,
8249 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8250 "authentication not failed");
8252 ut_params->obuf = ut_params->op->sym->m_src;
8253 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8259 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8260 const struct aead_test_data *tdata,
8261 void *digest_mem, uint64_t digest_phys)
8263 struct crypto_testsuite_params *ts_params = &testsuite_params;
8264 struct crypto_unittest_params *ut_params = &unittest_params;
8266 const unsigned int auth_tag_len = tdata->auth_tag.len;
8267 const unsigned int iv_len = tdata->iv.len;
8268 unsigned int aad_len = tdata->aad.len;
8270 /* Generate Crypto op data structure */
8271 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8272 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8273 TEST_ASSERT_NOT_NULL(ut_params->op,
8274 "Failed to allocate symmetric crypto operation struct");
8276 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8278 sym_op->aead.digest.data = digest_mem;
8280 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8281 "no room to append digest");
8283 sym_op->aead.digest.phys_addr = digest_phys;
8285 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8286 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8288 debug_hexdump(stdout, "digest:",
8289 sym_op->aead.digest.data,
8293 /* Append aad data */
8294 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8295 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8296 uint8_t *, IV_OFFSET);
8298 /* Copy IV 1 byte after the IV pointer, according to the API */
8299 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8301 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8303 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8304 ut_params->ibuf, aad_len);
8305 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8306 "no room to prepend aad");
8307 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8310 memset(sym_op->aead.aad.data, 0, aad_len);
8311 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8312 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8314 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8315 debug_hexdump(stdout, "aad:",
8316 sym_op->aead.aad.data, aad_len);
8318 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8319 uint8_t *, IV_OFFSET);
8321 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8323 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8324 ut_params->ibuf, aad_len);
8325 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8326 "no room to prepend aad");
8327 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8330 memset(sym_op->aead.aad.data, 0, aad_len);
8331 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8333 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8334 debug_hexdump(stdout, "aad:",
8335 sym_op->aead.aad.data, aad_len);
8338 sym_op->aead.data.length = tdata->plaintext.len;
8339 sym_op->aead.data.offset = aad_len;
8344 #define SGL_MAX_NO 16
8347 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8348 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8350 struct crypto_testsuite_params *ts_params = &testsuite_params;
8351 struct crypto_unittest_params *ut_params = &unittest_params;
8352 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8355 int to_trn_tbl[SGL_MAX_NO];
8357 unsigned int trn_data = 0;
8358 uint8_t *plaintext, *ciphertext, *auth_tag;
8360 if (fragsz > tdata->plaintext.len)
8361 fragsz = tdata->plaintext.len;
8363 uint16_t plaintext_len = fragsz;
8364 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8366 if (fragsz_oop > tdata->plaintext.len)
8367 frag_size_oop = tdata->plaintext.len;
8370 void *digest_mem = NULL;
8372 uint32_t prepend_len = tdata->aad.len;
8374 if (tdata->plaintext.len % fragsz != 0) {
8375 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8378 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8383 * For out-op-place we need to alloc another mbuf
8386 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8387 rte_pktmbuf_append(ut_params->obuf,
8388 frag_size_oop + prepend_len);
8389 buf_oop = ut_params->obuf;
8392 /* Create AEAD session */
8393 retval = create_aead_session(ts_params->valid_devs[0],
8395 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8396 tdata->key.data, tdata->key.len,
8397 tdata->aad.len, tdata->auth_tag.len,
8402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8404 /* clear mbuf payload */
8405 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8406 rte_pktmbuf_tailroom(ut_params->ibuf));
8408 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8411 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8413 trn_data += plaintext_len;
8415 buf = ut_params->ibuf;
8418 * Loop until no more fragments
8421 while (trn_data < tdata->plaintext.len) {
8423 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8424 (tdata->plaintext.len - trn_data) : fragsz;
8426 to_trn_tbl[ecx++] = to_trn;
8428 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8431 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8432 rte_pktmbuf_tailroom(buf));
8435 if (oop && !fragsz_oop) {
8436 buf_last_oop = buf_oop->next =
8437 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8438 buf_oop = buf_oop->next;
8439 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8440 0, rte_pktmbuf_tailroom(buf_oop));
8441 rte_pktmbuf_append(buf_oop, to_trn);
8444 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8447 memcpy(plaintext, tdata->plaintext.data + trn_data,
8450 if (trn_data == tdata->plaintext.len) {
8453 digest_mem = rte_pktmbuf_append(buf_oop,
8454 tdata->auth_tag.len);
8456 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8457 tdata->auth_tag.len);
8461 uint64_t digest_phys = 0;
8463 ut_params->ibuf->nb_segs = segs;
8466 if (fragsz_oop && oop) {
8470 if (frag_size_oop == tdata->plaintext.len) {
8471 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8472 tdata->auth_tag.len);
8474 digest_phys = rte_pktmbuf_iova_offset(
8476 tdata->plaintext.len + prepend_len);
8479 trn_data = frag_size_oop;
8480 while (trn_data < tdata->plaintext.len) {
8483 (tdata->plaintext.len - trn_data <
8485 (tdata->plaintext.len - trn_data) :
8488 to_trn_tbl[ecx++] = to_trn;
8490 buf_last_oop = buf_oop->next =
8491 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8492 buf_oop = buf_oop->next;
8493 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8494 0, rte_pktmbuf_tailroom(buf_oop));
8495 rte_pktmbuf_append(buf_oop, to_trn);
8499 if (trn_data == tdata->plaintext.len) {
8500 digest_mem = rte_pktmbuf_append(buf_oop,
8501 tdata->auth_tag.len);
8505 ut_params->obuf->nb_segs = segs;
8509 * Place digest at the end of the last buffer
8512 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8513 if (oop && buf_last_oop)
8514 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8516 if (!digest_mem && !oop) {
8517 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8518 + tdata->auth_tag.len);
8519 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8520 tdata->plaintext.len);
8523 /* Create AEAD operation */
8524 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8525 tdata, digest_mem, digest_phys);
8530 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8532 ut_params->op->sym->m_src = ut_params->ibuf;
8534 ut_params->op->sym->m_dst = ut_params->obuf;
8536 /* Process crypto operation */
8537 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8538 ut_params->op), "failed to process sym crypto op");
8540 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8541 "crypto op processing failed");
8544 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8545 uint8_t *, prepend_len);
8547 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8548 uint8_t *, prepend_len);
8552 fragsz = fragsz_oop;
8554 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8556 tdata->ciphertext.data,
8558 "Ciphertext data not as expected");
8560 buf = ut_params->op->sym->m_src->next;
8562 buf = ut_params->op->sym->m_dst->next;
8564 unsigned int off = fragsz;
8568 ciphertext = rte_pktmbuf_mtod(buf,
8571 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8573 tdata->ciphertext.data + off,
8575 "Ciphertext data not as expected");
8577 off += to_trn_tbl[ecx++];
8581 auth_tag = digest_mem;
8582 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8584 tdata->auth_tag.data,
8585 tdata->auth_tag.len,
8586 "Generated auth tag not as expected");
8592 #define OUT_OF_PLACE 1
8595 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8597 return test_authenticated_encryption_SGL(
8598 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8602 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8604 return test_authenticated_encryption_SGL(
8605 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8609 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8611 return test_authenticated_encryption_SGL(
8612 &gcm_test_case_8, OUT_OF_PLACE, 400,
8613 gcm_test_case_8.plaintext.len);
8617 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8620 return test_authenticated_encryption_SGL(
8621 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8625 test_authentication_verify_fail_when_data_corrupted(
8626 struct crypto_testsuite_params *ts_params,
8627 struct crypto_unittest_params *ut_params,
8628 const struct test_crypto_vector *reference)
8630 return test_authentication_verify_fail_when_data_corruption(
8631 ts_params, ut_params, reference, 1);
8635 test_authentication_verify_fail_when_tag_corrupted(
8636 struct crypto_testsuite_params *ts_params,
8637 struct crypto_unittest_params *ut_params,
8638 const struct test_crypto_vector *reference)
8640 return test_authentication_verify_fail_when_data_corruption(
8641 ts_params, ut_params, reference, 0);
8645 test_authentication_verify_GMAC_fail_when_data_corrupted(
8646 struct crypto_testsuite_params *ts_params,
8647 struct crypto_unittest_params *ut_params,
8648 const struct test_crypto_vector *reference)
8650 return test_authentication_verify_GMAC_fail_when_corruption(
8651 ts_params, ut_params, reference, 1);
8655 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8656 struct crypto_testsuite_params *ts_params,
8657 struct crypto_unittest_params *ut_params,
8658 const struct test_crypto_vector *reference)
8660 return test_authentication_verify_GMAC_fail_when_corruption(
8661 ts_params, ut_params, reference, 0);
8665 test_authenticated_decryption_fail_when_data_corrupted(
8666 struct crypto_testsuite_params *ts_params,
8667 struct crypto_unittest_params *ut_params,
8668 const struct test_crypto_vector *reference)
8670 return test_authenticated_decryption_fail_when_corruption(
8671 ts_params, ut_params, reference, 1);
8675 test_authenticated_decryption_fail_when_tag_corrupted(
8676 struct crypto_testsuite_params *ts_params,
8677 struct crypto_unittest_params *ut_params,
8678 const struct test_crypto_vector *reference)
8680 return test_authenticated_decryption_fail_when_corruption(
8681 ts_params, ut_params, reference, 0);
8685 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8687 return test_authentication_verify_fail_when_data_corrupted(
8688 &testsuite_params, &unittest_params,
8689 &hmac_sha1_test_crypto_vector);
8693 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8695 return test_authentication_verify_fail_when_tag_corrupted(
8696 &testsuite_params, &unittest_params,
8697 &hmac_sha1_test_crypto_vector);
8701 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8703 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8704 &testsuite_params, &unittest_params,
8705 &aes128_gmac_test_vector);
8709 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8711 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8712 &testsuite_params, &unittest_params,
8713 &aes128_gmac_test_vector);
8717 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8719 return test_authenticated_decryption_fail_when_data_corrupted(
8722 &aes128cbc_hmac_sha1_test_vector);
8726 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8728 return test_authenticated_decryption_fail_when_tag_corrupted(
8731 &aes128cbc_hmac_sha1_test_vector);
8734 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8736 /* global AESNI slave IDs for the scheduler test */
8737 uint8_t aesni_ids[2];
8740 test_scheduler_attach_slave_op(void)
8742 struct crypto_testsuite_params *ts_params = &testsuite_params;
8743 uint8_t sched_id = ts_params->valid_devs[0];
8744 uint32_t nb_devs, i, nb_devs_attached = 0;
8748 /* create 2 AESNI_MB if necessary */
8749 nb_devs = rte_cryptodev_device_count_by_driver(
8750 rte_cryptodev_driver_id_get(
8751 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8753 for (i = nb_devs; i < 2; i++) {
8754 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8755 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8757 ret = rte_vdev_init(vdev_name, NULL);
8759 TEST_ASSERT(ret == 0,
8760 "Failed to create instance %u of"
8762 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8766 /* attach 2 AESNI_MB cdevs */
8767 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8769 struct rte_cryptodev_info info;
8770 unsigned int session_size;
8772 rte_cryptodev_info_get(i, &info);
8773 if (info.driver_id != rte_cryptodev_driver_id_get(
8774 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8777 session_size = rte_cryptodev_sym_get_private_session_size(i);
8779 * Create the session mempool again, since now there are new devices
8780 * to use the mempool.
8782 if (ts_params->session_mpool) {
8783 rte_mempool_free(ts_params->session_mpool);
8784 ts_params->session_mpool = NULL;
8786 if (ts_params->session_priv_mpool) {
8787 rte_mempool_free(ts_params->session_priv_mpool);
8788 ts_params->session_priv_mpool = NULL;
8791 if (info.sym.max_nb_sessions != 0 &&
8792 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8794 "Device does not support "
8795 "at least %u sessions\n",
8800 * Create mempool with maximum number of sessions,
8801 * to include the session headers
8803 if (ts_params->session_mpool == NULL) {
8804 ts_params->session_mpool =
8805 rte_cryptodev_sym_session_pool_create(
8807 MAX_NB_SESSIONS, 0, 0, 0,
8809 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8810 "session mempool allocation failed");
8814 * Create mempool with maximum number of sessions,
8815 * to include device specific session private data
8817 if (ts_params->session_priv_mpool == NULL) {
8818 ts_params->session_priv_mpool = rte_mempool_create(
8819 "test_sess_mp_priv",
8822 0, 0, NULL, NULL, NULL,
8823 NULL, SOCKET_ID_ANY,
8826 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8827 "session mempool allocation failed");
8830 ts_params->qp_conf.mp_session = ts_params->session_mpool;
8831 ts_params->qp_conf.mp_session_private =
8832 ts_params->session_priv_mpool;
8834 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8837 TEST_ASSERT(ret == 0,
8838 "Failed to attach device %u of pmd : %s", i,
8839 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8841 aesni_ids[nb_devs_attached] = (uint8_t)i;
8850 test_scheduler_detach_slave_op(void)
8852 struct crypto_testsuite_params *ts_params = &testsuite_params;
8853 uint8_t sched_id = ts_params->valid_devs[0];
8857 for (i = 0; i < 2; i++) {
8858 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8860 TEST_ASSERT(ret == 0,
8861 "Failed to detach device %u", aesni_ids[i]);
8868 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8870 struct crypto_testsuite_params *ts_params = &testsuite_params;
8871 uint8_t sched_id = ts_params->valid_devs[0];
8873 return rte_cryptodev_scheduler_mode_set(sched_id,
8878 test_scheduler_mode_roundrobin_op(void)
8880 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8881 0, "Failed to set roundrobin mode");
8887 test_scheduler_mode_multicore_op(void)
8889 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8890 0, "Failed to set multicore mode");
8896 test_scheduler_mode_failover_op(void)
8898 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8899 0, "Failed to set failover mode");
8905 test_scheduler_mode_pkt_size_distr_op(void)
8907 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8908 0, "Failed to set pktsize mode");
8913 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8914 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8915 .setup = testsuite_setup,
8916 .teardown = testsuite_teardown,
8917 .unit_test_cases = {
8919 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8920 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_chain_scheduler_all),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_cipheronly_scheduler_all),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_authonly_scheduler_all),
8927 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8930 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8931 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_AES_chain_scheduler_all),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_AES_cipheronly_scheduler_all),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_authonly_scheduler_all),
8938 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8941 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8942 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_AES_chain_scheduler_all),
8945 TEST_CASE_ST(ut_setup, ut_teardown,
8946 test_AES_cipheronly_scheduler_all),
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 test_authonly_scheduler_all),
8949 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8952 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8953 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_AES_chain_scheduler_all),
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_AES_cipheronly_scheduler_all),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_authonly_scheduler_all),
8960 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8962 TEST_CASES_END() /**< NULL terminate unit test array */
8966 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8968 static struct unit_test_suite cryptodev_qat_testsuite = {
8969 .suite_name = "Crypto QAT Unit Test Suite",
8970 .setup = testsuite_setup,
8971 .teardown = testsuite_teardown,
8972 .unit_test_cases = {
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_device_configure_invalid_dev_id),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_device_configure_invalid_queue_pair_ids),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_queue_pair_descriptor_setup),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_multi_session),
8982 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_cipheronly_qat_all),
8985 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_3DES_cipheronly_qat_all),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_DES_cipheronly_qat_all),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_docsis_qat_all),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_DES_docsis_qat_all),
8994 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8995 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8997 /** AES CCM Authenticated Encryption 128 bits key */
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_CCM_authenticated_encryption_test_case_128_1),
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_CCM_authenticated_encryption_test_case_128_2),
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_CCM_authenticated_encryption_test_case_128_3),
9005 /** AES CCM Authenticated Decryption 128 bits key*/
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_CCM_authenticated_decryption_test_case_128_1),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_CCM_authenticated_decryption_test_case_128_2),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_CCM_authenticated_decryption_test_case_128_3),
9013 /** AES GCM Authenticated Encryption */
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_authenticated_encryption_test_case_1),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_authenticated_encryption_test_case_2),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_authenticated_encryption_test_case_3),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_authenticated_encryption_test_case_4),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_authenticated_encryption_test_case_5),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_authenticated_encryption_test_case_6),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_authenticated_encryption_test_case_7),
9035 /** AES GCM Authenticated Decryption */
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_authenticated_decryption_test_case_1),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_authenticated_decryption_test_case_2),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_authenticated_decryption_test_case_3),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_authenticated_decryption_test_case_4),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_authenticated_decryption_test_case_5),
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_authenticated_decryption_test_case_6),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_authenticated_decryption_test_case_7),
9051 /** AES GCM Authenticated Encryption 192 bits key */
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_encryption_test_case_192_1),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_encryption_test_case_192_2),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_auth_encryption_test_case_192_3),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_encryption_test_case_192_4),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_auth_encryption_test_case_192_5),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GCM_auth_encryption_test_case_192_6),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GCM_auth_encryption_test_case_192_7),
9067 /** AES GCM Authenticated Decryption 192 bits key */
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_auth_decryption_test_case_192_1),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_auth_decryption_test_case_192_2),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_auth_decryption_test_case_192_3),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GCM_auth_decryption_test_case_192_4),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GCM_auth_decryption_test_case_192_5),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GCM_auth_decryption_test_case_192_6),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_auth_decryption_test_case_192_7),
9083 /** AES GCM Authenticated Encryption 256 bits key */
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_auth_encryption_test_case_256_1),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_auth_encryption_test_case_256_2),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GCM_auth_encryption_test_case_256_3),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_GCM_auth_encryption_test_case_256_4),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_GCM_auth_encryption_test_case_256_5),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_auth_encryption_test_case_256_6),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_auth_encryption_test_case_256_7),
9099 /** AES GMAC Authentication */
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GMAC_authentication_test_case_1),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GMAC_authentication_verify_test_case_1),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GMAC_authentication_test_case_2),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GMAC_authentication_verify_test_case_2),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GMAC_authentication_test_case_3),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GMAC_authentication_verify_test_case_3),
9113 /** SNOW 3G encrypt only (UEA2) */
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_snow3g_encryption_test_case_1),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_snow3g_encryption_test_case_2),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_snow3g_encryption_test_case_3),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_snow3g_encryption_test_case_4),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_snow3g_encryption_test_case_5),
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_snow3g_encryption_test_case_1_oop),
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_snow3g_decryption_test_case_1_oop),
9130 /** SNOW 3G decrypt only (UEA2) */
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_snow3g_decryption_test_case_1),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_snow3g_decryption_test_case_2),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_snow3g_decryption_test_case_3),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_snow3g_decryption_test_case_4),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_snow3g_decryption_test_case_5),
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_snow3g_hash_generate_test_case_1),
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_snow3g_hash_generate_test_case_2),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_snow3g_hash_generate_test_case_3),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_snow3g_hash_verify_test_case_1),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_snow3g_hash_verify_test_case_2),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_snow3g_hash_verify_test_case_3),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_snow3g_cipher_auth_test_case_1),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_snow3g_auth_cipher_test_case_1),
9158 /** ZUC encrypt only (EEA3) */
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_zuc_encryption_test_case_1),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_zuc_encryption_test_case_2),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_zuc_encryption_test_case_3),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_zuc_encryption_test_case_4),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_zuc_encryption_test_case_5),
9170 /** ZUC authenticate (EIA3) */
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_zuc_hash_generate_test_case_6),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_zuc_hash_generate_test_case_7),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_zuc_hash_generate_test_case_8),
9178 /** ZUC alg-chain (EEA3/EIA3) */
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_zuc_cipher_auth_test_case_1),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_zuc_cipher_auth_test_case_2),
9184 /** HMAC_MD5 Authentication */
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_MD5_HMAC_generate_case_1),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_MD5_HMAC_verify_case_1),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_MD5_HMAC_generate_case_2),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_MD5_HMAC_verify_case_2),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_null_auth_only_operation),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_null_cipher_only_operation),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_null_cipher_auth_operation),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_null_auth_cipher_operation),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_kasumi_hash_generate_test_case_1),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_kasumi_hash_generate_test_case_2),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_kasumi_hash_generate_test_case_3),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_kasumi_hash_generate_test_case_4),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_kasumi_hash_generate_test_case_5),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_kasumi_hash_generate_test_case_6),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_kasumi_hash_verify_test_case_1),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_kasumi_hash_verify_test_case_2),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_kasumi_hash_verify_test_case_3),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_kasumi_hash_verify_test_case_4),
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_kasumi_hash_verify_test_case_5),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_kasumi_encryption_test_case_1),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_kasumi_encryption_test_case_3),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_kasumi_auth_cipher_test_case_1),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_kasumi_cipher_auth_test_case_1),
9238 /** Negative tests */
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 authentication_verify_AES128_GMAC_fail_data_corrupt),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9252 TEST_CASES_END() /**< NULL terminate unit test array */
9256 static struct unit_test_suite cryptodev_virtio_testsuite = {
9257 .suite_name = "Crypto VIRTIO Unit Test Suite",
9258 .setup = testsuite_setup,
9259 .teardown = testsuite_teardown,
9260 .unit_test_cases = {
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_AES_cipheronly_virtio_all),
9264 TEST_CASES_END() /**< NULL terminate unit test array */
9268 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9269 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9270 .setup = testsuite_setup,
9271 .teardown = testsuite_teardown,
9272 .unit_test_cases = {
9273 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_GCM_authenticated_encryption_test_case_1),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_AES_GCM_authenticated_encryption_test_case_2),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_AES_GCM_authenticated_encryption_test_case_3),
9280 TEST_CASE_ST(ut_setup, ut_teardown,
9281 test_AES_GCM_authenticated_encryption_test_case_4),
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_authenticated_encryption_test_case_5),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_authenticated_encryption_test_case_6),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_authenticated_encryption_test_case_7),
9289 /** AES GCM Authenticated Decryption */
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_authenticated_decryption_test_case_1),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_authenticated_decryption_test_case_2),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_authenticated_decryption_test_case_3),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_AES_GCM_authenticated_decryption_test_case_4),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_authenticated_decryption_test_case_5),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_authenticated_decryption_test_case_6),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_authenticated_decryption_test_case_7),
9305 /** AES GCM Authenticated Encryption 192 bits key */
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_auth_encryption_test_case_192_1),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_auth_encryption_test_case_192_2),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_auth_encryption_test_case_192_3),
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_AES_GCM_auth_encryption_test_case_192_4),
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_auth_encryption_test_case_192_5),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_encryption_test_case_192_6),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_encryption_test_case_192_7),
9321 /** AES GCM Authenticated Decryption 192 bits key */
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_decryption_test_case_192_1),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_decryption_test_case_192_2),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_decryption_test_case_192_3),
9328 TEST_CASE_ST(ut_setup, ut_teardown,
9329 test_AES_GCM_auth_decryption_test_case_192_4),
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_decryption_test_case_192_5),
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_auth_decryption_test_case_192_6),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_decryption_test_case_192_7),
9337 /** AES GCM Authenticated Encryption 256 bits key */
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_encryption_test_case_256_1),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_auth_encryption_test_case_256_2),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_auth_encryption_test_case_256_3),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GCM_auth_encryption_test_case_256_4),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_auth_encryption_test_case_256_5),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_auth_encryption_test_case_256_6),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_auth_encryption_test_case_256_7),
9353 /** AES GCM Authenticated Decryption 256 bits key */
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_auth_decryption_test_case_256_1),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_GCM_auth_decryption_test_case_256_2),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_auth_decryption_test_case_256_3),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_GCM_auth_decryption_test_case_256_4),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_auth_decryption_test_case_256_5),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_auth_decryption_test_case_256_6),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_auth_decryption_test_case_256_7),
9369 /** AES GCM Authenticated Encryption big aad size */
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_auth_encryption_test_case_aad_1),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_AES_GCM_auth_encryption_test_case_aad_2),
9375 /** AES GCM Authenticated Decryption big aad size */
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GCM_auth_decryption_test_case_aad_1),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GCM_auth_decryption_test_case_aad_2),
9381 /** Session-less tests */
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9387 /** AES GMAC Authentication */
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_AES_GMAC_authentication_test_case_1),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_GMAC_authentication_verify_test_case_1),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_AES_GMAC_authentication_test_case_2),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GMAC_authentication_verify_test_case_2),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GMAC_authentication_test_case_3),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GMAC_authentication_verify_test_case_3),
9400 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9402 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9403 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9404 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9405 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_DES_cipheronly_mb_all),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_DES_docsis_mb_all),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_3DES_cipheronly_mb_all),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_CCM_authenticated_encryption_test_case_128_1),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_CCM_authenticated_decryption_test_case_128_1),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_CCM_authenticated_encryption_test_case_128_2),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_CCM_authenticated_decryption_test_case_128_2),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_CCM_authenticated_encryption_test_case_128_3),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_CCM_authenticated_decryption_test_case_128_3),
9425 TEST_CASES_END() /**< NULL terminate unit test array */
9429 static struct unit_test_suite cryptodev_openssl_testsuite = {
9430 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9431 .setup = testsuite_setup,
9432 .teardown = testsuite_teardown,
9433 .unit_test_cases = {
9434 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_multi_session_random_usage),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_AES_chain_openssl_all),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_AES_cipheronly_openssl_all),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_3DES_chain_openssl_all),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_3DES_cipheronly_openssl_all),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_DES_cipheronly_openssl_all),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_DES_docsis_openssl_all),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_authonly_openssl_all),
9452 /** AES GCM Authenticated Encryption */
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_AES_GCM_authenticated_encryption_test_case_1),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_AES_GCM_authenticated_encryption_test_case_2),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_AES_GCM_authenticated_encryption_test_case_3),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_AES_GCM_authenticated_encryption_test_case_4),
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_AES_GCM_authenticated_encryption_test_case_5),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_AES_GCM_authenticated_encryption_test_case_6),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_AES_GCM_authenticated_encryption_test_case_7),
9468 /** AES GCM Authenticated Decryption */
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_AES_GCM_authenticated_decryption_test_case_1),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_AES_GCM_authenticated_decryption_test_case_2),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_AES_GCM_authenticated_decryption_test_case_3),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_AES_GCM_authenticated_decryption_test_case_4),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_AES_GCM_authenticated_decryption_test_case_5),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_AES_GCM_authenticated_decryption_test_case_6),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_AES_GCM_authenticated_decryption_test_case_7),
9485 /** AES GCM Authenticated Encryption 192 bits key */
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_auth_encryption_test_case_192_1),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_GCM_auth_encryption_test_case_192_2),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_auth_encryption_test_case_192_3),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_GCM_auth_encryption_test_case_192_4),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_AES_GCM_auth_encryption_test_case_192_5),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GCM_auth_encryption_test_case_192_6),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GCM_auth_encryption_test_case_192_7),
9501 /** AES GCM Authenticated Decryption 192 bits key */
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GCM_auth_decryption_test_case_192_1),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_auth_decryption_test_case_192_2),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_AES_GCM_auth_decryption_test_case_192_3),
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_AES_GCM_auth_decryption_test_case_192_4),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_AES_GCM_auth_decryption_test_case_192_5),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_GCM_auth_decryption_test_case_192_6),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_AES_GCM_auth_decryption_test_case_192_7),
9517 /** AES GCM Authenticated Encryption 256 bits key */
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_AES_GCM_auth_encryption_test_case_256_1),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_AES_GCM_auth_encryption_test_case_256_2),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_AES_GCM_auth_encryption_test_case_256_3),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_AES_GCM_auth_encryption_test_case_256_4),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_AES_GCM_auth_encryption_test_case_256_5),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_AES_GCM_auth_encryption_test_case_256_6),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_AES_GCM_auth_encryption_test_case_256_7),
9533 /** AES GCM Authenticated Decryption 256 bits key */
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_AES_GCM_auth_decryption_test_case_256_1),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_AES_GCM_auth_decryption_test_case_256_2),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_AES_GCM_auth_decryption_test_case_256_3),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_AES_GCM_auth_decryption_test_case_256_4),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_AES_GCM_auth_decryption_test_case_256_5),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_AES_GCM_auth_decryption_test_case_256_6),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_AES_GCM_auth_decryption_test_case_256_7),
9549 /** AES GMAC Authentication */
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_AES_GMAC_authentication_test_case_1),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_AES_GMAC_authentication_verify_test_case_1),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_GMAC_authentication_test_case_2),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_AES_GMAC_authentication_verify_test_case_2),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_GMAC_authentication_test_case_3),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GMAC_authentication_verify_test_case_3),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_AES_GMAC_authentication_test_case_4),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_AES_GMAC_authentication_verify_test_case_4),
9567 /** AES CCM Authenticated Encryption 128 bits key */
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_AES_CCM_authenticated_encryption_test_case_128_1),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_AES_CCM_authenticated_encryption_test_case_128_2),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 test_AES_CCM_authenticated_encryption_test_case_128_3),
9575 /** AES CCM Authenticated Decryption 128 bits key*/
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_CCM_authenticated_decryption_test_case_128_1),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 test_AES_CCM_authenticated_decryption_test_case_128_2),
9580 TEST_CASE_ST(ut_setup, ut_teardown,
9581 test_AES_CCM_authenticated_decryption_test_case_128_3),
9583 /** AES CCM Authenticated Encryption 192 bits key */
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_AES_CCM_authenticated_encryption_test_case_192_1),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_CCM_authenticated_encryption_test_case_192_2),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_CCM_authenticated_encryption_test_case_192_3),
9591 /** AES CCM Authenticated Decryption 192 bits key*/
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_CCM_authenticated_decryption_test_case_192_1),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_CCM_authenticated_decryption_test_case_192_2),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_CCM_authenticated_decryption_test_case_192_3),
9599 /** AES CCM Authenticated Encryption 256 bits key */
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_CCM_authenticated_encryption_test_case_256_1),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_CCM_authenticated_encryption_test_case_256_2),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_CCM_authenticated_encryption_test_case_256_3),
9607 /** AES CCM Authenticated Decryption 256 bits key*/
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_CCM_authenticated_decryption_test_case_256_1),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_CCM_authenticated_decryption_test_case_256_2),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_CCM_authenticated_decryption_test_case_256_3),
9615 /** Scatter-Gather */
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9619 /** Negative tests */
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 authentication_verify_AES128_GMAC_fail_data_corrupt),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9633 TEST_CASES_END() /**< NULL terminate unit test array */
9637 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9638 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9639 .setup = testsuite_setup,
9640 .teardown = testsuite_teardown,
9641 .unit_test_cases = {
9642 /** AES GCM Authenticated Encryption */
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_authenticated_encryption_test_case_1),
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_authenticated_encryption_test_case_2),
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_authenticated_encryption_test_case_3),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_authenticated_encryption_test_case_4),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_authenticated_encryption_test_case_5),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_authenticated_encryption_test_case_6),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_authenticated_encryption_test_case_7),
9658 /** AES GCM Authenticated Decryption */
9659 TEST_CASE_ST(ut_setup, ut_teardown,
9660 test_AES_GCM_authenticated_decryption_test_case_1),
9661 TEST_CASE_ST(ut_setup, ut_teardown,
9662 test_AES_GCM_authenticated_decryption_test_case_2),
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_authenticated_decryption_test_case_3),
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_AES_GCM_authenticated_decryption_test_case_4),
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_AES_GCM_authenticated_decryption_test_case_5),
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_authenticated_decryption_test_case_6),
9671 TEST_CASE_ST(ut_setup, ut_teardown,
9672 test_AES_GCM_authenticated_decryption_test_case_7),
9674 /** AES GCM Authenticated Encryption 192 bits key */
9675 TEST_CASE_ST(ut_setup, ut_teardown,
9676 test_AES_GCM_auth_encryption_test_case_192_1),
9677 TEST_CASE_ST(ut_setup, ut_teardown,
9678 test_AES_GCM_auth_encryption_test_case_192_2),
9679 TEST_CASE_ST(ut_setup, ut_teardown,
9680 test_AES_GCM_auth_encryption_test_case_192_3),
9681 TEST_CASE_ST(ut_setup, ut_teardown,
9682 test_AES_GCM_auth_encryption_test_case_192_4),
9683 TEST_CASE_ST(ut_setup, ut_teardown,
9684 test_AES_GCM_auth_encryption_test_case_192_5),
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GCM_auth_encryption_test_case_192_6),
9687 TEST_CASE_ST(ut_setup, ut_teardown,
9688 test_AES_GCM_auth_encryption_test_case_192_7),
9690 /** AES GCM Authenticated Decryption 192 bits key */
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_AES_GCM_auth_decryption_test_case_192_1),
9693 TEST_CASE_ST(ut_setup, ut_teardown,
9694 test_AES_GCM_auth_decryption_test_case_192_2),
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_AES_GCM_auth_decryption_test_case_192_3),
9697 TEST_CASE_ST(ut_setup, ut_teardown,
9698 test_AES_GCM_auth_decryption_test_case_192_4),
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_AES_GCM_auth_decryption_test_case_192_5),
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GCM_auth_decryption_test_case_192_6),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GCM_auth_decryption_test_case_192_7),
9706 /** AES GCM Authenticated Encryption 256 bits key */
9707 TEST_CASE_ST(ut_setup, ut_teardown,
9708 test_AES_GCM_auth_encryption_test_case_256_1),
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_GCM_auth_encryption_test_case_256_2),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_auth_encryption_test_case_256_3),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_GCM_auth_encryption_test_case_256_4),
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_GCM_auth_encryption_test_case_256_5),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_auth_encryption_test_case_256_6),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_AES_GCM_auth_encryption_test_case_256_7),
9722 /** AES GCM Authenticated Decryption 256 bits key */
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_AES_GCM_auth_decryption_test_case_256_1),
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_AES_GCM_auth_decryption_test_case_256_2),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_auth_decryption_test_case_256_3),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_AES_GCM_auth_decryption_test_case_256_4),
9731 TEST_CASE_ST(ut_setup, ut_teardown,
9732 test_AES_GCM_auth_decryption_test_case_256_5),
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_AES_GCM_auth_decryption_test_case_256_6),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_AES_GCM_auth_decryption_test_case_256_7),
9738 /** AES GCM Authenticated Encryption big aad size */
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_AES_GCM_auth_encryption_test_case_aad_1),
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_AES_GCM_auth_encryption_test_case_aad_2),
9744 /** AES GCM Authenticated Decryption big aad size */
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_AES_GCM_auth_decryption_test_case_aad_1),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_AES_GCM_auth_decryption_test_case_aad_2),
9750 /** AES GMAC Authentication */
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_AES_GMAC_authentication_test_case_1),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_AES_GMAC_authentication_verify_test_case_1),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_AES_GMAC_authentication_test_case_3),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_AES_GMAC_authentication_verify_test_case_3),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_AES_GMAC_authentication_test_case_4),
9761 TEST_CASE_ST(ut_setup, ut_teardown,
9762 test_AES_GMAC_authentication_verify_test_case_4),
9764 /** Negative tests */
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 authentication_verify_AES128_GMAC_fail_data_corrupt),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9770 /** Out of place tests */
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9776 /** Session-less tests */
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9782 /** Scatter-Gather */
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9786 TEST_CASES_END() /**< NULL terminate unit test array */
9790 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9791 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9792 .setup = testsuite_setup,
9793 .teardown = testsuite_teardown,
9794 .unit_test_cases = {
9795 /** KASUMI encrypt only (UEA1) */
9796 TEST_CASE_ST(ut_setup, ut_teardown,
9797 test_kasumi_encryption_test_case_1),
9798 TEST_CASE_ST(ut_setup, ut_teardown,
9799 test_kasumi_encryption_test_case_1_sgl),
9800 TEST_CASE_ST(ut_setup, ut_teardown,
9801 test_kasumi_encryption_test_case_2),
9802 TEST_CASE_ST(ut_setup, ut_teardown,
9803 test_kasumi_encryption_test_case_3),
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_kasumi_encryption_test_case_4),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_kasumi_encryption_test_case_5),
9808 /** KASUMI decrypt only (UEA1) */
9809 TEST_CASE_ST(ut_setup, ut_teardown,
9810 test_kasumi_decryption_test_case_1),
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 test_kasumi_decryption_test_case_2),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_kasumi_decryption_test_case_3),
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_kasumi_decryption_test_case_4),
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_kasumi_decryption_test_case_5),
9820 TEST_CASE_ST(ut_setup, ut_teardown,
9821 test_kasumi_encryption_test_case_1_oop),
9822 TEST_CASE_ST(ut_setup, ut_teardown,
9823 test_kasumi_encryption_test_case_1_oop_sgl),
9826 TEST_CASE_ST(ut_setup, ut_teardown,
9827 test_kasumi_decryption_test_case_1_oop),
9829 /** KASUMI hash only (UIA1) */
9830 TEST_CASE_ST(ut_setup, ut_teardown,
9831 test_kasumi_hash_generate_test_case_1),
9832 TEST_CASE_ST(ut_setup, ut_teardown,
9833 test_kasumi_hash_generate_test_case_2),
9834 TEST_CASE_ST(ut_setup, ut_teardown,
9835 test_kasumi_hash_generate_test_case_3),
9836 TEST_CASE_ST(ut_setup, ut_teardown,
9837 test_kasumi_hash_generate_test_case_4),
9838 TEST_CASE_ST(ut_setup, ut_teardown,
9839 test_kasumi_hash_generate_test_case_5),
9840 TEST_CASE_ST(ut_setup, ut_teardown,
9841 test_kasumi_hash_generate_test_case_6),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_kasumi_hash_verify_test_case_1),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_kasumi_hash_verify_test_case_2),
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 test_kasumi_hash_verify_test_case_3),
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 test_kasumi_hash_verify_test_case_4),
9850 TEST_CASE_ST(ut_setup, ut_teardown,
9851 test_kasumi_hash_verify_test_case_5),
9852 TEST_CASE_ST(ut_setup, ut_teardown,
9853 test_kasumi_auth_cipher_test_case_1),
9854 TEST_CASE_ST(ut_setup, ut_teardown,
9855 test_kasumi_cipher_auth_test_case_1),
9856 TEST_CASES_END() /**< NULL terminate unit test array */
9859 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9860 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9861 .setup = testsuite_setup,
9862 .teardown = testsuite_teardown,
9863 .unit_test_cases = {
9864 /** SNOW 3G encrypt only (UEA2) */
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_snow3g_encryption_test_case_1),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 test_snow3g_encryption_test_case_2),
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 test_snow3g_encryption_test_case_3),
9871 TEST_CASE_ST(ut_setup, ut_teardown,
9872 test_snow3g_encryption_test_case_4),
9873 TEST_CASE_ST(ut_setup, ut_teardown,
9874 test_snow3g_encryption_test_case_5),
9876 TEST_CASE_ST(ut_setup, ut_teardown,
9877 test_snow3g_encryption_test_case_1_oop),
9878 TEST_CASE_ST(ut_setup, ut_teardown,
9879 test_snow3g_encryption_test_case_1_oop_sgl),
9880 TEST_CASE_ST(ut_setup, ut_teardown,
9881 test_snow3g_decryption_test_case_1_oop),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_snow3g_encryption_test_case_1_offset_oop),
9886 /** SNOW 3G decrypt only (UEA2) */
9887 TEST_CASE_ST(ut_setup, ut_teardown,
9888 test_snow3g_decryption_test_case_1),
9889 TEST_CASE_ST(ut_setup, ut_teardown,
9890 test_snow3g_decryption_test_case_2),
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 test_snow3g_decryption_test_case_3),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 test_snow3g_decryption_test_case_4),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 test_snow3g_decryption_test_case_5),
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 test_snow3g_hash_generate_test_case_1),
9899 TEST_CASE_ST(ut_setup, ut_teardown,
9900 test_snow3g_hash_generate_test_case_2),
9901 TEST_CASE_ST(ut_setup, ut_teardown,
9902 test_snow3g_hash_generate_test_case_3),
9903 /* Tests with buffers which length is not byte-aligned */
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_snow3g_hash_generate_test_case_4),
9906 TEST_CASE_ST(ut_setup, ut_teardown,
9907 test_snow3g_hash_generate_test_case_5),
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 test_snow3g_hash_generate_test_case_6),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 test_snow3g_hash_verify_test_case_1),
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 test_snow3g_hash_verify_test_case_2),
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 test_snow3g_hash_verify_test_case_3),
9916 /* Tests with buffers which length is not byte-aligned */
9917 TEST_CASE_ST(ut_setup, ut_teardown,
9918 test_snow3g_hash_verify_test_case_4),
9919 TEST_CASE_ST(ut_setup, ut_teardown,
9920 test_snow3g_hash_verify_test_case_5),
9921 TEST_CASE_ST(ut_setup, ut_teardown,
9922 test_snow3g_hash_verify_test_case_6),
9923 TEST_CASE_ST(ut_setup, ut_teardown,
9924 test_snow3g_cipher_auth_test_case_1),
9925 TEST_CASE_ST(ut_setup, ut_teardown,
9926 test_snow3g_auth_cipher_test_case_1),
9928 TEST_CASES_END() /**< NULL terminate unit test array */
9932 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9933 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9934 .setup = testsuite_setup,
9935 .teardown = testsuite_teardown,
9936 .unit_test_cases = {
9937 /** ZUC encrypt only (EEA3) */
9938 TEST_CASE_ST(ut_setup, ut_teardown,
9939 test_zuc_encryption_test_case_1),
9940 TEST_CASE_ST(ut_setup, ut_teardown,
9941 test_zuc_encryption_test_case_2),
9942 TEST_CASE_ST(ut_setup, ut_teardown,
9943 test_zuc_encryption_test_case_3),
9944 TEST_CASE_ST(ut_setup, ut_teardown,
9945 test_zuc_encryption_test_case_4),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_zuc_encryption_test_case_5),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_zuc_hash_generate_test_case_1),
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_zuc_hash_generate_test_case_2),
9952 TEST_CASE_ST(ut_setup, ut_teardown,
9953 test_zuc_hash_generate_test_case_3),
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_zuc_hash_generate_test_case_4),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_zuc_hash_generate_test_case_5),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_zuc_encryption_test_case_6_sgl),
9960 TEST_CASES_END() /**< NULL terminate unit test array */
9964 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
9965 .suite_name = "Crypto CAAM JR Unit Test Suite",
9966 .setup = testsuite_setup,
9967 .teardown = testsuite_teardown,
9968 .unit_test_cases = {
9969 TEST_CASE_ST(ut_setup, ut_teardown,
9970 test_device_configure_invalid_dev_id),
9971 TEST_CASE_ST(ut_setup, ut_teardown,
9972 test_multi_session),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_AES_chain_caam_jr_all),
9976 TEST_CASE_ST(ut_setup, ut_teardown,
9977 test_3DES_chain_caam_jr_all),
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_AES_cipheronly_caam_jr_all),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_3DES_cipheronly_caam_jr_all),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_authonly_caam_jr_all),
9985 TEST_CASES_END() /**< NULL terminate unit test array */
9989 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9990 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9991 .setup = testsuite_setup,
9992 .teardown = testsuite_teardown,
9993 .unit_test_cases = {
9994 TEST_CASE_ST(ut_setup, ut_teardown,
9995 test_device_configure_invalid_dev_id),
9996 TEST_CASE_ST(ut_setup, ut_teardown,
9997 test_multi_session),
9999 TEST_CASE_ST(ut_setup, ut_teardown,
10000 test_AES_chain_dpaa_sec_all),
10001 TEST_CASE_ST(ut_setup, ut_teardown,
10002 test_3DES_chain_dpaa_sec_all),
10003 TEST_CASE_ST(ut_setup, ut_teardown,
10004 test_AES_cipheronly_dpaa_sec_all),
10005 TEST_CASE_ST(ut_setup, ut_teardown,
10006 test_3DES_cipheronly_dpaa_sec_all),
10007 TEST_CASE_ST(ut_setup, ut_teardown,
10008 test_authonly_dpaa_sec_all),
10010 /** AES GCM Authenticated Encryption */
10011 TEST_CASE_ST(ut_setup, ut_teardown,
10012 test_AES_GCM_authenticated_encryption_test_case_1),
10013 TEST_CASE_ST(ut_setup, ut_teardown,
10014 test_AES_GCM_authenticated_encryption_test_case_2),
10015 TEST_CASE_ST(ut_setup, ut_teardown,
10016 test_AES_GCM_authenticated_encryption_test_case_3),
10017 TEST_CASE_ST(ut_setup, ut_teardown,
10018 test_AES_GCM_authenticated_encryption_test_case_4),
10019 TEST_CASE_ST(ut_setup, ut_teardown,
10020 test_AES_GCM_authenticated_encryption_test_case_5),
10021 TEST_CASE_ST(ut_setup, ut_teardown,
10022 test_AES_GCM_authenticated_encryption_test_case_6),
10023 TEST_CASE_ST(ut_setup, ut_teardown,
10024 test_AES_GCM_authenticated_encryption_test_case_7),
10026 /** AES GCM Authenticated Decryption */
10027 TEST_CASE_ST(ut_setup, ut_teardown,
10028 test_AES_GCM_authenticated_decryption_test_case_1),
10029 TEST_CASE_ST(ut_setup, ut_teardown,
10030 test_AES_GCM_authenticated_decryption_test_case_2),
10031 TEST_CASE_ST(ut_setup, ut_teardown,
10032 test_AES_GCM_authenticated_decryption_test_case_3),
10033 TEST_CASE_ST(ut_setup, ut_teardown,
10034 test_AES_GCM_authenticated_decryption_test_case_4),
10035 TEST_CASE_ST(ut_setup, ut_teardown,
10036 test_AES_GCM_authenticated_decryption_test_case_5),
10037 TEST_CASE_ST(ut_setup, ut_teardown,
10038 test_AES_GCM_authenticated_decryption_test_case_6),
10039 TEST_CASE_ST(ut_setup, ut_teardown,
10040 test_AES_GCM_authenticated_decryption_test_case_7),
10042 /** AES GCM Authenticated Encryption 256 bits key */
10043 TEST_CASE_ST(ut_setup, ut_teardown,
10044 test_AES_GCM_auth_encryption_test_case_256_1),
10045 TEST_CASE_ST(ut_setup, ut_teardown,
10046 test_AES_GCM_auth_encryption_test_case_256_2),
10047 TEST_CASE_ST(ut_setup, ut_teardown,
10048 test_AES_GCM_auth_encryption_test_case_256_3),
10049 TEST_CASE_ST(ut_setup, ut_teardown,
10050 test_AES_GCM_auth_encryption_test_case_256_4),
10051 TEST_CASE_ST(ut_setup, ut_teardown,
10052 test_AES_GCM_auth_encryption_test_case_256_5),
10053 TEST_CASE_ST(ut_setup, ut_teardown,
10054 test_AES_GCM_auth_encryption_test_case_256_6),
10055 TEST_CASE_ST(ut_setup, ut_teardown,
10056 test_AES_GCM_auth_encryption_test_case_256_7),
10058 /** AES GCM Authenticated Decryption 256 bits key */
10059 TEST_CASE_ST(ut_setup, ut_teardown,
10060 test_AES_GCM_auth_decryption_test_case_256_1),
10061 TEST_CASE_ST(ut_setup, ut_teardown,
10062 test_AES_GCM_auth_decryption_test_case_256_2),
10063 TEST_CASE_ST(ut_setup, ut_teardown,
10064 test_AES_GCM_auth_decryption_test_case_256_3),
10065 TEST_CASE_ST(ut_setup, ut_teardown,
10066 test_AES_GCM_auth_decryption_test_case_256_4),
10067 TEST_CASE_ST(ut_setup, ut_teardown,
10068 test_AES_GCM_auth_decryption_test_case_256_5),
10069 TEST_CASE_ST(ut_setup, ut_teardown,
10070 test_AES_GCM_auth_decryption_test_case_256_6),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_AES_GCM_auth_decryption_test_case_256_7),
10074 /** Out of place tests */
10075 TEST_CASE_ST(ut_setup, ut_teardown,
10076 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10080 /** Scatter-Gather */
10081 TEST_CASE_ST(ut_setup, ut_teardown,
10082 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10090 TEST_CASES_END() /**< NULL terminate unit test array */
10094 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10095 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10096 .setup = testsuite_setup,
10097 .teardown = testsuite_teardown,
10098 .unit_test_cases = {
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_device_configure_invalid_dev_id),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_multi_session),
10104 TEST_CASE_ST(ut_setup, ut_teardown,
10105 test_AES_chain_dpaa2_sec_all),
10106 TEST_CASE_ST(ut_setup, ut_teardown,
10107 test_3DES_chain_dpaa2_sec_all),
10108 TEST_CASE_ST(ut_setup, ut_teardown,
10109 test_AES_cipheronly_dpaa2_sec_all),
10110 TEST_CASE_ST(ut_setup, ut_teardown,
10111 test_3DES_cipheronly_dpaa2_sec_all),
10112 TEST_CASE_ST(ut_setup, ut_teardown,
10113 test_authonly_dpaa2_sec_all),
10115 /** AES GCM Authenticated Encryption */
10116 TEST_CASE_ST(ut_setup, ut_teardown,
10117 test_AES_GCM_authenticated_encryption_test_case_1),
10118 TEST_CASE_ST(ut_setup, ut_teardown,
10119 test_AES_GCM_authenticated_encryption_test_case_2),
10120 TEST_CASE_ST(ut_setup, ut_teardown,
10121 test_AES_GCM_authenticated_encryption_test_case_3),
10122 TEST_CASE_ST(ut_setup, ut_teardown,
10123 test_AES_GCM_authenticated_encryption_test_case_4),
10124 TEST_CASE_ST(ut_setup, ut_teardown,
10125 test_AES_GCM_authenticated_encryption_test_case_5),
10126 TEST_CASE_ST(ut_setup, ut_teardown,
10127 test_AES_GCM_authenticated_encryption_test_case_6),
10128 TEST_CASE_ST(ut_setup, ut_teardown,
10129 test_AES_GCM_authenticated_encryption_test_case_7),
10131 /** AES GCM Authenticated Decryption */
10132 TEST_CASE_ST(ut_setup, ut_teardown,
10133 test_AES_GCM_authenticated_decryption_test_case_1),
10134 TEST_CASE_ST(ut_setup, ut_teardown,
10135 test_AES_GCM_authenticated_decryption_test_case_2),
10136 TEST_CASE_ST(ut_setup, ut_teardown,
10137 test_AES_GCM_authenticated_decryption_test_case_3),
10138 TEST_CASE_ST(ut_setup, ut_teardown,
10139 test_AES_GCM_authenticated_decryption_test_case_4),
10140 TEST_CASE_ST(ut_setup, ut_teardown,
10141 test_AES_GCM_authenticated_decryption_test_case_5),
10142 TEST_CASE_ST(ut_setup, ut_teardown,
10143 test_AES_GCM_authenticated_decryption_test_case_6),
10144 TEST_CASE_ST(ut_setup, ut_teardown,
10145 test_AES_GCM_authenticated_decryption_test_case_7),
10147 /** AES GCM Authenticated Encryption 192 bits key */
10148 TEST_CASE_ST(ut_setup, ut_teardown,
10149 test_AES_GCM_auth_encryption_test_case_192_1),
10150 TEST_CASE_ST(ut_setup, ut_teardown,
10151 test_AES_GCM_auth_encryption_test_case_192_2),
10152 TEST_CASE_ST(ut_setup, ut_teardown,
10153 test_AES_GCM_auth_encryption_test_case_192_3),
10154 TEST_CASE_ST(ut_setup, ut_teardown,
10155 test_AES_GCM_auth_encryption_test_case_192_4),
10156 TEST_CASE_ST(ut_setup, ut_teardown,
10157 test_AES_GCM_auth_encryption_test_case_192_5),
10158 TEST_CASE_ST(ut_setup, ut_teardown,
10159 test_AES_GCM_auth_encryption_test_case_192_6),
10160 TEST_CASE_ST(ut_setup, ut_teardown,
10161 test_AES_GCM_auth_encryption_test_case_192_7),
10163 /** AES GCM Authenticated Decryption 192 bits key */
10164 TEST_CASE_ST(ut_setup, ut_teardown,
10165 test_AES_GCM_auth_decryption_test_case_192_1),
10166 TEST_CASE_ST(ut_setup, ut_teardown,
10167 test_AES_GCM_auth_decryption_test_case_192_2),
10168 TEST_CASE_ST(ut_setup, ut_teardown,
10169 test_AES_GCM_auth_decryption_test_case_192_3),
10170 TEST_CASE_ST(ut_setup, ut_teardown,
10171 test_AES_GCM_auth_decryption_test_case_192_4),
10172 TEST_CASE_ST(ut_setup, ut_teardown,
10173 test_AES_GCM_auth_decryption_test_case_192_5),
10174 TEST_CASE_ST(ut_setup, ut_teardown,
10175 test_AES_GCM_auth_decryption_test_case_192_6),
10176 TEST_CASE_ST(ut_setup, ut_teardown,
10177 test_AES_GCM_auth_decryption_test_case_192_7),
10179 /** AES GCM Authenticated Encryption 256 bits key */
10180 TEST_CASE_ST(ut_setup, ut_teardown,
10181 test_AES_GCM_auth_encryption_test_case_256_1),
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_AES_GCM_auth_encryption_test_case_256_2),
10184 TEST_CASE_ST(ut_setup, ut_teardown,
10185 test_AES_GCM_auth_encryption_test_case_256_3),
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_AES_GCM_auth_encryption_test_case_256_4),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_AES_GCM_auth_encryption_test_case_256_5),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_AES_GCM_auth_encryption_test_case_256_6),
10192 TEST_CASE_ST(ut_setup, ut_teardown,
10193 test_AES_GCM_auth_encryption_test_case_256_7),
10195 /** AES GCM Authenticated Decryption 256 bits key */
10196 TEST_CASE_ST(ut_setup, ut_teardown,
10197 test_AES_GCM_auth_decryption_test_case_256_1),
10198 TEST_CASE_ST(ut_setup, ut_teardown,
10199 test_AES_GCM_auth_decryption_test_case_256_2),
10200 TEST_CASE_ST(ut_setup, ut_teardown,
10201 test_AES_GCM_auth_decryption_test_case_256_3),
10202 TEST_CASE_ST(ut_setup, ut_teardown,
10203 test_AES_GCM_auth_decryption_test_case_256_4),
10204 TEST_CASE_ST(ut_setup, ut_teardown,
10205 test_AES_GCM_auth_decryption_test_case_256_5),
10206 TEST_CASE_ST(ut_setup, ut_teardown,
10207 test_AES_GCM_auth_decryption_test_case_256_6),
10208 TEST_CASE_ST(ut_setup, ut_teardown,
10209 test_AES_GCM_auth_decryption_test_case_256_7),
10211 /** Out of place tests */
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10214 TEST_CASE_ST(ut_setup, ut_teardown,
10215 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10217 /** Scatter-Gather */
10218 TEST_CASE_ST(ut_setup, ut_teardown,
10219 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10222 TEST_CASE_ST(ut_setup, ut_teardown,
10223 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10227 TEST_CASES_END() /**< NULL terminate unit test array */
10231 static struct unit_test_suite cryptodev_null_testsuite = {
10232 .suite_name = "Crypto Device NULL Unit Test Suite",
10233 .setup = testsuite_setup,
10234 .teardown = testsuite_teardown,
10235 .unit_test_cases = {
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 test_null_auth_only_operation),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 test_null_cipher_only_operation),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 test_null_cipher_auth_operation),
10242 TEST_CASE_ST(ut_setup, ut_teardown,
10243 test_null_auth_cipher_operation),
10244 TEST_CASE_ST(ut_setup, ut_teardown,
10245 test_null_invalid_operation),
10246 TEST_CASE_ST(ut_setup, ut_teardown,
10247 test_null_burst_operation),
10249 TEST_CASES_END() /**< NULL terminate unit test array */
10253 static struct unit_test_suite cryptodev_armv8_testsuite = {
10254 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10255 .setup = testsuite_setup,
10256 .teardown = testsuite_teardown,
10257 .unit_test_cases = {
10258 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10260 /** Negative tests */
10261 TEST_CASE_ST(ut_setup, ut_teardown,
10262 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10266 TEST_CASES_END() /**< NULL terminate unit test array */
10270 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10271 .suite_name = "Crypto Device Marvell Component Test Suite",
10272 .setup = testsuite_setup,
10273 .teardown = testsuite_teardown,
10274 .unit_test_cases = {
10275 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 test_multi_session_random_usage),
10278 TEST_CASE_ST(ut_setup, ut_teardown,
10279 test_AES_chain_mrvl_all),
10280 TEST_CASE_ST(ut_setup, ut_teardown,
10281 test_AES_cipheronly_mrvl_all),
10282 TEST_CASE_ST(ut_setup, ut_teardown,
10283 test_authonly_mrvl_all),
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_3DES_chain_mrvl_all),
10286 TEST_CASE_ST(ut_setup, ut_teardown,
10287 test_3DES_cipheronly_mrvl_all),
10289 /** Negative tests */
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10296 TEST_CASE_ST(ut_setup, ut_teardown,
10297 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10299 TEST_CASES_END() /**< NULL terminate unit test array */
10303 static struct unit_test_suite cryptodev_ccp_testsuite = {
10304 .suite_name = "Crypto Device CCP Unit Test Suite",
10305 .setup = testsuite_setup,
10306 .teardown = testsuite_teardown,
10307 .unit_test_cases = {
10308 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10309 TEST_CASE_ST(ut_setup, ut_teardown,
10310 test_multi_session_random_usage),
10311 TEST_CASE_ST(ut_setup, ut_teardown,
10312 test_AES_chain_ccp_all),
10313 TEST_CASE_ST(ut_setup, ut_teardown,
10314 test_AES_cipheronly_ccp_all),
10315 TEST_CASE_ST(ut_setup, ut_teardown,
10316 test_3DES_chain_ccp_all),
10317 TEST_CASE_ST(ut_setup, ut_teardown,
10318 test_3DES_cipheronly_ccp_all),
10319 TEST_CASE_ST(ut_setup, ut_teardown,
10320 test_authonly_ccp_all),
10322 /** Negative tests */
10323 TEST_CASE_ST(ut_setup, ut_teardown,
10324 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10325 TEST_CASE_ST(ut_setup, ut_teardown,
10326 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10327 TEST_CASE_ST(ut_setup, ut_teardown,
10328 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10329 TEST_CASE_ST(ut_setup, ut_teardown,
10330 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10332 TEST_CASES_END() /**< NULL terminate unit test array */
10336 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10337 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10338 .setup = testsuite_setup,
10339 .teardown = testsuite_teardown,
10340 .unit_test_cases = {
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_AES_chain_octeontx_all),
10343 TEST_CASE_ST(ut_setup, ut_teardown,
10344 test_AES_cipheronly_octeontx_all),
10345 TEST_CASE_ST(ut_setup, ut_teardown,
10346 test_3DES_chain_octeontx_all),
10347 TEST_CASE_ST(ut_setup, ut_teardown,
10348 test_3DES_cipheronly_octeontx_all),
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_authonly_octeontx_all),
10352 /** AES GCM Authenticated Encryption */
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_AES_GCM_authenticated_encryption_test_case_1),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_AES_GCM_authenticated_encryption_test_case_2),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_AES_GCM_authenticated_encryption_test_case_3),
10359 TEST_CASE_ST(ut_setup, ut_teardown,
10360 test_AES_GCM_authenticated_encryption_test_case_4),
10361 TEST_CASE_ST(ut_setup, ut_teardown,
10362 test_AES_GCM_authenticated_encryption_test_case_5),
10363 TEST_CASE_ST(ut_setup, ut_teardown,
10364 test_AES_GCM_authenticated_encryption_test_case_6),
10365 TEST_CASE_ST(ut_setup, ut_teardown,
10366 test_AES_GCM_authenticated_encryption_test_case_7),
10368 /** AES GCM Authenticated Decryption */
10369 TEST_CASE_ST(ut_setup, ut_teardown,
10370 test_AES_GCM_authenticated_decryption_test_case_1),
10371 TEST_CASE_ST(ut_setup, ut_teardown,
10372 test_AES_GCM_authenticated_decryption_test_case_2),
10373 TEST_CASE_ST(ut_setup, ut_teardown,
10374 test_AES_GCM_authenticated_decryption_test_case_3),
10375 TEST_CASE_ST(ut_setup, ut_teardown,
10376 test_AES_GCM_authenticated_decryption_test_case_4),
10377 TEST_CASE_ST(ut_setup, ut_teardown,
10378 test_AES_GCM_authenticated_decryption_test_case_5),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_AES_GCM_authenticated_decryption_test_case_6),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_AES_GCM_authenticated_decryption_test_case_7),
10383 /** AES GMAC Authentication */
10384 TEST_CASE_ST(ut_setup, ut_teardown,
10385 test_AES_GMAC_authentication_test_case_1),
10386 TEST_CASE_ST(ut_setup, ut_teardown,
10387 test_AES_GMAC_authentication_verify_test_case_1),
10388 TEST_CASE_ST(ut_setup, ut_teardown,
10389 test_AES_GMAC_authentication_test_case_2),
10390 TEST_CASE_ST(ut_setup, ut_teardown,
10391 test_AES_GMAC_authentication_verify_test_case_2),
10392 TEST_CASE_ST(ut_setup, ut_teardown,
10393 test_AES_GMAC_authentication_test_case_3),
10394 TEST_CASE_ST(ut_setup, ut_teardown,
10395 test_AES_GMAC_authentication_verify_test_case_3),
10397 /** SNOW 3G encrypt only (UEA2) */
10398 TEST_CASE_ST(ut_setup, ut_teardown,
10399 test_snow3g_encryption_test_case_1),
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_snow3g_encryption_test_case_2),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_snow3g_encryption_test_case_3),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_snow3g_encryption_test_case_4),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_snow3g_encryption_test_case_5),
10409 TEST_CASE_ST(ut_setup, ut_teardown,
10410 test_snow3g_encryption_test_case_1_oop),
10411 TEST_CASE_ST(ut_setup, ut_teardown,
10412 test_snow3g_decryption_test_case_1_oop),
10413 TEST_CASE_ST(ut_setup, ut_teardown,
10414 test_snow3g_encryption_test_case_1_oop_sgl),
10416 /** SNOW 3G decrypt only (UEA2) */
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_snow3g_decryption_test_case_1),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_snow3g_decryption_test_case_2),
10421 TEST_CASE_ST(ut_setup, ut_teardown,
10422 test_snow3g_decryption_test_case_3),
10423 TEST_CASE_ST(ut_setup, ut_teardown,
10424 test_snow3g_decryption_test_case_4),
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_snow3g_decryption_test_case_5),
10428 TEST_CASE_ST(ut_setup, ut_teardown,
10429 test_snow3g_hash_generate_test_case_1),
10430 TEST_CASE_ST(ut_setup, ut_teardown,
10431 test_snow3g_hash_generate_test_case_2),
10432 TEST_CASE_ST(ut_setup, ut_teardown,
10433 test_snow3g_hash_generate_test_case_3),
10434 TEST_CASE_ST(ut_setup, ut_teardown,
10435 test_snow3g_hash_verify_test_case_1),
10436 TEST_CASE_ST(ut_setup, ut_teardown,
10437 test_snow3g_hash_verify_test_case_2),
10438 TEST_CASE_ST(ut_setup, ut_teardown,
10439 test_snow3g_hash_verify_test_case_3),
10441 /** ZUC encrypt only (EEA3) */
10442 TEST_CASE_ST(ut_setup, ut_teardown,
10443 test_zuc_encryption_test_case_1),
10444 TEST_CASE_ST(ut_setup, ut_teardown,
10445 test_zuc_encryption_test_case_2),
10446 TEST_CASE_ST(ut_setup, ut_teardown,
10447 test_zuc_encryption_test_case_3),
10448 TEST_CASE_ST(ut_setup, ut_teardown,
10449 test_zuc_encryption_test_case_4),
10450 TEST_CASE_ST(ut_setup, ut_teardown,
10451 test_zuc_encryption_test_case_5),
10452 TEST_CASE_ST(ut_setup, ut_teardown,
10453 test_zuc_hash_generate_test_case_1),
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_zuc_hash_generate_test_case_2),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_zuc_hash_generate_test_case_3),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_zuc_hash_generate_test_case_4),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_zuc_hash_generate_test_case_5),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_zuc_encryption_test_case_6_sgl),
10465 /** KASUMI encrypt only (UEA1) */
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_kasumi_encryption_test_case_1),
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_kasumi_encryption_test_case_2),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_kasumi_encryption_test_case_3),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_kasumi_encryption_test_case_4),
10474 TEST_CASE_ST(ut_setup, ut_teardown,
10475 test_kasumi_encryption_test_case_5),
10476 TEST_CASE_ST(ut_setup, ut_teardown,
10477 test_kasumi_encryption_test_case_1_sgl),
10478 TEST_CASE_ST(ut_setup, ut_teardown,
10479 test_kasumi_encryption_test_case_1_oop_sgl),
10480 /** KASUMI decrypt only (UEA1) */
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 test_kasumi_decryption_test_case_1),
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 test_kasumi_decryption_test_case_2),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 test_kasumi_decryption_test_case_3),
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 test_kasumi_decryption_test_case_4),
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 test_kasumi_decryption_test_case_5),
10492 TEST_CASE_ST(ut_setup, ut_teardown,
10493 test_kasumi_encryption_test_case_1_oop),
10494 TEST_CASE_ST(ut_setup, ut_teardown,
10495 test_kasumi_decryption_test_case_1_oop),
10497 /** KASUMI hash only (UIA1) */
10498 TEST_CASE_ST(ut_setup, ut_teardown,
10499 test_kasumi_hash_generate_test_case_1),
10500 TEST_CASE_ST(ut_setup, ut_teardown,
10501 test_kasumi_hash_generate_test_case_2),
10502 TEST_CASE_ST(ut_setup, ut_teardown,
10503 test_kasumi_hash_generate_test_case_3),
10504 TEST_CASE_ST(ut_setup, ut_teardown,
10505 test_kasumi_hash_generate_test_case_4),
10506 TEST_CASE_ST(ut_setup, ut_teardown,
10507 test_kasumi_hash_generate_test_case_5),
10508 TEST_CASE_ST(ut_setup, ut_teardown,
10509 test_kasumi_hash_generate_test_case_6),
10510 TEST_CASE_ST(ut_setup, ut_teardown,
10511 test_kasumi_hash_verify_test_case_1),
10512 TEST_CASE_ST(ut_setup, ut_teardown,
10513 test_kasumi_hash_verify_test_case_2),
10514 TEST_CASE_ST(ut_setup, ut_teardown,
10515 test_kasumi_hash_verify_test_case_3),
10516 TEST_CASE_ST(ut_setup, ut_teardown,
10517 test_kasumi_hash_verify_test_case_4),
10518 TEST_CASE_ST(ut_setup, ut_teardown,
10519 test_kasumi_hash_verify_test_case_5),
10522 TEST_CASE_ST(ut_setup, ut_teardown,
10523 test_null_cipher_only_operation),
10524 TEST_CASE_ST(ut_setup, ut_teardown,
10525 test_null_auth_only_operation),
10526 TEST_CASE_ST(ut_setup, ut_teardown,
10527 test_null_cipher_auth_operation),
10528 TEST_CASE_ST(ut_setup, ut_teardown,
10529 test_null_auth_cipher_operation),
10531 /** Negative tests */
10532 TEST_CASE_ST(ut_setup, ut_teardown,
10533 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10534 TEST_CASE_ST(ut_setup, ut_teardown,
10535 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10536 TEST_CASE_ST(ut_setup, ut_teardown,
10537 authentication_verify_AES128_GMAC_fail_data_corrupt),
10538 TEST_CASE_ST(ut_setup, ut_teardown,
10539 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10540 TEST_CASE_ST(ut_setup, ut_teardown,
10541 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10542 TEST_CASE_ST(ut_setup, ut_teardown,
10543 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10544 TEST_CASES_END() /**< NULL terminate unit test array */
10549 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10551 gbl_driver_id = rte_cryptodev_driver_id_get(
10552 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10554 if (gbl_driver_id == -1) {
10555 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10556 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10557 "are enabled in config file to run this testsuite.\n");
10558 return TEST_SKIPPED;
10561 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10565 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10567 gbl_driver_id = rte_cryptodev_driver_id_get(
10568 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10570 if (gbl_driver_id == -1) {
10571 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10572 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10573 "in config file to run this testsuite.\n");
10574 return TEST_FAILED;
10577 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10581 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10583 gbl_driver_id = rte_cryptodev_driver_id_get(
10584 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10586 if (gbl_driver_id == -1) {
10587 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10588 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10589 "in config file to run this testsuite.\n");
10590 return TEST_SKIPPED;
10593 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10597 test_cryptodev_openssl(void)
10599 gbl_driver_id = rte_cryptodev_driver_id_get(
10600 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10602 if (gbl_driver_id == -1) {
10603 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10604 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10605 "in config file to run this testsuite.\n");
10606 return TEST_SKIPPED;
10609 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10613 test_cryptodev_aesni_gcm(void)
10615 gbl_driver_id = rte_cryptodev_driver_id_get(
10616 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10618 if (gbl_driver_id == -1) {
10619 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10620 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10621 "in config file to run this testsuite.\n");
10622 return TEST_SKIPPED;
10625 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10629 test_cryptodev_null(void)
10631 gbl_driver_id = rte_cryptodev_driver_id_get(
10632 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10634 if (gbl_driver_id == -1) {
10635 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10636 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10637 "in config file to run this testsuite.\n");
10638 return TEST_SKIPPED;
10641 return unit_test_suite_runner(&cryptodev_null_testsuite);
10645 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10647 gbl_driver_id = rte_cryptodev_driver_id_get(
10648 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10650 if (gbl_driver_id == -1) {
10651 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10652 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10653 "in config file to run this testsuite.\n");
10654 return TEST_SKIPPED;
10657 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10661 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10663 gbl_driver_id = rte_cryptodev_driver_id_get(
10664 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10666 if (gbl_driver_id == -1) {
10667 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10668 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10669 "in config file to run this testsuite.\n");
10670 return TEST_SKIPPED;
10673 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10677 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10679 gbl_driver_id = rte_cryptodev_driver_id_get(
10680 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10682 if (gbl_driver_id == -1) {
10683 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10684 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10685 "in config file to run this testsuite.\n");
10686 return TEST_SKIPPED;
10689 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10693 test_cryptodev_armv8(void)
10695 gbl_driver_id = rte_cryptodev_driver_id_get(
10696 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10698 if (gbl_driver_id == -1) {
10699 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10700 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10701 "in config file to run this testsuite.\n");
10702 return TEST_SKIPPED;
10705 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10709 test_cryptodev_mrvl(void)
10711 gbl_driver_id = rte_cryptodev_driver_id_get(
10712 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10714 if (gbl_driver_id == -1) {
10715 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10716 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10717 "in config file to run this testsuite.\n");
10718 return TEST_SKIPPED;
10721 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10724 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10727 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10729 gbl_driver_id = rte_cryptodev_driver_id_get(
10730 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10732 if (gbl_driver_id == -1) {
10733 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10734 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10735 "in config file to run this testsuite.\n");
10736 return TEST_SKIPPED;
10739 if (rte_cryptodev_driver_id_get(
10740 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10741 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10742 " enabled in config file to run this testsuite.\n");
10743 return TEST_SKIPPED;
10745 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10748 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10753 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10755 gbl_driver_id = rte_cryptodev_driver_id_get(
10756 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10758 if (gbl_driver_id == -1) {
10759 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10760 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10761 "in config file to run this testsuite.\n");
10762 return TEST_SKIPPED;
10765 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10769 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10771 gbl_driver_id = rte_cryptodev_driver_id_get(
10772 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10774 if (gbl_driver_id == -1) {
10775 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10776 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10777 "in config file to run this testsuite.\n");
10778 return TEST_SKIPPED;
10781 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10785 test_cryptodev_ccp(void)
10787 gbl_driver_id = rte_cryptodev_driver_id_get(
10788 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10790 if (gbl_driver_id == -1) {
10791 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10792 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10793 "in config file to run this testsuite.\n");
10794 return TEST_FAILED;
10797 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10801 test_cryptodev_octeontx(void)
10803 gbl_driver_id = rte_cryptodev_driver_id_get(
10804 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10805 if (gbl_driver_id == -1) {
10806 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10807 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10808 "enabled in config file to run this "
10810 return TEST_FAILED;
10812 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10816 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10818 gbl_driver_id = rte_cryptodev_driver_id_get(
10819 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10821 if (gbl_driver_id == -1) {
10822 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10823 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10824 "in config file to run this testsuite.\n");
10825 return TEST_FAILED;
10828 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10831 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10832 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10833 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10834 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10835 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10836 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10837 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10838 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10839 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10840 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10841 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10842 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10843 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10844 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10845 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10846 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);