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;
465 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
466 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
467 dev_id, qp_id, &ts_params->qp_conf,
468 rte_cryptodev_socket_id(dev_id),
469 ts_params->session_mpool),
470 "Failed to setup queue pair %u on cryptodev %u",
478 testsuite_teardown(void)
480 struct crypto_testsuite_params *ts_params = &testsuite_params;
482 if (ts_params->mbuf_pool != NULL) {
483 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
484 rte_mempool_avail_count(ts_params->mbuf_pool));
487 if (ts_params->op_mpool != NULL) {
488 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
489 rte_mempool_avail_count(ts_params->op_mpool));
492 /* Free session mempools */
493 if (ts_params->session_mpool != NULL) {
494 rte_mempool_free(ts_params->session_mpool);
495 ts_params->session_mpool = NULL;
502 struct crypto_testsuite_params *ts_params = &testsuite_params;
503 struct crypto_unittest_params *ut_params = &unittest_params;
507 /* Clear unit test parameters before running test */
508 memset(ut_params, 0, sizeof(*ut_params));
510 /* Reconfigure device to default parameters */
511 ts_params->conf.socket_id = SOCKET_ID_ANY;
513 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
515 "Failed to configure cryptodev %u",
516 ts_params->valid_devs[0]);
518 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
519 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
520 ts_params->valid_devs[0], qp_id,
522 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
523 ts_params->session_mpool),
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*/
713 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
714 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
715 ts_params->valid_devs[0], qp_id, &qp_conf,
716 rte_cryptodev_socket_id(
717 ts_params->valid_devs[0]),
718 ts_params->session_mpool),
720 "rte_cryptodev_queue_pair_setup: num_inflights "
721 "%u on qp %u on cryptodev %u",
722 qp_conf.nb_descriptors, qp_id,
723 ts_params->valid_devs[0]);
726 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
728 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
729 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
730 ts_params->valid_devs[0], qp_id, &qp_conf,
731 rte_cryptodev_socket_id(
732 ts_params->valid_devs[0]),
733 ts_params->session_mpool),
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]),
748 ts_params->session_mpool),
750 "rte_cryptodev_queue_pair_setup: num_inflights"
751 " %u on qp %u on cryptodev %u",
752 qp_conf.nb_descriptors, qp_id,
753 ts_params->valid_devs[0]);
756 /* invalid number of descriptors - max supported + 2 */
757 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
759 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
760 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
761 ts_params->valid_devs[0], qp_id, &qp_conf,
762 rte_cryptodev_socket_id(
763 ts_params->valid_devs[0]),
764 ts_params->session_mpool),
765 "Unexpectedly passed test for "
766 "rte_cryptodev_queue_pair_setup:"
767 "num_inflights %u on qp %u on cryptodev %u",
768 qp_conf.nb_descriptors, qp_id,
769 ts_params->valid_devs[0]);
772 /* invalid number of descriptors - max value of parameter */
773 qp_conf.nb_descriptors = UINT32_MAX-1;
775 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
776 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
777 ts_params->valid_devs[0], qp_id, &qp_conf,
778 rte_cryptodev_socket_id(
779 ts_params->valid_devs[0]),
780 ts_params->session_mpool),
781 "Unexpectedly passed test for "
782 "rte_cryptodev_queue_pair_setup:"
783 "num_inflights %u on qp %u on cryptodev %u",
784 qp_conf.nb_descriptors, qp_id,
785 ts_params->valid_devs[0]);
788 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
790 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
791 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
792 ts_params->valid_devs[0], qp_id, &qp_conf,
793 rte_cryptodev_socket_id(
794 ts_params->valid_devs[0]),
795 ts_params->session_mpool),
797 " rte_cryptodev_queue_pair_setup:"
798 "num_inflights %u on qp %u on cryptodev %u",
799 qp_conf.nb_descriptors, qp_id,
800 ts_params->valid_devs[0]);
803 /* invalid number of descriptors - max supported + 1 */
804 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
806 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
807 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
808 ts_params->valid_devs[0], qp_id, &qp_conf,
809 rte_cryptodev_socket_id(
810 ts_params->valid_devs[0]),
811 ts_params->session_mpool),
812 "Unexpectedly passed test for "
813 "rte_cryptodev_queue_pair_setup:"
814 "num_inflights %u on qp %u on cryptodev %u",
815 qp_conf.nb_descriptors, qp_id,
816 ts_params->valid_devs[0]);
819 /* test invalid queue pair id */
820 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
822 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
824 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
825 ts_params->valid_devs[0],
827 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
828 ts_params->session_mpool),
829 "Failed test for rte_cryptodev_queue_pair_setup:"
830 "invalid qp %u on cryptodev %u",
831 qp_id, ts_params->valid_devs[0]);
833 qp_id = 0xffff; /*invalid*/
835 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
836 ts_params->valid_devs[0],
838 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
839 ts_params->session_mpool),
840 "Failed test for rte_cryptodev_queue_pair_setup:"
841 "invalid qp %u on cryptodev %u",
842 qp_id, ts_params->valid_devs[0]);
847 /* ***** Plaintext data for tests ***** */
849 const char catch_22_quote_1[] =
850 "There was only one catch and that was Catch-22, which "
851 "specified that a concern for one's safety in the face of "
852 "dangers that were real and immediate was the process of a "
853 "rational mind. Orr was crazy and could be grounded. All he "
854 "had to do was ask; and as soon as he did, he would no longer "
855 "be crazy and would have to fly more missions. Orr would be "
856 "crazy to fly more missions and sane if he didn't, but if he "
857 "was sane he had to fly them. If he flew them he was crazy "
858 "and didn't have to; but if he didn't want to he was sane and "
859 "had to. Yossarian was moved very deeply by the absolute "
860 "simplicity of this clause of Catch-22 and let out a "
861 "respectful whistle. \"That's some catch, that Catch-22\", he "
862 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
864 const char catch_22_quote[] =
865 "What a lousy earth! He wondered how many people were "
866 "destitute that same night even in his own prosperous country, "
867 "how many homes were shanties, how many husbands were drunk "
868 "and wives socked, and how many children were bullied, abused, "
869 "or abandoned. How many families hungered for food they could "
870 "not afford to buy? How many hearts were broken? How many "
871 "suicides would take place that same night, how many people "
872 "would go insane? How many cockroaches and landlords would "
873 "triumph? How many winners were losers, successes failures, "
874 "and rich men poor men? How many wise guys were stupid? How "
875 "many happy endings were unhappy endings? How many honest men "
876 "were liars, brave men cowards, loyal men traitors, how many "
877 "sainted men were corrupt, how many people in positions of "
878 "trust had sold their souls to bodyguards, how many had never "
879 "had souls? How many straight-and-narrow paths were crooked "
880 "paths? How many best families were worst families and how "
881 "many good people were bad people? When you added them all up "
882 "and then subtracted, you might be left with only the children, "
883 "and perhaps with Albert Einstein and an old violinist or "
884 "sculptor somewhere.";
886 #define QUOTE_480_BYTES (480)
887 #define QUOTE_512_BYTES (512)
888 #define QUOTE_768_BYTES (768)
889 #define QUOTE_1024_BYTES (1024)
893 /* ***** SHA1 Hash Tests ***** */
895 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
897 static uint8_t hmac_sha1_key[] = {
898 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
899 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
900 0xDE, 0xF4, 0xDE, 0xAD };
902 /* ***** SHA224 Hash Tests ***** */
904 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
907 /* ***** AES-CBC Cipher Tests ***** */
909 #define CIPHER_KEY_LENGTH_AES_CBC (16)
910 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
912 static uint8_t aes_cbc_key[] = {
913 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
914 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
916 static uint8_t aes_cbc_iv[] = {
917 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
918 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
921 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
923 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
924 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
925 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
926 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
927 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
928 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
929 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
930 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
931 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
932 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
933 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
934 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
935 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
936 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
937 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
938 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
939 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
940 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
941 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
942 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
943 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
944 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
945 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
946 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
947 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
948 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
949 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
950 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
951 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
952 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
953 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
954 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
955 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
956 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
957 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
958 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
959 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
960 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
961 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
962 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
963 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
964 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
965 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
966 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
967 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
968 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
969 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
970 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
971 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
972 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
973 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
974 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
975 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
976 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
977 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
978 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
979 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
980 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
981 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
982 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
983 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
984 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
985 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
986 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
987 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
990 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
991 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
992 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
993 0x18, 0x8c, 0x1d, 0x32
997 /* Multisession Vector context Test */
999 static uint8_t ms_aes_cbc_key0[] = {
1000 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1001 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1004 static uint8_t ms_aes_cbc_iv0[] = {
1005 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1006 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1009 static const uint8_t ms_aes_cbc_cipher0[] = {
1010 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1011 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1012 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1013 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1014 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1015 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1016 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1017 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1018 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1019 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1020 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1021 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1022 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1023 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1024 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1025 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1026 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1027 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1028 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1029 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1030 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1031 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1032 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1033 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1034 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1035 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1036 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1037 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1038 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1039 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1040 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1041 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1042 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1043 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1044 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1045 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1046 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1047 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1048 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1049 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1050 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1051 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1052 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1053 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1054 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1055 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1056 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1057 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1058 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1059 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1060 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1061 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1062 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1063 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1064 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1065 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1066 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1067 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1068 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1069 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1070 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1071 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1072 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1073 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1077 static uint8_t ms_hmac_key0[] = {
1078 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1079 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1080 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1081 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1082 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1083 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1084 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1085 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1088 static const uint8_t ms_hmac_digest0[] = {
1089 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1090 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1091 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1092 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1093 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1094 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1095 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1096 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1100 /* Begin session 1 */
1102 static uint8_t ms_aes_cbc_key1[] = {
1103 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1104 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1107 static uint8_t ms_aes_cbc_iv1[] = {
1108 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1109 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1112 static const uint8_t ms_aes_cbc_cipher1[] = {
1113 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1114 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1115 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1116 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1117 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1118 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1119 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1120 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1121 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1122 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1123 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1124 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1125 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1126 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1127 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1128 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1129 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1130 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1131 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1132 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1133 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1134 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1135 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1136 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1137 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1138 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1139 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1140 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1141 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1142 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1143 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1144 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1145 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1146 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1147 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1148 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1149 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1150 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1151 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1152 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1153 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1154 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1155 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1156 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1157 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1158 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1159 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1160 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1161 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1162 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1163 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1164 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1165 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1166 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1167 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1168 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1169 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1170 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1171 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1172 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1173 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1174 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1175 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1176 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1180 static uint8_t ms_hmac_key1[] = {
1181 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1182 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1183 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1184 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1185 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1186 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1187 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1188 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1191 static const uint8_t ms_hmac_digest1[] = {
1192 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1193 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1194 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1195 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1196 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1197 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1198 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1199 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1202 /* Begin Session 2 */
1203 static uint8_t ms_aes_cbc_key2[] = {
1204 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1205 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1208 static uint8_t ms_aes_cbc_iv2[] = {
1209 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1210 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1213 static const uint8_t ms_aes_cbc_cipher2[] = {
1214 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1215 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1216 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1217 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1218 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1219 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1220 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1221 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1222 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1223 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1224 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1225 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1226 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1227 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1228 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1229 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1230 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1231 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1232 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1233 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1234 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1235 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1236 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1237 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1238 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1239 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1240 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1241 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1242 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1243 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1244 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1245 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1246 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1247 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1248 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1249 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1250 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1251 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1252 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1253 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1254 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1255 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1256 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1257 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1258 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1259 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1260 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1261 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1262 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1263 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1264 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1265 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1266 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1267 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1268 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1269 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1270 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1271 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1272 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1273 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1274 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1275 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1276 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1277 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1280 static uint8_t ms_hmac_key2[] = {
1281 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1282 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1283 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1284 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1285 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1286 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1287 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1288 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1291 static const uint8_t ms_hmac_digest2[] = {
1292 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1293 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1294 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1295 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1296 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1297 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1298 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1299 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1306 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1308 struct crypto_testsuite_params *ts_params = &testsuite_params;
1309 struct crypto_unittest_params *ut_params = &unittest_params;
1311 /* Generate test mbuf data and space for digest */
1312 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1313 catch_22_quote, QUOTE_512_BYTES, 0);
1315 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1316 DIGEST_BYTE_LENGTH_SHA1);
1317 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1319 /* Setup Cipher Parameters */
1320 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1321 ut_params->cipher_xform.next = &ut_params->auth_xform;
1323 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1324 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1325 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1326 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1327 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1328 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1330 /* Setup HMAC Parameters */
1331 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1333 ut_params->auth_xform.next = NULL;
1335 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1336 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1337 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1338 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1339 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1341 ut_params->sess = rte_cryptodev_sym_session_create(
1342 ts_params->session_mpool);
1344 /* Create crypto session*/
1345 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1346 ut_params->sess, &ut_params->cipher_xform,
1347 ts_params->session_mpool);
1348 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1350 /* Generate crypto op data structure */
1351 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1352 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1353 TEST_ASSERT_NOT_NULL(ut_params->op,
1354 "Failed to allocate symmetric crypto operation struct");
1356 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1360 /* set crypto operation source mbuf */
1361 sym_op->m_src = ut_params->ibuf;
1363 /* Set crypto operation authentication parameters */
1364 sym_op->auth.digest.data = ut_params->digest;
1365 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1366 ut_params->ibuf, QUOTE_512_BYTES);
1368 sym_op->auth.data.offset = 0;
1369 sym_op->auth.data.length = QUOTE_512_BYTES;
1371 /* Copy IV at the end of the crypto operation */
1372 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1373 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1375 /* Set crypto operation cipher parameters */
1376 sym_op->cipher.data.offset = 0;
1377 sym_op->cipher.data.length = QUOTE_512_BYTES;
1379 /* Process crypto operation */
1380 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1381 ut_params->op), "failed to process sym crypto op");
1383 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1384 "crypto op processing failed");
1387 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1390 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1391 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1393 "ciphertext data not as expected");
1395 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1397 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1398 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1399 gbl_driver_id == rte_cryptodev_driver_id_get(
1400 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1401 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1402 DIGEST_BYTE_LENGTH_SHA1,
1403 "Generated digest data not as expected");
1405 return TEST_SUCCESS;
1408 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1410 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1412 static uint8_t hmac_sha512_key[] = {
1413 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1414 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1415 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1416 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1417 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1418 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1419 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1420 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1422 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1423 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1424 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1425 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1426 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1427 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1428 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1429 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1430 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1435 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1436 struct crypto_unittest_params *ut_params,
1437 uint8_t *cipher_key,
1441 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1442 struct crypto_unittest_params *ut_params,
1443 struct crypto_testsuite_params *ts_params,
1444 const uint8_t *cipher,
1445 const uint8_t *digest,
1450 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1451 struct crypto_unittest_params *ut_params,
1452 uint8_t *cipher_key,
1456 /* Setup Cipher Parameters */
1457 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1458 ut_params->cipher_xform.next = NULL;
1460 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1461 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1462 ut_params->cipher_xform.cipher.key.data = cipher_key;
1463 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1464 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1465 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1467 /* Setup HMAC Parameters */
1468 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1469 ut_params->auth_xform.next = &ut_params->cipher_xform;
1471 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1472 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1473 ut_params->auth_xform.auth.key.data = hmac_key;
1474 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1475 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1477 return TEST_SUCCESS;
1482 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1483 struct crypto_unittest_params *ut_params,
1484 struct crypto_testsuite_params *ts_params,
1485 const uint8_t *cipher,
1486 const uint8_t *digest,
1489 /* Generate test mbuf data and digest */
1490 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1493 QUOTE_512_BYTES, 0);
1495 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1496 DIGEST_BYTE_LENGTH_SHA512);
1497 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1499 rte_memcpy(ut_params->digest,
1501 DIGEST_BYTE_LENGTH_SHA512);
1503 /* Generate Crypto op data structure */
1504 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1505 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1506 TEST_ASSERT_NOT_NULL(ut_params->op,
1507 "Failed to allocate symmetric crypto operation struct");
1509 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1511 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1513 /* set crypto operation source mbuf */
1514 sym_op->m_src = ut_params->ibuf;
1516 sym_op->auth.digest.data = ut_params->digest;
1517 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1518 ut_params->ibuf, QUOTE_512_BYTES);
1520 sym_op->auth.data.offset = 0;
1521 sym_op->auth.data.length = QUOTE_512_BYTES;
1523 /* Copy IV at the end of the crypto operation */
1524 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1525 iv, CIPHER_IV_LENGTH_AES_CBC);
1527 sym_op->cipher.data.offset = 0;
1528 sym_op->cipher.data.length = QUOTE_512_BYTES;
1530 /* Process crypto operation */
1531 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1532 ut_params->op), "failed to process sym crypto op");
1534 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1535 "crypto op processing failed");
1537 ut_params->obuf = ut_params->op->sym->m_src;
1540 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1541 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1544 "Plaintext data not as expected");
1547 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1548 "Digest verification failed");
1550 return TEST_SUCCESS;
1554 test_AES_cipheronly_mb_all(void)
1556 struct crypto_testsuite_params *ts_params = &testsuite_params;
1559 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1560 ts_params->op_mpool,
1561 ts_params->session_mpool,
1562 ts_params->valid_devs[0],
1563 rte_cryptodev_driver_id_get(
1564 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1565 BLKCIPHER_AES_CIPHERONLY_TYPE);
1567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1569 return TEST_SUCCESS;
1573 test_AES_docsis_mb_all(void)
1575 struct crypto_testsuite_params *ts_params = &testsuite_params;
1578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1579 ts_params->op_mpool,
1580 ts_params->session_mpool,
1581 ts_params->valid_devs[0],
1582 rte_cryptodev_driver_id_get(
1583 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1584 BLKCIPHER_AES_DOCSIS_TYPE);
1586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1588 return TEST_SUCCESS;
1592 test_AES_docsis_qat_all(void)
1594 struct crypto_testsuite_params *ts_params = &testsuite_params;
1597 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1598 ts_params->op_mpool,
1599 ts_params->session_mpool,
1600 ts_params->valid_devs[0],
1601 rte_cryptodev_driver_id_get(
1602 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1603 BLKCIPHER_AES_DOCSIS_TYPE);
1605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1607 return TEST_SUCCESS;
1611 test_DES_docsis_qat_all(void)
1613 struct crypto_testsuite_params *ts_params = &testsuite_params;
1616 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1617 ts_params->op_mpool,
1618 ts_params->session_mpool,
1619 ts_params->valid_devs[0],
1620 rte_cryptodev_driver_id_get(
1621 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1622 BLKCIPHER_DES_DOCSIS_TYPE);
1624 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1626 return TEST_SUCCESS;
1630 test_authonly_mb_all(void)
1632 struct crypto_testsuite_params *ts_params = &testsuite_params;
1635 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1636 ts_params->op_mpool,
1637 ts_params->session_mpool,
1638 ts_params->valid_devs[0],
1639 rte_cryptodev_driver_id_get(
1640 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1641 BLKCIPHER_AUTHONLY_TYPE);
1643 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1645 return TEST_SUCCESS;
1649 test_authonly_qat_all(void)
1651 struct crypto_testsuite_params *ts_params = &testsuite_params;
1654 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1655 ts_params->op_mpool,
1656 ts_params->session_mpool,
1657 ts_params->valid_devs[0],
1658 rte_cryptodev_driver_id_get(
1659 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1660 BLKCIPHER_AUTHONLY_TYPE);
1662 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1664 return TEST_SUCCESS;
1667 test_AES_chain_mb_all(void)
1669 struct crypto_testsuite_params *ts_params = &testsuite_params;
1672 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1673 ts_params->op_mpool,
1674 ts_params->session_mpool,
1675 ts_params->valid_devs[0],
1676 rte_cryptodev_driver_id_get(
1677 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1678 BLKCIPHER_AES_CHAIN_TYPE);
1680 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1682 return TEST_SUCCESS;
1685 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1688 test_AES_cipheronly_scheduler_all(void)
1690 struct crypto_testsuite_params *ts_params = &testsuite_params;
1693 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1694 ts_params->op_mpool,
1695 ts_params->session_mpool,
1696 ts_params->valid_devs[0],
1697 rte_cryptodev_driver_id_get(
1698 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1699 BLKCIPHER_AES_CIPHERONLY_TYPE);
1701 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1703 return TEST_SUCCESS;
1707 test_AES_chain_scheduler_all(void)
1709 struct crypto_testsuite_params *ts_params = &testsuite_params;
1712 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1713 ts_params->op_mpool,
1714 ts_params->session_mpool,
1715 ts_params->valid_devs[0],
1716 rte_cryptodev_driver_id_get(
1717 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1718 BLKCIPHER_AES_CHAIN_TYPE);
1720 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1722 return TEST_SUCCESS;
1726 test_authonly_scheduler_all(void)
1728 struct crypto_testsuite_params *ts_params = &testsuite_params;
1731 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1732 ts_params->op_mpool,
1733 ts_params->session_mpool,
1734 ts_params->valid_devs[0],
1735 rte_cryptodev_driver_id_get(
1736 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1737 BLKCIPHER_AUTHONLY_TYPE);
1739 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1741 return TEST_SUCCESS;
1744 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1747 test_AES_chain_openssl_all(void)
1749 struct crypto_testsuite_params *ts_params = &testsuite_params;
1752 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1753 ts_params->op_mpool,
1754 ts_params->session_mpool,
1755 ts_params->valid_devs[0],
1756 rte_cryptodev_driver_id_get(
1757 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1758 BLKCIPHER_AES_CHAIN_TYPE);
1760 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1762 return TEST_SUCCESS;
1766 test_AES_cipheronly_openssl_all(void)
1768 struct crypto_testsuite_params *ts_params = &testsuite_params;
1771 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1772 ts_params->op_mpool,
1773 ts_params->session_mpool,
1774 ts_params->valid_devs[0],
1775 rte_cryptodev_driver_id_get(
1776 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1777 BLKCIPHER_AES_CIPHERONLY_TYPE);
1779 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1781 return TEST_SUCCESS;
1785 test_AES_chain_ccp_all(void)
1787 struct crypto_testsuite_params *ts_params = &testsuite_params;
1790 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1791 ts_params->op_mpool,
1792 ts_params->session_mpool,
1793 ts_params->valid_devs[0],
1794 rte_cryptodev_driver_id_get(
1795 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1796 BLKCIPHER_AES_CHAIN_TYPE);
1798 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1800 return TEST_SUCCESS;
1804 test_AES_cipheronly_ccp_all(void)
1806 struct crypto_testsuite_params *ts_params = &testsuite_params;
1809 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1810 ts_params->op_mpool,
1811 ts_params->session_mpool,
1812 ts_params->valid_devs[0],
1813 rte_cryptodev_driver_id_get(
1814 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1815 BLKCIPHER_AES_CIPHERONLY_TYPE);
1817 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1819 return TEST_SUCCESS;
1823 test_AES_chain_qat_all(void)
1825 struct crypto_testsuite_params *ts_params = &testsuite_params;
1828 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1829 ts_params->op_mpool,
1830 ts_params->session_mpool,
1831 ts_params->valid_devs[0],
1832 rte_cryptodev_driver_id_get(
1833 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1834 BLKCIPHER_AES_CHAIN_TYPE);
1836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1838 return TEST_SUCCESS;
1842 test_AES_cipheronly_qat_all(void)
1844 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1848 ts_params->op_mpool,
1849 ts_params->session_mpool,
1850 ts_params->valid_devs[0],
1851 rte_cryptodev_driver_id_get(
1852 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1853 BLKCIPHER_AES_CIPHERONLY_TYPE);
1855 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1857 return TEST_SUCCESS;
1861 test_AES_cipheronly_virtio_all(void)
1863 struct crypto_testsuite_params *ts_params = &testsuite_params;
1866 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1867 ts_params->op_mpool,
1868 ts_params->session_mpool,
1869 ts_params->valid_devs[0],
1870 rte_cryptodev_driver_id_get(
1871 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1872 BLKCIPHER_AES_CIPHERONLY_TYPE);
1874 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1876 return TEST_SUCCESS;
1880 test_AES_chain_caam_jr_all(void)
1882 struct crypto_testsuite_params *ts_params = &testsuite_params;
1885 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1886 ts_params->op_mpool,
1887 ts_params->session_mpool,
1888 ts_params->valid_devs[0],
1889 rte_cryptodev_driver_id_get(
1890 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1891 BLKCIPHER_AES_CHAIN_TYPE);
1893 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1895 return TEST_SUCCESS;
1899 test_AES_cipheronly_caam_jr_all(void)
1901 struct crypto_testsuite_params *ts_params = &testsuite_params;
1904 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1905 ts_params->op_mpool,
1906 ts_params->session_mpool,
1907 ts_params->valid_devs[0],
1908 rte_cryptodev_driver_id_get(
1909 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1910 BLKCIPHER_AES_CIPHERONLY_TYPE);
1912 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1914 return TEST_SUCCESS;
1918 test_authonly_caam_jr_all(void)
1920 struct crypto_testsuite_params *ts_params = &testsuite_params;
1923 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1924 ts_params->op_mpool,
1925 ts_params->session_mpool,
1926 ts_params->valid_devs[0],
1927 rte_cryptodev_driver_id_get(
1928 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1929 BLKCIPHER_AUTHONLY_TYPE);
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1938 test_AES_chain_dpaa_sec_all(void)
1940 struct crypto_testsuite_params *ts_params = &testsuite_params;
1943 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1944 ts_params->op_mpool,
1945 ts_params->session_mpool,
1946 ts_params->valid_devs[0],
1947 rte_cryptodev_driver_id_get(
1948 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1949 BLKCIPHER_AES_CHAIN_TYPE);
1951 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1953 return TEST_SUCCESS;
1957 test_AES_cipheronly_dpaa_sec_all(void)
1959 struct crypto_testsuite_params *ts_params = &testsuite_params;
1962 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1963 ts_params->op_mpool,
1964 ts_params->session_mpool,
1965 ts_params->valid_devs[0],
1966 rte_cryptodev_driver_id_get(
1967 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1968 BLKCIPHER_AES_CIPHERONLY_TYPE);
1970 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1972 return TEST_SUCCESS;
1976 test_authonly_dpaa_sec_all(void)
1978 struct crypto_testsuite_params *ts_params = &testsuite_params;
1981 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1982 ts_params->op_mpool,
1983 ts_params->session_mpool,
1984 ts_params->valid_devs[0],
1985 rte_cryptodev_driver_id_get(
1986 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1987 BLKCIPHER_AUTHONLY_TYPE);
1989 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1991 return TEST_SUCCESS;
1995 test_AES_chain_dpaa2_sec_all(void)
1997 struct crypto_testsuite_params *ts_params = &testsuite_params;
2000 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2001 ts_params->op_mpool,
2002 ts_params->session_mpool,
2003 ts_params->valid_devs[0],
2004 rte_cryptodev_driver_id_get(
2005 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2006 BLKCIPHER_AES_CHAIN_TYPE);
2008 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2010 return TEST_SUCCESS;
2014 test_AES_cipheronly_dpaa2_sec_all(void)
2016 struct crypto_testsuite_params *ts_params = &testsuite_params;
2019 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2020 ts_params->op_mpool,
2021 ts_params->session_mpool,
2022 ts_params->valid_devs[0],
2023 rte_cryptodev_driver_id_get(
2024 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2025 BLKCIPHER_AES_CIPHERONLY_TYPE);
2027 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2029 return TEST_SUCCESS;
2033 test_authonly_dpaa2_sec_all(void)
2035 struct crypto_testsuite_params *ts_params = &testsuite_params;
2038 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2039 ts_params->op_mpool,
2040 ts_params->session_mpool,
2041 ts_params->valid_devs[0],
2042 rte_cryptodev_driver_id_get(
2043 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2044 BLKCIPHER_AUTHONLY_TYPE);
2046 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2048 return TEST_SUCCESS;
2052 test_authonly_openssl_all(void)
2054 struct crypto_testsuite_params *ts_params = &testsuite_params;
2057 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2058 ts_params->op_mpool,
2059 ts_params->session_mpool,
2060 ts_params->valid_devs[0],
2061 rte_cryptodev_driver_id_get(
2062 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2063 BLKCIPHER_AUTHONLY_TYPE);
2065 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2067 return TEST_SUCCESS;
2071 test_authonly_ccp_all(void)
2073 struct crypto_testsuite_params *ts_params = &testsuite_params;
2076 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2077 ts_params->op_mpool,
2078 ts_params->session_mpool,
2079 ts_params->valid_devs[0],
2080 rte_cryptodev_driver_id_get(
2081 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2082 BLKCIPHER_AUTHONLY_TYPE);
2084 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2086 return TEST_SUCCESS;
2090 test_AES_chain_armv8_all(void)
2092 struct crypto_testsuite_params *ts_params = &testsuite_params;
2095 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2096 ts_params->op_mpool,
2097 ts_params->session_mpool,
2098 ts_params->valid_devs[0],
2099 rte_cryptodev_driver_id_get(
2100 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2101 BLKCIPHER_AES_CHAIN_TYPE);
2103 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2105 return TEST_SUCCESS;
2109 test_AES_chain_mrvl_all(void)
2111 struct crypto_testsuite_params *ts_params = &testsuite_params;
2114 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2115 ts_params->op_mpool,
2116 ts_params->session_mpool,
2117 ts_params->valid_devs[0],
2118 rte_cryptodev_driver_id_get(
2119 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2120 BLKCIPHER_AES_CHAIN_TYPE);
2122 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2124 return TEST_SUCCESS;
2128 test_AES_cipheronly_mrvl_all(void)
2130 struct crypto_testsuite_params *ts_params = &testsuite_params;
2133 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2134 ts_params->op_mpool,
2135 ts_params->session_mpool,
2136 ts_params->valid_devs[0],
2137 rte_cryptodev_driver_id_get(
2138 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2139 BLKCIPHER_AES_CIPHERONLY_TYPE);
2141 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2143 return TEST_SUCCESS;
2147 test_authonly_mrvl_all(void)
2149 struct crypto_testsuite_params *ts_params = &testsuite_params;
2152 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2153 ts_params->op_mpool,
2154 ts_params->session_mpool,
2155 ts_params->valid_devs[0],
2156 rte_cryptodev_driver_id_get(
2157 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2158 BLKCIPHER_AUTHONLY_TYPE);
2160 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2162 return TEST_SUCCESS;
2166 test_3DES_chain_mrvl_all(void)
2168 struct crypto_testsuite_params *ts_params = &testsuite_params;
2171 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2172 ts_params->op_mpool,
2173 ts_params->session_mpool,
2174 ts_params->valid_devs[0],
2175 rte_cryptodev_driver_id_get(
2176 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2177 BLKCIPHER_3DES_CHAIN_TYPE);
2179 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2181 return TEST_SUCCESS;
2185 test_3DES_cipheronly_mrvl_all(void)
2187 struct crypto_testsuite_params *ts_params = &testsuite_params;
2190 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2191 ts_params->op_mpool,
2192 ts_params->session_mpool,
2193 ts_params->valid_devs[0],
2194 rte_cryptodev_driver_id_get(
2195 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2196 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2198 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2200 return TEST_SUCCESS;
2204 test_AES_chain_octeontx_all(void)
2206 struct crypto_testsuite_params *ts_params = &testsuite_params;
2209 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2210 ts_params->op_mpool, ts_params->session_mpool,
2211 ts_params->valid_devs[0],
2212 rte_cryptodev_driver_id_get(
2213 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2214 BLKCIPHER_AES_CHAIN_TYPE);
2216 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2218 return TEST_SUCCESS;
2222 test_AES_cipheronly_octeontx_all(void)
2224 struct crypto_testsuite_params *ts_params = &testsuite_params;
2227 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2228 ts_params->op_mpool, ts_params->session_mpool,
2229 ts_params->valid_devs[0],
2230 rte_cryptodev_driver_id_get(
2231 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2232 BLKCIPHER_AES_CIPHERONLY_TYPE);
2234 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2236 return TEST_SUCCESS;
2240 test_3DES_chain_octeontx_all(void)
2242 struct crypto_testsuite_params *ts_params = &testsuite_params;
2245 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2246 ts_params->op_mpool, ts_params->session_mpool,
2247 ts_params->valid_devs[0],
2248 rte_cryptodev_driver_id_get(
2249 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2250 BLKCIPHER_3DES_CHAIN_TYPE);
2252 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2254 return TEST_SUCCESS;
2258 test_3DES_cipheronly_octeontx_all(void)
2260 struct crypto_testsuite_params *ts_params = &testsuite_params;
2263 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2264 ts_params->op_mpool, ts_params->session_mpool,
2265 ts_params->valid_devs[0],
2266 rte_cryptodev_driver_id_get(
2267 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2268 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2270 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2272 return TEST_SUCCESS;
2276 test_authonly_octeontx_all(void)
2278 struct crypto_testsuite_params *ts_params = &testsuite_params;
2281 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2282 ts_params->op_mpool, ts_params->session_mpool,
2283 ts_params->valid_devs[0],
2284 rte_cryptodev_driver_id_get(
2285 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2286 BLKCIPHER_AUTHONLY_TYPE);
2288 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2290 return TEST_SUCCESS;
2293 /* ***** SNOW 3G Tests ***** */
2295 create_wireless_algo_hash_session(uint8_t dev_id,
2296 const uint8_t *key, const uint8_t key_len,
2297 const uint8_t iv_len, const uint8_t auth_len,
2298 enum rte_crypto_auth_operation op,
2299 enum rte_crypto_auth_algorithm algo)
2301 uint8_t hash_key[key_len];
2303 struct crypto_testsuite_params *ts_params = &testsuite_params;
2304 struct crypto_unittest_params *ut_params = &unittest_params;
2306 memcpy(hash_key, key, key_len);
2308 debug_hexdump(stdout, "key:", key, key_len);
2310 /* Setup Authentication Parameters */
2311 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2312 ut_params->auth_xform.next = NULL;
2314 ut_params->auth_xform.auth.op = op;
2315 ut_params->auth_xform.auth.algo = algo;
2316 ut_params->auth_xform.auth.key.length = key_len;
2317 ut_params->auth_xform.auth.key.data = hash_key;
2318 ut_params->auth_xform.auth.digest_length = auth_len;
2319 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2320 ut_params->auth_xform.auth.iv.length = iv_len;
2321 ut_params->sess = rte_cryptodev_sym_session_create(
2322 ts_params->session_mpool);
2324 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2325 &ut_params->auth_xform, ts_params->session_mpool);
2326 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2331 create_wireless_algo_cipher_session(uint8_t dev_id,
2332 enum rte_crypto_cipher_operation op,
2333 enum rte_crypto_cipher_algorithm algo,
2334 const uint8_t *key, const uint8_t key_len,
2337 uint8_t cipher_key[key_len];
2339 struct crypto_testsuite_params *ts_params = &testsuite_params;
2340 struct crypto_unittest_params *ut_params = &unittest_params;
2342 memcpy(cipher_key, key, key_len);
2344 /* Setup Cipher Parameters */
2345 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2346 ut_params->cipher_xform.next = NULL;
2348 ut_params->cipher_xform.cipher.algo = algo;
2349 ut_params->cipher_xform.cipher.op = op;
2350 ut_params->cipher_xform.cipher.key.data = cipher_key;
2351 ut_params->cipher_xform.cipher.key.length = key_len;
2352 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2353 ut_params->cipher_xform.cipher.iv.length = iv_len;
2355 debug_hexdump(stdout, "key:", key, key_len);
2357 /* Create Crypto session */
2358 ut_params->sess = rte_cryptodev_sym_session_create(
2359 ts_params->session_mpool);
2361 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2362 &ut_params->cipher_xform, ts_params->session_mpool);
2363 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2368 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2369 unsigned int cipher_len,
2370 unsigned int cipher_offset)
2372 struct crypto_testsuite_params *ts_params = &testsuite_params;
2373 struct crypto_unittest_params *ut_params = &unittest_params;
2375 /* Generate Crypto op data structure */
2376 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2377 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2378 TEST_ASSERT_NOT_NULL(ut_params->op,
2379 "Failed to allocate pktmbuf offload");
2381 /* Set crypto operation data parameters */
2382 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2384 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2386 /* set crypto operation source mbuf */
2387 sym_op->m_src = ut_params->ibuf;
2390 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2392 sym_op->cipher.data.length = cipher_len;
2393 sym_op->cipher.data.offset = cipher_offset;
2398 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2399 unsigned int cipher_len,
2400 unsigned int cipher_offset)
2402 struct crypto_testsuite_params *ts_params = &testsuite_params;
2403 struct crypto_unittest_params *ut_params = &unittest_params;
2405 /* Generate Crypto op data structure */
2406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2408 TEST_ASSERT_NOT_NULL(ut_params->op,
2409 "Failed to allocate pktmbuf offload");
2411 /* Set crypto operation data parameters */
2412 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2414 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2416 /* set crypto operation source mbuf */
2417 sym_op->m_src = ut_params->ibuf;
2418 sym_op->m_dst = ut_params->obuf;
2421 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2423 sym_op->cipher.data.length = cipher_len;
2424 sym_op->cipher.data.offset = cipher_offset;
2429 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2430 enum rte_crypto_cipher_operation cipher_op,
2431 enum rte_crypto_auth_operation auth_op,
2432 enum rte_crypto_auth_algorithm auth_algo,
2433 enum rte_crypto_cipher_algorithm cipher_algo,
2434 const uint8_t *key, uint8_t key_len,
2435 uint8_t auth_iv_len, uint8_t auth_len,
2436 uint8_t cipher_iv_len)
2439 uint8_t cipher_auth_key[key_len];
2441 struct crypto_testsuite_params *ts_params = &testsuite_params;
2442 struct crypto_unittest_params *ut_params = &unittest_params;
2444 memcpy(cipher_auth_key, key, key_len);
2446 /* Setup Authentication Parameters */
2447 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2448 ut_params->auth_xform.next = NULL;
2450 ut_params->auth_xform.auth.op = auth_op;
2451 ut_params->auth_xform.auth.algo = auth_algo;
2452 ut_params->auth_xform.auth.key.length = key_len;
2453 /* Hash key = cipher key */
2454 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2455 ut_params->auth_xform.auth.digest_length = auth_len;
2456 /* Auth IV will be after cipher IV */
2457 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2458 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2460 /* Setup Cipher Parameters */
2461 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2462 ut_params->cipher_xform.next = &ut_params->auth_xform;
2464 ut_params->cipher_xform.cipher.algo = cipher_algo;
2465 ut_params->cipher_xform.cipher.op = cipher_op;
2466 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2467 ut_params->cipher_xform.cipher.key.length = key_len;
2468 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2469 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2471 debug_hexdump(stdout, "key:", key, key_len);
2473 /* Create Crypto session*/
2474 ut_params->sess = rte_cryptodev_sym_session_create(
2475 ts_params->session_mpool);
2477 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2478 &ut_params->cipher_xform, ts_params->session_mpool);
2480 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2485 create_wireless_cipher_auth_session(uint8_t dev_id,
2486 enum rte_crypto_cipher_operation cipher_op,
2487 enum rte_crypto_auth_operation auth_op,
2488 enum rte_crypto_auth_algorithm auth_algo,
2489 enum rte_crypto_cipher_algorithm cipher_algo,
2490 const struct wireless_test_data *tdata)
2492 const uint8_t key_len = tdata->key.len;
2493 uint8_t cipher_auth_key[key_len];
2495 struct crypto_testsuite_params *ts_params = &testsuite_params;
2496 struct crypto_unittest_params *ut_params = &unittest_params;
2497 const uint8_t *key = tdata->key.data;
2498 const uint8_t auth_len = tdata->digest.len;
2499 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2500 uint8_t auth_iv_len = tdata->auth_iv.len;
2502 memcpy(cipher_auth_key, key, key_len);
2504 /* Setup Authentication Parameters */
2505 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2506 ut_params->auth_xform.next = NULL;
2508 ut_params->auth_xform.auth.op = auth_op;
2509 ut_params->auth_xform.auth.algo = auth_algo;
2510 ut_params->auth_xform.auth.key.length = key_len;
2511 /* Hash key = cipher key */
2512 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2513 ut_params->auth_xform.auth.digest_length = auth_len;
2514 /* Auth IV will be after cipher IV */
2515 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2516 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2518 /* Setup Cipher Parameters */
2519 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2520 ut_params->cipher_xform.next = &ut_params->auth_xform;
2522 ut_params->cipher_xform.cipher.algo = cipher_algo;
2523 ut_params->cipher_xform.cipher.op = cipher_op;
2524 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2525 ut_params->cipher_xform.cipher.key.length = key_len;
2526 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2527 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2530 debug_hexdump(stdout, "key:", key, key_len);
2532 /* Create Crypto session*/
2533 ut_params->sess = rte_cryptodev_sym_session_create(
2534 ts_params->session_mpool);
2536 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2537 &ut_params->cipher_xform, ts_params->session_mpool);
2539 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2544 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2545 const struct wireless_test_data *tdata)
2547 return create_wireless_cipher_auth_session(dev_id,
2548 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2549 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2550 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2554 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2555 enum rte_crypto_cipher_operation cipher_op,
2556 enum rte_crypto_auth_operation auth_op,
2557 enum rte_crypto_auth_algorithm auth_algo,
2558 enum rte_crypto_cipher_algorithm cipher_algo,
2559 const uint8_t *key, const uint8_t key_len,
2560 uint8_t auth_iv_len, uint8_t auth_len,
2561 uint8_t cipher_iv_len)
2563 uint8_t auth_cipher_key[key_len];
2565 struct crypto_testsuite_params *ts_params = &testsuite_params;
2566 struct crypto_unittest_params *ut_params = &unittest_params;
2568 memcpy(auth_cipher_key, key, key_len);
2570 /* Setup Authentication Parameters */
2571 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2572 ut_params->auth_xform.auth.op = auth_op;
2573 ut_params->auth_xform.next = &ut_params->cipher_xform;
2574 ut_params->auth_xform.auth.algo = auth_algo;
2575 ut_params->auth_xform.auth.key.length = key_len;
2576 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2577 ut_params->auth_xform.auth.digest_length = auth_len;
2578 /* Auth IV will be after cipher IV */
2579 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2580 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2582 /* Setup Cipher Parameters */
2583 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2584 ut_params->cipher_xform.next = NULL;
2585 ut_params->cipher_xform.cipher.algo = cipher_algo;
2586 ut_params->cipher_xform.cipher.op = cipher_op;
2587 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2588 ut_params->cipher_xform.cipher.key.length = key_len;
2589 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2590 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2592 debug_hexdump(stdout, "key:", key, key_len);
2594 /* Create Crypto session*/
2595 ut_params->sess = rte_cryptodev_sym_session_create(
2596 ts_params->session_mpool);
2598 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2599 &ut_params->auth_xform, ts_params->session_mpool);
2601 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2607 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2608 unsigned int auth_tag_len,
2609 const uint8_t *iv, unsigned int iv_len,
2610 unsigned int data_pad_len,
2611 enum rte_crypto_auth_operation op,
2612 unsigned int auth_len, unsigned int auth_offset)
2614 struct crypto_testsuite_params *ts_params = &testsuite_params;
2616 struct crypto_unittest_params *ut_params = &unittest_params;
2618 /* Generate Crypto op data structure */
2619 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2620 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2621 TEST_ASSERT_NOT_NULL(ut_params->op,
2622 "Failed to allocate pktmbuf offload");
2624 /* Set crypto operation data parameters */
2625 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2627 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2629 /* set crypto operation source mbuf */
2630 sym_op->m_src = ut_params->ibuf;
2633 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2636 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2637 ut_params->ibuf, auth_tag_len);
2639 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2640 "no room to append auth tag");
2641 ut_params->digest = sym_op->auth.digest.data;
2642 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2643 ut_params->ibuf, data_pad_len);
2644 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2645 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2647 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2649 debug_hexdump(stdout, "digest:",
2650 sym_op->auth.digest.data,
2653 sym_op->auth.data.length = auth_len;
2654 sym_op->auth.data.offset = auth_offset;
2660 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2661 enum rte_crypto_auth_operation op)
2663 struct crypto_testsuite_params *ts_params = &testsuite_params;
2664 struct crypto_unittest_params *ut_params = &unittest_params;
2666 const uint8_t *auth_tag = tdata->digest.data;
2667 const unsigned int auth_tag_len = tdata->digest.len;
2668 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2669 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2671 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2672 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2673 const uint8_t *auth_iv = tdata->auth_iv.data;
2674 const uint8_t auth_iv_len = tdata->auth_iv.len;
2675 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2676 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2678 /* Generate Crypto op data structure */
2679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2681 TEST_ASSERT_NOT_NULL(ut_params->op,
2682 "Failed to allocate pktmbuf offload");
2683 /* Set crypto operation data parameters */
2684 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2686 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2688 /* set crypto operation source mbuf */
2689 sym_op->m_src = ut_params->ibuf;
2692 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2693 ut_params->ibuf, auth_tag_len);
2695 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2696 "no room to append auth tag");
2697 ut_params->digest = sym_op->auth.digest.data;
2698 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2699 ut_params->ibuf, data_pad_len);
2700 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2701 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2703 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2705 debug_hexdump(stdout, "digest:",
2706 sym_op->auth.digest.data,
2709 /* Copy cipher and auth IVs at the end of the crypto operation */
2710 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2712 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2713 iv_ptr += cipher_iv_len;
2714 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2716 sym_op->cipher.data.length = cipher_len;
2717 sym_op->cipher.data.offset = 0;
2718 sym_op->auth.data.length = auth_len;
2719 sym_op->auth.data.offset = 0;
2725 create_zuc_cipher_hash_generate_operation(
2726 const struct wireless_test_data *tdata)
2728 return create_wireless_cipher_hash_operation(tdata,
2729 RTE_CRYPTO_AUTH_OP_GENERATE);
2733 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2734 const unsigned auth_tag_len,
2735 const uint8_t *auth_iv, uint8_t auth_iv_len,
2736 unsigned data_pad_len,
2737 enum rte_crypto_auth_operation op,
2738 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2739 const unsigned cipher_len, const unsigned cipher_offset,
2740 const unsigned auth_len, const unsigned auth_offset)
2742 struct crypto_testsuite_params *ts_params = &testsuite_params;
2743 struct crypto_unittest_params *ut_params = &unittest_params;
2745 /* Generate Crypto op data structure */
2746 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2747 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2748 TEST_ASSERT_NOT_NULL(ut_params->op,
2749 "Failed to allocate pktmbuf offload");
2750 /* Set crypto operation data parameters */
2751 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2753 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2755 /* set crypto operation source mbuf */
2756 sym_op->m_src = ut_params->ibuf;
2759 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2760 ut_params->ibuf, auth_tag_len);
2762 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2763 "no room to append auth tag");
2764 ut_params->digest = sym_op->auth.digest.data;
2765 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2766 ut_params->ibuf, data_pad_len);
2767 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2768 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2770 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2772 debug_hexdump(stdout, "digest:",
2773 sym_op->auth.digest.data,
2776 /* Copy cipher and auth IVs at the end of the crypto operation */
2777 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2779 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2780 iv_ptr += cipher_iv_len;
2781 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2783 sym_op->cipher.data.length = cipher_len;
2784 sym_op->cipher.data.offset = cipher_offset;
2785 sym_op->auth.data.length = auth_len;
2786 sym_op->auth.data.offset = auth_offset;
2792 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2793 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2794 const uint8_t *auth_iv, uint8_t auth_iv_len,
2795 unsigned int data_pad_len,
2796 unsigned int cipher_len, unsigned int cipher_offset,
2797 unsigned int auth_len, unsigned int auth_offset)
2799 struct crypto_testsuite_params *ts_params = &testsuite_params;
2800 struct crypto_unittest_params *ut_params = &unittest_params;
2802 /* Generate Crypto op data structure */
2803 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2804 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2805 TEST_ASSERT_NOT_NULL(ut_params->op,
2806 "Failed to allocate pktmbuf offload");
2808 /* Set crypto operation data parameters */
2809 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2811 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2813 /* set crypto operation source mbuf */
2814 sym_op->m_src = ut_params->ibuf;
2817 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2818 ut_params->ibuf, auth_tag_len);
2820 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2821 "no room to append auth tag");
2823 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2824 ut_params->ibuf, data_pad_len);
2826 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2828 debug_hexdump(stdout, "digest:",
2829 sym_op->auth.digest.data,
2832 /* Copy cipher and auth IVs at the end of the crypto operation */
2833 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2835 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2836 iv_ptr += cipher_iv_len;
2837 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2839 sym_op->cipher.data.length = cipher_len;
2840 sym_op->cipher.data.offset = cipher_offset;
2842 sym_op->auth.data.length = auth_len;
2843 sym_op->auth.data.offset = auth_offset;
2849 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2851 struct crypto_testsuite_params *ts_params = &testsuite_params;
2852 struct crypto_unittest_params *ut_params = &unittest_params;
2855 unsigned plaintext_pad_len;
2856 unsigned plaintext_len;
2859 /* Create SNOW 3G session */
2860 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2861 tdata->key.data, tdata->key.len,
2862 tdata->auth_iv.len, tdata->digest.len,
2863 RTE_CRYPTO_AUTH_OP_GENERATE,
2864 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2868 /* alloc mbuf and set payload */
2869 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2871 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2872 rte_pktmbuf_tailroom(ut_params->ibuf));
2874 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2875 /* Append data which is padded to a multiple of */
2876 /* the algorithms block size */
2877 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2878 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2880 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2882 /* Create SNOW 3G operation */
2883 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2884 tdata->auth_iv.data, tdata->auth_iv.len,
2885 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2886 tdata->validAuthLenInBits.len,
2891 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2893 ut_params->obuf = ut_params->op->sym->m_src;
2894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2895 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2896 + plaintext_pad_len;
2899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2902 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2903 "SNOW 3G Generated auth tag not as expected");
2909 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2911 struct crypto_testsuite_params *ts_params = &testsuite_params;
2912 struct crypto_unittest_params *ut_params = &unittest_params;
2915 unsigned plaintext_pad_len;
2916 unsigned plaintext_len;
2919 /* Create SNOW 3G session */
2920 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2921 tdata->key.data, tdata->key.len,
2922 tdata->auth_iv.len, tdata->digest.len,
2923 RTE_CRYPTO_AUTH_OP_VERIFY,
2924 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2927 /* alloc mbuf and set payload */
2928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2930 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2931 rte_pktmbuf_tailroom(ut_params->ibuf));
2933 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2934 /* Append data which is padded to a multiple of */
2935 /* the algorithms block size */
2936 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2937 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2939 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2941 /* Create SNOW 3G operation */
2942 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2944 tdata->auth_iv.data, tdata->auth_iv.len,
2946 RTE_CRYPTO_AUTH_OP_VERIFY,
2947 tdata->validAuthLenInBits.len,
2952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2954 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2955 ut_params->obuf = ut_params->op->sym->m_src;
2956 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2957 + plaintext_pad_len;
2960 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2969 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2971 struct crypto_testsuite_params *ts_params = &testsuite_params;
2972 struct crypto_unittest_params *ut_params = &unittest_params;
2975 unsigned plaintext_pad_len;
2976 unsigned plaintext_len;
2979 /* Create KASUMI session */
2980 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2981 tdata->key.data, tdata->key.len,
2982 0, tdata->digest.len,
2983 RTE_CRYPTO_AUTH_OP_GENERATE,
2984 RTE_CRYPTO_AUTH_KASUMI_F9);
2988 /* alloc mbuf and set payload */
2989 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2992 rte_pktmbuf_tailroom(ut_params->ibuf));
2994 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2995 /* Append data which is padded to a multiple of */
2996 /* the algorithms block size */
2997 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2998 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3000 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3002 /* Create KASUMI operation */
3003 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3005 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3006 tdata->plaintext.len,
3011 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3013 ut_params->obuf = ut_params->op->sym->m_src;
3014 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3015 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3016 + plaintext_pad_len;
3019 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3022 DIGEST_BYTE_LENGTH_KASUMI_F9,
3023 "KASUMI Generated auth tag not as expected");
3029 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3031 struct crypto_testsuite_params *ts_params = &testsuite_params;
3032 struct crypto_unittest_params *ut_params = &unittest_params;
3035 unsigned plaintext_pad_len;
3036 unsigned plaintext_len;
3039 /* Create KASUMI session */
3040 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3041 tdata->key.data, tdata->key.len,
3042 0, tdata->digest.len,
3043 RTE_CRYPTO_AUTH_OP_VERIFY,
3044 RTE_CRYPTO_AUTH_KASUMI_F9);
3047 /* alloc mbuf and set payload */
3048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3050 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3051 rte_pktmbuf_tailroom(ut_params->ibuf));
3053 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3054 /* Append data which is padded to a multiple */
3055 /* of the algorithms block size */
3056 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3057 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3059 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3061 /* Create KASUMI operation */
3062 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3066 RTE_CRYPTO_AUTH_OP_VERIFY,
3067 tdata->plaintext.len,
3072 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3074 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3075 ut_params->obuf = ut_params->op->sym->m_src;
3076 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3077 + plaintext_pad_len;
3080 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3089 test_snow3g_hash_generate_test_case_1(void)
3091 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3095 test_snow3g_hash_generate_test_case_2(void)
3097 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3101 test_snow3g_hash_generate_test_case_3(void)
3103 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3107 test_snow3g_hash_generate_test_case_4(void)
3109 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3113 test_snow3g_hash_generate_test_case_5(void)
3115 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3119 test_snow3g_hash_generate_test_case_6(void)
3121 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3125 test_snow3g_hash_verify_test_case_1(void)
3127 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3132 test_snow3g_hash_verify_test_case_2(void)
3134 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3138 test_snow3g_hash_verify_test_case_3(void)
3140 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3144 test_snow3g_hash_verify_test_case_4(void)
3146 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3150 test_snow3g_hash_verify_test_case_5(void)
3152 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3156 test_snow3g_hash_verify_test_case_6(void)
3158 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3162 test_kasumi_hash_generate_test_case_1(void)
3164 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3168 test_kasumi_hash_generate_test_case_2(void)
3170 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3174 test_kasumi_hash_generate_test_case_3(void)
3176 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3180 test_kasumi_hash_generate_test_case_4(void)
3182 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3186 test_kasumi_hash_generate_test_case_5(void)
3188 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3192 test_kasumi_hash_generate_test_case_6(void)
3194 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3198 test_kasumi_hash_verify_test_case_1(void)
3200 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3204 test_kasumi_hash_verify_test_case_2(void)
3206 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3210 test_kasumi_hash_verify_test_case_3(void)
3212 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3216 test_kasumi_hash_verify_test_case_4(void)
3218 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3222 test_kasumi_hash_verify_test_case_5(void)
3224 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3228 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3230 struct crypto_testsuite_params *ts_params = &testsuite_params;
3231 struct crypto_unittest_params *ut_params = &unittest_params;
3234 uint8_t *plaintext, *ciphertext;
3235 unsigned plaintext_pad_len;
3236 unsigned plaintext_len;
3238 /* Create KASUMI session */
3239 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3240 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3241 RTE_CRYPTO_CIPHER_KASUMI_F8,
3242 tdata->key.data, tdata->key.len,
3243 tdata->cipher_iv.len);
3247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3249 /* Clear mbuf payload */
3250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3251 rte_pktmbuf_tailroom(ut_params->ibuf));
3253 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3254 /* Append data which is padded to a multiple */
3255 /* of the algorithms block size */
3256 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3261 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3263 /* Create KASUMI operation */
3264 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3265 tdata->cipher_iv.len,
3266 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3267 tdata->validCipherOffsetInBits.len);
3271 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3273 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3275 ut_params->obuf = ut_params->op->sym->m_dst;
3276 if (ut_params->obuf)
3277 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3279 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3281 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3283 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3284 (tdata->validCipherOffsetInBits.len >> 3);
3286 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3288 reference_ciphertext,
3289 tdata->validCipherLenInBits.len,
3290 "KASUMI Ciphertext data not as expected");
3295 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3297 struct crypto_testsuite_params *ts_params = &testsuite_params;
3298 struct crypto_unittest_params *ut_params = &unittest_params;
3302 unsigned int plaintext_pad_len;
3303 unsigned int plaintext_len;
3305 uint8_t buffer[10000];
3306 const uint8_t *ciphertext;
3308 struct rte_cryptodev_info dev_info;
3310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3312 uint64_t feat_flags = dev_info.feature_flags;
3314 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3315 printf("Device doesn't support in-place scatter-gather. "
3320 /* Create KASUMI session */
3321 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3322 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3323 RTE_CRYPTO_CIPHER_KASUMI_F8,
3324 tdata->key.data, tdata->key.len,
3325 tdata->cipher_iv.len);
3329 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3332 /* Append data which is padded to a multiple */
3333 /* of the algorithms block size */
3334 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3336 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3337 plaintext_pad_len, 10, 0);
3339 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3341 /* Create KASUMI operation */
3342 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3343 tdata->cipher_iv.len,
3344 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3345 tdata->validCipherOffsetInBits.len);
3349 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3351 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3353 ut_params->obuf = ut_params->op->sym->m_dst;
3355 if (ut_params->obuf)
3356 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3357 plaintext_len, buffer);
3359 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3360 tdata->validCipherOffsetInBits.len >> 3,
3361 plaintext_len, buffer);
3364 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3366 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3367 (tdata->validCipherOffsetInBits.len >> 3);
3369 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3371 reference_ciphertext,
3372 tdata->validCipherLenInBits.len,
3373 "KASUMI Ciphertext data not as expected");
3378 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3380 struct crypto_testsuite_params *ts_params = &testsuite_params;
3381 struct crypto_unittest_params *ut_params = &unittest_params;
3384 uint8_t *plaintext, *ciphertext;
3385 unsigned plaintext_pad_len;
3386 unsigned plaintext_len;
3388 /* Create KASUMI session */
3389 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3390 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3391 RTE_CRYPTO_CIPHER_KASUMI_F8,
3392 tdata->key.data, tdata->key.len,
3393 tdata->cipher_iv.len);
3397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3398 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3400 /* Clear mbuf payload */
3401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3402 rte_pktmbuf_tailroom(ut_params->ibuf));
3404 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3405 /* Append data which is padded to a multiple */
3406 /* of the algorithms block size */
3407 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3408 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3410 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3411 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3413 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3415 /* Create KASUMI operation */
3416 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3417 tdata->cipher_iv.len,
3418 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3419 tdata->validCipherOffsetInBits.len);
3423 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3425 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3427 ut_params->obuf = ut_params->op->sym->m_dst;
3428 if (ut_params->obuf)
3429 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3431 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3433 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3435 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3436 (tdata->validCipherOffsetInBits.len >> 3);
3438 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3440 reference_ciphertext,
3441 tdata->validCipherLenInBits.len,
3442 "KASUMI Ciphertext data not as expected");
3447 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3449 struct crypto_testsuite_params *ts_params = &testsuite_params;
3450 struct crypto_unittest_params *ut_params = &unittest_params;
3453 unsigned int plaintext_pad_len;
3454 unsigned int plaintext_len;
3456 const uint8_t *ciphertext;
3457 uint8_t buffer[2048];
3459 struct rte_cryptodev_info dev_info;
3461 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3463 uint64_t feat_flags = dev_info.feature_flags;
3464 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3465 printf("Device doesn't support out-of-place scatter-gather "
3466 "in both input and output mbufs. "
3471 /* Create KASUMI session */
3472 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3473 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3474 RTE_CRYPTO_CIPHER_KASUMI_F8,
3475 tdata->key.data, tdata->key.len,
3476 tdata->cipher_iv.len);
3480 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3481 /* Append data which is padded to a multiple */
3482 /* of the algorithms block size */
3483 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3485 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3486 plaintext_pad_len, 10, 0);
3487 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3488 plaintext_pad_len, 3, 0);
3490 /* Append data which is padded to a multiple */
3491 /* of the algorithms block size */
3492 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3494 /* Create KASUMI operation */
3495 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3496 tdata->cipher_iv.len,
3497 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3498 tdata->validCipherOffsetInBits.len);
3502 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3504 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3506 ut_params->obuf = ut_params->op->sym->m_dst;
3507 if (ut_params->obuf)
3508 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3509 plaintext_pad_len, buffer);
3511 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3512 tdata->validCipherOffsetInBits.len >> 3,
3513 plaintext_pad_len, buffer);
3515 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3516 (tdata->validCipherOffsetInBits.len >> 3);
3518 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3520 reference_ciphertext,
3521 tdata->validCipherLenInBits.len,
3522 "KASUMI Ciphertext data not as expected");
3528 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3530 struct crypto_testsuite_params *ts_params = &testsuite_params;
3531 struct crypto_unittest_params *ut_params = &unittest_params;
3534 uint8_t *ciphertext, *plaintext;
3535 unsigned ciphertext_pad_len;
3536 unsigned ciphertext_len;
3538 /* Create KASUMI session */
3539 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3540 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3541 RTE_CRYPTO_CIPHER_KASUMI_F8,
3542 tdata->key.data, tdata->key.len,
3543 tdata->cipher_iv.len);
3547 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3548 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3550 /* Clear mbuf payload */
3551 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3552 rte_pktmbuf_tailroom(ut_params->ibuf));
3554 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3555 /* Append data which is padded to a multiple */
3556 /* of the algorithms block size */
3557 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3558 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3559 ciphertext_pad_len);
3560 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3561 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3563 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3565 /* Create KASUMI operation */
3566 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3567 tdata->cipher_iv.len,
3568 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3569 tdata->validCipherOffsetInBits.len);
3573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3575 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3577 ut_params->obuf = ut_params->op->sym->m_dst;
3578 if (ut_params->obuf)
3579 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3581 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3583 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3585 const uint8_t *reference_plaintext = tdata->plaintext.data +
3586 (tdata->validCipherOffsetInBits.len >> 3);
3588 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3590 reference_plaintext,
3591 tdata->validCipherLenInBits.len,
3592 "KASUMI Plaintext data not as expected");
3597 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3599 struct crypto_testsuite_params *ts_params = &testsuite_params;
3600 struct crypto_unittest_params *ut_params = &unittest_params;
3603 uint8_t *ciphertext, *plaintext;
3604 unsigned ciphertext_pad_len;
3605 unsigned ciphertext_len;
3607 /* Create KASUMI session */
3608 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3609 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3610 RTE_CRYPTO_CIPHER_KASUMI_F8,
3611 tdata->key.data, tdata->key.len,
3612 tdata->cipher_iv.len);
3616 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3618 /* Clear mbuf payload */
3619 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3620 rte_pktmbuf_tailroom(ut_params->ibuf));
3622 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3623 /* Append data which is padded to a multiple */
3624 /* of the algorithms block size */
3625 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3626 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3627 ciphertext_pad_len);
3628 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3630 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3632 /* Create KASUMI operation */
3633 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3634 tdata->cipher_iv.len,
3635 tdata->ciphertext.len,
3636 tdata->validCipherOffsetInBits.len);
3640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3642 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3644 ut_params->obuf = ut_params->op->sym->m_dst;
3645 if (ut_params->obuf)
3646 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3648 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3650 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3652 const uint8_t *reference_plaintext = tdata->plaintext.data +
3653 (tdata->validCipherOffsetInBits.len >> 3);
3655 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3657 reference_plaintext,
3658 tdata->validCipherLenInBits.len,
3659 "KASUMI Plaintext data not as expected");
3664 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3666 struct crypto_testsuite_params *ts_params = &testsuite_params;
3667 struct crypto_unittest_params *ut_params = &unittest_params;
3670 uint8_t *plaintext, *ciphertext;
3671 unsigned plaintext_pad_len;
3672 unsigned plaintext_len;
3674 /* Create SNOW 3G session */
3675 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3676 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3677 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3678 tdata->key.data, tdata->key.len,
3679 tdata->cipher_iv.len);
3683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3685 /* Clear mbuf payload */
3686 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3687 rte_pktmbuf_tailroom(ut_params->ibuf));
3689 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3690 /* Append data which is padded to a multiple of */
3691 /* the algorithms block size */
3692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3693 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3695 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3697 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3699 /* Create SNOW 3G operation */
3700 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3701 tdata->cipher_iv.len,
3702 tdata->validCipherLenInBits.len,
3707 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3709 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3711 ut_params->obuf = ut_params->op->sym->m_dst;
3712 if (ut_params->obuf)
3713 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3715 ciphertext = plaintext;
3717 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3720 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3722 tdata->ciphertext.data,
3723 tdata->validDataLenInBits.len,
3724 "SNOW 3G Ciphertext data not as expected");
3730 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3732 struct crypto_testsuite_params *ts_params = &testsuite_params;
3733 struct crypto_unittest_params *ut_params = &unittest_params;
3734 uint8_t *plaintext, *ciphertext;
3737 unsigned plaintext_pad_len;
3738 unsigned plaintext_len;
3740 /* Create SNOW 3G session */
3741 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3742 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3743 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3744 tdata->key.data, tdata->key.len,
3745 tdata->cipher_iv.len);
3749 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3750 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3752 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3753 "Failed to allocate input buffer in mempool");
3754 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3755 "Failed to allocate output buffer in mempool");
3757 /* Clear mbuf payload */
3758 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3759 rte_pktmbuf_tailroom(ut_params->ibuf));
3761 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3762 /* Append data which is padded to a multiple of */
3763 /* the algorithms block size */
3764 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3765 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3767 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3768 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3770 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3772 /* Create SNOW 3G operation */
3773 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3774 tdata->cipher_iv.len,
3775 tdata->validCipherLenInBits.len,
3780 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3782 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3784 ut_params->obuf = ut_params->op->sym->m_dst;
3785 if (ut_params->obuf)
3786 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3788 ciphertext = plaintext;
3790 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3793 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3795 tdata->ciphertext.data,
3796 tdata->validDataLenInBits.len,
3797 "SNOW 3G Ciphertext data not as expected");
3802 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3804 struct crypto_testsuite_params *ts_params = &testsuite_params;
3805 struct crypto_unittest_params *ut_params = &unittest_params;
3808 unsigned int plaintext_pad_len;
3809 unsigned int plaintext_len;
3810 uint8_t buffer[10000];
3811 const uint8_t *ciphertext;
3813 struct rte_cryptodev_info dev_info;
3815 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3817 uint64_t feat_flags = dev_info.feature_flags;
3819 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3820 printf("Device doesn't support out-of-place scatter-gather "
3821 "in both input and output mbufs. "
3826 /* Create SNOW 3G session */
3827 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3828 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3829 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3830 tdata->key.data, tdata->key.len,
3831 tdata->cipher_iv.len);
3835 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3836 /* Append data which is padded to a multiple of */
3837 /* the algorithms block size */
3838 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3840 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3841 plaintext_pad_len, 10, 0);
3842 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3843 plaintext_pad_len, 3, 0);
3845 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3846 "Failed to allocate input buffer in mempool");
3847 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3848 "Failed to allocate output buffer in mempool");
3850 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3852 /* Create SNOW 3G operation */
3853 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3854 tdata->cipher_iv.len,
3855 tdata->validCipherLenInBits.len,
3860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3864 ut_params->obuf = ut_params->op->sym->m_dst;
3865 if (ut_params->obuf)
3866 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3867 plaintext_len, buffer);
3869 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3870 plaintext_len, buffer);
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3875 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3877 tdata->ciphertext.data,
3878 tdata->validDataLenInBits.len,
3879 "SNOW 3G Ciphertext data not as expected");
3884 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3886 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3888 uint8_t curr_byte, prev_byte;
3889 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3890 uint8_t lower_byte_mask = (1 << offset) - 1;
3893 prev_byte = buffer[0];
3894 buffer[0] >>= offset;
3896 for (i = 1; i < length_in_bytes; i++) {
3897 curr_byte = buffer[i];
3898 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3899 (curr_byte >> offset);
3900 prev_byte = curr_byte;
3905 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3907 struct crypto_testsuite_params *ts_params = &testsuite_params;
3908 struct crypto_unittest_params *ut_params = &unittest_params;
3909 uint8_t *plaintext, *ciphertext;
3911 uint32_t plaintext_len;
3912 uint32_t plaintext_pad_len;
3913 uint8_t extra_offset = 4;
3914 uint8_t *expected_ciphertext_shifted;
3916 /* Create SNOW 3G session */
3917 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3919 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3920 tdata->key.data, tdata->key.len,
3921 tdata->cipher_iv.len);
3925 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3926 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3928 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3929 "Failed to allocate input buffer in mempool");
3930 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3931 "Failed to allocate output buffer in mempool");
3933 /* Clear mbuf payload */
3934 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3935 rte_pktmbuf_tailroom(ut_params->ibuf));
3937 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3939 * Append data which is padded to a
3940 * multiple of the algorithms block size
3942 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3944 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3947 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3949 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3950 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3952 #ifdef RTE_APP_TEST_DEBUG
3953 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3955 /* Create SNOW 3G operation */
3956 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3957 tdata->cipher_iv.len,
3958 tdata->validCipherLenInBits.len,
3963 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3965 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3967 ut_params->obuf = ut_params->op->sym->m_dst;
3968 if (ut_params->obuf)
3969 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3971 ciphertext = plaintext;
3973 #ifdef RTE_APP_TEST_DEBUG
3974 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3977 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3979 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3980 "failed to reserve memory for ciphertext shifted\n");
3982 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3983 ceil_byte_length(tdata->ciphertext.len));
3984 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3989 expected_ciphertext_shifted,
3990 tdata->validDataLenInBits.len,
3992 "SNOW 3G Ciphertext data not as expected");
3996 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3998 struct crypto_testsuite_params *ts_params = &testsuite_params;
3999 struct crypto_unittest_params *ut_params = &unittest_params;
4003 uint8_t *plaintext, *ciphertext;
4004 unsigned ciphertext_pad_len;
4005 unsigned ciphertext_len;
4007 /* Create SNOW 3G session */
4008 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4009 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4010 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4011 tdata->key.data, tdata->key.len,
4012 tdata->cipher_iv.len);
4016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4018 /* Clear mbuf payload */
4019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4020 rte_pktmbuf_tailroom(ut_params->ibuf));
4022 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4023 /* Append data which is padded to a multiple of */
4024 /* the algorithms block size */
4025 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4026 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4027 ciphertext_pad_len);
4028 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4030 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4032 /* Create SNOW 3G operation */
4033 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4034 tdata->cipher_iv.len,
4035 tdata->validCipherLenInBits.len,
4040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4042 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4043 ut_params->obuf = ut_params->op->sym->m_dst;
4044 if (ut_params->obuf)
4045 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4047 plaintext = ciphertext;
4049 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4053 tdata->plaintext.data,
4054 tdata->validDataLenInBits.len,
4055 "SNOW 3G Plaintext data not as expected");
4059 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4061 struct crypto_testsuite_params *ts_params = &testsuite_params;
4062 struct crypto_unittest_params *ut_params = &unittest_params;
4066 uint8_t *plaintext, *ciphertext;
4067 unsigned ciphertext_pad_len;
4068 unsigned ciphertext_len;
4070 /* Create SNOW 3G session */
4071 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4072 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4073 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4074 tdata->key.data, tdata->key.len,
4075 tdata->cipher_iv.len);
4079 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4080 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4082 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4083 "Failed to allocate input buffer");
4084 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4085 "Failed to allocate output buffer");
4087 /* Clear mbuf payload */
4088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4089 rte_pktmbuf_tailroom(ut_params->ibuf));
4091 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4092 rte_pktmbuf_tailroom(ut_params->obuf));
4094 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4095 /* Append data which is padded to a multiple of */
4096 /* the algorithms block size */
4097 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4098 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4099 ciphertext_pad_len);
4100 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4101 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4103 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4105 /* Create SNOW 3G operation */
4106 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4107 tdata->cipher_iv.len,
4108 tdata->validCipherLenInBits.len,
4113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4116 ut_params->obuf = ut_params->op->sym->m_dst;
4117 if (ut_params->obuf)
4118 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4120 plaintext = ciphertext;
4122 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4125 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4126 tdata->plaintext.data,
4127 tdata->validDataLenInBits.len,
4128 "SNOW 3G Plaintext data not as expected");
4133 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4135 struct crypto_testsuite_params *ts_params = &testsuite_params;
4136 struct crypto_unittest_params *ut_params = &unittest_params;
4140 uint8_t *plaintext, *ciphertext;
4141 unsigned int plaintext_pad_len;
4142 unsigned int plaintext_len;
4144 struct rte_cryptodev_sym_capability_idx cap_idx;
4146 /* Check if device supports ZUC EEA3 */
4147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4150 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4154 /* Check if device supports ZUC EIA3 */
4155 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4156 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4158 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4162 /* Create ZUC session */
4163 retval = create_zuc_cipher_auth_encrypt_generate_session(
4164 ts_params->valid_devs[0],
4168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4170 /* clear mbuf payload */
4171 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4172 rte_pktmbuf_tailroom(ut_params->ibuf));
4174 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4175 /* Append data which is padded to a multiple of */
4176 /* the algorithms block size */
4177 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4178 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4180 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4182 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4184 /* Create ZUC operation */
4185 retval = create_zuc_cipher_hash_generate_operation(tdata);
4189 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4192 ut_params->obuf = ut_params->op->sym->m_src;
4193 if (ut_params->obuf)
4194 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4196 ciphertext = plaintext;
4198 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4202 tdata->ciphertext.data,
4203 tdata->validDataLenInBits.len,
4204 "ZUC Ciphertext data not as expected");
4206 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4207 + plaintext_pad_len;
4210 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4214 "ZUC Generated auth tag not as expected");
4219 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4221 struct crypto_testsuite_params *ts_params = &testsuite_params;
4222 struct crypto_unittest_params *ut_params = &unittest_params;
4226 uint8_t *plaintext, *ciphertext;
4227 unsigned plaintext_pad_len;
4228 unsigned plaintext_len;
4230 /* Create SNOW 3G session */
4231 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4232 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4233 RTE_CRYPTO_AUTH_OP_GENERATE,
4234 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4235 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4236 tdata->key.data, tdata->key.len,
4237 tdata->auth_iv.len, tdata->digest.len,
4238 tdata->cipher_iv.len);
4241 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4243 /* clear mbuf payload */
4244 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4245 rte_pktmbuf_tailroom(ut_params->ibuf));
4247 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4248 /* Append data which is padded to a multiple of */
4249 /* the algorithms block size */
4250 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4251 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4253 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4255 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4257 /* Create SNOW 3G operation */
4258 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4259 tdata->digest.len, tdata->auth_iv.data,
4261 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4262 tdata->cipher_iv.data, tdata->cipher_iv.len,
4263 tdata->validCipherLenInBits.len,
4265 tdata->validAuthLenInBits.len,
4271 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4273 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4274 ut_params->obuf = ut_params->op->sym->m_src;
4275 if (ut_params->obuf)
4276 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4278 ciphertext = plaintext;
4280 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4282 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4284 tdata->ciphertext.data,
4285 tdata->validDataLenInBits.len,
4286 "SNOW 3G Ciphertext data not as expected");
4288 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4289 + plaintext_pad_len;
4292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4295 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4296 "SNOW 3G Generated auth tag not as expected");
4300 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4302 struct crypto_testsuite_params *ts_params = &testsuite_params;
4303 struct crypto_unittest_params *ut_params = &unittest_params;
4307 uint8_t *plaintext, *ciphertext;
4308 unsigned plaintext_pad_len;
4309 unsigned plaintext_len;
4311 /* Create SNOW 3G session */
4312 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4313 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4314 RTE_CRYPTO_AUTH_OP_GENERATE,
4315 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4316 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4317 tdata->key.data, tdata->key.len,
4318 tdata->auth_iv.len, tdata->digest.len,
4319 tdata->cipher_iv.len);
4323 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4325 /* clear mbuf payload */
4326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4327 rte_pktmbuf_tailroom(ut_params->ibuf));
4329 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4330 /* Append data which is padded to a multiple of */
4331 /* the algorithms block size */
4332 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4335 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4337 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4339 /* Create SNOW 3G operation */
4340 retval = create_wireless_algo_auth_cipher_operation(
4342 tdata->cipher_iv.data, tdata->cipher_iv.len,
4343 tdata->auth_iv.data, tdata->auth_iv.len,
4345 tdata->validCipherLenInBits.len,
4347 tdata->validAuthLenInBits.len,
4353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4356 ut_params->obuf = ut_params->op->sym->m_src;
4357 if (ut_params->obuf)
4358 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4360 ciphertext = plaintext;
4362 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4363 + plaintext_pad_len;
4364 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4367 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4369 tdata->ciphertext.data,
4370 tdata->validDataLenInBits.len,
4371 "SNOW 3G Ciphertext data not as expected");
4374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4377 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4378 "SNOW 3G Generated auth tag not as expected");
4383 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4385 struct crypto_testsuite_params *ts_params = &testsuite_params;
4386 struct crypto_unittest_params *ut_params = &unittest_params;
4390 uint8_t *plaintext, *ciphertext;
4391 unsigned plaintext_pad_len;
4392 unsigned plaintext_len;
4394 /* Create KASUMI session */
4395 retval = create_wireless_algo_auth_cipher_session(
4396 ts_params->valid_devs[0],
4397 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4398 RTE_CRYPTO_AUTH_OP_GENERATE,
4399 RTE_CRYPTO_AUTH_KASUMI_F9,
4400 RTE_CRYPTO_CIPHER_KASUMI_F8,
4401 tdata->key.data, tdata->key.len,
4402 0, tdata->digest.len,
4403 tdata->cipher_iv.len);
4406 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4408 /* clear mbuf payload */
4409 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4410 rte_pktmbuf_tailroom(ut_params->ibuf));
4412 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4413 /* Append data which is padded to a multiple of */
4414 /* the algorithms block size */
4415 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4416 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4418 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4420 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4422 /* Create KASUMI operation */
4423 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4424 tdata->cipher_iv.data, tdata->cipher_iv.len,
4427 tdata->validCipherLenInBits.len,
4428 tdata->validCipherOffsetInBits.len,
4429 tdata->validAuthLenInBits.len,
4436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4439 if (ut_params->op->sym->m_dst)
4440 ut_params->obuf = ut_params->op->sym->m_dst;
4442 ut_params->obuf = ut_params->op->sym->m_src;
4444 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4445 tdata->validCipherOffsetInBits.len >> 3);
4447 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4448 (tdata->validCipherOffsetInBits.len >> 3);
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4452 reference_ciphertext,
4453 tdata->validCipherLenInBits.len,
4454 "KASUMI Ciphertext data not as expected");
4455 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4456 + plaintext_pad_len;
4459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4462 DIGEST_BYTE_LENGTH_KASUMI_F9,
4463 "KASUMI Generated auth tag not as expected");
4468 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4470 struct crypto_testsuite_params *ts_params = &testsuite_params;
4471 struct crypto_unittest_params *ut_params = &unittest_params;
4475 uint8_t *plaintext, *ciphertext;
4476 unsigned plaintext_pad_len;
4477 unsigned plaintext_len;
4479 /* Create KASUMI session */
4480 retval = create_wireless_algo_cipher_auth_session(
4481 ts_params->valid_devs[0],
4482 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4483 RTE_CRYPTO_AUTH_OP_GENERATE,
4484 RTE_CRYPTO_AUTH_KASUMI_F9,
4485 RTE_CRYPTO_CIPHER_KASUMI_F8,
4486 tdata->key.data, tdata->key.len,
4487 0, tdata->digest.len,
4488 tdata->cipher_iv.len);
4492 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4494 /* clear mbuf payload */
4495 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4496 rte_pktmbuf_tailroom(ut_params->ibuf));
4498 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4499 /* Append data which is padded to a multiple of */
4500 /* the algorithms block size */
4501 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4502 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4504 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4506 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4508 /* Create KASUMI operation */
4509 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4510 tdata->digest.len, NULL, 0,
4511 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4512 tdata->cipher_iv.data, tdata->cipher_iv.len,
4513 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4514 tdata->validCipherOffsetInBits.len,
4515 tdata->validAuthLenInBits.len,
4521 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4525 if (ut_params->op->sym->m_dst)
4526 ut_params->obuf = ut_params->op->sym->m_dst;
4528 ut_params->obuf = ut_params->op->sym->m_src;
4530 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4531 tdata->validCipherOffsetInBits.len >> 3);
4533 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4534 + plaintext_pad_len;
4536 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4537 (tdata->validCipherOffsetInBits.len >> 3);
4539 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4541 reference_ciphertext,
4542 tdata->validCipherLenInBits.len,
4543 "KASUMI Ciphertext data not as expected");
4546 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4549 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4550 "KASUMI Generated auth tag not as expected");
4555 test_zuc_encryption(const struct wireless_test_data *tdata)
4557 struct crypto_testsuite_params *ts_params = &testsuite_params;
4558 struct crypto_unittest_params *ut_params = &unittest_params;
4561 uint8_t *plaintext, *ciphertext;
4562 unsigned plaintext_pad_len;
4563 unsigned plaintext_len;
4565 struct rte_cryptodev_sym_capability_idx cap_idx;
4567 /* Check if device supports ZUC EEA3 */
4568 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4569 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4571 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4575 /* Create ZUC session */
4576 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4577 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4578 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4579 tdata->key.data, tdata->key.len,
4580 tdata->cipher_iv.len);
4584 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4586 /* Clear mbuf payload */
4587 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4588 rte_pktmbuf_tailroom(ut_params->ibuf));
4590 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4591 /* Append data which is padded to a multiple */
4592 /* of the algorithms block size */
4593 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4594 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4596 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4598 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4600 /* Create ZUC operation */
4601 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4602 tdata->cipher_iv.len,
4603 tdata->plaintext.len,
4608 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4610 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4612 ut_params->obuf = ut_params->op->sym->m_dst;
4613 if (ut_params->obuf)
4614 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4616 ciphertext = plaintext;
4618 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4621 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4623 tdata->ciphertext.data,
4624 tdata->validCipherLenInBits.len,
4625 "ZUC Ciphertext data not as expected");
4630 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4632 struct crypto_testsuite_params *ts_params = &testsuite_params;
4633 struct crypto_unittest_params *ut_params = &unittest_params;
4637 unsigned int plaintext_pad_len;
4638 unsigned int plaintext_len;
4639 const uint8_t *ciphertext;
4640 uint8_t ciphertext_buffer[2048];
4641 struct rte_cryptodev_info dev_info;
4643 struct rte_cryptodev_sym_capability_idx cap_idx;
4645 /* Check if device supports ZUC EEA3 */
4646 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4647 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4649 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4653 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4655 uint64_t feat_flags = dev_info.feature_flags;
4657 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4658 printf("Device doesn't support in-place scatter-gather. "
4663 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4665 /* Append data which is padded to a multiple */
4666 /* of the algorithms block size */
4667 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4669 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4670 plaintext_pad_len, 10, 0);
4672 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4673 tdata->plaintext.data);
4675 /* Create ZUC session */
4676 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4677 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4678 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4679 tdata->key.data, tdata->key.len,
4680 tdata->cipher_iv.len);
4684 /* Clear mbuf payload */
4686 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4688 /* Create ZUC operation */
4689 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4690 tdata->cipher_iv.len, tdata->plaintext.len,
4695 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4697 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4699 ut_params->obuf = ut_params->op->sym->m_dst;
4700 if (ut_params->obuf)
4701 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4702 0, plaintext_len, ciphertext_buffer);
4704 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4705 0, plaintext_len, ciphertext_buffer);
4708 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4711 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4713 tdata->ciphertext.data,
4714 tdata->validCipherLenInBits.len,
4715 "ZUC Ciphertext data not as expected");
4721 test_zuc_authentication(const struct wireless_test_data *tdata)
4723 struct crypto_testsuite_params *ts_params = &testsuite_params;
4724 struct crypto_unittest_params *ut_params = &unittest_params;
4727 unsigned plaintext_pad_len;
4728 unsigned plaintext_len;
4731 struct rte_cryptodev_sym_capability_idx cap_idx;
4733 /* Check if device supports ZUC EIA3 */
4734 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4735 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4741 /* Create ZUC session */
4742 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4743 tdata->key.data, tdata->key.len,
4744 tdata->auth_iv.len, tdata->digest.len,
4745 RTE_CRYPTO_AUTH_OP_GENERATE,
4746 RTE_CRYPTO_AUTH_ZUC_EIA3);
4750 /* alloc mbuf and set payload */
4751 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4753 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4754 rte_pktmbuf_tailroom(ut_params->ibuf));
4756 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4757 /* Append data which is padded to a multiple of */
4758 /* the algorithms block size */
4759 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4760 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4762 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4764 /* Create ZUC operation */
4765 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4766 tdata->auth_iv.data, tdata->auth_iv.len,
4767 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4768 tdata->validAuthLenInBits.len,
4773 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4775 ut_params->obuf = ut_params->op->sym->m_src;
4776 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4777 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4778 + plaintext_pad_len;
4781 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4784 DIGEST_BYTE_LENGTH_KASUMI_F9,
4785 "ZUC Generated auth tag not as expected");
4791 test_kasumi_encryption_test_case_1(void)
4793 return test_kasumi_encryption(&kasumi_test_case_1);
4797 test_kasumi_encryption_test_case_1_sgl(void)
4799 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4803 test_kasumi_encryption_test_case_1_oop(void)
4805 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4809 test_kasumi_encryption_test_case_1_oop_sgl(void)
4811 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4815 test_kasumi_encryption_test_case_2(void)
4817 return test_kasumi_encryption(&kasumi_test_case_2);
4821 test_kasumi_encryption_test_case_3(void)
4823 return test_kasumi_encryption(&kasumi_test_case_3);
4827 test_kasumi_encryption_test_case_4(void)
4829 return test_kasumi_encryption(&kasumi_test_case_4);
4833 test_kasumi_encryption_test_case_5(void)
4835 return test_kasumi_encryption(&kasumi_test_case_5);
4839 test_kasumi_decryption_test_case_1(void)
4841 return test_kasumi_decryption(&kasumi_test_case_1);
4845 test_kasumi_decryption_test_case_1_oop(void)
4847 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4851 test_kasumi_decryption_test_case_2(void)
4853 return test_kasumi_decryption(&kasumi_test_case_2);
4857 test_kasumi_decryption_test_case_3(void)
4859 return test_kasumi_decryption(&kasumi_test_case_3);
4863 test_kasumi_decryption_test_case_4(void)
4865 return test_kasumi_decryption(&kasumi_test_case_4);
4869 test_kasumi_decryption_test_case_5(void)
4871 return test_kasumi_decryption(&kasumi_test_case_5);
4874 test_snow3g_encryption_test_case_1(void)
4876 return test_snow3g_encryption(&snow3g_test_case_1);
4880 test_snow3g_encryption_test_case_1_oop(void)
4882 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4886 test_snow3g_encryption_test_case_1_oop_sgl(void)
4888 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4893 test_snow3g_encryption_test_case_1_offset_oop(void)
4895 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4899 test_snow3g_encryption_test_case_2(void)
4901 return test_snow3g_encryption(&snow3g_test_case_2);
4905 test_snow3g_encryption_test_case_3(void)
4907 return test_snow3g_encryption(&snow3g_test_case_3);
4911 test_snow3g_encryption_test_case_4(void)
4913 return test_snow3g_encryption(&snow3g_test_case_4);
4917 test_snow3g_encryption_test_case_5(void)
4919 return test_snow3g_encryption(&snow3g_test_case_5);
4923 test_snow3g_decryption_test_case_1(void)
4925 return test_snow3g_decryption(&snow3g_test_case_1);
4929 test_snow3g_decryption_test_case_1_oop(void)
4931 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4935 test_snow3g_decryption_test_case_2(void)
4937 return test_snow3g_decryption(&snow3g_test_case_2);
4941 test_snow3g_decryption_test_case_3(void)
4943 return test_snow3g_decryption(&snow3g_test_case_3);
4947 test_snow3g_decryption_test_case_4(void)
4949 return test_snow3g_decryption(&snow3g_test_case_4);
4953 test_snow3g_decryption_test_case_5(void)
4955 return test_snow3g_decryption(&snow3g_test_case_5);
4958 test_snow3g_cipher_auth_test_case_1(void)
4960 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4964 test_snow3g_auth_cipher_test_case_1(void)
4966 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4970 test_kasumi_auth_cipher_test_case_1(void)
4972 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4976 test_kasumi_cipher_auth_test_case_1(void)
4978 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4982 test_zuc_encryption_test_case_1(void)
4984 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4988 test_zuc_encryption_test_case_2(void)
4990 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4994 test_zuc_encryption_test_case_3(void)
4996 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5000 test_zuc_encryption_test_case_4(void)
5002 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5006 test_zuc_encryption_test_case_5(void)
5008 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5012 test_zuc_encryption_test_case_6_sgl(void)
5014 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5018 test_zuc_hash_generate_test_case_1(void)
5020 return test_zuc_authentication(&zuc_test_case_auth_1b);
5024 test_zuc_hash_generate_test_case_2(void)
5026 return test_zuc_authentication(&zuc_test_case_auth_90b);
5030 test_zuc_hash_generate_test_case_3(void)
5032 return test_zuc_authentication(&zuc_test_case_auth_577b);
5036 test_zuc_hash_generate_test_case_4(void)
5038 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5042 test_zuc_hash_generate_test_case_5(void)
5044 return test_zuc_authentication(&zuc_test_auth_5670b);
5048 test_zuc_hash_generate_test_case_6(void)
5050 return test_zuc_authentication(&zuc_test_case_auth_128b);
5054 test_zuc_hash_generate_test_case_7(void)
5056 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5060 test_zuc_hash_generate_test_case_8(void)
5062 return test_zuc_authentication(&zuc_test_case_auth_584b);
5066 test_zuc_cipher_auth_test_case_1(void)
5068 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5072 test_zuc_cipher_auth_test_case_2(void)
5074 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5078 test_3DES_chain_qat_all(void)
5080 struct crypto_testsuite_params *ts_params = &testsuite_params;
5083 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5084 ts_params->op_mpool,
5085 ts_params->session_mpool,
5086 ts_params->valid_devs[0],
5087 rte_cryptodev_driver_id_get(
5088 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5089 BLKCIPHER_3DES_CHAIN_TYPE);
5091 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5093 return TEST_SUCCESS;
5097 test_DES_cipheronly_qat_all(void)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5102 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5103 ts_params->op_mpool,
5104 ts_params->session_mpool,
5105 ts_params->valid_devs[0],
5106 rte_cryptodev_driver_id_get(
5107 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5108 BLKCIPHER_DES_CIPHERONLY_TYPE);
5110 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5112 return TEST_SUCCESS;
5116 test_DES_cipheronly_openssl_all(void)
5118 struct crypto_testsuite_params *ts_params = &testsuite_params;
5121 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5122 ts_params->op_mpool,
5123 ts_params->session_mpool,
5124 ts_params->valid_devs[0],
5125 rte_cryptodev_driver_id_get(
5126 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5127 BLKCIPHER_DES_CIPHERONLY_TYPE);
5129 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5131 return TEST_SUCCESS;
5135 test_DES_docsis_openssl_all(void)
5137 struct crypto_testsuite_params *ts_params = &testsuite_params;
5140 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5141 ts_params->op_mpool,
5142 ts_params->session_mpool,
5143 ts_params->valid_devs[0],
5144 rte_cryptodev_driver_id_get(
5145 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5146 BLKCIPHER_DES_DOCSIS_TYPE);
5148 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5150 return TEST_SUCCESS;
5154 test_DES_cipheronly_mb_all(void)
5156 struct crypto_testsuite_params *ts_params = &testsuite_params;
5159 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5160 ts_params->op_mpool,
5161 ts_params->session_mpool,
5162 ts_params->valid_devs[0],
5163 rte_cryptodev_driver_id_get(
5164 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5165 BLKCIPHER_DES_CIPHERONLY_TYPE);
5167 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5169 return TEST_SUCCESS;
5172 test_3DES_cipheronly_mb_all(void)
5174 struct crypto_testsuite_params *ts_params = &testsuite_params;
5177 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5178 ts_params->op_mpool,
5179 ts_params->session_mpool,
5180 ts_params->valid_devs[0],
5181 rte_cryptodev_driver_id_get(
5182 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5183 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5185 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5187 return TEST_SUCCESS;
5191 test_DES_docsis_mb_all(void)
5193 struct crypto_testsuite_params *ts_params = &testsuite_params;
5196 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5197 ts_params->op_mpool,
5198 ts_params->session_mpool,
5199 ts_params->valid_devs[0],
5200 rte_cryptodev_driver_id_get(
5201 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5202 BLKCIPHER_DES_DOCSIS_TYPE);
5204 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5206 return TEST_SUCCESS;
5210 test_3DES_chain_caam_jr_all(void)
5212 struct crypto_testsuite_params *ts_params = &testsuite_params;
5215 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5216 ts_params->op_mpool,
5217 ts_params->session_mpool,
5218 ts_params->valid_devs[0],
5219 rte_cryptodev_driver_id_get(
5220 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5221 BLKCIPHER_3DES_CHAIN_TYPE);
5223 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5225 return TEST_SUCCESS;
5229 test_3DES_cipheronly_caam_jr_all(void)
5231 struct crypto_testsuite_params *ts_params = &testsuite_params;
5234 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5235 ts_params->op_mpool,
5236 ts_params->session_mpool,
5237 ts_params->valid_devs[0],
5238 rte_cryptodev_driver_id_get(
5239 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5240 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5242 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5244 return TEST_SUCCESS;
5248 test_3DES_chain_dpaa_sec_all(void)
5250 struct crypto_testsuite_params *ts_params = &testsuite_params;
5253 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5254 ts_params->op_mpool,
5255 ts_params->session_mpool,
5256 ts_params->valid_devs[0],
5257 rte_cryptodev_driver_id_get(
5258 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5259 BLKCIPHER_3DES_CHAIN_TYPE);
5261 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5263 return TEST_SUCCESS;
5267 test_3DES_cipheronly_dpaa_sec_all(void)
5269 struct crypto_testsuite_params *ts_params = &testsuite_params;
5272 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5273 ts_params->op_mpool,
5274 ts_params->session_mpool,
5275 ts_params->valid_devs[0],
5276 rte_cryptodev_driver_id_get(
5277 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5278 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5280 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5282 return TEST_SUCCESS;
5286 test_3DES_chain_dpaa2_sec_all(void)
5288 struct crypto_testsuite_params *ts_params = &testsuite_params;
5291 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5292 ts_params->op_mpool,
5293 ts_params->session_mpool,
5294 ts_params->valid_devs[0],
5295 rte_cryptodev_driver_id_get(
5296 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5297 BLKCIPHER_3DES_CHAIN_TYPE);
5299 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5301 return TEST_SUCCESS;
5305 test_3DES_cipheronly_dpaa2_sec_all(void)
5307 struct crypto_testsuite_params *ts_params = &testsuite_params;
5310 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5311 ts_params->op_mpool,
5312 ts_params->session_mpool,
5313 ts_params->valid_devs[0],
5314 rte_cryptodev_driver_id_get(
5315 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5316 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5318 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5320 return TEST_SUCCESS;
5324 test_3DES_chain_ccp_all(void)
5326 struct crypto_testsuite_params *ts_params = &testsuite_params;
5329 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5330 ts_params->op_mpool,
5331 ts_params->session_mpool,
5332 ts_params->valid_devs[0],
5333 rte_cryptodev_driver_id_get(
5334 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5335 BLKCIPHER_3DES_CHAIN_TYPE);
5337 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5339 return TEST_SUCCESS;
5343 test_3DES_cipheronly_ccp_all(void)
5345 struct crypto_testsuite_params *ts_params = &testsuite_params;
5348 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5349 ts_params->op_mpool,
5350 ts_params->session_mpool,
5351 ts_params->valid_devs[0],
5352 rte_cryptodev_driver_id_get(
5353 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5354 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5356 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5358 return TEST_SUCCESS;
5362 test_3DES_cipheronly_qat_all(void)
5364 struct crypto_testsuite_params *ts_params = &testsuite_params;
5367 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5368 ts_params->op_mpool,
5369 ts_params->session_mpool,
5370 ts_params->valid_devs[0],
5371 rte_cryptodev_driver_id_get(
5372 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5373 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5375 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5377 return TEST_SUCCESS;
5381 test_3DES_chain_openssl_all(void)
5383 struct crypto_testsuite_params *ts_params = &testsuite_params;
5386 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5387 ts_params->op_mpool,
5388 ts_params->session_mpool,
5389 ts_params->valid_devs[0],
5390 rte_cryptodev_driver_id_get(
5391 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5392 BLKCIPHER_3DES_CHAIN_TYPE);
5394 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5396 return TEST_SUCCESS;
5400 test_3DES_cipheronly_openssl_all(void)
5402 struct crypto_testsuite_params *ts_params = &testsuite_params;
5405 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5406 ts_params->op_mpool,
5407 ts_params->session_mpool,
5408 ts_params->valid_devs[0],
5409 rte_cryptodev_driver_id_get(
5410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5411 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5413 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5415 return TEST_SUCCESS;
5418 /* ***** AEAD algorithm Tests ***** */
5421 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5422 enum rte_crypto_aead_operation op,
5423 const uint8_t *key, const uint8_t key_len,
5424 const uint16_t aad_len, const uint8_t auth_len,
5427 uint8_t aead_key[key_len];
5429 struct crypto_testsuite_params *ts_params = &testsuite_params;
5430 struct crypto_unittest_params *ut_params = &unittest_params;
5432 memcpy(aead_key, key, key_len);
5434 /* Setup AEAD Parameters */
5435 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5436 ut_params->aead_xform.next = NULL;
5437 ut_params->aead_xform.aead.algo = algo;
5438 ut_params->aead_xform.aead.op = op;
5439 ut_params->aead_xform.aead.key.data = aead_key;
5440 ut_params->aead_xform.aead.key.length = key_len;
5441 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5442 ut_params->aead_xform.aead.iv.length = iv_len;
5443 ut_params->aead_xform.aead.digest_length = auth_len;
5444 ut_params->aead_xform.aead.aad_length = aad_len;
5446 debug_hexdump(stdout, "key:", key, key_len);
5448 /* Create Crypto session*/
5449 ut_params->sess = rte_cryptodev_sym_session_create(
5450 ts_params->session_mpool);
5452 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5453 &ut_params->aead_xform, ts_params->session_mpool);
5455 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5461 create_aead_xform(struct rte_crypto_op *op,
5462 enum rte_crypto_aead_algorithm algo,
5463 enum rte_crypto_aead_operation aead_op,
5464 uint8_t *key, const uint8_t key_len,
5465 const uint8_t aad_len, const uint8_t auth_len,
5468 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5469 "failed to allocate space for crypto transform");
5471 struct rte_crypto_sym_op *sym_op = op->sym;
5473 /* Setup AEAD Parameters */
5474 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5475 sym_op->xform->next = NULL;
5476 sym_op->xform->aead.algo = algo;
5477 sym_op->xform->aead.op = aead_op;
5478 sym_op->xform->aead.key.data = key;
5479 sym_op->xform->aead.key.length = key_len;
5480 sym_op->xform->aead.iv.offset = IV_OFFSET;
5481 sym_op->xform->aead.iv.length = iv_len;
5482 sym_op->xform->aead.digest_length = auth_len;
5483 sym_op->xform->aead.aad_length = aad_len;
5485 debug_hexdump(stdout, "key:", key, key_len);
5491 create_aead_operation(enum rte_crypto_aead_operation op,
5492 const struct aead_test_data *tdata)
5494 struct crypto_testsuite_params *ts_params = &testsuite_params;
5495 struct crypto_unittest_params *ut_params = &unittest_params;
5497 uint8_t *plaintext, *ciphertext;
5498 unsigned int aad_pad_len, plaintext_pad_len;
5500 /* Generate Crypto op data structure */
5501 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5502 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5503 TEST_ASSERT_NOT_NULL(ut_params->op,
5504 "Failed to allocate symmetric crypto operation struct");
5506 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5508 /* Append aad data */
5509 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5510 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5511 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5513 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5514 "no room to append aad");
5516 sym_op->aead.aad.phys_addr =
5517 rte_pktmbuf_iova(ut_params->ibuf);
5518 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5519 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5520 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5523 /* Append IV at the end of the crypto operation*/
5524 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5525 uint8_t *, IV_OFFSET);
5527 /* Copy IV 1 byte after the IV pointer, according to the API */
5528 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5529 debug_hexdump(stdout, "iv:", iv_ptr,
5532 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5533 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5535 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5536 "no room to append aad");
5538 sym_op->aead.aad.phys_addr =
5539 rte_pktmbuf_iova(ut_params->ibuf);
5540 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5541 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5544 /* Append IV at the end of the crypto operation*/
5545 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5546 uint8_t *, IV_OFFSET);
5548 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5549 debug_hexdump(stdout, "iv:", iv_ptr,
5553 /* Append plaintext/ciphertext */
5554 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5555 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5556 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5558 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5560 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5561 debug_hexdump(stdout, "plaintext:", plaintext,
5562 tdata->plaintext.len);
5564 if (ut_params->obuf) {
5565 ciphertext = (uint8_t *)rte_pktmbuf_append(
5567 plaintext_pad_len + aad_pad_len);
5568 TEST_ASSERT_NOT_NULL(ciphertext,
5569 "no room to append ciphertext");
5571 memset(ciphertext + aad_pad_len, 0,
5572 tdata->ciphertext.len);
5575 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5576 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5578 TEST_ASSERT_NOT_NULL(ciphertext,
5579 "no room to append ciphertext");
5581 memcpy(ciphertext, tdata->ciphertext.data,
5582 tdata->ciphertext.len);
5583 debug_hexdump(stdout, "ciphertext:", ciphertext,
5584 tdata->ciphertext.len);
5586 if (ut_params->obuf) {
5587 plaintext = (uint8_t *)rte_pktmbuf_append(
5589 plaintext_pad_len + aad_pad_len);
5590 TEST_ASSERT_NOT_NULL(plaintext,
5591 "no room to append plaintext");
5593 memset(plaintext + aad_pad_len, 0,
5594 tdata->plaintext.len);
5598 /* Append digest data */
5599 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5600 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5601 ut_params->obuf ? ut_params->obuf :
5603 tdata->auth_tag.len);
5604 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5605 "no room to append digest");
5606 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5607 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5608 ut_params->obuf ? ut_params->obuf :
5613 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5614 ut_params->ibuf, tdata->auth_tag.len);
5615 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5616 "no room to append digest");
5617 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5619 plaintext_pad_len + aad_pad_len);
5621 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5622 tdata->auth_tag.len);
5623 debug_hexdump(stdout, "digest:",
5624 sym_op->aead.digest.data,
5625 tdata->auth_tag.len);
5628 sym_op->aead.data.length = tdata->plaintext.len;
5629 sym_op->aead.data.offset = aad_pad_len;
5635 test_authenticated_encryption(const struct aead_test_data *tdata)
5637 struct crypto_testsuite_params *ts_params = &testsuite_params;
5638 struct crypto_unittest_params *ut_params = &unittest_params;
5641 uint8_t *ciphertext, *auth_tag;
5642 uint16_t plaintext_pad_len;
5645 /* Create AEAD session */
5646 retval = create_aead_session(ts_params->valid_devs[0],
5648 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5649 tdata->key.data, tdata->key.len,
5650 tdata->aad.len, tdata->auth_tag.len,
5655 if (tdata->aad.len > MBUF_SIZE) {
5656 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5657 /* Populate full size of add data */
5658 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5659 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5661 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5663 /* clear mbuf payload */
5664 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5665 rte_pktmbuf_tailroom(ut_params->ibuf));
5667 /* Create AEAD operation */
5668 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5672 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5674 ut_params->op->sym->m_src = ut_params->ibuf;
5676 /* Process crypto operation */
5677 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5678 ut_params->op), "failed to process sym crypto op");
5680 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5681 "crypto op processing failed");
5683 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5685 if (ut_params->op->sym->m_dst) {
5686 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5688 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5689 uint8_t *, plaintext_pad_len);
5691 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5693 ut_params->op->sym->cipher.data.offset);
5694 auth_tag = ciphertext + plaintext_pad_len;
5697 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5698 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5703 tdata->ciphertext.data,
5704 tdata->ciphertext.len,
5705 "Ciphertext data not as expected");
5707 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5709 tdata->auth_tag.data,
5710 tdata->auth_tag.len,
5711 "Generated auth tag not as expected");
5718 test_AES_GCM_authenticated_encryption_test_case_1(void)
5720 return test_authenticated_encryption(&gcm_test_case_1);
5724 test_AES_GCM_authenticated_encryption_test_case_2(void)
5726 return test_authenticated_encryption(&gcm_test_case_2);
5730 test_AES_GCM_authenticated_encryption_test_case_3(void)
5732 return test_authenticated_encryption(&gcm_test_case_3);
5736 test_AES_GCM_authenticated_encryption_test_case_4(void)
5738 return test_authenticated_encryption(&gcm_test_case_4);
5742 test_AES_GCM_authenticated_encryption_test_case_5(void)
5744 return test_authenticated_encryption(&gcm_test_case_5);
5748 test_AES_GCM_authenticated_encryption_test_case_6(void)
5750 return test_authenticated_encryption(&gcm_test_case_6);
5754 test_AES_GCM_authenticated_encryption_test_case_7(void)
5756 return test_authenticated_encryption(&gcm_test_case_7);
5760 test_AES_GCM_auth_encryption_test_case_192_1(void)
5762 return test_authenticated_encryption(&gcm_test_case_192_1);
5766 test_AES_GCM_auth_encryption_test_case_192_2(void)
5768 return test_authenticated_encryption(&gcm_test_case_192_2);
5772 test_AES_GCM_auth_encryption_test_case_192_3(void)
5774 return test_authenticated_encryption(&gcm_test_case_192_3);
5778 test_AES_GCM_auth_encryption_test_case_192_4(void)
5780 return test_authenticated_encryption(&gcm_test_case_192_4);
5784 test_AES_GCM_auth_encryption_test_case_192_5(void)
5786 return test_authenticated_encryption(&gcm_test_case_192_5);
5790 test_AES_GCM_auth_encryption_test_case_192_6(void)
5792 return test_authenticated_encryption(&gcm_test_case_192_6);
5796 test_AES_GCM_auth_encryption_test_case_192_7(void)
5798 return test_authenticated_encryption(&gcm_test_case_192_7);
5802 test_AES_GCM_auth_encryption_test_case_256_1(void)
5804 return test_authenticated_encryption(&gcm_test_case_256_1);
5808 test_AES_GCM_auth_encryption_test_case_256_2(void)
5810 return test_authenticated_encryption(&gcm_test_case_256_2);
5814 test_AES_GCM_auth_encryption_test_case_256_3(void)
5816 return test_authenticated_encryption(&gcm_test_case_256_3);
5820 test_AES_GCM_auth_encryption_test_case_256_4(void)
5822 return test_authenticated_encryption(&gcm_test_case_256_4);
5826 test_AES_GCM_auth_encryption_test_case_256_5(void)
5828 return test_authenticated_encryption(&gcm_test_case_256_5);
5832 test_AES_GCM_auth_encryption_test_case_256_6(void)
5834 return test_authenticated_encryption(&gcm_test_case_256_6);
5838 test_AES_GCM_auth_encryption_test_case_256_7(void)
5840 return test_authenticated_encryption(&gcm_test_case_256_7);
5844 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5846 return test_authenticated_encryption(&gcm_test_case_aad_1);
5850 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5852 return test_authenticated_encryption(&gcm_test_case_aad_2);
5856 test_authenticated_decryption(const struct aead_test_data *tdata)
5858 struct crypto_testsuite_params *ts_params = &testsuite_params;
5859 struct crypto_unittest_params *ut_params = &unittest_params;
5865 /* Create AEAD session */
5866 retval = create_aead_session(ts_params->valid_devs[0],
5868 RTE_CRYPTO_AEAD_OP_DECRYPT,
5869 tdata->key.data, tdata->key.len,
5870 tdata->aad.len, tdata->auth_tag.len,
5875 /* alloc mbuf and set payload */
5876 if (tdata->aad.len > MBUF_SIZE) {
5877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5878 /* Populate full size of add data */
5879 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5880 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5882 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5884 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5885 rte_pktmbuf_tailroom(ut_params->ibuf));
5887 /* Create AEAD operation */
5888 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5892 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5894 ut_params->op->sym->m_src = ut_params->ibuf;
5896 /* Process crypto operation */
5897 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5898 ut_params->op), "failed to process sym crypto op");
5900 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5901 "crypto op processing failed");
5903 if (ut_params->op->sym->m_dst)
5904 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5907 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5909 ut_params->op->sym->cipher.data.offset);
5911 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5914 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5916 tdata->plaintext.data,
5917 tdata->plaintext.len,
5918 "Plaintext data not as expected");
5920 TEST_ASSERT_EQUAL(ut_params->op->status,
5921 RTE_CRYPTO_OP_STATUS_SUCCESS,
5922 "Authentication failed");
5927 test_AES_GCM_authenticated_decryption_test_case_1(void)
5929 return test_authenticated_decryption(&gcm_test_case_1);
5933 test_AES_GCM_authenticated_decryption_test_case_2(void)
5935 return test_authenticated_decryption(&gcm_test_case_2);
5939 test_AES_GCM_authenticated_decryption_test_case_3(void)
5941 return test_authenticated_decryption(&gcm_test_case_3);
5945 test_AES_GCM_authenticated_decryption_test_case_4(void)
5947 return test_authenticated_decryption(&gcm_test_case_4);
5951 test_AES_GCM_authenticated_decryption_test_case_5(void)
5953 return test_authenticated_decryption(&gcm_test_case_5);
5957 test_AES_GCM_authenticated_decryption_test_case_6(void)
5959 return test_authenticated_decryption(&gcm_test_case_6);
5963 test_AES_GCM_authenticated_decryption_test_case_7(void)
5965 return test_authenticated_decryption(&gcm_test_case_7);
5969 test_AES_GCM_auth_decryption_test_case_192_1(void)
5971 return test_authenticated_decryption(&gcm_test_case_192_1);
5975 test_AES_GCM_auth_decryption_test_case_192_2(void)
5977 return test_authenticated_decryption(&gcm_test_case_192_2);
5981 test_AES_GCM_auth_decryption_test_case_192_3(void)
5983 return test_authenticated_decryption(&gcm_test_case_192_3);
5987 test_AES_GCM_auth_decryption_test_case_192_4(void)
5989 return test_authenticated_decryption(&gcm_test_case_192_4);
5993 test_AES_GCM_auth_decryption_test_case_192_5(void)
5995 return test_authenticated_decryption(&gcm_test_case_192_5);
5999 test_AES_GCM_auth_decryption_test_case_192_6(void)
6001 return test_authenticated_decryption(&gcm_test_case_192_6);
6005 test_AES_GCM_auth_decryption_test_case_192_7(void)
6007 return test_authenticated_decryption(&gcm_test_case_192_7);
6011 test_AES_GCM_auth_decryption_test_case_256_1(void)
6013 return test_authenticated_decryption(&gcm_test_case_256_1);
6017 test_AES_GCM_auth_decryption_test_case_256_2(void)
6019 return test_authenticated_decryption(&gcm_test_case_256_2);
6023 test_AES_GCM_auth_decryption_test_case_256_3(void)
6025 return test_authenticated_decryption(&gcm_test_case_256_3);
6029 test_AES_GCM_auth_decryption_test_case_256_4(void)
6031 return test_authenticated_decryption(&gcm_test_case_256_4);
6035 test_AES_GCM_auth_decryption_test_case_256_5(void)
6037 return test_authenticated_decryption(&gcm_test_case_256_5);
6041 test_AES_GCM_auth_decryption_test_case_256_6(void)
6043 return test_authenticated_decryption(&gcm_test_case_256_6);
6047 test_AES_GCM_auth_decryption_test_case_256_7(void)
6049 return test_authenticated_decryption(&gcm_test_case_256_7);
6053 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6055 return test_authenticated_decryption(&gcm_test_case_aad_1);
6059 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6061 return test_authenticated_decryption(&gcm_test_case_aad_2);
6065 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6067 struct crypto_testsuite_params *ts_params = &testsuite_params;
6068 struct crypto_unittest_params *ut_params = &unittest_params;
6071 uint8_t *ciphertext, *auth_tag;
6072 uint16_t plaintext_pad_len;
6074 /* Create AEAD session */
6075 retval = create_aead_session(ts_params->valid_devs[0],
6077 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6078 tdata->key.data, tdata->key.len,
6079 tdata->aad.len, tdata->auth_tag.len,
6084 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6085 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6087 /* clear mbuf payload */
6088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6089 rte_pktmbuf_tailroom(ut_params->ibuf));
6090 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6091 rte_pktmbuf_tailroom(ut_params->obuf));
6093 /* Create AEAD operation */
6094 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6100 ut_params->op->sym->m_src = ut_params->ibuf;
6101 ut_params->op->sym->m_dst = ut_params->obuf;
6103 /* Process crypto operation */
6104 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6105 ut_params->op), "failed to process sym crypto op");
6107 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6108 "crypto op processing failed");
6110 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6112 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6113 ut_params->op->sym->cipher.data.offset);
6114 auth_tag = ciphertext + plaintext_pad_len;
6116 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6117 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6122 tdata->ciphertext.data,
6123 tdata->ciphertext.len,
6124 "Ciphertext data not as expected");
6126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6128 tdata->auth_tag.data,
6129 tdata->auth_tag.len,
6130 "Generated auth tag not as expected");
6137 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6139 return test_authenticated_encryption_oop(&gcm_test_case_5);
6143 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6145 struct crypto_testsuite_params *ts_params = &testsuite_params;
6146 struct crypto_unittest_params *ut_params = &unittest_params;
6151 /* Create AEAD session */
6152 retval = create_aead_session(ts_params->valid_devs[0],
6154 RTE_CRYPTO_AEAD_OP_DECRYPT,
6155 tdata->key.data, tdata->key.len,
6156 tdata->aad.len, tdata->auth_tag.len,
6161 /* alloc mbuf and set payload */
6162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6163 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6166 rte_pktmbuf_tailroom(ut_params->ibuf));
6167 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6168 rte_pktmbuf_tailroom(ut_params->obuf));
6170 /* Create AEAD operation */
6171 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6175 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6177 ut_params->op->sym->m_src = ut_params->ibuf;
6178 ut_params->op->sym->m_dst = ut_params->obuf;
6180 /* Process crypto operation */
6181 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6182 ut_params->op), "failed to process sym crypto op");
6184 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6185 "crypto op processing failed");
6187 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6188 ut_params->op->sym->cipher.data.offset);
6190 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6193 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6195 tdata->plaintext.data,
6196 tdata->plaintext.len,
6197 "Plaintext data not as expected");
6199 TEST_ASSERT_EQUAL(ut_params->op->status,
6200 RTE_CRYPTO_OP_STATUS_SUCCESS,
6201 "Authentication failed");
6206 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6208 return test_authenticated_decryption_oop(&gcm_test_case_5);
6212 test_authenticated_encryption_sessionless(
6213 const struct aead_test_data *tdata)
6215 struct crypto_testsuite_params *ts_params = &testsuite_params;
6216 struct crypto_unittest_params *ut_params = &unittest_params;
6219 uint8_t *ciphertext, *auth_tag;
6220 uint16_t plaintext_pad_len;
6221 uint8_t key[tdata->key.len + 1];
6223 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6225 /* clear mbuf payload */
6226 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6227 rte_pktmbuf_tailroom(ut_params->ibuf));
6229 /* Create AEAD operation */
6230 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6234 /* Create GCM xform */
6235 memcpy(key, tdata->key.data, tdata->key.len);
6236 retval = create_aead_xform(ut_params->op,
6238 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6239 key, tdata->key.len,
6240 tdata->aad.len, tdata->auth_tag.len,
6245 ut_params->op->sym->m_src = ut_params->ibuf;
6247 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6248 RTE_CRYPTO_OP_SESSIONLESS,
6249 "crypto op session type not sessionless");
6251 /* Process crypto operation */
6252 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6253 ut_params->op), "failed to process sym crypto op");
6255 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6257 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6258 "crypto op status not success");
6260 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6262 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6263 ut_params->op->sym->cipher.data.offset);
6264 auth_tag = ciphertext + plaintext_pad_len;
6266 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6267 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6270 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6272 tdata->ciphertext.data,
6273 tdata->ciphertext.len,
6274 "Ciphertext data not as expected");
6276 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6278 tdata->auth_tag.data,
6279 tdata->auth_tag.len,
6280 "Generated auth tag not as expected");
6287 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6289 return test_authenticated_encryption_sessionless(
6294 test_authenticated_decryption_sessionless(
6295 const struct aead_test_data *tdata)
6297 struct crypto_testsuite_params *ts_params = &testsuite_params;
6298 struct crypto_unittest_params *ut_params = &unittest_params;
6302 uint8_t key[tdata->key.len + 1];
6304 /* alloc mbuf and set payload */
6305 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6307 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6308 rte_pktmbuf_tailroom(ut_params->ibuf));
6310 /* Create AEAD operation */
6311 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6315 /* Create AEAD xform */
6316 memcpy(key, tdata->key.data, tdata->key.len);
6317 retval = create_aead_xform(ut_params->op,
6319 RTE_CRYPTO_AEAD_OP_DECRYPT,
6320 key, tdata->key.len,
6321 tdata->aad.len, tdata->auth_tag.len,
6326 ut_params->op->sym->m_src = ut_params->ibuf;
6328 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6329 RTE_CRYPTO_OP_SESSIONLESS,
6330 "crypto op session type not sessionless");
6332 /* Process crypto operation */
6333 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6334 ut_params->op), "failed to process sym crypto op");
6336 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6338 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6339 "crypto op status not success");
6341 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6342 ut_params->op->sym->cipher.data.offset);
6344 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6347 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6349 tdata->plaintext.data,
6350 tdata->plaintext.len,
6351 "Plaintext data not as expected");
6353 TEST_ASSERT_EQUAL(ut_params->op->status,
6354 RTE_CRYPTO_OP_STATUS_SUCCESS,
6355 "Authentication failed");
6360 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6362 return test_authenticated_decryption_sessionless(
6367 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6369 return test_authenticated_encryption(&ccm_test_case_128_1);
6373 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6375 return test_authenticated_encryption(&ccm_test_case_128_2);
6379 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6381 return test_authenticated_encryption(&ccm_test_case_128_3);
6385 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6387 return test_authenticated_decryption(&ccm_test_case_128_1);
6391 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6393 return test_authenticated_decryption(&ccm_test_case_128_2);
6397 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6399 return test_authenticated_decryption(&ccm_test_case_128_3);
6403 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6405 return test_authenticated_encryption(&ccm_test_case_192_1);
6409 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6411 return test_authenticated_encryption(&ccm_test_case_192_2);
6415 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6417 return test_authenticated_encryption(&ccm_test_case_192_3);
6421 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6423 return test_authenticated_decryption(&ccm_test_case_192_1);
6427 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6429 return test_authenticated_decryption(&ccm_test_case_192_2);
6433 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6435 return test_authenticated_decryption(&ccm_test_case_192_3);
6439 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6441 return test_authenticated_encryption(&ccm_test_case_256_1);
6445 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6447 return test_authenticated_encryption(&ccm_test_case_256_2);
6451 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6453 return test_authenticated_encryption(&ccm_test_case_256_3);
6457 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6459 return test_authenticated_decryption(&ccm_test_case_256_1);
6463 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6465 return test_authenticated_decryption(&ccm_test_case_256_2);
6469 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6471 return test_authenticated_decryption(&ccm_test_case_256_3);
6477 struct crypto_testsuite_params *ts_params = &testsuite_params;
6478 struct rte_cryptodev_stats stats;
6479 struct rte_cryptodev *dev;
6480 cryptodev_stats_get_t temp_pfn;
6482 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6483 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6484 &stats) == -ENODEV),
6485 "rte_cryptodev_stats_get invalid dev failed");
6486 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6487 "rte_cryptodev_stats_get invalid Param failed");
6488 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6489 temp_pfn = dev->dev_ops->stats_get;
6490 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6491 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6493 "rte_cryptodev_stats_get invalid Param failed");
6494 dev->dev_ops->stats_get = temp_pfn;
6496 /* Test expected values */
6498 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6500 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6502 "rte_cryptodev_stats_get failed");
6503 TEST_ASSERT((stats.enqueued_count == 1),
6504 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6505 TEST_ASSERT((stats.dequeued_count == 1),
6506 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6507 TEST_ASSERT((stats.enqueue_err_count == 0),
6508 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6509 TEST_ASSERT((stats.dequeue_err_count == 0),
6510 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6512 /* invalid device but should ignore and not reset device stats*/
6513 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6514 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6516 "rte_cryptodev_stats_get failed");
6517 TEST_ASSERT((stats.enqueued_count == 1),
6518 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6520 /* check that a valid reset clears stats */
6521 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6522 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6524 "rte_cryptodev_stats_get failed");
6525 TEST_ASSERT((stats.enqueued_count == 0),
6526 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6527 TEST_ASSERT((stats.dequeued_count == 0),
6528 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6530 return TEST_SUCCESS;
6533 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6534 struct crypto_unittest_params *ut_params,
6535 enum rte_crypto_auth_operation op,
6536 const struct HMAC_MD5_vector *test_case)
6540 memcpy(key, test_case->key.data, test_case->key.len);
6542 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6543 ut_params->auth_xform.next = NULL;
6544 ut_params->auth_xform.auth.op = op;
6546 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6548 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6549 ut_params->auth_xform.auth.key.length = test_case->key.len;
6550 ut_params->auth_xform.auth.key.data = key;
6552 ut_params->sess = rte_cryptodev_sym_session_create(
6553 ts_params->session_mpool);
6555 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6556 ut_params->sess, &ut_params->auth_xform,
6557 ts_params->session_mpool);
6559 if (ut_params->sess == NULL)
6562 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6564 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6565 rte_pktmbuf_tailroom(ut_params->ibuf));
6570 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6571 const struct HMAC_MD5_vector *test_case,
6572 uint8_t **plaintext)
6574 uint16_t plaintext_pad_len;
6576 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6578 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6581 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6583 memcpy(*plaintext, test_case->plaintext.data,
6584 test_case->plaintext.len);
6586 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6587 ut_params->ibuf, MD5_DIGEST_LEN);
6588 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6589 "no room to append digest");
6590 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6591 ut_params->ibuf, plaintext_pad_len);
6593 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6594 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6595 test_case->auth_tag.len);
6598 sym_op->auth.data.offset = 0;
6599 sym_op->auth.data.length = test_case->plaintext.len;
6601 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6602 ut_params->op->sym->m_src = ut_params->ibuf;
6608 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6610 uint16_t plaintext_pad_len;
6611 uint8_t *plaintext, *auth_tag;
6613 struct crypto_testsuite_params *ts_params = &testsuite_params;
6614 struct crypto_unittest_params *ut_params = &unittest_params;
6616 if (MD5_HMAC_create_session(ts_params, ut_params,
6617 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6620 /* Generate Crypto op data structure */
6621 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6622 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6623 TEST_ASSERT_NOT_NULL(ut_params->op,
6624 "Failed to allocate symmetric crypto operation struct");
6626 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6629 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6632 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6633 ut_params->op), "failed to process sym crypto op");
6635 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6636 "crypto op processing failed");
6638 if (ut_params->op->sym->m_dst) {
6639 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6640 uint8_t *, plaintext_pad_len);
6642 auth_tag = plaintext + plaintext_pad_len;
6645 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6647 test_case->auth_tag.data,
6648 test_case->auth_tag.len,
6649 "HMAC_MD5 generated tag not as expected");
6651 return TEST_SUCCESS;
6655 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6659 struct crypto_testsuite_params *ts_params = &testsuite_params;
6660 struct crypto_unittest_params *ut_params = &unittest_params;
6662 if (MD5_HMAC_create_session(ts_params, ut_params,
6663 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6667 /* Generate Crypto op data structure */
6668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6670 TEST_ASSERT_NOT_NULL(ut_params->op,
6671 "Failed to allocate symmetric crypto operation struct");
6673 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6676 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6677 ut_params->op), "failed to process sym crypto op");
6679 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6680 "HMAC_MD5 crypto op processing failed");
6682 return TEST_SUCCESS;
6686 test_MD5_HMAC_generate_case_1(void)
6688 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6692 test_MD5_HMAC_verify_case_1(void)
6694 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6698 test_MD5_HMAC_generate_case_2(void)
6700 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6704 test_MD5_HMAC_verify_case_2(void)
6706 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6710 test_multi_session(void)
6712 struct crypto_testsuite_params *ts_params = &testsuite_params;
6713 struct crypto_unittest_params *ut_params = &unittest_params;
6715 struct rte_cryptodev_info dev_info;
6716 struct rte_cryptodev_sym_session **sessions;
6720 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6721 aes_cbc_key, hmac_sha512_key);
6724 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6726 sessions = rte_malloc(NULL,
6727 (sizeof(struct rte_cryptodev_sym_session *) *
6728 MAX_NB_SESSIONS) + 1, 0);
6730 /* Create multiple crypto sessions*/
6731 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6733 sessions[i] = rte_cryptodev_sym_session_create(
6734 ts_params->session_mpool);
6736 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6737 sessions[i], &ut_params->auth_xform,
6738 ts_params->session_mpool);
6739 TEST_ASSERT_NOT_NULL(sessions[i],
6740 "Session creation failed at session number %u",
6743 /* Attempt to send a request on each session */
6744 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6748 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6749 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6751 "Failed to perform decrypt on request number %u.", i);
6752 /* free crypto operation structure */
6754 rte_crypto_op_free(ut_params->op);
6757 * free mbuf - both obuf and ibuf are usually the same,
6758 * so check if they point at the same address is necessary,
6759 * to avoid freeing the mbuf twice.
6761 if (ut_params->obuf) {
6762 rte_pktmbuf_free(ut_params->obuf);
6763 if (ut_params->ibuf == ut_params->obuf)
6764 ut_params->ibuf = 0;
6765 ut_params->obuf = 0;
6767 if (ut_params->ibuf) {
6768 rte_pktmbuf_free(ut_params->ibuf);
6769 ut_params->ibuf = 0;
6773 /* Next session create should fail */
6774 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6775 sessions[i], &ut_params->auth_xform,
6776 ts_params->session_mpool);
6777 TEST_ASSERT_NULL(sessions[i],
6778 "Session creation succeeded unexpectedly!");
6780 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6781 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6783 rte_cryptodev_sym_session_free(sessions[i]);
6788 return TEST_SUCCESS;
6791 struct multi_session_params {
6792 struct crypto_unittest_params ut_params;
6793 uint8_t *cipher_key;
6795 const uint8_t *cipher;
6796 const uint8_t *digest;
6800 #define MB_SESSION_NUMBER 3
6803 test_multi_session_random_usage(void)
6805 struct crypto_testsuite_params *ts_params = &testsuite_params;
6806 struct rte_cryptodev_info dev_info;
6807 struct rte_cryptodev_sym_session **sessions;
6809 struct multi_session_params ut_paramz[] = {
6812 .cipher_key = ms_aes_cbc_key0,
6813 .hmac_key = ms_hmac_key0,
6814 .cipher = ms_aes_cbc_cipher0,
6815 .digest = ms_hmac_digest0,
6816 .iv = ms_aes_cbc_iv0
6819 .cipher_key = ms_aes_cbc_key1,
6820 .hmac_key = ms_hmac_key1,
6821 .cipher = ms_aes_cbc_cipher1,
6822 .digest = ms_hmac_digest1,
6823 .iv = ms_aes_cbc_iv1
6826 .cipher_key = ms_aes_cbc_key2,
6827 .hmac_key = ms_hmac_key2,
6828 .cipher = ms_aes_cbc_cipher2,
6829 .digest = ms_hmac_digest2,
6830 .iv = ms_aes_cbc_iv2
6835 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6837 sessions = rte_malloc(NULL,
6838 (sizeof(struct rte_cryptodev_sym_session *)
6839 * MAX_NB_SESSIONS) + 1, 0);
6841 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6842 sessions[i] = rte_cryptodev_sym_session_create(
6843 ts_params->session_mpool);
6845 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6846 sizeof(struct crypto_unittest_params));
6848 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6849 &ut_paramz[i].ut_params,
6850 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6852 /* Create multiple crypto sessions*/
6853 rte_cryptodev_sym_session_init(
6854 ts_params->valid_devs[0],
6856 &ut_paramz[i].ut_params.auth_xform,
6857 ts_params->session_mpool);
6859 TEST_ASSERT_NOT_NULL(sessions[i],
6860 "Session creation failed at session number %u",
6866 for (i = 0; i < 40000; i++) {
6868 j = rand() % MB_SESSION_NUMBER;
6870 TEST_ASSERT_SUCCESS(
6871 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6873 &ut_paramz[j].ut_params,
6874 ts_params, ut_paramz[j].cipher,
6875 ut_paramz[j].digest,
6877 "Failed to perform decrypt on request number %u.", i);
6879 if (ut_paramz[j].ut_params.op)
6880 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6883 * free mbuf - both obuf and ibuf are usually the same,
6884 * so check if they point at the same address is necessary,
6885 * to avoid freeing the mbuf twice.
6887 if (ut_paramz[j].ut_params.obuf) {
6888 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6889 if (ut_paramz[j].ut_params.ibuf
6890 == ut_paramz[j].ut_params.obuf)
6891 ut_paramz[j].ut_params.ibuf = 0;
6892 ut_paramz[j].ut_params.obuf = 0;
6894 if (ut_paramz[j].ut_params.ibuf) {
6895 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6896 ut_paramz[j].ut_params.ibuf = 0;
6900 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6901 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6903 rte_cryptodev_sym_session_free(sessions[i]);
6908 return TEST_SUCCESS;
6912 test_null_cipher_only_operation(void)
6914 struct crypto_testsuite_params *ts_params = &testsuite_params;
6915 struct crypto_unittest_params *ut_params = &unittest_params;
6917 /* Generate test mbuf data and space for digest */
6918 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6919 catch_22_quote, QUOTE_512_BYTES, 0);
6921 /* Setup Cipher Parameters */
6922 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6923 ut_params->cipher_xform.next = NULL;
6925 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6926 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6928 ut_params->sess = rte_cryptodev_sym_session_create(
6929 ts_params->session_mpool);
6931 /* Create Crypto session*/
6932 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6934 &ut_params->cipher_xform,
6935 ts_params->session_mpool);
6936 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6938 /* Generate Crypto op data structure */
6939 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6940 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6941 TEST_ASSERT_NOT_NULL(ut_params->op,
6942 "Failed to allocate symmetric crypto operation struct");
6944 /* Set crypto operation data parameters */
6945 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6947 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6949 /* set crypto operation source mbuf */
6950 sym_op->m_src = ut_params->ibuf;
6952 sym_op->cipher.data.offset = 0;
6953 sym_op->cipher.data.length = QUOTE_512_BYTES;
6955 /* Process crypto operation */
6956 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6958 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6960 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6961 "crypto operation processing failed");
6964 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6965 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6968 "Ciphertext data not as expected");
6970 return TEST_SUCCESS;
6972 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6973 0xab, 0xab, 0xab, 0xab,
6974 0xab, 0xab, 0xab, 0xab,
6975 0xab, 0xab, 0xab, 0xab};
6977 test_null_auth_only_operation(void)
6979 struct crypto_testsuite_params *ts_params = &testsuite_params;
6980 struct crypto_unittest_params *ut_params = &unittest_params;
6983 /* Generate test mbuf data and space for digest */
6984 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6985 catch_22_quote, QUOTE_512_BYTES, 0);
6987 /* create a pointer for digest, but don't expect anything to be written
6988 * here in a NULL auth algo so no mbuf append done.
6990 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6992 /* prefill the memory pointed to by digest */
6993 memcpy(digest, orig_data, sizeof(orig_data));
6995 /* Setup HMAC Parameters */
6996 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6997 ut_params->auth_xform.next = NULL;
6999 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7000 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7002 ut_params->sess = rte_cryptodev_sym_session_create(
7003 ts_params->session_mpool);
7005 /* Create Crypto session*/
7006 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7007 ut_params->sess, &ut_params->auth_xform,
7008 ts_params->session_mpool);
7009 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7011 /* Generate Crypto op data structure */
7012 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7013 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7014 TEST_ASSERT_NOT_NULL(ut_params->op,
7015 "Failed to allocate symmetric crypto operation struct");
7017 /* Set crypto operation data parameters */
7018 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7020 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7022 sym_op->m_src = ut_params->ibuf;
7024 sym_op->auth.data.offset = 0;
7025 sym_op->auth.data.length = QUOTE_512_BYTES;
7026 sym_op->auth.digest.data = digest;
7027 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7030 /* Process crypto operation */
7031 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7033 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7035 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7036 "crypto operation processing failed");
7037 /* Make sure memory pointed to by digest hasn't been overwritten */
7038 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7042 "Memory at digest ptr overwritten unexpectedly");
7044 return TEST_SUCCESS;
7049 test_null_cipher_auth_operation(void)
7051 struct crypto_testsuite_params *ts_params = &testsuite_params;
7052 struct crypto_unittest_params *ut_params = &unittest_params;
7055 /* Generate test mbuf data and space for digest */
7056 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7057 catch_22_quote, QUOTE_512_BYTES, 0);
7059 /* create a pointer for digest, but don't expect anything to be written
7060 * here in a NULL auth algo so no mbuf append done.
7062 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7064 /* prefill the memory pointed to by digest */
7065 memcpy(digest, orig_data, sizeof(orig_data));
7067 /* Setup Cipher Parameters */
7068 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7069 ut_params->cipher_xform.next = &ut_params->auth_xform;
7071 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7072 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7074 /* Setup HMAC Parameters */
7075 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7076 ut_params->auth_xform.next = NULL;
7078 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7079 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7081 ut_params->sess = rte_cryptodev_sym_session_create(
7082 ts_params->session_mpool);
7084 /* Create Crypto session*/
7085 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7086 ut_params->sess, &ut_params->cipher_xform,
7087 ts_params->session_mpool);
7088 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7090 /* Generate Crypto op data structure */
7091 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7092 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7093 TEST_ASSERT_NOT_NULL(ut_params->op,
7094 "Failed to allocate symmetric crypto operation struct");
7096 /* Set crypto operation data parameters */
7097 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7099 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7101 sym_op->m_src = ut_params->ibuf;
7103 sym_op->cipher.data.offset = 0;
7104 sym_op->cipher.data.length = QUOTE_512_BYTES;
7106 sym_op->auth.data.offset = 0;
7107 sym_op->auth.data.length = QUOTE_512_BYTES;
7108 sym_op->auth.digest.data = digest;
7109 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7112 /* Process crypto operation */
7113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7115 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7117 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7118 "crypto operation processing failed");
7121 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7122 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7125 "Ciphertext data not as expected");
7126 /* Make sure memory pointed to by digest hasn't been overwritten */
7127 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7131 "Memory at digest ptr overwritten unexpectedly");
7133 return TEST_SUCCESS;
7137 test_null_auth_cipher_operation(void)
7139 struct crypto_testsuite_params *ts_params = &testsuite_params;
7140 struct crypto_unittest_params *ut_params = &unittest_params;
7143 /* Generate test mbuf data */
7144 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7145 catch_22_quote, QUOTE_512_BYTES, 0);
7147 /* create a pointer for digest, but don't expect anything to be written
7148 * here in a NULL auth algo so no mbuf append done.
7150 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7152 /* prefill the memory pointed to by digest */
7153 memcpy(digest, orig_data, sizeof(orig_data));
7155 /* Setup Cipher Parameters */
7156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7157 ut_params->cipher_xform.next = NULL;
7159 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7160 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7162 /* Setup HMAC Parameters */
7163 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7164 ut_params->auth_xform.next = &ut_params->cipher_xform;
7166 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7167 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7169 ut_params->sess = rte_cryptodev_sym_session_create(
7170 ts_params->session_mpool);
7172 /* Create Crypto session*/
7173 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7174 ut_params->sess, &ut_params->cipher_xform,
7175 ts_params->session_mpool);
7176 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7178 /* Generate Crypto op data structure */
7179 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7180 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7181 TEST_ASSERT_NOT_NULL(ut_params->op,
7182 "Failed to allocate symmetric crypto operation struct");
7184 /* Set crypto operation data parameters */
7185 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7187 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7189 sym_op->m_src = ut_params->ibuf;
7191 sym_op->cipher.data.offset = 0;
7192 sym_op->cipher.data.length = QUOTE_512_BYTES;
7194 sym_op->auth.data.offset = 0;
7195 sym_op->auth.data.length = QUOTE_512_BYTES;
7196 sym_op->auth.digest.data = digest;
7197 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7200 /* Process crypto operation */
7201 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7203 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7205 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7206 "crypto operation processing failed");
7209 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7210 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7213 "Ciphertext data not as expected");
7214 /* Make sure memory pointed to by digest hasn't been overwritten */
7215 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7219 "Memory at digest ptr overwritten unexpectedly");
7221 return TEST_SUCCESS;
7226 test_null_invalid_operation(void)
7228 struct crypto_testsuite_params *ts_params = &testsuite_params;
7229 struct crypto_unittest_params *ut_params = &unittest_params;
7232 /* Setup Cipher Parameters */
7233 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7234 ut_params->cipher_xform.next = NULL;
7236 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7237 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7239 ut_params->sess = rte_cryptodev_sym_session_create(
7240 ts_params->session_mpool);
7242 /* Create Crypto session*/
7243 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7244 ut_params->sess, &ut_params->cipher_xform,
7245 ts_params->session_mpool);
7246 TEST_ASSERT(ret < 0,
7247 "Session creation succeeded unexpectedly");
7250 /* Setup HMAC Parameters */
7251 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7252 ut_params->auth_xform.next = NULL;
7254 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7255 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7257 ut_params->sess = rte_cryptodev_sym_session_create(
7258 ts_params->session_mpool);
7260 /* Create Crypto session*/
7261 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7262 ut_params->sess, &ut_params->auth_xform,
7263 ts_params->session_mpool);
7264 TEST_ASSERT(ret < 0,
7265 "Session creation succeeded unexpectedly");
7267 return TEST_SUCCESS;
7271 #define NULL_BURST_LENGTH (32)
7274 test_null_burst_operation(void)
7276 struct crypto_testsuite_params *ts_params = &testsuite_params;
7277 struct crypto_unittest_params *ut_params = &unittest_params;
7279 unsigned i, burst_len = NULL_BURST_LENGTH;
7281 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7282 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7284 /* Setup Cipher Parameters */
7285 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7286 ut_params->cipher_xform.next = &ut_params->auth_xform;
7288 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7289 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7291 /* Setup HMAC Parameters */
7292 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7293 ut_params->auth_xform.next = NULL;
7295 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7296 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7298 ut_params->sess = rte_cryptodev_sym_session_create(
7299 ts_params->session_mpool);
7301 /* Create Crypto session*/
7302 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7303 ut_params->sess, &ut_params->cipher_xform,
7304 ts_params->session_mpool);
7305 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7307 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7308 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7309 burst_len, "failed to generate burst of crypto ops");
7311 /* Generate an operation for each mbuf in burst */
7312 for (i = 0; i < burst_len; i++) {
7313 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7315 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7317 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7321 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7323 burst[i]->sym->m_src = m;
7326 /* Process crypto operation */
7327 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7328 0, burst, burst_len),
7330 "Error enqueuing burst");
7332 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7333 0, burst_dequeued, burst_len),
7335 "Error dequeuing burst");
7338 for (i = 0; i < burst_len; i++) {
7340 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7341 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7343 "data not as expected");
7345 rte_pktmbuf_free(burst[i]->sym->m_src);
7346 rte_crypto_op_free(burst[i]);
7349 return TEST_SUCCESS;
7353 generate_gmac_large_plaintext(uint8_t *data)
7357 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7358 memcpy(&data[i], &data[0], 32);
7362 create_gmac_operation(enum rte_crypto_auth_operation op,
7363 const struct gmac_test_data *tdata)
7365 struct crypto_testsuite_params *ts_params = &testsuite_params;
7366 struct crypto_unittest_params *ut_params = &unittest_params;
7367 struct rte_crypto_sym_op *sym_op;
7369 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7371 /* Generate Crypto op data structure */
7372 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7373 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7374 TEST_ASSERT_NOT_NULL(ut_params->op,
7375 "Failed to allocate symmetric crypto operation struct");
7377 sym_op = ut_params->op->sym;
7379 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7380 ut_params->ibuf, tdata->gmac_tag.len);
7381 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7382 "no room to append digest");
7384 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7385 ut_params->ibuf, plaintext_pad_len);
7387 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7388 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7389 tdata->gmac_tag.len);
7390 debug_hexdump(stdout, "digest:",
7391 sym_op->auth.digest.data,
7392 tdata->gmac_tag.len);
7395 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7396 uint8_t *, IV_OFFSET);
7398 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7400 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7402 sym_op->cipher.data.length = 0;
7403 sym_op->cipher.data.offset = 0;
7405 sym_op->auth.data.offset = 0;
7406 sym_op->auth.data.length = tdata->plaintext.len;
7411 static int create_gmac_session(uint8_t dev_id,
7412 const struct gmac_test_data *tdata,
7413 enum rte_crypto_auth_operation auth_op)
7415 uint8_t auth_key[tdata->key.len];
7417 struct crypto_testsuite_params *ts_params = &testsuite_params;
7418 struct crypto_unittest_params *ut_params = &unittest_params;
7420 memcpy(auth_key, tdata->key.data, tdata->key.len);
7422 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7423 ut_params->auth_xform.next = NULL;
7425 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7426 ut_params->auth_xform.auth.op = auth_op;
7427 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7428 ut_params->auth_xform.auth.key.length = tdata->key.len;
7429 ut_params->auth_xform.auth.key.data = auth_key;
7430 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7431 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7434 ut_params->sess = rte_cryptodev_sym_session_create(
7435 ts_params->session_mpool);
7437 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7438 &ut_params->auth_xform,
7439 ts_params->session_mpool);
7441 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7447 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7449 struct crypto_testsuite_params *ts_params = &testsuite_params;
7450 struct crypto_unittest_params *ut_params = &unittest_params;
7454 uint8_t *auth_tag, *plaintext;
7455 uint16_t plaintext_pad_len;
7457 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7458 "No GMAC length in the source data");
7460 retval = create_gmac_session(ts_params->valid_devs[0],
7461 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7466 if (tdata->plaintext.len > MBUF_SIZE)
7467 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7470 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7471 "Failed to allocate input buffer in mempool");
7473 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7474 rte_pktmbuf_tailroom(ut_params->ibuf));
7476 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7478 * Runtime generate the large plain text instead of use hard code
7479 * plain text vector. It is done to avoid create huge source file
7480 * with the test vector.
7482 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7483 generate_gmac_large_plaintext(tdata->plaintext.data);
7485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7487 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7489 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7490 debug_hexdump(stdout, "plaintext:", plaintext,
7491 tdata->plaintext.len);
7493 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7499 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7501 ut_params->op->sym->m_src = ut_params->ibuf;
7503 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7504 ut_params->op), "failed to process sym crypto op");
7506 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7507 "crypto op processing failed");
7509 if (ut_params->op->sym->m_dst) {
7510 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7511 uint8_t *, plaintext_pad_len);
7513 auth_tag = plaintext + plaintext_pad_len;
7516 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7518 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7520 tdata->gmac_tag.data,
7521 tdata->gmac_tag.len,
7522 "GMAC Generated auth tag not as expected");
7528 test_AES_GMAC_authentication_test_case_1(void)
7530 return test_AES_GMAC_authentication(&gmac_test_case_1);
7534 test_AES_GMAC_authentication_test_case_2(void)
7536 return test_AES_GMAC_authentication(&gmac_test_case_2);
7540 test_AES_GMAC_authentication_test_case_3(void)
7542 return test_AES_GMAC_authentication(&gmac_test_case_3);
7546 test_AES_GMAC_authentication_test_case_4(void)
7548 return test_AES_GMAC_authentication(&gmac_test_case_4);
7552 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7554 struct crypto_testsuite_params *ts_params = &testsuite_params;
7555 struct crypto_unittest_params *ut_params = &unittest_params;
7557 uint32_t plaintext_pad_len;
7560 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7561 "No GMAC length in the source data");
7563 retval = create_gmac_session(ts_params->valid_devs[0],
7564 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7569 if (tdata->plaintext.len > MBUF_SIZE)
7570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7573 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7574 "Failed to allocate input buffer in mempool");
7576 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7577 rte_pktmbuf_tailroom(ut_params->ibuf));
7579 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7582 * Runtime generate the large plain text instead of use hard code
7583 * plain text vector. It is done to avoid create huge source file
7584 * with the test vector.
7586 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7587 generate_gmac_large_plaintext(tdata->plaintext.data);
7589 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7591 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7593 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7594 debug_hexdump(stdout, "plaintext:", plaintext,
7595 tdata->plaintext.len);
7597 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7603 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7605 ut_params->op->sym->m_src = ut_params->ibuf;
7607 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7608 ut_params->op), "failed to process sym crypto op");
7610 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7611 "crypto op processing failed");
7618 test_AES_GMAC_authentication_verify_test_case_1(void)
7620 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7624 test_AES_GMAC_authentication_verify_test_case_2(void)
7626 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7630 test_AES_GMAC_authentication_verify_test_case_3(void)
7632 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7636 test_AES_GMAC_authentication_verify_test_case_4(void)
7638 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7641 struct test_crypto_vector {
7642 enum rte_crypto_cipher_algorithm crypto_algo;
7655 const uint8_t *data;
7660 const uint8_t *data;
7664 enum rte_crypto_auth_algorithm auth_algo;
7672 const uint8_t *data;
7682 static const struct test_crypto_vector
7683 hmac_sha1_test_crypto_vector = {
7684 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7686 .data = plaintext_hash,
7691 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7692 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7693 0xDE, 0xF4, 0xDE, 0xAD
7699 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7700 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7701 0x3F, 0x91, 0x64, 0x59
7707 static const struct test_crypto_vector
7708 aes128_gmac_test_vector = {
7709 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7711 .data = plaintext_hash,
7716 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7717 0x08, 0x09, 0x0A, 0x0B
7723 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7724 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7730 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7731 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7737 static const struct test_crypto_vector
7738 aes128cbc_hmac_sha1_test_vector = {
7739 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7742 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7743 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7749 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7750 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7755 .data = plaintext_hash,
7759 .data = ciphertext512_aes128cbc,
7762 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7765 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7766 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7767 0xDE, 0xF4, 0xDE, 0xAD
7773 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7774 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7775 0x18, 0x8C, 0x1D, 0x32
7782 data_corruption(uint8_t *data)
7788 tag_corruption(uint8_t *data, unsigned int tag_offset)
7790 data[tag_offset] += 1;
7794 create_auth_session(struct crypto_unittest_params *ut_params,
7796 const struct test_crypto_vector *reference,
7797 enum rte_crypto_auth_operation auth_op)
7799 struct crypto_testsuite_params *ts_params = &testsuite_params;
7800 uint8_t auth_key[reference->auth_key.len + 1];
7802 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7804 /* Setup Authentication Parameters */
7805 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7806 ut_params->auth_xform.auth.op = auth_op;
7807 ut_params->auth_xform.next = NULL;
7808 ut_params->auth_xform.auth.algo = reference->auth_algo;
7809 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7810 ut_params->auth_xform.auth.key.data = auth_key;
7811 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7813 /* Create Crypto session*/
7814 ut_params->sess = rte_cryptodev_sym_session_create(
7815 ts_params->session_mpool);
7817 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7818 &ut_params->auth_xform,
7819 ts_params->session_mpool);
7821 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7827 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7829 const struct test_crypto_vector *reference,
7830 enum rte_crypto_auth_operation auth_op,
7831 enum rte_crypto_cipher_operation cipher_op)
7833 struct crypto_testsuite_params *ts_params = &testsuite_params;
7834 uint8_t cipher_key[reference->cipher_key.len + 1];
7835 uint8_t auth_key[reference->auth_key.len + 1];
7837 memcpy(cipher_key, reference->cipher_key.data,
7838 reference->cipher_key.len);
7839 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7841 /* Setup Authentication Parameters */
7842 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7843 ut_params->auth_xform.auth.op = auth_op;
7844 ut_params->auth_xform.auth.algo = reference->auth_algo;
7845 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7846 ut_params->auth_xform.auth.key.data = auth_key;
7847 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7849 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7850 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7851 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7853 ut_params->auth_xform.next = &ut_params->cipher_xform;
7855 /* Setup Cipher Parameters */
7856 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7857 ut_params->cipher_xform.next = NULL;
7858 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7859 ut_params->cipher_xform.cipher.op = cipher_op;
7860 ut_params->cipher_xform.cipher.key.data = cipher_key;
7861 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7862 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7863 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7866 /* Create Crypto session*/
7867 ut_params->sess = rte_cryptodev_sym_session_create(
7868 ts_params->session_mpool);
7870 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7871 &ut_params->auth_xform,
7872 ts_params->session_mpool);
7874 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7880 create_auth_operation(struct crypto_testsuite_params *ts_params,
7881 struct crypto_unittest_params *ut_params,
7882 const struct test_crypto_vector *reference,
7883 unsigned int auth_generate)
7885 /* Generate Crypto op data structure */
7886 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7887 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7888 TEST_ASSERT_NOT_NULL(ut_params->op,
7889 "Failed to allocate pktmbuf offload");
7891 /* Set crypto operation data parameters */
7892 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7894 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7896 /* set crypto operation source mbuf */
7897 sym_op->m_src = ut_params->ibuf;
7900 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7901 ut_params->ibuf, reference->digest.len);
7903 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7904 "no room to append auth tag");
7906 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7907 ut_params->ibuf, reference->plaintext.len);
7910 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7912 memcpy(sym_op->auth.digest.data,
7913 reference->digest.data,
7914 reference->digest.len);
7916 debug_hexdump(stdout, "digest:",
7917 sym_op->auth.digest.data,
7918 reference->digest.len);
7920 sym_op->auth.data.length = reference->plaintext.len;
7921 sym_op->auth.data.offset = 0;
7927 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7928 struct crypto_unittest_params *ut_params,
7929 const struct test_crypto_vector *reference,
7930 unsigned int auth_generate)
7932 /* Generate Crypto op data structure */
7933 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7934 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7935 TEST_ASSERT_NOT_NULL(ut_params->op,
7936 "Failed to allocate pktmbuf offload");
7938 /* Set crypto operation data parameters */
7939 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7941 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7943 /* set crypto operation source mbuf */
7944 sym_op->m_src = ut_params->ibuf;
7947 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7948 ut_params->ibuf, reference->digest.len);
7950 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7951 "no room to append auth tag");
7953 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7954 ut_params->ibuf, reference->ciphertext.len);
7957 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7959 memcpy(sym_op->auth.digest.data,
7960 reference->digest.data,
7961 reference->digest.len);
7963 debug_hexdump(stdout, "digest:",
7964 sym_op->auth.digest.data,
7965 reference->digest.len);
7967 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7968 reference->iv.data, reference->iv.len);
7970 sym_op->cipher.data.length = 0;
7971 sym_op->cipher.data.offset = 0;
7973 sym_op->auth.data.length = reference->plaintext.len;
7974 sym_op->auth.data.offset = 0;
7980 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7981 struct crypto_unittest_params *ut_params,
7982 const struct test_crypto_vector *reference,
7983 unsigned int auth_generate)
7985 /* Generate Crypto op data structure */
7986 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7987 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7988 TEST_ASSERT_NOT_NULL(ut_params->op,
7989 "Failed to allocate pktmbuf offload");
7991 /* Set crypto operation data parameters */
7992 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7994 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7996 /* set crypto operation source mbuf */
7997 sym_op->m_src = ut_params->ibuf;
8000 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8001 ut_params->ibuf, reference->digest.len);
8003 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8004 "no room to append auth tag");
8006 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8007 ut_params->ibuf, reference->ciphertext.len);
8010 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8012 memcpy(sym_op->auth.digest.data,
8013 reference->digest.data,
8014 reference->digest.len);
8016 debug_hexdump(stdout, "digest:",
8017 sym_op->auth.digest.data,
8018 reference->digest.len);
8020 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8021 reference->iv.data, reference->iv.len);
8023 sym_op->cipher.data.length = reference->ciphertext.len;
8024 sym_op->cipher.data.offset = 0;
8026 sym_op->auth.data.length = reference->ciphertext.len;
8027 sym_op->auth.data.offset = 0;
8033 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8034 struct crypto_unittest_params *ut_params,
8035 const struct test_crypto_vector *reference)
8037 return create_auth_operation(ts_params, ut_params, reference, 0);
8041 create_auth_verify_GMAC_operation(
8042 struct crypto_testsuite_params *ts_params,
8043 struct crypto_unittest_params *ut_params,
8044 const struct test_crypto_vector *reference)
8046 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8050 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8051 struct crypto_unittest_params *ut_params,
8052 const struct test_crypto_vector *reference)
8054 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8058 test_authentication_verify_fail_when_data_corruption(
8059 struct crypto_testsuite_params *ts_params,
8060 struct crypto_unittest_params *ut_params,
8061 const struct test_crypto_vector *reference,
8062 unsigned int data_corrupted)
8068 /* Create session */
8069 retval = create_auth_session(ut_params,
8070 ts_params->valid_devs[0],
8072 RTE_CRYPTO_AUTH_OP_VERIFY);
8076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8077 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8078 "Failed to allocate input buffer in mempool");
8080 /* clear mbuf payload */
8081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8082 rte_pktmbuf_tailroom(ut_params->ibuf));
8084 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8085 reference->plaintext.len);
8086 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8087 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8089 debug_hexdump(stdout, "plaintext:", plaintext,
8090 reference->plaintext.len);
8092 /* Create operation */
8093 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8099 data_corruption(plaintext);
8101 tag_corruption(plaintext, reference->plaintext.len);
8103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8106 TEST_ASSERT_EQUAL(ut_params->op->status,
8107 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8108 "authentication not failed");
8110 ut_params->obuf = ut_params->op->sym->m_src;
8111 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8117 test_authentication_verify_GMAC_fail_when_corruption(
8118 struct crypto_testsuite_params *ts_params,
8119 struct crypto_unittest_params *ut_params,
8120 const struct test_crypto_vector *reference,
8121 unsigned int data_corrupted)
8126 /* Create session */
8127 retval = create_auth_cipher_session(ut_params,
8128 ts_params->valid_devs[0],
8130 RTE_CRYPTO_AUTH_OP_VERIFY,
8131 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8136 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8137 "Failed to allocate input buffer in mempool");
8139 /* clear mbuf payload */
8140 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8141 rte_pktmbuf_tailroom(ut_params->ibuf));
8143 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8144 reference->plaintext.len);
8145 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8146 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8148 debug_hexdump(stdout, "plaintext:", plaintext,
8149 reference->plaintext.len);
8151 /* Create operation */
8152 retval = create_auth_verify_GMAC_operation(ts_params,
8160 data_corruption(plaintext);
8162 tag_corruption(plaintext, reference->aad.len);
8164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8166 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8167 TEST_ASSERT_EQUAL(ut_params->op->status,
8168 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8169 "authentication not failed");
8171 ut_params->obuf = ut_params->op->sym->m_src;
8172 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8178 test_authenticated_decryption_fail_when_corruption(
8179 struct crypto_testsuite_params *ts_params,
8180 struct crypto_unittest_params *ut_params,
8181 const struct test_crypto_vector *reference,
8182 unsigned int data_corrupted)
8186 uint8_t *ciphertext;
8188 /* Create session */
8189 retval = create_auth_cipher_session(ut_params,
8190 ts_params->valid_devs[0],
8192 RTE_CRYPTO_AUTH_OP_VERIFY,
8193 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8197 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8198 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8199 "Failed to allocate input buffer in mempool");
8201 /* clear mbuf payload */
8202 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8203 rte_pktmbuf_tailroom(ut_params->ibuf));
8205 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8206 reference->ciphertext.len);
8207 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8208 memcpy(ciphertext, reference->ciphertext.data,
8209 reference->ciphertext.len);
8211 /* Create operation */
8212 retval = create_cipher_auth_verify_operation(ts_params,
8220 data_corruption(ciphertext);
8222 tag_corruption(ciphertext, reference->ciphertext.len);
8224 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8227 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8228 TEST_ASSERT_EQUAL(ut_params->op->status,
8229 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8230 "authentication not failed");
8232 ut_params->obuf = ut_params->op->sym->m_src;
8233 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8239 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8240 const struct aead_test_data *tdata,
8241 void *digest_mem, uint64_t digest_phys)
8243 struct crypto_testsuite_params *ts_params = &testsuite_params;
8244 struct crypto_unittest_params *ut_params = &unittest_params;
8246 const unsigned int auth_tag_len = tdata->auth_tag.len;
8247 const unsigned int iv_len = tdata->iv.len;
8248 unsigned int aad_len = tdata->aad.len;
8250 /* Generate Crypto op data structure */
8251 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8252 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8253 TEST_ASSERT_NOT_NULL(ut_params->op,
8254 "Failed to allocate symmetric crypto operation struct");
8256 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8258 sym_op->aead.digest.data = digest_mem;
8260 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8261 "no room to append digest");
8263 sym_op->aead.digest.phys_addr = digest_phys;
8265 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8266 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8268 debug_hexdump(stdout, "digest:",
8269 sym_op->aead.digest.data,
8273 /* Append aad data */
8274 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8275 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8276 uint8_t *, IV_OFFSET);
8278 /* Copy IV 1 byte after the IV pointer, according to the API */
8279 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8281 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8283 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8284 ut_params->ibuf, aad_len);
8285 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8286 "no room to prepend aad");
8287 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8290 memset(sym_op->aead.aad.data, 0, aad_len);
8291 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8292 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8294 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8295 debug_hexdump(stdout, "aad:",
8296 sym_op->aead.aad.data, aad_len);
8298 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8299 uint8_t *, IV_OFFSET);
8301 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8303 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8304 ut_params->ibuf, aad_len);
8305 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8306 "no room to prepend aad");
8307 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8310 memset(sym_op->aead.aad.data, 0, aad_len);
8311 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8313 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8314 debug_hexdump(stdout, "aad:",
8315 sym_op->aead.aad.data, aad_len);
8318 sym_op->aead.data.length = tdata->plaintext.len;
8319 sym_op->aead.data.offset = aad_len;
8324 #define SGL_MAX_NO 16
8327 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8328 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8330 struct crypto_testsuite_params *ts_params = &testsuite_params;
8331 struct crypto_unittest_params *ut_params = &unittest_params;
8332 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8335 int to_trn_tbl[SGL_MAX_NO];
8337 unsigned int trn_data = 0;
8338 uint8_t *plaintext, *ciphertext, *auth_tag;
8340 if (fragsz > tdata->plaintext.len)
8341 fragsz = tdata->plaintext.len;
8343 uint16_t plaintext_len = fragsz;
8344 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8346 if (fragsz_oop > tdata->plaintext.len)
8347 frag_size_oop = tdata->plaintext.len;
8350 void *digest_mem = NULL;
8352 uint32_t prepend_len = tdata->aad.len;
8354 if (tdata->plaintext.len % fragsz != 0) {
8355 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8358 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8363 * For out-op-place we need to alloc another mbuf
8366 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8367 rte_pktmbuf_append(ut_params->obuf,
8368 frag_size_oop + prepend_len);
8369 buf_oop = ut_params->obuf;
8372 /* Create AEAD session */
8373 retval = create_aead_session(ts_params->valid_devs[0],
8375 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8376 tdata->key.data, tdata->key.len,
8377 tdata->aad.len, tdata->auth_tag.len,
8382 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8384 /* clear mbuf payload */
8385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8386 rte_pktmbuf_tailroom(ut_params->ibuf));
8388 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8391 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8393 trn_data += plaintext_len;
8395 buf = ut_params->ibuf;
8398 * Loop until no more fragments
8401 while (trn_data < tdata->plaintext.len) {
8403 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8404 (tdata->plaintext.len - trn_data) : fragsz;
8406 to_trn_tbl[ecx++] = to_trn;
8408 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8411 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8412 rte_pktmbuf_tailroom(buf));
8415 if (oop && !fragsz_oop) {
8416 buf_last_oop = buf_oop->next =
8417 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8418 buf_oop = buf_oop->next;
8419 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8420 0, rte_pktmbuf_tailroom(buf_oop));
8421 rte_pktmbuf_append(buf_oop, to_trn);
8424 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8427 memcpy(plaintext, tdata->plaintext.data + trn_data,
8430 if (trn_data == tdata->plaintext.len) {
8433 digest_mem = rte_pktmbuf_append(buf_oop,
8434 tdata->auth_tag.len);
8436 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8437 tdata->auth_tag.len);
8441 uint64_t digest_phys = 0;
8443 ut_params->ibuf->nb_segs = segs;
8446 if (fragsz_oop && oop) {
8450 if (frag_size_oop == tdata->plaintext.len) {
8451 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8452 tdata->auth_tag.len);
8454 digest_phys = rte_pktmbuf_iova_offset(
8456 tdata->plaintext.len + prepend_len);
8459 trn_data = frag_size_oop;
8460 while (trn_data < tdata->plaintext.len) {
8463 (tdata->plaintext.len - trn_data <
8465 (tdata->plaintext.len - trn_data) :
8468 to_trn_tbl[ecx++] = to_trn;
8470 buf_last_oop = buf_oop->next =
8471 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8472 buf_oop = buf_oop->next;
8473 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8474 0, rte_pktmbuf_tailroom(buf_oop));
8475 rte_pktmbuf_append(buf_oop, to_trn);
8479 if (trn_data == tdata->plaintext.len) {
8480 digest_mem = rte_pktmbuf_append(buf_oop,
8481 tdata->auth_tag.len);
8485 ut_params->obuf->nb_segs = segs;
8489 * Place digest at the end of the last buffer
8492 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8493 if (oop && buf_last_oop)
8494 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8496 if (!digest_mem && !oop) {
8497 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8498 + tdata->auth_tag.len);
8499 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8500 tdata->plaintext.len);
8503 /* Create AEAD operation */
8504 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8505 tdata, digest_mem, digest_phys);
8510 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8512 ut_params->op->sym->m_src = ut_params->ibuf;
8514 ut_params->op->sym->m_dst = ut_params->obuf;
8516 /* Process crypto operation */
8517 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8518 ut_params->op), "failed to process sym crypto op");
8520 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8521 "crypto op processing failed");
8524 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8525 uint8_t *, prepend_len);
8527 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8528 uint8_t *, prepend_len);
8532 fragsz = fragsz_oop;
8534 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8536 tdata->ciphertext.data,
8538 "Ciphertext data not as expected");
8540 buf = ut_params->op->sym->m_src->next;
8542 buf = ut_params->op->sym->m_dst->next;
8544 unsigned int off = fragsz;
8548 ciphertext = rte_pktmbuf_mtod(buf,
8551 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8553 tdata->ciphertext.data + off,
8555 "Ciphertext data not as expected");
8557 off += to_trn_tbl[ecx++];
8561 auth_tag = digest_mem;
8562 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8564 tdata->auth_tag.data,
8565 tdata->auth_tag.len,
8566 "Generated auth tag not as expected");
8572 #define OUT_OF_PLACE 1
8575 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8577 return test_authenticated_encryption_SGL(
8578 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8582 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8584 return test_authenticated_encryption_SGL(
8585 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8589 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8591 return test_authenticated_encryption_SGL(
8592 &gcm_test_case_8, OUT_OF_PLACE, 400,
8593 gcm_test_case_8.plaintext.len);
8597 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8600 return test_authenticated_encryption_SGL(
8601 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8605 test_authentication_verify_fail_when_data_corrupted(
8606 struct crypto_testsuite_params *ts_params,
8607 struct crypto_unittest_params *ut_params,
8608 const struct test_crypto_vector *reference)
8610 return test_authentication_verify_fail_when_data_corruption(
8611 ts_params, ut_params, reference, 1);
8615 test_authentication_verify_fail_when_tag_corrupted(
8616 struct crypto_testsuite_params *ts_params,
8617 struct crypto_unittest_params *ut_params,
8618 const struct test_crypto_vector *reference)
8620 return test_authentication_verify_fail_when_data_corruption(
8621 ts_params, ut_params, reference, 0);
8625 test_authentication_verify_GMAC_fail_when_data_corrupted(
8626 struct crypto_testsuite_params *ts_params,
8627 struct crypto_unittest_params *ut_params,
8628 const struct test_crypto_vector *reference)
8630 return test_authentication_verify_GMAC_fail_when_corruption(
8631 ts_params, ut_params, reference, 1);
8635 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8636 struct crypto_testsuite_params *ts_params,
8637 struct crypto_unittest_params *ut_params,
8638 const struct test_crypto_vector *reference)
8640 return test_authentication_verify_GMAC_fail_when_corruption(
8641 ts_params, ut_params, reference, 0);
8645 test_authenticated_decryption_fail_when_data_corrupted(
8646 struct crypto_testsuite_params *ts_params,
8647 struct crypto_unittest_params *ut_params,
8648 const struct test_crypto_vector *reference)
8650 return test_authenticated_decryption_fail_when_corruption(
8651 ts_params, ut_params, reference, 1);
8655 test_authenticated_decryption_fail_when_tag_corrupted(
8656 struct crypto_testsuite_params *ts_params,
8657 struct crypto_unittest_params *ut_params,
8658 const struct test_crypto_vector *reference)
8660 return test_authenticated_decryption_fail_when_corruption(
8661 ts_params, ut_params, reference, 0);
8665 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8667 return test_authentication_verify_fail_when_data_corrupted(
8668 &testsuite_params, &unittest_params,
8669 &hmac_sha1_test_crypto_vector);
8673 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8675 return test_authentication_verify_fail_when_tag_corrupted(
8676 &testsuite_params, &unittest_params,
8677 &hmac_sha1_test_crypto_vector);
8681 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8683 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8684 &testsuite_params, &unittest_params,
8685 &aes128_gmac_test_vector);
8689 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8691 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8692 &testsuite_params, &unittest_params,
8693 &aes128_gmac_test_vector);
8697 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8699 return test_authenticated_decryption_fail_when_data_corrupted(
8702 &aes128cbc_hmac_sha1_test_vector);
8706 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8708 return test_authenticated_decryption_fail_when_tag_corrupted(
8711 &aes128cbc_hmac_sha1_test_vector);
8714 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8716 /* global AESNI slave IDs for the scheduler test */
8717 uint8_t aesni_ids[2];
8720 test_scheduler_attach_slave_op(void)
8722 struct crypto_testsuite_params *ts_params = &testsuite_params;
8723 uint8_t sched_id = ts_params->valid_devs[0];
8724 uint32_t nb_devs, i, nb_devs_attached = 0;
8728 /* create 2 AESNI_MB if necessary */
8729 nb_devs = rte_cryptodev_device_count_by_driver(
8730 rte_cryptodev_driver_id_get(
8731 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8733 for (i = nb_devs; i < 2; i++) {
8734 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8735 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8737 ret = rte_vdev_init(vdev_name, NULL);
8739 TEST_ASSERT(ret == 0,
8740 "Failed to create instance %u of"
8742 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8746 /* attach 2 AESNI_MB cdevs */
8747 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8749 struct rte_cryptodev_info info;
8751 rte_cryptodev_info_get(i, &info);
8752 if (info.driver_id != rte_cryptodev_driver_id_get(
8753 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8757 * Create the session mempool again, since now there are new devices
8758 * to use the mempool.
8760 if (ts_params->session_mpool) {
8761 rte_mempool_free(ts_params->session_mpool);
8762 ts_params->session_mpool = NULL;
8764 unsigned int session_size =
8765 rte_cryptodev_sym_get_private_session_size(i);
8767 if (info.sym.max_nb_sessions != 0 &&
8768 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8770 "Device does not support "
8771 "at least %u sessions\n",
8776 * Create mempool with maximum number of sessions * 2,
8777 * to include the session headers
8779 if (ts_params->session_mpool == NULL) {
8780 ts_params->session_mpool = rte_mempool_create(
8782 MAX_NB_SESSIONS * 2,
8784 0, 0, NULL, NULL, NULL,
8785 NULL, SOCKET_ID_ANY,
8788 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8789 "session mempool allocation failed");
8792 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8795 TEST_ASSERT(ret == 0,
8796 "Failed to attach device %u of pmd : %s", i,
8797 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8799 aesni_ids[nb_devs_attached] = (uint8_t)i;
8808 test_scheduler_detach_slave_op(void)
8810 struct crypto_testsuite_params *ts_params = &testsuite_params;
8811 uint8_t sched_id = ts_params->valid_devs[0];
8815 for (i = 0; i < 2; i++) {
8816 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8818 TEST_ASSERT(ret == 0,
8819 "Failed to detach device %u", aesni_ids[i]);
8826 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8828 struct crypto_testsuite_params *ts_params = &testsuite_params;
8829 uint8_t sched_id = ts_params->valid_devs[0];
8831 return rte_cryptodev_scheduler_mode_set(sched_id,
8836 test_scheduler_mode_roundrobin_op(void)
8838 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8839 0, "Failed to set roundrobin mode");
8845 test_scheduler_mode_multicore_op(void)
8847 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8848 0, "Failed to set multicore mode");
8854 test_scheduler_mode_failover_op(void)
8856 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8857 0, "Failed to set failover mode");
8863 test_scheduler_mode_pkt_size_distr_op(void)
8865 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8866 0, "Failed to set pktsize mode");
8871 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8872 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8873 .setup = testsuite_setup,
8874 .teardown = testsuite_teardown,
8875 .unit_test_cases = {
8877 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8878 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_AES_chain_scheduler_all),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_cipheronly_scheduler_all),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_authonly_scheduler_all),
8885 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8888 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8889 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 test_AES_chain_scheduler_all),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_AES_cipheronly_scheduler_all),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_authonly_scheduler_all),
8896 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8899 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8900 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_chain_scheduler_all),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_AES_cipheronly_scheduler_all),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_authonly_scheduler_all),
8907 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8910 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8911 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8912 TEST_CASE_ST(ut_setup, ut_teardown,
8913 test_AES_chain_scheduler_all),
8914 TEST_CASE_ST(ut_setup, ut_teardown,
8915 test_AES_cipheronly_scheduler_all),
8916 TEST_CASE_ST(ut_setup, ut_teardown,
8917 test_authonly_scheduler_all),
8918 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8920 TEST_CASES_END() /**< NULL terminate unit test array */
8924 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8926 static struct unit_test_suite cryptodev_qat_testsuite = {
8927 .suite_name = "Crypto QAT Unit Test Suite",
8928 .setup = testsuite_setup,
8929 .teardown = testsuite_teardown,
8930 .unit_test_cases = {
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_device_configure_invalid_dev_id),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_device_configure_invalid_queue_pair_ids),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_queue_pair_descriptor_setup),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_multi_session),
8940 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_AES_cipheronly_qat_all),
8943 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_3DES_cipheronly_qat_all),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_DES_cipheronly_qat_all),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_AES_docsis_qat_all),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_DES_docsis_qat_all),
8952 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8953 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8955 /** AES CCM Authenticated Encryption 128 bits key */
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_AES_CCM_authenticated_encryption_test_case_128_1),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_AES_CCM_authenticated_encryption_test_case_128_2),
8960 TEST_CASE_ST(ut_setup, ut_teardown,
8961 test_AES_CCM_authenticated_encryption_test_case_128_3),
8963 /** AES CCM Authenticated Decryption 128 bits key*/
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_CCM_authenticated_decryption_test_case_128_1),
8966 TEST_CASE_ST(ut_setup, ut_teardown,
8967 test_AES_CCM_authenticated_decryption_test_case_128_2),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_CCM_authenticated_decryption_test_case_128_3),
8971 /** AES GCM Authenticated Encryption */
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_encryption_test_case_1),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_encryption_test_case_2),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 test_AES_GCM_authenticated_encryption_test_case_3),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_authenticated_encryption_test_case_4),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_AES_GCM_authenticated_encryption_test_case_5),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_authenticated_encryption_test_case_6),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_authenticated_encryption_test_case_7),
8993 /** AES GCM Authenticated Decryption */
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_GCM_authenticated_decryption_test_case_1),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_GCM_authenticated_decryption_test_case_2),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_GCM_authenticated_decryption_test_case_3),
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_GCM_authenticated_decryption_test_case_4),
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_GCM_authenticated_decryption_test_case_5),
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_authenticated_decryption_test_case_6),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_authenticated_decryption_test_case_7),
9009 /** AES GCM Authenticated Encryption 192 bits key */
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_encryption_test_case_192_1),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_encryption_test_case_192_2),
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_auth_encryption_test_case_192_3),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_encryption_test_case_192_4),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_auth_encryption_test_case_192_5),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_encryption_test_case_192_6),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_encryption_test_case_192_7),
9025 /** AES GCM Authenticated Decryption 192 bits key */
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_decryption_test_case_192_1),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_decryption_test_case_192_2),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_auth_decryption_test_case_192_3),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_auth_decryption_test_case_192_4),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_AES_GCM_auth_decryption_test_case_192_5),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_decryption_test_case_192_6),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_decryption_test_case_192_7),
9041 /** AES GCM Authenticated Encryption 256 bits key */
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_encryption_test_case_256_1),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_encryption_test_case_256_2),
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_auth_encryption_test_case_256_3),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_auth_encryption_test_case_256_4),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_auth_encryption_test_case_256_5),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_encryption_test_case_256_6),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_encryption_test_case_256_7),
9057 /** AES GMAC Authentication */
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GMAC_authentication_test_case_1),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GMAC_authentication_verify_test_case_1),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GMAC_authentication_test_case_2),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GMAC_authentication_verify_test_case_2),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GMAC_authentication_test_case_3),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GMAC_authentication_verify_test_case_3),
9071 /** SNOW 3G encrypt only (UEA2) */
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_snow3g_encryption_test_case_1),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_snow3g_encryption_test_case_2),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_snow3g_encryption_test_case_3),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_snow3g_encryption_test_case_4),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_snow3g_encryption_test_case_5),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_snow3g_encryption_test_case_1_oop),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_snow3g_decryption_test_case_1_oop),
9088 /** SNOW 3G decrypt only (UEA2) */
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_snow3g_decryption_test_case_1),
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 test_snow3g_decryption_test_case_2),
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_snow3g_decryption_test_case_3),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_snow3g_decryption_test_case_4),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_snow3g_decryption_test_case_5),
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_snow3g_hash_generate_test_case_1),
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_snow3g_hash_generate_test_case_2),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_snow3g_hash_generate_test_case_3),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_snow3g_hash_verify_test_case_1),
9107 TEST_CASE_ST(ut_setup, ut_teardown,
9108 test_snow3g_hash_verify_test_case_2),
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_snow3g_hash_verify_test_case_3),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_snow3g_cipher_auth_test_case_1),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_snow3g_auth_cipher_test_case_1),
9116 /** ZUC encrypt only (EEA3) */
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_zuc_encryption_test_case_1),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_zuc_encryption_test_case_2),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_zuc_encryption_test_case_3),
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_zuc_encryption_test_case_4),
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_zuc_encryption_test_case_5),
9128 /** ZUC authenticate (EIA3) */
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_zuc_hash_generate_test_case_6),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_zuc_hash_generate_test_case_7),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_zuc_hash_generate_test_case_8),
9136 /** ZUC alg-chain (EEA3/EIA3) */
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_zuc_cipher_auth_test_case_1),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_zuc_cipher_auth_test_case_2),
9142 /** HMAC_MD5 Authentication */
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_MD5_HMAC_generate_case_1),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_MD5_HMAC_verify_case_1),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_MD5_HMAC_generate_case_2),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_MD5_HMAC_verify_case_2),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_null_auth_only_operation),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_null_cipher_only_operation),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_null_cipher_auth_operation),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_null_auth_cipher_operation),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_kasumi_hash_generate_test_case_1),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_kasumi_hash_generate_test_case_2),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_kasumi_hash_generate_test_case_3),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_kasumi_hash_generate_test_case_4),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_kasumi_hash_generate_test_case_5),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_kasumi_hash_generate_test_case_6),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_kasumi_hash_verify_test_case_1),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_kasumi_hash_verify_test_case_2),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_kasumi_hash_verify_test_case_3),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_kasumi_hash_verify_test_case_4),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_kasumi_hash_verify_test_case_5),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_kasumi_encryption_test_case_1),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_kasumi_encryption_test_case_3),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_kasumi_auth_cipher_test_case_1),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_kasumi_cipher_auth_test_case_1),
9196 /** Negative tests */
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 authentication_verify_AES128_GMAC_fail_data_corrupt),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9210 TEST_CASES_END() /**< NULL terminate unit test array */
9214 static struct unit_test_suite cryptodev_virtio_testsuite = {
9215 .suite_name = "Crypto VIRTIO Unit Test Suite",
9216 .setup = testsuite_setup,
9217 .teardown = testsuite_teardown,
9218 .unit_test_cases = {
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_AES_cipheronly_virtio_all),
9222 TEST_CASES_END() /**< NULL terminate unit test array */
9226 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9227 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9228 .setup = testsuite_setup,
9229 .teardown = testsuite_teardown,
9230 .unit_test_cases = {
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_GCM_authenticated_encryption_test_case_1),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_AES_GCM_authenticated_encryption_test_case_2),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_AES_GCM_authenticated_encryption_test_case_3),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_AES_GCM_authenticated_encryption_test_case_4),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_AES_GCM_authenticated_encryption_test_case_5),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_AES_GCM_authenticated_encryption_test_case_6),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_AES_GCM_authenticated_encryption_test_case_7),
9246 /** AES GCM Authenticated Decryption */
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_AES_GCM_authenticated_decryption_test_case_1),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_AES_GCM_authenticated_decryption_test_case_2),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_AES_GCM_authenticated_decryption_test_case_3),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_authenticated_decryption_test_case_4),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_AES_GCM_authenticated_decryption_test_case_5),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_AES_GCM_authenticated_decryption_test_case_6),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_authenticated_decryption_test_case_7),
9262 /** AES GCM Authenticated Encryption 192 bits key */
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_AES_GCM_auth_encryption_test_case_192_1),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_AES_GCM_auth_encryption_test_case_192_2),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_AES_GCM_auth_encryption_test_case_192_3),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_AES_GCM_auth_encryption_test_case_192_4),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_GCM_auth_encryption_test_case_192_5),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_GCM_auth_encryption_test_case_192_6),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GCM_auth_encryption_test_case_192_7),
9278 /** AES GCM Authenticated Decryption 192 bits key */
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_GCM_auth_decryption_test_case_192_1),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_AES_GCM_auth_decryption_test_case_192_2),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_GCM_auth_decryption_test_case_192_3),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_auth_decryption_test_case_192_4),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_auth_decryption_test_case_192_5),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_auth_decryption_test_case_192_6),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_auth_decryption_test_case_192_7),
9294 /** AES GCM Authenticated Encryption 256 bits key */
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_auth_encryption_test_case_256_1),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_auth_encryption_test_case_256_2),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_auth_encryption_test_case_256_3),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_auth_encryption_test_case_256_4),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_auth_encryption_test_case_256_5),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_auth_encryption_test_case_256_6),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_auth_encryption_test_case_256_7),
9310 /** AES GCM Authenticated Decryption 256 bits key */
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_auth_decryption_test_case_256_1),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_auth_decryption_test_case_256_2),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_auth_decryption_test_case_256_3),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_decryption_test_case_256_4),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_auth_decryption_test_case_256_5),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_auth_decryption_test_case_256_6),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_decryption_test_case_256_7),
9326 /** AES GCM Authenticated Encryption big aad size */
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_encryption_test_case_aad_1),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_auth_encryption_test_case_aad_2),
9332 /** AES GCM Authenticated Decryption big aad size */
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_decryption_test_case_aad_1),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_decryption_test_case_aad_2),
9338 /** Session-less tests */
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9345 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9346 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9347 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9348 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_DES_cipheronly_mb_all),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_DES_docsis_mb_all),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_3DES_cipheronly_mb_all),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_CCM_authenticated_encryption_test_case_128_1),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_CCM_authenticated_decryption_test_case_128_1),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_CCM_authenticated_encryption_test_case_128_2),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_CCM_authenticated_decryption_test_case_128_2),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_CCM_authenticated_encryption_test_case_128_3),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_CCM_authenticated_decryption_test_case_128_3),
9368 TEST_CASES_END() /**< NULL terminate unit test array */
9372 static struct unit_test_suite cryptodev_openssl_testsuite = {
9373 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9374 .setup = testsuite_setup,
9375 .teardown = testsuite_teardown,
9376 .unit_test_cases = {
9377 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_multi_session_random_usage),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_AES_chain_openssl_all),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_cipheronly_openssl_all),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_3DES_chain_openssl_all),
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_3DES_cipheronly_openssl_all),
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_DES_cipheronly_openssl_all),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_DES_docsis_openssl_all),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_authonly_openssl_all),
9395 /** AES GCM Authenticated Encryption */
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_authenticated_encryption_test_case_1),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_authenticated_encryption_test_case_2),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_authenticated_encryption_test_case_3),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_authenticated_encryption_test_case_4),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_authenticated_encryption_test_case_5),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_encryption_test_case_6),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_authenticated_encryption_test_case_7),
9411 /** AES GCM Authenticated Decryption */
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_decryption_test_case_1),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_decryption_test_case_2),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_decryption_test_case_3),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_authenticated_decryption_test_case_4),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_decryption_test_case_5),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_test_case_6),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_authenticated_decryption_test_case_7),
9428 /** AES GCM Authenticated Encryption 192 bits key */
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_AES_GCM_auth_encryption_test_case_192_1),
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_AES_GCM_auth_encryption_test_case_192_2),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_AES_GCM_auth_encryption_test_case_192_3),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_AES_GCM_auth_encryption_test_case_192_4),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_AES_GCM_auth_encryption_test_case_192_5),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_AES_GCM_auth_encryption_test_case_192_6),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_AES_GCM_auth_encryption_test_case_192_7),
9444 /** AES GCM Authenticated Decryption 192 bits key */
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_AES_GCM_auth_decryption_test_case_192_1),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_AES_GCM_auth_decryption_test_case_192_2),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_AES_GCM_auth_decryption_test_case_192_3),
9451 TEST_CASE_ST(ut_setup, ut_teardown,
9452 test_AES_GCM_auth_decryption_test_case_192_4),
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_AES_GCM_auth_decryption_test_case_192_5),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_AES_GCM_auth_decryption_test_case_192_6),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_AES_GCM_auth_decryption_test_case_192_7),
9460 /** AES GCM Authenticated Encryption 256 bits key */
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_AES_GCM_auth_encryption_test_case_256_1),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_AES_GCM_auth_encryption_test_case_256_2),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_AES_GCM_auth_encryption_test_case_256_3),
9467 TEST_CASE_ST(ut_setup, ut_teardown,
9468 test_AES_GCM_auth_encryption_test_case_256_4),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_AES_GCM_auth_encryption_test_case_256_5),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_AES_GCM_auth_encryption_test_case_256_6),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_AES_GCM_auth_encryption_test_case_256_7),
9476 /** AES GCM Authenticated Decryption 256 bits key */
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_AES_GCM_auth_decryption_test_case_256_1),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_AES_GCM_auth_decryption_test_case_256_2),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_AES_GCM_auth_decryption_test_case_256_3),
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_AES_GCM_auth_decryption_test_case_256_4),
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_AES_GCM_auth_decryption_test_case_256_5),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_GCM_auth_decryption_test_case_256_6),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_AES_GCM_auth_decryption_test_case_256_7),
9492 /** AES GMAC Authentication */
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_AES_GMAC_authentication_test_case_1),
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_AES_GMAC_authentication_verify_test_case_1),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_AES_GMAC_authentication_test_case_2),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_AES_GMAC_authentication_verify_test_case_2),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_AES_GMAC_authentication_test_case_3),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_GMAC_authentication_verify_test_case_3),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_GMAC_authentication_test_case_4),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_GMAC_authentication_verify_test_case_4),
9510 /** AES CCM Authenticated Encryption 128 bits key */
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_AES_CCM_authenticated_encryption_test_case_128_1),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_AES_CCM_authenticated_encryption_test_case_128_2),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_AES_CCM_authenticated_encryption_test_case_128_3),
9518 /** AES CCM Authenticated Decryption 128 bits key*/
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_CCM_authenticated_decryption_test_case_128_1),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_CCM_authenticated_decryption_test_case_128_2),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_CCM_authenticated_decryption_test_case_128_3),
9526 /** AES CCM Authenticated Encryption 192 bits key */
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_CCM_authenticated_encryption_test_case_192_1),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_CCM_authenticated_encryption_test_case_192_2),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_CCM_authenticated_encryption_test_case_192_3),
9534 /** AES CCM Authenticated Decryption 192 bits key*/
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_CCM_authenticated_decryption_test_case_192_1),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_CCM_authenticated_decryption_test_case_192_2),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_CCM_authenticated_decryption_test_case_192_3),
9542 /** AES CCM Authenticated Encryption 256 bits key */
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_CCM_authenticated_encryption_test_case_256_1),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_CCM_authenticated_encryption_test_case_256_2),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_CCM_authenticated_encryption_test_case_256_3),
9550 /** AES CCM Authenticated Decryption 256 bits key*/
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_AES_CCM_authenticated_decryption_test_case_256_1),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_AES_CCM_authenticated_decryption_test_case_256_2),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_AES_CCM_authenticated_decryption_test_case_256_3),
9558 /** Scatter-Gather */
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9562 /** Negative tests */
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 authentication_verify_AES128_GMAC_fail_data_corrupt),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9576 TEST_CASES_END() /**< NULL terminate unit test array */
9580 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9581 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9582 .setup = testsuite_setup,
9583 .teardown = testsuite_teardown,
9584 .unit_test_cases = {
9585 /** AES GCM Authenticated Encryption */
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_GCM_authenticated_encryption_test_case_1),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_GCM_authenticated_encryption_test_case_2),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_AES_GCM_authenticated_encryption_test_case_3),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_GCM_authenticated_encryption_test_case_4),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_authenticated_encryption_test_case_5),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_authenticated_encryption_test_case_6),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_encryption_test_case_7),
9601 /** AES GCM Authenticated Decryption */
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_decryption_test_case_1),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_decryption_test_case_2),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_decryption_test_case_3),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_authenticated_decryption_test_case_4),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_authenticated_decryption_test_case_5),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_authenticated_decryption_test_case_6),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_authenticated_decryption_test_case_7),
9617 /** AES GCM Authenticated Encryption 192 bits key */
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_auth_encryption_test_case_192_1),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_auth_encryption_test_case_192_2),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_auth_encryption_test_case_192_3),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_auth_encryption_test_case_192_4),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_auth_encryption_test_case_192_5),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_encryption_test_case_192_6),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_encryption_test_case_192_7),
9633 /** AES GCM Authenticated Decryption 192 bits key */
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_decryption_test_case_192_1),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_decryption_test_case_192_2),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_decryption_test_case_192_3),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_decryption_test_case_192_4),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_decryption_test_case_192_5),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_decryption_test_case_192_6),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_decryption_test_case_192_7),
9649 /** AES GCM Authenticated Encryption 256 bits key */
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_encryption_test_case_256_1),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_encryption_test_case_256_2),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_encryption_test_case_256_3),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_encryption_test_case_256_4),
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_encryption_test_case_256_5),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_auth_encryption_test_case_256_6),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_auth_encryption_test_case_256_7),
9665 /** AES GCM Authenticated Decryption 256 bits key */
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_decryption_test_case_256_1),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_decryption_test_case_256_2),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_decryption_test_case_256_3),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_auth_decryption_test_case_256_4),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_GCM_auth_decryption_test_case_256_5),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GCM_auth_decryption_test_case_256_6),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GCM_auth_decryption_test_case_256_7),
9681 /** AES GCM Authenticated Encryption big aad size */
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_encryption_test_case_aad_1),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_auth_encryption_test_case_aad_2),
9687 /** AES GCM Authenticated Decryption big aad size */
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GCM_auth_decryption_test_case_aad_1),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_GCM_auth_decryption_test_case_aad_2),
9693 /** AES GMAC Authentication */
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_AES_GMAC_authentication_test_case_1),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_GMAC_authentication_verify_test_case_1),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_GMAC_authentication_test_case_3),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_AES_GMAC_authentication_verify_test_case_3),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GMAC_authentication_test_case_4),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GMAC_authentication_verify_test_case_4),
9707 /** Negative tests */
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 authentication_verify_AES128_GMAC_fail_data_corrupt),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9713 /** Out of place tests */
9714 TEST_CASE_ST(ut_setup, ut_teardown,
9715 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9719 /** Session-less tests */
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9725 /** Scatter-Gather */
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9729 TEST_CASES_END() /**< NULL terminate unit test array */
9733 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9734 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9735 .setup = testsuite_setup,
9736 .teardown = testsuite_teardown,
9737 .unit_test_cases = {
9738 /** KASUMI encrypt only (UEA1) */
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_kasumi_encryption_test_case_1),
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_kasumi_encryption_test_case_1_sgl),
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_kasumi_encryption_test_case_2),
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_kasumi_encryption_test_case_3),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_kasumi_encryption_test_case_4),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_kasumi_encryption_test_case_5),
9751 /** KASUMI decrypt only (UEA1) */
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_kasumi_decryption_test_case_1),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_kasumi_decryption_test_case_2),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_kasumi_decryption_test_case_3),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_kasumi_decryption_test_case_4),
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_kasumi_decryption_test_case_5),
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_kasumi_encryption_test_case_1_oop),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_kasumi_encryption_test_case_1_oop_sgl),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_kasumi_decryption_test_case_1_oop),
9772 /** KASUMI hash only (UIA1) */
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_kasumi_hash_generate_test_case_1),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_kasumi_hash_generate_test_case_2),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_kasumi_hash_generate_test_case_3),
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_kasumi_hash_generate_test_case_4),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_kasumi_hash_generate_test_case_5),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_kasumi_hash_generate_test_case_6),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_kasumi_hash_verify_test_case_1),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_kasumi_hash_verify_test_case_2),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_kasumi_hash_verify_test_case_3),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_kasumi_hash_verify_test_case_4),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_kasumi_hash_verify_test_case_5),
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_kasumi_auth_cipher_test_case_1),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_kasumi_cipher_auth_test_case_1),
9799 TEST_CASES_END() /**< NULL terminate unit test array */
9802 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9803 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9804 .setup = testsuite_setup,
9805 .teardown = testsuite_teardown,
9806 .unit_test_cases = {
9807 /** SNOW 3G encrypt only (UEA2) */
9808 TEST_CASE_ST(ut_setup, ut_teardown,
9809 test_snow3g_encryption_test_case_1),
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_snow3g_encryption_test_case_2),
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 test_snow3g_encryption_test_case_3),
9814 TEST_CASE_ST(ut_setup, ut_teardown,
9815 test_snow3g_encryption_test_case_4),
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 test_snow3g_encryption_test_case_5),
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_snow3g_encryption_test_case_1_oop),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_snow3g_encryption_test_case_1_oop_sgl),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_snow3g_decryption_test_case_1_oop),
9826 TEST_CASE_ST(ut_setup, ut_teardown,
9827 test_snow3g_encryption_test_case_1_offset_oop),
9829 /** SNOW 3G decrypt only (UEA2) */
9830 TEST_CASE_ST(ut_setup, ut_teardown,
9831 test_snow3g_decryption_test_case_1),
9832 TEST_CASE_ST(ut_setup, ut_teardown,
9833 test_snow3g_decryption_test_case_2),
9834 TEST_CASE_ST(ut_setup, ut_teardown,
9835 test_snow3g_decryption_test_case_3),
9836 TEST_CASE_ST(ut_setup, ut_teardown,
9837 test_snow3g_decryption_test_case_4),
9838 TEST_CASE_ST(ut_setup, ut_teardown,
9839 test_snow3g_decryption_test_case_5),
9840 TEST_CASE_ST(ut_setup, ut_teardown,
9841 test_snow3g_hash_generate_test_case_1),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_snow3g_hash_generate_test_case_2),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_snow3g_hash_generate_test_case_3),
9846 /* Tests with buffers which length is not byte-aligned */
9847 TEST_CASE_ST(ut_setup, ut_teardown,
9848 test_snow3g_hash_generate_test_case_4),
9849 TEST_CASE_ST(ut_setup, ut_teardown,
9850 test_snow3g_hash_generate_test_case_5),
9851 TEST_CASE_ST(ut_setup, ut_teardown,
9852 test_snow3g_hash_generate_test_case_6),
9853 TEST_CASE_ST(ut_setup, ut_teardown,
9854 test_snow3g_hash_verify_test_case_1),
9855 TEST_CASE_ST(ut_setup, ut_teardown,
9856 test_snow3g_hash_verify_test_case_2),
9857 TEST_CASE_ST(ut_setup, ut_teardown,
9858 test_snow3g_hash_verify_test_case_3),
9859 /* Tests with buffers which length is not byte-aligned */
9860 TEST_CASE_ST(ut_setup, ut_teardown,
9861 test_snow3g_hash_verify_test_case_4),
9862 TEST_CASE_ST(ut_setup, ut_teardown,
9863 test_snow3g_hash_verify_test_case_5),
9864 TEST_CASE_ST(ut_setup, ut_teardown,
9865 test_snow3g_hash_verify_test_case_6),
9866 TEST_CASE_ST(ut_setup, ut_teardown,
9867 test_snow3g_cipher_auth_test_case_1),
9868 TEST_CASE_ST(ut_setup, ut_teardown,
9869 test_snow3g_auth_cipher_test_case_1),
9871 TEST_CASES_END() /**< NULL terminate unit test array */
9875 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9876 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9877 .setup = testsuite_setup,
9878 .teardown = testsuite_teardown,
9879 .unit_test_cases = {
9880 /** ZUC encrypt only (EEA3) */
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_zuc_encryption_test_case_1),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_zuc_encryption_test_case_2),
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_zuc_encryption_test_case_3),
9887 TEST_CASE_ST(ut_setup, ut_teardown,
9888 test_zuc_encryption_test_case_4),
9889 TEST_CASE_ST(ut_setup, ut_teardown,
9890 test_zuc_encryption_test_case_5),
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 test_zuc_hash_generate_test_case_1),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 test_zuc_hash_generate_test_case_2),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 test_zuc_hash_generate_test_case_3),
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 test_zuc_hash_generate_test_case_4),
9899 TEST_CASE_ST(ut_setup, ut_teardown,
9900 test_zuc_hash_generate_test_case_5),
9901 TEST_CASE_ST(ut_setup, ut_teardown,
9902 test_zuc_encryption_test_case_6_sgl),
9903 TEST_CASES_END() /**< NULL terminate unit test array */
9907 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
9908 .suite_name = "Crypto CAAM JR Unit Test Suite",
9909 .setup = testsuite_setup,
9910 .teardown = testsuite_teardown,
9911 .unit_test_cases = {
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 test_device_configure_invalid_dev_id),
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 test_multi_session),
9917 TEST_CASE_ST(ut_setup, ut_teardown,
9918 test_AES_chain_caam_jr_all),
9919 TEST_CASE_ST(ut_setup, ut_teardown,
9920 test_3DES_chain_caam_jr_all),
9921 TEST_CASE_ST(ut_setup, ut_teardown,
9922 test_AES_cipheronly_caam_jr_all),
9923 TEST_CASE_ST(ut_setup, ut_teardown,
9924 test_3DES_cipheronly_caam_jr_all),
9925 TEST_CASE_ST(ut_setup, ut_teardown,
9926 test_authonly_caam_jr_all),
9928 TEST_CASES_END() /**< NULL terminate unit test array */
9932 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9933 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9934 .setup = testsuite_setup,
9935 .teardown = testsuite_teardown,
9936 .unit_test_cases = {
9937 TEST_CASE_ST(ut_setup, ut_teardown,
9938 test_device_configure_invalid_dev_id),
9939 TEST_CASE_ST(ut_setup, ut_teardown,
9940 test_multi_session),
9942 TEST_CASE_ST(ut_setup, ut_teardown,
9943 test_AES_chain_dpaa_sec_all),
9944 TEST_CASE_ST(ut_setup, ut_teardown,
9945 test_3DES_chain_dpaa_sec_all),
9946 TEST_CASE_ST(ut_setup, ut_teardown,
9947 test_AES_cipheronly_dpaa_sec_all),
9948 TEST_CASE_ST(ut_setup, ut_teardown,
9949 test_3DES_cipheronly_dpaa_sec_all),
9950 TEST_CASE_ST(ut_setup, ut_teardown,
9951 test_authonly_dpaa_sec_all),
9953 /** AES GCM Authenticated Encryption */
9954 TEST_CASE_ST(ut_setup, ut_teardown,
9955 test_AES_GCM_authenticated_encryption_test_case_1),
9956 TEST_CASE_ST(ut_setup, ut_teardown,
9957 test_AES_GCM_authenticated_encryption_test_case_2),
9958 TEST_CASE_ST(ut_setup, ut_teardown,
9959 test_AES_GCM_authenticated_encryption_test_case_3),
9960 TEST_CASE_ST(ut_setup, ut_teardown,
9961 test_AES_GCM_authenticated_encryption_test_case_4),
9962 TEST_CASE_ST(ut_setup, ut_teardown,
9963 test_AES_GCM_authenticated_encryption_test_case_5),
9964 TEST_CASE_ST(ut_setup, ut_teardown,
9965 test_AES_GCM_authenticated_encryption_test_case_6),
9966 TEST_CASE_ST(ut_setup, ut_teardown,
9967 test_AES_GCM_authenticated_encryption_test_case_7),
9969 /** AES GCM Authenticated Decryption */
9970 TEST_CASE_ST(ut_setup, ut_teardown,
9971 test_AES_GCM_authenticated_decryption_test_case_1),
9972 TEST_CASE_ST(ut_setup, ut_teardown,
9973 test_AES_GCM_authenticated_decryption_test_case_2),
9974 TEST_CASE_ST(ut_setup, ut_teardown,
9975 test_AES_GCM_authenticated_decryption_test_case_3),
9976 TEST_CASE_ST(ut_setup, ut_teardown,
9977 test_AES_GCM_authenticated_decryption_test_case_4),
9978 TEST_CASE_ST(ut_setup, ut_teardown,
9979 test_AES_GCM_authenticated_decryption_test_case_5),
9980 TEST_CASE_ST(ut_setup, ut_teardown,
9981 test_AES_GCM_authenticated_decryption_test_case_6),
9982 TEST_CASE_ST(ut_setup, ut_teardown,
9983 test_AES_GCM_authenticated_decryption_test_case_7),
9985 /** AES GCM Authenticated Encryption 256 bits key */
9986 TEST_CASE_ST(ut_setup, ut_teardown,
9987 test_AES_GCM_auth_encryption_test_case_256_1),
9988 TEST_CASE_ST(ut_setup, ut_teardown,
9989 test_AES_GCM_auth_encryption_test_case_256_2),
9990 TEST_CASE_ST(ut_setup, ut_teardown,
9991 test_AES_GCM_auth_encryption_test_case_256_3),
9992 TEST_CASE_ST(ut_setup, ut_teardown,
9993 test_AES_GCM_auth_encryption_test_case_256_4),
9994 TEST_CASE_ST(ut_setup, ut_teardown,
9995 test_AES_GCM_auth_encryption_test_case_256_5),
9996 TEST_CASE_ST(ut_setup, ut_teardown,
9997 test_AES_GCM_auth_encryption_test_case_256_6),
9998 TEST_CASE_ST(ut_setup, ut_teardown,
9999 test_AES_GCM_auth_encryption_test_case_256_7),
10001 /** AES GCM Authenticated Decryption 256 bits key */
10002 TEST_CASE_ST(ut_setup, ut_teardown,
10003 test_AES_GCM_auth_decryption_test_case_256_1),
10004 TEST_CASE_ST(ut_setup, ut_teardown,
10005 test_AES_GCM_auth_decryption_test_case_256_2),
10006 TEST_CASE_ST(ut_setup, ut_teardown,
10007 test_AES_GCM_auth_decryption_test_case_256_3),
10008 TEST_CASE_ST(ut_setup, ut_teardown,
10009 test_AES_GCM_auth_decryption_test_case_256_4),
10010 TEST_CASE_ST(ut_setup, ut_teardown,
10011 test_AES_GCM_auth_decryption_test_case_256_5),
10012 TEST_CASE_ST(ut_setup, ut_teardown,
10013 test_AES_GCM_auth_decryption_test_case_256_6),
10014 TEST_CASE_ST(ut_setup, ut_teardown,
10015 test_AES_GCM_auth_decryption_test_case_256_7),
10017 /** Out of place tests */
10018 TEST_CASE_ST(ut_setup, ut_teardown,
10019 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10020 TEST_CASE_ST(ut_setup, ut_teardown,
10021 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10023 /** Scatter-Gather */
10024 TEST_CASE_ST(ut_setup, ut_teardown,
10025 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10026 TEST_CASE_ST(ut_setup, ut_teardown,
10027 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10028 TEST_CASE_ST(ut_setup, ut_teardown,
10029 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10030 TEST_CASE_ST(ut_setup, ut_teardown,
10031 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10033 TEST_CASES_END() /**< NULL terminate unit test array */
10037 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10038 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10039 .setup = testsuite_setup,
10040 .teardown = testsuite_teardown,
10041 .unit_test_cases = {
10042 TEST_CASE_ST(ut_setup, ut_teardown,
10043 test_device_configure_invalid_dev_id),
10044 TEST_CASE_ST(ut_setup, ut_teardown,
10045 test_multi_session),
10047 TEST_CASE_ST(ut_setup, ut_teardown,
10048 test_AES_chain_dpaa2_sec_all),
10049 TEST_CASE_ST(ut_setup, ut_teardown,
10050 test_3DES_chain_dpaa2_sec_all),
10051 TEST_CASE_ST(ut_setup, ut_teardown,
10052 test_AES_cipheronly_dpaa2_sec_all),
10053 TEST_CASE_ST(ut_setup, ut_teardown,
10054 test_3DES_cipheronly_dpaa2_sec_all),
10055 TEST_CASE_ST(ut_setup, ut_teardown,
10056 test_authonly_dpaa2_sec_all),
10058 /** AES GCM Authenticated Encryption */
10059 TEST_CASE_ST(ut_setup, ut_teardown,
10060 test_AES_GCM_authenticated_encryption_test_case_1),
10061 TEST_CASE_ST(ut_setup, ut_teardown,
10062 test_AES_GCM_authenticated_encryption_test_case_2),
10063 TEST_CASE_ST(ut_setup, ut_teardown,
10064 test_AES_GCM_authenticated_encryption_test_case_3),
10065 TEST_CASE_ST(ut_setup, ut_teardown,
10066 test_AES_GCM_authenticated_encryption_test_case_4),
10067 TEST_CASE_ST(ut_setup, ut_teardown,
10068 test_AES_GCM_authenticated_encryption_test_case_5),
10069 TEST_CASE_ST(ut_setup, ut_teardown,
10070 test_AES_GCM_authenticated_encryption_test_case_6),
10071 TEST_CASE_ST(ut_setup, ut_teardown,
10072 test_AES_GCM_authenticated_encryption_test_case_7),
10074 /** AES GCM Authenticated Decryption */
10075 TEST_CASE_ST(ut_setup, ut_teardown,
10076 test_AES_GCM_authenticated_decryption_test_case_1),
10077 TEST_CASE_ST(ut_setup, ut_teardown,
10078 test_AES_GCM_authenticated_decryption_test_case_2),
10079 TEST_CASE_ST(ut_setup, ut_teardown,
10080 test_AES_GCM_authenticated_decryption_test_case_3),
10081 TEST_CASE_ST(ut_setup, ut_teardown,
10082 test_AES_GCM_authenticated_decryption_test_case_4),
10083 TEST_CASE_ST(ut_setup, ut_teardown,
10084 test_AES_GCM_authenticated_decryption_test_case_5),
10085 TEST_CASE_ST(ut_setup, ut_teardown,
10086 test_AES_GCM_authenticated_decryption_test_case_6),
10087 TEST_CASE_ST(ut_setup, ut_teardown,
10088 test_AES_GCM_authenticated_decryption_test_case_7),
10090 /** AES GCM Authenticated Encryption 192 bits key */
10091 TEST_CASE_ST(ut_setup, ut_teardown,
10092 test_AES_GCM_auth_encryption_test_case_192_1),
10093 TEST_CASE_ST(ut_setup, ut_teardown,
10094 test_AES_GCM_auth_encryption_test_case_192_2),
10095 TEST_CASE_ST(ut_setup, ut_teardown,
10096 test_AES_GCM_auth_encryption_test_case_192_3),
10097 TEST_CASE_ST(ut_setup, ut_teardown,
10098 test_AES_GCM_auth_encryption_test_case_192_4),
10099 TEST_CASE_ST(ut_setup, ut_teardown,
10100 test_AES_GCM_auth_encryption_test_case_192_5),
10101 TEST_CASE_ST(ut_setup, ut_teardown,
10102 test_AES_GCM_auth_encryption_test_case_192_6),
10103 TEST_CASE_ST(ut_setup, ut_teardown,
10104 test_AES_GCM_auth_encryption_test_case_192_7),
10106 /** AES GCM Authenticated Decryption 192 bits key */
10107 TEST_CASE_ST(ut_setup, ut_teardown,
10108 test_AES_GCM_auth_decryption_test_case_192_1),
10109 TEST_CASE_ST(ut_setup, ut_teardown,
10110 test_AES_GCM_auth_decryption_test_case_192_2),
10111 TEST_CASE_ST(ut_setup, ut_teardown,
10112 test_AES_GCM_auth_decryption_test_case_192_3),
10113 TEST_CASE_ST(ut_setup, ut_teardown,
10114 test_AES_GCM_auth_decryption_test_case_192_4),
10115 TEST_CASE_ST(ut_setup, ut_teardown,
10116 test_AES_GCM_auth_decryption_test_case_192_5),
10117 TEST_CASE_ST(ut_setup, ut_teardown,
10118 test_AES_GCM_auth_decryption_test_case_192_6),
10119 TEST_CASE_ST(ut_setup, ut_teardown,
10120 test_AES_GCM_auth_decryption_test_case_192_7),
10122 /** AES GCM Authenticated Encryption 256 bits key */
10123 TEST_CASE_ST(ut_setup, ut_teardown,
10124 test_AES_GCM_auth_encryption_test_case_256_1),
10125 TEST_CASE_ST(ut_setup, ut_teardown,
10126 test_AES_GCM_auth_encryption_test_case_256_2),
10127 TEST_CASE_ST(ut_setup, ut_teardown,
10128 test_AES_GCM_auth_encryption_test_case_256_3),
10129 TEST_CASE_ST(ut_setup, ut_teardown,
10130 test_AES_GCM_auth_encryption_test_case_256_4),
10131 TEST_CASE_ST(ut_setup, ut_teardown,
10132 test_AES_GCM_auth_encryption_test_case_256_5),
10133 TEST_CASE_ST(ut_setup, ut_teardown,
10134 test_AES_GCM_auth_encryption_test_case_256_6),
10135 TEST_CASE_ST(ut_setup, ut_teardown,
10136 test_AES_GCM_auth_encryption_test_case_256_7),
10138 /** AES GCM Authenticated Decryption 256 bits key */
10139 TEST_CASE_ST(ut_setup, ut_teardown,
10140 test_AES_GCM_auth_decryption_test_case_256_1),
10141 TEST_CASE_ST(ut_setup, ut_teardown,
10142 test_AES_GCM_auth_decryption_test_case_256_2),
10143 TEST_CASE_ST(ut_setup, ut_teardown,
10144 test_AES_GCM_auth_decryption_test_case_256_3),
10145 TEST_CASE_ST(ut_setup, ut_teardown,
10146 test_AES_GCM_auth_decryption_test_case_256_4),
10147 TEST_CASE_ST(ut_setup, ut_teardown,
10148 test_AES_GCM_auth_decryption_test_case_256_5),
10149 TEST_CASE_ST(ut_setup, ut_teardown,
10150 test_AES_GCM_auth_decryption_test_case_256_6),
10151 TEST_CASE_ST(ut_setup, ut_teardown,
10152 test_AES_GCM_auth_decryption_test_case_256_7),
10154 /** Out of place tests */
10155 TEST_CASE_ST(ut_setup, ut_teardown,
10156 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10157 TEST_CASE_ST(ut_setup, ut_teardown,
10158 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10160 /** Scatter-Gather */
10161 TEST_CASE_ST(ut_setup, ut_teardown,
10162 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10163 TEST_CASE_ST(ut_setup, ut_teardown,
10164 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10165 TEST_CASE_ST(ut_setup, ut_teardown,
10166 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10167 TEST_CASE_ST(ut_setup, ut_teardown,
10168 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10170 TEST_CASES_END() /**< NULL terminate unit test array */
10174 static struct unit_test_suite cryptodev_null_testsuite = {
10175 .suite_name = "Crypto Device NULL Unit Test Suite",
10176 .setup = testsuite_setup,
10177 .teardown = testsuite_teardown,
10178 .unit_test_cases = {
10179 TEST_CASE_ST(ut_setup, ut_teardown,
10180 test_null_auth_only_operation),
10181 TEST_CASE_ST(ut_setup, ut_teardown,
10182 test_null_cipher_only_operation),
10183 TEST_CASE_ST(ut_setup, ut_teardown,
10184 test_null_cipher_auth_operation),
10185 TEST_CASE_ST(ut_setup, ut_teardown,
10186 test_null_auth_cipher_operation),
10187 TEST_CASE_ST(ut_setup, ut_teardown,
10188 test_null_invalid_operation),
10189 TEST_CASE_ST(ut_setup, ut_teardown,
10190 test_null_burst_operation),
10192 TEST_CASES_END() /**< NULL terminate unit test array */
10196 static struct unit_test_suite cryptodev_armv8_testsuite = {
10197 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10198 .setup = testsuite_setup,
10199 .teardown = testsuite_teardown,
10200 .unit_test_cases = {
10201 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10203 /** Negative tests */
10204 TEST_CASE_ST(ut_setup, ut_teardown,
10205 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10206 TEST_CASE_ST(ut_setup, ut_teardown,
10207 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10209 TEST_CASES_END() /**< NULL terminate unit test array */
10213 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10214 .suite_name = "Crypto Device Marvell Component Test Suite",
10215 .setup = testsuite_setup,
10216 .teardown = testsuite_teardown,
10217 .unit_test_cases = {
10218 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10219 TEST_CASE_ST(ut_setup, ut_teardown,
10220 test_multi_session_random_usage),
10221 TEST_CASE_ST(ut_setup, ut_teardown,
10222 test_AES_chain_mrvl_all),
10223 TEST_CASE_ST(ut_setup, ut_teardown,
10224 test_AES_cipheronly_mrvl_all),
10225 TEST_CASE_ST(ut_setup, ut_teardown,
10226 test_authonly_mrvl_all),
10227 TEST_CASE_ST(ut_setup, ut_teardown,
10228 test_3DES_chain_mrvl_all),
10229 TEST_CASE_ST(ut_setup, ut_teardown,
10230 test_3DES_cipheronly_mrvl_all),
10232 /** Negative tests */
10233 TEST_CASE_ST(ut_setup, ut_teardown,
10234 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10235 TEST_CASE_ST(ut_setup, ut_teardown,
10236 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10237 TEST_CASE_ST(ut_setup, ut_teardown,
10238 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10239 TEST_CASE_ST(ut_setup, ut_teardown,
10240 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10242 TEST_CASES_END() /**< NULL terminate unit test array */
10246 static struct unit_test_suite cryptodev_ccp_testsuite = {
10247 .suite_name = "Crypto Device CCP Unit Test Suite",
10248 .setup = testsuite_setup,
10249 .teardown = testsuite_teardown,
10250 .unit_test_cases = {
10251 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10252 TEST_CASE_ST(ut_setup, ut_teardown,
10253 test_multi_session_random_usage),
10254 TEST_CASE_ST(ut_setup, ut_teardown,
10255 test_AES_chain_ccp_all),
10256 TEST_CASE_ST(ut_setup, ut_teardown,
10257 test_AES_cipheronly_ccp_all),
10258 TEST_CASE_ST(ut_setup, ut_teardown,
10259 test_3DES_chain_ccp_all),
10260 TEST_CASE_ST(ut_setup, ut_teardown,
10261 test_3DES_cipheronly_ccp_all),
10262 TEST_CASE_ST(ut_setup, ut_teardown,
10263 test_authonly_ccp_all),
10265 /** Negative tests */
10266 TEST_CASE_ST(ut_setup, ut_teardown,
10267 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10268 TEST_CASE_ST(ut_setup, ut_teardown,
10269 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10270 TEST_CASE_ST(ut_setup, ut_teardown,
10271 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10272 TEST_CASE_ST(ut_setup, ut_teardown,
10273 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10275 TEST_CASES_END() /**< NULL terminate unit test array */
10279 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10280 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10281 .setup = testsuite_setup,
10282 .teardown = testsuite_teardown,
10283 .unit_test_cases = {
10284 TEST_CASE_ST(ut_setup, ut_teardown,
10285 test_AES_chain_octeontx_all),
10286 TEST_CASE_ST(ut_setup, ut_teardown,
10287 test_AES_cipheronly_octeontx_all),
10288 TEST_CASE_ST(ut_setup, ut_teardown,
10289 test_3DES_chain_octeontx_all),
10290 TEST_CASE_ST(ut_setup, ut_teardown,
10291 test_3DES_cipheronly_octeontx_all),
10292 TEST_CASE_ST(ut_setup, ut_teardown,
10293 test_authonly_octeontx_all),
10295 /** AES GCM Authenticated Encryption */
10296 TEST_CASE_ST(ut_setup, ut_teardown,
10297 test_AES_GCM_authenticated_encryption_test_case_1),
10298 TEST_CASE_ST(ut_setup, ut_teardown,
10299 test_AES_GCM_authenticated_encryption_test_case_2),
10300 TEST_CASE_ST(ut_setup, ut_teardown,
10301 test_AES_GCM_authenticated_encryption_test_case_3),
10302 TEST_CASE_ST(ut_setup, ut_teardown,
10303 test_AES_GCM_authenticated_encryption_test_case_4),
10304 TEST_CASE_ST(ut_setup, ut_teardown,
10305 test_AES_GCM_authenticated_encryption_test_case_5),
10306 TEST_CASE_ST(ut_setup, ut_teardown,
10307 test_AES_GCM_authenticated_encryption_test_case_6),
10308 TEST_CASE_ST(ut_setup, ut_teardown,
10309 test_AES_GCM_authenticated_encryption_test_case_7),
10311 /** AES GCM Authenticated Decryption */
10312 TEST_CASE_ST(ut_setup, ut_teardown,
10313 test_AES_GCM_authenticated_decryption_test_case_1),
10314 TEST_CASE_ST(ut_setup, ut_teardown,
10315 test_AES_GCM_authenticated_decryption_test_case_2),
10316 TEST_CASE_ST(ut_setup, ut_teardown,
10317 test_AES_GCM_authenticated_decryption_test_case_3),
10318 TEST_CASE_ST(ut_setup, ut_teardown,
10319 test_AES_GCM_authenticated_decryption_test_case_4),
10320 TEST_CASE_ST(ut_setup, ut_teardown,
10321 test_AES_GCM_authenticated_decryption_test_case_5),
10322 TEST_CASE_ST(ut_setup, ut_teardown,
10323 test_AES_GCM_authenticated_decryption_test_case_6),
10324 TEST_CASE_ST(ut_setup, ut_teardown,
10325 test_AES_GCM_authenticated_decryption_test_case_7),
10326 /** AES GMAC Authentication */
10327 TEST_CASE_ST(ut_setup, ut_teardown,
10328 test_AES_GMAC_authentication_test_case_1),
10329 TEST_CASE_ST(ut_setup, ut_teardown,
10330 test_AES_GMAC_authentication_verify_test_case_1),
10331 TEST_CASE_ST(ut_setup, ut_teardown,
10332 test_AES_GMAC_authentication_test_case_2),
10333 TEST_CASE_ST(ut_setup, ut_teardown,
10334 test_AES_GMAC_authentication_verify_test_case_2),
10335 TEST_CASE_ST(ut_setup, ut_teardown,
10336 test_AES_GMAC_authentication_test_case_3),
10337 TEST_CASE_ST(ut_setup, ut_teardown,
10338 test_AES_GMAC_authentication_verify_test_case_3),
10340 /** SNOW 3G encrypt only (UEA2) */
10341 TEST_CASE_ST(ut_setup, ut_teardown,
10342 test_snow3g_encryption_test_case_1),
10343 TEST_CASE_ST(ut_setup, ut_teardown,
10344 test_snow3g_encryption_test_case_2),
10345 TEST_CASE_ST(ut_setup, ut_teardown,
10346 test_snow3g_encryption_test_case_3),
10347 TEST_CASE_ST(ut_setup, ut_teardown,
10348 test_snow3g_encryption_test_case_4),
10349 TEST_CASE_ST(ut_setup, ut_teardown,
10350 test_snow3g_encryption_test_case_5),
10352 TEST_CASE_ST(ut_setup, ut_teardown,
10353 test_snow3g_encryption_test_case_1_oop),
10354 TEST_CASE_ST(ut_setup, ut_teardown,
10355 test_snow3g_decryption_test_case_1_oop),
10356 TEST_CASE_ST(ut_setup, ut_teardown,
10357 test_snow3g_encryption_test_case_1_oop_sgl),
10359 /** SNOW 3G decrypt only (UEA2) */
10360 TEST_CASE_ST(ut_setup, ut_teardown,
10361 test_snow3g_decryption_test_case_1),
10362 TEST_CASE_ST(ut_setup, ut_teardown,
10363 test_snow3g_decryption_test_case_2),
10364 TEST_CASE_ST(ut_setup, ut_teardown,
10365 test_snow3g_decryption_test_case_3),
10366 TEST_CASE_ST(ut_setup, ut_teardown,
10367 test_snow3g_decryption_test_case_4),
10368 TEST_CASE_ST(ut_setup, ut_teardown,
10369 test_snow3g_decryption_test_case_5),
10371 TEST_CASE_ST(ut_setup, ut_teardown,
10372 test_snow3g_hash_generate_test_case_1),
10373 TEST_CASE_ST(ut_setup, ut_teardown,
10374 test_snow3g_hash_generate_test_case_2),
10375 TEST_CASE_ST(ut_setup, ut_teardown,
10376 test_snow3g_hash_generate_test_case_3),
10377 TEST_CASE_ST(ut_setup, ut_teardown,
10378 test_snow3g_hash_verify_test_case_1),
10379 TEST_CASE_ST(ut_setup, ut_teardown,
10380 test_snow3g_hash_verify_test_case_2),
10381 TEST_CASE_ST(ut_setup, ut_teardown,
10382 test_snow3g_hash_verify_test_case_3),
10384 /** ZUC encrypt only (EEA3) */
10385 TEST_CASE_ST(ut_setup, ut_teardown,
10386 test_zuc_encryption_test_case_1),
10387 TEST_CASE_ST(ut_setup, ut_teardown,
10388 test_zuc_encryption_test_case_2),
10389 TEST_CASE_ST(ut_setup, ut_teardown,
10390 test_zuc_encryption_test_case_3),
10391 TEST_CASE_ST(ut_setup, ut_teardown,
10392 test_zuc_encryption_test_case_4),
10393 TEST_CASE_ST(ut_setup, ut_teardown,
10394 test_zuc_encryption_test_case_5),
10395 TEST_CASE_ST(ut_setup, ut_teardown,
10396 test_zuc_hash_generate_test_case_1),
10397 TEST_CASE_ST(ut_setup, ut_teardown,
10398 test_zuc_hash_generate_test_case_2),
10399 TEST_CASE_ST(ut_setup, ut_teardown,
10400 test_zuc_hash_generate_test_case_3),
10401 TEST_CASE_ST(ut_setup, ut_teardown,
10402 test_zuc_hash_generate_test_case_4),
10403 TEST_CASE_ST(ut_setup, ut_teardown,
10404 test_zuc_hash_generate_test_case_5),
10405 TEST_CASE_ST(ut_setup, ut_teardown,
10406 test_zuc_encryption_test_case_6_sgl),
10408 /** KASUMI encrypt only (UEA1) */
10409 TEST_CASE_ST(ut_setup, ut_teardown,
10410 test_kasumi_encryption_test_case_1),
10411 TEST_CASE_ST(ut_setup, ut_teardown,
10412 test_kasumi_encryption_test_case_2),
10413 TEST_CASE_ST(ut_setup, ut_teardown,
10414 test_kasumi_encryption_test_case_3),
10415 TEST_CASE_ST(ut_setup, ut_teardown,
10416 test_kasumi_encryption_test_case_4),
10417 TEST_CASE_ST(ut_setup, ut_teardown,
10418 test_kasumi_encryption_test_case_5),
10419 TEST_CASE_ST(ut_setup, ut_teardown,
10420 test_kasumi_encryption_test_case_1_sgl),
10421 TEST_CASE_ST(ut_setup, ut_teardown,
10422 test_kasumi_encryption_test_case_1_oop_sgl),
10423 /** KASUMI decrypt only (UEA1) */
10424 TEST_CASE_ST(ut_setup, ut_teardown,
10425 test_kasumi_decryption_test_case_1),
10426 TEST_CASE_ST(ut_setup, ut_teardown,
10427 test_kasumi_decryption_test_case_2),
10428 TEST_CASE_ST(ut_setup, ut_teardown,
10429 test_kasumi_decryption_test_case_3),
10430 TEST_CASE_ST(ut_setup, ut_teardown,
10431 test_kasumi_decryption_test_case_4),
10432 TEST_CASE_ST(ut_setup, ut_teardown,
10433 test_kasumi_decryption_test_case_5),
10435 TEST_CASE_ST(ut_setup, ut_teardown,
10436 test_kasumi_encryption_test_case_1_oop),
10437 TEST_CASE_ST(ut_setup, ut_teardown,
10438 test_kasumi_decryption_test_case_1_oop),
10440 /** KASUMI hash only (UIA1) */
10441 TEST_CASE_ST(ut_setup, ut_teardown,
10442 test_kasumi_hash_generate_test_case_1),
10443 TEST_CASE_ST(ut_setup, ut_teardown,
10444 test_kasumi_hash_generate_test_case_2),
10445 TEST_CASE_ST(ut_setup, ut_teardown,
10446 test_kasumi_hash_generate_test_case_3),
10447 TEST_CASE_ST(ut_setup, ut_teardown,
10448 test_kasumi_hash_generate_test_case_4),
10449 TEST_CASE_ST(ut_setup, ut_teardown,
10450 test_kasumi_hash_generate_test_case_5),
10451 TEST_CASE_ST(ut_setup, ut_teardown,
10452 test_kasumi_hash_generate_test_case_6),
10453 TEST_CASE_ST(ut_setup, ut_teardown,
10454 test_kasumi_hash_verify_test_case_1),
10455 TEST_CASE_ST(ut_setup, ut_teardown,
10456 test_kasumi_hash_verify_test_case_2),
10457 TEST_CASE_ST(ut_setup, ut_teardown,
10458 test_kasumi_hash_verify_test_case_3),
10459 TEST_CASE_ST(ut_setup, ut_teardown,
10460 test_kasumi_hash_verify_test_case_4),
10461 TEST_CASE_ST(ut_setup, ut_teardown,
10462 test_kasumi_hash_verify_test_case_5),
10465 TEST_CASE_ST(ut_setup, ut_teardown,
10466 test_null_cipher_only_operation),
10467 TEST_CASE_ST(ut_setup, ut_teardown,
10468 test_null_auth_only_operation),
10469 TEST_CASE_ST(ut_setup, ut_teardown,
10470 test_null_cipher_auth_operation),
10471 TEST_CASE_ST(ut_setup, ut_teardown,
10472 test_null_auth_cipher_operation),
10474 /** Negative tests */
10475 TEST_CASE_ST(ut_setup, ut_teardown,
10476 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10477 TEST_CASE_ST(ut_setup, ut_teardown,
10478 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10479 TEST_CASE_ST(ut_setup, ut_teardown,
10480 authentication_verify_AES128_GMAC_fail_data_corrupt),
10481 TEST_CASE_ST(ut_setup, ut_teardown,
10482 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10483 TEST_CASE_ST(ut_setup, ut_teardown,
10484 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10485 TEST_CASE_ST(ut_setup, ut_teardown,
10486 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10487 TEST_CASES_END() /**< NULL terminate unit test array */
10492 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10494 gbl_driver_id = rte_cryptodev_driver_id_get(
10495 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10497 if (gbl_driver_id == -1) {
10498 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10499 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10500 "are enabled in config file to run this testsuite.\n");
10501 return TEST_SKIPPED;
10504 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10508 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10510 gbl_driver_id = rte_cryptodev_driver_id_get(
10511 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10513 if (gbl_driver_id == -1) {
10514 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10515 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10516 "in config file to run this testsuite.\n");
10517 return TEST_FAILED;
10520 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10524 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10526 gbl_driver_id = rte_cryptodev_driver_id_get(
10527 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10529 if (gbl_driver_id == -1) {
10530 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10531 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10532 "in config file to run this testsuite.\n");
10533 return TEST_SKIPPED;
10536 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10540 test_cryptodev_openssl(void)
10542 gbl_driver_id = rte_cryptodev_driver_id_get(
10543 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10545 if (gbl_driver_id == -1) {
10546 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10547 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10548 "in config file to run this testsuite.\n");
10549 return TEST_SKIPPED;
10552 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10556 test_cryptodev_aesni_gcm(void)
10558 gbl_driver_id = rte_cryptodev_driver_id_get(
10559 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10561 if (gbl_driver_id == -1) {
10562 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10563 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10564 "in config file to run this testsuite.\n");
10565 return TEST_SKIPPED;
10568 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10572 test_cryptodev_null(void)
10574 gbl_driver_id = rte_cryptodev_driver_id_get(
10575 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10577 if (gbl_driver_id == -1) {
10578 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10579 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10580 "in config file to run this testsuite.\n");
10581 return TEST_SKIPPED;
10584 return unit_test_suite_runner(&cryptodev_null_testsuite);
10588 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10590 gbl_driver_id = rte_cryptodev_driver_id_get(
10591 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10593 if (gbl_driver_id == -1) {
10594 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10595 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10596 "in config file to run this testsuite.\n");
10597 return TEST_SKIPPED;
10600 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10604 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10606 gbl_driver_id = rte_cryptodev_driver_id_get(
10607 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10609 if (gbl_driver_id == -1) {
10610 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10611 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10612 "in config file to run this testsuite.\n");
10613 return TEST_SKIPPED;
10616 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10620 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10622 gbl_driver_id = rte_cryptodev_driver_id_get(
10623 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10625 if (gbl_driver_id == -1) {
10626 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10627 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10628 "in config file to run this testsuite.\n");
10629 return TEST_SKIPPED;
10632 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10636 test_cryptodev_armv8(void)
10638 gbl_driver_id = rte_cryptodev_driver_id_get(
10639 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10641 if (gbl_driver_id == -1) {
10642 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10643 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10644 "in config file to run this testsuite.\n");
10645 return TEST_SKIPPED;
10648 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10652 test_cryptodev_mrvl(void)
10654 gbl_driver_id = rte_cryptodev_driver_id_get(
10655 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10657 if (gbl_driver_id == -1) {
10658 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10659 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10660 "in config file to run this testsuite.\n");
10661 return TEST_SKIPPED;
10664 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10667 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10670 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10672 gbl_driver_id = rte_cryptodev_driver_id_get(
10673 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10675 if (gbl_driver_id == -1) {
10676 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10677 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10678 "in config file to run this testsuite.\n");
10679 return TEST_SKIPPED;
10682 if (rte_cryptodev_driver_id_get(
10683 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10684 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10685 " enabled in config file to run this testsuite.\n");
10686 return TEST_SKIPPED;
10688 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10691 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10696 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10698 gbl_driver_id = rte_cryptodev_driver_id_get(
10699 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10701 if (gbl_driver_id == -1) {
10702 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10703 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10704 "in config file to run this testsuite.\n");
10705 return TEST_SKIPPED;
10708 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10712 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10714 gbl_driver_id = rte_cryptodev_driver_id_get(
10715 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10717 if (gbl_driver_id == -1) {
10718 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10719 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10720 "in config file to run this testsuite.\n");
10721 return TEST_SKIPPED;
10724 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10728 test_cryptodev_ccp(void)
10730 gbl_driver_id = rte_cryptodev_driver_id_get(
10731 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10733 if (gbl_driver_id == -1) {
10734 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10735 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10736 "in config file to run this testsuite.\n");
10737 return TEST_FAILED;
10740 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10744 test_cryptodev_octeontx(void)
10746 gbl_driver_id = rte_cryptodev_driver_id_get(
10747 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10748 if (gbl_driver_id == -1) {
10749 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10750 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10751 "enabled in config file to run this "
10753 return TEST_FAILED;
10755 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10759 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10761 gbl_driver_id = rte_cryptodev_driver_id_get(
10762 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10764 if (gbl_driver_id == -1) {
10765 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10766 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10767 "in config file to run this testsuite.\n");
10768 return TEST_FAILED;
10771 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10774 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10775 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10776 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10777 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10778 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10779 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10780 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10781 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10782 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10783 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10784 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10785 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10786 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10787 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10788 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10789 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);