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_cryptodev_config conf;
52 struct rte_cryptodev_qp_conf qp_conf;
54 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
55 uint8_t valid_dev_count;
58 struct crypto_unittest_params {
59 struct rte_crypto_sym_xform cipher_xform;
60 struct rte_crypto_sym_xform auth_xform;
61 struct rte_crypto_sym_xform aead_xform;
63 struct rte_cryptodev_sym_session *sess;
65 struct rte_crypto_op *op;
67 struct rte_mbuf *obuf, *ibuf;
72 #define ALIGN_POW2_ROUNDUP(num, align) \
73 (((num) + (align) - 1) & ~((align) - 1))
76 * Forward declarations.
79 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
80 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
84 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
85 struct crypto_unittest_params *ut_params,
86 struct crypto_testsuite_params *ts_param,
87 const uint8_t *cipher,
88 const uint8_t *digest,
91 static struct rte_mbuf *
92 setup_test_string(struct rte_mempool *mpool,
93 const char *string, size_t len, uint8_t blocksize)
95 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
96 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
98 memset(m->buf_addr, 0, m->buf_len);
100 char *dst = rte_pktmbuf_append(m, t_len);
107 rte_memcpy(dst, string, t_len);
109 memset(dst, 0, t_len);
115 /* Get number of bytes in X bits (rounding up) */
117 ceil_byte_length(uint32_t num_bits)
120 return ((num_bits >> 3) + 1);
122 return (num_bits >> 3);
125 static struct rte_crypto_op *
126 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
128 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
129 printf("Error sending packet for encryption");
135 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
141 static struct crypto_testsuite_params testsuite_params = { NULL };
142 static struct crypto_unittest_params unittest_params;
145 testsuite_setup(void)
147 struct crypto_testsuite_params *ts_params = &testsuite_params;
148 struct rte_cryptodev_info info;
149 uint32_t i = 0, nb_devs, dev_id;
153 memset(ts_params, 0, sizeof(*ts_params));
155 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
156 if (ts_params->mbuf_pool == NULL) {
157 /* Not already created so create */
158 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
160 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
162 if (ts_params->mbuf_pool == NULL) {
163 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
168 ts_params->large_mbuf_pool = rte_mempool_lookup(
169 "CRYPTO_LARGE_MBUFPOOL");
170 if (ts_params->large_mbuf_pool == NULL) {
171 /* Not already created so create */
172 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
173 "CRYPTO_LARGE_MBUFPOOL",
176 if (ts_params->large_mbuf_pool == NULL) {
178 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
183 ts_params->op_mpool = rte_crypto_op_pool_create(
184 "MBUF_CRYPTO_SYM_OP_POOL",
185 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
186 NUM_MBUFS, MBUF_CACHE_SIZE,
188 sizeof(struct rte_crypto_sym_xform) +
191 if (ts_params->op_mpool == NULL) {
192 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
196 /* Create an AESNI MB device if required */
197 if (gbl_driver_id == rte_cryptodev_driver_id_get(
198 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
199 nb_devs = rte_cryptodev_device_count_by_driver(
200 rte_cryptodev_driver_id_get(
201 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
206 TEST_ASSERT(ret == 0,
207 "Failed to create instance of"
209 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
213 /* Create an AESNI GCM device if required */
214 if (gbl_driver_id == rte_cryptodev_driver_id_get(
215 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
216 nb_devs = rte_cryptodev_device_count_by_driver(
217 rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
220 TEST_ASSERT_SUCCESS(rte_vdev_init(
221 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
222 "Failed to create instance of"
224 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
228 /* Create a SNOW 3G device if required */
229 if (gbl_driver_id == rte_cryptodev_driver_id_get(
230 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
231 nb_devs = rte_cryptodev_device_count_by_driver(
232 rte_cryptodev_driver_id_get(
233 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
235 TEST_ASSERT_SUCCESS(rte_vdev_init(
236 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
237 "Failed to create instance of"
239 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
243 /* Create a KASUMI device if required */
244 if (gbl_driver_id == rte_cryptodev_driver_id_get(
245 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
246 nb_devs = rte_cryptodev_device_count_by_driver(
247 rte_cryptodev_driver_id_get(
248 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
250 TEST_ASSERT_SUCCESS(rte_vdev_init(
251 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
252 "Failed to create instance of"
254 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
258 /* Create a ZUC device if required */
259 if (gbl_driver_id == rte_cryptodev_driver_id_get(
260 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
261 nb_devs = rte_cryptodev_device_count_by_driver(
262 rte_cryptodev_driver_id_get(
263 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
265 TEST_ASSERT_SUCCESS(rte_vdev_init(
266 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
267 "Failed to create instance of"
269 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
273 /* Create a NULL device if required */
274 if (gbl_driver_id == rte_cryptodev_driver_id_get(
275 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
276 nb_devs = rte_cryptodev_device_count_by_driver(
277 rte_cryptodev_driver_id_get(
278 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
281 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
283 TEST_ASSERT(ret == 0,
284 "Failed to create instance of"
286 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
290 /* Create an OPENSSL device if required */
291 if (gbl_driver_id == rte_cryptodev_driver_id_get(
292 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
293 nb_devs = rte_cryptodev_device_count_by_driver(
294 rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
298 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
301 TEST_ASSERT(ret == 0, "Failed to create "
302 "instance of pmd : %s",
303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
307 /* Create a ARMv8 device if required */
308 if (gbl_driver_id == rte_cryptodev_driver_id_get(
309 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
310 nb_devs = rte_cryptodev_device_count_by_driver(
311 rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
315 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
318 TEST_ASSERT(ret == 0, "Failed to create "
319 "instance of pmd : %s",
320 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
324 /* Create a MVSAM device if required */
325 if (gbl_driver_id == rte_cryptodev_driver_id_get(
326 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
327 nb_devs = rte_cryptodev_device_count_by_driver(
328 rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
332 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
335 TEST_ASSERT(ret == 0, "Failed to create "
336 "instance of pmd : %s",
337 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
341 /* Create an CCP device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
349 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
352 TEST_ASSERT(ret == 0, "Failed to create "
353 "instance of pmd : %s",
354 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
358 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
359 char vdev_args[VDEV_ARGS_SIZE] = {""};
360 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
361 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
362 uint16_t slave_core_count = 0;
363 uint16_t socket_id = 0;
365 if (gbl_driver_id == rte_cryptodev_driver_id_get(
366 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
368 /* Identify the Slave Cores
369 * Use 2 slave cores for the device args
371 RTE_LCORE_FOREACH_SLAVE(i) {
372 if (slave_core_count > 1)
374 snprintf(vdev_args, sizeof(vdev_args),
375 "%s%d", temp_str, i);
376 strcpy(temp_str, vdev_args);
377 strcat(temp_str, ";");
379 socket_id = lcore_config[i].socket_id;
381 if (slave_core_count != 2) {
383 "Cryptodev scheduler test require at least "
384 "two slave cores to run. "
385 "Please use the correct coremask.\n");
388 strcpy(temp_str, vdev_args);
389 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
390 temp_str, socket_id);
391 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
392 nb_devs = rte_cryptodev_device_count_by_driver(
393 rte_cryptodev_driver_id_get(
394 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
397 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
399 TEST_ASSERT(ret == 0,
400 "Failed to create instance %u of"
402 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
405 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
407 nb_devs = rte_cryptodev_count();
409 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
413 /* Create list of valid crypto devs */
414 for (i = 0; i < nb_devs; i++) {
415 rte_cryptodev_info_get(i, &info);
416 if (info.driver_id == gbl_driver_id)
417 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
420 if (ts_params->valid_dev_count < 1)
423 /* Set up all the qps on the first of the valid devices found */
425 dev_id = ts_params->valid_devs[0];
427 rte_cryptodev_info_get(dev_id, &info);
429 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
430 ts_params->conf.socket_id = SOCKET_ID_ANY;
432 unsigned int session_size =
433 rte_cryptodev_sym_get_private_session_size(dev_id);
436 * Create mempool with maximum number of sessions * 2,
437 * to include the session headers
439 if (info.sym.max_nb_sessions != 0 &&
440 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
441 RTE_LOG(ERR, USER1, "Device does not support "
442 "at least %u sessions\n",
447 ts_params->session_mpool = rte_mempool_create(
451 0, 0, NULL, NULL, NULL,
455 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
456 "session mempool allocation failed");
458 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
460 "Failed to configure cryptodev %u with %u qps",
461 dev_id, ts_params->conf.nb_queue_pairs);
463 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
464 ts_params->qp_conf.mp_session = ts_params->session_mpool;
465 ts_params->qp_conf.mp_session_private = ts_params->session_mpool;
467 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
468 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
469 dev_id, qp_id, &ts_params->qp_conf,
470 rte_cryptodev_socket_id(dev_id)),
471 "Failed to setup queue pair %u on cryptodev %u",
479 testsuite_teardown(void)
481 struct crypto_testsuite_params *ts_params = &testsuite_params;
483 if (ts_params->mbuf_pool != NULL) {
484 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
485 rte_mempool_avail_count(ts_params->mbuf_pool));
488 if (ts_params->op_mpool != NULL) {
489 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
490 rte_mempool_avail_count(ts_params->op_mpool));
493 /* Free session mempools */
494 if (ts_params->session_mpool != NULL) {
495 rte_mempool_free(ts_params->session_mpool);
496 ts_params->session_mpool = NULL;
503 struct crypto_testsuite_params *ts_params = &testsuite_params;
504 struct crypto_unittest_params *ut_params = &unittest_params;
508 /* Clear unit test parameters before running test */
509 memset(ut_params, 0, sizeof(*ut_params));
511 /* Reconfigure device to default parameters */
512 ts_params->conf.socket_id = SOCKET_ID_ANY;
514 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
516 "Failed to configure cryptodev %u",
517 ts_params->valid_devs[0]);
519 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
520 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
521 ts_params->valid_devs[0], qp_id,
523 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
524 "Failed to setup queue pair %u on cryptodev %u",
525 qp_id, ts_params->valid_devs[0]);
529 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
531 /* Start the device */
532 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
533 "Failed to start cryptodev %u",
534 ts_params->valid_devs[0]);
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 struct crypto_unittest_params *ut_params = &unittest_params;
544 struct rte_cryptodev_stats stats;
546 /* free crypto session structure */
547 if (ut_params->sess) {
548 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
550 rte_cryptodev_sym_session_free(ut_params->sess);
551 ut_params->sess = NULL;
554 /* free crypto operation structure */
556 rte_crypto_op_free(ut_params->op);
559 * free mbuf - both obuf and ibuf are usually the same,
560 * so check if they point at the same address is necessary,
561 * to avoid freeing the mbuf twice.
563 if (ut_params->obuf) {
564 rte_pktmbuf_free(ut_params->obuf);
565 if (ut_params->ibuf == ut_params->obuf)
569 if (ut_params->ibuf) {
570 rte_pktmbuf_free(ut_params->ibuf);
574 if (ts_params->mbuf_pool != NULL)
575 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
576 rte_mempool_avail_count(ts_params->mbuf_pool));
578 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
580 /* Stop the device */
581 rte_cryptodev_stop(ts_params->valid_devs[0]);
585 test_device_configure_invalid_dev_id(void)
587 struct crypto_testsuite_params *ts_params = &testsuite_params;
588 uint16_t dev_id, num_devs = 0;
590 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
591 "Need at least %d devices for test", 1);
593 /* valid dev_id values */
594 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
596 /* Stop the device in case it's started so it can be configured */
597 rte_cryptodev_stop(dev_id);
599 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
600 "Failed test for rte_cryptodev_configure: "
601 "invalid dev_num %u", dev_id);
603 /* invalid dev_id values */
606 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
607 "Failed test for rte_cryptodev_configure: "
608 "invalid dev_num %u", dev_id);
612 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
613 "Failed test for rte_cryptodev_configure:"
614 "invalid dev_num %u", dev_id);
620 test_device_configure_invalid_queue_pair_ids(void)
622 struct crypto_testsuite_params *ts_params = &testsuite_params;
623 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
625 /* Stop the device in case it's started so it can be configured */
626 rte_cryptodev_stop(ts_params->valid_devs[0]);
628 /* valid - one queue pairs */
629 ts_params->conf.nb_queue_pairs = 1;
631 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
633 "Failed to configure cryptodev: dev_id %u, qp_id %u",
634 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
637 /* valid - max value queue pairs */
638 ts_params->conf.nb_queue_pairs = orig_nb_qps;
640 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
642 "Failed to configure cryptodev: dev_id %u, qp_id %u",
643 ts_params->valid_devs[0],
644 ts_params->conf.nb_queue_pairs);
647 /* invalid - zero queue pairs */
648 ts_params->conf.nb_queue_pairs = 0;
650 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
652 "Failed test for rte_cryptodev_configure, dev_id %u,"
654 ts_params->valid_devs[0],
655 ts_params->conf.nb_queue_pairs);
658 /* invalid - max value supported by field queue pairs */
659 ts_params->conf.nb_queue_pairs = UINT16_MAX;
661 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
663 "Failed test for rte_cryptodev_configure, dev_id %u,"
665 ts_params->valid_devs[0],
666 ts_params->conf.nb_queue_pairs);
669 /* invalid - max value + 1 queue pairs */
670 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
672 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
674 "Failed test for rte_cryptodev_configure, dev_id %u,"
676 ts_params->valid_devs[0],
677 ts_params->conf.nb_queue_pairs);
679 /* revert to original testsuite value */
680 ts_params->conf.nb_queue_pairs = orig_nb_qps;
686 test_queue_pair_descriptor_setup(void)
688 struct crypto_testsuite_params *ts_params = &testsuite_params;
689 struct rte_cryptodev_info dev_info;
690 struct rte_cryptodev_qp_conf qp_conf = {
691 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
696 /* Stop the device in case it's started so it can be configured */
697 rte_cryptodev_stop(ts_params->valid_devs[0]);
700 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
702 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
704 "Failed to configure cryptodev %u",
705 ts_params->valid_devs[0]);
708 * Test various ring sizes on this device. memzones can't be
709 * freed so are re-used if ring is released and re-created.
711 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
712 qp_conf.mp_session = ts_params->session_mpool;
713 qp_conf.mp_session_private = ts_params->session_mpool;
715 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
716 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
717 ts_params->valid_devs[0], qp_id, &qp_conf,
718 rte_cryptodev_socket_id(
719 ts_params->valid_devs[0])),
721 "rte_cryptodev_queue_pair_setup: num_inflights "
722 "%u on qp %u on cryptodev %u",
723 qp_conf.nb_descriptors, qp_id,
724 ts_params->valid_devs[0]);
727 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
729 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
730 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
731 ts_params->valid_devs[0], qp_id, &qp_conf,
732 rte_cryptodev_socket_id(
733 ts_params->valid_devs[0])),
735 " rte_cryptodev_queue_pair_setup: num_inflights"
736 " %u on qp %u on cryptodev %u",
737 qp_conf.nb_descriptors, qp_id,
738 ts_params->valid_devs[0]);
741 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
743 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
744 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
745 ts_params->valid_devs[0], qp_id, &qp_conf,
746 rte_cryptodev_socket_id(
747 ts_params->valid_devs[0])),
749 "rte_cryptodev_queue_pair_setup: num_inflights"
750 " %u on qp %u on cryptodev %u",
751 qp_conf.nb_descriptors, qp_id,
752 ts_params->valid_devs[0]);
755 /* invalid number of descriptors - max supported + 2 */
756 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
758 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
759 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
760 ts_params->valid_devs[0], qp_id, &qp_conf,
761 rte_cryptodev_socket_id(
762 ts_params->valid_devs[0])),
763 "Unexpectedly passed test for "
764 "rte_cryptodev_queue_pair_setup:"
765 "num_inflights %u on qp %u on cryptodev %u",
766 qp_conf.nb_descriptors, qp_id,
767 ts_params->valid_devs[0]);
770 /* invalid number of descriptors - max value of parameter */
771 qp_conf.nb_descriptors = UINT32_MAX-1;
773 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
774 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
775 ts_params->valid_devs[0], qp_id, &qp_conf,
776 rte_cryptodev_socket_id(
777 ts_params->valid_devs[0])),
778 "Unexpectedly passed test for "
779 "rte_cryptodev_queue_pair_setup:"
780 "num_inflights %u on qp %u on cryptodev %u",
781 qp_conf.nb_descriptors, qp_id,
782 ts_params->valid_devs[0]);
785 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
787 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
788 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
789 ts_params->valid_devs[0], qp_id, &qp_conf,
790 rte_cryptodev_socket_id(
791 ts_params->valid_devs[0])),
793 " rte_cryptodev_queue_pair_setup:"
794 "num_inflights %u on qp %u on cryptodev %u",
795 qp_conf.nb_descriptors, qp_id,
796 ts_params->valid_devs[0]);
799 /* invalid number of descriptors - max supported + 1 */
800 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
802 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
803 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
804 ts_params->valid_devs[0], qp_id, &qp_conf,
805 rte_cryptodev_socket_id(
806 ts_params->valid_devs[0])),
807 "Unexpectedly passed test for "
808 "rte_cryptodev_queue_pair_setup:"
809 "num_inflights %u on qp %u on cryptodev %u",
810 qp_conf.nb_descriptors, qp_id,
811 ts_params->valid_devs[0]);
814 /* test invalid queue pair id */
815 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
817 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
819 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
820 ts_params->valid_devs[0],
822 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
823 "Failed test for rte_cryptodev_queue_pair_setup:"
824 "invalid qp %u on cryptodev %u",
825 qp_id, ts_params->valid_devs[0]);
827 qp_id = 0xffff; /*invalid*/
829 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
830 ts_params->valid_devs[0],
832 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
833 "Failed test for rte_cryptodev_queue_pair_setup:"
834 "invalid qp %u on cryptodev %u",
835 qp_id, ts_params->valid_devs[0]);
840 /* ***** Plaintext data for tests ***** */
842 const char catch_22_quote_1[] =
843 "There was only one catch and that was Catch-22, which "
844 "specified that a concern for one's safety in the face of "
845 "dangers that were real and immediate was the process of a "
846 "rational mind. Orr was crazy and could be grounded. All he "
847 "had to do was ask; and as soon as he did, he would no longer "
848 "be crazy and would have to fly more missions. Orr would be "
849 "crazy to fly more missions and sane if he didn't, but if he "
850 "was sane he had to fly them. If he flew them he was crazy "
851 "and didn't have to; but if he didn't want to he was sane and "
852 "had to. Yossarian was moved very deeply by the absolute "
853 "simplicity of this clause of Catch-22 and let out a "
854 "respectful whistle. \"That's some catch, that Catch-22\", he "
855 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
857 const char catch_22_quote[] =
858 "What a lousy earth! He wondered how many people were "
859 "destitute that same night even in his own prosperous country, "
860 "how many homes were shanties, how many husbands were drunk "
861 "and wives socked, and how many children were bullied, abused, "
862 "or abandoned. How many families hungered for food they could "
863 "not afford to buy? How many hearts were broken? How many "
864 "suicides would take place that same night, how many people "
865 "would go insane? How many cockroaches and landlords would "
866 "triumph? How many winners were losers, successes failures, "
867 "and rich men poor men? How many wise guys were stupid? How "
868 "many happy endings were unhappy endings? How many honest men "
869 "were liars, brave men cowards, loyal men traitors, how many "
870 "sainted men were corrupt, how many people in positions of "
871 "trust had sold their souls to bodyguards, how many had never "
872 "had souls? How many straight-and-narrow paths were crooked "
873 "paths? How many best families were worst families and how "
874 "many good people were bad people? When you added them all up "
875 "and then subtracted, you might be left with only the children, "
876 "and perhaps with Albert Einstein and an old violinist or "
877 "sculptor somewhere.";
879 #define QUOTE_480_BYTES (480)
880 #define QUOTE_512_BYTES (512)
881 #define QUOTE_768_BYTES (768)
882 #define QUOTE_1024_BYTES (1024)
886 /* ***** SHA1 Hash Tests ***** */
888 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
890 static uint8_t hmac_sha1_key[] = {
891 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
892 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
893 0xDE, 0xF4, 0xDE, 0xAD };
895 /* ***** SHA224 Hash Tests ***** */
897 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
900 /* ***** AES-CBC Cipher Tests ***** */
902 #define CIPHER_KEY_LENGTH_AES_CBC (16)
903 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
905 static uint8_t aes_cbc_key[] = {
906 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
907 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
909 static uint8_t aes_cbc_iv[] = {
910 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
911 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
914 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
916 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
917 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
918 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
919 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
920 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
921 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
922 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
923 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
924 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
925 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
926 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
927 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
928 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
929 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
930 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
931 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
932 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
933 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
934 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
935 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
936 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
937 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
938 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
939 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
940 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
941 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
942 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
943 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
944 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
945 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
946 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
947 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
948 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
949 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
950 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
951 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
952 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
953 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
954 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
955 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
956 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
957 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
958 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
959 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
960 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
961 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
962 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
963 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
964 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
965 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
966 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
967 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
968 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
969 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
970 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
971 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
972 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
973 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
974 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
975 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
976 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
977 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
978 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
979 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
980 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
983 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
984 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
985 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
986 0x18, 0x8c, 0x1d, 0x32
990 /* Multisession Vector context Test */
992 static uint8_t ms_aes_cbc_key0[] = {
993 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
994 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
997 static uint8_t ms_aes_cbc_iv0[] = {
998 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
999 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1002 static const uint8_t ms_aes_cbc_cipher0[] = {
1003 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1004 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1005 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1006 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1007 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1008 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1009 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1010 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1011 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1012 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1013 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1014 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1015 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1016 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1017 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1018 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1019 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1020 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1021 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1022 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1023 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1024 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1025 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1026 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1027 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1028 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1029 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1030 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1031 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1032 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1033 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1034 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1035 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1036 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1037 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1038 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1039 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1040 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1041 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1042 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1043 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1044 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1045 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1046 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1047 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1048 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1049 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1050 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1051 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1052 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1053 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1054 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1055 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1056 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1057 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1058 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1059 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1060 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1061 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1062 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1063 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1064 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1065 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1066 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1070 static uint8_t ms_hmac_key0[] = {
1071 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1072 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1073 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1074 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1075 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1076 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1077 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1078 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1081 static const uint8_t ms_hmac_digest0[] = {
1082 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1083 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1084 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1085 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1086 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1087 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1088 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1089 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1093 /* Begin session 1 */
1095 static uint8_t ms_aes_cbc_key1[] = {
1096 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1097 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1100 static uint8_t ms_aes_cbc_iv1[] = {
1101 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1102 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1105 static const uint8_t ms_aes_cbc_cipher1[] = {
1106 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1107 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1108 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1109 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1110 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1111 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1112 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1113 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1114 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1115 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1116 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1117 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1118 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1119 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1120 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1121 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1122 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1123 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1124 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1125 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1126 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1127 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1128 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1129 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1130 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1131 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1132 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1133 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1134 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1135 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1136 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1137 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1138 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1139 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1140 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1141 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1142 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1143 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1144 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1145 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1146 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1147 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1148 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1149 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1150 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1151 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1152 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1153 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1154 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1155 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1156 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1157 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1158 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1159 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1160 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1161 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1162 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1163 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1164 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1165 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1166 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1167 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1168 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1169 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1173 static uint8_t ms_hmac_key1[] = {
1174 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1175 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1176 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1177 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1178 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1179 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1180 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1181 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1184 static const uint8_t ms_hmac_digest1[] = {
1185 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1186 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1187 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1188 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1189 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1190 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1191 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1192 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1195 /* Begin Session 2 */
1196 static uint8_t ms_aes_cbc_key2[] = {
1197 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1198 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1201 static uint8_t ms_aes_cbc_iv2[] = {
1202 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1203 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1206 static const uint8_t ms_aes_cbc_cipher2[] = {
1207 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1208 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1209 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1210 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1211 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1212 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1213 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1214 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1215 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1216 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1217 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1218 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1219 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1220 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1221 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1222 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1223 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1224 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1225 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1226 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1227 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1228 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1229 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1230 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1231 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1232 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1233 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1234 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1235 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1236 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1237 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1238 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1239 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1240 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1241 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1242 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1243 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1244 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1245 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1246 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1247 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1248 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1249 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1250 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1251 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1252 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1253 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1254 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1255 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1256 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1257 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1258 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1259 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1260 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1261 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1262 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1263 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1264 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1265 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1266 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1267 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1268 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1269 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1270 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1273 static uint8_t ms_hmac_key2[] = {
1274 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1275 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1276 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1277 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1278 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1279 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1280 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1281 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1284 static const uint8_t ms_hmac_digest2[] = {
1285 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1286 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1287 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1288 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1289 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1290 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1291 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1292 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1299 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1301 struct crypto_testsuite_params *ts_params = &testsuite_params;
1302 struct crypto_unittest_params *ut_params = &unittest_params;
1304 /* Generate test mbuf data and space for digest */
1305 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1306 catch_22_quote, QUOTE_512_BYTES, 0);
1308 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1309 DIGEST_BYTE_LENGTH_SHA1);
1310 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1312 /* Setup Cipher Parameters */
1313 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1314 ut_params->cipher_xform.next = &ut_params->auth_xform;
1316 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1317 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1318 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1319 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1320 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1321 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1323 /* Setup HMAC Parameters */
1324 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1326 ut_params->auth_xform.next = NULL;
1328 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1329 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1330 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1331 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1332 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1334 ut_params->sess = rte_cryptodev_sym_session_create(
1335 ts_params->session_mpool);
1337 /* Create crypto session*/
1338 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1339 ut_params->sess, &ut_params->cipher_xform,
1340 ts_params->session_mpool);
1341 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1343 /* Generate crypto op data structure */
1344 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1345 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1346 TEST_ASSERT_NOT_NULL(ut_params->op,
1347 "Failed to allocate symmetric crypto operation struct");
1349 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1351 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1353 /* set crypto operation source mbuf */
1354 sym_op->m_src = ut_params->ibuf;
1356 /* Set crypto operation authentication parameters */
1357 sym_op->auth.digest.data = ut_params->digest;
1358 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1359 ut_params->ibuf, QUOTE_512_BYTES);
1361 sym_op->auth.data.offset = 0;
1362 sym_op->auth.data.length = QUOTE_512_BYTES;
1364 /* Copy IV at the end of the crypto operation */
1365 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1366 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1368 /* Set crypto operation cipher parameters */
1369 sym_op->cipher.data.offset = 0;
1370 sym_op->cipher.data.length = QUOTE_512_BYTES;
1372 /* Process crypto operation */
1373 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1374 ut_params->op), "failed to process sym crypto op");
1376 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1377 "crypto op processing failed");
1380 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1383 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1384 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1386 "ciphertext data not as expected");
1388 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1390 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1391 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1392 gbl_driver_id == rte_cryptodev_driver_id_get(
1393 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1394 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1395 DIGEST_BYTE_LENGTH_SHA1,
1396 "Generated digest data not as expected");
1398 return TEST_SUCCESS;
1401 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1403 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1405 static uint8_t hmac_sha512_key[] = {
1406 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1407 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1408 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1409 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1410 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1411 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1412 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1413 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1415 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1416 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1417 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1418 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1419 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1420 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1421 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1422 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1423 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1428 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1429 struct crypto_unittest_params *ut_params,
1430 uint8_t *cipher_key,
1434 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1435 struct crypto_unittest_params *ut_params,
1436 struct crypto_testsuite_params *ts_params,
1437 const uint8_t *cipher,
1438 const uint8_t *digest,
1443 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1444 struct crypto_unittest_params *ut_params,
1445 uint8_t *cipher_key,
1449 /* Setup Cipher Parameters */
1450 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1451 ut_params->cipher_xform.next = NULL;
1453 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1454 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1455 ut_params->cipher_xform.cipher.key.data = cipher_key;
1456 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1457 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1458 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1460 /* Setup HMAC Parameters */
1461 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1462 ut_params->auth_xform.next = &ut_params->cipher_xform;
1464 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1465 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1466 ut_params->auth_xform.auth.key.data = hmac_key;
1467 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1468 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1470 return TEST_SUCCESS;
1475 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1476 struct crypto_unittest_params *ut_params,
1477 struct crypto_testsuite_params *ts_params,
1478 const uint8_t *cipher,
1479 const uint8_t *digest,
1482 /* Generate test mbuf data and digest */
1483 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1486 QUOTE_512_BYTES, 0);
1488 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1489 DIGEST_BYTE_LENGTH_SHA512);
1490 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1492 rte_memcpy(ut_params->digest,
1494 DIGEST_BYTE_LENGTH_SHA512);
1496 /* Generate Crypto op data structure */
1497 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1498 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1499 TEST_ASSERT_NOT_NULL(ut_params->op,
1500 "Failed to allocate symmetric crypto operation struct");
1502 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1504 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1506 /* set crypto operation source mbuf */
1507 sym_op->m_src = ut_params->ibuf;
1509 sym_op->auth.digest.data = ut_params->digest;
1510 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1511 ut_params->ibuf, QUOTE_512_BYTES);
1513 sym_op->auth.data.offset = 0;
1514 sym_op->auth.data.length = QUOTE_512_BYTES;
1516 /* Copy IV at the end of the crypto operation */
1517 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1518 iv, CIPHER_IV_LENGTH_AES_CBC);
1520 sym_op->cipher.data.offset = 0;
1521 sym_op->cipher.data.length = QUOTE_512_BYTES;
1523 /* Process crypto operation */
1524 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1525 ut_params->op), "failed to process sym crypto op");
1527 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1528 "crypto op processing failed");
1530 ut_params->obuf = ut_params->op->sym->m_src;
1533 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1534 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1537 "Plaintext data not as expected");
1540 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1541 "Digest verification failed");
1543 return TEST_SUCCESS;
1547 test_AES_cipheronly_mb_all(void)
1549 struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1553 ts_params->op_mpool,
1554 ts_params->session_mpool,
1555 ts_params->valid_devs[0],
1556 rte_cryptodev_driver_id_get(
1557 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1558 BLKCIPHER_AES_CIPHERONLY_TYPE);
1560 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1562 return TEST_SUCCESS;
1566 test_AES_docsis_mb_all(void)
1568 struct crypto_testsuite_params *ts_params = &testsuite_params;
1571 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1572 ts_params->op_mpool,
1573 ts_params->session_mpool,
1574 ts_params->valid_devs[0],
1575 rte_cryptodev_driver_id_get(
1576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1577 BLKCIPHER_AES_DOCSIS_TYPE);
1579 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1581 return TEST_SUCCESS;
1585 test_AES_docsis_qat_all(void)
1587 struct crypto_testsuite_params *ts_params = &testsuite_params;
1590 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1591 ts_params->op_mpool,
1592 ts_params->session_mpool,
1593 ts_params->valid_devs[0],
1594 rte_cryptodev_driver_id_get(
1595 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1596 BLKCIPHER_AES_DOCSIS_TYPE);
1598 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1600 return TEST_SUCCESS;
1604 test_DES_docsis_qat_all(void)
1606 struct crypto_testsuite_params *ts_params = &testsuite_params;
1609 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1610 ts_params->op_mpool,
1611 ts_params->session_mpool,
1612 ts_params->valid_devs[0],
1613 rte_cryptodev_driver_id_get(
1614 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1615 BLKCIPHER_DES_DOCSIS_TYPE);
1617 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1619 return TEST_SUCCESS;
1623 test_authonly_mb_all(void)
1625 struct crypto_testsuite_params *ts_params = &testsuite_params;
1628 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1629 ts_params->op_mpool,
1630 ts_params->session_mpool,
1631 ts_params->valid_devs[0],
1632 rte_cryptodev_driver_id_get(
1633 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1634 BLKCIPHER_AUTHONLY_TYPE);
1636 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1638 return TEST_SUCCESS;
1642 test_authonly_qat_all(void)
1644 struct crypto_testsuite_params *ts_params = &testsuite_params;
1647 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1648 ts_params->op_mpool,
1649 ts_params->session_mpool,
1650 ts_params->valid_devs[0],
1651 rte_cryptodev_driver_id_get(
1652 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1653 BLKCIPHER_AUTHONLY_TYPE);
1655 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1657 return TEST_SUCCESS;
1660 test_AES_chain_mb_all(void)
1662 struct crypto_testsuite_params *ts_params = &testsuite_params;
1665 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1666 ts_params->op_mpool,
1667 ts_params->session_mpool,
1668 ts_params->valid_devs[0],
1669 rte_cryptodev_driver_id_get(
1670 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1671 BLKCIPHER_AES_CHAIN_TYPE);
1673 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1675 return TEST_SUCCESS;
1678 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1681 test_AES_cipheronly_scheduler_all(void)
1683 struct crypto_testsuite_params *ts_params = &testsuite_params;
1686 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1687 ts_params->op_mpool,
1688 ts_params->session_mpool,
1689 ts_params->valid_devs[0],
1690 rte_cryptodev_driver_id_get(
1691 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1692 BLKCIPHER_AES_CIPHERONLY_TYPE);
1694 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1696 return TEST_SUCCESS;
1700 test_AES_chain_scheduler_all(void)
1702 struct crypto_testsuite_params *ts_params = &testsuite_params;
1705 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1706 ts_params->op_mpool,
1707 ts_params->session_mpool,
1708 ts_params->valid_devs[0],
1709 rte_cryptodev_driver_id_get(
1710 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1711 BLKCIPHER_AES_CHAIN_TYPE);
1713 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1715 return TEST_SUCCESS;
1719 test_authonly_scheduler_all(void)
1721 struct crypto_testsuite_params *ts_params = &testsuite_params;
1724 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1725 ts_params->op_mpool,
1726 ts_params->session_mpool,
1727 ts_params->valid_devs[0],
1728 rte_cryptodev_driver_id_get(
1729 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1730 BLKCIPHER_AUTHONLY_TYPE);
1732 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1734 return TEST_SUCCESS;
1737 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1740 test_AES_chain_openssl_all(void)
1742 struct crypto_testsuite_params *ts_params = &testsuite_params;
1745 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1746 ts_params->op_mpool,
1747 ts_params->session_mpool,
1748 ts_params->valid_devs[0],
1749 rte_cryptodev_driver_id_get(
1750 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1751 BLKCIPHER_AES_CHAIN_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1759 test_AES_cipheronly_openssl_all(void)
1761 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1765 ts_params->op_mpool,
1766 ts_params->session_mpool,
1767 ts_params->valid_devs[0],
1768 rte_cryptodev_driver_id_get(
1769 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1770 BLKCIPHER_AES_CIPHERONLY_TYPE);
1772 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1774 return TEST_SUCCESS;
1778 test_AES_chain_ccp_all(void)
1780 struct crypto_testsuite_params *ts_params = &testsuite_params;
1783 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1784 ts_params->op_mpool,
1785 ts_params->session_mpool,
1786 ts_params->valid_devs[0],
1787 rte_cryptodev_driver_id_get(
1788 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1789 BLKCIPHER_AES_CHAIN_TYPE);
1791 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1793 return TEST_SUCCESS;
1797 test_AES_cipheronly_ccp_all(void)
1799 struct crypto_testsuite_params *ts_params = &testsuite_params;
1802 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1803 ts_params->op_mpool,
1804 ts_params->session_mpool,
1805 ts_params->valid_devs[0],
1806 rte_cryptodev_driver_id_get(
1807 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1808 BLKCIPHER_AES_CIPHERONLY_TYPE);
1810 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1812 return TEST_SUCCESS;
1816 test_AES_chain_qat_all(void)
1818 struct crypto_testsuite_params *ts_params = &testsuite_params;
1821 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1822 ts_params->op_mpool,
1823 ts_params->session_mpool,
1824 ts_params->valid_devs[0],
1825 rte_cryptodev_driver_id_get(
1826 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1827 BLKCIPHER_AES_CHAIN_TYPE);
1829 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1831 return TEST_SUCCESS;
1835 test_AES_cipheronly_qat_all(void)
1837 struct crypto_testsuite_params *ts_params = &testsuite_params;
1840 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1841 ts_params->op_mpool,
1842 ts_params->session_mpool,
1843 ts_params->valid_devs[0],
1844 rte_cryptodev_driver_id_get(
1845 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1846 BLKCIPHER_AES_CIPHERONLY_TYPE);
1848 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1850 return TEST_SUCCESS;
1854 test_AES_cipheronly_virtio_all(void)
1856 struct crypto_testsuite_params *ts_params = &testsuite_params;
1859 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1860 ts_params->op_mpool,
1861 ts_params->session_mpool,
1862 ts_params->valid_devs[0],
1863 rte_cryptodev_driver_id_get(
1864 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1865 BLKCIPHER_AES_CIPHERONLY_TYPE);
1867 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1869 return TEST_SUCCESS;
1873 test_AES_chain_caam_jr_all(void)
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1878 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1879 ts_params->op_mpool,
1880 ts_params->session_mpool,
1881 ts_params->valid_devs[0],
1882 rte_cryptodev_driver_id_get(
1883 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1884 BLKCIPHER_AES_CHAIN_TYPE);
1886 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1888 return TEST_SUCCESS;
1892 test_AES_cipheronly_caam_jr_all(void)
1894 struct crypto_testsuite_params *ts_params = &testsuite_params;
1897 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1898 ts_params->op_mpool,
1899 ts_params->session_mpool,
1900 ts_params->valid_devs[0],
1901 rte_cryptodev_driver_id_get(
1902 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1903 BLKCIPHER_AES_CIPHERONLY_TYPE);
1905 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1907 return TEST_SUCCESS;
1911 test_authonly_caam_jr_all(void)
1913 struct crypto_testsuite_params *ts_params = &testsuite_params;
1916 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1917 ts_params->op_mpool,
1918 ts_params->session_mpool,
1919 ts_params->valid_devs[0],
1920 rte_cryptodev_driver_id_get(
1921 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1922 BLKCIPHER_AUTHONLY_TYPE);
1924 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1926 return TEST_SUCCESS;
1931 test_AES_chain_dpaa_sec_all(void)
1933 struct crypto_testsuite_params *ts_params = &testsuite_params;
1936 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1937 ts_params->op_mpool,
1938 ts_params->session_mpool,
1939 ts_params->valid_devs[0],
1940 rte_cryptodev_driver_id_get(
1941 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1942 BLKCIPHER_AES_CHAIN_TYPE);
1944 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1946 return TEST_SUCCESS;
1950 test_AES_cipheronly_dpaa_sec_all(void)
1952 struct crypto_testsuite_params *ts_params = &testsuite_params;
1955 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1956 ts_params->op_mpool,
1957 ts_params->session_mpool,
1958 ts_params->valid_devs[0],
1959 rte_cryptodev_driver_id_get(
1960 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1961 BLKCIPHER_AES_CIPHERONLY_TYPE);
1963 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1965 return TEST_SUCCESS;
1969 test_authonly_dpaa_sec_all(void)
1971 struct crypto_testsuite_params *ts_params = &testsuite_params;
1974 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1975 ts_params->op_mpool,
1976 ts_params->session_mpool,
1977 ts_params->valid_devs[0],
1978 rte_cryptodev_driver_id_get(
1979 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1980 BLKCIPHER_AUTHONLY_TYPE);
1982 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1984 return TEST_SUCCESS;
1988 test_AES_chain_dpaa2_sec_all(void)
1990 struct crypto_testsuite_params *ts_params = &testsuite_params;
1993 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1994 ts_params->op_mpool,
1995 ts_params->session_mpool,
1996 ts_params->valid_devs[0],
1997 rte_cryptodev_driver_id_get(
1998 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1999 BLKCIPHER_AES_CHAIN_TYPE);
2001 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2003 return TEST_SUCCESS;
2007 test_AES_cipheronly_dpaa2_sec_all(void)
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2012 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2013 ts_params->op_mpool,
2014 ts_params->session_mpool,
2015 ts_params->valid_devs[0],
2016 rte_cryptodev_driver_id_get(
2017 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2018 BLKCIPHER_AES_CIPHERONLY_TYPE);
2020 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2022 return TEST_SUCCESS;
2026 test_authonly_dpaa2_sec_all(void)
2028 struct crypto_testsuite_params *ts_params = &testsuite_params;
2031 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2032 ts_params->op_mpool,
2033 ts_params->session_mpool,
2034 ts_params->valid_devs[0],
2035 rte_cryptodev_driver_id_get(
2036 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2037 BLKCIPHER_AUTHONLY_TYPE);
2039 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2041 return TEST_SUCCESS;
2045 test_authonly_openssl_all(void)
2047 struct crypto_testsuite_params *ts_params = &testsuite_params;
2050 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2051 ts_params->op_mpool,
2052 ts_params->session_mpool,
2053 ts_params->valid_devs[0],
2054 rte_cryptodev_driver_id_get(
2055 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2056 BLKCIPHER_AUTHONLY_TYPE);
2058 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2060 return TEST_SUCCESS;
2064 test_authonly_ccp_all(void)
2066 struct crypto_testsuite_params *ts_params = &testsuite_params;
2069 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2070 ts_params->op_mpool,
2071 ts_params->session_mpool,
2072 ts_params->valid_devs[0],
2073 rte_cryptodev_driver_id_get(
2074 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2075 BLKCIPHER_AUTHONLY_TYPE);
2077 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2079 return TEST_SUCCESS;
2083 test_AES_chain_armv8_all(void)
2085 struct crypto_testsuite_params *ts_params = &testsuite_params;
2088 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2089 ts_params->op_mpool,
2090 ts_params->session_mpool,
2091 ts_params->valid_devs[0],
2092 rte_cryptodev_driver_id_get(
2093 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2094 BLKCIPHER_AES_CHAIN_TYPE);
2096 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2098 return TEST_SUCCESS;
2102 test_AES_chain_mrvl_all(void)
2104 struct crypto_testsuite_params *ts_params = &testsuite_params;
2107 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2108 ts_params->op_mpool,
2109 ts_params->session_mpool,
2110 ts_params->valid_devs[0],
2111 rte_cryptodev_driver_id_get(
2112 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2113 BLKCIPHER_AES_CHAIN_TYPE);
2115 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2117 return TEST_SUCCESS;
2121 test_AES_cipheronly_mrvl_all(void)
2123 struct crypto_testsuite_params *ts_params = &testsuite_params;
2126 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2127 ts_params->op_mpool,
2128 ts_params->session_mpool,
2129 ts_params->valid_devs[0],
2130 rte_cryptodev_driver_id_get(
2131 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2132 BLKCIPHER_AES_CIPHERONLY_TYPE);
2134 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2136 return TEST_SUCCESS;
2140 test_authonly_mrvl_all(void)
2142 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2146 ts_params->op_mpool,
2147 ts_params->session_mpool,
2148 ts_params->valid_devs[0],
2149 rte_cryptodev_driver_id_get(
2150 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2151 BLKCIPHER_AUTHONLY_TYPE);
2153 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2155 return TEST_SUCCESS;
2159 test_3DES_chain_mrvl_all(void)
2161 struct crypto_testsuite_params *ts_params = &testsuite_params;
2164 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2165 ts_params->op_mpool,
2166 ts_params->session_mpool,
2167 ts_params->valid_devs[0],
2168 rte_cryptodev_driver_id_get(
2169 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2170 BLKCIPHER_3DES_CHAIN_TYPE);
2172 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2174 return TEST_SUCCESS;
2178 test_3DES_cipheronly_mrvl_all(void)
2180 struct crypto_testsuite_params *ts_params = &testsuite_params;
2183 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2184 ts_params->op_mpool,
2185 ts_params->session_mpool,
2186 ts_params->valid_devs[0],
2187 rte_cryptodev_driver_id_get(
2188 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2189 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2191 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2193 return TEST_SUCCESS;
2197 test_AES_chain_octeontx_all(void)
2199 struct crypto_testsuite_params *ts_params = &testsuite_params;
2202 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2203 ts_params->op_mpool, ts_params->session_mpool,
2204 ts_params->valid_devs[0],
2205 rte_cryptodev_driver_id_get(
2206 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2207 BLKCIPHER_AES_CHAIN_TYPE);
2209 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2211 return TEST_SUCCESS;
2215 test_AES_cipheronly_octeontx_all(void)
2217 struct crypto_testsuite_params *ts_params = &testsuite_params;
2220 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2221 ts_params->op_mpool, ts_params->session_mpool,
2222 ts_params->valid_devs[0],
2223 rte_cryptodev_driver_id_get(
2224 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2225 BLKCIPHER_AES_CIPHERONLY_TYPE);
2227 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2229 return TEST_SUCCESS;
2233 test_3DES_chain_octeontx_all(void)
2235 struct crypto_testsuite_params *ts_params = &testsuite_params;
2238 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2239 ts_params->op_mpool, ts_params->session_mpool,
2240 ts_params->valid_devs[0],
2241 rte_cryptodev_driver_id_get(
2242 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2243 BLKCIPHER_3DES_CHAIN_TYPE);
2245 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2247 return TEST_SUCCESS;
2251 test_3DES_cipheronly_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->valid_devs[0],
2259 rte_cryptodev_driver_id_get(
2260 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2261 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2263 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2265 return TEST_SUCCESS;
2269 test_authonly_octeontx_all(void)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2275 ts_params->op_mpool, ts_params->session_mpool,
2276 ts_params->valid_devs[0],
2277 rte_cryptodev_driver_id_get(
2278 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2279 BLKCIPHER_AUTHONLY_TYPE);
2281 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2283 return TEST_SUCCESS;
2286 /* ***** SNOW 3G Tests ***** */
2288 create_wireless_algo_hash_session(uint8_t dev_id,
2289 const uint8_t *key, const uint8_t key_len,
2290 const uint8_t iv_len, const uint8_t auth_len,
2291 enum rte_crypto_auth_operation op,
2292 enum rte_crypto_auth_algorithm algo)
2294 uint8_t hash_key[key_len];
2296 struct crypto_testsuite_params *ts_params = &testsuite_params;
2297 struct crypto_unittest_params *ut_params = &unittest_params;
2299 memcpy(hash_key, key, key_len);
2301 debug_hexdump(stdout, "key:", key, key_len);
2303 /* Setup Authentication Parameters */
2304 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2305 ut_params->auth_xform.next = NULL;
2307 ut_params->auth_xform.auth.op = op;
2308 ut_params->auth_xform.auth.algo = algo;
2309 ut_params->auth_xform.auth.key.length = key_len;
2310 ut_params->auth_xform.auth.key.data = hash_key;
2311 ut_params->auth_xform.auth.digest_length = auth_len;
2312 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2313 ut_params->auth_xform.auth.iv.length = iv_len;
2314 ut_params->sess = rte_cryptodev_sym_session_create(
2315 ts_params->session_mpool);
2317 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2318 &ut_params->auth_xform, ts_params->session_mpool);
2319 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2324 create_wireless_algo_cipher_session(uint8_t dev_id,
2325 enum rte_crypto_cipher_operation op,
2326 enum rte_crypto_cipher_algorithm algo,
2327 const uint8_t *key, const uint8_t key_len,
2330 uint8_t cipher_key[key_len];
2332 struct crypto_testsuite_params *ts_params = &testsuite_params;
2333 struct crypto_unittest_params *ut_params = &unittest_params;
2335 memcpy(cipher_key, key, key_len);
2337 /* Setup Cipher Parameters */
2338 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2339 ut_params->cipher_xform.next = NULL;
2341 ut_params->cipher_xform.cipher.algo = algo;
2342 ut_params->cipher_xform.cipher.op = op;
2343 ut_params->cipher_xform.cipher.key.data = cipher_key;
2344 ut_params->cipher_xform.cipher.key.length = key_len;
2345 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2346 ut_params->cipher_xform.cipher.iv.length = iv_len;
2348 debug_hexdump(stdout, "key:", key, key_len);
2350 /* Create Crypto session */
2351 ut_params->sess = rte_cryptodev_sym_session_create(
2352 ts_params->session_mpool);
2354 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2355 &ut_params->cipher_xform, ts_params->session_mpool);
2356 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2361 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2362 unsigned int cipher_len,
2363 unsigned int cipher_offset)
2365 struct crypto_testsuite_params *ts_params = &testsuite_params;
2366 struct crypto_unittest_params *ut_params = &unittest_params;
2368 /* Generate Crypto op data structure */
2369 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2370 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2371 TEST_ASSERT_NOT_NULL(ut_params->op,
2372 "Failed to allocate pktmbuf offload");
2374 /* Set crypto operation data parameters */
2375 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2377 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2379 /* set crypto operation source mbuf */
2380 sym_op->m_src = ut_params->ibuf;
2383 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2385 sym_op->cipher.data.length = cipher_len;
2386 sym_op->cipher.data.offset = cipher_offset;
2391 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2392 unsigned int cipher_len,
2393 unsigned int cipher_offset)
2395 struct crypto_testsuite_params *ts_params = &testsuite_params;
2396 struct crypto_unittest_params *ut_params = &unittest_params;
2398 /* Generate Crypto op data structure */
2399 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2400 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2401 TEST_ASSERT_NOT_NULL(ut_params->op,
2402 "Failed to allocate pktmbuf offload");
2404 /* Set crypto operation data parameters */
2405 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2407 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2409 /* set crypto operation source mbuf */
2410 sym_op->m_src = ut_params->ibuf;
2411 sym_op->m_dst = ut_params->obuf;
2414 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2416 sym_op->cipher.data.length = cipher_len;
2417 sym_op->cipher.data.offset = cipher_offset;
2422 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2423 enum rte_crypto_cipher_operation cipher_op,
2424 enum rte_crypto_auth_operation auth_op,
2425 enum rte_crypto_auth_algorithm auth_algo,
2426 enum rte_crypto_cipher_algorithm cipher_algo,
2427 const uint8_t *key, uint8_t key_len,
2428 uint8_t auth_iv_len, uint8_t auth_len,
2429 uint8_t cipher_iv_len)
2432 uint8_t cipher_auth_key[key_len];
2434 struct crypto_testsuite_params *ts_params = &testsuite_params;
2435 struct crypto_unittest_params *ut_params = &unittest_params;
2437 memcpy(cipher_auth_key, key, key_len);
2439 /* Setup Authentication Parameters */
2440 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2441 ut_params->auth_xform.next = NULL;
2443 ut_params->auth_xform.auth.op = auth_op;
2444 ut_params->auth_xform.auth.algo = auth_algo;
2445 ut_params->auth_xform.auth.key.length = key_len;
2446 /* Hash key = cipher key */
2447 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2448 ut_params->auth_xform.auth.digest_length = auth_len;
2449 /* Auth IV will be after cipher IV */
2450 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2451 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2453 /* Setup Cipher Parameters */
2454 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2455 ut_params->cipher_xform.next = &ut_params->auth_xform;
2457 ut_params->cipher_xform.cipher.algo = cipher_algo;
2458 ut_params->cipher_xform.cipher.op = cipher_op;
2459 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2460 ut_params->cipher_xform.cipher.key.length = key_len;
2461 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2462 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2464 debug_hexdump(stdout, "key:", key, key_len);
2466 /* Create Crypto session*/
2467 ut_params->sess = rte_cryptodev_sym_session_create(
2468 ts_params->session_mpool);
2470 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2471 &ut_params->cipher_xform, ts_params->session_mpool);
2473 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2478 create_wireless_cipher_auth_session(uint8_t dev_id,
2479 enum rte_crypto_cipher_operation cipher_op,
2480 enum rte_crypto_auth_operation auth_op,
2481 enum rte_crypto_auth_algorithm auth_algo,
2482 enum rte_crypto_cipher_algorithm cipher_algo,
2483 const struct wireless_test_data *tdata)
2485 const uint8_t key_len = tdata->key.len;
2486 uint8_t cipher_auth_key[key_len];
2488 struct crypto_testsuite_params *ts_params = &testsuite_params;
2489 struct crypto_unittest_params *ut_params = &unittest_params;
2490 const uint8_t *key = tdata->key.data;
2491 const uint8_t auth_len = tdata->digest.len;
2492 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2493 uint8_t auth_iv_len = tdata->auth_iv.len;
2495 memcpy(cipher_auth_key, key, key_len);
2497 /* Setup Authentication Parameters */
2498 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2499 ut_params->auth_xform.next = NULL;
2501 ut_params->auth_xform.auth.op = auth_op;
2502 ut_params->auth_xform.auth.algo = auth_algo;
2503 ut_params->auth_xform.auth.key.length = key_len;
2504 /* Hash key = cipher key */
2505 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2506 ut_params->auth_xform.auth.digest_length = auth_len;
2507 /* Auth IV will be after cipher IV */
2508 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2509 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2511 /* Setup Cipher Parameters */
2512 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2513 ut_params->cipher_xform.next = &ut_params->auth_xform;
2515 ut_params->cipher_xform.cipher.algo = cipher_algo;
2516 ut_params->cipher_xform.cipher.op = cipher_op;
2517 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2518 ut_params->cipher_xform.cipher.key.length = key_len;
2519 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2520 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2523 debug_hexdump(stdout, "key:", key, key_len);
2525 /* Create Crypto session*/
2526 ut_params->sess = rte_cryptodev_sym_session_create(
2527 ts_params->session_mpool);
2529 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2530 &ut_params->cipher_xform, ts_params->session_mpool);
2532 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2537 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2538 const struct wireless_test_data *tdata)
2540 return create_wireless_cipher_auth_session(dev_id,
2541 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2542 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2543 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2547 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2548 enum rte_crypto_cipher_operation cipher_op,
2549 enum rte_crypto_auth_operation auth_op,
2550 enum rte_crypto_auth_algorithm auth_algo,
2551 enum rte_crypto_cipher_algorithm cipher_algo,
2552 const uint8_t *key, const uint8_t key_len,
2553 uint8_t auth_iv_len, uint8_t auth_len,
2554 uint8_t cipher_iv_len)
2556 uint8_t auth_cipher_key[key_len];
2558 struct crypto_testsuite_params *ts_params = &testsuite_params;
2559 struct crypto_unittest_params *ut_params = &unittest_params;
2561 memcpy(auth_cipher_key, key, key_len);
2563 /* Setup Authentication Parameters */
2564 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2565 ut_params->auth_xform.auth.op = auth_op;
2566 ut_params->auth_xform.next = &ut_params->cipher_xform;
2567 ut_params->auth_xform.auth.algo = auth_algo;
2568 ut_params->auth_xform.auth.key.length = key_len;
2569 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2570 ut_params->auth_xform.auth.digest_length = auth_len;
2571 /* Auth IV will be after cipher IV */
2572 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2573 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2575 /* Setup Cipher Parameters */
2576 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2577 ut_params->cipher_xform.next = NULL;
2578 ut_params->cipher_xform.cipher.algo = cipher_algo;
2579 ut_params->cipher_xform.cipher.op = cipher_op;
2580 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2581 ut_params->cipher_xform.cipher.key.length = key_len;
2582 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2583 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2585 debug_hexdump(stdout, "key:", key, key_len);
2587 /* Create Crypto session*/
2588 ut_params->sess = rte_cryptodev_sym_session_create(
2589 ts_params->session_mpool);
2591 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2592 &ut_params->auth_xform, ts_params->session_mpool);
2594 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2600 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2601 unsigned int auth_tag_len,
2602 const uint8_t *iv, unsigned int iv_len,
2603 unsigned int data_pad_len,
2604 enum rte_crypto_auth_operation op,
2605 unsigned int auth_len, unsigned int auth_offset)
2607 struct crypto_testsuite_params *ts_params = &testsuite_params;
2609 struct crypto_unittest_params *ut_params = &unittest_params;
2611 /* Generate Crypto op data structure */
2612 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2613 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2614 TEST_ASSERT_NOT_NULL(ut_params->op,
2615 "Failed to allocate pktmbuf offload");
2617 /* Set crypto operation data parameters */
2618 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2620 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2622 /* set crypto operation source mbuf */
2623 sym_op->m_src = ut_params->ibuf;
2626 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2629 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2630 ut_params->ibuf, auth_tag_len);
2632 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2633 "no room to append auth tag");
2634 ut_params->digest = sym_op->auth.digest.data;
2635 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2636 ut_params->ibuf, data_pad_len);
2637 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2638 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2640 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2642 debug_hexdump(stdout, "digest:",
2643 sym_op->auth.digest.data,
2646 sym_op->auth.data.length = auth_len;
2647 sym_op->auth.data.offset = auth_offset;
2653 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2654 enum rte_crypto_auth_operation op)
2656 struct crypto_testsuite_params *ts_params = &testsuite_params;
2657 struct crypto_unittest_params *ut_params = &unittest_params;
2659 const uint8_t *auth_tag = tdata->digest.data;
2660 const unsigned int auth_tag_len = tdata->digest.len;
2661 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2662 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2664 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2665 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2666 const uint8_t *auth_iv = tdata->auth_iv.data;
2667 const uint8_t auth_iv_len = tdata->auth_iv.len;
2668 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2669 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2671 /* Generate Crypto op data structure */
2672 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2673 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2674 TEST_ASSERT_NOT_NULL(ut_params->op,
2675 "Failed to allocate pktmbuf offload");
2676 /* Set crypto operation data parameters */
2677 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2679 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2681 /* set crypto operation source mbuf */
2682 sym_op->m_src = ut_params->ibuf;
2685 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2686 ut_params->ibuf, auth_tag_len);
2688 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2689 "no room to append auth tag");
2690 ut_params->digest = sym_op->auth.digest.data;
2691 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2692 ut_params->ibuf, data_pad_len);
2693 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2694 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2696 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2698 debug_hexdump(stdout, "digest:",
2699 sym_op->auth.digest.data,
2702 /* Copy cipher and auth IVs at the end of the crypto operation */
2703 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2705 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2706 iv_ptr += cipher_iv_len;
2707 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2709 sym_op->cipher.data.length = cipher_len;
2710 sym_op->cipher.data.offset = 0;
2711 sym_op->auth.data.length = auth_len;
2712 sym_op->auth.data.offset = 0;
2718 create_zuc_cipher_hash_generate_operation(
2719 const struct wireless_test_data *tdata)
2721 return create_wireless_cipher_hash_operation(tdata,
2722 RTE_CRYPTO_AUTH_OP_GENERATE);
2726 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2727 const unsigned auth_tag_len,
2728 const uint8_t *auth_iv, uint8_t auth_iv_len,
2729 unsigned data_pad_len,
2730 enum rte_crypto_auth_operation op,
2731 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2732 const unsigned cipher_len, const unsigned cipher_offset,
2733 const unsigned auth_len, const unsigned auth_offset)
2735 struct crypto_testsuite_params *ts_params = &testsuite_params;
2736 struct crypto_unittest_params *ut_params = &unittest_params;
2738 /* Generate Crypto op data structure */
2739 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2740 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2741 TEST_ASSERT_NOT_NULL(ut_params->op,
2742 "Failed to allocate pktmbuf offload");
2743 /* Set crypto operation data parameters */
2744 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2746 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2748 /* set crypto operation source mbuf */
2749 sym_op->m_src = ut_params->ibuf;
2752 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2753 ut_params->ibuf, auth_tag_len);
2755 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2756 "no room to append auth tag");
2757 ut_params->digest = sym_op->auth.digest.data;
2758 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2759 ut_params->ibuf, data_pad_len);
2760 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2761 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2763 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2765 debug_hexdump(stdout, "digest:",
2766 sym_op->auth.digest.data,
2769 /* Copy cipher and auth IVs at the end of the crypto operation */
2770 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2772 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2773 iv_ptr += cipher_iv_len;
2774 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2776 sym_op->cipher.data.length = cipher_len;
2777 sym_op->cipher.data.offset = cipher_offset;
2778 sym_op->auth.data.length = auth_len;
2779 sym_op->auth.data.offset = auth_offset;
2785 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2786 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2787 const uint8_t *auth_iv, uint8_t auth_iv_len,
2788 unsigned int data_pad_len,
2789 unsigned int cipher_len, unsigned int cipher_offset,
2790 unsigned int auth_len, unsigned int auth_offset)
2792 struct crypto_testsuite_params *ts_params = &testsuite_params;
2793 struct crypto_unittest_params *ut_params = &unittest_params;
2795 /* Generate Crypto op data structure */
2796 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2797 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2798 TEST_ASSERT_NOT_NULL(ut_params->op,
2799 "Failed to allocate pktmbuf offload");
2801 /* Set crypto operation data parameters */
2802 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2804 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2806 /* set crypto operation source mbuf */
2807 sym_op->m_src = ut_params->ibuf;
2810 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2811 ut_params->ibuf, auth_tag_len);
2813 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2814 "no room to append auth tag");
2816 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2817 ut_params->ibuf, data_pad_len);
2819 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2821 debug_hexdump(stdout, "digest:",
2822 sym_op->auth.digest.data,
2825 /* Copy cipher and auth IVs at the end of the crypto operation */
2826 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2828 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2829 iv_ptr += cipher_iv_len;
2830 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2832 sym_op->cipher.data.length = cipher_len;
2833 sym_op->cipher.data.offset = cipher_offset;
2835 sym_op->auth.data.length = auth_len;
2836 sym_op->auth.data.offset = auth_offset;
2842 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2844 struct crypto_testsuite_params *ts_params = &testsuite_params;
2845 struct crypto_unittest_params *ut_params = &unittest_params;
2848 unsigned plaintext_pad_len;
2849 unsigned plaintext_len;
2852 /* Create SNOW 3G session */
2853 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2854 tdata->key.data, tdata->key.len,
2855 tdata->auth_iv.len, tdata->digest.len,
2856 RTE_CRYPTO_AUTH_OP_GENERATE,
2857 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2861 /* alloc mbuf and set payload */
2862 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2865 rte_pktmbuf_tailroom(ut_params->ibuf));
2867 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2868 /* Append data which is padded to a multiple of */
2869 /* the algorithms block size */
2870 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2873 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2875 /* Create SNOW 3G operation */
2876 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2877 tdata->auth_iv.data, tdata->auth_iv.len,
2878 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2879 tdata->validAuthLenInBits.len,
2884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2886 ut_params->obuf = ut_params->op->sym->m_src;
2887 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2888 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2889 + plaintext_pad_len;
2892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2895 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2896 "SNOW 3G Generated auth tag not as expected");
2902 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2904 struct crypto_testsuite_params *ts_params = &testsuite_params;
2905 struct crypto_unittest_params *ut_params = &unittest_params;
2908 unsigned plaintext_pad_len;
2909 unsigned plaintext_len;
2912 /* Create SNOW 3G session */
2913 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2914 tdata->key.data, tdata->key.len,
2915 tdata->auth_iv.len, tdata->digest.len,
2916 RTE_CRYPTO_AUTH_OP_VERIFY,
2917 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2920 /* alloc mbuf and set payload */
2921 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2923 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2924 rte_pktmbuf_tailroom(ut_params->ibuf));
2926 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2927 /* Append data which is padded to a multiple of */
2928 /* the algorithms block size */
2929 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2930 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2932 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2934 /* Create SNOW 3G operation */
2935 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2937 tdata->auth_iv.data, tdata->auth_iv.len,
2939 RTE_CRYPTO_AUTH_OP_VERIFY,
2940 tdata->validAuthLenInBits.len,
2945 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2948 ut_params->obuf = ut_params->op->sym->m_src;
2949 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2950 + plaintext_pad_len;
2953 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2962 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2964 struct crypto_testsuite_params *ts_params = &testsuite_params;
2965 struct crypto_unittest_params *ut_params = &unittest_params;
2968 unsigned plaintext_pad_len;
2969 unsigned plaintext_len;
2972 /* Create KASUMI session */
2973 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2974 tdata->key.data, tdata->key.len,
2975 0, tdata->digest.len,
2976 RTE_CRYPTO_AUTH_OP_GENERATE,
2977 RTE_CRYPTO_AUTH_KASUMI_F9);
2981 /* alloc mbuf and set payload */
2982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2985 rte_pktmbuf_tailroom(ut_params->ibuf));
2987 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2988 /* Append data which is padded to a multiple of */
2989 /* the algorithms block size */
2990 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2991 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2993 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2995 /* Create KASUMI operation */
2996 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2998 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2999 tdata->plaintext.len,
3004 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3006 ut_params->obuf = ut_params->op->sym->m_src;
3007 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3008 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3009 + plaintext_pad_len;
3012 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3015 DIGEST_BYTE_LENGTH_KASUMI_F9,
3016 "KASUMI Generated auth tag not as expected");
3022 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3024 struct crypto_testsuite_params *ts_params = &testsuite_params;
3025 struct crypto_unittest_params *ut_params = &unittest_params;
3028 unsigned plaintext_pad_len;
3029 unsigned plaintext_len;
3032 /* Create KASUMI session */
3033 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3034 tdata->key.data, tdata->key.len,
3035 0, tdata->digest.len,
3036 RTE_CRYPTO_AUTH_OP_VERIFY,
3037 RTE_CRYPTO_AUTH_KASUMI_F9);
3040 /* alloc mbuf and set payload */
3041 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3044 rte_pktmbuf_tailroom(ut_params->ibuf));
3046 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3047 /* Append data which is padded to a multiple */
3048 /* of the algorithms block size */
3049 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3050 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3052 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3054 /* Create KASUMI operation */
3055 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3059 RTE_CRYPTO_AUTH_OP_VERIFY,
3060 tdata->plaintext.len,
3065 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3068 ut_params->obuf = ut_params->op->sym->m_src;
3069 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3070 + plaintext_pad_len;
3073 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3082 test_snow3g_hash_generate_test_case_1(void)
3084 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3088 test_snow3g_hash_generate_test_case_2(void)
3090 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3094 test_snow3g_hash_generate_test_case_3(void)
3096 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3100 test_snow3g_hash_generate_test_case_4(void)
3102 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3106 test_snow3g_hash_generate_test_case_5(void)
3108 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3112 test_snow3g_hash_generate_test_case_6(void)
3114 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3118 test_snow3g_hash_verify_test_case_1(void)
3120 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3125 test_snow3g_hash_verify_test_case_2(void)
3127 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3131 test_snow3g_hash_verify_test_case_3(void)
3133 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3137 test_snow3g_hash_verify_test_case_4(void)
3139 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3143 test_snow3g_hash_verify_test_case_5(void)
3145 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3149 test_snow3g_hash_verify_test_case_6(void)
3151 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3155 test_kasumi_hash_generate_test_case_1(void)
3157 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3161 test_kasumi_hash_generate_test_case_2(void)
3163 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3167 test_kasumi_hash_generate_test_case_3(void)
3169 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3173 test_kasumi_hash_generate_test_case_4(void)
3175 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3179 test_kasumi_hash_generate_test_case_5(void)
3181 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3185 test_kasumi_hash_generate_test_case_6(void)
3187 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3191 test_kasumi_hash_verify_test_case_1(void)
3193 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3197 test_kasumi_hash_verify_test_case_2(void)
3199 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3203 test_kasumi_hash_verify_test_case_3(void)
3205 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3209 test_kasumi_hash_verify_test_case_4(void)
3211 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3215 test_kasumi_hash_verify_test_case_5(void)
3217 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3221 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3223 struct crypto_testsuite_params *ts_params = &testsuite_params;
3224 struct crypto_unittest_params *ut_params = &unittest_params;
3227 uint8_t *plaintext, *ciphertext;
3228 unsigned plaintext_pad_len;
3229 unsigned plaintext_len;
3231 /* Create KASUMI session */
3232 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3233 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3234 RTE_CRYPTO_CIPHER_KASUMI_F8,
3235 tdata->key.data, tdata->key.len,
3236 tdata->cipher_iv.len);
3240 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3242 /* Clear mbuf payload */
3243 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3244 rte_pktmbuf_tailroom(ut_params->ibuf));
3246 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3247 /* Append data which is padded to a multiple */
3248 /* of the algorithms block size */
3249 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3250 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3252 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3254 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3256 /* Create KASUMI operation */
3257 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3258 tdata->cipher_iv.len,
3259 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3260 tdata->validCipherOffsetInBits.len);
3264 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3266 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3268 ut_params->obuf = ut_params->op->sym->m_dst;
3269 if (ut_params->obuf)
3270 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3272 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3274 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3276 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3277 (tdata->validCipherOffsetInBits.len >> 3);
3279 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3281 reference_ciphertext,
3282 tdata->validCipherLenInBits.len,
3283 "KASUMI Ciphertext data not as expected");
3288 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3290 struct crypto_testsuite_params *ts_params = &testsuite_params;
3291 struct crypto_unittest_params *ut_params = &unittest_params;
3295 unsigned int plaintext_pad_len;
3296 unsigned int plaintext_len;
3298 uint8_t buffer[10000];
3299 const uint8_t *ciphertext;
3301 struct rte_cryptodev_info dev_info;
3303 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3305 uint64_t feat_flags = dev_info.feature_flags;
3307 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3308 printf("Device doesn't support in-place scatter-gather. "
3313 /* Create KASUMI session */
3314 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3315 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3316 RTE_CRYPTO_CIPHER_KASUMI_F8,
3317 tdata->key.data, tdata->key.len,
3318 tdata->cipher_iv.len);
3322 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3325 /* Append data which is padded to a multiple */
3326 /* of the algorithms block size */
3327 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3329 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3330 plaintext_pad_len, 10, 0);
3332 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3334 /* Create KASUMI operation */
3335 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3336 tdata->cipher_iv.len,
3337 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3338 tdata->validCipherOffsetInBits.len);
3342 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3344 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3346 ut_params->obuf = ut_params->op->sym->m_dst;
3348 if (ut_params->obuf)
3349 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3350 plaintext_len, buffer);
3352 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3353 tdata->validCipherOffsetInBits.len >> 3,
3354 plaintext_len, buffer);
3357 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3359 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3360 (tdata->validCipherOffsetInBits.len >> 3);
3362 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3364 reference_ciphertext,
3365 tdata->validCipherLenInBits.len,
3366 "KASUMI Ciphertext data not as expected");
3371 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3373 struct crypto_testsuite_params *ts_params = &testsuite_params;
3374 struct crypto_unittest_params *ut_params = &unittest_params;
3377 uint8_t *plaintext, *ciphertext;
3378 unsigned plaintext_pad_len;
3379 unsigned plaintext_len;
3381 /* Create KASUMI session */
3382 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3383 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3384 RTE_CRYPTO_CIPHER_KASUMI_F8,
3385 tdata->key.data, tdata->key.len,
3386 tdata->cipher_iv.len);
3390 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3391 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3393 /* Clear mbuf payload */
3394 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3395 rte_pktmbuf_tailroom(ut_params->ibuf));
3397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3398 /* Append data which is padded to a multiple */
3399 /* of the algorithms block size */
3400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3401 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3403 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3404 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3406 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3408 /* Create KASUMI operation */
3409 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3410 tdata->cipher_iv.len,
3411 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3412 tdata->validCipherOffsetInBits.len);
3416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3420 ut_params->obuf = ut_params->op->sym->m_dst;
3421 if (ut_params->obuf)
3422 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3424 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3426 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3428 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3429 (tdata->validCipherOffsetInBits.len >> 3);
3431 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3433 reference_ciphertext,
3434 tdata->validCipherLenInBits.len,
3435 "KASUMI Ciphertext data not as expected");
3440 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3442 struct crypto_testsuite_params *ts_params = &testsuite_params;
3443 struct crypto_unittest_params *ut_params = &unittest_params;
3446 unsigned int plaintext_pad_len;
3447 unsigned int plaintext_len;
3449 const uint8_t *ciphertext;
3450 uint8_t buffer[2048];
3452 struct rte_cryptodev_info dev_info;
3454 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3456 uint64_t feat_flags = dev_info.feature_flags;
3457 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3458 printf("Device doesn't support out-of-place scatter-gather "
3459 "in both input and output mbufs. "
3464 /* Create KASUMI session */
3465 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3466 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3467 RTE_CRYPTO_CIPHER_KASUMI_F8,
3468 tdata->key.data, tdata->key.len,
3469 tdata->cipher_iv.len);
3473 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3474 /* Append data which is padded to a multiple */
3475 /* of the algorithms block size */
3476 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3478 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3479 plaintext_pad_len, 10, 0);
3480 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3481 plaintext_pad_len, 3, 0);
3483 /* Append data which is padded to a multiple */
3484 /* of the algorithms block size */
3485 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3487 /* Create KASUMI operation */
3488 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3489 tdata->cipher_iv.len,
3490 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3491 tdata->validCipherOffsetInBits.len);
3495 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3497 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3499 ut_params->obuf = ut_params->op->sym->m_dst;
3500 if (ut_params->obuf)
3501 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3502 plaintext_pad_len, buffer);
3504 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3505 tdata->validCipherOffsetInBits.len >> 3,
3506 plaintext_pad_len, buffer);
3508 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3509 (tdata->validCipherOffsetInBits.len >> 3);
3511 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3513 reference_ciphertext,
3514 tdata->validCipherLenInBits.len,
3515 "KASUMI Ciphertext data not as expected");
3521 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3523 struct crypto_testsuite_params *ts_params = &testsuite_params;
3524 struct crypto_unittest_params *ut_params = &unittest_params;
3527 uint8_t *ciphertext, *plaintext;
3528 unsigned ciphertext_pad_len;
3529 unsigned ciphertext_len;
3531 /* Create KASUMI session */
3532 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3533 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3534 RTE_CRYPTO_CIPHER_KASUMI_F8,
3535 tdata->key.data, tdata->key.len,
3536 tdata->cipher_iv.len);
3540 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3541 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3543 /* Clear mbuf payload */
3544 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3545 rte_pktmbuf_tailroom(ut_params->ibuf));
3547 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3548 /* Append data which is padded to a multiple */
3549 /* of the algorithms block size */
3550 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3551 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3552 ciphertext_pad_len);
3553 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3554 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3556 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3558 /* Create KASUMI operation */
3559 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3560 tdata->cipher_iv.len,
3561 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3562 tdata->validCipherOffsetInBits.len);
3566 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3570 ut_params->obuf = ut_params->op->sym->m_dst;
3571 if (ut_params->obuf)
3572 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3574 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3576 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3578 const uint8_t *reference_plaintext = tdata->plaintext.data +
3579 (tdata->validCipherOffsetInBits.len >> 3);
3581 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3583 reference_plaintext,
3584 tdata->validCipherLenInBits.len,
3585 "KASUMI Plaintext data not as expected");
3590 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3592 struct crypto_testsuite_params *ts_params = &testsuite_params;
3593 struct crypto_unittest_params *ut_params = &unittest_params;
3596 uint8_t *ciphertext, *plaintext;
3597 unsigned ciphertext_pad_len;
3598 unsigned ciphertext_len;
3600 /* Create KASUMI session */
3601 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3602 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3603 RTE_CRYPTO_CIPHER_KASUMI_F8,
3604 tdata->key.data, tdata->key.len,
3605 tdata->cipher_iv.len);
3609 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3611 /* Clear mbuf payload */
3612 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3613 rte_pktmbuf_tailroom(ut_params->ibuf));
3615 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3616 /* Append data which is padded to a multiple */
3617 /* of the algorithms block size */
3618 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3619 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3620 ciphertext_pad_len);
3621 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3623 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3625 /* Create KASUMI operation */
3626 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3627 tdata->cipher_iv.len,
3628 tdata->ciphertext.len,
3629 tdata->validCipherOffsetInBits.len);
3633 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3635 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3637 ut_params->obuf = ut_params->op->sym->m_dst;
3638 if (ut_params->obuf)
3639 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3641 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3643 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3645 const uint8_t *reference_plaintext = tdata->plaintext.data +
3646 (tdata->validCipherOffsetInBits.len >> 3);
3648 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3650 reference_plaintext,
3651 tdata->validCipherLenInBits.len,
3652 "KASUMI Plaintext data not as expected");
3657 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3659 struct crypto_testsuite_params *ts_params = &testsuite_params;
3660 struct crypto_unittest_params *ut_params = &unittest_params;
3663 uint8_t *plaintext, *ciphertext;
3664 unsigned plaintext_pad_len;
3665 unsigned plaintext_len;
3667 /* Create SNOW 3G session */
3668 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3669 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3670 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3671 tdata->key.data, tdata->key.len,
3672 tdata->cipher_iv.len);
3676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3678 /* Clear mbuf payload */
3679 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3680 rte_pktmbuf_tailroom(ut_params->ibuf));
3682 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3683 /* Append data which is padded to a multiple of */
3684 /* the algorithms block size */
3685 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3686 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3688 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3690 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3692 /* Create SNOW 3G operation */
3693 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3694 tdata->cipher_iv.len,
3695 tdata->validCipherLenInBits.len,
3700 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3702 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3704 ut_params->obuf = ut_params->op->sym->m_dst;
3705 if (ut_params->obuf)
3706 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3708 ciphertext = plaintext;
3710 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3713 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3715 tdata->ciphertext.data,
3716 tdata->validDataLenInBits.len,
3717 "SNOW 3G Ciphertext data not as expected");
3723 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3725 struct crypto_testsuite_params *ts_params = &testsuite_params;
3726 struct crypto_unittest_params *ut_params = &unittest_params;
3727 uint8_t *plaintext, *ciphertext;
3730 unsigned plaintext_pad_len;
3731 unsigned plaintext_len;
3733 /* Create SNOW 3G session */
3734 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3735 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3736 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3737 tdata->key.data, tdata->key.len,
3738 tdata->cipher_iv.len);
3742 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3743 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3745 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3746 "Failed to allocate input buffer in mempool");
3747 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3748 "Failed to allocate output buffer in mempool");
3750 /* Clear mbuf payload */
3751 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3752 rte_pktmbuf_tailroom(ut_params->ibuf));
3754 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3755 /* Append data which is padded to a multiple of */
3756 /* the algorithms block size */
3757 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3758 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3760 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3761 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3763 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3765 /* Create SNOW 3G operation */
3766 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3767 tdata->cipher_iv.len,
3768 tdata->validCipherLenInBits.len,
3773 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3775 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3777 ut_params->obuf = ut_params->op->sym->m_dst;
3778 if (ut_params->obuf)
3779 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3781 ciphertext = plaintext;
3783 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3786 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3788 tdata->ciphertext.data,
3789 tdata->validDataLenInBits.len,
3790 "SNOW 3G Ciphertext data not as expected");
3795 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3797 struct crypto_testsuite_params *ts_params = &testsuite_params;
3798 struct crypto_unittest_params *ut_params = &unittest_params;
3801 unsigned int plaintext_pad_len;
3802 unsigned int plaintext_len;
3803 uint8_t buffer[10000];
3804 const uint8_t *ciphertext;
3806 struct rte_cryptodev_info dev_info;
3808 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3810 uint64_t feat_flags = dev_info.feature_flags;
3812 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3813 printf("Device doesn't support out-of-place scatter-gather "
3814 "in both input and output mbufs. "
3819 /* Create SNOW 3G session */
3820 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3821 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3822 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3823 tdata->key.data, tdata->key.len,
3824 tdata->cipher_iv.len);
3828 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3829 /* Append data which is padded to a multiple of */
3830 /* the algorithms block size */
3831 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3833 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3834 plaintext_pad_len, 10, 0);
3835 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3836 plaintext_pad_len, 3, 0);
3838 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3839 "Failed to allocate input buffer in mempool");
3840 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3841 "Failed to allocate output buffer in mempool");
3843 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3845 /* Create SNOW 3G operation */
3846 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3847 tdata->cipher_iv.len,
3848 tdata->validCipherLenInBits.len,
3853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3855 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3857 ut_params->obuf = ut_params->op->sym->m_dst;
3858 if (ut_params->obuf)
3859 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3860 plaintext_len, buffer);
3862 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3863 plaintext_len, buffer);
3865 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3868 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3870 tdata->ciphertext.data,
3871 tdata->validDataLenInBits.len,
3872 "SNOW 3G Ciphertext data not as expected");
3877 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3879 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3881 uint8_t curr_byte, prev_byte;
3882 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3883 uint8_t lower_byte_mask = (1 << offset) - 1;
3886 prev_byte = buffer[0];
3887 buffer[0] >>= offset;
3889 for (i = 1; i < length_in_bytes; i++) {
3890 curr_byte = buffer[i];
3891 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3892 (curr_byte >> offset);
3893 prev_byte = curr_byte;
3898 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3900 struct crypto_testsuite_params *ts_params = &testsuite_params;
3901 struct crypto_unittest_params *ut_params = &unittest_params;
3902 uint8_t *plaintext, *ciphertext;
3904 uint32_t plaintext_len;
3905 uint32_t plaintext_pad_len;
3906 uint8_t extra_offset = 4;
3907 uint8_t *expected_ciphertext_shifted;
3909 /* Create SNOW 3G session */
3910 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3911 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3912 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3913 tdata->key.data, tdata->key.len,
3914 tdata->cipher_iv.len);
3918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3919 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3921 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3922 "Failed to allocate input buffer in mempool");
3923 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3924 "Failed to allocate output buffer in mempool");
3926 /* Clear mbuf payload */
3927 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3928 rte_pktmbuf_tailroom(ut_params->ibuf));
3930 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3932 * Append data which is padded to a
3933 * multiple of the algorithms block size
3935 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3937 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3940 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3942 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3943 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3945 #ifdef RTE_APP_TEST_DEBUG
3946 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3948 /* Create SNOW 3G operation */
3949 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3950 tdata->cipher_iv.len,
3951 tdata->validCipherLenInBits.len,
3956 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3958 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3960 ut_params->obuf = ut_params->op->sym->m_dst;
3961 if (ut_params->obuf)
3962 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3964 ciphertext = plaintext;
3966 #ifdef RTE_APP_TEST_DEBUG
3967 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3970 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3972 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3973 "failed to reserve memory for ciphertext shifted\n");
3975 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3976 ceil_byte_length(tdata->ciphertext.len));
3977 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3982 expected_ciphertext_shifted,
3983 tdata->validDataLenInBits.len,
3985 "SNOW 3G Ciphertext data not as expected");
3989 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3991 struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 struct crypto_unittest_params *ut_params = &unittest_params;
3996 uint8_t *plaintext, *ciphertext;
3997 unsigned ciphertext_pad_len;
3998 unsigned ciphertext_len;
4000 /* Create SNOW 3G session */
4001 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4002 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4003 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4004 tdata->key.data, tdata->key.len,
4005 tdata->cipher_iv.len);
4009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4011 /* Clear mbuf payload */
4012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4013 rte_pktmbuf_tailroom(ut_params->ibuf));
4015 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4016 /* Append data which is padded to a multiple of */
4017 /* the algorithms block size */
4018 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4019 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4020 ciphertext_pad_len);
4021 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4023 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4025 /* Create SNOW 3G operation */
4026 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4027 tdata->cipher_iv.len,
4028 tdata->validCipherLenInBits.len,
4033 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4035 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4036 ut_params->obuf = ut_params->op->sym->m_dst;
4037 if (ut_params->obuf)
4038 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4040 plaintext = ciphertext;
4042 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4046 tdata->plaintext.data,
4047 tdata->validDataLenInBits.len,
4048 "SNOW 3G Plaintext data not as expected");
4052 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4054 struct crypto_testsuite_params *ts_params = &testsuite_params;
4055 struct crypto_unittest_params *ut_params = &unittest_params;
4059 uint8_t *plaintext, *ciphertext;
4060 unsigned ciphertext_pad_len;
4061 unsigned ciphertext_len;
4063 /* Create SNOW 3G session */
4064 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4065 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4066 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4067 tdata->key.data, tdata->key.len,
4068 tdata->cipher_iv.len);
4072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4073 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4076 "Failed to allocate input buffer");
4077 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4078 "Failed to allocate output buffer");
4080 /* Clear mbuf payload */
4081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4082 rte_pktmbuf_tailroom(ut_params->ibuf));
4084 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4085 rte_pktmbuf_tailroom(ut_params->obuf));
4087 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4088 /* Append data which is padded to a multiple of */
4089 /* the algorithms block size */
4090 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4091 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4092 ciphertext_pad_len);
4093 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4094 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4096 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4098 /* Create SNOW 3G operation */
4099 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4100 tdata->cipher_iv.len,
4101 tdata->validCipherLenInBits.len,
4106 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4108 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4109 ut_params->obuf = ut_params->op->sym->m_dst;
4110 if (ut_params->obuf)
4111 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4113 plaintext = ciphertext;
4115 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4119 tdata->plaintext.data,
4120 tdata->validDataLenInBits.len,
4121 "SNOW 3G Plaintext data not as expected");
4126 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4128 struct crypto_testsuite_params *ts_params = &testsuite_params;
4129 struct crypto_unittest_params *ut_params = &unittest_params;
4133 uint8_t *plaintext, *ciphertext;
4134 unsigned int plaintext_pad_len;
4135 unsigned int plaintext_len;
4137 struct rte_cryptodev_sym_capability_idx cap_idx;
4139 /* Check if device supports ZUC EEA3 */
4140 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4141 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4143 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4147 /* Check if device supports ZUC EIA3 */
4148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4149 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4155 /* Create ZUC session */
4156 retval = create_zuc_cipher_auth_encrypt_generate_session(
4157 ts_params->valid_devs[0],
4161 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4163 /* clear mbuf payload */
4164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4165 rte_pktmbuf_tailroom(ut_params->ibuf));
4167 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4168 /* Append data which is padded to a multiple of */
4169 /* the algorithms block size */
4170 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4173 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4175 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4177 /* Create ZUC operation */
4178 retval = create_zuc_cipher_hash_generate_operation(tdata);
4182 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4184 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4185 ut_params->obuf = ut_params->op->sym->m_src;
4186 if (ut_params->obuf)
4187 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4189 ciphertext = plaintext;
4191 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4193 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4195 tdata->ciphertext.data,
4196 tdata->validDataLenInBits.len,
4197 "ZUC Ciphertext data not as expected");
4199 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4200 + plaintext_pad_len;
4203 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4207 "ZUC Generated auth tag not as expected");
4212 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4214 struct crypto_testsuite_params *ts_params = &testsuite_params;
4215 struct crypto_unittest_params *ut_params = &unittest_params;
4219 uint8_t *plaintext, *ciphertext;
4220 unsigned plaintext_pad_len;
4221 unsigned plaintext_len;
4223 /* Create SNOW 3G session */
4224 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4225 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4226 RTE_CRYPTO_AUTH_OP_GENERATE,
4227 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4228 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4229 tdata->key.data, tdata->key.len,
4230 tdata->auth_iv.len, tdata->digest.len,
4231 tdata->cipher_iv.len);
4234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4236 /* clear mbuf payload */
4237 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4238 rte_pktmbuf_tailroom(ut_params->ibuf));
4240 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4241 /* Append data which is padded to a multiple of */
4242 /* the algorithms block size */
4243 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4244 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4246 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4248 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4250 /* Create SNOW 3G operation */
4251 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4252 tdata->digest.len, tdata->auth_iv.data,
4254 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4255 tdata->cipher_iv.data, tdata->cipher_iv.len,
4256 tdata->validCipherLenInBits.len,
4258 tdata->validAuthLenInBits.len,
4264 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4266 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4267 ut_params->obuf = ut_params->op->sym->m_src;
4268 if (ut_params->obuf)
4269 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4271 ciphertext = plaintext;
4273 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4275 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4277 tdata->ciphertext.data,
4278 tdata->validDataLenInBits.len,
4279 "SNOW 3G Ciphertext data not as expected");
4281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4282 + plaintext_pad_len;
4285 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4288 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4289 "SNOW 3G Generated auth tag not as expected");
4293 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4295 struct crypto_testsuite_params *ts_params = &testsuite_params;
4296 struct crypto_unittest_params *ut_params = &unittest_params;
4300 uint8_t *plaintext, *ciphertext;
4301 unsigned plaintext_pad_len;
4302 unsigned plaintext_len;
4304 /* Create SNOW 3G session */
4305 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4306 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4307 RTE_CRYPTO_AUTH_OP_GENERATE,
4308 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4309 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4310 tdata->key.data, tdata->key.len,
4311 tdata->auth_iv.len, tdata->digest.len,
4312 tdata->cipher_iv.len);
4316 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4318 /* clear mbuf payload */
4319 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4320 rte_pktmbuf_tailroom(ut_params->ibuf));
4322 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4323 /* Append data which is padded to a multiple of */
4324 /* the algorithms block size */
4325 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4326 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4328 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4330 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4332 /* Create SNOW 3G operation */
4333 retval = create_wireless_algo_auth_cipher_operation(
4335 tdata->cipher_iv.data, tdata->cipher_iv.len,
4336 tdata->auth_iv.data, tdata->auth_iv.len,
4338 tdata->validCipherLenInBits.len,
4340 tdata->validAuthLenInBits.len,
4346 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4348 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4349 ut_params->obuf = ut_params->op->sym->m_src;
4350 if (ut_params->obuf)
4351 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4353 ciphertext = plaintext;
4355 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4356 + plaintext_pad_len;
4357 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4360 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4362 tdata->ciphertext.data,
4363 tdata->validDataLenInBits.len,
4364 "SNOW 3G Ciphertext data not as expected");
4367 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4370 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4371 "SNOW 3G Generated auth tag not as expected");
4376 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4378 struct crypto_testsuite_params *ts_params = &testsuite_params;
4379 struct crypto_unittest_params *ut_params = &unittest_params;
4383 uint8_t *plaintext, *ciphertext;
4384 unsigned plaintext_pad_len;
4385 unsigned plaintext_len;
4387 /* Create KASUMI session */
4388 retval = create_wireless_algo_auth_cipher_session(
4389 ts_params->valid_devs[0],
4390 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4391 RTE_CRYPTO_AUTH_OP_GENERATE,
4392 RTE_CRYPTO_AUTH_KASUMI_F9,
4393 RTE_CRYPTO_CIPHER_KASUMI_F8,
4394 tdata->key.data, tdata->key.len,
4395 0, tdata->digest.len,
4396 tdata->cipher_iv.len);
4399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4401 /* clear mbuf payload */
4402 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4403 rte_pktmbuf_tailroom(ut_params->ibuf));
4405 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4406 /* Append data which is padded to a multiple of */
4407 /* the algorithms block size */
4408 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4411 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4413 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4415 /* Create KASUMI operation */
4416 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4417 tdata->cipher_iv.data, tdata->cipher_iv.len,
4420 tdata->validCipherLenInBits.len,
4421 tdata->validCipherOffsetInBits.len,
4422 tdata->validAuthLenInBits.len,
4429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4432 if (ut_params->op->sym->m_dst)
4433 ut_params->obuf = ut_params->op->sym->m_dst;
4435 ut_params->obuf = ut_params->op->sym->m_src;
4437 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4438 tdata->validCipherOffsetInBits.len >> 3);
4440 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4441 (tdata->validCipherOffsetInBits.len >> 3);
4443 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4445 reference_ciphertext,
4446 tdata->validCipherLenInBits.len,
4447 "KASUMI Ciphertext data not as expected");
4448 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4449 + plaintext_pad_len;
4452 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4455 DIGEST_BYTE_LENGTH_KASUMI_F9,
4456 "KASUMI Generated auth tag not as expected");
4461 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4463 struct crypto_testsuite_params *ts_params = &testsuite_params;
4464 struct crypto_unittest_params *ut_params = &unittest_params;
4468 uint8_t *plaintext, *ciphertext;
4469 unsigned plaintext_pad_len;
4470 unsigned plaintext_len;
4472 /* Create KASUMI session */
4473 retval = create_wireless_algo_cipher_auth_session(
4474 ts_params->valid_devs[0],
4475 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4476 RTE_CRYPTO_AUTH_OP_GENERATE,
4477 RTE_CRYPTO_AUTH_KASUMI_F9,
4478 RTE_CRYPTO_CIPHER_KASUMI_F8,
4479 tdata->key.data, tdata->key.len,
4480 0, tdata->digest.len,
4481 tdata->cipher_iv.len);
4485 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4487 /* clear mbuf payload */
4488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4489 rte_pktmbuf_tailroom(ut_params->ibuf));
4491 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4492 /* Append data which is padded to a multiple of */
4493 /* the algorithms block size */
4494 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4495 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4497 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4499 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4501 /* Create KASUMI operation */
4502 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4503 tdata->digest.len, NULL, 0,
4504 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4505 tdata->cipher_iv.data, tdata->cipher_iv.len,
4506 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4507 tdata->validCipherOffsetInBits.len,
4508 tdata->validAuthLenInBits.len,
4514 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4516 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4518 if (ut_params->op->sym->m_dst)
4519 ut_params->obuf = ut_params->op->sym->m_dst;
4521 ut_params->obuf = ut_params->op->sym->m_src;
4523 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4524 tdata->validCipherOffsetInBits.len >> 3);
4526 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4527 + plaintext_pad_len;
4529 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4530 (tdata->validCipherOffsetInBits.len >> 3);
4532 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4534 reference_ciphertext,
4535 tdata->validCipherLenInBits.len,
4536 "KASUMI Ciphertext data not as expected");
4539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4542 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4543 "KASUMI Generated auth tag not as expected");
4548 test_zuc_encryption(const struct wireless_test_data *tdata)
4550 struct crypto_testsuite_params *ts_params = &testsuite_params;
4551 struct crypto_unittest_params *ut_params = &unittest_params;
4554 uint8_t *plaintext, *ciphertext;
4555 unsigned plaintext_pad_len;
4556 unsigned plaintext_len;
4558 struct rte_cryptodev_sym_capability_idx cap_idx;
4560 /* Check if device supports ZUC EEA3 */
4561 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4562 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4564 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4568 /* Create ZUC session */
4569 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4570 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4571 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4572 tdata->key.data, tdata->key.len,
4573 tdata->cipher_iv.len);
4577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4579 /* Clear mbuf payload */
4580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4581 rte_pktmbuf_tailroom(ut_params->ibuf));
4583 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4584 /* Append data which is padded to a multiple */
4585 /* of the algorithms block size */
4586 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4587 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4589 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4591 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4593 /* Create ZUC operation */
4594 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4595 tdata->cipher_iv.len,
4596 tdata->plaintext.len,
4601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4603 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4605 ut_params->obuf = ut_params->op->sym->m_dst;
4606 if (ut_params->obuf)
4607 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4609 ciphertext = plaintext;
4611 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4614 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4616 tdata->ciphertext.data,
4617 tdata->validCipherLenInBits.len,
4618 "ZUC Ciphertext data not as expected");
4623 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4625 struct crypto_testsuite_params *ts_params = &testsuite_params;
4626 struct crypto_unittest_params *ut_params = &unittest_params;
4630 unsigned int plaintext_pad_len;
4631 unsigned int plaintext_len;
4632 const uint8_t *ciphertext;
4633 uint8_t ciphertext_buffer[2048];
4634 struct rte_cryptodev_info dev_info;
4636 struct rte_cryptodev_sym_capability_idx cap_idx;
4638 /* Check if device supports ZUC EEA3 */
4639 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4640 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4642 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4646 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4648 uint64_t feat_flags = dev_info.feature_flags;
4650 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4651 printf("Device doesn't support in-place scatter-gather. "
4656 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4658 /* Append data which is padded to a multiple */
4659 /* of the algorithms block size */
4660 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4662 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4663 plaintext_pad_len, 10, 0);
4665 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4666 tdata->plaintext.data);
4668 /* Create ZUC session */
4669 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4670 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4671 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4672 tdata->key.data, tdata->key.len,
4673 tdata->cipher_iv.len);
4677 /* Clear mbuf payload */
4679 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4681 /* Create ZUC operation */
4682 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4683 tdata->cipher_iv.len, tdata->plaintext.len,
4688 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4690 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4692 ut_params->obuf = ut_params->op->sym->m_dst;
4693 if (ut_params->obuf)
4694 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4695 0, plaintext_len, ciphertext_buffer);
4697 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4698 0, plaintext_len, ciphertext_buffer);
4701 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4704 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4706 tdata->ciphertext.data,
4707 tdata->validCipherLenInBits.len,
4708 "ZUC Ciphertext data not as expected");
4714 test_zuc_authentication(const struct wireless_test_data *tdata)
4716 struct crypto_testsuite_params *ts_params = &testsuite_params;
4717 struct crypto_unittest_params *ut_params = &unittest_params;
4720 unsigned plaintext_pad_len;
4721 unsigned plaintext_len;
4724 struct rte_cryptodev_sym_capability_idx cap_idx;
4726 /* Check if device supports ZUC EIA3 */
4727 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4728 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4730 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4734 /* Create ZUC session */
4735 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4736 tdata->key.data, tdata->key.len,
4737 tdata->auth_iv.len, tdata->digest.len,
4738 RTE_CRYPTO_AUTH_OP_GENERATE,
4739 RTE_CRYPTO_AUTH_ZUC_EIA3);
4743 /* alloc mbuf and set payload */
4744 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4746 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4747 rte_pktmbuf_tailroom(ut_params->ibuf));
4749 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4750 /* Append data which is padded to a multiple of */
4751 /* the algorithms block size */
4752 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4753 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4755 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4757 /* Create ZUC operation */
4758 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4759 tdata->auth_iv.data, tdata->auth_iv.len,
4760 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4761 tdata->validAuthLenInBits.len,
4766 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4768 ut_params->obuf = ut_params->op->sym->m_src;
4769 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4770 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4771 + plaintext_pad_len;
4774 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4777 DIGEST_BYTE_LENGTH_KASUMI_F9,
4778 "ZUC Generated auth tag not as expected");
4784 test_kasumi_encryption_test_case_1(void)
4786 return test_kasumi_encryption(&kasumi_test_case_1);
4790 test_kasumi_encryption_test_case_1_sgl(void)
4792 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4796 test_kasumi_encryption_test_case_1_oop(void)
4798 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4802 test_kasumi_encryption_test_case_1_oop_sgl(void)
4804 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4808 test_kasumi_encryption_test_case_2(void)
4810 return test_kasumi_encryption(&kasumi_test_case_2);
4814 test_kasumi_encryption_test_case_3(void)
4816 return test_kasumi_encryption(&kasumi_test_case_3);
4820 test_kasumi_encryption_test_case_4(void)
4822 return test_kasumi_encryption(&kasumi_test_case_4);
4826 test_kasumi_encryption_test_case_5(void)
4828 return test_kasumi_encryption(&kasumi_test_case_5);
4832 test_kasumi_decryption_test_case_1(void)
4834 return test_kasumi_decryption(&kasumi_test_case_1);
4838 test_kasumi_decryption_test_case_1_oop(void)
4840 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4844 test_kasumi_decryption_test_case_2(void)
4846 return test_kasumi_decryption(&kasumi_test_case_2);
4850 test_kasumi_decryption_test_case_3(void)
4852 return test_kasumi_decryption(&kasumi_test_case_3);
4856 test_kasumi_decryption_test_case_4(void)
4858 return test_kasumi_decryption(&kasumi_test_case_4);
4862 test_kasumi_decryption_test_case_5(void)
4864 return test_kasumi_decryption(&kasumi_test_case_5);
4867 test_snow3g_encryption_test_case_1(void)
4869 return test_snow3g_encryption(&snow3g_test_case_1);
4873 test_snow3g_encryption_test_case_1_oop(void)
4875 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4879 test_snow3g_encryption_test_case_1_oop_sgl(void)
4881 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4886 test_snow3g_encryption_test_case_1_offset_oop(void)
4888 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4892 test_snow3g_encryption_test_case_2(void)
4894 return test_snow3g_encryption(&snow3g_test_case_2);
4898 test_snow3g_encryption_test_case_3(void)
4900 return test_snow3g_encryption(&snow3g_test_case_3);
4904 test_snow3g_encryption_test_case_4(void)
4906 return test_snow3g_encryption(&snow3g_test_case_4);
4910 test_snow3g_encryption_test_case_5(void)
4912 return test_snow3g_encryption(&snow3g_test_case_5);
4916 test_snow3g_decryption_test_case_1(void)
4918 return test_snow3g_decryption(&snow3g_test_case_1);
4922 test_snow3g_decryption_test_case_1_oop(void)
4924 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4928 test_snow3g_decryption_test_case_2(void)
4930 return test_snow3g_decryption(&snow3g_test_case_2);
4934 test_snow3g_decryption_test_case_3(void)
4936 return test_snow3g_decryption(&snow3g_test_case_3);
4940 test_snow3g_decryption_test_case_4(void)
4942 return test_snow3g_decryption(&snow3g_test_case_4);
4946 test_snow3g_decryption_test_case_5(void)
4948 return test_snow3g_decryption(&snow3g_test_case_5);
4951 test_snow3g_cipher_auth_test_case_1(void)
4953 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4957 test_snow3g_auth_cipher_test_case_1(void)
4959 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4963 test_kasumi_auth_cipher_test_case_1(void)
4965 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4969 test_kasumi_cipher_auth_test_case_1(void)
4971 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4975 test_zuc_encryption_test_case_1(void)
4977 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4981 test_zuc_encryption_test_case_2(void)
4983 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4987 test_zuc_encryption_test_case_3(void)
4989 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4993 test_zuc_encryption_test_case_4(void)
4995 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4999 test_zuc_encryption_test_case_5(void)
5001 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5005 test_zuc_encryption_test_case_6_sgl(void)
5007 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5011 test_zuc_hash_generate_test_case_1(void)
5013 return test_zuc_authentication(&zuc_test_case_auth_1b);
5017 test_zuc_hash_generate_test_case_2(void)
5019 return test_zuc_authentication(&zuc_test_case_auth_90b);
5023 test_zuc_hash_generate_test_case_3(void)
5025 return test_zuc_authentication(&zuc_test_case_auth_577b);
5029 test_zuc_hash_generate_test_case_4(void)
5031 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5035 test_zuc_hash_generate_test_case_5(void)
5037 return test_zuc_authentication(&zuc_test_auth_5670b);
5041 test_zuc_hash_generate_test_case_6(void)
5043 return test_zuc_authentication(&zuc_test_case_auth_128b);
5047 test_zuc_hash_generate_test_case_7(void)
5049 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5053 test_zuc_hash_generate_test_case_8(void)
5055 return test_zuc_authentication(&zuc_test_case_auth_584b);
5059 test_zuc_cipher_auth_test_case_1(void)
5061 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5065 test_zuc_cipher_auth_test_case_2(void)
5067 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5071 test_3DES_chain_qat_all(void)
5073 struct crypto_testsuite_params *ts_params = &testsuite_params;
5076 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5077 ts_params->op_mpool,
5078 ts_params->session_mpool,
5079 ts_params->valid_devs[0],
5080 rte_cryptodev_driver_id_get(
5081 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5082 BLKCIPHER_3DES_CHAIN_TYPE);
5084 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5086 return TEST_SUCCESS;
5090 test_DES_cipheronly_qat_all(void)
5092 struct crypto_testsuite_params *ts_params = &testsuite_params;
5095 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5096 ts_params->op_mpool,
5097 ts_params->session_mpool,
5098 ts_params->valid_devs[0],
5099 rte_cryptodev_driver_id_get(
5100 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5101 BLKCIPHER_DES_CIPHERONLY_TYPE);
5103 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5105 return TEST_SUCCESS;
5109 test_DES_cipheronly_openssl_all(void)
5111 struct crypto_testsuite_params *ts_params = &testsuite_params;
5114 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5115 ts_params->op_mpool,
5116 ts_params->session_mpool,
5117 ts_params->valid_devs[0],
5118 rte_cryptodev_driver_id_get(
5119 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5120 BLKCIPHER_DES_CIPHERONLY_TYPE);
5122 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5124 return TEST_SUCCESS;
5128 test_DES_docsis_openssl_all(void)
5130 struct crypto_testsuite_params *ts_params = &testsuite_params;
5133 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5134 ts_params->op_mpool,
5135 ts_params->session_mpool,
5136 ts_params->valid_devs[0],
5137 rte_cryptodev_driver_id_get(
5138 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5139 BLKCIPHER_DES_DOCSIS_TYPE);
5141 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5143 return TEST_SUCCESS;
5147 test_DES_cipheronly_mb_all(void)
5149 struct crypto_testsuite_params *ts_params = &testsuite_params;
5152 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5153 ts_params->op_mpool,
5154 ts_params->session_mpool,
5155 ts_params->valid_devs[0],
5156 rte_cryptodev_driver_id_get(
5157 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5158 BLKCIPHER_DES_CIPHERONLY_TYPE);
5160 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5162 return TEST_SUCCESS;
5165 test_3DES_cipheronly_mb_all(void)
5167 struct crypto_testsuite_params *ts_params = &testsuite_params;
5170 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5171 ts_params->op_mpool,
5172 ts_params->session_mpool,
5173 ts_params->valid_devs[0],
5174 rte_cryptodev_driver_id_get(
5175 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5176 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5178 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5180 return TEST_SUCCESS;
5184 test_DES_docsis_mb_all(void)
5186 struct crypto_testsuite_params *ts_params = &testsuite_params;
5189 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5190 ts_params->op_mpool,
5191 ts_params->session_mpool,
5192 ts_params->valid_devs[0],
5193 rte_cryptodev_driver_id_get(
5194 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5195 BLKCIPHER_DES_DOCSIS_TYPE);
5197 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5199 return TEST_SUCCESS;
5203 test_3DES_chain_caam_jr_all(void)
5205 struct crypto_testsuite_params *ts_params = &testsuite_params;
5208 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5209 ts_params->op_mpool,
5210 ts_params->session_mpool,
5211 ts_params->valid_devs[0],
5212 rte_cryptodev_driver_id_get(
5213 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5214 BLKCIPHER_3DES_CHAIN_TYPE);
5216 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5218 return TEST_SUCCESS;
5222 test_3DES_cipheronly_caam_jr_all(void)
5224 struct crypto_testsuite_params *ts_params = &testsuite_params;
5227 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5228 ts_params->op_mpool,
5229 ts_params->session_mpool,
5230 ts_params->valid_devs[0],
5231 rte_cryptodev_driver_id_get(
5232 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5233 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5235 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5237 return TEST_SUCCESS;
5241 test_3DES_chain_dpaa_sec_all(void)
5243 struct crypto_testsuite_params *ts_params = &testsuite_params;
5246 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5247 ts_params->op_mpool,
5248 ts_params->session_mpool,
5249 ts_params->valid_devs[0],
5250 rte_cryptodev_driver_id_get(
5251 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5252 BLKCIPHER_3DES_CHAIN_TYPE);
5254 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5256 return TEST_SUCCESS;
5260 test_3DES_cipheronly_dpaa_sec_all(void)
5262 struct crypto_testsuite_params *ts_params = &testsuite_params;
5265 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5266 ts_params->op_mpool,
5267 ts_params->session_mpool,
5268 ts_params->valid_devs[0],
5269 rte_cryptodev_driver_id_get(
5270 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5271 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5273 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5275 return TEST_SUCCESS;
5279 test_3DES_chain_dpaa2_sec_all(void)
5281 struct crypto_testsuite_params *ts_params = &testsuite_params;
5284 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5285 ts_params->op_mpool,
5286 ts_params->session_mpool,
5287 ts_params->valid_devs[0],
5288 rte_cryptodev_driver_id_get(
5289 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5290 BLKCIPHER_3DES_CHAIN_TYPE);
5292 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5294 return TEST_SUCCESS;
5298 test_3DES_cipheronly_dpaa2_sec_all(void)
5300 struct crypto_testsuite_params *ts_params = &testsuite_params;
5303 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5304 ts_params->op_mpool,
5305 ts_params->session_mpool,
5306 ts_params->valid_devs[0],
5307 rte_cryptodev_driver_id_get(
5308 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5309 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5311 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5313 return TEST_SUCCESS;
5317 test_3DES_chain_ccp_all(void)
5319 struct crypto_testsuite_params *ts_params = &testsuite_params;
5322 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5323 ts_params->op_mpool,
5324 ts_params->session_mpool,
5325 ts_params->valid_devs[0],
5326 rte_cryptodev_driver_id_get(
5327 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5328 BLKCIPHER_3DES_CHAIN_TYPE);
5330 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5332 return TEST_SUCCESS;
5336 test_3DES_cipheronly_ccp_all(void)
5338 struct crypto_testsuite_params *ts_params = &testsuite_params;
5341 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5342 ts_params->op_mpool,
5343 ts_params->session_mpool,
5344 ts_params->valid_devs[0],
5345 rte_cryptodev_driver_id_get(
5346 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5347 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5349 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5351 return TEST_SUCCESS;
5355 test_3DES_cipheronly_qat_all(void)
5357 struct crypto_testsuite_params *ts_params = &testsuite_params;
5360 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5361 ts_params->op_mpool,
5362 ts_params->session_mpool,
5363 ts_params->valid_devs[0],
5364 rte_cryptodev_driver_id_get(
5365 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5366 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5368 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5370 return TEST_SUCCESS;
5374 test_3DES_chain_openssl_all(void)
5376 struct crypto_testsuite_params *ts_params = &testsuite_params;
5379 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5380 ts_params->op_mpool,
5381 ts_params->session_mpool,
5382 ts_params->valid_devs[0],
5383 rte_cryptodev_driver_id_get(
5384 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5385 BLKCIPHER_3DES_CHAIN_TYPE);
5387 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5389 return TEST_SUCCESS;
5393 test_3DES_cipheronly_openssl_all(void)
5395 struct crypto_testsuite_params *ts_params = &testsuite_params;
5398 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5399 ts_params->op_mpool,
5400 ts_params->session_mpool,
5401 ts_params->valid_devs[0],
5402 rte_cryptodev_driver_id_get(
5403 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5404 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5406 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5408 return TEST_SUCCESS;
5411 /* ***** AEAD algorithm Tests ***** */
5414 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5415 enum rte_crypto_aead_operation op,
5416 const uint8_t *key, const uint8_t key_len,
5417 const uint16_t aad_len, const uint8_t auth_len,
5420 uint8_t aead_key[key_len];
5422 struct crypto_testsuite_params *ts_params = &testsuite_params;
5423 struct crypto_unittest_params *ut_params = &unittest_params;
5425 memcpy(aead_key, key, key_len);
5427 /* Setup AEAD Parameters */
5428 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5429 ut_params->aead_xform.next = NULL;
5430 ut_params->aead_xform.aead.algo = algo;
5431 ut_params->aead_xform.aead.op = op;
5432 ut_params->aead_xform.aead.key.data = aead_key;
5433 ut_params->aead_xform.aead.key.length = key_len;
5434 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5435 ut_params->aead_xform.aead.iv.length = iv_len;
5436 ut_params->aead_xform.aead.digest_length = auth_len;
5437 ut_params->aead_xform.aead.aad_length = aad_len;
5439 debug_hexdump(stdout, "key:", key, key_len);
5441 /* Create Crypto session*/
5442 ut_params->sess = rte_cryptodev_sym_session_create(
5443 ts_params->session_mpool);
5445 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5446 &ut_params->aead_xform, ts_params->session_mpool);
5448 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5454 create_aead_xform(struct rte_crypto_op *op,
5455 enum rte_crypto_aead_algorithm algo,
5456 enum rte_crypto_aead_operation aead_op,
5457 uint8_t *key, const uint8_t key_len,
5458 const uint8_t aad_len, const uint8_t auth_len,
5461 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5462 "failed to allocate space for crypto transform");
5464 struct rte_crypto_sym_op *sym_op = op->sym;
5466 /* Setup AEAD Parameters */
5467 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5468 sym_op->xform->next = NULL;
5469 sym_op->xform->aead.algo = algo;
5470 sym_op->xform->aead.op = aead_op;
5471 sym_op->xform->aead.key.data = key;
5472 sym_op->xform->aead.key.length = key_len;
5473 sym_op->xform->aead.iv.offset = IV_OFFSET;
5474 sym_op->xform->aead.iv.length = iv_len;
5475 sym_op->xform->aead.digest_length = auth_len;
5476 sym_op->xform->aead.aad_length = aad_len;
5478 debug_hexdump(stdout, "key:", key, key_len);
5484 create_aead_operation(enum rte_crypto_aead_operation op,
5485 const struct aead_test_data *tdata)
5487 struct crypto_testsuite_params *ts_params = &testsuite_params;
5488 struct crypto_unittest_params *ut_params = &unittest_params;
5490 uint8_t *plaintext, *ciphertext;
5491 unsigned int aad_pad_len, plaintext_pad_len;
5493 /* Generate Crypto op data structure */
5494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5496 TEST_ASSERT_NOT_NULL(ut_params->op,
5497 "Failed to allocate symmetric crypto operation struct");
5499 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5501 /* Append aad data */
5502 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5503 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5504 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5506 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5507 "no room to append aad");
5509 sym_op->aead.aad.phys_addr =
5510 rte_pktmbuf_iova(ut_params->ibuf);
5511 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5512 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5513 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5516 /* Append IV at the end of the crypto operation*/
5517 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5518 uint8_t *, IV_OFFSET);
5520 /* Copy IV 1 byte after the IV pointer, according to the API */
5521 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5522 debug_hexdump(stdout, "iv:", iv_ptr,
5525 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5526 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5528 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5529 "no room to append aad");
5531 sym_op->aead.aad.phys_addr =
5532 rte_pktmbuf_iova(ut_params->ibuf);
5533 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5534 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5537 /* Append IV at the end of the crypto operation*/
5538 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5539 uint8_t *, IV_OFFSET);
5541 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5542 debug_hexdump(stdout, "iv:", iv_ptr,
5546 /* Append plaintext/ciphertext */
5547 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5548 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5549 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5551 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5553 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5554 debug_hexdump(stdout, "plaintext:", plaintext,
5555 tdata->plaintext.len);
5557 if (ut_params->obuf) {
5558 ciphertext = (uint8_t *)rte_pktmbuf_append(
5560 plaintext_pad_len + aad_pad_len);
5561 TEST_ASSERT_NOT_NULL(ciphertext,
5562 "no room to append ciphertext");
5564 memset(ciphertext + aad_pad_len, 0,
5565 tdata->ciphertext.len);
5568 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5569 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5571 TEST_ASSERT_NOT_NULL(ciphertext,
5572 "no room to append ciphertext");
5574 memcpy(ciphertext, tdata->ciphertext.data,
5575 tdata->ciphertext.len);
5576 debug_hexdump(stdout, "ciphertext:", ciphertext,
5577 tdata->ciphertext.len);
5579 if (ut_params->obuf) {
5580 plaintext = (uint8_t *)rte_pktmbuf_append(
5582 plaintext_pad_len + aad_pad_len);
5583 TEST_ASSERT_NOT_NULL(plaintext,
5584 "no room to append plaintext");
5586 memset(plaintext + aad_pad_len, 0,
5587 tdata->plaintext.len);
5591 /* Append digest data */
5592 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5593 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5594 ut_params->obuf ? ut_params->obuf :
5596 tdata->auth_tag.len);
5597 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5598 "no room to append digest");
5599 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5600 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5601 ut_params->obuf ? ut_params->obuf :
5606 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5607 ut_params->ibuf, tdata->auth_tag.len);
5608 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5609 "no room to append digest");
5610 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5612 plaintext_pad_len + aad_pad_len);
5614 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5615 tdata->auth_tag.len);
5616 debug_hexdump(stdout, "digest:",
5617 sym_op->aead.digest.data,
5618 tdata->auth_tag.len);
5621 sym_op->aead.data.length = tdata->plaintext.len;
5622 sym_op->aead.data.offset = aad_pad_len;
5628 test_authenticated_encryption(const struct aead_test_data *tdata)
5630 struct crypto_testsuite_params *ts_params = &testsuite_params;
5631 struct crypto_unittest_params *ut_params = &unittest_params;
5634 uint8_t *ciphertext, *auth_tag;
5635 uint16_t plaintext_pad_len;
5638 /* Create AEAD session */
5639 retval = create_aead_session(ts_params->valid_devs[0],
5641 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5642 tdata->key.data, tdata->key.len,
5643 tdata->aad.len, tdata->auth_tag.len,
5648 if (tdata->aad.len > MBUF_SIZE) {
5649 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5650 /* Populate full size of add data */
5651 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5652 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5656 /* clear mbuf payload */
5657 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5658 rte_pktmbuf_tailroom(ut_params->ibuf));
5660 /* Create AEAD operation */
5661 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5665 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5667 ut_params->op->sym->m_src = ut_params->ibuf;
5669 /* Process crypto operation */
5670 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5671 ut_params->op), "failed to process sym crypto op");
5673 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5674 "crypto op processing failed");
5676 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5678 if (ut_params->op->sym->m_dst) {
5679 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5681 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5682 uint8_t *, plaintext_pad_len);
5684 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5686 ut_params->op->sym->cipher.data.offset);
5687 auth_tag = ciphertext + plaintext_pad_len;
5690 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5691 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5694 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5696 tdata->ciphertext.data,
5697 tdata->ciphertext.len,
5698 "Ciphertext data not as expected");
5700 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5702 tdata->auth_tag.data,
5703 tdata->auth_tag.len,
5704 "Generated auth tag not as expected");
5711 test_AES_GCM_authenticated_encryption_test_case_1(void)
5713 return test_authenticated_encryption(&gcm_test_case_1);
5717 test_AES_GCM_authenticated_encryption_test_case_2(void)
5719 return test_authenticated_encryption(&gcm_test_case_2);
5723 test_AES_GCM_authenticated_encryption_test_case_3(void)
5725 return test_authenticated_encryption(&gcm_test_case_3);
5729 test_AES_GCM_authenticated_encryption_test_case_4(void)
5731 return test_authenticated_encryption(&gcm_test_case_4);
5735 test_AES_GCM_authenticated_encryption_test_case_5(void)
5737 return test_authenticated_encryption(&gcm_test_case_5);
5741 test_AES_GCM_authenticated_encryption_test_case_6(void)
5743 return test_authenticated_encryption(&gcm_test_case_6);
5747 test_AES_GCM_authenticated_encryption_test_case_7(void)
5749 return test_authenticated_encryption(&gcm_test_case_7);
5753 test_AES_GCM_auth_encryption_test_case_192_1(void)
5755 return test_authenticated_encryption(&gcm_test_case_192_1);
5759 test_AES_GCM_auth_encryption_test_case_192_2(void)
5761 return test_authenticated_encryption(&gcm_test_case_192_2);
5765 test_AES_GCM_auth_encryption_test_case_192_3(void)
5767 return test_authenticated_encryption(&gcm_test_case_192_3);
5771 test_AES_GCM_auth_encryption_test_case_192_4(void)
5773 return test_authenticated_encryption(&gcm_test_case_192_4);
5777 test_AES_GCM_auth_encryption_test_case_192_5(void)
5779 return test_authenticated_encryption(&gcm_test_case_192_5);
5783 test_AES_GCM_auth_encryption_test_case_192_6(void)
5785 return test_authenticated_encryption(&gcm_test_case_192_6);
5789 test_AES_GCM_auth_encryption_test_case_192_7(void)
5791 return test_authenticated_encryption(&gcm_test_case_192_7);
5795 test_AES_GCM_auth_encryption_test_case_256_1(void)
5797 return test_authenticated_encryption(&gcm_test_case_256_1);
5801 test_AES_GCM_auth_encryption_test_case_256_2(void)
5803 return test_authenticated_encryption(&gcm_test_case_256_2);
5807 test_AES_GCM_auth_encryption_test_case_256_3(void)
5809 return test_authenticated_encryption(&gcm_test_case_256_3);
5813 test_AES_GCM_auth_encryption_test_case_256_4(void)
5815 return test_authenticated_encryption(&gcm_test_case_256_4);
5819 test_AES_GCM_auth_encryption_test_case_256_5(void)
5821 return test_authenticated_encryption(&gcm_test_case_256_5);
5825 test_AES_GCM_auth_encryption_test_case_256_6(void)
5827 return test_authenticated_encryption(&gcm_test_case_256_6);
5831 test_AES_GCM_auth_encryption_test_case_256_7(void)
5833 return test_authenticated_encryption(&gcm_test_case_256_7);
5837 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5839 return test_authenticated_encryption(&gcm_test_case_aad_1);
5843 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5845 return test_authenticated_encryption(&gcm_test_case_aad_2);
5849 test_authenticated_decryption(const struct aead_test_data *tdata)
5851 struct crypto_testsuite_params *ts_params = &testsuite_params;
5852 struct crypto_unittest_params *ut_params = &unittest_params;
5858 /* Create AEAD session */
5859 retval = create_aead_session(ts_params->valid_devs[0],
5861 RTE_CRYPTO_AEAD_OP_DECRYPT,
5862 tdata->key.data, tdata->key.len,
5863 tdata->aad.len, tdata->auth_tag.len,
5868 /* alloc mbuf and set payload */
5869 if (tdata->aad.len > MBUF_SIZE) {
5870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5871 /* Populate full size of add data */
5872 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5873 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5878 rte_pktmbuf_tailroom(ut_params->ibuf));
5880 /* Create AEAD operation */
5881 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5885 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5887 ut_params->op->sym->m_src = ut_params->ibuf;
5889 /* Process crypto operation */
5890 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5891 ut_params->op), "failed to process sym crypto op");
5893 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5894 "crypto op processing failed");
5896 if (ut_params->op->sym->m_dst)
5897 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5900 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5902 ut_params->op->sym->cipher.data.offset);
5904 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5907 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5909 tdata->plaintext.data,
5910 tdata->plaintext.len,
5911 "Plaintext data not as expected");
5913 TEST_ASSERT_EQUAL(ut_params->op->status,
5914 RTE_CRYPTO_OP_STATUS_SUCCESS,
5915 "Authentication failed");
5920 test_AES_GCM_authenticated_decryption_test_case_1(void)
5922 return test_authenticated_decryption(&gcm_test_case_1);
5926 test_AES_GCM_authenticated_decryption_test_case_2(void)
5928 return test_authenticated_decryption(&gcm_test_case_2);
5932 test_AES_GCM_authenticated_decryption_test_case_3(void)
5934 return test_authenticated_decryption(&gcm_test_case_3);
5938 test_AES_GCM_authenticated_decryption_test_case_4(void)
5940 return test_authenticated_decryption(&gcm_test_case_4);
5944 test_AES_GCM_authenticated_decryption_test_case_5(void)
5946 return test_authenticated_decryption(&gcm_test_case_5);
5950 test_AES_GCM_authenticated_decryption_test_case_6(void)
5952 return test_authenticated_decryption(&gcm_test_case_6);
5956 test_AES_GCM_authenticated_decryption_test_case_7(void)
5958 return test_authenticated_decryption(&gcm_test_case_7);
5962 test_AES_GCM_auth_decryption_test_case_192_1(void)
5964 return test_authenticated_decryption(&gcm_test_case_192_1);
5968 test_AES_GCM_auth_decryption_test_case_192_2(void)
5970 return test_authenticated_decryption(&gcm_test_case_192_2);
5974 test_AES_GCM_auth_decryption_test_case_192_3(void)
5976 return test_authenticated_decryption(&gcm_test_case_192_3);
5980 test_AES_GCM_auth_decryption_test_case_192_4(void)
5982 return test_authenticated_decryption(&gcm_test_case_192_4);
5986 test_AES_GCM_auth_decryption_test_case_192_5(void)
5988 return test_authenticated_decryption(&gcm_test_case_192_5);
5992 test_AES_GCM_auth_decryption_test_case_192_6(void)
5994 return test_authenticated_decryption(&gcm_test_case_192_6);
5998 test_AES_GCM_auth_decryption_test_case_192_7(void)
6000 return test_authenticated_decryption(&gcm_test_case_192_7);
6004 test_AES_GCM_auth_decryption_test_case_256_1(void)
6006 return test_authenticated_decryption(&gcm_test_case_256_1);
6010 test_AES_GCM_auth_decryption_test_case_256_2(void)
6012 return test_authenticated_decryption(&gcm_test_case_256_2);
6016 test_AES_GCM_auth_decryption_test_case_256_3(void)
6018 return test_authenticated_decryption(&gcm_test_case_256_3);
6022 test_AES_GCM_auth_decryption_test_case_256_4(void)
6024 return test_authenticated_decryption(&gcm_test_case_256_4);
6028 test_AES_GCM_auth_decryption_test_case_256_5(void)
6030 return test_authenticated_decryption(&gcm_test_case_256_5);
6034 test_AES_GCM_auth_decryption_test_case_256_6(void)
6036 return test_authenticated_decryption(&gcm_test_case_256_6);
6040 test_AES_GCM_auth_decryption_test_case_256_7(void)
6042 return test_authenticated_decryption(&gcm_test_case_256_7);
6046 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6048 return test_authenticated_decryption(&gcm_test_case_aad_1);
6052 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6054 return test_authenticated_decryption(&gcm_test_case_aad_2);
6058 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6060 struct crypto_testsuite_params *ts_params = &testsuite_params;
6061 struct crypto_unittest_params *ut_params = &unittest_params;
6064 uint8_t *ciphertext, *auth_tag;
6065 uint16_t plaintext_pad_len;
6067 /* Create AEAD session */
6068 retval = create_aead_session(ts_params->valid_devs[0],
6070 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6071 tdata->key.data, tdata->key.len,
6072 tdata->aad.len, tdata->auth_tag.len,
6077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6080 /* clear mbuf payload */
6081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6082 rte_pktmbuf_tailroom(ut_params->ibuf));
6083 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6084 rte_pktmbuf_tailroom(ut_params->obuf));
6086 /* Create AEAD operation */
6087 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6091 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6093 ut_params->op->sym->m_src = ut_params->ibuf;
6094 ut_params->op->sym->m_dst = ut_params->obuf;
6096 /* Process crypto operation */
6097 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6098 ut_params->op), "failed to process sym crypto op");
6100 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6101 "crypto op processing failed");
6103 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6105 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6106 ut_params->op->sym->cipher.data.offset);
6107 auth_tag = ciphertext + plaintext_pad_len;
6109 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6110 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6113 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6115 tdata->ciphertext.data,
6116 tdata->ciphertext.len,
6117 "Ciphertext data not as expected");
6119 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6121 tdata->auth_tag.data,
6122 tdata->auth_tag.len,
6123 "Generated auth tag not as expected");
6130 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6132 return test_authenticated_encryption_oop(&gcm_test_case_5);
6136 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6138 struct crypto_testsuite_params *ts_params = &testsuite_params;
6139 struct crypto_unittest_params *ut_params = &unittest_params;
6144 /* Create AEAD session */
6145 retval = create_aead_session(ts_params->valid_devs[0],
6147 RTE_CRYPTO_AEAD_OP_DECRYPT,
6148 tdata->key.data, tdata->key.len,
6149 tdata->aad.len, tdata->auth_tag.len,
6154 /* alloc mbuf and set payload */
6155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6156 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6158 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6159 rte_pktmbuf_tailroom(ut_params->ibuf));
6160 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6161 rte_pktmbuf_tailroom(ut_params->obuf));
6163 /* Create AEAD operation */
6164 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6168 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6170 ut_params->op->sym->m_src = ut_params->ibuf;
6171 ut_params->op->sym->m_dst = ut_params->obuf;
6173 /* Process crypto operation */
6174 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6175 ut_params->op), "failed to process sym crypto op");
6177 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6178 "crypto op processing failed");
6180 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6181 ut_params->op->sym->cipher.data.offset);
6183 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6186 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6188 tdata->plaintext.data,
6189 tdata->plaintext.len,
6190 "Plaintext data not as expected");
6192 TEST_ASSERT_EQUAL(ut_params->op->status,
6193 RTE_CRYPTO_OP_STATUS_SUCCESS,
6194 "Authentication failed");
6199 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6201 return test_authenticated_decryption_oop(&gcm_test_case_5);
6205 test_authenticated_encryption_sessionless(
6206 const struct aead_test_data *tdata)
6208 struct crypto_testsuite_params *ts_params = &testsuite_params;
6209 struct crypto_unittest_params *ut_params = &unittest_params;
6212 uint8_t *ciphertext, *auth_tag;
6213 uint16_t plaintext_pad_len;
6214 uint8_t key[tdata->key.len + 1];
6216 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6218 /* clear mbuf payload */
6219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6220 rte_pktmbuf_tailroom(ut_params->ibuf));
6222 /* Create AEAD operation */
6223 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6227 /* Create GCM xform */
6228 memcpy(key, tdata->key.data, tdata->key.len);
6229 retval = create_aead_xform(ut_params->op,
6231 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6232 key, tdata->key.len,
6233 tdata->aad.len, tdata->auth_tag.len,
6238 ut_params->op->sym->m_src = ut_params->ibuf;
6240 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6241 RTE_CRYPTO_OP_SESSIONLESS,
6242 "crypto op session type not sessionless");
6244 /* Process crypto operation */
6245 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6246 ut_params->op), "failed to process sym crypto op");
6248 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6250 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6251 "crypto op status not success");
6253 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6255 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6256 ut_params->op->sym->cipher.data.offset);
6257 auth_tag = ciphertext + plaintext_pad_len;
6259 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6260 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6265 tdata->ciphertext.data,
6266 tdata->ciphertext.len,
6267 "Ciphertext data not as expected");
6269 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6271 tdata->auth_tag.data,
6272 tdata->auth_tag.len,
6273 "Generated auth tag not as expected");
6280 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6282 return test_authenticated_encryption_sessionless(
6287 test_authenticated_decryption_sessionless(
6288 const struct aead_test_data *tdata)
6290 struct crypto_testsuite_params *ts_params = &testsuite_params;
6291 struct crypto_unittest_params *ut_params = &unittest_params;
6295 uint8_t key[tdata->key.len + 1];
6297 /* alloc mbuf and set payload */
6298 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6300 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6301 rte_pktmbuf_tailroom(ut_params->ibuf));
6303 /* Create AEAD operation */
6304 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6308 /* Create AEAD xform */
6309 memcpy(key, tdata->key.data, tdata->key.len);
6310 retval = create_aead_xform(ut_params->op,
6312 RTE_CRYPTO_AEAD_OP_DECRYPT,
6313 key, tdata->key.len,
6314 tdata->aad.len, tdata->auth_tag.len,
6319 ut_params->op->sym->m_src = ut_params->ibuf;
6321 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6322 RTE_CRYPTO_OP_SESSIONLESS,
6323 "crypto op session type not sessionless");
6325 /* Process crypto operation */
6326 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6327 ut_params->op), "failed to process sym crypto op");
6329 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6331 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6332 "crypto op status not success");
6334 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6335 ut_params->op->sym->cipher.data.offset);
6337 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6342 tdata->plaintext.data,
6343 tdata->plaintext.len,
6344 "Plaintext data not as expected");
6346 TEST_ASSERT_EQUAL(ut_params->op->status,
6347 RTE_CRYPTO_OP_STATUS_SUCCESS,
6348 "Authentication failed");
6353 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6355 return test_authenticated_decryption_sessionless(
6360 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6362 return test_authenticated_encryption(&ccm_test_case_128_1);
6366 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6368 return test_authenticated_encryption(&ccm_test_case_128_2);
6372 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6374 return test_authenticated_encryption(&ccm_test_case_128_3);
6378 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6380 return test_authenticated_decryption(&ccm_test_case_128_1);
6384 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6386 return test_authenticated_decryption(&ccm_test_case_128_2);
6390 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6392 return test_authenticated_decryption(&ccm_test_case_128_3);
6396 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6398 return test_authenticated_encryption(&ccm_test_case_192_1);
6402 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6404 return test_authenticated_encryption(&ccm_test_case_192_2);
6408 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6410 return test_authenticated_encryption(&ccm_test_case_192_3);
6414 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6416 return test_authenticated_decryption(&ccm_test_case_192_1);
6420 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6422 return test_authenticated_decryption(&ccm_test_case_192_2);
6426 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6428 return test_authenticated_decryption(&ccm_test_case_192_3);
6432 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6434 return test_authenticated_encryption(&ccm_test_case_256_1);
6438 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6440 return test_authenticated_encryption(&ccm_test_case_256_2);
6444 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6446 return test_authenticated_encryption(&ccm_test_case_256_3);
6450 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6452 return test_authenticated_decryption(&ccm_test_case_256_1);
6456 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6458 return test_authenticated_decryption(&ccm_test_case_256_2);
6462 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6464 return test_authenticated_decryption(&ccm_test_case_256_3);
6470 struct crypto_testsuite_params *ts_params = &testsuite_params;
6471 struct rte_cryptodev_stats stats;
6472 struct rte_cryptodev *dev;
6473 cryptodev_stats_get_t temp_pfn;
6475 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6476 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6477 &stats) == -ENODEV),
6478 "rte_cryptodev_stats_get invalid dev failed");
6479 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6480 "rte_cryptodev_stats_get invalid Param failed");
6481 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6482 temp_pfn = dev->dev_ops->stats_get;
6483 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6484 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6486 "rte_cryptodev_stats_get invalid Param failed");
6487 dev->dev_ops->stats_get = temp_pfn;
6489 /* Test expected values */
6491 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6493 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6495 "rte_cryptodev_stats_get failed");
6496 TEST_ASSERT((stats.enqueued_count == 1),
6497 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6498 TEST_ASSERT((stats.dequeued_count == 1),
6499 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6500 TEST_ASSERT((stats.enqueue_err_count == 0),
6501 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6502 TEST_ASSERT((stats.dequeue_err_count == 0),
6503 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6505 /* invalid device but should ignore and not reset device stats*/
6506 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6507 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6509 "rte_cryptodev_stats_get failed");
6510 TEST_ASSERT((stats.enqueued_count == 1),
6511 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6513 /* check that a valid reset clears stats */
6514 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6515 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6517 "rte_cryptodev_stats_get failed");
6518 TEST_ASSERT((stats.enqueued_count == 0),
6519 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6520 TEST_ASSERT((stats.dequeued_count == 0),
6521 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6523 return TEST_SUCCESS;
6526 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6527 struct crypto_unittest_params *ut_params,
6528 enum rte_crypto_auth_operation op,
6529 const struct HMAC_MD5_vector *test_case)
6533 memcpy(key, test_case->key.data, test_case->key.len);
6535 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6536 ut_params->auth_xform.next = NULL;
6537 ut_params->auth_xform.auth.op = op;
6539 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6541 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6542 ut_params->auth_xform.auth.key.length = test_case->key.len;
6543 ut_params->auth_xform.auth.key.data = key;
6545 ut_params->sess = rte_cryptodev_sym_session_create(
6546 ts_params->session_mpool);
6548 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6549 ut_params->sess, &ut_params->auth_xform,
6550 ts_params->session_mpool);
6552 if (ut_params->sess == NULL)
6555 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6557 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6558 rte_pktmbuf_tailroom(ut_params->ibuf));
6563 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6564 const struct HMAC_MD5_vector *test_case,
6565 uint8_t **plaintext)
6567 uint16_t plaintext_pad_len;
6569 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6571 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6574 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6576 memcpy(*plaintext, test_case->plaintext.data,
6577 test_case->plaintext.len);
6579 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6580 ut_params->ibuf, MD5_DIGEST_LEN);
6581 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6582 "no room to append digest");
6583 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6584 ut_params->ibuf, plaintext_pad_len);
6586 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6587 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6588 test_case->auth_tag.len);
6591 sym_op->auth.data.offset = 0;
6592 sym_op->auth.data.length = test_case->plaintext.len;
6594 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6595 ut_params->op->sym->m_src = ut_params->ibuf;
6601 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6603 uint16_t plaintext_pad_len;
6604 uint8_t *plaintext, *auth_tag;
6606 struct crypto_testsuite_params *ts_params = &testsuite_params;
6607 struct crypto_unittest_params *ut_params = &unittest_params;
6609 if (MD5_HMAC_create_session(ts_params, ut_params,
6610 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6613 /* Generate Crypto op data structure */
6614 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6615 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6616 TEST_ASSERT_NOT_NULL(ut_params->op,
6617 "Failed to allocate symmetric crypto operation struct");
6619 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6622 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6625 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6626 ut_params->op), "failed to process sym crypto op");
6628 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6629 "crypto op processing failed");
6631 if (ut_params->op->sym->m_dst) {
6632 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6633 uint8_t *, plaintext_pad_len);
6635 auth_tag = plaintext + plaintext_pad_len;
6638 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6640 test_case->auth_tag.data,
6641 test_case->auth_tag.len,
6642 "HMAC_MD5 generated tag not as expected");
6644 return TEST_SUCCESS;
6648 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6652 struct crypto_testsuite_params *ts_params = &testsuite_params;
6653 struct crypto_unittest_params *ut_params = &unittest_params;
6655 if (MD5_HMAC_create_session(ts_params, ut_params,
6656 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6660 /* Generate Crypto op data structure */
6661 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6662 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6663 TEST_ASSERT_NOT_NULL(ut_params->op,
6664 "Failed to allocate symmetric crypto operation struct");
6666 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6669 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6670 ut_params->op), "failed to process sym crypto op");
6672 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6673 "HMAC_MD5 crypto op processing failed");
6675 return TEST_SUCCESS;
6679 test_MD5_HMAC_generate_case_1(void)
6681 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6685 test_MD5_HMAC_verify_case_1(void)
6687 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6691 test_MD5_HMAC_generate_case_2(void)
6693 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6697 test_MD5_HMAC_verify_case_2(void)
6699 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6703 test_multi_session(void)
6705 struct crypto_testsuite_params *ts_params = &testsuite_params;
6706 struct crypto_unittest_params *ut_params = &unittest_params;
6708 struct rte_cryptodev_info dev_info;
6709 struct rte_cryptodev_sym_session **sessions;
6713 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6714 aes_cbc_key, hmac_sha512_key);
6717 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6719 sessions = rte_malloc(NULL,
6720 (sizeof(struct rte_cryptodev_sym_session *) *
6721 MAX_NB_SESSIONS) + 1, 0);
6723 /* Create multiple crypto sessions*/
6724 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6726 sessions[i] = rte_cryptodev_sym_session_create(
6727 ts_params->session_mpool);
6729 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6730 sessions[i], &ut_params->auth_xform,
6731 ts_params->session_mpool);
6732 TEST_ASSERT_NOT_NULL(sessions[i],
6733 "Session creation failed at session number %u",
6736 /* Attempt to send a request on each session */
6737 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6741 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6742 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6744 "Failed to perform decrypt on request number %u.", i);
6745 /* free crypto operation structure */
6747 rte_crypto_op_free(ut_params->op);
6750 * free mbuf - both obuf and ibuf are usually the same,
6751 * so check if they point at the same address is necessary,
6752 * to avoid freeing the mbuf twice.
6754 if (ut_params->obuf) {
6755 rte_pktmbuf_free(ut_params->obuf);
6756 if (ut_params->ibuf == ut_params->obuf)
6757 ut_params->ibuf = 0;
6758 ut_params->obuf = 0;
6760 if (ut_params->ibuf) {
6761 rte_pktmbuf_free(ut_params->ibuf);
6762 ut_params->ibuf = 0;
6766 /* Next session create should fail */
6767 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6768 sessions[i], &ut_params->auth_xform,
6769 ts_params->session_mpool);
6770 TEST_ASSERT_NULL(sessions[i],
6771 "Session creation succeeded unexpectedly!");
6773 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6774 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6776 rte_cryptodev_sym_session_free(sessions[i]);
6781 return TEST_SUCCESS;
6784 struct multi_session_params {
6785 struct crypto_unittest_params ut_params;
6786 uint8_t *cipher_key;
6788 const uint8_t *cipher;
6789 const uint8_t *digest;
6793 #define MB_SESSION_NUMBER 3
6796 test_multi_session_random_usage(void)
6798 struct crypto_testsuite_params *ts_params = &testsuite_params;
6799 struct rte_cryptodev_info dev_info;
6800 struct rte_cryptodev_sym_session **sessions;
6802 struct multi_session_params ut_paramz[] = {
6805 .cipher_key = ms_aes_cbc_key0,
6806 .hmac_key = ms_hmac_key0,
6807 .cipher = ms_aes_cbc_cipher0,
6808 .digest = ms_hmac_digest0,
6809 .iv = ms_aes_cbc_iv0
6812 .cipher_key = ms_aes_cbc_key1,
6813 .hmac_key = ms_hmac_key1,
6814 .cipher = ms_aes_cbc_cipher1,
6815 .digest = ms_hmac_digest1,
6816 .iv = ms_aes_cbc_iv1
6819 .cipher_key = ms_aes_cbc_key2,
6820 .hmac_key = ms_hmac_key2,
6821 .cipher = ms_aes_cbc_cipher2,
6822 .digest = ms_hmac_digest2,
6823 .iv = ms_aes_cbc_iv2
6828 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6830 sessions = rte_malloc(NULL,
6831 (sizeof(struct rte_cryptodev_sym_session *)
6832 * MAX_NB_SESSIONS) + 1, 0);
6834 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6835 sessions[i] = rte_cryptodev_sym_session_create(
6836 ts_params->session_mpool);
6838 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6839 sizeof(struct crypto_unittest_params));
6841 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6842 &ut_paramz[i].ut_params,
6843 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6845 /* Create multiple crypto sessions*/
6846 rte_cryptodev_sym_session_init(
6847 ts_params->valid_devs[0],
6849 &ut_paramz[i].ut_params.auth_xform,
6850 ts_params->session_mpool);
6852 TEST_ASSERT_NOT_NULL(sessions[i],
6853 "Session creation failed at session number %u",
6859 for (i = 0; i < 40000; i++) {
6861 j = rand() % MB_SESSION_NUMBER;
6863 TEST_ASSERT_SUCCESS(
6864 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6866 &ut_paramz[j].ut_params,
6867 ts_params, ut_paramz[j].cipher,
6868 ut_paramz[j].digest,
6870 "Failed to perform decrypt on request number %u.", i);
6872 if (ut_paramz[j].ut_params.op)
6873 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6876 * free mbuf - both obuf and ibuf are usually the same,
6877 * so check if they point at the same address is necessary,
6878 * to avoid freeing the mbuf twice.
6880 if (ut_paramz[j].ut_params.obuf) {
6881 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6882 if (ut_paramz[j].ut_params.ibuf
6883 == ut_paramz[j].ut_params.obuf)
6884 ut_paramz[j].ut_params.ibuf = 0;
6885 ut_paramz[j].ut_params.obuf = 0;
6887 if (ut_paramz[j].ut_params.ibuf) {
6888 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6889 ut_paramz[j].ut_params.ibuf = 0;
6893 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6894 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6896 rte_cryptodev_sym_session_free(sessions[i]);
6901 return TEST_SUCCESS;
6905 test_null_cipher_only_operation(void)
6907 struct crypto_testsuite_params *ts_params = &testsuite_params;
6908 struct crypto_unittest_params *ut_params = &unittest_params;
6910 /* Generate test mbuf data and space for digest */
6911 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6912 catch_22_quote, QUOTE_512_BYTES, 0);
6914 /* Setup Cipher Parameters */
6915 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6916 ut_params->cipher_xform.next = NULL;
6918 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6919 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6921 ut_params->sess = rte_cryptodev_sym_session_create(
6922 ts_params->session_mpool);
6924 /* Create Crypto session*/
6925 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6927 &ut_params->cipher_xform,
6928 ts_params->session_mpool);
6929 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6931 /* Generate Crypto op data structure */
6932 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6933 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6934 TEST_ASSERT_NOT_NULL(ut_params->op,
6935 "Failed to allocate symmetric crypto operation struct");
6937 /* Set crypto operation data parameters */
6938 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6940 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6942 /* set crypto operation source mbuf */
6943 sym_op->m_src = ut_params->ibuf;
6945 sym_op->cipher.data.offset = 0;
6946 sym_op->cipher.data.length = QUOTE_512_BYTES;
6948 /* Process crypto operation */
6949 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6951 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6953 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6954 "crypto operation processing failed");
6957 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6958 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6961 "Ciphertext data not as expected");
6963 return TEST_SUCCESS;
6965 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6966 0xab, 0xab, 0xab, 0xab,
6967 0xab, 0xab, 0xab, 0xab,
6968 0xab, 0xab, 0xab, 0xab};
6970 test_null_auth_only_operation(void)
6972 struct crypto_testsuite_params *ts_params = &testsuite_params;
6973 struct crypto_unittest_params *ut_params = &unittest_params;
6976 /* Generate test mbuf data and space for digest */
6977 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6978 catch_22_quote, QUOTE_512_BYTES, 0);
6980 /* create a pointer for digest, but don't expect anything to be written
6981 * here in a NULL auth algo so no mbuf append done.
6983 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6985 /* prefill the memory pointed to by digest */
6986 memcpy(digest, orig_data, sizeof(orig_data));
6988 /* Setup HMAC Parameters */
6989 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6990 ut_params->auth_xform.next = NULL;
6992 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6993 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6995 ut_params->sess = rte_cryptodev_sym_session_create(
6996 ts_params->session_mpool);
6998 /* Create Crypto session*/
6999 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7000 ut_params->sess, &ut_params->auth_xform,
7001 ts_params->session_mpool);
7002 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7004 /* Generate Crypto op data structure */
7005 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7006 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7007 TEST_ASSERT_NOT_NULL(ut_params->op,
7008 "Failed to allocate symmetric crypto operation struct");
7010 /* Set crypto operation data parameters */
7011 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7013 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7015 sym_op->m_src = ut_params->ibuf;
7017 sym_op->auth.data.offset = 0;
7018 sym_op->auth.data.length = QUOTE_512_BYTES;
7019 sym_op->auth.digest.data = digest;
7020 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7023 /* Process crypto operation */
7024 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7026 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7028 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7029 "crypto operation processing failed");
7030 /* Make sure memory pointed to by digest hasn't been overwritten */
7031 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7035 "Memory at digest ptr overwritten unexpectedly");
7037 return TEST_SUCCESS;
7042 test_null_cipher_auth_operation(void)
7044 struct crypto_testsuite_params *ts_params = &testsuite_params;
7045 struct crypto_unittest_params *ut_params = &unittest_params;
7048 /* Generate test mbuf data and space for digest */
7049 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7050 catch_22_quote, QUOTE_512_BYTES, 0);
7052 /* create a pointer for digest, but don't expect anything to be written
7053 * here in a NULL auth algo so no mbuf append done.
7055 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7057 /* prefill the memory pointed to by digest */
7058 memcpy(digest, orig_data, sizeof(orig_data));
7060 /* Setup Cipher Parameters */
7061 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7062 ut_params->cipher_xform.next = &ut_params->auth_xform;
7064 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7065 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7067 /* Setup HMAC Parameters */
7068 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7069 ut_params->auth_xform.next = NULL;
7071 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7072 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7074 ut_params->sess = rte_cryptodev_sym_session_create(
7075 ts_params->session_mpool);
7077 /* Create Crypto session*/
7078 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7079 ut_params->sess, &ut_params->cipher_xform,
7080 ts_params->session_mpool);
7081 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7083 /* Generate Crypto op data structure */
7084 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7085 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7086 TEST_ASSERT_NOT_NULL(ut_params->op,
7087 "Failed to allocate symmetric crypto operation struct");
7089 /* Set crypto operation data parameters */
7090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7092 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7094 sym_op->m_src = ut_params->ibuf;
7096 sym_op->cipher.data.offset = 0;
7097 sym_op->cipher.data.length = QUOTE_512_BYTES;
7099 sym_op->auth.data.offset = 0;
7100 sym_op->auth.data.length = QUOTE_512_BYTES;
7101 sym_op->auth.digest.data = digest;
7102 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7105 /* Process crypto operation */
7106 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7108 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7110 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7111 "crypto operation processing failed");
7114 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7115 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7118 "Ciphertext data not as expected");
7119 /* Make sure memory pointed to by digest hasn't been overwritten */
7120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7124 "Memory at digest ptr overwritten unexpectedly");
7126 return TEST_SUCCESS;
7130 test_null_auth_cipher_operation(void)
7132 struct crypto_testsuite_params *ts_params = &testsuite_params;
7133 struct crypto_unittest_params *ut_params = &unittest_params;
7136 /* Generate test mbuf data */
7137 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7138 catch_22_quote, QUOTE_512_BYTES, 0);
7140 /* create a pointer for digest, but don't expect anything to be written
7141 * here in a NULL auth algo so no mbuf append done.
7143 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7145 /* prefill the memory pointed to by digest */
7146 memcpy(digest, orig_data, sizeof(orig_data));
7148 /* Setup Cipher Parameters */
7149 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7150 ut_params->cipher_xform.next = NULL;
7152 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7153 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7155 /* Setup HMAC Parameters */
7156 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7157 ut_params->auth_xform.next = &ut_params->cipher_xform;
7159 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7160 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7162 ut_params->sess = rte_cryptodev_sym_session_create(
7163 ts_params->session_mpool);
7165 /* Create Crypto session*/
7166 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7167 ut_params->sess, &ut_params->cipher_xform,
7168 ts_params->session_mpool);
7169 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7171 /* Generate Crypto op data structure */
7172 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7173 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7174 TEST_ASSERT_NOT_NULL(ut_params->op,
7175 "Failed to allocate symmetric crypto operation struct");
7177 /* Set crypto operation data parameters */
7178 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7180 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7182 sym_op->m_src = ut_params->ibuf;
7184 sym_op->cipher.data.offset = 0;
7185 sym_op->cipher.data.length = QUOTE_512_BYTES;
7187 sym_op->auth.data.offset = 0;
7188 sym_op->auth.data.length = QUOTE_512_BYTES;
7189 sym_op->auth.digest.data = digest;
7190 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7193 /* Process crypto operation */
7194 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7196 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7198 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7199 "crypto operation processing failed");
7202 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7203 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7206 "Ciphertext data not as expected");
7207 /* Make sure memory pointed to by digest hasn't been overwritten */
7208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7212 "Memory at digest ptr overwritten unexpectedly");
7214 return TEST_SUCCESS;
7219 test_null_invalid_operation(void)
7221 struct crypto_testsuite_params *ts_params = &testsuite_params;
7222 struct crypto_unittest_params *ut_params = &unittest_params;
7225 /* Setup Cipher Parameters */
7226 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7227 ut_params->cipher_xform.next = NULL;
7229 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7230 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7232 ut_params->sess = rte_cryptodev_sym_session_create(
7233 ts_params->session_mpool);
7235 /* Create Crypto session*/
7236 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7237 ut_params->sess, &ut_params->cipher_xform,
7238 ts_params->session_mpool);
7239 TEST_ASSERT(ret < 0,
7240 "Session creation succeeded unexpectedly");
7243 /* Setup HMAC Parameters */
7244 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7245 ut_params->auth_xform.next = NULL;
7247 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7248 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7250 ut_params->sess = rte_cryptodev_sym_session_create(
7251 ts_params->session_mpool);
7253 /* Create Crypto session*/
7254 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7255 ut_params->sess, &ut_params->auth_xform,
7256 ts_params->session_mpool);
7257 TEST_ASSERT(ret < 0,
7258 "Session creation succeeded unexpectedly");
7260 return TEST_SUCCESS;
7264 #define NULL_BURST_LENGTH (32)
7267 test_null_burst_operation(void)
7269 struct crypto_testsuite_params *ts_params = &testsuite_params;
7270 struct crypto_unittest_params *ut_params = &unittest_params;
7272 unsigned i, burst_len = NULL_BURST_LENGTH;
7274 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7275 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7277 /* Setup Cipher Parameters */
7278 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7279 ut_params->cipher_xform.next = &ut_params->auth_xform;
7281 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7282 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7284 /* Setup HMAC Parameters */
7285 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7286 ut_params->auth_xform.next = NULL;
7288 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7289 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7291 ut_params->sess = rte_cryptodev_sym_session_create(
7292 ts_params->session_mpool);
7294 /* Create Crypto session*/
7295 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7296 ut_params->sess, &ut_params->cipher_xform,
7297 ts_params->session_mpool);
7298 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7300 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7301 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7302 burst_len, "failed to generate burst of crypto ops");
7304 /* Generate an operation for each mbuf in burst */
7305 for (i = 0; i < burst_len; i++) {
7306 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7308 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7310 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7314 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7316 burst[i]->sym->m_src = m;
7319 /* Process crypto operation */
7320 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7321 0, burst, burst_len),
7323 "Error enqueuing burst");
7325 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7326 0, burst_dequeued, burst_len),
7328 "Error dequeuing burst");
7331 for (i = 0; i < burst_len; i++) {
7333 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7334 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7336 "data not as expected");
7338 rte_pktmbuf_free(burst[i]->sym->m_src);
7339 rte_crypto_op_free(burst[i]);
7342 return TEST_SUCCESS;
7346 generate_gmac_large_plaintext(uint8_t *data)
7350 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7351 memcpy(&data[i], &data[0], 32);
7355 create_gmac_operation(enum rte_crypto_auth_operation op,
7356 const struct gmac_test_data *tdata)
7358 struct crypto_testsuite_params *ts_params = &testsuite_params;
7359 struct crypto_unittest_params *ut_params = &unittest_params;
7360 struct rte_crypto_sym_op *sym_op;
7362 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7364 /* Generate Crypto op data structure */
7365 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7366 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7367 TEST_ASSERT_NOT_NULL(ut_params->op,
7368 "Failed to allocate symmetric crypto operation struct");
7370 sym_op = ut_params->op->sym;
7372 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7373 ut_params->ibuf, tdata->gmac_tag.len);
7374 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7375 "no room to append digest");
7377 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7378 ut_params->ibuf, plaintext_pad_len);
7380 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7381 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7382 tdata->gmac_tag.len);
7383 debug_hexdump(stdout, "digest:",
7384 sym_op->auth.digest.data,
7385 tdata->gmac_tag.len);
7388 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7389 uint8_t *, IV_OFFSET);
7391 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7393 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7395 sym_op->cipher.data.length = 0;
7396 sym_op->cipher.data.offset = 0;
7398 sym_op->auth.data.offset = 0;
7399 sym_op->auth.data.length = tdata->plaintext.len;
7404 static int create_gmac_session(uint8_t dev_id,
7405 const struct gmac_test_data *tdata,
7406 enum rte_crypto_auth_operation auth_op)
7408 uint8_t auth_key[tdata->key.len];
7410 struct crypto_testsuite_params *ts_params = &testsuite_params;
7411 struct crypto_unittest_params *ut_params = &unittest_params;
7413 memcpy(auth_key, tdata->key.data, tdata->key.len);
7415 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7416 ut_params->auth_xform.next = NULL;
7418 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7419 ut_params->auth_xform.auth.op = auth_op;
7420 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7421 ut_params->auth_xform.auth.key.length = tdata->key.len;
7422 ut_params->auth_xform.auth.key.data = auth_key;
7423 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7424 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7427 ut_params->sess = rte_cryptodev_sym_session_create(
7428 ts_params->session_mpool);
7430 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7431 &ut_params->auth_xform,
7432 ts_params->session_mpool);
7434 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7440 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7442 struct crypto_testsuite_params *ts_params = &testsuite_params;
7443 struct crypto_unittest_params *ut_params = &unittest_params;
7447 uint8_t *auth_tag, *plaintext;
7448 uint16_t plaintext_pad_len;
7450 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7451 "No GMAC length in the source data");
7453 retval = create_gmac_session(ts_params->valid_devs[0],
7454 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7459 if (tdata->plaintext.len > MBUF_SIZE)
7460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7464 "Failed to allocate input buffer in mempool");
7466 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7467 rte_pktmbuf_tailroom(ut_params->ibuf));
7469 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7471 * Runtime generate the large plain text instead of use hard code
7472 * plain text vector. It is done to avoid create huge source file
7473 * with the test vector.
7475 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7476 generate_gmac_large_plaintext(tdata->plaintext.data);
7478 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7480 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7482 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7483 debug_hexdump(stdout, "plaintext:", plaintext,
7484 tdata->plaintext.len);
7486 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7494 ut_params->op->sym->m_src = ut_params->ibuf;
7496 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7497 ut_params->op), "failed to process sym crypto op");
7499 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7500 "crypto op processing failed");
7502 if (ut_params->op->sym->m_dst) {
7503 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7504 uint8_t *, plaintext_pad_len);
7506 auth_tag = plaintext + plaintext_pad_len;
7509 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7513 tdata->gmac_tag.data,
7514 tdata->gmac_tag.len,
7515 "GMAC Generated auth tag not as expected");
7521 test_AES_GMAC_authentication_test_case_1(void)
7523 return test_AES_GMAC_authentication(&gmac_test_case_1);
7527 test_AES_GMAC_authentication_test_case_2(void)
7529 return test_AES_GMAC_authentication(&gmac_test_case_2);
7533 test_AES_GMAC_authentication_test_case_3(void)
7535 return test_AES_GMAC_authentication(&gmac_test_case_3);
7539 test_AES_GMAC_authentication_test_case_4(void)
7541 return test_AES_GMAC_authentication(&gmac_test_case_4);
7545 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7547 struct crypto_testsuite_params *ts_params = &testsuite_params;
7548 struct crypto_unittest_params *ut_params = &unittest_params;
7550 uint32_t plaintext_pad_len;
7553 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7554 "No GMAC length in the source data");
7556 retval = create_gmac_session(ts_params->valid_devs[0],
7557 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7562 if (tdata->plaintext.len > MBUF_SIZE)
7563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7566 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7567 "Failed to allocate input buffer in mempool");
7569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7570 rte_pktmbuf_tailroom(ut_params->ibuf));
7572 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7575 * Runtime generate the large plain text instead of use hard code
7576 * plain text vector. It is done to avoid create huge source file
7577 * with the test vector.
7579 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7580 generate_gmac_large_plaintext(tdata->plaintext.data);
7582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7584 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7586 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7587 debug_hexdump(stdout, "plaintext:", plaintext,
7588 tdata->plaintext.len);
7590 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7596 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7598 ut_params->op->sym->m_src = ut_params->ibuf;
7600 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7601 ut_params->op), "failed to process sym crypto op");
7603 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7604 "crypto op processing failed");
7611 test_AES_GMAC_authentication_verify_test_case_1(void)
7613 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7617 test_AES_GMAC_authentication_verify_test_case_2(void)
7619 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7623 test_AES_GMAC_authentication_verify_test_case_3(void)
7625 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7629 test_AES_GMAC_authentication_verify_test_case_4(void)
7631 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7634 struct test_crypto_vector {
7635 enum rte_crypto_cipher_algorithm crypto_algo;
7648 const uint8_t *data;
7653 const uint8_t *data;
7657 enum rte_crypto_auth_algorithm auth_algo;
7665 const uint8_t *data;
7675 static const struct test_crypto_vector
7676 hmac_sha1_test_crypto_vector = {
7677 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7679 .data = plaintext_hash,
7684 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7685 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7686 0xDE, 0xF4, 0xDE, 0xAD
7692 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7693 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7694 0x3F, 0x91, 0x64, 0x59
7700 static const struct test_crypto_vector
7701 aes128_gmac_test_vector = {
7702 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7704 .data = plaintext_hash,
7709 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7710 0x08, 0x09, 0x0A, 0x0B
7716 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7717 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7723 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7724 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7730 static const struct test_crypto_vector
7731 aes128cbc_hmac_sha1_test_vector = {
7732 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7735 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7736 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7742 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7743 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7748 .data = plaintext_hash,
7752 .data = ciphertext512_aes128cbc,
7755 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7758 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7759 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7760 0xDE, 0xF4, 0xDE, 0xAD
7766 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7767 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7768 0x18, 0x8C, 0x1D, 0x32
7775 data_corruption(uint8_t *data)
7781 tag_corruption(uint8_t *data, unsigned int tag_offset)
7783 data[tag_offset] += 1;
7787 create_auth_session(struct crypto_unittest_params *ut_params,
7789 const struct test_crypto_vector *reference,
7790 enum rte_crypto_auth_operation auth_op)
7792 struct crypto_testsuite_params *ts_params = &testsuite_params;
7793 uint8_t auth_key[reference->auth_key.len + 1];
7795 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7797 /* Setup Authentication Parameters */
7798 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7799 ut_params->auth_xform.auth.op = auth_op;
7800 ut_params->auth_xform.next = NULL;
7801 ut_params->auth_xform.auth.algo = reference->auth_algo;
7802 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7803 ut_params->auth_xform.auth.key.data = auth_key;
7804 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7806 /* Create Crypto session*/
7807 ut_params->sess = rte_cryptodev_sym_session_create(
7808 ts_params->session_mpool);
7810 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7811 &ut_params->auth_xform,
7812 ts_params->session_mpool);
7814 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7820 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7822 const struct test_crypto_vector *reference,
7823 enum rte_crypto_auth_operation auth_op,
7824 enum rte_crypto_cipher_operation cipher_op)
7826 struct crypto_testsuite_params *ts_params = &testsuite_params;
7827 uint8_t cipher_key[reference->cipher_key.len + 1];
7828 uint8_t auth_key[reference->auth_key.len + 1];
7830 memcpy(cipher_key, reference->cipher_key.data,
7831 reference->cipher_key.len);
7832 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7834 /* Setup Authentication Parameters */
7835 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7836 ut_params->auth_xform.auth.op = auth_op;
7837 ut_params->auth_xform.auth.algo = reference->auth_algo;
7838 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7839 ut_params->auth_xform.auth.key.data = auth_key;
7840 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7842 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7843 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7844 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7846 ut_params->auth_xform.next = &ut_params->cipher_xform;
7848 /* Setup Cipher Parameters */
7849 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7850 ut_params->cipher_xform.next = NULL;
7851 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7852 ut_params->cipher_xform.cipher.op = cipher_op;
7853 ut_params->cipher_xform.cipher.key.data = cipher_key;
7854 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7855 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7856 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7859 /* Create Crypto session*/
7860 ut_params->sess = rte_cryptodev_sym_session_create(
7861 ts_params->session_mpool);
7863 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7864 &ut_params->auth_xform,
7865 ts_params->session_mpool);
7867 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7873 create_auth_operation(struct crypto_testsuite_params *ts_params,
7874 struct crypto_unittest_params *ut_params,
7875 const struct test_crypto_vector *reference,
7876 unsigned int auth_generate)
7878 /* Generate Crypto op data structure */
7879 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7880 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7881 TEST_ASSERT_NOT_NULL(ut_params->op,
7882 "Failed to allocate pktmbuf offload");
7884 /* Set crypto operation data parameters */
7885 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7887 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7889 /* set crypto operation source mbuf */
7890 sym_op->m_src = ut_params->ibuf;
7893 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7894 ut_params->ibuf, reference->digest.len);
7896 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7897 "no room to append auth tag");
7899 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7900 ut_params->ibuf, reference->plaintext.len);
7903 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7905 memcpy(sym_op->auth.digest.data,
7906 reference->digest.data,
7907 reference->digest.len);
7909 debug_hexdump(stdout, "digest:",
7910 sym_op->auth.digest.data,
7911 reference->digest.len);
7913 sym_op->auth.data.length = reference->plaintext.len;
7914 sym_op->auth.data.offset = 0;
7920 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7921 struct crypto_unittest_params *ut_params,
7922 const struct test_crypto_vector *reference,
7923 unsigned int auth_generate)
7925 /* Generate Crypto op data structure */
7926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7928 TEST_ASSERT_NOT_NULL(ut_params->op,
7929 "Failed to allocate pktmbuf offload");
7931 /* Set crypto operation data parameters */
7932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7934 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7936 /* set crypto operation source mbuf */
7937 sym_op->m_src = ut_params->ibuf;
7940 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7941 ut_params->ibuf, reference->digest.len);
7943 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7944 "no room to append auth tag");
7946 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7947 ut_params->ibuf, reference->ciphertext.len);
7950 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7952 memcpy(sym_op->auth.digest.data,
7953 reference->digest.data,
7954 reference->digest.len);
7956 debug_hexdump(stdout, "digest:",
7957 sym_op->auth.digest.data,
7958 reference->digest.len);
7960 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7961 reference->iv.data, reference->iv.len);
7963 sym_op->cipher.data.length = 0;
7964 sym_op->cipher.data.offset = 0;
7966 sym_op->auth.data.length = reference->plaintext.len;
7967 sym_op->auth.data.offset = 0;
7973 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7974 struct crypto_unittest_params *ut_params,
7975 const struct test_crypto_vector *reference,
7976 unsigned int auth_generate)
7978 /* Generate Crypto op data structure */
7979 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7980 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7981 TEST_ASSERT_NOT_NULL(ut_params->op,
7982 "Failed to allocate pktmbuf offload");
7984 /* Set crypto operation data parameters */
7985 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7987 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7989 /* set crypto operation source mbuf */
7990 sym_op->m_src = ut_params->ibuf;
7993 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7994 ut_params->ibuf, reference->digest.len);
7996 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7997 "no room to append auth tag");
7999 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8000 ut_params->ibuf, reference->ciphertext.len);
8003 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8005 memcpy(sym_op->auth.digest.data,
8006 reference->digest.data,
8007 reference->digest.len);
8009 debug_hexdump(stdout, "digest:",
8010 sym_op->auth.digest.data,
8011 reference->digest.len);
8013 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8014 reference->iv.data, reference->iv.len);
8016 sym_op->cipher.data.length = reference->ciphertext.len;
8017 sym_op->cipher.data.offset = 0;
8019 sym_op->auth.data.length = reference->ciphertext.len;
8020 sym_op->auth.data.offset = 0;
8026 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8027 struct crypto_unittest_params *ut_params,
8028 const struct test_crypto_vector *reference)
8030 return create_auth_operation(ts_params, ut_params, reference, 0);
8034 create_auth_verify_GMAC_operation(
8035 struct crypto_testsuite_params *ts_params,
8036 struct crypto_unittest_params *ut_params,
8037 const struct test_crypto_vector *reference)
8039 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8043 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8044 struct crypto_unittest_params *ut_params,
8045 const struct test_crypto_vector *reference)
8047 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8051 test_authentication_verify_fail_when_data_corruption(
8052 struct crypto_testsuite_params *ts_params,
8053 struct crypto_unittest_params *ut_params,
8054 const struct test_crypto_vector *reference,
8055 unsigned int data_corrupted)
8061 /* Create session */
8062 retval = create_auth_session(ut_params,
8063 ts_params->valid_devs[0],
8065 RTE_CRYPTO_AUTH_OP_VERIFY);
8069 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8070 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8071 "Failed to allocate input buffer in mempool");
8073 /* clear mbuf payload */
8074 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8075 rte_pktmbuf_tailroom(ut_params->ibuf));
8077 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8078 reference->plaintext.len);
8079 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8080 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8082 debug_hexdump(stdout, "plaintext:", plaintext,
8083 reference->plaintext.len);
8085 /* Create operation */
8086 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8092 data_corruption(plaintext);
8094 tag_corruption(plaintext, reference->plaintext.len);
8096 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8098 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8099 TEST_ASSERT_EQUAL(ut_params->op->status,
8100 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8101 "authentication not failed");
8103 ut_params->obuf = ut_params->op->sym->m_src;
8104 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8110 test_authentication_verify_GMAC_fail_when_corruption(
8111 struct crypto_testsuite_params *ts_params,
8112 struct crypto_unittest_params *ut_params,
8113 const struct test_crypto_vector *reference,
8114 unsigned int data_corrupted)
8119 /* Create session */
8120 retval = create_auth_cipher_session(ut_params,
8121 ts_params->valid_devs[0],
8123 RTE_CRYPTO_AUTH_OP_VERIFY,
8124 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8128 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8129 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8130 "Failed to allocate input buffer in mempool");
8132 /* clear mbuf payload */
8133 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8134 rte_pktmbuf_tailroom(ut_params->ibuf));
8136 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8137 reference->plaintext.len);
8138 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8139 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8141 debug_hexdump(stdout, "plaintext:", plaintext,
8142 reference->plaintext.len);
8144 /* Create operation */
8145 retval = create_auth_verify_GMAC_operation(ts_params,
8153 data_corruption(plaintext);
8155 tag_corruption(plaintext, reference->aad.len);
8157 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8159 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8160 TEST_ASSERT_EQUAL(ut_params->op->status,
8161 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8162 "authentication not failed");
8164 ut_params->obuf = ut_params->op->sym->m_src;
8165 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8171 test_authenticated_decryption_fail_when_corruption(
8172 struct crypto_testsuite_params *ts_params,
8173 struct crypto_unittest_params *ut_params,
8174 const struct test_crypto_vector *reference,
8175 unsigned int data_corrupted)
8179 uint8_t *ciphertext;
8181 /* Create session */
8182 retval = create_auth_cipher_session(ut_params,
8183 ts_params->valid_devs[0],
8185 RTE_CRYPTO_AUTH_OP_VERIFY,
8186 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8190 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8191 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8192 "Failed to allocate input buffer in mempool");
8194 /* clear mbuf payload */
8195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8196 rte_pktmbuf_tailroom(ut_params->ibuf));
8198 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8199 reference->ciphertext.len);
8200 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8201 memcpy(ciphertext, reference->ciphertext.data,
8202 reference->ciphertext.len);
8204 /* Create operation */
8205 retval = create_cipher_auth_verify_operation(ts_params,
8213 data_corruption(ciphertext);
8215 tag_corruption(ciphertext, reference->ciphertext.len);
8217 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8220 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8221 TEST_ASSERT_EQUAL(ut_params->op->status,
8222 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8223 "authentication not failed");
8225 ut_params->obuf = ut_params->op->sym->m_src;
8226 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8232 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8233 const struct aead_test_data *tdata,
8234 void *digest_mem, uint64_t digest_phys)
8236 struct crypto_testsuite_params *ts_params = &testsuite_params;
8237 struct crypto_unittest_params *ut_params = &unittest_params;
8239 const unsigned int auth_tag_len = tdata->auth_tag.len;
8240 const unsigned int iv_len = tdata->iv.len;
8241 unsigned int aad_len = tdata->aad.len;
8243 /* Generate Crypto op data structure */
8244 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8245 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8246 TEST_ASSERT_NOT_NULL(ut_params->op,
8247 "Failed to allocate symmetric crypto operation struct");
8249 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8251 sym_op->aead.digest.data = digest_mem;
8253 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8254 "no room to append digest");
8256 sym_op->aead.digest.phys_addr = digest_phys;
8258 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8259 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8261 debug_hexdump(stdout, "digest:",
8262 sym_op->aead.digest.data,
8266 /* Append aad data */
8267 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8268 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8269 uint8_t *, IV_OFFSET);
8271 /* Copy IV 1 byte after the IV pointer, according to the API */
8272 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8274 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8276 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8277 ut_params->ibuf, aad_len);
8278 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8279 "no room to prepend aad");
8280 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8283 memset(sym_op->aead.aad.data, 0, aad_len);
8284 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8285 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8287 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8288 debug_hexdump(stdout, "aad:",
8289 sym_op->aead.aad.data, aad_len);
8291 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8292 uint8_t *, IV_OFFSET);
8294 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8296 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8297 ut_params->ibuf, aad_len);
8298 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8299 "no room to prepend aad");
8300 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8303 memset(sym_op->aead.aad.data, 0, aad_len);
8304 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8306 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8307 debug_hexdump(stdout, "aad:",
8308 sym_op->aead.aad.data, aad_len);
8311 sym_op->aead.data.length = tdata->plaintext.len;
8312 sym_op->aead.data.offset = aad_len;
8317 #define SGL_MAX_NO 16
8320 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8321 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8323 struct crypto_testsuite_params *ts_params = &testsuite_params;
8324 struct crypto_unittest_params *ut_params = &unittest_params;
8325 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8328 int to_trn_tbl[SGL_MAX_NO];
8330 unsigned int trn_data = 0;
8331 uint8_t *plaintext, *ciphertext, *auth_tag;
8333 if (fragsz > tdata->plaintext.len)
8334 fragsz = tdata->plaintext.len;
8336 uint16_t plaintext_len = fragsz;
8337 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8339 if (fragsz_oop > tdata->plaintext.len)
8340 frag_size_oop = tdata->plaintext.len;
8343 void *digest_mem = NULL;
8345 uint32_t prepend_len = tdata->aad.len;
8347 if (tdata->plaintext.len % fragsz != 0) {
8348 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8351 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8356 * For out-op-place we need to alloc another mbuf
8359 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8360 rte_pktmbuf_append(ut_params->obuf,
8361 frag_size_oop + prepend_len);
8362 buf_oop = ut_params->obuf;
8365 /* Create AEAD session */
8366 retval = create_aead_session(ts_params->valid_devs[0],
8368 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8369 tdata->key.data, tdata->key.len,
8370 tdata->aad.len, tdata->auth_tag.len,
8375 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8377 /* clear mbuf payload */
8378 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8379 rte_pktmbuf_tailroom(ut_params->ibuf));
8381 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8384 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8386 trn_data += plaintext_len;
8388 buf = ut_params->ibuf;
8391 * Loop until no more fragments
8394 while (trn_data < tdata->plaintext.len) {
8396 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8397 (tdata->plaintext.len - trn_data) : fragsz;
8399 to_trn_tbl[ecx++] = to_trn;
8401 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8404 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8405 rte_pktmbuf_tailroom(buf));
8408 if (oop && !fragsz_oop) {
8409 buf_last_oop = buf_oop->next =
8410 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8411 buf_oop = buf_oop->next;
8412 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8413 0, rte_pktmbuf_tailroom(buf_oop));
8414 rte_pktmbuf_append(buf_oop, to_trn);
8417 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8420 memcpy(plaintext, tdata->plaintext.data + trn_data,
8423 if (trn_data == tdata->plaintext.len) {
8426 digest_mem = rte_pktmbuf_append(buf_oop,
8427 tdata->auth_tag.len);
8429 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8430 tdata->auth_tag.len);
8434 uint64_t digest_phys = 0;
8436 ut_params->ibuf->nb_segs = segs;
8439 if (fragsz_oop && oop) {
8443 if (frag_size_oop == tdata->plaintext.len) {
8444 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8445 tdata->auth_tag.len);
8447 digest_phys = rte_pktmbuf_iova_offset(
8449 tdata->plaintext.len + prepend_len);
8452 trn_data = frag_size_oop;
8453 while (trn_data < tdata->plaintext.len) {
8456 (tdata->plaintext.len - trn_data <
8458 (tdata->plaintext.len - trn_data) :
8461 to_trn_tbl[ecx++] = to_trn;
8463 buf_last_oop = buf_oop->next =
8464 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8465 buf_oop = buf_oop->next;
8466 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8467 0, rte_pktmbuf_tailroom(buf_oop));
8468 rte_pktmbuf_append(buf_oop, to_trn);
8472 if (trn_data == tdata->plaintext.len) {
8473 digest_mem = rte_pktmbuf_append(buf_oop,
8474 tdata->auth_tag.len);
8478 ut_params->obuf->nb_segs = segs;
8482 * Place digest at the end of the last buffer
8485 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8486 if (oop && buf_last_oop)
8487 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8489 if (!digest_mem && !oop) {
8490 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8491 + tdata->auth_tag.len);
8492 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8493 tdata->plaintext.len);
8496 /* Create AEAD operation */
8497 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8498 tdata, digest_mem, digest_phys);
8503 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8505 ut_params->op->sym->m_src = ut_params->ibuf;
8507 ut_params->op->sym->m_dst = ut_params->obuf;
8509 /* Process crypto operation */
8510 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8511 ut_params->op), "failed to process sym crypto op");
8513 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8514 "crypto op processing failed");
8517 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8518 uint8_t *, prepend_len);
8520 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8521 uint8_t *, prepend_len);
8525 fragsz = fragsz_oop;
8527 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8529 tdata->ciphertext.data,
8531 "Ciphertext data not as expected");
8533 buf = ut_params->op->sym->m_src->next;
8535 buf = ut_params->op->sym->m_dst->next;
8537 unsigned int off = fragsz;
8541 ciphertext = rte_pktmbuf_mtod(buf,
8544 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8546 tdata->ciphertext.data + off,
8548 "Ciphertext data not as expected");
8550 off += to_trn_tbl[ecx++];
8554 auth_tag = digest_mem;
8555 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8557 tdata->auth_tag.data,
8558 tdata->auth_tag.len,
8559 "Generated auth tag not as expected");
8565 #define OUT_OF_PLACE 1
8568 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8570 return test_authenticated_encryption_SGL(
8571 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8575 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8577 return test_authenticated_encryption_SGL(
8578 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8582 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8584 return test_authenticated_encryption_SGL(
8585 &gcm_test_case_8, OUT_OF_PLACE, 400,
8586 gcm_test_case_8.plaintext.len);
8590 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8593 return test_authenticated_encryption_SGL(
8594 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8598 test_authentication_verify_fail_when_data_corrupted(
8599 struct crypto_testsuite_params *ts_params,
8600 struct crypto_unittest_params *ut_params,
8601 const struct test_crypto_vector *reference)
8603 return test_authentication_verify_fail_when_data_corruption(
8604 ts_params, ut_params, reference, 1);
8608 test_authentication_verify_fail_when_tag_corrupted(
8609 struct crypto_testsuite_params *ts_params,
8610 struct crypto_unittest_params *ut_params,
8611 const struct test_crypto_vector *reference)
8613 return test_authentication_verify_fail_when_data_corruption(
8614 ts_params, ut_params, reference, 0);
8618 test_authentication_verify_GMAC_fail_when_data_corrupted(
8619 struct crypto_testsuite_params *ts_params,
8620 struct crypto_unittest_params *ut_params,
8621 const struct test_crypto_vector *reference)
8623 return test_authentication_verify_GMAC_fail_when_corruption(
8624 ts_params, ut_params, reference, 1);
8628 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8629 struct crypto_testsuite_params *ts_params,
8630 struct crypto_unittest_params *ut_params,
8631 const struct test_crypto_vector *reference)
8633 return test_authentication_verify_GMAC_fail_when_corruption(
8634 ts_params, ut_params, reference, 0);
8638 test_authenticated_decryption_fail_when_data_corrupted(
8639 struct crypto_testsuite_params *ts_params,
8640 struct crypto_unittest_params *ut_params,
8641 const struct test_crypto_vector *reference)
8643 return test_authenticated_decryption_fail_when_corruption(
8644 ts_params, ut_params, reference, 1);
8648 test_authenticated_decryption_fail_when_tag_corrupted(
8649 struct crypto_testsuite_params *ts_params,
8650 struct crypto_unittest_params *ut_params,
8651 const struct test_crypto_vector *reference)
8653 return test_authenticated_decryption_fail_when_corruption(
8654 ts_params, ut_params, reference, 0);
8658 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8660 return test_authentication_verify_fail_when_data_corrupted(
8661 &testsuite_params, &unittest_params,
8662 &hmac_sha1_test_crypto_vector);
8666 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8668 return test_authentication_verify_fail_when_tag_corrupted(
8669 &testsuite_params, &unittest_params,
8670 &hmac_sha1_test_crypto_vector);
8674 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8676 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8677 &testsuite_params, &unittest_params,
8678 &aes128_gmac_test_vector);
8682 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8684 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8685 &testsuite_params, &unittest_params,
8686 &aes128_gmac_test_vector);
8690 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8692 return test_authenticated_decryption_fail_when_data_corrupted(
8695 &aes128cbc_hmac_sha1_test_vector);
8699 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8701 return test_authenticated_decryption_fail_when_tag_corrupted(
8704 &aes128cbc_hmac_sha1_test_vector);
8707 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8709 /* global AESNI slave IDs for the scheduler test */
8710 uint8_t aesni_ids[2];
8713 test_scheduler_attach_slave_op(void)
8715 struct crypto_testsuite_params *ts_params = &testsuite_params;
8716 uint8_t sched_id = ts_params->valid_devs[0];
8717 uint32_t nb_devs, i, nb_devs_attached = 0;
8721 /* create 2 AESNI_MB if necessary */
8722 nb_devs = rte_cryptodev_device_count_by_driver(
8723 rte_cryptodev_driver_id_get(
8724 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8726 for (i = nb_devs; i < 2; i++) {
8727 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8728 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8730 ret = rte_vdev_init(vdev_name, NULL);
8732 TEST_ASSERT(ret == 0,
8733 "Failed to create instance %u of"
8735 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8739 /* attach 2 AESNI_MB cdevs */
8740 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8742 struct rte_cryptodev_info info;
8744 rte_cryptodev_info_get(i, &info);
8745 if (info.driver_id != rte_cryptodev_driver_id_get(
8746 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8750 * Create the session mempool again, since now there are new devices
8751 * to use the mempool.
8753 if (ts_params->session_mpool) {
8754 rte_mempool_free(ts_params->session_mpool);
8755 ts_params->session_mpool = NULL;
8757 unsigned int session_size =
8758 rte_cryptodev_sym_get_private_session_size(i);
8760 if (info.sym.max_nb_sessions != 0 &&
8761 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8763 "Device does not support "
8764 "at least %u sessions\n",
8769 * Create mempool with maximum number of sessions * 2,
8770 * to include the session headers
8772 if (ts_params->session_mpool == NULL) {
8773 ts_params->session_mpool = rte_mempool_create(
8775 MAX_NB_SESSIONS * 2,
8777 0, 0, NULL, NULL, NULL,
8778 NULL, SOCKET_ID_ANY,
8781 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8782 "session mempool allocation failed");
8785 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8788 TEST_ASSERT(ret == 0,
8789 "Failed to attach device %u of pmd : %s", i,
8790 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8792 aesni_ids[nb_devs_attached] = (uint8_t)i;
8801 test_scheduler_detach_slave_op(void)
8803 struct crypto_testsuite_params *ts_params = &testsuite_params;
8804 uint8_t sched_id = ts_params->valid_devs[0];
8808 for (i = 0; i < 2; i++) {
8809 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8811 TEST_ASSERT(ret == 0,
8812 "Failed to detach device %u", aesni_ids[i]);
8819 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8821 struct crypto_testsuite_params *ts_params = &testsuite_params;
8822 uint8_t sched_id = ts_params->valid_devs[0];
8824 return rte_cryptodev_scheduler_mode_set(sched_id,
8829 test_scheduler_mode_roundrobin_op(void)
8831 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8832 0, "Failed to set roundrobin mode");
8838 test_scheduler_mode_multicore_op(void)
8840 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8841 0, "Failed to set multicore mode");
8847 test_scheduler_mode_failover_op(void)
8849 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8850 0, "Failed to set failover mode");
8856 test_scheduler_mode_pkt_size_distr_op(void)
8858 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8859 0, "Failed to set pktsize mode");
8864 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8865 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8866 .setup = testsuite_setup,
8867 .teardown = testsuite_teardown,
8868 .unit_test_cases = {
8870 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8871 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_AES_chain_scheduler_all),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_AES_cipheronly_scheduler_all),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_authonly_scheduler_all),
8878 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8881 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8882 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_chain_scheduler_all),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_cipheronly_scheduler_all),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_authonly_scheduler_all),
8889 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8892 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8893 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_AES_chain_scheduler_all),
8896 TEST_CASE_ST(ut_setup, ut_teardown,
8897 test_AES_cipheronly_scheduler_all),
8898 TEST_CASE_ST(ut_setup, ut_teardown,
8899 test_authonly_scheduler_all),
8900 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8903 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8904 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_chain_scheduler_all),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_cipheronly_scheduler_all),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_authonly_scheduler_all),
8911 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8913 TEST_CASES_END() /**< NULL terminate unit test array */
8917 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8919 static struct unit_test_suite cryptodev_qat_testsuite = {
8920 .suite_name = "Crypto QAT Unit Test Suite",
8921 .setup = testsuite_setup,
8922 .teardown = testsuite_teardown,
8923 .unit_test_cases = {
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_device_configure_invalid_dev_id),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_device_configure_invalid_queue_pair_ids),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_queue_pair_descriptor_setup),
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_multi_session),
8933 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_AES_cipheronly_qat_all),
8936 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_3DES_cipheronly_qat_all),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_DES_cipheronly_qat_all),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_AES_docsis_qat_all),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_DES_docsis_qat_all),
8945 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8946 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8948 /** AES CCM Authenticated Encryption 128 bits key */
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_AES_CCM_authenticated_encryption_test_case_128_1),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_AES_CCM_authenticated_encryption_test_case_128_2),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_AES_CCM_authenticated_encryption_test_case_128_3),
8956 /** AES CCM Authenticated Decryption 128 bits key*/
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_AES_CCM_authenticated_decryption_test_case_128_1),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_AES_CCM_authenticated_decryption_test_case_128_2),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_AES_CCM_authenticated_decryption_test_case_128_3),
8964 /** AES GCM Authenticated Encryption */
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_AES_GCM_authenticated_encryption_test_case_1),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_GCM_authenticated_encryption_test_case_2),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_GCM_authenticated_encryption_test_case_3),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_AES_GCM_authenticated_encryption_test_case_4),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_GCM_authenticated_encryption_test_case_5),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_AES_GCM_authenticated_encryption_test_case_6),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_GCM_authenticated_encryption_test_case_7),
8986 /** AES GCM Authenticated Decryption */
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_authenticated_decryption_test_case_1),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_AES_GCM_authenticated_decryption_test_case_2),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_GCM_authenticated_decryption_test_case_3),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 test_AES_GCM_authenticated_decryption_test_case_4),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_authenticated_decryption_test_case_5),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 test_AES_GCM_authenticated_decryption_test_case_6),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_AES_GCM_authenticated_decryption_test_case_7),
9002 /** AES GCM Authenticated Encryption 192 bits key */
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_GCM_auth_encryption_test_case_192_1),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_GCM_auth_encryption_test_case_192_2),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_GCM_auth_encryption_test_case_192_3),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_GCM_auth_encryption_test_case_192_4),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_GCM_auth_encryption_test_case_192_5),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_GCM_auth_encryption_test_case_192_6),
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_GCM_auth_encryption_test_case_192_7),
9018 /** AES GCM Authenticated Decryption 192 bits key */
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_decryption_test_case_192_1),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_auth_decryption_test_case_192_2),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_auth_decryption_test_case_192_3),
9025 TEST_CASE_ST(ut_setup, ut_teardown,
9026 test_AES_GCM_auth_decryption_test_case_192_4),
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_auth_decryption_test_case_192_5),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_AES_GCM_auth_decryption_test_case_192_6),
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_AES_GCM_auth_decryption_test_case_192_7),
9034 /** AES GCM Authenticated Encryption 256 bits key */
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_GCM_auth_encryption_test_case_256_1),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GCM_auth_encryption_test_case_256_2),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GCM_auth_encryption_test_case_256_3),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_AES_GCM_auth_encryption_test_case_256_4),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GCM_auth_encryption_test_case_256_5),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_GCM_auth_encryption_test_case_256_6),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GCM_auth_encryption_test_case_256_7),
9050 /** AES GMAC Authentication */
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_AES_GMAC_authentication_test_case_1),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_GMAC_authentication_verify_test_case_1),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_GMAC_authentication_test_case_2),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_AES_GMAC_authentication_verify_test_case_2),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_GMAC_authentication_test_case_3),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_GMAC_authentication_verify_test_case_3),
9064 /** SNOW 3G encrypt only (UEA2) */
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_snow3g_encryption_test_case_1),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_snow3g_encryption_test_case_2),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_snow3g_encryption_test_case_3),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_snow3g_encryption_test_case_4),
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_snow3g_encryption_test_case_5),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_snow3g_encryption_test_case_1_oop),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_snow3g_decryption_test_case_1_oop),
9081 /** SNOW 3G decrypt only (UEA2) */
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_snow3g_decryption_test_case_1),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_snow3g_decryption_test_case_2),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_snow3g_decryption_test_case_3),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_snow3g_decryption_test_case_4),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_snow3g_decryption_test_case_5),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_snow3g_hash_generate_test_case_1),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_snow3g_hash_generate_test_case_2),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_snow3g_hash_generate_test_case_3),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_snow3g_hash_verify_test_case_1),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_snow3g_hash_verify_test_case_2),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_snow3g_hash_verify_test_case_3),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_snow3g_cipher_auth_test_case_1),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_snow3g_auth_cipher_test_case_1),
9109 /** ZUC encrypt only (EEA3) */
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_zuc_encryption_test_case_1),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_zuc_encryption_test_case_2),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_zuc_encryption_test_case_3),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_zuc_encryption_test_case_4),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_zuc_encryption_test_case_5),
9121 /** ZUC authenticate (EIA3) */
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_zuc_hash_generate_test_case_6),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_zuc_hash_generate_test_case_7),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_zuc_hash_generate_test_case_8),
9129 /** ZUC alg-chain (EEA3/EIA3) */
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_zuc_cipher_auth_test_case_1),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_zuc_cipher_auth_test_case_2),
9135 /** HMAC_MD5 Authentication */
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_MD5_HMAC_generate_case_1),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_MD5_HMAC_verify_case_1),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_MD5_HMAC_generate_case_2),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_MD5_HMAC_verify_case_2),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_null_auth_only_operation),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_null_cipher_only_operation),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_null_cipher_auth_operation),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_null_auth_cipher_operation),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_kasumi_hash_generate_test_case_1),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_kasumi_hash_generate_test_case_2),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_kasumi_hash_generate_test_case_3),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_kasumi_hash_generate_test_case_4),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_kasumi_hash_generate_test_case_5),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_kasumi_hash_generate_test_case_6),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_kasumi_hash_verify_test_case_1),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_kasumi_hash_verify_test_case_2),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_kasumi_hash_verify_test_case_3),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_kasumi_hash_verify_test_case_4),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_kasumi_hash_verify_test_case_5),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_kasumi_encryption_test_case_1),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_kasumi_encryption_test_case_3),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_kasumi_auth_cipher_test_case_1),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_kasumi_cipher_auth_test_case_1),
9189 /** Negative tests */
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 authentication_verify_AES128_GMAC_fail_data_corrupt),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9203 TEST_CASES_END() /**< NULL terminate unit test array */
9207 static struct unit_test_suite cryptodev_virtio_testsuite = {
9208 .suite_name = "Crypto VIRTIO Unit Test Suite",
9209 .setup = testsuite_setup,
9210 .teardown = testsuite_teardown,
9211 .unit_test_cases = {
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_cipheronly_virtio_all),
9215 TEST_CASES_END() /**< NULL terminate unit test array */
9219 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9220 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9221 .setup = testsuite_setup,
9222 .teardown = testsuite_teardown,
9223 .unit_test_cases = {
9224 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_AES_GCM_authenticated_encryption_test_case_1),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_GCM_authenticated_encryption_test_case_2),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_AES_GCM_authenticated_encryption_test_case_3),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_GCM_authenticated_encryption_test_case_4),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_AES_GCM_authenticated_encryption_test_case_5),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_AES_GCM_authenticated_encryption_test_case_6),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_AES_GCM_authenticated_encryption_test_case_7),
9240 /** AES GCM Authenticated Decryption */
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_AES_GCM_authenticated_decryption_test_case_1),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_AES_GCM_authenticated_decryption_test_case_2),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_AES_GCM_authenticated_decryption_test_case_3),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_AES_GCM_authenticated_decryption_test_case_4),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_AES_GCM_authenticated_decryption_test_case_5),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_AES_GCM_authenticated_decryption_test_case_6),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_authenticated_decryption_test_case_7),
9256 /** AES GCM Authenticated Encryption 192 bits key */
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_AES_GCM_auth_encryption_test_case_192_1),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_auth_encryption_test_case_192_2),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_AES_GCM_auth_encryption_test_case_192_3),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_AES_GCM_auth_encryption_test_case_192_4),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_AES_GCM_auth_encryption_test_case_192_5),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_AES_GCM_auth_encryption_test_case_192_6),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_AES_GCM_auth_encryption_test_case_192_7),
9272 /** AES GCM Authenticated Decryption 192 bits key */
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_GCM_auth_decryption_test_case_192_1),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GCM_auth_decryption_test_case_192_2),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_AES_GCM_auth_decryption_test_case_192_3),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_GCM_auth_decryption_test_case_192_4),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_AES_GCM_auth_decryption_test_case_192_5),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_GCM_auth_decryption_test_case_192_6),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_auth_decryption_test_case_192_7),
9288 /** AES GCM Authenticated Encryption 256 bits key */
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_auth_encryption_test_case_256_1),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_auth_encryption_test_case_256_2),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_auth_encryption_test_case_256_3),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_auth_encryption_test_case_256_4),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_auth_encryption_test_case_256_5),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_auth_encryption_test_case_256_6),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_auth_encryption_test_case_256_7),
9304 /** AES GCM Authenticated Decryption 256 bits key */
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_auth_decryption_test_case_256_1),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_auth_decryption_test_case_256_2),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_auth_decryption_test_case_256_3),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_auth_decryption_test_case_256_4),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_auth_decryption_test_case_256_5),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_auth_decryption_test_case_256_6),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_decryption_test_case_256_7),
9320 /** AES GCM Authenticated Encryption big aad size */
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_auth_encryption_test_case_aad_1),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_encryption_test_case_aad_2),
9326 /** AES GCM Authenticated Decryption big aad size */
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_decryption_test_case_aad_1),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_auth_decryption_test_case_aad_2),
9332 /** Session-less tests */
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9338 /** AES GMAC Authentication */
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GMAC_authentication_test_case_1),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GMAC_authentication_verify_test_case_1),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GMAC_authentication_test_case_2),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GMAC_authentication_verify_test_case_2),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GMAC_authentication_test_case_3),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GMAC_authentication_verify_test_case_3),
9351 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9353 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9354 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9355 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9356 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_DES_cipheronly_mb_all),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_DES_docsis_mb_all),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_3DES_cipheronly_mb_all),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_CCM_authenticated_encryption_test_case_128_1),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_CCM_authenticated_decryption_test_case_128_1),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_CCM_authenticated_encryption_test_case_128_2),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_CCM_authenticated_decryption_test_case_128_2),
9371 TEST_CASE_ST(ut_setup, ut_teardown,
9372 test_AES_CCM_authenticated_encryption_test_case_128_3),
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 test_AES_CCM_authenticated_decryption_test_case_128_3),
9376 TEST_CASES_END() /**< NULL terminate unit test array */
9380 static struct unit_test_suite cryptodev_openssl_testsuite = {
9381 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9382 .setup = testsuite_setup,
9383 .teardown = testsuite_teardown,
9384 .unit_test_cases = {
9385 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_multi_session_random_usage),
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_AES_chain_openssl_all),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_cipheronly_openssl_all),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_3DES_chain_openssl_all),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_3DES_cipheronly_openssl_all),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_DES_cipheronly_openssl_all),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_DES_docsis_openssl_all),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_authonly_openssl_all),
9403 /** AES GCM Authenticated Encryption */
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_authenticated_encryption_test_case_1),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_encryption_test_case_2),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_authenticated_encryption_test_case_3),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_authenticated_encryption_test_case_4),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_encryption_test_case_5),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_encryption_test_case_6),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_encryption_test_case_7),
9419 /** AES GCM Authenticated Decryption */
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_decryption_test_case_1),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_test_case_2),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_authenticated_decryption_test_case_3),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_authenticated_decryption_test_case_4),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_authenticated_decryption_test_case_5),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_authenticated_decryption_test_case_6),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_authenticated_decryption_test_case_7),
9436 /** AES GCM Authenticated Encryption 192 bits key */
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_AES_GCM_auth_encryption_test_case_192_1),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_AES_GCM_auth_encryption_test_case_192_2),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_AES_GCM_auth_encryption_test_case_192_3),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_AES_GCM_auth_encryption_test_case_192_4),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_AES_GCM_auth_encryption_test_case_192_5),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_AES_GCM_auth_encryption_test_case_192_6),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_AES_GCM_auth_encryption_test_case_192_7),
9452 /** AES GCM Authenticated Decryption 192 bits key */
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_AES_GCM_auth_decryption_test_case_192_1),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_AES_GCM_auth_decryption_test_case_192_2),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_AES_GCM_auth_decryption_test_case_192_3),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_AES_GCM_auth_decryption_test_case_192_4),
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_AES_GCM_auth_decryption_test_case_192_5),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_AES_GCM_auth_decryption_test_case_192_6),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_AES_GCM_auth_decryption_test_case_192_7),
9468 /** AES GCM Authenticated Encryption 256 bits key */
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_AES_GCM_auth_encryption_test_case_256_1),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_AES_GCM_auth_encryption_test_case_256_2),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_AES_GCM_auth_encryption_test_case_256_3),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_AES_GCM_auth_encryption_test_case_256_4),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_AES_GCM_auth_encryption_test_case_256_5),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_AES_GCM_auth_encryption_test_case_256_6),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_AES_GCM_auth_encryption_test_case_256_7),
9484 /** AES GCM Authenticated Decryption 256 bits key */
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_AES_GCM_auth_decryption_test_case_256_1),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_GCM_auth_decryption_test_case_256_2),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_AES_GCM_auth_decryption_test_case_256_3),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_AES_GCM_auth_decryption_test_case_256_4),
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_AES_GCM_auth_decryption_test_case_256_5),
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_AES_GCM_auth_decryption_test_case_256_6),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_AES_GCM_auth_decryption_test_case_256_7),
9500 /** AES GMAC Authentication */
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_AES_GMAC_authentication_test_case_1),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_GMAC_authentication_verify_test_case_1),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_GMAC_authentication_test_case_2),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_GMAC_authentication_verify_test_case_2),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_AES_GMAC_authentication_test_case_3),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_AES_GMAC_authentication_verify_test_case_3),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_AES_GMAC_authentication_test_case_4),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_AES_GMAC_authentication_verify_test_case_4),
9518 /** AES CCM Authenticated Encryption 128 bits key */
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_CCM_authenticated_encryption_test_case_128_1),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_CCM_authenticated_encryption_test_case_128_2),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_CCM_authenticated_encryption_test_case_128_3),
9526 /** AES CCM Authenticated Decryption 128 bits key*/
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_CCM_authenticated_decryption_test_case_128_1),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_CCM_authenticated_decryption_test_case_128_2),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_CCM_authenticated_decryption_test_case_128_3),
9534 /** AES CCM Authenticated Encryption 192 bits key */
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_CCM_authenticated_encryption_test_case_192_1),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_CCM_authenticated_encryption_test_case_192_2),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_CCM_authenticated_encryption_test_case_192_3),
9542 /** AES CCM Authenticated Decryption 192 bits key*/
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_CCM_authenticated_decryption_test_case_192_1),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_CCM_authenticated_decryption_test_case_192_2),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_CCM_authenticated_decryption_test_case_192_3),
9550 /** AES CCM Authenticated Encryption 256 bits key */
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_AES_CCM_authenticated_encryption_test_case_256_1),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_AES_CCM_authenticated_encryption_test_case_256_2),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_AES_CCM_authenticated_encryption_test_case_256_3),
9558 /** AES CCM Authenticated Decryption 256 bits key*/
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_AES_CCM_authenticated_decryption_test_case_256_1),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_AES_CCM_authenticated_decryption_test_case_256_2),
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 test_AES_CCM_authenticated_decryption_test_case_256_3),
9566 /** Scatter-Gather */
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9570 /** Negative tests */
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9575 TEST_CASE_ST(ut_setup, ut_teardown,
9576 authentication_verify_AES128_GMAC_fail_data_corrupt),
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9584 TEST_CASES_END() /**< NULL terminate unit test array */
9588 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9589 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9590 .setup = testsuite_setup,
9591 .teardown = testsuite_teardown,
9592 .unit_test_cases = {
9593 /** AES GCM Authenticated Encryption */
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_authenticated_encryption_test_case_1),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_authenticated_encryption_test_case_2),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_encryption_test_case_3),
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_encryption_test_case_4),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_encryption_test_case_5),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_encryption_test_case_6),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_encryption_test_case_7),
9609 /** AES GCM Authenticated Decryption */
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_authenticated_decryption_test_case_1),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_authenticated_decryption_test_case_2),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_authenticated_decryption_test_case_3),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_authenticated_decryption_test_case_4),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_authenticated_decryption_test_case_5),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_authenticated_decryption_test_case_6),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_authenticated_decryption_test_case_7),
9625 /** AES GCM Authenticated Encryption 192 bits key */
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_auth_encryption_test_case_192_1),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_encryption_test_case_192_2),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_encryption_test_case_192_3),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_encryption_test_case_192_4),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_encryption_test_case_192_5),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_encryption_test_case_192_6),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_192_7),
9641 /** AES GCM Authenticated Decryption 192 bits key */
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_decryption_test_case_192_1),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_decryption_test_case_192_2),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_decryption_test_case_192_3),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_decryption_test_case_192_4),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_decryption_test_case_192_5),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_decryption_test_case_192_6),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_192_7),
9657 /** AES GCM Authenticated Encryption 256 bits key */
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_encryption_test_case_256_1),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_auth_encryption_test_case_256_2),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_auth_encryption_test_case_256_3),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_encryption_test_case_256_4),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_encryption_test_case_256_5),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_encryption_test_case_256_6),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_encryption_test_case_256_7),
9673 /** AES GCM Authenticated Decryption 256 bits key */
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_GCM_auth_decryption_test_case_256_1),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GCM_auth_decryption_test_case_256_2),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GCM_auth_decryption_test_case_256_3),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GCM_auth_decryption_test_case_256_4),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_decryption_test_case_256_5),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_auth_decryption_test_case_256_6),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GCM_auth_decryption_test_case_256_7),
9689 /** AES GCM Authenticated Encryption big aad size */
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_GCM_auth_encryption_test_case_aad_1),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_GCM_auth_encryption_test_case_aad_2),
9695 /** AES GCM Authenticated Decryption big aad size */
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_GCM_auth_decryption_test_case_aad_1),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_GCM_auth_decryption_test_case_aad_2),
9701 /** AES GMAC Authentication */
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GMAC_authentication_test_case_1),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GMAC_authentication_verify_test_case_1),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_GMAC_authentication_test_case_3),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_GMAC_authentication_verify_test_case_3),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 test_AES_GMAC_authentication_test_case_4),
9712 TEST_CASE_ST(ut_setup, ut_teardown,
9713 test_AES_GMAC_authentication_verify_test_case_4),
9715 /** Negative tests */
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 authentication_verify_AES128_GMAC_fail_data_corrupt),
9718 TEST_CASE_ST(ut_setup, ut_teardown,
9719 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9721 /** Out of place tests */
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9727 /** Session-less tests */
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9733 /** Scatter-Gather */
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9737 TEST_CASES_END() /**< NULL terminate unit test array */
9741 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9742 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9743 .setup = testsuite_setup,
9744 .teardown = testsuite_teardown,
9745 .unit_test_cases = {
9746 /** KASUMI encrypt only (UEA1) */
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_kasumi_encryption_test_case_1),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_kasumi_encryption_test_case_1_sgl),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_kasumi_encryption_test_case_2),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_kasumi_encryption_test_case_3),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_kasumi_encryption_test_case_4),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_kasumi_encryption_test_case_5),
9759 /** KASUMI decrypt only (UEA1) */
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_kasumi_decryption_test_case_1),
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_kasumi_decryption_test_case_2),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_kasumi_decryption_test_case_3),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_kasumi_decryption_test_case_4),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_kasumi_decryption_test_case_5),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_kasumi_encryption_test_case_1_oop),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_kasumi_encryption_test_case_1_oop_sgl),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_kasumi_decryption_test_case_1_oop),
9780 /** KASUMI hash only (UIA1) */
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_kasumi_hash_generate_test_case_1),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_kasumi_hash_generate_test_case_2),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_kasumi_hash_generate_test_case_3),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_kasumi_hash_generate_test_case_4),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_kasumi_hash_generate_test_case_5),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_kasumi_hash_generate_test_case_6),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_kasumi_hash_verify_test_case_1),
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_kasumi_hash_verify_test_case_2),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_kasumi_hash_verify_test_case_3),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_kasumi_hash_verify_test_case_4),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_kasumi_hash_verify_test_case_5),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_kasumi_auth_cipher_test_case_1),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_kasumi_cipher_auth_test_case_1),
9807 TEST_CASES_END() /**< NULL terminate unit test array */
9810 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9811 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9812 .setup = testsuite_setup,
9813 .teardown = testsuite_teardown,
9814 .unit_test_cases = {
9815 /** SNOW 3G encrypt only (UEA2) */
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 test_snow3g_encryption_test_case_1),
9818 TEST_CASE_ST(ut_setup, ut_teardown,
9819 test_snow3g_encryption_test_case_2),
9820 TEST_CASE_ST(ut_setup, ut_teardown,
9821 test_snow3g_encryption_test_case_3),
9822 TEST_CASE_ST(ut_setup, ut_teardown,
9823 test_snow3g_encryption_test_case_4),
9824 TEST_CASE_ST(ut_setup, ut_teardown,
9825 test_snow3g_encryption_test_case_5),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_snow3g_encryption_test_case_1_oop),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_snow3g_encryption_test_case_1_oop_sgl),
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_snow3g_decryption_test_case_1_oop),
9834 TEST_CASE_ST(ut_setup, ut_teardown,
9835 test_snow3g_encryption_test_case_1_offset_oop),
9837 /** SNOW 3G decrypt only (UEA2) */
9838 TEST_CASE_ST(ut_setup, ut_teardown,
9839 test_snow3g_decryption_test_case_1),
9840 TEST_CASE_ST(ut_setup, ut_teardown,
9841 test_snow3g_decryption_test_case_2),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_snow3g_decryption_test_case_3),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_snow3g_decryption_test_case_4),
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 test_snow3g_decryption_test_case_5),
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 test_snow3g_hash_generate_test_case_1),
9850 TEST_CASE_ST(ut_setup, ut_teardown,
9851 test_snow3g_hash_generate_test_case_2),
9852 TEST_CASE_ST(ut_setup, ut_teardown,
9853 test_snow3g_hash_generate_test_case_3),
9854 /* Tests with buffers which length is not byte-aligned */
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_snow3g_hash_generate_test_case_4),
9857 TEST_CASE_ST(ut_setup, ut_teardown,
9858 test_snow3g_hash_generate_test_case_5),
9859 TEST_CASE_ST(ut_setup, ut_teardown,
9860 test_snow3g_hash_generate_test_case_6),
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_snow3g_hash_verify_test_case_1),
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 test_snow3g_hash_verify_test_case_2),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_snow3g_hash_verify_test_case_3),
9867 /* Tests with buffers which length is not byte-aligned */
9868 TEST_CASE_ST(ut_setup, ut_teardown,
9869 test_snow3g_hash_verify_test_case_4),
9870 TEST_CASE_ST(ut_setup, ut_teardown,
9871 test_snow3g_hash_verify_test_case_5),
9872 TEST_CASE_ST(ut_setup, ut_teardown,
9873 test_snow3g_hash_verify_test_case_6),
9874 TEST_CASE_ST(ut_setup, ut_teardown,
9875 test_snow3g_cipher_auth_test_case_1),
9876 TEST_CASE_ST(ut_setup, ut_teardown,
9877 test_snow3g_auth_cipher_test_case_1),
9879 TEST_CASES_END() /**< NULL terminate unit test array */
9883 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9884 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9885 .setup = testsuite_setup,
9886 .teardown = testsuite_teardown,
9887 .unit_test_cases = {
9888 /** ZUC encrypt only (EEA3) */
9889 TEST_CASE_ST(ut_setup, ut_teardown,
9890 test_zuc_encryption_test_case_1),
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 test_zuc_encryption_test_case_2),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 test_zuc_encryption_test_case_3),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 test_zuc_encryption_test_case_4),
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 test_zuc_encryption_test_case_5),
9899 TEST_CASE_ST(ut_setup, ut_teardown,
9900 test_zuc_hash_generate_test_case_1),
9901 TEST_CASE_ST(ut_setup, ut_teardown,
9902 test_zuc_hash_generate_test_case_2),
9903 TEST_CASE_ST(ut_setup, ut_teardown,
9904 test_zuc_hash_generate_test_case_3),
9905 TEST_CASE_ST(ut_setup, ut_teardown,
9906 test_zuc_hash_generate_test_case_4),
9907 TEST_CASE_ST(ut_setup, ut_teardown,
9908 test_zuc_hash_generate_test_case_5),
9909 TEST_CASE_ST(ut_setup, ut_teardown,
9910 test_zuc_encryption_test_case_6_sgl),
9911 TEST_CASES_END() /**< NULL terminate unit test array */
9915 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
9916 .suite_name = "Crypto CAAM JR Unit Test Suite",
9917 .setup = testsuite_setup,
9918 .teardown = testsuite_teardown,
9919 .unit_test_cases = {
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_device_configure_invalid_dev_id),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_multi_session),
9925 TEST_CASE_ST(ut_setup, ut_teardown,
9926 test_AES_chain_caam_jr_all),
9927 TEST_CASE_ST(ut_setup, ut_teardown,
9928 test_3DES_chain_caam_jr_all),
9929 TEST_CASE_ST(ut_setup, ut_teardown,
9930 test_AES_cipheronly_caam_jr_all),
9931 TEST_CASE_ST(ut_setup, ut_teardown,
9932 test_3DES_cipheronly_caam_jr_all),
9933 TEST_CASE_ST(ut_setup, ut_teardown,
9934 test_authonly_caam_jr_all),
9936 TEST_CASES_END() /**< NULL terminate unit test array */
9940 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9941 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9942 .setup = testsuite_setup,
9943 .teardown = testsuite_teardown,
9944 .unit_test_cases = {
9945 TEST_CASE_ST(ut_setup, ut_teardown,
9946 test_device_configure_invalid_dev_id),
9947 TEST_CASE_ST(ut_setup, ut_teardown,
9948 test_multi_session),
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_AES_chain_dpaa_sec_all),
9952 TEST_CASE_ST(ut_setup, ut_teardown,
9953 test_3DES_chain_dpaa_sec_all),
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_AES_cipheronly_dpaa_sec_all),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_3DES_cipheronly_dpaa_sec_all),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_authonly_dpaa_sec_all),
9961 /** AES GCM Authenticated Encryption */
9962 TEST_CASE_ST(ut_setup, ut_teardown,
9963 test_AES_GCM_authenticated_encryption_test_case_1),
9964 TEST_CASE_ST(ut_setup, ut_teardown,
9965 test_AES_GCM_authenticated_encryption_test_case_2),
9966 TEST_CASE_ST(ut_setup, ut_teardown,
9967 test_AES_GCM_authenticated_encryption_test_case_3),
9968 TEST_CASE_ST(ut_setup, ut_teardown,
9969 test_AES_GCM_authenticated_encryption_test_case_4),
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_AES_GCM_authenticated_encryption_test_case_5),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_AES_GCM_authenticated_encryption_test_case_6),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_AES_GCM_authenticated_encryption_test_case_7),
9977 /** AES GCM Authenticated Decryption */
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_AES_GCM_authenticated_decryption_test_case_1),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_AES_GCM_authenticated_decryption_test_case_2),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_AES_GCM_authenticated_decryption_test_case_3),
9984 TEST_CASE_ST(ut_setup, ut_teardown,
9985 test_AES_GCM_authenticated_decryption_test_case_4),
9986 TEST_CASE_ST(ut_setup, ut_teardown,
9987 test_AES_GCM_authenticated_decryption_test_case_5),
9988 TEST_CASE_ST(ut_setup, ut_teardown,
9989 test_AES_GCM_authenticated_decryption_test_case_6),
9990 TEST_CASE_ST(ut_setup, ut_teardown,
9991 test_AES_GCM_authenticated_decryption_test_case_7),
9993 /** AES GCM Authenticated Encryption 256 bits key */
9994 TEST_CASE_ST(ut_setup, ut_teardown,
9995 test_AES_GCM_auth_encryption_test_case_256_1),
9996 TEST_CASE_ST(ut_setup, ut_teardown,
9997 test_AES_GCM_auth_encryption_test_case_256_2),
9998 TEST_CASE_ST(ut_setup, ut_teardown,
9999 test_AES_GCM_auth_encryption_test_case_256_3),
10000 TEST_CASE_ST(ut_setup, ut_teardown,
10001 test_AES_GCM_auth_encryption_test_case_256_4),
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_AES_GCM_auth_encryption_test_case_256_5),
10004 TEST_CASE_ST(ut_setup, ut_teardown,
10005 test_AES_GCM_auth_encryption_test_case_256_6),
10006 TEST_CASE_ST(ut_setup, ut_teardown,
10007 test_AES_GCM_auth_encryption_test_case_256_7),
10009 /** AES GCM Authenticated Decryption 256 bits key */
10010 TEST_CASE_ST(ut_setup, ut_teardown,
10011 test_AES_GCM_auth_decryption_test_case_256_1),
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_AES_GCM_auth_decryption_test_case_256_2),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_AES_GCM_auth_decryption_test_case_256_3),
10016 TEST_CASE_ST(ut_setup, ut_teardown,
10017 test_AES_GCM_auth_decryption_test_case_256_4),
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_AES_GCM_auth_decryption_test_case_256_5),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_AES_GCM_auth_decryption_test_case_256_6),
10022 TEST_CASE_ST(ut_setup, ut_teardown,
10023 test_AES_GCM_auth_decryption_test_case_256_7),
10025 /** Out of place tests */
10026 TEST_CASE_ST(ut_setup, ut_teardown,
10027 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10031 /** Scatter-Gather */
10032 TEST_CASE_ST(ut_setup, ut_teardown,
10033 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10034 TEST_CASE_ST(ut_setup, ut_teardown,
10035 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10036 TEST_CASE_ST(ut_setup, ut_teardown,
10037 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10038 TEST_CASE_ST(ut_setup, ut_teardown,
10039 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10041 TEST_CASES_END() /**< NULL terminate unit test array */
10045 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10046 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10047 .setup = testsuite_setup,
10048 .teardown = testsuite_teardown,
10049 .unit_test_cases = {
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_device_configure_invalid_dev_id),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_multi_session),
10055 TEST_CASE_ST(ut_setup, ut_teardown,
10056 test_AES_chain_dpaa2_sec_all),
10057 TEST_CASE_ST(ut_setup, ut_teardown,
10058 test_3DES_chain_dpaa2_sec_all),
10059 TEST_CASE_ST(ut_setup, ut_teardown,
10060 test_AES_cipheronly_dpaa2_sec_all),
10061 TEST_CASE_ST(ut_setup, ut_teardown,
10062 test_3DES_cipheronly_dpaa2_sec_all),
10063 TEST_CASE_ST(ut_setup, ut_teardown,
10064 test_authonly_dpaa2_sec_all),
10066 /** AES GCM Authenticated Encryption */
10067 TEST_CASE_ST(ut_setup, ut_teardown,
10068 test_AES_GCM_authenticated_encryption_test_case_1),
10069 TEST_CASE_ST(ut_setup, ut_teardown,
10070 test_AES_GCM_authenticated_encryption_test_case_2),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_AES_GCM_authenticated_encryption_test_case_3),
10073 TEST_CASE_ST(ut_setup, ut_teardown,
10074 test_AES_GCM_authenticated_encryption_test_case_4),
10075 TEST_CASE_ST(ut_setup, ut_teardown,
10076 test_AES_GCM_authenticated_encryption_test_case_5),
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_AES_GCM_authenticated_encryption_test_case_6),
10079 TEST_CASE_ST(ut_setup, ut_teardown,
10080 test_AES_GCM_authenticated_encryption_test_case_7),
10082 /** AES GCM Authenticated Decryption */
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_authenticated_decryption_test_case_1),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_authenticated_decryption_test_case_2),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_authenticated_decryption_test_case_3),
10089 TEST_CASE_ST(ut_setup, ut_teardown,
10090 test_AES_GCM_authenticated_decryption_test_case_4),
10091 TEST_CASE_ST(ut_setup, ut_teardown,
10092 test_AES_GCM_authenticated_decryption_test_case_5),
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_AES_GCM_authenticated_decryption_test_case_6),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_AES_GCM_authenticated_decryption_test_case_7),
10098 /** AES GCM Authenticated Encryption 192 bits key */
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_AES_GCM_auth_encryption_test_case_192_1),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_AES_GCM_auth_encryption_test_case_192_2),
10103 TEST_CASE_ST(ut_setup, ut_teardown,
10104 test_AES_GCM_auth_encryption_test_case_192_3),
10105 TEST_CASE_ST(ut_setup, ut_teardown,
10106 test_AES_GCM_auth_encryption_test_case_192_4),
10107 TEST_CASE_ST(ut_setup, ut_teardown,
10108 test_AES_GCM_auth_encryption_test_case_192_5),
10109 TEST_CASE_ST(ut_setup, ut_teardown,
10110 test_AES_GCM_auth_encryption_test_case_192_6),
10111 TEST_CASE_ST(ut_setup, ut_teardown,
10112 test_AES_GCM_auth_encryption_test_case_192_7),
10114 /** AES GCM Authenticated Decryption 192 bits key */
10115 TEST_CASE_ST(ut_setup, ut_teardown,
10116 test_AES_GCM_auth_decryption_test_case_192_1),
10117 TEST_CASE_ST(ut_setup, ut_teardown,
10118 test_AES_GCM_auth_decryption_test_case_192_2),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_AES_GCM_auth_decryption_test_case_192_3),
10121 TEST_CASE_ST(ut_setup, ut_teardown,
10122 test_AES_GCM_auth_decryption_test_case_192_4),
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_GCM_auth_decryption_test_case_192_5),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_AES_GCM_auth_decryption_test_case_192_6),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_AES_GCM_auth_decryption_test_case_192_7),
10130 /** AES GCM Authenticated Encryption 256 bits key */
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_AES_GCM_auth_encryption_test_case_256_1),
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_AES_GCM_auth_encryption_test_case_256_2),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_auth_encryption_test_case_256_3),
10137 TEST_CASE_ST(ut_setup, ut_teardown,
10138 test_AES_GCM_auth_encryption_test_case_256_4),
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_auth_encryption_test_case_256_5),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_auth_encryption_test_case_256_6),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_AES_GCM_auth_encryption_test_case_256_7),
10146 /** AES GCM Authenticated Decryption 256 bits key */
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_AES_GCM_auth_decryption_test_case_256_1),
10149 TEST_CASE_ST(ut_setup, ut_teardown,
10150 test_AES_GCM_auth_decryption_test_case_256_2),
10151 TEST_CASE_ST(ut_setup, ut_teardown,
10152 test_AES_GCM_auth_decryption_test_case_256_3),
10153 TEST_CASE_ST(ut_setup, ut_teardown,
10154 test_AES_GCM_auth_decryption_test_case_256_4),
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_auth_decryption_test_case_256_5),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_auth_decryption_test_case_256_6),
10159 TEST_CASE_ST(ut_setup, ut_teardown,
10160 test_AES_GCM_auth_decryption_test_case_256_7),
10162 /** Out of place tests */
10163 TEST_CASE_ST(ut_setup, ut_teardown,
10164 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10165 TEST_CASE_ST(ut_setup, ut_teardown,
10166 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10168 /** Scatter-Gather */
10169 TEST_CASE_ST(ut_setup, ut_teardown,
10170 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10171 TEST_CASE_ST(ut_setup, ut_teardown,
10172 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10173 TEST_CASE_ST(ut_setup, ut_teardown,
10174 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10175 TEST_CASE_ST(ut_setup, ut_teardown,
10176 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10178 TEST_CASES_END() /**< NULL terminate unit test array */
10182 static struct unit_test_suite cryptodev_null_testsuite = {
10183 .suite_name = "Crypto Device NULL Unit Test Suite",
10184 .setup = testsuite_setup,
10185 .teardown = testsuite_teardown,
10186 .unit_test_cases = {
10187 TEST_CASE_ST(ut_setup, ut_teardown,
10188 test_null_auth_only_operation),
10189 TEST_CASE_ST(ut_setup, ut_teardown,
10190 test_null_cipher_only_operation),
10191 TEST_CASE_ST(ut_setup, ut_teardown,
10192 test_null_cipher_auth_operation),
10193 TEST_CASE_ST(ut_setup, ut_teardown,
10194 test_null_auth_cipher_operation),
10195 TEST_CASE_ST(ut_setup, ut_teardown,
10196 test_null_invalid_operation),
10197 TEST_CASE_ST(ut_setup, ut_teardown,
10198 test_null_burst_operation),
10200 TEST_CASES_END() /**< NULL terminate unit test array */
10204 static struct unit_test_suite cryptodev_armv8_testsuite = {
10205 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10206 .setup = testsuite_setup,
10207 .teardown = testsuite_teardown,
10208 .unit_test_cases = {
10209 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10211 /** Negative tests */
10212 TEST_CASE_ST(ut_setup, ut_teardown,
10213 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10214 TEST_CASE_ST(ut_setup, ut_teardown,
10215 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10217 TEST_CASES_END() /**< NULL terminate unit test array */
10221 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10222 .suite_name = "Crypto Device Marvell Component Test Suite",
10223 .setup = testsuite_setup,
10224 .teardown = testsuite_teardown,
10225 .unit_test_cases = {
10226 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10227 TEST_CASE_ST(ut_setup, ut_teardown,
10228 test_multi_session_random_usage),
10229 TEST_CASE_ST(ut_setup, ut_teardown,
10230 test_AES_chain_mrvl_all),
10231 TEST_CASE_ST(ut_setup, ut_teardown,
10232 test_AES_cipheronly_mrvl_all),
10233 TEST_CASE_ST(ut_setup, ut_teardown,
10234 test_authonly_mrvl_all),
10235 TEST_CASE_ST(ut_setup, ut_teardown,
10236 test_3DES_chain_mrvl_all),
10237 TEST_CASE_ST(ut_setup, ut_teardown,
10238 test_3DES_cipheronly_mrvl_all),
10240 /** Negative tests */
10241 TEST_CASE_ST(ut_setup, ut_teardown,
10242 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10243 TEST_CASE_ST(ut_setup, ut_teardown,
10244 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10245 TEST_CASE_ST(ut_setup, ut_teardown,
10246 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10247 TEST_CASE_ST(ut_setup, ut_teardown,
10248 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10250 TEST_CASES_END() /**< NULL terminate unit test array */
10254 static struct unit_test_suite cryptodev_ccp_testsuite = {
10255 .suite_name = "Crypto Device CCP Unit Test Suite",
10256 .setup = testsuite_setup,
10257 .teardown = testsuite_teardown,
10258 .unit_test_cases = {
10259 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_multi_session_random_usage),
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 test_AES_chain_ccp_all),
10264 TEST_CASE_ST(ut_setup, ut_teardown,
10265 test_AES_cipheronly_ccp_all),
10266 TEST_CASE_ST(ut_setup, ut_teardown,
10267 test_3DES_chain_ccp_all),
10268 TEST_CASE_ST(ut_setup, ut_teardown,
10269 test_3DES_cipheronly_ccp_all),
10270 TEST_CASE_ST(ut_setup, ut_teardown,
10271 test_authonly_ccp_all),
10273 /** Negative tests */
10274 TEST_CASE_ST(ut_setup, ut_teardown,
10275 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10276 TEST_CASE_ST(ut_setup, ut_teardown,
10277 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10278 TEST_CASE_ST(ut_setup, ut_teardown,
10279 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10280 TEST_CASE_ST(ut_setup, ut_teardown,
10281 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10283 TEST_CASES_END() /**< NULL terminate unit test array */
10287 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10288 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10289 .setup = testsuite_setup,
10290 .teardown = testsuite_teardown,
10291 .unit_test_cases = {
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_AES_chain_octeontx_all),
10294 TEST_CASE_ST(ut_setup, ut_teardown,
10295 test_AES_cipheronly_octeontx_all),
10296 TEST_CASE_ST(ut_setup, ut_teardown,
10297 test_3DES_chain_octeontx_all),
10298 TEST_CASE_ST(ut_setup, ut_teardown,
10299 test_3DES_cipheronly_octeontx_all),
10300 TEST_CASE_ST(ut_setup, ut_teardown,
10301 test_authonly_octeontx_all),
10303 /** AES GCM Authenticated Encryption */
10304 TEST_CASE_ST(ut_setup, ut_teardown,
10305 test_AES_GCM_authenticated_encryption_test_case_1),
10306 TEST_CASE_ST(ut_setup, ut_teardown,
10307 test_AES_GCM_authenticated_encryption_test_case_2),
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_AES_GCM_authenticated_encryption_test_case_3),
10310 TEST_CASE_ST(ut_setup, ut_teardown,
10311 test_AES_GCM_authenticated_encryption_test_case_4),
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_AES_GCM_authenticated_encryption_test_case_5),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_AES_GCM_authenticated_encryption_test_case_6),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_AES_GCM_authenticated_encryption_test_case_7),
10319 /** AES GCM Authenticated Decryption */
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_AES_GCM_authenticated_decryption_test_case_1),
10322 TEST_CASE_ST(ut_setup, ut_teardown,
10323 test_AES_GCM_authenticated_decryption_test_case_2),
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 test_AES_GCM_authenticated_decryption_test_case_3),
10326 TEST_CASE_ST(ut_setup, ut_teardown,
10327 test_AES_GCM_authenticated_decryption_test_case_4),
10328 TEST_CASE_ST(ut_setup, ut_teardown,
10329 test_AES_GCM_authenticated_decryption_test_case_5),
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 test_AES_GCM_authenticated_decryption_test_case_6),
10332 TEST_CASE_ST(ut_setup, ut_teardown,
10333 test_AES_GCM_authenticated_decryption_test_case_7),
10334 /** AES GMAC Authentication */
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 test_AES_GMAC_authentication_test_case_1),
10337 TEST_CASE_ST(ut_setup, ut_teardown,
10338 test_AES_GMAC_authentication_verify_test_case_1),
10339 TEST_CASE_ST(ut_setup, ut_teardown,
10340 test_AES_GMAC_authentication_test_case_2),
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_AES_GMAC_authentication_verify_test_case_2),
10343 TEST_CASE_ST(ut_setup, ut_teardown,
10344 test_AES_GMAC_authentication_test_case_3),
10345 TEST_CASE_ST(ut_setup, ut_teardown,
10346 test_AES_GMAC_authentication_verify_test_case_3),
10348 /** SNOW 3G encrypt only (UEA2) */
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_snow3g_encryption_test_case_1),
10351 TEST_CASE_ST(ut_setup, ut_teardown,
10352 test_snow3g_encryption_test_case_2),
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_snow3g_encryption_test_case_3),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_snow3g_encryption_test_case_4),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_snow3g_encryption_test_case_5),
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 test_snow3g_encryption_test_case_1_oop),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_snow3g_decryption_test_case_1_oop),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_snow3g_encryption_test_case_1_oop_sgl),
10367 /** SNOW 3G decrypt only (UEA2) */
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 test_snow3g_decryption_test_case_1),
10370 TEST_CASE_ST(ut_setup, ut_teardown,
10371 test_snow3g_decryption_test_case_2),
10372 TEST_CASE_ST(ut_setup, ut_teardown,
10373 test_snow3g_decryption_test_case_3),
10374 TEST_CASE_ST(ut_setup, ut_teardown,
10375 test_snow3g_decryption_test_case_4),
10376 TEST_CASE_ST(ut_setup, ut_teardown,
10377 test_snow3g_decryption_test_case_5),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_snow3g_hash_generate_test_case_1),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_snow3g_hash_generate_test_case_2),
10383 TEST_CASE_ST(ut_setup, ut_teardown,
10384 test_snow3g_hash_generate_test_case_3),
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_snow3g_hash_verify_test_case_1),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_snow3g_hash_verify_test_case_2),
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 test_snow3g_hash_verify_test_case_3),
10392 /** ZUC encrypt only (EEA3) */
10393 TEST_CASE_ST(ut_setup, ut_teardown,
10394 test_zuc_encryption_test_case_1),
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 test_zuc_encryption_test_case_2),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 test_zuc_encryption_test_case_3),
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 test_zuc_encryption_test_case_4),
10401 TEST_CASE_ST(ut_setup, ut_teardown,
10402 test_zuc_encryption_test_case_5),
10403 TEST_CASE_ST(ut_setup, ut_teardown,
10404 test_zuc_hash_generate_test_case_1),
10405 TEST_CASE_ST(ut_setup, ut_teardown,
10406 test_zuc_hash_generate_test_case_2),
10407 TEST_CASE_ST(ut_setup, ut_teardown,
10408 test_zuc_hash_generate_test_case_3),
10409 TEST_CASE_ST(ut_setup, ut_teardown,
10410 test_zuc_hash_generate_test_case_4),
10411 TEST_CASE_ST(ut_setup, ut_teardown,
10412 test_zuc_hash_generate_test_case_5),
10413 TEST_CASE_ST(ut_setup, ut_teardown,
10414 test_zuc_encryption_test_case_6_sgl),
10416 /** KASUMI encrypt only (UEA1) */
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_kasumi_encryption_test_case_1),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_kasumi_encryption_test_case_2),
10421 TEST_CASE_ST(ut_setup, ut_teardown,
10422 test_kasumi_encryption_test_case_3),
10423 TEST_CASE_ST(ut_setup, ut_teardown,
10424 test_kasumi_encryption_test_case_4),
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_kasumi_encryption_test_case_5),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_kasumi_encryption_test_case_1_sgl),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_kasumi_encryption_test_case_1_oop_sgl),
10431 /** KASUMI decrypt only (UEA1) */
10432 TEST_CASE_ST(ut_setup, ut_teardown,
10433 test_kasumi_decryption_test_case_1),
10434 TEST_CASE_ST(ut_setup, ut_teardown,
10435 test_kasumi_decryption_test_case_2),
10436 TEST_CASE_ST(ut_setup, ut_teardown,
10437 test_kasumi_decryption_test_case_3),
10438 TEST_CASE_ST(ut_setup, ut_teardown,
10439 test_kasumi_decryption_test_case_4),
10440 TEST_CASE_ST(ut_setup, ut_teardown,
10441 test_kasumi_decryption_test_case_5),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_kasumi_encryption_test_case_1_oop),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_kasumi_decryption_test_case_1_oop),
10448 /** KASUMI hash only (UIA1) */
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_kasumi_hash_generate_test_case_1),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_kasumi_hash_generate_test_case_2),
10453 TEST_CASE_ST(ut_setup, ut_teardown,
10454 test_kasumi_hash_generate_test_case_3),
10455 TEST_CASE_ST(ut_setup, ut_teardown,
10456 test_kasumi_hash_generate_test_case_4),
10457 TEST_CASE_ST(ut_setup, ut_teardown,
10458 test_kasumi_hash_generate_test_case_5),
10459 TEST_CASE_ST(ut_setup, ut_teardown,
10460 test_kasumi_hash_generate_test_case_6),
10461 TEST_CASE_ST(ut_setup, ut_teardown,
10462 test_kasumi_hash_verify_test_case_1),
10463 TEST_CASE_ST(ut_setup, ut_teardown,
10464 test_kasumi_hash_verify_test_case_2),
10465 TEST_CASE_ST(ut_setup, ut_teardown,
10466 test_kasumi_hash_verify_test_case_3),
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_kasumi_hash_verify_test_case_4),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_kasumi_hash_verify_test_case_5),
10473 TEST_CASE_ST(ut_setup, ut_teardown,
10474 test_null_cipher_only_operation),
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 test_null_auth_only_operation),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 test_null_cipher_auth_operation),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 test_null_auth_cipher_operation),
10482 /** Negative tests */
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10487 TEST_CASE_ST(ut_setup, ut_teardown,
10488 authentication_verify_AES128_GMAC_fail_data_corrupt),
10489 TEST_CASE_ST(ut_setup, ut_teardown,
10490 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10491 TEST_CASE_ST(ut_setup, ut_teardown,
10492 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10493 TEST_CASE_ST(ut_setup, ut_teardown,
10494 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10495 TEST_CASES_END() /**< NULL terminate unit test array */
10500 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10502 gbl_driver_id = rte_cryptodev_driver_id_get(
10503 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10505 if (gbl_driver_id == -1) {
10506 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10507 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10508 "are enabled in config file to run this testsuite.\n");
10509 return TEST_SKIPPED;
10512 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10516 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10518 gbl_driver_id = rte_cryptodev_driver_id_get(
10519 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10521 if (gbl_driver_id == -1) {
10522 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10523 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10524 "in config file to run this testsuite.\n");
10525 return TEST_FAILED;
10528 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10532 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10534 gbl_driver_id = rte_cryptodev_driver_id_get(
10535 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10537 if (gbl_driver_id == -1) {
10538 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10539 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10540 "in config file to run this testsuite.\n");
10541 return TEST_SKIPPED;
10544 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10548 test_cryptodev_openssl(void)
10550 gbl_driver_id = rte_cryptodev_driver_id_get(
10551 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10553 if (gbl_driver_id == -1) {
10554 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10555 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10556 "in config file to run this testsuite.\n");
10557 return TEST_SKIPPED;
10560 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10564 test_cryptodev_aesni_gcm(void)
10566 gbl_driver_id = rte_cryptodev_driver_id_get(
10567 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10569 if (gbl_driver_id == -1) {
10570 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10571 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10572 "in config file to run this testsuite.\n");
10573 return TEST_SKIPPED;
10576 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10580 test_cryptodev_null(void)
10582 gbl_driver_id = rte_cryptodev_driver_id_get(
10583 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10585 if (gbl_driver_id == -1) {
10586 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10587 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10588 "in config file to run this testsuite.\n");
10589 return TEST_SKIPPED;
10592 return unit_test_suite_runner(&cryptodev_null_testsuite);
10596 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10598 gbl_driver_id = rte_cryptodev_driver_id_get(
10599 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10601 if (gbl_driver_id == -1) {
10602 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10603 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10604 "in config file to run this testsuite.\n");
10605 return TEST_SKIPPED;
10608 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10612 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10614 gbl_driver_id = rte_cryptodev_driver_id_get(
10615 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10617 if (gbl_driver_id == -1) {
10618 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10619 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10620 "in config file to run this testsuite.\n");
10621 return TEST_SKIPPED;
10624 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10628 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10630 gbl_driver_id = rte_cryptodev_driver_id_get(
10631 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10633 if (gbl_driver_id == -1) {
10634 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10635 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10636 "in config file to run this testsuite.\n");
10637 return TEST_SKIPPED;
10640 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10644 test_cryptodev_armv8(void)
10646 gbl_driver_id = rte_cryptodev_driver_id_get(
10647 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10649 if (gbl_driver_id == -1) {
10650 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10651 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10652 "in config file to run this testsuite.\n");
10653 return TEST_SKIPPED;
10656 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10660 test_cryptodev_mrvl(void)
10662 gbl_driver_id = rte_cryptodev_driver_id_get(
10663 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10665 if (gbl_driver_id == -1) {
10666 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10667 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10668 "in config file to run this testsuite.\n");
10669 return TEST_SKIPPED;
10672 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10675 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10678 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10680 gbl_driver_id = rte_cryptodev_driver_id_get(
10681 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10683 if (gbl_driver_id == -1) {
10684 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10685 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10686 "in config file to run this testsuite.\n");
10687 return TEST_SKIPPED;
10690 if (rte_cryptodev_driver_id_get(
10691 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10692 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10693 " enabled in config file to run this testsuite.\n");
10694 return TEST_SKIPPED;
10696 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10699 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10704 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10706 gbl_driver_id = rte_cryptodev_driver_id_get(
10707 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10709 if (gbl_driver_id == -1) {
10710 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10711 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10712 "in config file to run this testsuite.\n");
10713 return TEST_SKIPPED;
10716 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10720 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10722 gbl_driver_id = rte_cryptodev_driver_id_get(
10723 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10725 if (gbl_driver_id == -1) {
10726 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10727 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10728 "in config file to run this testsuite.\n");
10729 return TEST_SKIPPED;
10732 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10736 test_cryptodev_ccp(void)
10738 gbl_driver_id = rte_cryptodev_driver_id_get(
10739 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10741 if (gbl_driver_id == -1) {
10742 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10743 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10744 "in config file to run this testsuite.\n");
10745 return TEST_FAILED;
10748 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10752 test_cryptodev_octeontx(void)
10754 gbl_driver_id = rte_cryptodev_driver_id_get(
10755 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10756 if (gbl_driver_id == -1) {
10757 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10758 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10759 "enabled in config file to run this "
10761 return TEST_FAILED;
10763 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10767 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10769 gbl_driver_id = rte_cryptodev_driver_id_get(
10770 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10772 if (gbl_driver_id == -1) {
10773 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10774 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10775 "in config file to run this testsuite.\n");
10776 return TEST_FAILED;
10779 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10782 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10783 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10784 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10785 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10786 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10787 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10788 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10789 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10790 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10791 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10792 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10793 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10794 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10795 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10796 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10797 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);