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_dpaa_sec_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_DPAA_SEC_PMD)),
1891 BLKCIPHER_AES_CHAIN_TYPE);
1893 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1895 return TEST_SUCCESS;
1899 test_AES_cipheronly_dpaa_sec_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_DPAA_SEC_PMD)),
1910 BLKCIPHER_AES_CIPHERONLY_TYPE);
1912 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1914 return TEST_SUCCESS;
1918 test_authonly_dpaa_sec_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_DPAA_SEC_PMD)),
1929 BLKCIPHER_AUTHONLY_TYPE);
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1937 test_AES_chain_dpaa2_sec_all(void)
1939 struct crypto_testsuite_params *ts_params = &testsuite_params;
1942 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1943 ts_params->op_mpool,
1944 ts_params->session_mpool,
1945 ts_params->valid_devs[0],
1946 rte_cryptodev_driver_id_get(
1947 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1948 BLKCIPHER_AES_CHAIN_TYPE);
1950 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1952 return TEST_SUCCESS;
1956 test_AES_cipheronly_dpaa2_sec_all(void)
1958 struct crypto_testsuite_params *ts_params = &testsuite_params;
1961 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1962 ts_params->op_mpool,
1963 ts_params->session_mpool,
1964 ts_params->valid_devs[0],
1965 rte_cryptodev_driver_id_get(
1966 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1967 BLKCIPHER_AES_CIPHERONLY_TYPE);
1969 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1971 return TEST_SUCCESS;
1975 test_authonly_dpaa2_sec_all(void)
1977 struct crypto_testsuite_params *ts_params = &testsuite_params;
1980 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1981 ts_params->op_mpool,
1982 ts_params->session_mpool,
1983 ts_params->valid_devs[0],
1984 rte_cryptodev_driver_id_get(
1985 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1986 BLKCIPHER_AUTHONLY_TYPE);
1988 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1990 return TEST_SUCCESS;
1994 test_authonly_openssl_all(void)
1996 struct crypto_testsuite_params *ts_params = &testsuite_params;
1999 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2000 ts_params->op_mpool,
2001 ts_params->session_mpool,
2002 ts_params->valid_devs[0],
2003 rte_cryptodev_driver_id_get(
2004 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2005 BLKCIPHER_AUTHONLY_TYPE);
2007 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2009 return TEST_SUCCESS;
2013 test_authonly_ccp_all(void)
2015 struct crypto_testsuite_params *ts_params = &testsuite_params;
2018 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2019 ts_params->op_mpool,
2020 ts_params->session_mpool,
2021 ts_params->valid_devs[0],
2022 rte_cryptodev_driver_id_get(
2023 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2024 BLKCIPHER_AUTHONLY_TYPE);
2026 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2028 return TEST_SUCCESS;
2032 test_AES_chain_armv8_all(void)
2034 struct crypto_testsuite_params *ts_params = &testsuite_params;
2037 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2038 ts_params->op_mpool,
2039 ts_params->session_mpool,
2040 ts_params->valid_devs[0],
2041 rte_cryptodev_driver_id_get(
2042 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2043 BLKCIPHER_AES_CHAIN_TYPE);
2045 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2047 return TEST_SUCCESS;
2051 test_AES_chain_mrvl_all(void)
2053 struct crypto_testsuite_params *ts_params = &testsuite_params;
2056 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2057 ts_params->op_mpool,
2058 ts_params->session_mpool,
2059 ts_params->valid_devs[0],
2060 rte_cryptodev_driver_id_get(
2061 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2062 BLKCIPHER_AES_CHAIN_TYPE);
2064 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2066 return TEST_SUCCESS;
2070 test_AES_cipheronly_mrvl_all(void)
2072 struct crypto_testsuite_params *ts_params = &testsuite_params;
2075 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2076 ts_params->op_mpool,
2077 ts_params->session_mpool,
2078 ts_params->valid_devs[0],
2079 rte_cryptodev_driver_id_get(
2080 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2081 BLKCIPHER_AES_CIPHERONLY_TYPE);
2083 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2085 return TEST_SUCCESS;
2089 test_authonly_mrvl_all(void)
2091 struct crypto_testsuite_params *ts_params = &testsuite_params;
2094 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2095 ts_params->op_mpool,
2096 ts_params->session_mpool,
2097 ts_params->valid_devs[0],
2098 rte_cryptodev_driver_id_get(
2099 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2100 BLKCIPHER_AUTHONLY_TYPE);
2102 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2104 return TEST_SUCCESS;
2108 test_3DES_chain_mrvl_all(void)
2110 struct crypto_testsuite_params *ts_params = &testsuite_params;
2113 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2114 ts_params->op_mpool,
2115 ts_params->session_mpool,
2116 ts_params->valid_devs[0],
2117 rte_cryptodev_driver_id_get(
2118 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2119 BLKCIPHER_3DES_CHAIN_TYPE);
2121 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2123 return TEST_SUCCESS;
2127 test_3DES_cipheronly_mrvl_all(void)
2129 struct crypto_testsuite_params *ts_params = &testsuite_params;
2132 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2133 ts_params->op_mpool,
2134 ts_params->session_mpool,
2135 ts_params->valid_devs[0],
2136 rte_cryptodev_driver_id_get(
2137 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2138 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2140 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2142 return TEST_SUCCESS;
2145 /* ***** SNOW 3G Tests ***** */
2147 create_wireless_algo_hash_session(uint8_t dev_id,
2148 const uint8_t *key, const uint8_t key_len,
2149 const uint8_t iv_len, const uint8_t auth_len,
2150 enum rte_crypto_auth_operation op,
2151 enum rte_crypto_auth_algorithm algo)
2153 uint8_t hash_key[key_len];
2155 struct crypto_testsuite_params *ts_params = &testsuite_params;
2156 struct crypto_unittest_params *ut_params = &unittest_params;
2158 memcpy(hash_key, key, key_len);
2160 debug_hexdump(stdout, "key:", key, key_len);
2162 /* Setup Authentication Parameters */
2163 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2164 ut_params->auth_xform.next = NULL;
2166 ut_params->auth_xform.auth.op = op;
2167 ut_params->auth_xform.auth.algo = algo;
2168 ut_params->auth_xform.auth.key.length = key_len;
2169 ut_params->auth_xform.auth.key.data = hash_key;
2170 ut_params->auth_xform.auth.digest_length = auth_len;
2171 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2172 ut_params->auth_xform.auth.iv.length = iv_len;
2173 ut_params->sess = rte_cryptodev_sym_session_create(
2174 ts_params->session_mpool);
2176 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2177 &ut_params->auth_xform, ts_params->session_mpool);
2178 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2183 create_wireless_algo_cipher_session(uint8_t dev_id,
2184 enum rte_crypto_cipher_operation op,
2185 enum rte_crypto_cipher_algorithm algo,
2186 const uint8_t *key, const uint8_t key_len,
2189 uint8_t cipher_key[key_len];
2191 struct crypto_testsuite_params *ts_params = &testsuite_params;
2192 struct crypto_unittest_params *ut_params = &unittest_params;
2194 memcpy(cipher_key, key, key_len);
2196 /* Setup Cipher Parameters */
2197 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2198 ut_params->cipher_xform.next = NULL;
2200 ut_params->cipher_xform.cipher.algo = algo;
2201 ut_params->cipher_xform.cipher.op = op;
2202 ut_params->cipher_xform.cipher.key.data = cipher_key;
2203 ut_params->cipher_xform.cipher.key.length = key_len;
2204 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2205 ut_params->cipher_xform.cipher.iv.length = iv_len;
2207 debug_hexdump(stdout, "key:", key, key_len);
2209 /* Create Crypto session */
2210 ut_params->sess = rte_cryptodev_sym_session_create(
2211 ts_params->session_mpool);
2213 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2214 &ut_params->cipher_xform, ts_params->session_mpool);
2215 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2220 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2221 unsigned int cipher_len,
2222 unsigned int cipher_offset)
2224 struct crypto_testsuite_params *ts_params = &testsuite_params;
2225 struct crypto_unittest_params *ut_params = &unittest_params;
2227 /* Generate Crypto op data structure */
2228 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2229 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2230 TEST_ASSERT_NOT_NULL(ut_params->op,
2231 "Failed to allocate pktmbuf offload");
2233 /* Set crypto operation data parameters */
2234 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2236 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2238 /* set crypto operation source mbuf */
2239 sym_op->m_src = ut_params->ibuf;
2242 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2244 sym_op->cipher.data.length = cipher_len;
2245 sym_op->cipher.data.offset = cipher_offset;
2250 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2251 unsigned int cipher_len,
2252 unsigned int cipher_offset)
2254 struct crypto_testsuite_params *ts_params = &testsuite_params;
2255 struct crypto_unittest_params *ut_params = &unittest_params;
2257 /* Generate Crypto op data structure */
2258 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2259 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2260 TEST_ASSERT_NOT_NULL(ut_params->op,
2261 "Failed to allocate pktmbuf offload");
2263 /* Set crypto operation data parameters */
2264 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2266 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2268 /* set crypto operation source mbuf */
2269 sym_op->m_src = ut_params->ibuf;
2270 sym_op->m_dst = ut_params->obuf;
2273 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2275 sym_op->cipher.data.length = cipher_len;
2276 sym_op->cipher.data.offset = cipher_offset;
2281 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2282 enum rte_crypto_cipher_operation cipher_op,
2283 enum rte_crypto_auth_operation auth_op,
2284 enum rte_crypto_auth_algorithm auth_algo,
2285 enum rte_crypto_cipher_algorithm cipher_algo,
2286 const uint8_t *key, uint8_t key_len,
2287 uint8_t auth_iv_len, uint8_t auth_len,
2288 uint8_t cipher_iv_len)
2291 uint8_t cipher_auth_key[key_len];
2293 struct crypto_testsuite_params *ts_params = &testsuite_params;
2294 struct crypto_unittest_params *ut_params = &unittest_params;
2296 memcpy(cipher_auth_key, key, key_len);
2298 /* Setup Authentication Parameters */
2299 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2300 ut_params->auth_xform.next = NULL;
2302 ut_params->auth_xform.auth.op = auth_op;
2303 ut_params->auth_xform.auth.algo = auth_algo;
2304 ut_params->auth_xform.auth.key.length = key_len;
2305 /* Hash key = cipher key */
2306 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2307 ut_params->auth_xform.auth.digest_length = auth_len;
2308 /* Auth IV will be after cipher IV */
2309 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2310 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2312 /* Setup Cipher Parameters */
2313 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2314 ut_params->cipher_xform.next = &ut_params->auth_xform;
2316 ut_params->cipher_xform.cipher.algo = cipher_algo;
2317 ut_params->cipher_xform.cipher.op = cipher_op;
2318 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2319 ut_params->cipher_xform.cipher.key.length = key_len;
2320 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2321 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2323 debug_hexdump(stdout, "key:", key, key_len);
2325 /* Create Crypto session*/
2326 ut_params->sess = rte_cryptodev_sym_session_create(
2327 ts_params->session_mpool);
2329 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2330 &ut_params->cipher_xform, ts_params->session_mpool);
2332 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2337 create_wireless_cipher_auth_session(uint8_t dev_id,
2338 enum rte_crypto_cipher_operation cipher_op,
2339 enum rte_crypto_auth_operation auth_op,
2340 enum rte_crypto_auth_algorithm auth_algo,
2341 enum rte_crypto_cipher_algorithm cipher_algo,
2342 const struct wireless_test_data *tdata)
2344 const uint8_t key_len = tdata->key.len;
2345 uint8_t cipher_auth_key[key_len];
2347 struct crypto_testsuite_params *ts_params = &testsuite_params;
2348 struct crypto_unittest_params *ut_params = &unittest_params;
2349 const uint8_t *key = tdata->key.data;
2350 const uint8_t auth_len = tdata->digest.len;
2351 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2352 uint8_t auth_iv_len = tdata->auth_iv.len;
2354 memcpy(cipher_auth_key, key, key_len);
2356 /* Setup Authentication Parameters */
2357 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2358 ut_params->auth_xform.next = NULL;
2360 ut_params->auth_xform.auth.op = auth_op;
2361 ut_params->auth_xform.auth.algo = auth_algo;
2362 ut_params->auth_xform.auth.key.length = key_len;
2363 /* Hash key = cipher key */
2364 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2365 ut_params->auth_xform.auth.digest_length = auth_len;
2366 /* Auth IV will be after cipher IV */
2367 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2368 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2370 /* Setup Cipher Parameters */
2371 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2372 ut_params->cipher_xform.next = &ut_params->auth_xform;
2374 ut_params->cipher_xform.cipher.algo = cipher_algo;
2375 ut_params->cipher_xform.cipher.op = cipher_op;
2376 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2377 ut_params->cipher_xform.cipher.key.length = key_len;
2378 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2379 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2382 debug_hexdump(stdout, "key:", key, key_len);
2384 /* Create Crypto session*/
2385 ut_params->sess = rte_cryptodev_sym_session_create(
2386 ts_params->session_mpool);
2388 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2389 &ut_params->cipher_xform, ts_params->session_mpool);
2391 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2396 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2397 const struct wireless_test_data *tdata)
2399 return create_wireless_cipher_auth_session(dev_id,
2400 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2401 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2402 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2406 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2407 enum rte_crypto_cipher_operation cipher_op,
2408 enum rte_crypto_auth_operation auth_op,
2409 enum rte_crypto_auth_algorithm auth_algo,
2410 enum rte_crypto_cipher_algorithm cipher_algo,
2411 const uint8_t *key, const uint8_t key_len,
2412 uint8_t auth_iv_len, uint8_t auth_len,
2413 uint8_t cipher_iv_len)
2415 uint8_t auth_cipher_key[key_len];
2417 struct crypto_testsuite_params *ts_params = &testsuite_params;
2418 struct crypto_unittest_params *ut_params = &unittest_params;
2420 memcpy(auth_cipher_key, key, key_len);
2422 /* Setup Authentication Parameters */
2423 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2424 ut_params->auth_xform.auth.op = auth_op;
2425 ut_params->auth_xform.next = &ut_params->cipher_xform;
2426 ut_params->auth_xform.auth.algo = auth_algo;
2427 ut_params->auth_xform.auth.key.length = key_len;
2428 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2429 ut_params->auth_xform.auth.digest_length = auth_len;
2430 /* Auth IV will be after cipher IV */
2431 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2432 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2434 /* Setup Cipher Parameters */
2435 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2436 ut_params->cipher_xform.next = NULL;
2437 ut_params->cipher_xform.cipher.algo = cipher_algo;
2438 ut_params->cipher_xform.cipher.op = cipher_op;
2439 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2440 ut_params->cipher_xform.cipher.key.length = key_len;
2441 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2442 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2444 debug_hexdump(stdout, "key:", key, key_len);
2446 /* Create Crypto session*/
2447 ut_params->sess = rte_cryptodev_sym_session_create(
2448 ts_params->session_mpool);
2450 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2451 &ut_params->auth_xform, ts_params->session_mpool);
2453 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2460 unsigned int auth_tag_len,
2461 const uint8_t *iv, unsigned int iv_len,
2462 unsigned int data_pad_len,
2463 enum rte_crypto_auth_operation op,
2464 unsigned int auth_len, unsigned int auth_offset)
2466 struct crypto_testsuite_params *ts_params = &testsuite_params;
2468 struct crypto_unittest_params *ut_params = &unittest_params;
2470 /* Generate Crypto op data structure */
2471 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2472 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2473 TEST_ASSERT_NOT_NULL(ut_params->op,
2474 "Failed to allocate pktmbuf offload");
2476 /* Set crypto operation data parameters */
2477 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2479 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2481 /* set crypto operation source mbuf */
2482 sym_op->m_src = ut_params->ibuf;
2485 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2488 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2489 ut_params->ibuf, auth_tag_len);
2491 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2492 "no room to append auth tag");
2493 ut_params->digest = sym_op->auth.digest.data;
2494 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2495 ut_params->ibuf, data_pad_len);
2496 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2497 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2499 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2501 debug_hexdump(stdout, "digest:",
2502 sym_op->auth.digest.data,
2505 sym_op->auth.data.length = auth_len;
2506 sym_op->auth.data.offset = auth_offset;
2512 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2513 enum rte_crypto_auth_operation op)
2515 struct crypto_testsuite_params *ts_params = &testsuite_params;
2516 struct crypto_unittest_params *ut_params = &unittest_params;
2518 const uint8_t *auth_tag = tdata->digest.data;
2519 const unsigned int auth_tag_len = tdata->digest.len;
2520 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2521 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2523 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2524 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2525 const uint8_t *auth_iv = tdata->auth_iv.data;
2526 const uint8_t auth_iv_len = tdata->auth_iv.len;
2527 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2528 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2530 /* Generate Crypto op data structure */
2531 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2532 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2533 TEST_ASSERT_NOT_NULL(ut_params->op,
2534 "Failed to allocate pktmbuf offload");
2535 /* Set crypto operation data parameters */
2536 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2538 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2540 /* set crypto operation source mbuf */
2541 sym_op->m_src = ut_params->ibuf;
2544 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2545 ut_params->ibuf, auth_tag_len);
2547 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2548 "no room to append auth tag");
2549 ut_params->digest = sym_op->auth.digest.data;
2550 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2551 ut_params->ibuf, data_pad_len);
2552 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2553 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2555 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2557 debug_hexdump(stdout, "digest:",
2558 sym_op->auth.digest.data,
2561 /* Copy cipher and auth IVs at the end of the crypto operation */
2562 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2564 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2565 iv_ptr += cipher_iv_len;
2566 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2568 sym_op->cipher.data.length = cipher_len;
2569 sym_op->cipher.data.offset = 0;
2570 sym_op->auth.data.length = auth_len;
2571 sym_op->auth.data.offset = 0;
2577 create_zuc_cipher_hash_generate_operation(
2578 const struct wireless_test_data *tdata)
2580 return create_wireless_cipher_hash_operation(tdata,
2581 RTE_CRYPTO_AUTH_OP_GENERATE);
2585 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2586 const unsigned auth_tag_len,
2587 const uint8_t *auth_iv, uint8_t auth_iv_len,
2588 unsigned data_pad_len,
2589 enum rte_crypto_auth_operation op,
2590 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2591 const unsigned cipher_len, const unsigned cipher_offset,
2592 const unsigned auth_len, const unsigned auth_offset)
2594 struct crypto_testsuite_params *ts_params = &testsuite_params;
2595 struct crypto_unittest_params *ut_params = &unittest_params;
2597 /* Generate Crypto op data structure */
2598 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2599 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2600 TEST_ASSERT_NOT_NULL(ut_params->op,
2601 "Failed to allocate pktmbuf offload");
2602 /* Set crypto operation data parameters */
2603 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2605 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2607 /* set crypto operation source mbuf */
2608 sym_op->m_src = ut_params->ibuf;
2611 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2612 ut_params->ibuf, auth_tag_len);
2614 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2615 "no room to append auth tag");
2616 ut_params->digest = sym_op->auth.digest.data;
2617 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2618 ut_params->ibuf, data_pad_len);
2619 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2620 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2622 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2624 debug_hexdump(stdout, "digest:",
2625 sym_op->auth.digest.data,
2628 /* Copy cipher and auth IVs at the end of the crypto operation */
2629 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2631 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2632 iv_ptr += cipher_iv_len;
2633 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2635 sym_op->cipher.data.length = cipher_len;
2636 sym_op->cipher.data.offset = cipher_offset;
2637 sym_op->auth.data.length = auth_len;
2638 sym_op->auth.data.offset = auth_offset;
2644 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2645 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2646 const uint8_t *auth_iv, uint8_t auth_iv_len,
2647 unsigned int data_pad_len,
2648 unsigned int cipher_len, unsigned int cipher_offset,
2649 unsigned int auth_len, unsigned int auth_offset)
2651 struct crypto_testsuite_params *ts_params = &testsuite_params;
2652 struct crypto_unittest_params *ut_params = &unittest_params;
2654 /* Generate Crypto op data structure */
2655 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2656 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2657 TEST_ASSERT_NOT_NULL(ut_params->op,
2658 "Failed to allocate pktmbuf offload");
2660 /* Set crypto operation data parameters */
2661 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2663 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2665 /* set crypto operation source mbuf */
2666 sym_op->m_src = ut_params->ibuf;
2669 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2670 ut_params->ibuf, auth_tag_len);
2672 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2673 "no room to append auth tag");
2675 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2676 ut_params->ibuf, data_pad_len);
2678 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2680 debug_hexdump(stdout, "digest:",
2681 sym_op->auth.digest.data,
2684 /* Copy cipher and auth IVs at the end of the crypto operation */
2685 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2687 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2688 iv_ptr += cipher_iv_len;
2689 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2691 sym_op->cipher.data.length = cipher_len;
2692 sym_op->cipher.data.offset = cipher_offset;
2694 sym_op->auth.data.length = auth_len;
2695 sym_op->auth.data.offset = auth_offset;
2701 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2703 struct crypto_testsuite_params *ts_params = &testsuite_params;
2704 struct crypto_unittest_params *ut_params = &unittest_params;
2707 unsigned plaintext_pad_len;
2708 unsigned plaintext_len;
2711 /* Create SNOW 3G session */
2712 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2713 tdata->key.data, tdata->key.len,
2714 tdata->auth_iv.len, tdata->digest.len,
2715 RTE_CRYPTO_AUTH_OP_GENERATE,
2716 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2720 /* alloc mbuf and set payload */
2721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2723 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2724 rte_pktmbuf_tailroom(ut_params->ibuf));
2726 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2727 /* Append data which is padded to a multiple of */
2728 /* the algorithms block size */
2729 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2730 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2732 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2734 /* Create SNOW 3G operation */
2735 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2736 tdata->auth_iv.data, tdata->auth_iv.len,
2737 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2738 tdata->validAuthLenInBits.len,
2743 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2745 ut_params->obuf = ut_params->op->sym->m_src;
2746 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2747 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2748 + plaintext_pad_len;
2751 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2754 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2755 "SNOW 3G Generated auth tag not as expected");
2761 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2763 struct crypto_testsuite_params *ts_params = &testsuite_params;
2764 struct crypto_unittest_params *ut_params = &unittest_params;
2767 unsigned plaintext_pad_len;
2768 unsigned plaintext_len;
2771 /* Create SNOW 3G session */
2772 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2773 tdata->key.data, tdata->key.len,
2774 tdata->auth_iv.len, tdata->digest.len,
2775 RTE_CRYPTO_AUTH_OP_VERIFY,
2776 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2779 /* alloc mbuf and set payload */
2780 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2782 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2783 rte_pktmbuf_tailroom(ut_params->ibuf));
2785 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2786 /* Append data which is padded to a multiple of */
2787 /* the algorithms block size */
2788 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2789 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2791 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2793 /* Create SNOW 3G operation */
2794 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2796 tdata->auth_iv.data, tdata->auth_iv.len,
2798 RTE_CRYPTO_AUTH_OP_VERIFY,
2799 tdata->validAuthLenInBits.len,
2804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2807 ut_params->obuf = ut_params->op->sym->m_src;
2808 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2809 + plaintext_pad_len;
2812 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2821 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2823 struct crypto_testsuite_params *ts_params = &testsuite_params;
2824 struct crypto_unittest_params *ut_params = &unittest_params;
2827 unsigned plaintext_pad_len;
2828 unsigned plaintext_len;
2831 /* Create KASUMI session */
2832 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2833 tdata->key.data, tdata->key.len,
2834 0, tdata->digest.len,
2835 RTE_CRYPTO_AUTH_OP_GENERATE,
2836 RTE_CRYPTO_AUTH_KASUMI_F9);
2840 /* alloc mbuf and set payload */
2841 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2843 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2844 rte_pktmbuf_tailroom(ut_params->ibuf));
2846 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2847 /* Append data which is padded to a multiple of */
2848 /* the algorithms block size */
2849 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2850 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2852 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2854 /* Create KASUMI operation */
2855 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2857 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2858 tdata->plaintext.len,
2863 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2865 ut_params->obuf = ut_params->op->sym->m_src;
2866 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2867 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2868 + plaintext_pad_len;
2871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2874 DIGEST_BYTE_LENGTH_KASUMI_F9,
2875 "KASUMI Generated auth tag not as expected");
2881 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2883 struct crypto_testsuite_params *ts_params = &testsuite_params;
2884 struct crypto_unittest_params *ut_params = &unittest_params;
2887 unsigned plaintext_pad_len;
2888 unsigned plaintext_len;
2891 /* Create KASUMI session */
2892 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2893 tdata->key.data, tdata->key.len,
2894 0, tdata->digest.len,
2895 RTE_CRYPTO_AUTH_OP_VERIFY,
2896 RTE_CRYPTO_AUTH_KASUMI_F9);
2899 /* alloc mbuf and set payload */
2900 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2902 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2903 rte_pktmbuf_tailroom(ut_params->ibuf));
2905 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2906 /* Append data which is padded to a multiple */
2907 /* of the algorithms block size */
2908 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2909 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2911 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2913 /* Create KASUMI operation */
2914 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2918 RTE_CRYPTO_AUTH_OP_VERIFY,
2919 tdata->plaintext.len,
2924 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2926 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2927 ut_params->obuf = ut_params->op->sym->m_src;
2928 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2929 + plaintext_pad_len;
2932 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2941 test_snow3g_hash_generate_test_case_1(void)
2943 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2947 test_snow3g_hash_generate_test_case_2(void)
2949 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2953 test_snow3g_hash_generate_test_case_3(void)
2955 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2959 test_snow3g_hash_generate_test_case_4(void)
2961 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2965 test_snow3g_hash_generate_test_case_5(void)
2967 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2971 test_snow3g_hash_generate_test_case_6(void)
2973 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2977 test_snow3g_hash_verify_test_case_1(void)
2979 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2984 test_snow3g_hash_verify_test_case_2(void)
2986 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2990 test_snow3g_hash_verify_test_case_3(void)
2992 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2996 test_snow3g_hash_verify_test_case_4(void)
2998 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3002 test_snow3g_hash_verify_test_case_5(void)
3004 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3008 test_snow3g_hash_verify_test_case_6(void)
3010 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3014 test_kasumi_hash_generate_test_case_1(void)
3016 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3020 test_kasumi_hash_generate_test_case_2(void)
3022 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3026 test_kasumi_hash_generate_test_case_3(void)
3028 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3032 test_kasumi_hash_generate_test_case_4(void)
3034 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3038 test_kasumi_hash_generate_test_case_5(void)
3040 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3044 test_kasumi_hash_generate_test_case_6(void)
3046 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3050 test_kasumi_hash_verify_test_case_1(void)
3052 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3056 test_kasumi_hash_verify_test_case_2(void)
3058 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3062 test_kasumi_hash_verify_test_case_3(void)
3064 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3068 test_kasumi_hash_verify_test_case_4(void)
3070 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3074 test_kasumi_hash_verify_test_case_5(void)
3076 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3080 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3082 struct crypto_testsuite_params *ts_params = &testsuite_params;
3083 struct crypto_unittest_params *ut_params = &unittest_params;
3086 uint8_t *plaintext, *ciphertext;
3087 unsigned plaintext_pad_len;
3088 unsigned plaintext_len;
3090 /* Create KASUMI session */
3091 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3092 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3093 RTE_CRYPTO_CIPHER_KASUMI_F8,
3094 tdata->key.data, tdata->key.len,
3095 tdata->cipher_iv.len);
3099 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3101 /* Clear mbuf payload */
3102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3103 rte_pktmbuf_tailroom(ut_params->ibuf));
3105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3106 /* Append data which is padded to a multiple */
3107 /* of the algorithms block size */
3108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3109 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3111 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3113 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3115 /* Create KASUMI operation */
3116 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3117 tdata->cipher_iv.len,
3118 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3119 tdata->validCipherOffsetInBits.len);
3123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3127 ut_params->obuf = ut_params->op->sym->m_dst;
3128 if (ut_params->obuf)
3129 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3131 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3133 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3135 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3136 (tdata->validCipherOffsetInBits.len >> 3);
3138 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3140 reference_ciphertext,
3141 tdata->validCipherLenInBits.len,
3142 "KASUMI Ciphertext data not as expected");
3147 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3149 struct crypto_testsuite_params *ts_params = &testsuite_params;
3150 struct crypto_unittest_params *ut_params = &unittest_params;
3154 unsigned int plaintext_pad_len;
3155 unsigned int plaintext_len;
3157 uint8_t buffer[10000];
3158 const uint8_t *ciphertext;
3160 struct rte_cryptodev_info dev_info;
3162 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3164 uint64_t feat_flags = dev_info.feature_flags;
3166 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3167 printf("Device doesn't support in-place scatter-gather. "
3172 /* Create KASUMI session */
3173 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3174 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3175 RTE_CRYPTO_CIPHER_KASUMI_F8,
3176 tdata->key.data, tdata->key.len,
3177 tdata->cipher_iv.len);
3181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3184 /* Append data which is padded to a multiple */
3185 /* of the algorithms block size */
3186 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3188 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3189 plaintext_pad_len, 10, 0);
3191 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3193 /* Create KASUMI operation */
3194 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3195 tdata->cipher_iv.len,
3196 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3197 tdata->validCipherOffsetInBits.len);
3201 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3205 ut_params->obuf = ut_params->op->sym->m_dst;
3207 if (ut_params->obuf)
3208 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3209 plaintext_len, buffer);
3211 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3212 tdata->validCipherOffsetInBits.len >> 3,
3213 plaintext_len, buffer);
3216 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3218 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3219 (tdata->validCipherOffsetInBits.len >> 3);
3221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3223 reference_ciphertext,
3224 tdata->validCipherLenInBits.len,
3225 "KASUMI Ciphertext data not as expected");
3230 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3232 struct crypto_testsuite_params *ts_params = &testsuite_params;
3233 struct crypto_unittest_params *ut_params = &unittest_params;
3236 uint8_t *plaintext, *ciphertext;
3237 unsigned plaintext_pad_len;
3238 unsigned plaintext_len;
3240 /* Create KASUMI session */
3241 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3242 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3243 RTE_CRYPTO_CIPHER_KASUMI_F8,
3244 tdata->key.data, tdata->key.len,
3245 tdata->cipher_iv.len);
3249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3250 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3252 /* Clear mbuf payload */
3253 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3254 rte_pktmbuf_tailroom(ut_params->ibuf));
3256 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3257 /* Append data which is padded to a multiple */
3258 /* of the algorithms block size */
3259 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3260 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3262 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3263 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3265 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3267 /* Create KASUMI operation */
3268 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3269 tdata->cipher_iv.len,
3270 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3271 tdata->validCipherOffsetInBits.len);
3275 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3277 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3279 ut_params->obuf = ut_params->op->sym->m_dst;
3280 if (ut_params->obuf)
3281 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3283 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3285 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3287 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3288 (tdata->validCipherOffsetInBits.len >> 3);
3290 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3292 reference_ciphertext,
3293 tdata->validCipherLenInBits.len,
3294 "KASUMI Ciphertext data not as expected");
3299 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3301 struct crypto_testsuite_params *ts_params = &testsuite_params;
3302 struct crypto_unittest_params *ut_params = &unittest_params;
3305 unsigned int plaintext_pad_len;
3306 unsigned int plaintext_len;
3308 const uint8_t *ciphertext;
3309 uint8_t buffer[2048];
3311 struct rte_cryptodev_info dev_info;
3313 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3315 uint64_t feat_flags = dev_info.feature_flags;
3316 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3317 printf("Device doesn't support out-of-place scatter-gather "
3318 "in both input and output mbufs. "
3323 /* Create KASUMI session */
3324 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3325 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3326 RTE_CRYPTO_CIPHER_KASUMI_F8,
3327 tdata->key.data, tdata->key.len,
3328 tdata->cipher_iv.len);
3332 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3333 /* Append data which is padded to a multiple */
3334 /* of the algorithms block size */
3335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3337 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3338 plaintext_pad_len, 10, 0);
3339 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3340 plaintext_pad_len, 3, 0);
3342 /* Append data which is padded to a multiple */
3343 /* of the algorithms block size */
3344 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3346 /* Create KASUMI operation */
3347 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3348 tdata->cipher_iv.len,
3349 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3350 tdata->validCipherOffsetInBits.len);
3354 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3358 ut_params->obuf = ut_params->op->sym->m_dst;
3359 if (ut_params->obuf)
3360 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3361 plaintext_pad_len, buffer);
3363 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3364 tdata->validCipherOffsetInBits.len >> 3,
3365 plaintext_pad_len, buffer);
3367 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3368 (tdata->validCipherOffsetInBits.len >> 3);
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3372 reference_ciphertext,
3373 tdata->validCipherLenInBits.len,
3374 "KASUMI Ciphertext data not as expected");
3380 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3382 struct crypto_testsuite_params *ts_params = &testsuite_params;
3383 struct crypto_unittest_params *ut_params = &unittest_params;
3386 uint8_t *ciphertext, *plaintext;
3387 unsigned ciphertext_pad_len;
3388 unsigned ciphertext_len;
3390 /* Create KASUMI session */
3391 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3392 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3393 RTE_CRYPTO_CIPHER_KASUMI_F8,
3394 tdata->key.data, tdata->key.len,
3395 tdata->cipher_iv.len);
3399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3400 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3402 /* Clear mbuf payload */
3403 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3404 rte_pktmbuf_tailroom(ut_params->ibuf));
3406 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3407 /* Append data which is padded to a multiple */
3408 /* of the algorithms block size */
3409 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3410 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3411 ciphertext_pad_len);
3412 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3413 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3415 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3417 /* Create KASUMI operation */
3418 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3419 tdata->cipher_iv.len,
3420 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3421 tdata->validCipherOffsetInBits.len);
3425 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3427 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3429 ut_params->obuf = ut_params->op->sym->m_dst;
3430 if (ut_params->obuf)
3431 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3433 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3435 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3437 const uint8_t *reference_plaintext = tdata->plaintext.data +
3438 (tdata->validCipherOffsetInBits.len >> 3);
3440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3442 reference_plaintext,
3443 tdata->validCipherLenInBits.len,
3444 "KASUMI Plaintext data not as expected");
3449 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3455 uint8_t *ciphertext, *plaintext;
3456 unsigned ciphertext_pad_len;
3457 unsigned ciphertext_len;
3459 /* Create KASUMI session */
3460 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3461 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3462 RTE_CRYPTO_CIPHER_KASUMI_F8,
3463 tdata->key.data, tdata->key.len,
3464 tdata->cipher_iv.len);
3468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3470 /* Clear mbuf payload */
3471 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3472 rte_pktmbuf_tailroom(ut_params->ibuf));
3474 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3475 /* Append data which is padded to a multiple */
3476 /* of the algorithms block size */
3477 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3478 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3479 ciphertext_pad_len);
3480 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3482 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3484 /* Create KASUMI operation */
3485 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3486 tdata->cipher_iv.len,
3487 tdata->ciphertext.len,
3488 tdata->validCipherOffsetInBits.len);
3492 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3494 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3496 ut_params->obuf = ut_params->op->sym->m_dst;
3497 if (ut_params->obuf)
3498 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3500 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3502 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3504 const uint8_t *reference_plaintext = tdata->plaintext.data +
3505 (tdata->validCipherOffsetInBits.len >> 3);
3507 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3509 reference_plaintext,
3510 tdata->validCipherLenInBits.len,
3511 "KASUMI Plaintext data not as expected");
3516 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3518 struct crypto_testsuite_params *ts_params = &testsuite_params;
3519 struct crypto_unittest_params *ut_params = &unittest_params;
3522 uint8_t *plaintext, *ciphertext;
3523 unsigned plaintext_pad_len;
3524 unsigned plaintext_len;
3526 /* Create SNOW 3G session */
3527 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3528 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3529 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3530 tdata->key.data, tdata->key.len,
3531 tdata->cipher_iv.len);
3535 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3537 /* Clear mbuf payload */
3538 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3539 rte_pktmbuf_tailroom(ut_params->ibuf));
3541 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3542 /* Append data which is padded to a multiple of */
3543 /* the algorithms block size */
3544 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3549 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3551 /* Create SNOW 3G operation */
3552 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3553 tdata->cipher_iv.len,
3554 tdata->validCipherLenInBits.len,
3559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3563 ut_params->obuf = ut_params->op->sym->m_dst;
3564 if (ut_params->obuf)
3565 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3567 ciphertext = plaintext;
3569 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3574 tdata->ciphertext.data,
3575 tdata->validDataLenInBits.len,
3576 "SNOW 3G Ciphertext data not as expected");
3582 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3584 struct crypto_testsuite_params *ts_params = &testsuite_params;
3585 struct crypto_unittest_params *ut_params = &unittest_params;
3586 uint8_t *plaintext, *ciphertext;
3589 unsigned plaintext_pad_len;
3590 unsigned plaintext_len;
3592 /* Create SNOW 3G session */
3593 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3594 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3595 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3596 tdata->key.data, tdata->key.len,
3597 tdata->cipher_iv.len);
3601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3602 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3604 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3605 "Failed to allocate input buffer in mempool");
3606 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3607 "Failed to allocate output buffer in mempool");
3609 /* Clear mbuf payload */
3610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3611 rte_pktmbuf_tailroom(ut_params->ibuf));
3613 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3614 /* Append data which is padded to a multiple of */
3615 /* the algorithms block size */
3616 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3617 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3619 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3620 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3622 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3624 /* Create SNOW 3G operation */
3625 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3626 tdata->cipher_iv.len,
3627 tdata->validCipherLenInBits.len,
3632 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3634 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3636 ut_params->obuf = ut_params->op->sym->m_dst;
3637 if (ut_params->obuf)
3638 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3640 ciphertext = plaintext;
3642 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3645 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3647 tdata->ciphertext.data,
3648 tdata->validDataLenInBits.len,
3649 "SNOW 3G Ciphertext data not as expected");
3654 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3656 struct crypto_testsuite_params *ts_params = &testsuite_params;
3657 struct crypto_unittest_params *ut_params = &unittest_params;
3660 unsigned int plaintext_pad_len;
3661 unsigned int plaintext_len;
3662 uint8_t buffer[10000];
3663 const uint8_t *ciphertext;
3665 struct rte_cryptodev_info dev_info;
3667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3669 uint64_t feat_flags = dev_info.feature_flags;
3671 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3672 printf("Device doesn't support out-of-place scatter-gather "
3673 "in both input and output mbufs. "
3678 /* Create SNOW 3G session */
3679 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3680 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3681 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3682 tdata->key.data, tdata->key.len,
3683 tdata->cipher_iv.len);
3687 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3688 /* Append data which is padded to a multiple of */
3689 /* the algorithms block size */
3690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3692 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3693 plaintext_pad_len, 10, 0);
3694 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3695 plaintext_pad_len, 3, 0);
3697 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3698 "Failed to allocate input buffer in mempool");
3699 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3700 "Failed to allocate output buffer in mempool");
3702 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3704 /* Create SNOW 3G operation */
3705 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3706 tdata->cipher_iv.len,
3707 tdata->validCipherLenInBits.len,
3712 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3714 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3716 ut_params->obuf = ut_params->op->sym->m_dst;
3717 if (ut_params->obuf)
3718 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3719 plaintext_len, buffer);
3721 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3722 plaintext_len, buffer);
3724 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3727 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3729 tdata->ciphertext.data,
3730 tdata->validDataLenInBits.len,
3731 "SNOW 3G Ciphertext data not as expected");
3736 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3738 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3740 uint8_t curr_byte, prev_byte;
3741 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3742 uint8_t lower_byte_mask = (1 << offset) - 1;
3745 prev_byte = buffer[0];
3746 buffer[0] >>= offset;
3748 for (i = 1; i < length_in_bytes; i++) {
3749 curr_byte = buffer[i];
3750 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3751 (curr_byte >> offset);
3752 prev_byte = curr_byte;
3757 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3759 struct crypto_testsuite_params *ts_params = &testsuite_params;
3760 struct crypto_unittest_params *ut_params = &unittest_params;
3761 uint8_t *plaintext, *ciphertext;
3763 uint32_t plaintext_len;
3764 uint32_t plaintext_pad_len;
3765 uint8_t extra_offset = 4;
3766 uint8_t *expected_ciphertext_shifted;
3768 /* Create SNOW 3G session */
3769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3770 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3772 tdata->key.data, tdata->key.len,
3773 tdata->cipher_iv.len);
3777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3780 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3781 "Failed to allocate input buffer in mempool");
3782 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3783 "Failed to allocate output buffer in mempool");
3785 /* Clear mbuf payload */
3786 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3787 rte_pktmbuf_tailroom(ut_params->ibuf));
3789 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3791 * Append data which is padded to a
3792 * multiple of the algorithms block size
3794 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3796 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3799 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3801 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3802 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3804 #ifdef RTE_APP_TEST_DEBUG
3805 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3807 /* Create SNOW 3G operation */
3808 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3809 tdata->cipher_iv.len,
3810 tdata->validCipherLenInBits.len,
3815 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3817 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3819 ut_params->obuf = ut_params->op->sym->m_dst;
3820 if (ut_params->obuf)
3821 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3823 ciphertext = plaintext;
3825 #ifdef RTE_APP_TEST_DEBUG
3826 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3829 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3831 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3832 "failed to reserve memory for ciphertext shifted\n");
3834 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3835 ceil_byte_length(tdata->ciphertext.len));
3836 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3839 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3841 expected_ciphertext_shifted,
3842 tdata->validDataLenInBits.len,
3844 "SNOW 3G Ciphertext data not as expected");
3848 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3850 struct crypto_testsuite_params *ts_params = &testsuite_params;
3851 struct crypto_unittest_params *ut_params = &unittest_params;
3855 uint8_t *plaintext, *ciphertext;
3856 unsigned ciphertext_pad_len;
3857 unsigned ciphertext_len;
3859 /* Create SNOW 3G session */
3860 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3861 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3862 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3863 tdata->key.data, tdata->key.len,
3864 tdata->cipher_iv.len);
3868 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3870 /* Clear mbuf payload */
3871 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3872 rte_pktmbuf_tailroom(ut_params->ibuf));
3874 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3875 /* Append data which is padded to a multiple of */
3876 /* the algorithms block size */
3877 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3878 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3879 ciphertext_pad_len);
3880 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3882 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3884 /* Create SNOW 3G operation */
3885 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3886 tdata->cipher_iv.len,
3887 tdata->validCipherLenInBits.len,
3892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3895 ut_params->obuf = ut_params->op->sym->m_dst;
3896 if (ut_params->obuf)
3897 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3899 plaintext = ciphertext;
3901 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3904 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3905 tdata->plaintext.data,
3906 tdata->validDataLenInBits.len,
3907 "SNOW 3G Plaintext data not as expected");
3911 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3913 struct crypto_testsuite_params *ts_params = &testsuite_params;
3914 struct crypto_unittest_params *ut_params = &unittest_params;
3918 uint8_t *plaintext, *ciphertext;
3919 unsigned ciphertext_pad_len;
3920 unsigned ciphertext_len;
3922 /* Create SNOW 3G session */
3923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3924 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3925 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3926 tdata->key.data, tdata->key.len,
3927 tdata->cipher_iv.len);
3931 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3932 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3934 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3935 "Failed to allocate input buffer");
3936 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3937 "Failed to allocate output buffer");
3939 /* Clear mbuf payload */
3940 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3941 rte_pktmbuf_tailroom(ut_params->ibuf));
3943 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3944 rte_pktmbuf_tailroom(ut_params->obuf));
3946 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3947 /* Append data which is padded to a multiple of */
3948 /* the algorithms block size */
3949 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3950 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3951 ciphertext_pad_len);
3952 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3953 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3955 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3957 /* Create SNOW 3G operation */
3958 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3959 tdata->cipher_iv.len,
3960 tdata->validCipherLenInBits.len,
3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3968 ut_params->obuf = ut_params->op->sym->m_dst;
3969 if (ut_params->obuf)
3970 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3972 plaintext = ciphertext;
3974 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3977 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3978 tdata->plaintext.data,
3979 tdata->validDataLenInBits.len,
3980 "SNOW 3G Plaintext data not as expected");
3985 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3987 struct crypto_testsuite_params *ts_params = &testsuite_params;
3988 struct crypto_unittest_params *ut_params = &unittest_params;
3992 uint8_t *plaintext, *ciphertext;
3993 unsigned int plaintext_pad_len;
3994 unsigned int plaintext_len;
3996 struct rte_cryptodev_sym_capability_idx cap_idx;
3998 /* Check if device supports ZUC EEA3 */
3999 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4000 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4002 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4006 /* Check if device supports ZUC EIA3 */
4007 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4008 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4014 /* Create ZUC session */
4015 retval = create_zuc_cipher_auth_encrypt_generate_session(
4016 ts_params->valid_devs[0],
4020 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4022 /* clear mbuf payload */
4023 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4024 rte_pktmbuf_tailroom(ut_params->ibuf));
4026 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4027 /* Append data which is padded to a multiple of */
4028 /* the algorithms block size */
4029 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4030 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4032 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4034 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4036 /* Create ZUC operation */
4037 retval = create_zuc_cipher_hash_generate_operation(tdata);
4041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_src;
4045 if (ut_params->obuf)
4046 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 ciphertext = plaintext;
4050 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4054 tdata->ciphertext.data,
4055 tdata->validDataLenInBits.len,
4056 "ZUC Ciphertext data not as expected");
4058 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4059 + plaintext_pad_len;
4062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4066 "ZUC Generated auth tag not as expected");
4071 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4073 struct crypto_testsuite_params *ts_params = &testsuite_params;
4074 struct crypto_unittest_params *ut_params = &unittest_params;
4078 uint8_t *plaintext, *ciphertext;
4079 unsigned plaintext_pad_len;
4080 unsigned plaintext_len;
4082 /* Create SNOW 3G session */
4083 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4084 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4085 RTE_CRYPTO_AUTH_OP_GENERATE,
4086 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4087 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4088 tdata->key.data, tdata->key.len,
4089 tdata->auth_iv.len, tdata->digest.len,
4090 tdata->cipher_iv.len);
4093 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4095 /* clear mbuf payload */
4096 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4097 rte_pktmbuf_tailroom(ut_params->ibuf));
4099 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4100 /* Append data which is padded to a multiple of */
4101 /* the algorithms block size */
4102 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4103 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4105 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4107 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4109 /* Create SNOW 3G operation */
4110 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4111 tdata->digest.len, tdata->auth_iv.data,
4113 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4114 tdata->cipher_iv.data, tdata->cipher_iv.len,
4115 tdata->validCipherLenInBits.len,
4117 tdata->validAuthLenInBits.len,
4123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4126 ut_params->obuf = ut_params->op->sym->m_src;
4127 if (ut_params->obuf)
4128 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4130 ciphertext = plaintext;
4132 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4134 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4136 tdata->ciphertext.data,
4137 tdata->validDataLenInBits.len,
4138 "SNOW 3G Ciphertext data not as expected");
4140 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4141 + plaintext_pad_len;
4144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4147 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4148 "SNOW 3G Generated auth tag not as expected");
4152 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4159 uint8_t *plaintext, *ciphertext;
4160 unsigned plaintext_pad_len;
4161 unsigned plaintext_len;
4163 /* Create SNOW 3G session */
4164 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4165 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4166 RTE_CRYPTO_AUTH_OP_GENERATE,
4167 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4168 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4169 tdata->key.data, tdata->key.len,
4170 tdata->auth_iv.len, tdata->digest.len,
4171 tdata->cipher_iv.len);
4175 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4177 /* clear mbuf payload */
4178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->ibuf));
4181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4187 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4189 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4191 /* Create SNOW 3G operation */
4192 retval = create_wireless_algo_auth_cipher_operation(
4194 tdata->cipher_iv.data, tdata->cipher_iv.len,
4195 tdata->auth_iv.data, tdata->auth_iv.len,
4197 tdata->validCipherLenInBits.len,
4199 tdata->validAuthLenInBits.len,
4205 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4208 ut_params->obuf = ut_params->op->sym->m_src;
4209 if (ut_params->obuf)
4210 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4212 ciphertext = plaintext;
4214 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4215 + plaintext_pad_len;
4216 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4219 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4221 tdata->ciphertext.data,
4222 tdata->validDataLenInBits.len,
4223 "SNOW 3G Ciphertext data not as expected");
4226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4229 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4230 "SNOW 3G Generated auth tag not as expected");
4235 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4242 uint8_t *plaintext, *ciphertext;
4243 unsigned plaintext_pad_len;
4244 unsigned plaintext_len;
4246 /* Create KASUMI session */
4247 retval = create_wireless_algo_auth_cipher_session(
4248 ts_params->valid_devs[0],
4249 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4250 RTE_CRYPTO_AUTH_OP_GENERATE,
4251 RTE_CRYPTO_AUTH_KASUMI_F9,
4252 RTE_CRYPTO_CIPHER_KASUMI_F8,
4253 tdata->key.data, tdata->key.len,
4254 0, tdata->digest.len,
4255 tdata->cipher_iv.len);
4258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4260 /* clear mbuf payload */
4261 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4262 rte_pktmbuf_tailroom(ut_params->ibuf));
4264 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4265 /* Append data which is padded to a multiple of */
4266 /* the algorithms block size */
4267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4270 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4272 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4274 /* Create KASUMI operation */
4275 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4276 tdata->cipher_iv.data, tdata->cipher_iv.len,
4279 tdata->validCipherLenInBits.len,
4280 tdata->validCipherOffsetInBits.len,
4281 tdata->validAuthLenInBits.len,
4288 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4291 if (ut_params->op->sym->m_dst)
4292 ut_params->obuf = ut_params->op->sym->m_dst;
4294 ut_params->obuf = ut_params->op->sym->m_src;
4296 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4297 tdata->validCipherOffsetInBits.len >> 3);
4299 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4300 (tdata->validCipherOffsetInBits.len >> 3);
4302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4304 reference_ciphertext,
4305 tdata->validCipherLenInBits.len,
4306 "KASUMI Ciphertext data not as expected");
4307 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4308 + plaintext_pad_len;
4311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4314 DIGEST_BYTE_LENGTH_KASUMI_F9,
4315 "KASUMI Generated auth tag not as expected");
4320 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4322 struct crypto_testsuite_params *ts_params = &testsuite_params;
4323 struct crypto_unittest_params *ut_params = &unittest_params;
4327 uint8_t *plaintext, *ciphertext;
4328 unsigned plaintext_pad_len;
4329 unsigned plaintext_len;
4331 /* Create KASUMI session */
4332 retval = create_wireless_algo_cipher_auth_session(
4333 ts_params->valid_devs[0],
4334 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4335 RTE_CRYPTO_AUTH_OP_GENERATE,
4336 RTE_CRYPTO_AUTH_KASUMI_F9,
4337 RTE_CRYPTO_CIPHER_KASUMI_F8,
4338 tdata->key.data, tdata->key.len,
4339 0, tdata->digest.len,
4340 tdata->cipher_iv.len);
4344 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4346 /* clear mbuf payload */
4347 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4348 rte_pktmbuf_tailroom(ut_params->ibuf));
4350 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4351 /* Append data which is padded to a multiple of */
4352 /* the algorithms block size */
4353 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4356 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4358 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4360 /* Create KASUMI operation */
4361 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4362 tdata->digest.len, NULL, 0,
4363 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4364 tdata->cipher_iv.data, tdata->cipher_iv.len,
4365 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4366 tdata->validCipherOffsetInBits.len,
4367 tdata->validAuthLenInBits.len,
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4377 if (ut_params->op->sym->m_dst)
4378 ut_params->obuf = ut_params->op->sym->m_dst;
4380 ut_params->obuf = ut_params->op->sym->m_src;
4382 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4383 tdata->validCipherOffsetInBits.len >> 3);
4385 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4386 + plaintext_pad_len;
4388 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4389 (tdata->validCipherOffsetInBits.len >> 3);
4391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4393 reference_ciphertext,
4394 tdata->validCipherLenInBits.len,
4395 "KASUMI Ciphertext data not as expected");
4398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4401 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4402 "KASUMI Generated auth tag not as expected");
4407 test_zuc_encryption(const struct wireless_test_data *tdata)
4409 struct crypto_testsuite_params *ts_params = &testsuite_params;
4410 struct crypto_unittest_params *ut_params = &unittest_params;
4413 uint8_t *plaintext, *ciphertext;
4414 unsigned plaintext_pad_len;
4415 unsigned plaintext_len;
4417 struct rte_cryptodev_sym_capability_idx cap_idx;
4419 /* Check if device supports ZUC EEA3 */
4420 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4421 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4427 /* Create ZUC session */
4428 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4429 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4430 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4431 tdata->key.data, tdata->key.len,
4432 tdata->cipher_iv.len);
4436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4438 /* Clear mbuf payload */
4439 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4440 rte_pktmbuf_tailroom(ut_params->ibuf));
4442 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4443 /* Append data which is padded to a multiple */
4444 /* of the algorithms block size */
4445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4446 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4448 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4450 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4452 /* Create ZUC operation */
4453 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4454 tdata->cipher_iv.len,
4455 tdata->plaintext.len,
4460 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4464 ut_params->obuf = ut_params->op->sym->m_dst;
4465 if (ut_params->obuf)
4466 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4468 ciphertext = plaintext;
4470 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4473 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4475 tdata->ciphertext.data,
4476 tdata->validCipherLenInBits.len,
4477 "ZUC Ciphertext data not as expected");
4482 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4484 struct crypto_testsuite_params *ts_params = &testsuite_params;
4485 struct crypto_unittest_params *ut_params = &unittest_params;
4489 unsigned int plaintext_pad_len;
4490 unsigned int plaintext_len;
4491 const uint8_t *ciphertext;
4492 uint8_t ciphertext_buffer[2048];
4493 struct rte_cryptodev_info dev_info;
4495 struct rte_cryptodev_sym_capability_idx cap_idx;
4497 /* Check if device supports ZUC EEA3 */
4498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4499 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4501 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4505 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4507 uint64_t feat_flags = dev_info.feature_flags;
4509 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4510 printf("Device doesn't support in-place scatter-gather. "
4515 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4517 /* Append data which is padded to a multiple */
4518 /* of the algorithms block size */
4519 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4521 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4522 plaintext_pad_len, 10, 0);
4524 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4525 tdata->plaintext.data);
4527 /* Create ZUC session */
4528 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4529 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4530 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4531 tdata->key.data, tdata->key.len,
4532 tdata->cipher_iv.len);
4536 /* Clear mbuf payload */
4538 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4540 /* Create ZUC operation */
4541 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4542 tdata->cipher_iv.len, tdata->plaintext.len,
4547 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4549 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4551 ut_params->obuf = ut_params->op->sym->m_dst;
4552 if (ut_params->obuf)
4553 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4554 0, plaintext_len, ciphertext_buffer);
4556 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4557 0, plaintext_len, ciphertext_buffer);
4560 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4563 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4565 tdata->ciphertext.data,
4566 tdata->validCipherLenInBits.len,
4567 "ZUC Ciphertext data not as expected");
4573 test_zuc_authentication(const struct wireless_test_data *tdata)
4575 struct crypto_testsuite_params *ts_params = &testsuite_params;
4576 struct crypto_unittest_params *ut_params = &unittest_params;
4579 unsigned plaintext_pad_len;
4580 unsigned plaintext_len;
4583 struct rte_cryptodev_sym_capability_idx cap_idx;
4585 /* Check if device supports ZUC EIA3 */
4586 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4587 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4589 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4593 /* Create ZUC session */
4594 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4595 tdata->key.data, tdata->key.len,
4596 tdata->auth_iv.len, tdata->digest.len,
4597 RTE_CRYPTO_AUTH_OP_GENERATE,
4598 RTE_CRYPTO_AUTH_ZUC_EIA3);
4602 /* alloc mbuf and set payload */
4603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4606 rte_pktmbuf_tailroom(ut_params->ibuf));
4608 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4609 /* Append data which is padded to a multiple of */
4610 /* the algorithms block size */
4611 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4612 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4614 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4616 /* Create ZUC operation */
4617 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4618 tdata->auth_iv.data, tdata->auth_iv.len,
4619 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4620 tdata->validAuthLenInBits.len,
4625 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4627 ut_params->obuf = ut_params->op->sym->m_src;
4628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4629 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4630 + plaintext_pad_len;
4633 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4636 DIGEST_BYTE_LENGTH_KASUMI_F9,
4637 "ZUC Generated auth tag not as expected");
4643 test_kasumi_encryption_test_case_1(void)
4645 return test_kasumi_encryption(&kasumi_test_case_1);
4649 test_kasumi_encryption_test_case_1_sgl(void)
4651 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4655 test_kasumi_encryption_test_case_1_oop(void)
4657 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4661 test_kasumi_encryption_test_case_1_oop_sgl(void)
4663 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4667 test_kasumi_encryption_test_case_2(void)
4669 return test_kasumi_encryption(&kasumi_test_case_2);
4673 test_kasumi_encryption_test_case_3(void)
4675 return test_kasumi_encryption(&kasumi_test_case_3);
4679 test_kasumi_encryption_test_case_4(void)
4681 return test_kasumi_encryption(&kasumi_test_case_4);
4685 test_kasumi_encryption_test_case_5(void)
4687 return test_kasumi_encryption(&kasumi_test_case_5);
4691 test_kasumi_decryption_test_case_1(void)
4693 return test_kasumi_decryption(&kasumi_test_case_1);
4697 test_kasumi_decryption_test_case_1_oop(void)
4699 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4703 test_kasumi_decryption_test_case_2(void)
4705 return test_kasumi_decryption(&kasumi_test_case_2);
4709 test_kasumi_decryption_test_case_3(void)
4711 return test_kasumi_decryption(&kasumi_test_case_3);
4715 test_kasumi_decryption_test_case_4(void)
4717 return test_kasumi_decryption(&kasumi_test_case_4);
4721 test_kasumi_decryption_test_case_5(void)
4723 return test_kasumi_decryption(&kasumi_test_case_5);
4726 test_snow3g_encryption_test_case_1(void)
4728 return test_snow3g_encryption(&snow3g_test_case_1);
4732 test_snow3g_encryption_test_case_1_oop(void)
4734 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4738 test_snow3g_encryption_test_case_1_oop_sgl(void)
4740 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4745 test_snow3g_encryption_test_case_1_offset_oop(void)
4747 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4751 test_snow3g_encryption_test_case_2(void)
4753 return test_snow3g_encryption(&snow3g_test_case_2);
4757 test_snow3g_encryption_test_case_3(void)
4759 return test_snow3g_encryption(&snow3g_test_case_3);
4763 test_snow3g_encryption_test_case_4(void)
4765 return test_snow3g_encryption(&snow3g_test_case_4);
4769 test_snow3g_encryption_test_case_5(void)
4771 return test_snow3g_encryption(&snow3g_test_case_5);
4775 test_snow3g_decryption_test_case_1(void)
4777 return test_snow3g_decryption(&snow3g_test_case_1);
4781 test_snow3g_decryption_test_case_1_oop(void)
4783 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4787 test_snow3g_decryption_test_case_2(void)
4789 return test_snow3g_decryption(&snow3g_test_case_2);
4793 test_snow3g_decryption_test_case_3(void)
4795 return test_snow3g_decryption(&snow3g_test_case_3);
4799 test_snow3g_decryption_test_case_4(void)
4801 return test_snow3g_decryption(&snow3g_test_case_4);
4805 test_snow3g_decryption_test_case_5(void)
4807 return test_snow3g_decryption(&snow3g_test_case_5);
4810 test_snow3g_cipher_auth_test_case_1(void)
4812 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4816 test_snow3g_auth_cipher_test_case_1(void)
4818 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4822 test_kasumi_auth_cipher_test_case_1(void)
4824 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4828 test_kasumi_cipher_auth_test_case_1(void)
4830 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4834 test_zuc_encryption_test_case_1(void)
4836 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4840 test_zuc_encryption_test_case_2(void)
4842 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4846 test_zuc_encryption_test_case_3(void)
4848 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4852 test_zuc_encryption_test_case_4(void)
4854 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4858 test_zuc_encryption_test_case_5(void)
4860 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4864 test_zuc_encryption_test_case_6_sgl(void)
4866 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4870 test_zuc_hash_generate_test_case_1(void)
4872 return test_zuc_authentication(&zuc_test_case_auth_1b);
4876 test_zuc_hash_generate_test_case_2(void)
4878 return test_zuc_authentication(&zuc_test_case_auth_90b);
4882 test_zuc_hash_generate_test_case_3(void)
4884 return test_zuc_authentication(&zuc_test_case_auth_577b);
4888 test_zuc_hash_generate_test_case_4(void)
4890 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4894 test_zuc_hash_generate_test_case_5(void)
4896 return test_zuc_authentication(&zuc_test_auth_5670b);
4900 test_zuc_hash_generate_test_case_6(void)
4902 return test_zuc_authentication(&zuc_test_case_auth_128b);
4906 test_zuc_hash_generate_test_case_7(void)
4908 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4912 test_zuc_hash_generate_test_case_8(void)
4914 return test_zuc_authentication(&zuc_test_case_auth_584b);
4918 test_zuc_cipher_auth_test_case_1(void)
4920 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4924 test_zuc_cipher_auth_test_case_2(void)
4926 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4930 test_3DES_chain_qat_all(void)
4932 struct crypto_testsuite_params *ts_params = &testsuite_params;
4935 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4936 ts_params->op_mpool,
4937 ts_params->session_mpool,
4938 ts_params->valid_devs[0],
4939 rte_cryptodev_driver_id_get(
4940 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4941 BLKCIPHER_3DES_CHAIN_TYPE);
4943 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4945 return TEST_SUCCESS;
4949 test_DES_cipheronly_qat_all(void)
4951 struct crypto_testsuite_params *ts_params = &testsuite_params;
4954 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4955 ts_params->op_mpool,
4956 ts_params->session_mpool,
4957 ts_params->valid_devs[0],
4958 rte_cryptodev_driver_id_get(
4959 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4960 BLKCIPHER_DES_CIPHERONLY_TYPE);
4962 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4964 return TEST_SUCCESS;
4968 test_DES_cipheronly_openssl_all(void)
4970 struct crypto_testsuite_params *ts_params = &testsuite_params;
4973 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4974 ts_params->op_mpool,
4975 ts_params->session_mpool,
4976 ts_params->valid_devs[0],
4977 rte_cryptodev_driver_id_get(
4978 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4979 BLKCIPHER_DES_CIPHERONLY_TYPE);
4981 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4983 return TEST_SUCCESS;
4987 test_DES_docsis_openssl_all(void)
4989 struct crypto_testsuite_params *ts_params = &testsuite_params;
4992 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4993 ts_params->op_mpool,
4994 ts_params->session_mpool,
4995 ts_params->valid_devs[0],
4996 rte_cryptodev_driver_id_get(
4997 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4998 BLKCIPHER_DES_DOCSIS_TYPE);
5000 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5002 return TEST_SUCCESS;
5006 test_DES_cipheronly_mb_all(void)
5008 struct crypto_testsuite_params *ts_params = &testsuite_params;
5011 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5012 ts_params->op_mpool,
5013 ts_params->session_mpool,
5014 ts_params->valid_devs[0],
5015 rte_cryptodev_driver_id_get(
5016 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5017 BLKCIPHER_DES_CIPHERONLY_TYPE);
5019 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5021 return TEST_SUCCESS;
5024 test_3DES_cipheronly_mb_all(void)
5026 struct crypto_testsuite_params *ts_params = &testsuite_params;
5029 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5030 ts_params->op_mpool,
5031 ts_params->session_mpool,
5032 ts_params->valid_devs[0],
5033 rte_cryptodev_driver_id_get(
5034 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5035 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5037 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5039 return TEST_SUCCESS;
5043 test_DES_docsis_mb_all(void)
5045 struct crypto_testsuite_params *ts_params = &testsuite_params;
5048 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5049 ts_params->op_mpool,
5050 ts_params->session_mpool,
5051 ts_params->valid_devs[0],
5052 rte_cryptodev_driver_id_get(
5053 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5054 BLKCIPHER_DES_DOCSIS_TYPE);
5056 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5058 return TEST_SUCCESS;
5062 test_3DES_chain_dpaa_sec_all(void)
5064 struct crypto_testsuite_params *ts_params = &testsuite_params;
5067 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5068 ts_params->op_mpool,
5069 ts_params->session_mpool,
5070 ts_params->valid_devs[0],
5071 rte_cryptodev_driver_id_get(
5072 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5073 BLKCIPHER_3DES_CHAIN_TYPE);
5075 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5077 return TEST_SUCCESS;
5081 test_3DES_cipheronly_dpaa_sec_all(void)
5083 struct crypto_testsuite_params *ts_params = &testsuite_params;
5086 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5087 ts_params->op_mpool,
5088 ts_params->session_mpool,
5089 ts_params->valid_devs[0],
5090 rte_cryptodev_driver_id_get(
5091 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5092 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5094 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5096 return TEST_SUCCESS;
5100 test_3DES_chain_dpaa2_sec_all(void)
5102 struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5106 ts_params->op_mpool,
5107 ts_params->session_mpool,
5108 ts_params->valid_devs[0],
5109 rte_cryptodev_driver_id_get(
5110 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5111 BLKCIPHER_3DES_CHAIN_TYPE);
5113 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5115 return TEST_SUCCESS;
5119 test_3DES_cipheronly_dpaa2_sec_all(void)
5121 struct crypto_testsuite_params *ts_params = &testsuite_params;
5124 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5125 ts_params->op_mpool,
5126 ts_params->session_mpool,
5127 ts_params->valid_devs[0],
5128 rte_cryptodev_driver_id_get(
5129 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5130 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5132 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5134 return TEST_SUCCESS;
5138 test_3DES_chain_ccp_all(void)
5140 struct crypto_testsuite_params *ts_params = &testsuite_params;
5143 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5144 ts_params->op_mpool,
5145 ts_params->session_mpool,
5146 ts_params->valid_devs[0],
5147 rte_cryptodev_driver_id_get(
5148 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5149 BLKCIPHER_3DES_CHAIN_TYPE);
5151 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5153 return TEST_SUCCESS;
5157 test_3DES_cipheronly_ccp_all(void)
5159 struct crypto_testsuite_params *ts_params = &testsuite_params;
5162 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5163 ts_params->op_mpool,
5164 ts_params->session_mpool,
5165 ts_params->valid_devs[0],
5166 rte_cryptodev_driver_id_get(
5167 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5168 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5170 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5172 return TEST_SUCCESS;
5176 test_3DES_cipheronly_qat_all(void)
5178 struct crypto_testsuite_params *ts_params = &testsuite_params;
5181 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5182 ts_params->op_mpool,
5183 ts_params->session_mpool,
5184 ts_params->valid_devs[0],
5185 rte_cryptodev_driver_id_get(
5186 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5187 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5189 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5191 return TEST_SUCCESS;
5195 test_3DES_chain_openssl_all(void)
5197 struct crypto_testsuite_params *ts_params = &testsuite_params;
5200 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5201 ts_params->op_mpool,
5202 ts_params->session_mpool,
5203 ts_params->valid_devs[0],
5204 rte_cryptodev_driver_id_get(
5205 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5206 BLKCIPHER_3DES_CHAIN_TYPE);
5208 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5210 return TEST_SUCCESS;
5214 test_3DES_cipheronly_openssl_all(void)
5216 struct crypto_testsuite_params *ts_params = &testsuite_params;
5219 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5220 ts_params->op_mpool,
5221 ts_params->session_mpool,
5222 ts_params->valid_devs[0],
5223 rte_cryptodev_driver_id_get(
5224 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5225 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5227 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5229 return TEST_SUCCESS;
5232 /* ***** AEAD algorithm Tests ***** */
5235 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5236 enum rte_crypto_aead_operation op,
5237 const uint8_t *key, const uint8_t key_len,
5238 const uint16_t aad_len, const uint8_t auth_len,
5241 uint8_t aead_key[key_len];
5243 struct crypto_testsuite_params *ts_params = &testsuite_params;
5244 struct crypto_unittest_params *ut_params = &unittest_params;
5246 memcpy(aead_key, key, key_len);
5248 /* Setup AEAD Parameters */
5249 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5250 ut_params->aead_xform.next = NULL;
5251 ut_params->aead_xform.aead.algo = algo;
5252 ut_params->aead_xform.aead.op = op;
5253 ut_params->aead_xform.aead.key.data = aead_key;
5254 ut_params->aead_xform.aead.key.length = key_len;
5255 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5256 ut_params->aead_xform.aead.iv.length = iv_len;
5257 ut_params->aead_xform.aead.digest_length = auth_len;
5258 ut_params->aead_xform.aead.aad_length = aad_len;
5260 debug_hexdump(stdout, "key:", key, key_len);
5262 /* Create Crypto session*/
5263 ut_params->sess = rte_cryptodev_sym_session_create(
5264 ts_params->session_mpool);
5266 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5267 &ut_params->aead_xform, ts_params->session_mpool);
5269 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5275 create_aead_xform(struct rte_crypto_op *op,
5276 enum rte_crypto_aead_algorithm algo,
5277 enum rte_crypto_aead_operation aead_op,
5278 uint8_t *key, const uint8_t key_len,
5279 const uint8_t aad_len, const uint8_t auth_len,
5282 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5283 "failed to allocate space for crypto transform");
5285 struct rte_crypto_sym_op *sym_op = op->sym;
5287 /* Setup AEAD Parameters */
5288 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5289 sym_op->xform->next = NULL;
5290 sym_op->xform->aead.algo = algo;
5291 sym_op->xform->aead.op = aead_op;
5292 sym_op->xform->aead.key.data = key;
5293 sym_op->xform->aead.key.length = key_len;
5294 sym_op->xform->aead.iv.offset = IV_OFFSET;
5295 sym_op->xform->aead.iv.length = iv_len;
5296 sym_op->xform->aead.digest_length = auth_len;
5297 sym_op->xform->aead.aad_length = aad_len;
5299 debug_hexdump(stdout, "key:", key, key_len);
5305 create_aead_operation(enum rte_crypto_aead_operation op,
5306 const struct aead_test_data *tdata)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5309 struct crypto_unittest_params *ut_params = &unittest_params;
5311 uint8_t *plaintext, *ciphertext;
5312 unsigned int aad_pad_len, plaintext_pad_len;
5314 /* Generate Crypto op data structure */
5315 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5316 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5317 TEST_ASSERT_NOT_NULL(ut_params->op,
5318 "Failed to allocate symmetric crypto operation struct");
5320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5322 /* Append aad data */
5323 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5324 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5325 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5327 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5328 "no room to append aad");
5330 sym_op->aead.aad.phys_addr =
5331 rte_pktmbuf_iova(ut_params->ibuf);
5332 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5333 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5334 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5337 /* Append IV at the end of the crypto operation*/
5338 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5339 uint8_t *, IV_OFFSET);
5341 /* Copy IV 1 byte after the IV pointer, according to the API */
5342 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5343 debug_hexdump(stdout, "iv:", iv_ptr,
5346 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5347 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5349 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5350 "no room to append aad");
5352 sym_op->aead.aad.phys_addr =
5353 rte_pktmbuf_iova(ut_params->ibuf);
5354 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5355 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5358 /* Append IV at the end of the crypto operation*/
5359 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5360 uint8_t *, IV_OFFSET);
5362 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5363 debug_hexdump(stdout, "iv:", iv_ptr,
5367 /* Append plaintext/ciphertext */
5368 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5369 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5372 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5374 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5375 debug_hexdump(stdout, "plaintext:", plaintext,
5376 tdata->plaintext.len);
5378 if (ut_params->obuf) {
5379 ciphertext = (uint8_t *)rte_pktmbuf_append(
5381 plaintext_pad_len + aad_pad_len);
5382 TEST_ASSERT_NOT_NULL(ciphertext,
5383 "no room to append ciphertext");
5385 memset(ciphertext + aad_pad_len, 0,
5386 tdata->ciphertext.len);
5389 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5390 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5392 TEST_ASSERT_NOT_NULL(ciphertext,
5393 "no room to append ciphertext");
5395 memcpy(ciphertext, tdata->ciphertext.data,
5396 tdata->ciphertext.len);
5397 debug_hexdump(stdout, "ciphertext:", ciphertext,
5398 tdata->ciphertext.len);
5400 if (ut_params->obuf) {
5401 plaintext = (uint8_t *)rte_pktmbuf_append(
5403 plaintext_pad_len + aad_pad_len);
5404 TEST_ASSERT_NOT_NULL(plaintext,
5405 "no room to append plaintext");
5407 memset(plaintext + aad_pad_len, 0,
5408 tdata->plaintext.len);
5412 /* Append digest data */
5413 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5414 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5415 ut_params->obuf ? ut_params->obuf :
5417 tdata->auth_tag.len);
5418 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5419 "no room to append digest");
5420 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5421 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5422 ut_params->obuf ? ut_params->obuf :
5427 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5428 ut_params->ibuf, tdata->auth_tag.len);
5429 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5430 "no room to append digest");
5431 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5433 plaintext_pad_len + aad_pad_len);
5435 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5436 tdata->auth_tag.len);
5437 debug_hexdump(stdout, "digest:",
5438 sym_op->aead.digest.data,
5439 tdata->auth_tag.len);
5442 sym_op->aead.data.length = tdata->plaintext.len;
5443 sym_op->aead.data.offset = aad_pad_len;
5449 test_authenticated_encryption(const struct aead_test_data *tdata)
5451 struct crypto_testsuite_params *ts_params = &testsuite_params;
5452 struct crypto_unittest_params *ut_params = &unittest_params;
5455 uint8_t *ciphertext, *auth_tag;
5456 uint16_t plaintext_pad_len;
5459 /* Create AEAD session */
5460 retval = create_aead_session(ts_params->valid_devs[0],
5462 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5463 tdata->key.data, tdata->key.len,
5464 tdata->aad.len, tdata->auth_tag.len,
5469 if (tdata->aad.len > MBUF_SIZE) {
5470 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5471 /* Populate full size of add data */
5472 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5473 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5477 /* clear mbuf payload */
5478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5479 rte_pktmbuf_tailroom(ut_params->ibuf));
5481 /* Create AEAD operation */
5482 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5486 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5488 ut_params->op->sym->m_src = ut_params->ibuf;
5490 /* Process crypto operation */
5491 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5492 ut_params->op), "failed to process sym crypto op");
5494 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5495 "crypto op processing failed");
5497 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5499 if (ut_params->op->sym->m_dst) {
5500 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5502 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5503 uint8_t *, plaintext_pad_len);
5505 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5507 ut_params->op->sym->cipher.data.offset);
5508 auth_tag = ciphertext + plaintext_pad_len;
5511 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5512 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5517 tdata->ciphertext.data,
5518 tdata->ciphertext.len,
5519 "Ciphertext data not as expected");
5521 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5523 tdata->auth_tag.data,
5524 tdata->auth_tag.len,
5525 "Generated auth tag not as expected");
5532 test_AES_GCM_authenticated_encryption_test_case_1(void)
5534 return test_authenticated_encryption(&gcm_test_case_1);
5538 test_AES_GCM_authenticated_encryption_test_case_2(void)
5540 return test_authenticated_encryption(&gcm_test_case_2);
5544 test_AES_GCM_authenticated_encryption_test_case_3(void)
5546 return test_authenticated_encryption(&gcm_test_case_3);
5550 test_AES_GCM_authenticated_encryption_test_case_4(void)
5552 return test_authenticated_encryption(&gcm_test_case_4);
5556 test_AES_GCM_authenticated_encryption_test_case_5(void)
5558 return test_authenticated_encryption(&gcm_test_case_5);
5562 test_AES_GCM_authenticated_encryption_test_case_6(void)
5564 return test_authenticated_encryption(&gcm_test_case_6);
5568 test_AES_GCM_authenticated_encryption_test_case_7(void)
5570 return test_authenticated_encryption(&gcm_test_case_7);
5574 test_AES_GCM_auth_encryption_test_case_192_1(void)
5576 return test_authenticated_encryption(&gcm_test_case_192_1);
5580 test_AES_GCM_auth_encryption_test_case_192_2(void)
5582 return test_authenticated_encryption(&gcm_test_case_192_2);
5586 test_AES_GCM_auth_encryption_test_case_192_3(void)
5588 return test_authenticated_encryption(&gcm_test_case_192_3);
5592 test_AES_GCM_auth_encryption_test_case_192_4(void)
5594 return test_authenticated_encryption(&gcm_test_case_192_4);
5598 test_AES_GCM_auth_encryption_test_case_192_5(void)
5600 return test_authenticated_encryption(&gcm_test_case_192_5);
5604 test_AES_GCM_auth_encryption_test_case_192_6(void)
5606 return test_authenticated_encryption(&gcm_test_case_192_6);
5610 test_AES_GCM_auth_encryption_test_case_192_7(void)
5612 return test_authenticated_encryption(&gcm_test_case_192_7);
5616 test_AES_GCM_auth_encryption_test_case_256_1(void)
5618 return test_authenticated_encryption(&gcm_test_case_256_1);
5622 test_AES_GCM_auth_encryption_test_case_256_2(void)
5624 return test_authenticated_encryption(&gcm_test_case_256_2);
5628 test_AES_GCM_auth_encryption_test_case_256_3(void)
5630 return test_authenticated_encryption(&gcm_test_case_256_3);
5634 test_AES_GCM_auth_encryption_test_case_256_4(void)
5636 return test_authenticated_encryption(&gcm_test_case_256_4);
5640 test_AES_GCM_auth_encryption_test_case_256_5(void)
5642 return test_authenticated_encryption(&gcm_test_case_256_5);
5646 test_AES_GCM_auth_encryption_test_case_256_6(void)
5648 return test_authenticated_encryption(&gcm_test_case_256_6);
5652 test_AES_GCM_auth_encryption_test_case_256_7(void)
5654 return test_authenticated_encryption(&gcm_test_case_256_7);
5658 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5660 return test_authenticated_encryption(&gcm_test_case_aad_1);
5664 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5666 return test_authenticated_encryption(&gcm_test_case_aad_2);
5670 test_authenticated_decryption(const struct aead_test_data *tdata)
5672 struct crypto_testsuite_params *ts_params = &testsuite_params;
5673 struct crypto_unittest_params *ut_params = &unittest_params;
5679 /* Create AEAD session */
5680 retval = create_aead_session(ts_params->valid_devs[0],
5682 RTE_CRYPTO_AEAD_OP_DECRYPT,
5683 tdata->key.data, tdata->key.len,
5684 tdata->aad.len, tdata->auth_tag.len,
5689 /* alloc mbuf and set payload */
5690 if (tdata->aad.len > MBUF_SIZE) {
5691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5692 /* Populate full size of add data */
5693 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5694 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5698 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5699 rte_pktmbuf_tailroom(ut_params->ibuf));
5701 /* Create AEAD operation */
5702 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5706 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5708 ut_params->op->sym->m_src = ut_params->ibuf;
5710 /* Process crypto operation */
5711 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5712 ut_params->op), "failed to process sym crypto op");
5714 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5715 "crypto op processing failed");
5717 if (ut_params->op->sym->m_dst)
5718 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5721 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5723 ut_params->op->sym->cipher.data.offset);
5725 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5730 tdata->plaintext.data,
5731 tdata->plaintext.len,
5732 "Plaintext data not as expected");
5734 TEST_ASSERT_EQUAL(ut_params->op->status,
5735 RTE_CRYPTO_OP_STATUS_SUCCESS,
5736 "Authentication failed");
5741 test_AES_GCM_authenticated_decryption_test_case_1(void)
5743 return test_authenticated_decryption(&gcm_test_case_1);
5747 test_AES_GCM_authenticated_decryption_test_case_2(void)
5749 return test_authenticated_decryption(&gcm_test_case_2);
5753 test_AES_GCM_authenticated_decryption_test_case_3(void)
5755 return test_authenticated_decryption(&gcm_test_case_3);
5759 test_AES_GCM_authenticated_decryption_test_case_4(void)
5761 return test_authenticated_decryption(&gcm_test_case_4);
5765 test_AES_GCM_authenticated_decryption_test_case_5(void)
5767 return test_authenticated_decryption(&gcm_test_case_5);
5771 test_AES_GCM_authenticated_decryption_test_case_6(void)
5773 return test_authenticated_decryption(&gcm_test_case_6);
5777 test_AES_GCM_authenticated_decryption_test_case_7(void)
5779 return test_authenticated_decryption(&gcm_test_case_7);
5783 test_AES_GCM_auth_decryption_test_case_192_1(void)
5785 return test_authenticated_decryption(&gcm_test_case_192_1);
5789 test_AES_GCM_auth_decryption_test_case_192_2(void)
5791 return test_authenticated_decryption(&gcm_test_case_192_2);
5795 test_AES_GCM_auth_decryption_test_case_192_3(void)
5797 return test_authenticated_decryption(&gcm_test_case_192_3);
5801 test_AES_GCM_auth_decryption_test_case_192_4(void)
5803 return test_authenticated_decryption(&gcm_test_case_192_4);
5807 test_AES_GCM_auth_decryption_test_case_192_5(void)
5809 return test_authenticated_decryption(&gcm_test_case_192_5);
5813 test_AES_GCM_auth_decryption_test_case_192_6(void)
5815 return test_authenticated_decryption(&gcm_test_case_192_6);
5819 test_AES_GCM_auth_decryption_test_case_192_7(void)
5821 return test_authenticated_decryption(&gcm_test_case_192_7);
5825 test_AES_GCM_auth_decryption_test_case_256_1(void)
5827 return test_authenticated_decryption(&gcm_test_case_256_1);
5831 test_AES_GCM_auth_decryption_test_case_256_2(void)
5833 return test_authenticated_decryption(&gcm_test_case_256_2);
5837 test_AES_GCM_auth_decryption_test_case_256_3(void)
5839 return test_authenticated_decryption(&gcm_test_case_256_3);
5843 test_AES_GCM_auth_decryption_test_case_256_4(void)
5845 return test_authenticated_decryption(&gcm_test_case_256_4);
5849 test_AES_GCM_auth_decryption_test_case_256_5(void)
5851 return test_authenticated_decryption(&gcm_test_case_256_5);
5855 test_AES_GCM_auth_decryption_test_case_256_6(void)
5857 return test_authenticated_decryption(&gcm_test_case_256_6);
5861 test_AES_GCM_auth_decryption_test_case_256_7(void)
5863 return test_authenticated_decryption(&gcm_test_case_256_7);
5867 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5869 return test_authenticated_decryption(&gcm_test_case_aad_1);
5873 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5875 return test_authenticated_decryption(&gcm_test_case_aad_2);
5879 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5881 struct crypto_testsuite_params *ts_params = &testsuite_params;
5882 struct crypto_unittest_params *ut_params = &unittest_params;
5885 uint8_t *ciphertext, *auth_tag;
5886 uint16_t plaintext_pad_len;
5888 /* Create AEAD session */
5889 retval = create_aead_session(ts_params->valid_devs[0],
5891 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5892 tdata->key.data, tdata->key.len,
5893 tdata->aad.len, tdata->auth_tag.len,
5898 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5899 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5901 /* clear mbuf payload */
5902 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5903 rte_pktmbuf_tailroom(ut_params->ibuf));
5904 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5905 rte_pktmbuf_tailroom(ut_params->obuf));
5907 /* Create AEAD operation */
5908 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5914 ut_params->op->sym->m_src = ut_params->ibuf;
5915 ut_params->op->sym->m_dst = ut_params->obuf;
5917 /* Process crypto operation */
5918 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5919 ut_params->op), "failed to process sym crypto op");
5921 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5922 "crypto op processing failed");
5924 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5926 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5927 ut_params->op->sym->cipher.data.offset);
5928 auth_tag = ciphertext + plaintext_pad_len;
5930 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5931 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5934 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5936 tdata->ciphertext.data,
5937 tdata->ciphertext.len,
5938 "Ciphertext data not as expected");
5940 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5942 tdata->auth_tag.data,
5943 tdata->auth_tag.len,
5944 "Generated auth tag not as expected");
5951 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5953 return test_authenticated_encryption_oop(&gcm_test_case_5);
5957 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5959 struct crypto_testsuite_params *ts_params = &testsuite_params;
5960 struct crypto_unittest_params *ut_params = &unittest_params;
5965 /* Create AEAD session */
5966 retval = create_aead_session(ts_params->valid_devs[0],
5968 RTE_CRYPTO_AEAD_OP_DECRYPT,
5969 tdata->key.data, tdata->key.len,
5970 tdata->aad.len, tdata->auth_tag.len,
5975 /* alloc mbuf and set payload */
5976 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5977 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5979 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5980 rte_pktmbuf_tailroom(ut_params->ibuf));
5981 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5982 rte_pktmbuf_tailroom(ut_params->obuf));
5984 /* Create AEAD operation */
5985 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5989 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5991 ut_params->op->sym->m_src = ut_params->ibuf;
5992 ut_params->op->sym->m_dst = ut_params->obuf;
5994 /* Process crypto operation */
5995 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5996 ut_params->op), "failed to process sym crypto op");
5998 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5999 "crypto op processing failed");
6001 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6002 ut_params->op->sym->cipher.data.offset);
6004 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6007 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6009 tdata->plaintext.data,
6010 tdata->plaintext.len,
6011 "Plaintext data not as expected");
6013 TEST_ASSERT_EQUAL(ut_params->op->status,
6014 RTE_CRYPTO_OP_STATUS_SUCCESS,
6015 "Authentication failed");
6020 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6022 return test_authenticated_decryption_oop(&gcm_test_case_5);
6026 test_authenticated_encryption_sessionless(
6027 const struct aead_test_data *tdata)
6029 struct crypto_testsuite_params *ts_params = &testsuite_params;
6030 struct crypto_unittest_params *ut_params = &unittest_params;
6033 uint8_t *ciphertext, *auth_tag;
6034 uint16_t plaintext_pad_len;
6035 uint8_t key[tdata->key.len + 1];
6037 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6039 /* clear mbuf payload */
6040 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6041 rte_pktmbuf_tailroom(ut_params->ibuf));
6043 /* Create AEAD operation */
6044 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6048 /* Create GCM xform */
6049 memcpy(key, tdata->key.data, tdata->key.len);
6050 retval = create_aead_xform(ut_params->op,
6052 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6053 key, tdata->key.len,
6054 tdata->aad.len, tdata->auth_tag.len,
6059 ut_params->op->sym->m_src = ut_params->ibuf;
6061 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6062 RTE_CRYPTO_OP_SESSIONLESS,
6063 "crypto op session type not sessionless");
6065 /* Process crypto operation */
6066 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6067 ut_params->op), "failed to process sym crypto op");
6069 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6071 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6072 "crypto op status not success");
6074 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6076 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6077 ut_params->op->sym->cipher.data.offset);
6078 auth_tag = ciphertext + plaintext_pad_len;
6080 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6081 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6084 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6086 tdata->ciphertext.data,
6087 tdata->ciphertext.len,
6088 "Ciphertext data not as expected");
6090 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6092 tdata->auth_tag.data,
6093 tdata->auth_tag.len,
6094 "Generated auth tag not as expected");
6101 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6103 return test_authenticated_encryption_sessionless(
6108 test_authenticated_decryption_sessionless(
6109 const struct aead_test_data *tdata)
6111 struct crypto_testsuite_params *ts_params = &testsuite_params;
6112 struct crypto_unittest_params *ut_params = &unittest_params;
6116 uint8_t key[tdata->key.len + 1];
6118 /* alloc mbuf and set payload */
6119 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6121 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6122 rte_pktmbuf_tailroom(ut_params->ibuf));
6124 /* Create AEAD operation */
6125 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6129 /* Create AEAD xform */
6130 memcpy(key, tdata->key.data, tdata->key.len);
6131 retval = create_aead_xform(ut_params->op,
6133 RTE_CRYPTO_AEAD_OP_DECRYPT,
6134 key, tdata->key.len,
6135 tdata->aad.len, tdata->auth_tag.len,
6140 ut_params->op->sym->m_src = ut_params->ibuf;
6142 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6143 RTE_CRYPTO_OP_SESSIONLESS,
6144 "crypto op session type not sessionless");
6146 /* Process crypto operation */
6147 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6148 ut_params->op), "failed to process sym crypto op");
6150 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6152 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6153 "crypto op status not success");
6155 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6156 ut_params->op->sym->cipher.data.offset);
6158 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6161 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6163 tdata->plaintext.data,
6164 tdata->plaintext.len,
6165 "Plaintext data not as expected");
6167 TEST_ASSERT_EQUAL(ut_params->op->status,
6168 RTE_CRYPTO_OP_STATUS_SUCCESS,
6169 "Authentication failed");
6174 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6176 return test_authenticated_decryption_sessionless(
6181 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6183 return test_authenticated_encryption(&ccm_test_case_128_1);
6187 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6189 return test_authenticated_encryption(&ccm_test_case_128_2);
6193 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6195 return test_authenticated_encryption(&ccm_test_case_128_3);
6199 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6201 return test_authenticated_decryption(&ccm_test_case_128_1);
6205 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6207 return test_authenticated_decryption(&ccm_test_case_128_2);
6211 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6213 return test_authenticated_decryption(&ccm_test_case_128_3);
6217 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6219 return test_authenticated_encryption(&ccm_test_case_192_1);
6223 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6225 return test_authenticated_encryption(&ccm_test_case_192_2);
6229 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6231 return test_authenticated_encryption(&ccm_test_case_192_3);
6235 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6237 return test_authenticated_decryption(&ccm_test_case_192_1);
6241 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6243 return test_authenticated_decryption(&ccm_test_case_192_2);
6247 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6249 return test_authenticated_decryption(&ccm_test_case_192_3);
6253 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6255 return test_authenticated_encryption(&ccm_test_case_256_1);
6259 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6261 return test_authenticated_encryption(&ccm_test_case_256_2);
6265 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6267 return test_authenticated_encryption(&ccm_test_case_256_3);
6271 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6273 return test_authenticated_decryption(&ccm_test_case_256_1);
6277 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6279 return test_authenticated_decryption(&ccm_test_case_256_2);
6283 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6285 return test_authenticated_decryption(&ccm_test_case_256_3);
6291 struct crypto_testsuite_params *ts_params = &testsuite_params;
6292 struct rte_cryptodev_stats stats;
6293 struct rte_cryptodev *dev;
6294 cryptodev_stats_get_t temp_pfn;
6296 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6297 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6298 &stats) == -ENODEV),
6299 "rte_cryptodev_stats_get invalid dev failed");
6300 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6301 "rte_cryptodev_stats_get invalid Param failed");
6302 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6303 temp_pfn = dev->dev_ops->stats_get;
6304 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6305 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6307 "rte_cryptodev_stats_get invalid Param failed");
6308 dev->dev_ops->stats_get = temp_pfn;
6310 /* Test expected values */
6312 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6314 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6316 "rte_cryptodev_stats_get failed");
6317 TEST_ASSERT((stats.enqueued_count == 1),
6318 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6319 TEST_ASSERT((stats.dequeued_count == 1),
6320 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6321 TEST_ASSERT((stats.enqueue_err_count == 0),
6322 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6323 TEST_ASSERT((stats.dequeue_err_count == 0),
6324 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6326 /* invalid device but should ignore and not reset device stats*/
6327 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6328 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6330 "rte_cryptodev_stats_get failed");
6331 TEST_ASSERT((stats.enqueued_count == 1),
6332 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6334 /* check that a valid reset clears stats */
6335 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6336 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6338 "rte_cryptodev_stats_get failed");
6339 TEST_ASSERT((stats.enqueued_count == 0),
6340 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6341 TEST_ASSERT((stats.dequeued_count == 0),
6342 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6344 return TEST_SUCCESS;
6347 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6348 struct crypto_unittest_params *ut_params,
6349 enum rte_crypto_auth_operation op,
6350 const struct HMAC_MD5_vector *test_case)
6354 memcpy(key, test_case->key.data, test_case->key.len);
6356 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6357 ut_params->auth_xform.next = NULL;
6358 ut_params->auth_xform.auth.op = op;
6360 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6362 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6363 ut_params->auth_xform.auth.key.length = test_case->key.len;
6364 ut_params->auth_xform.auth.key.data = key;
6366 ut_params->sess = rte_cryptodev_sym_session_create(
6367 ts_params->session_mpool);
6369 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6370 ut_params->sess, &ut_params->auth_xform,
6371 ts_params->session_mpool);
6373 if (ut_params->sess == NULL)
6376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6378 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6379 rte_pktmbuf_tailroom(ut_params->ibuf));
6384 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6385 const struct HMAC_MD5_vector *test_case,
6386 uint8_t **plaintext)
6388 uint16_t plaintext_pad_len;
6390 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6392 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6395 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6397 memcpy(*plaintext, test_case->plaintext.data,
6398 test_case->plaintext.len);
6400 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6401 ut_params->ibuf, MD5_DIGEST_LEN);
6402 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6403 "no room to append digest");
6404 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6405 ut_params->ibuf, plaintext_pad_len);
6407 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6408 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6409 test_case->auth_tag.len);
6412 sym_op->auth.data.offset = 0;
6413 sym_op->auth.data.length = test_case->plaintext.len;
6415 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6416 ut_params->op->sym->m_src = ut_params->ibuf;
6422 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6424 uint16_t plaintext_pad_len;
6425 uint8_t *plaintext, *auth_tag;
6427 struct crypto_testsuite_params *ts_params = &testsuite_params;
6428 struct crypto_unittest_params *ut_params = &unittest_params;
6430 if (MD5_HMAC_create_session(ts_params, ut_params,
6431 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6434 /* Generate Crypto op data structure */
6435 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6436 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6437 TEST_ASSERT_NOT_NULL(ut_params->op,
6438 "Failed to allocate symmetric crypto operation struct");
6440 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6443 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6446 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6447 ut_params->op), "failed to process sym crypto op");
6449 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6450 "crypto op processing failed");
6452 if (ut_params->op->sym->m_dst) {
6453 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6454 uint8_t *, plaintext_pad_len);
6456 auth_tag = plaintext + plaintext_pad_len;
6459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6461 test_case->auth_tag.data,
6462 test_case->auth_tag.len,
6463 "HMAC_MD5 generated tag not as expected");
6465 return TEST_SUCCESS;
6469 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6473 struct crypto_testsuite_params *ts_params = &testsuite_params;
6474 struct crypto_unittest_params *ut_params = &unittest_params;
6476 if (MD5_HMAC_create_session(ts_params, ut_params,
6477 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6481 /* Generate Crypto op data structure */
6482 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6483 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6484 TEST_ASSERT_NOT_NULL(ut_params->op,
6485 "Failed to allocate symmetric crypto operation struct");
6487 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6490 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6491 ut_params->op), "failed to process sym crypto op");
6493 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6494 "HMAC_MD5 crypto op processing failed");
6496 return TEST_SUCCESS;
6500 test_MD5_HMAC_generate_case_1(void)
6502 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6506 test_MD5_HMAC_verify_case_1(void)
6508 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6512 test_MD5_HMAC_generate_case_2(void)
6514 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6518 test_MD5_HMAC_verify_case_2(void)
6520 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6524 test_multi_session(void)
6526 struct crypto_testsuite_params *ts_params = &testsuite_params;
6527 struct crypto_unittest_params *ut_params = &unittest_params;
6529 struct rte_cryptodev_info dev_info;
6530 struct rte_cryptodev_sym_session **sessions;
6534 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6535 aes_cbc_key, hmac_sha512_key);
6538 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6540 sessions = rte_malloc(NULL,
6541 (sizeof(struct rte_cryptodev_sym_session *) *
6542 MAX_NB_SESSIONS) + 1, 0);
6544 /* Create multiple crypto sessions*/
6545 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6547 sessions[i] = rte_cryptodev_sym_session_create(
6548 ts_params->session_mpool);
6550 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6551 sessions[i], &ut_params->auth_xform,
6552 ts_params->session_mpool);
6553 TEST_ASSERT_NOT_NULL(sessions[i],
6554 "Session creation failed at session number %u",
6557 /* Attempt to send a request on each session */
6558 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6562 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6563 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6565 "Failed to perform decrypt on request number %u.", i);
6566 /* free crypto operation structure */
6568 rte_crypto_op_free(ut_params->op);
6571 * free mbuf - both obuf and ibuf are usually the same,
6572 * so check if they point at the same address is necessary,
6573 * to avoid freeing the mbuf twice.
6575 if (ut_params->obuf) {
6576 rte_pktmbuf_free(ut_params->obuf);
6577 if (ut_params->ibuf == ut_params->obuf)
6578 ut_params->ibuf = 0;
6579 ut_params->obuf = 0;
6581 if (ut_params->ibuf) {
6582 rte_pktmbuf_free(ut_params->ibuf);
6583 ut_params->ibuf = 0;
6587 /* Next session create should fail */
6588 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6589 sessions[i], &ut_params->auth_xform,
6590 ts_params->session_mpool);
6591 TEST_ASSERT_NULL(sessions[i],
6592 "Session creation succeeded unexpectedly!");
6594 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6595 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6597 rte_cryptodev_sym_session_free(sessions[i]);
6602 return TEST_SUCCESS;
6605 struct multi_session_params {
6606 struct crypto_unittest_params ut_params;
6607 uint8_t *cipher_key;
6609 const uint8_t *cipher;
6610 const uint8_t *digest;
6614 #define MB_SESSION_NUMBER 3
6617 test_multi_session_random_usage(void)
6619 struct crypto_testsuite_params *ts_params = &testsuite_params;
6620 struct rte_cryptodev_info dev_info;
6621 struct rte_cryptodev_sym_session **sessions;
6623 struct multi_session_params ut_paramz[] = {
6626 .cipher_key = ms_aes_cbc_key0,
6627 .hmac_key = ms_hmac_key0,
6628 .cipher = ms_aes_cbc_cipher0,
6629 .digest = ms_hmac_digest0,
6630 .iv = ms_aes_cbc_iv0
6633 .cipher_key = ms_aes_cbc_key1,
6634 .hmac_key = ms_hmac_key1,
6635 .cipher = ms_aes_cbc_cipher1,
6636 .digest = ms_hmac_digest1,
6637 .iv = ms_aes_cbc_iv1
6640 .cipher_key = ms_aes_cbc_key2,
6641 .hmac_key = ms_hmac_key2,
6642 .cipher = ms_aes_cbc_cipher2,
6643 .digest = ms_hmac_digest2,
6644 .iv = ms_aes_cbc_iv2
6649 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6651 sessions = rte_malloc(NULL,
6652 (sizeof(struct rte_cryptodev_sym_session *)
6653 * MAX_NB_SESSIONS) + 1, 0);
6655 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6656 sessions[i] = rte_cryptodev_sym_session_create(
6657 ts_params->session_mpool);
6659 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6660 sizeof(struct crypto_unittest_params));
6662 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6663 &ut_paramz[i].ut_params,
6664 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6666 /* Create multiple crypto sessions*/
6667 rte_cryptodev_sym_session_init(
6668 ts_params->valid_devs[0],
6670 &ut_paramz[i].ut_params.auth_xform,
6671 ts_params->session_mpool);
6673 TEST_ASSERT_NOT_NULL(sessions[i],
6674 "Session creation failed at session number %u",
6680 for (i = 0; i < 40000; i++) {
6682 j = rand() % MB_SESSION_NUMBER;
6684 TEST_ASSERT_SUCCESS(
6685 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6687 &ut_paramz[j].ut_params,
6688 ts_params, ut_paramz[j].cipher,
6689 ut_paramz[j].digest,
6691 "Failed to perform decrypt on request number %u.", i);
6693 if (ut_paramz[j].ut_params.op)
6694 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6697 * free mbuf - both obuf and ibuf are usually the same,
6698 * so check if they point at the same address is necessary,
6699 * to avoid freeing the mbuf twice.
6701 if (ut_paramz[j].ut_params.obuf) {
6702 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6703 if (ut_paramz[j].ut_params.ibuf
6704 == ut_paramz[j].ut_params.obuf)
6705 ut_paramz[j].ut_params.ibuf = 0;
6706 ut_paramz[j].ut_params.obuf = 0;
6708 if (ut_paramz[j].ut_params.ibuf) {
6709 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6710 ut_paramz[j].ut_params.ibuf = 0;
6714 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6715 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6717 rte_cryptodev_sym_session_free(sessions[i]);
6722 return TEST_SUCCESS;
6726 test_null_cipher_only_operation(void)
6728 struct crypto_testsuite_params *ts_params = &testsuite_params;
6729 struct crypto_unittest_params *ut_params = &unittest_params;
6731 /* Generate test mbuf data and space for digest */
6732 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6733 catch_22_quote, QUOTE_512_BYTES, 0);
6735 /* Setup Cipher Parameters */
6736 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6737 ut_params->cipher_xform.next = NULL;
6739 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6740 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6742 ut_params->sess = rte_cryptodev_sym_session_create(
6743 ts_params->session_mpool);
6745 /* Create Crypto session*/
6746 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6748 &ut_params->cipher_xform,
6749 ts_params->session_mpool);
6750 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6752 /* Generate Crypto op data structure */
6753 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6754 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6755 TEST_ASSERT_NOT_NULL(ut_params->op,
6756 "Failed to allocate symmetric crypto operation struct");
6758 /* Set crypto operation data parameters */
6759 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6761 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6763 /* set crypto operation source mbuf */
6764 sym_op->m_src = ut_params->ibuf;
6766 sym_op->cipher.data.offset = 0;
6767 sym_op->cipher.data.length = QUOTE_512_BYTES;
6769 /* Process crypto operation */
6770 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6772 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6774 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6775 "crypto operation processing failed");
6778 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6779 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6782 "Ciphertext data not as expected");
6784 return TEST_SUCCESS;
6786 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6787 0xab, 0xab, 0xab, 0xab,
6788 0xab, 0xab, 0xab, 0xab,
6789 0xab, 0xab, 0xab, 0xab};
6791 test_null_auth_only_operation(void)
6793 struct crypto_testsuite_params *ts_params = &testsuite_params;
6794 struct crypto_unittest_params *ut_params = &unittest_params;
6797 /* Generate test mbuf data and space for digest */
6798 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6799 catch_22_quote, QUOTE_512_BYTES, 0);
6801 /* create a pointer for digest, but don't expect anything to be written
6802 * here in a NULL auth algo so no mbuf append done.
6804 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6806 /* prefill the memory pointed to by digest */
6807 memcpy(digest, orig_data, sizeof(orig_data));
6809 /* Setup HMAC Parameters */
6810 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6811 ut_params->auth_xform.next = NULL;
6813 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6814 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6816 ut_params->sess = rte_cryptodev_sym_session_create(
6817 ts_params->session_mpool);
6819 /* Create Crypto session*/
6820 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6821 ut_params->sess, &ut_params->auth_xform,
6822 ts_params->session_mpool);
6823 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6825 /* Generate Crypto op data structure */
6826 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6827 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6828 TEST_ASSERT_NOT_NULL(ut_params->op,
6829 "Failed to allocate symmetric crypto operation struct");
6831 /* Set crypto operation data parameters */
6832 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6836 sym_op->m_src = ut_params->ibuf;
6838 sym_op->auth.data.offset = 0;
6839 sym_op->auth.data.length = QUOTE_512_BYTES;
6840 sym_op->auth.digest.data = digest;
6841 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6844 /* Process crypto operation */
6845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6847 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6849 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6850 "crypto operation processing failed");
6851 /* Make sure memory pointed to by digest hasn't been overwritten */
6852 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6856 "Memory at digest ptr overwritten unexpectedly");
6858 return TEST_SUCCESS;
6863 test_null_cipher_auth_operation(void)
6865 struct crypto_testsuite_params *ts_params = &testsuite_params;
6866 struct crypto_unittest_params *ut_params = &unittest_params;
6869 /* Generate test mbuf data and space for digest */
6870 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6871 catch_22_quote, QUOTE_512_BYTES, 0);
6873 /* create a pointer for digest, but don't expect anything to be written
6874 * here in a NULL auth algo so no mbuf append done.
6876 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6878 /* prefill the memory pointed to by digest */
6879 memcpy(digest, orig_data, sizeof(orig_data));
6881 /* Setup Cipher Parameters */
6882 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6883 ut_params->cipher_xform.next = &ut_params->auth_xform;
6885 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6886 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6888 /* Setup HMAC Parameters */
6889 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6890 ut_params->auth_xform.next = NULL;
6892 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6893 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6895 ut_params->sess = rte_cryptodev_sym_session_create(
6896 ts_params->session_mpool);
6898 /* Create Crypto session*/
6899 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6900 ut_params->sess, &ut_params->cipher_xform,
6901 ts_params->session_mpool);
6902 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6904 /* Generate Crypto op data structure */
6905 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6906 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6907 TEST_ASSERT_NOT_NULL(ut_params->op,
6908 "Failed to allocate symmetric crypto operation struct");
6910 /* Set crypto operation data parameters */
6911 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6913 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6915 sym_op->m_src = ut_params->ibuf;
6917 sym_op->cipher.data.offset = 0;
6918 sym_op->cipher.data.length = QUOTE_512_BYTES;
6920 sym_op->auth.data.offset = 0;
6921 sym_op->auth.data.length = QUOTE_512_BYTES;
6922 sym_op->auth.digest.data = digest;
6923 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6926 /* Process crypto operation */
6927 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6929 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6931 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6932 "crypto operation processing failed");
6935 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6936 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6939 "Ciphertext data not as expected");
6940 /* Make sure memory pointed to by digest hasn't been overwritten */
6941 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6945 "Memory at digest ptr overwritten unexpectedly");
6947 return TEST_SUCCESS;
6951 test_null_auth_cipher_operation(void)
6953 struct crypto_testsuite_params *ts_params = &testsuite_params;
6954 struct crypto_unittest_params *ut_params = &unittest_params;
6957 /* Generate test mbuf data */
6958 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6959 catch_22_quote, QUOTE_512_BYTES, 0);
6961 /* create a pointer for digest, but don't expect anything to be written
6962 * here in a NULL auth algo so no mbuf append done.
6964 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6966 /* prefill the memory pointed to by digest */
6967 memcpy(digest, orig_data, sizeof(orig_data));
6969 /* Setup Cipher Parameters */
6970 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6971 ut_params->cipher_xform.next = NULL;
6973 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6974 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6976 /* Setup HMAC Parameters */
6977 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6978 ut_params->auth_xform.next = &ut_params->cipher_xform;
6980 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6981 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6983 ut_params->sess = rte_cryptodev_sym_session_create(
6984 ts_params->session_mpool);
6986 /* Create Crypto session*/
6987 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6988 ut_params->sess, &ut_params->cipher_xform,
6989 ts_params->session_mpool);
6990 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6992 /* Generate Crypto op data structure */
6993 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6994 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6995 TEST_ASSERT_NOT_NULL(ut_params->op,
6996 "Failed to allocate symmetric crypto operation struct");
6998 /* Set crypto operation data parameters */
6999 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7001 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7003 sym_op->m_src = ut_params->ibuf;
7005 sym_op->cipher.data.offset = 0;
7006 sym_op->cipher.data.length = QUOTE_512_BYTES;
7008 sym_op->auth.data.offset = 0;
7009 sym_op->auth.data.length = QUOTE_512_BYTES;
7010 sym_op->auth.digest.data = digest;
7011 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7014 /* Process crypto operation */
7015 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7017 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7019 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7020 "crypto operation processing failed");
7023 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7024 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7027 "Ciphertext data not as expected");
7028 /* Make sure memory pointed to by digest hasn't been overwritten */
7029 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7033 "Memory at digest ptr overwritten unexpectedly");
7035 return TEST_SUCCESS;
7040 test_null_invalid_operation(void)
7042 struct crypto_testsuite_params *ts_params = &testsuite_params;
7043 struct crypto_unittest_params *ut_params = &unittest_params;
7046 /* Setup Cipher Parameters */
7047 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7048 ut_params->cipher_xform.next = NULL;
7050 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7051 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7053 ut_params->sess = rte_cryptodev_sym_session_create(
7054 ts_params->session_mpool);
7056 /* Create Crypto session*/
7057 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7058 ut_params->sess, &ut_params->cipher_xform,
7059 ts_params->session_mpool);
7060 TEST_ASSERT(ret < 0,
7061 "Session creation succeeded unexpectedly");
7064 /* Setup HMAC Parameters */
7065 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7066 ut_params->auth_xform.next = NULL;
7068 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7069 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7071 ut_params->sess = rte_cryptodev_sym_session_create(
7072 ts_params->session_mpool);
7074 /* Create Crypto session*/
7075 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7076 ut_params->sess, &ut_params->auth_xform,
7077 ts_params->session_mpool);
7078 TEST_ASSERT(ret < 0,
7079 "Session creation succeeded unexpectedly");
7081 return TEST_SUCCESS;
7085 #define NULL_BURST_LENGTH (32)
7088 test_null_burst_operation(void)
7090 struct crypto_testsuite_params *ts_params = &testsuite_params;
7091 struct crypto_unittest_params *ut_params = &unittest_params;
7093 unsigned i, burst_len = NULL_BURST_LENGTH;
7095 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7096 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7098 /* Setup Cipher Parameters */
7099 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7100 ut_params->cipher_xform.next = &ut_params->auth_xform;
7102 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7103 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7105 /* Setup HMAC Parameters */
7106 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7107 ut_params->auth_xform.next = NULL;
7109 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7110 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7112 ut_params->sess = rte_cryptodev_sym_session_create(
7113 ts_params->session_mpool);
7115 /* Create Crypto session*/
7116 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7117 ut_params->sess, &ut_params->cipher_xform,
7118 ts_params->session_mpool);
7119 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7121 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7122 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7123 burst_len, "failed to generate burst of crypto ops");
7125 /* Generate an operation for each mbuf in burst */
7126 for (i = 0; i < burst_len; i++) {
7127 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7129 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7131 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7135 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7137 burst[i]->sym->m_src = m;
7140 /* Process crypto operation */
7141 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7142 0, burst, burst_len),
7144 "Error enqueuing burst");
7146 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7147 0, burst_dequeued, burst_len),
7149 "Error dequeuing burst");
7152 for (i = 0; i < burst_len; i++) {
7154 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7155 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7157 "data not as expected");
7159 rte_pktmbuf_free(burst[i]->sym->m_src);
7160 rte_crypto_op_free(burst[i]);
7163 return TEST_SUCCESS;
7167 generate_gmac_large_plaintext(uint8_t *data)
7171 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7172 memcpy(&data[i], &data[0], 32);
7176 create_gmac_operation(enum rte_crypto_auth_operation op,
7177 const struct gmac_test_data *tdata)
7179 struct crypto_testsuite_params *ts_params = &testsuite_params;
7180 struct crypto_unittest_params *ut_params = &unittest_params;
7181 struct rte_crypto_sym_op *sym_op;
7183 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7185 /* Generate Crypto op data structure */
7186 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7187 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7188 TEST_ASSERT_NOT_NULL(ut_params->op,
7189 "Failed to allocate symmetric crypto operation struct");
7191 sym_op = ut_params->op->sym;
7193 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7194 ut_params->ibuf, tdata->gmac_tag.len);
7195 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7196 "no room to append digest");
7198 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7199 ut_params->ibuf, plaintext_pad_len);
7201 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7202 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7203 tdata->gmac_tag.len);
7204 debug_hexdump(stdout, "digest:",
7205 sym_op->auth.digest.data,
7206 tdata->gmac_tag.len);
7209 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7210 uint8_t *, IV_OFFSET);
7212 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7214 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7216 sym_op->cipher.data.length = 0;
7217 sym_op->cipher.data.offset = 0;
7219 sym_op->auth.data.offset = 0;
7220 sym_op->auth.data.length = tdata->plaintext.len;
7225 static int create_gmac_session(uint8_t dev_id,
7226 const struct gmac_test_data *tdata,
7227 enum rte_crypto_auth_operation auth_op)
7229 uint8_t auth_key[tdata->key.len];
7231 struct crypto_testsuite_params *ts_params = &testsuite_params;
7232 struct crypto_unittest_params *ut_params = &unittest_params;
7234 memcpy(auth_key, tdata->key.data, tdata->key.len);
7236 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7237 ut_params->auth_xform.next = NULL;
7239 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7240 ut_params->auth_xform.auth.op = auth_op;
7241 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7242 ut_params->auth_xform.auth.key.length = tdata->key.len;
7243 ut_params->auth_xform.auth.key.data = auth_key;
7244 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7245 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7248 ut_params->sess = rte_cryptodev_sym_session_create(
7249 ts_params->session_mpool);
7251 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7252 &ut_params->auth_xform,
7253 ts_params->session_mpool);
7255 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7261 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7263 struct crypto_testsuite_params *ts_params = &testsuite_params;
7264 struct crypto_unittest_params *ut_params = &unittest_params;
7268 uint8_t *auth_tag, *plaintext;
7269 uint16_t plaintext_pad_len;
7271 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7272 "No GMAC length in the source data");
7274 retval = create_gmac_session(ts_params->valid_devs[0],
7275 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7280 if (tdata->plaintext.len > MBUF_SIZE)
7281 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7283 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7284 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7285 "Failed to allocate input buffer in mempool");
7287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7288 rte_pktmbuf_tailroom(ut_params->ibuf));
7290 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7292 * Runtime generate the large plain text instead of use hard code
7293 * plain text vector. It is done to avoid create huge source file
7294 * with the test vector.
7296 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7297 generate_gmac_large_plaintext(tdata->plaintext.data);
7299 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7301 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7303 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7304 debug_hexdump(stdout, "plaintext:", plaintext,
7305 tdata->plaintext.len);
7307 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7315 ut_params->op->sym->m_src = ut_params->ibuf;
7317 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7318 ut_params->op), "failed to process sym crypto op");
7320 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7321 "crypto op processing failed");
7323 if (ut_params->op->sym->m_dst) {
7324 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7325 uint8_t *, plaintext_pad_len);
7327 auth_tag = plaintext + plaintext_pad_len;
7330 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7332 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7334 tdata->gmac_tag.data,
7335 tdata->gmac_tag.len,
7336 "GMAC Generated auth tag not as expected");
7342 test_AES_GMAC_authentication_test_case_1(void)
7344 return test_AES_GMAC_authentication(&gmac_test_case_1);
7348 test_AES_GMAC_authentication_test_case_2(void)
7350 return test_AES_GMAC_authentication(&gmac_test_case_2);
7354 test_AES_GMAC_authentication_test_case_3(void)
7356 return test_AES_GMAC_authentication(&gmac_test_case_3);
7360 test_AES_GMAC_authentication_test_case_4(void)
7362 return test_AES_GMAC_authentication(&gmac_test_case_4);
7366 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7368 struct crypto_testsuite_params *ts_params = &testsuite_params;
7369 struct crypto_unittest_params *ut_params = &unittest_params;
7371 uint32_t plaintext_pad_len;
7374 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7375 "No GMAC length in the source data");
7377 retval = create_gmac_session(ts_params->valid_devs[0],
7378 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7383 if (tdata->plaintext.len > MBUF_SIZE)
7384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7386 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7387 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7388 "Failed to allocate input buffer in mempool");
7390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7391 rte_pktmbuf_tailroom(ut_params->ibuf));
7393 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7396 * Runtime generate the large plain text instead of use hard code
7397 * plain text vector. It is done to avoid create huge source file
7398 * with the test vector.
7400 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7401 generate_gmac_large_plaintext(tdata->plaintext.data);
7403 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7405 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7407 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7408 debug_hexdump(stdout, "plaintext:", plaintext,
7409 tdata->plaintext.len);
7411 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7417 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7419 ut_params->op->sym->m_src = ut_params->ibuf;
7421 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7422 ut_params->op), "failed to process sym crypto op");
7424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7425 "crypto op processing failed");
7432 test_AES_GMAC_authentication_verify_test_case_1(void)
7434 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7438 test_AES_GMAC_authentication_verify_test_case_2(void)
7440 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7444 test_AES_GMAC_authentication_verify_test_case_3(void)
7446 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7450 test_AES_GMAC_authentication_verify_test_case_4(void)
7452 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7455 struct test_crypto_vector {
7456 enum rte_crypto_cipher_algorithm crypto_algo;
7469 const uint8_t *data;
7474 const uint8_t *data;
7478 enum rte_crypto_auth_algorithm auth_algo;
7486 const uint8_t *data;
7496 static const struct test_crypto_vector
7497 hmac_sha1_test_crypto_vector = {
7498 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7500 .data = plaintext_hash,
7505 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7506 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7507 0xDE, 0xF4, 0xDE, 0xAD
7513 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7514 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7515 0x3F, 0x91, 0x64, 0x59
7521 static const struct test_crypto_vector
7522 aes128_gmac_test_vector = {
7523 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7525 .data = plaintext_hash,
7530 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7531 0x08, 0x09, 0x0A, 0x0B
7537 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7538 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7544 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7545 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7551 static const struct test_crypto_vector
7552 aes128cbc_hmac_sha1_test_vector = {
7553 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7556 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7557 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7563 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7564 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7569 .data = plaintext_hash,
7573 .data = ciphertext512_aes128cbc,
7576 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7579 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7580 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7581 0xDE, 0xF4, 0xDE, 0xAD
7587 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7588 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7589 0x18, 0x8C, 0x1D, 0x32
7596 data_corruption(uint8_t *data)
7602 tag_corruption(uint8_t *data, unsigned int tag_offset)
7604 data[tag_offset] += 1;
7608 create_auth_session(struct crypto_unittest_params *ut_params,
7610 const struct test_crypto_vector *reference,
7611 enum rte_crypto_auth_operation auth_op)
7613 struct crypto_testsuite_params *ts_params = &testsuite_params;
7614 uint8_t auth_key[reference->auth_key.len + 1];
7616 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7618 /* Setup Authentication Parameters */
7619 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7620 ut_params->auth_xform.auth.op = auth_op;
7621 ut_params->auth_xform.next = NULL;
7622 ut_params->auth_xform.auth.algo = reference->auth_algo;
7623 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7624 ut_params->auth_xform.auth.key.data = auth_key;
7625 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7627 /* Create Crypto session*/
7628 ut_params->sess = rte_cryptodev_sym_session_create(
7629 ts_params->session_mpool);
7631 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7632 &ut_params->auth_xform,
7633 ts_params->session_mpool);
7635 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7641 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7643 const struct test_crypto_vector *reference,
7644 enum rte_crypto_auth_operation auth_op,
7645 enum rte_crypto_cipher_operation cipher_op)
7647 struct crypto_testsuite_params *ts_params = &testsuite_params;
7648 uint8_t cipher_key[reference->cipher_key.len + 1];
7649 uint8_t auth_key[reference->auth_key.len + 1];
7651 memcpy(cipher_key, reference->cipher_key.data,
7652 reference->cipher_key.len);
7653 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7655 /* Setup Authentication Parameters */
7656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7657 ut_params->auth_xform.auth.op = auth_op;
7658 ut_params->auth_xform.auth.algo = reference->auth_algo;
7659 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7660 ut_params->auth_xform.auth.key.data = auth_key;
7661 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7663 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7664 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7665 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7667 ut_params->auth_xform.next = &ut_params->cipher_xform;
7669 /* Setup Cipher Parameters */
7670 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7671 ut_params->cipher_xform.next = NULL;
7672 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7673 ut_params->cipher_xform.cipher.op = cipher_op;
7674 ut_params->cipher_xform.cipher.key.data = cipher_key;
7675 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7676 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7677 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7680 /* Create Crypto session*/
7681 ut_params->sess = rte_cryptodev_sym_session_create(
7682 ts_params->session_mpool);
7684 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7685 &ut_params->auth_xform,
7686 ts_params->session_mpool);
7688 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7694 create_auth_operation(struct crypto_testsuite_params *ts_params,
7695 struct crypto_unittest_params *ut_params,
7696 const struct test_crypto_vector *reference,
7697 unsigned int auth_generate)
7699 /* Generate Crypto op data structure */
7700 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7701 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7702 TEST_ASSERT_NOT_NULL(ut_params->op,
7703 "Failed to allocate pktmbuf offload");
7705 /* Set crypto operation data parameters */
7706 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7708 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7710 /* set crypto operation source mbuf */
7711 sym_op->m_src = ut_params->ibuf;
7714 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7715 ut_params->ibuf, reference->digest.len);
7717 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7718 "no room to append auth tag");
7720 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7721 ut_params->ibuf, reference->plaintext.len);
7724 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7726 memcpy(sym_op->auth.digest.data,
7727 reference->digest.data,
7728 reference->digest.len);
7730 debug_hexdump(stdout, "digest:",
7731 sym_op->auth.digest.data,
7732 reference->digest.len);
7734 sym_op->auth.data.length = reference->plaintext.len;
7735 sym_op->auth.data.offset = 0;
7741 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7742 struct crypto_unittest_params *ut_params,
7743 const struct test_crypto_vector *reference,
7744 unsigned int auth_generate)
7746 /* Generate Crypto op data structure */
7747 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7748 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7749 TEST_ASSERT_NOT_NULL(ut_params->op,
7750 "Failed to allocate pktmbuf offload");
7752 /* Set crypto operation data parameters */
7753 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7755 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7757 /* set crypto operation source mbuf */
7758 sym_op->m_src = ut_params->ibuf;
7761 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7762 ut_params->ibuf, reference->digest.len);
7764 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7765 "no room to append auth tag");
7767 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7768 ut_params->ibuf, reference->ciphertext.len);
7771 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7773 memcpy(sym_op->auth.digest.data,
7774 reference->digest.data,
7775 reference->digest.len);
7777 debug_hexdump(stdout, "digest:",
7778 sym_op->auth.digest.data,
7779 reference->digest.len);
7781 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7782 reference->iv.data, reference->iv.len);
7784 sym_op->cipher.data.length = 0;
7785 sym_op->cipher.data.offset = 0;
7787 sym_op->auth.data.length = reference->plaintext.len;
7788 sym_op->auth.data.offset = 0;
7794 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7795 struct crypto_unittest_params *ut_params,
7796 const struct test_crypto_vector *reference,
7797 unsigned int auth_generate)
7799 /* Generate Crypto op data structure */
7800 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7801 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7802 TEST_ASSERT_NOT_NULL(ut_params->op,
7803 "Failed to allocate pktmbuf offload");
7805 /* Set crypto operation data parameters */
7806 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7808 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7810 /* set crypto operation source mbuf */
7811 sym_op->m_src = ut_params->ibuf;
7814 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7815 ut_params->ibuf, reference->digest.len);
7817 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7818 "no room to append auth tag");
7820 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7821 ut_params->ibuf, reference->ciphertext.len);
7824 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7826 memcpy(sym_op->auth.digest.data,
7827 reference->digest.data,
7828 reference->digest.len);
7830 debug_hexdump(stdout, "digest:",
7831 sym_op->auth.digest.data,
7832 reference->digest.len);
7834 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7835 reference->iv.data, reference->iv.len);
7837 sym_op->cipher.data.length = reference->ciphertext.len;
7838 sym_op->cipher.data.offset = 0;
7840 sym_op->auth.data.length = reference->ciphertext.len;
7841 sym_op->auth.data.offset = 0;
7847 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7848 struct crypto_unittest_params *ut_params,
7849 const struct test_crypto_vector *reference)
7851 return create_auth_operation(ts_params, ut_params, reference, 0);
7855 create_auth_verify_GMAC_operation(
7856 struct crypto_testsuite_params *ts_params,
7857 struct crypto_unittest_params *ut_params,
7858 const struct test_crypto_vector *reference)
7860 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7864 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7865 struct crypto_unittest_params *ut_params,
7866 const struct test_crypto_vector *reference)
7868 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7872 test_authentication_verify_fail_when_data_corruption(
7873 struct crypto_testsuite_params *ts_params,
7874 struct crypto_unittest_params *ut_params,
7875 const struct test_crypto_vector *reference,
7876 unsigned int data_corrupted)
7882 /* Create session */
7883 retval = create_auth_session(ut_params,
7884 ts_params->valid_devs[0],
7886 RTE_CRYPTO_AUTH_OP_VERIFY);
7890 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7891 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7892 "Failed to allocate input buffer in mempool");
7894 /* clear mbuf payload */
7895 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7896 rte_pktmbuf_tailroom(ut_params->ibuf));
7898 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7899 reference->plaintext.len);
7900 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7901 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7903 debug_hexdump(stdout, "plaintext:", plaintext,
7904 reference->plaintext.len);
7906 /* Create operation */
7907 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7913 data_corruption(plaintext);
7915 tag_corruption(plaintext, reference->plaintext.len);
7917 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7919 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7920 TEST_ASSERT_EQUAL(ut_params->op->status,
7921 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7922 "authentication not failed");
7924 ut_params->obuf = ut_params->op->sym->m_src;
7925 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7931 test_authentication_verify_GMAC_fail_when_corruption(
7932 struct crypto_testsuite_params *ts_params,
7933 struct crypto_unittest_params *ut_params,
7934 const struct test_crypto_vector *reference,
7935 unsigned int data_corrupted)
7940 /* Create session */
7941 retval = create_auth_cipher_session(ut_params,
7942 ts_params->valid_devs[0],
7944 RTE_CRYPTO_AUTH_OP_VERIFY,
7945 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7949 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7950 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7951 "Failed to allocate input buffer in mempool");
7953 /* clear mbuf payload */
7954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7955 rte_pktmbuf_tailroom(ut_params->ibuf));
7957 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7958 reference->plaintext.len);
7959 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7960 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7962 debug_hexdump(stdout, "plaintext:", plaintext,
7963 reference->plaintext.len);
7965 /* Create operation */
7966 retval = create_auth_verify_GMAC_operation(ts_params,
7974 data_corruption(plaintext);
7976 tag_corruption(plaintext, reference->aad.len);
7978 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7980 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7981 TEST_ASSERT_EQUAL(ut_params->op->status,
7982 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7983 "authentication not failed");
7985 ut_params->obuf = ut_params->op->sym->m_src;
7986 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7992 test_authenticated_decryption_fail_when_corruption(
7993 struct crypto_testsuite_params *ts_params,
7994 struct crypto_unittest_params *ut_params,
7995 const struct test_crypto_vector *reference,
7996 unsigned int data_corrupted)
8000 uint8_t *ciphertext;
8002 /* Create session */
8003 retval = create_auth_cipher_session(ut_params,
8004 ts_params->valid_devs[0],
8006 RTE_CRYPTO_AUTH_OP_VERIFY,
8007 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8011 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8012 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8013 "Failed to allocate input buffer in mempool");
8015 /* clear mbuf payload */
8016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8017 rte_pktmbuf_tailroom(ut_params->ibuf));
8019 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8020 reference->ciphertext.len);
8021 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8022 memcpy(ciphertext, reference->ciphertext.data,
8023 reference->ciphertext.len);
8025 /* Create operation */
8026 retval = create_cipher_auth_verify_operation(ts_params,
8034 data_corruption(ciphertext);
8036 tag_corruption(ciphertext, reference->ciphertext.len);
8038 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8042 TEST_ASSERT_EQUAL(ut_params->op->status,
8043 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8044 "authentication not failed");
8046 ut_params->obuf = ut_params->op->sym->m_src;
8047 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8053 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8054 const struct aead_test_data *tdata,
8055 void *digest_mem, uint64_t digest_phys)
8057 struct crypto_testsuite_params *ts_params = &testsuite_params;
8058 struct crypto_unittest_params *ut_params = &unittest_params;
8060 const unsigned int auth_tag_len = tdata->auth_tag.len;
8061 const unsigned int iv_len = tdata->iv.len;
8062 unsigned int aad_len = tdata->aad.len;
8064 /* Generate Crypto op data structure */
8065 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8066 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8067 TEST_ASSERT_NOT_NULL(ut_params->op,
8068 "Failed to allocate symmetric crypto operation struct");
8070 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8072 sym_op->aead.digest.data = digest_mem;
8074 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8075 "no room to append digest");
8077 sym_op->aead.digest.phys_addr = digest_phys;
8079 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8080 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8082 debug_hexdump(stdout, "digest:",
8083 sym_op->aead.digest.data,
8087 /* Append aad data */
8088 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8089 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8090 uint8_t *, IV_OFFSET);
8092 /* Copy IV 1 byte after the IV pointer, according to the API */
8093 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8095 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8097 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8098 ut_params->ibuf, aad_len);
8099 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8100 "no room to prepend aad");
8101 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8104 memset(sym_op->aead.aad.data, 0, aad_len);
8105 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8106 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8108 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8109 debug_hexdump(stdout, "aad:",
8110 sym_op->aead.aad.data, aad_len);
8112 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8113 uint8_t *, IV_OFFSET);
8115 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8117 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8118 ut_params->ibuf, aad_len);
8119 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8120 "no room to prepend aad");
8121 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8124 memset(sym_op->aead.aad.data, 0, aad_len);
8125 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8127 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8128 debug_hexdump(stdout, "aad:",
8129 sym_op->aead.aad.data, aad_len);
8132 sym_op->aead.data.length = tdata->plaintext.len;
8133 sym_op->aead.data.offset = aad_len;
8138 #define SGL_MAX_NO 16
8141 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8142 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8144 struct crypto_testsuite_params *ts_params = &testsuite_params;
8145 struct crypto_unittest_params *ut_params = &unittest_params;
8146 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8149 int to_trn_tbl[SGL_MAX_NO];
8151 unsigned int trn_data = 0;
8152 uint8_t *plaintext, *ciphertext, *auth_tag;
8154 if (fragsz > tdata->plaintext.len)
8155 fragsz = tdata->plaintext.len;
8157 uint16_t plaintext_len = fragsz;
8158 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8160 if (fragsz_oop > tdata->plaintext.len)
8161 frag_size_oop = tdata->plaintext.len;
8164 void *digest_mem = NULL;
8166 uint32_t prepend_len = tdata->aad.len;
8168 if (tdata->plaintext.len % fragsz != 0) {
8169 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8172 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8177 * For out-op-place we need to alloc another mbuf
8180 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8181 rte_pktmbuf_append(ut_params->obuf,
8182 frag_size_oop + prepend_len);
8183 buf_oop = ut_params->obuf;
8186 /* Create AEAD session */
8187 retval = create_aead_session(ts_params->valid_devs[0],
8189 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8190 tdata->key.data, tdata->key.len,
8191 tdata->aad.len, tdata->auth_tag.len,
8196 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8198 /* clear mbuf payload */
8199 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8200 rte_pktmbuf_tailroom(ut_params->ibuf));
8202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8205 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8207 trn_data += plaintext_len;
8209 buf = ut_params->ibuf;
8212 * Loop until no more fragments
8215 while (trn_data < tdata->plaintext.len) {
8217 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8218 (tdata->plaintext.len - trn_data) : fragsz;
8220 to_trn_tbl[ecx++] = to_trn;
8222 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8225 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8226 rte_pktmbuf_tailroom(buf));
8229 if (oop && !fragsz_oop) {
8230 buf_last_oop = buf_oop->next =
8231 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8232 buf_oop = buf_oop->next;
8233 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8234 0, rte_pktmbuf_tailroom(buf_oop));
8235 rte_pktmbuf_append(buf_oop, to_trn);
8238 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8241 memcpy(plaintext, tdata->plaintext.data + trn_data,
8244 if (trn_data == tdata->plaintext.len) {
8247 digest_mem = rte_pktmbuf_append(buf_oop,
8248 tdata->auth_tag.len);
8250 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8251 tdata->auth_tag.len);
8255 uint64_t digest_phys = 0;
8257 ut_params->ibuf->nb_segs = segs;
8260 if (fragsz_oop && oop) {
8264 if (frag_size_oop == tdata->plaintext.len) {
8265 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8266 tdata->auth_tag.len);
8268 digest_phys = rte_pktmbuf_iova_offset(
8270 tdata->plaintext.len + prepend_len);
8273 trn_data = frag_size_oop;
8274 while (trn_data < tdata->plaintext.len) {
8277 (tdata->plaintext.len - trn_data <
8279 (tdata->plaintext.len - trn_data) :
8282 to_trn_tbl[ecx++] = to_trn;
8284 buf_last_oop = buf_oop->next =
8285 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8286 buf_oop = buf_oop->next;
8287 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8288 0, rte_pktmbuf_tailroom(buf_oop));
8289 rte_pktmbuf_append(buf_oop, to_trn);
8293 if (trn_data == tdata->plaintext.len) {
8294 digest_mem = rte_pktmbuf_append(buf_oop,
8295 tdata->auth_tag.len);
8299 ut_params->obuf->nb_segs = segs;
8303 * Place digest at the end of the last buffer
8306 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8307 if (oop && buf_last_oop)
8308 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8310 if (!digest_mem && !oop) {
8311 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8312 + tdata->auth_tag.len);
8313 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8314 tdata->plaintext.len);
8317 /* Create AEAD operation */
8318 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8319 tdata, digest_mem, digest_phys);
8324 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8326 ut_params->op->sym->m_src = ut_params->ibuf;
8328 ut_params->op->sym->m_dst = ut_params->obuf;
8330 /* Process crypto operation */
8331 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8332 ut_params->op), "failed to process sym crypto op");
8334 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8335 "crypto op processing failed");
8338 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8339 uint8_t *, prepend_len);
8341 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8342 uint8_t *, prepend_len);
8346 fragsz = fragsz_oop;
8348 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8350 tdata->ciphertext.data,
8352 "Ciphertext data not as expected");
8354 buf = ut_params->op->sym->m_src->next;
8356 buf = ut_params->op->sym->m_dst->next;
8358 unsigned int off = fragsz;
8362 ciphertext = rte_pktmbuf_mtod(buf,
8365 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8367 tdata->ciphertext.data + off,
8369 "Ciphertext data not as expected");
8371 off += to_trn_tbl[ecx++];
8375 auth_tag = digest_mem;
8376 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8378 tdata->auth_tag.data,
8379 tdata->auth_tag.len,
8380 "Generated auth tag not as expected");
8386 #define OUT_OF_PLACE 1
8389 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8391 return test_authenticated_encryption_SGL(
8392 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8396 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8398 return test_authenticated_encryption_SGL(
8399 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8403 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8405 return test_authenticated_encryption_SGL(
8406 &gcm_test_case_8, OUT_OF_PLACE, 400,
8407 gcm_test_case_8.plaintext.len);
8411 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8414 return test_authenticated_encryption_SGL(
8415 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8419 test_authentication_verify_fail_when_data_corrupted(
8420 struct crypto_testsuite_params *ts_params,
8421 struct crypto_unittest_params *ut_params,
8422 const struct test_crypto_vector *reference)
8424 return test_authentication_verify_fail_when_data_corruption(
8425 ts_params, ut_params, reference, 1);
8429 test_authentication_verify_fail_when_tag_corrupted(
8430 struct crypto_testsuite_params *ts_params,
8431 struct crypto_unittest_params *ut_params,
8432 const struct test_crypto_vector *reference)
8434 return test_authentication_verify_fail_when_data_corruption(
8435 ts_params, ut_params, reference, 0);
8439 test_authentication_verify_GMAC_fail_when_data_corrupted(
8440 struct crypto_testsuite_params *ts_params,
8441 struct crypto_unittest_params *ut_params,
8442 const struct test_crypto_vector *reference)
8444 return test_authentication_verify_GMAC_fail_when_corruption(
8445 ts_params, ut_params, reference, 1);
8449 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8450 struct crypto_testsuite_params *ts_params,
8451 struct crypto_unittest_params *ut_params,
8452 const struct test_crypto_vector *reference)
8454 return test_authentication_verify_GMAC_fail_when_corruption(
8455 ts_params, ut_params, reference, 0);
8459 test_authenticated_decryption_fail_when_data_corrupted(
8460 struct crypto_testsuite_params *ts_params,
8461 struct crypto_unittest_params *ut_params,
8462 const struct test_crypto_vector *reference)
8464 return test_authenticated_decryption_fail_when_corruption(
8465 ts_params, ut_params, reference, 1);
8469 test_authenticated_decryption_fail_when_tag_corrupted(
8470 struct crypto_testsuite_params *ts_params,
8471 struct crypto_unittest_params *ut_params,
8472 const struct test_crypto_vector *reference)
8474 return test_authenticated_decryption_fail_when_corruption(
8475 ts_params, ut_params, reference, 0);
8479 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8481 return test_authentication_verify_fail_when_data_corrupted(
8482 &testsuite_params, &unittest_params,
8483 &hmac_sha1_test_crypto_vector);
8487 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8489 return test_authentication_verify_fail_when_tag_corrupted(
8490 &testsuite_params, &unittest_params,
8491 &hmac_sha1_test_crypto_vector);
8495 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8497 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8498 &testsuite_params, &unittest_params,
8499 &aes128_gmac_test_vector);
8503 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8505 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8506 &testsuite_params, &unittest_params,
8507 &aes128_gmac_test_vector);
8511 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8513 return test_authenticated_decryption_fail_when_data_corrupted(
8516 &aes128cbc_hmac_sha1_test_vector);
8520 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8522 return test_authenticated_decryption_fail_when_tag_corrupted(
8525 &aes128cbc_hmac_sha1_test_vector);
8528 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8530 /* global AESNI slave IDs for the scheduler test */
8531 uint8_t aesni_ids[2];
8534 test_scheduler_attach_slave_op(void)
8536 struct crypto_testsuite_params *ts_params = &testsuite_params;
8537 uint8_t sched_id = ts_params->valid_devs[0];
8538 uint32_t nb_devs, i, nb_devs_attached = 0;
8542 /* create 2 AESNI_MB if necessary */
8543 nb_devs = rte_cryptodev_device_count_by_driver(
8544 rte_cryptodev_driver_id_get(
8545 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8547 for (i = nb_devs; i < 2; i++) {
8548 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8549 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8551 ret = rte_vdev_init(vdev_name, NULL);
8553 TEST_ASSERT(ret == 0,
8554 "Failed to create instance %u of"
8556 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8560 /* attach 2 AESNI_MB cdevs */
8561 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8563 struct rte_cryptodev_info info;
8565 rte_cryptodev_info_get(i, &info);
8566 if (info.driver_id != rte_cryptodev_driver_id_get(
8567 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8571 * Create the session mempool again, since now there are new devices
8572 * to use the mempool.
8574 if (ts_params->session_mpool) {
8575 rte_mempool_free(ts_params->session_mpool);
8576 ts_params->session_mpool = NULL;
8578 unsigned int session_size =
8579 rte_cryptodev_sym_get_private_session_size(i);
8581 if (info.sym.max_nb_sessions != 0 &&
8582 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8584 "Device does not support "
8585 "at least %u sessions\n",
8590 * Create mempool with maximum number of sessions * 2,
8591 * to include the session headers
8593 if (ts_params->session_mpool == NULL) {
8594 ts_params->session_mpool = rte_mempool_create(
8596 MAX_NB_SESSIONS * 2,
8598 0, 0, NULL, NULL, NULL,
8599 NULL, SOCKET_ID_ANY,
8602 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8603 "session mempool allocation failed");
8606 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8609 TEST_ASSERT(ret == 0,
8610 "Failed to attach device %u of pmd : %s", i,
8611 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8613 aesni_ids[nb_devs_attached] = (uint8_t)i;
8622 test_scheduler_detach_slave_op(void)
8624 struct crypto_testsuite_params *ts_params = &testsuite_params;
8625 uint8_t sched_id = ts_params->valid_devs[0];
8629 for (i = 0; i < 2; i++) {
8630 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8632 TEST_ASSERT(ret == 0,
8633 "Failed to detach device %u", aesni_ids[i]);
8640 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8642 struct crypto_testsuite_params *ts_params = &testsuite_params;
8643 uint8_t sched_id = ts_params->valid_devs[0];
8645 return rte_cryptodev_scheduler_mode_set(sched_id,
8650 test_scheduler_mode_roundrobin_op(void)
8652 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8653 0, "Failed to set roundrobin mode");
8659 test_scheduler_mode_multicore_op(void)
8661 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8662 0, "Failed to set multicore mode");
8668 test_scheduler_mode_failover_op(void)
8670 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8671 0, "Failed to set failover mode");
8677 test_scheduler_mode_pkt_size_distr_op(void)
8679 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8680 0, "Failed to set pktsize mode");
8685 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8686 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8687 .setup = testsuite_setup,
8688 .teardown = testsuite_teardown,
8689 .unit_test_cases = {
8691 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8692 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_AES_chain_scheduler_all),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_AES_cipheronly_scheduler_all),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_authonly_scheduler_all),
8699 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8702 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8703 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_AES_chain_scheduler_all),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_AES_cipheronly_scheduler_all),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_authonly_scheduler_all),
8710 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8713 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8714 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_AES_chain_scheduler_all),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_AES_cipheronly_scheduler_all),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_authonly_scheduler_all),
8721 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8724 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8725 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 test_AES_chain_scheduler_all),
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 test_AES_cipheronly_scheduler_all),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_authonly_scheduler_all),
8732 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8734 TEST_CASES_END() /**< NULL terminate unit test array */
8738 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8740 static struct unit_test_suite cryptodev_qat_testsuite = {
8741 .suite_name = "Crypto QAT Unit Test Suite",
8742 .setup = testsuite_setup,
8743 .teardown = testsuite_teardown,
8744 .unit_test_cases = {
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_device_configure_invalid_dev_id),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_device_configure_invalid_queue_pair_ids),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_queue_pair_descriptor_setup),
8751 TEST_CASE_ST(ut_setup, ut_teardown,
8752 test_multi_session),
8754 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8755 TEST_CASE_ST(ut_setup, ut_teardown,
8756 test_AES_cipheronly_qat_all),
8757 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_3DES_cipheronly_qat_all),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_DES_cipheronly_qat_all),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_docsis_qat_all),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_DES_docsis_qat_all),
8766 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8767 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8769 /** AES CCM Authenticated Encryption 128 bits key */
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_CCM_authenticated_encryption_test_case_128_1),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_CCM_authenticated_encryption_test_case_128_2),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_CCM_authenticated_encryption_test_case_128_3),
8777 /** AES CCM Authenticated Decryption 128 bits key*/
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_CCM_authenticated_decryption_test_case_128_1),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_CCM_authenticated_decryption_test_case_128_2),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_CCM_authenticated_decryption_test_case_128_3),
8785 /** AES GCM Authenticated Encryption */
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_authenticated_encryption_test_case_1),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_authenticated_encryption_test_case_2),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_authenticated_encryption_test_case_3),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_authenticated_encryption_test_case_4),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_authenticated_encryption_test_case_5),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_authenticated_encryption_test_case_6),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_AES_GCM_authenticated_encryption_test_case_7),
8807 /** AES GCM Authenticated Decryption */
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_authenticated_decryption_test_case_1),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_authenticated_decryption_test_case_2),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_authenticated_decryption_test_case_3),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_authenticated_decryption_test_case_4),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_authenticated_decryption_test_case_5),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_authenticated_decryption_test_case_6),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_AES_GCM_authenticated_decryption_test_case_7),
8823 /** AES GCM Authenticated Encryption 192 bits key */
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GCM_auth_encryption_test_case_192_1),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_auth_encryption_test_case_192_2),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GCM_auth_encryption_test_case_192_3),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GCM_auth_encryption_test_case_192_4),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GCM_auth_encryption_test_case_192_5),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GCM_auth_encryption_test_case_192_6),
8836 TEST_CASE_ST(ut_setup, ut_teardown,
8837 test_AES_GCM_auth_encryption_test_case_192_7),
8839 /** AES GCM Authenticated Decryption 192 bits key */
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_AES_GCM_auth_decryption_test_case_192_1),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_AES_GCM_auth_decryption_test_case_192_2),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_AES_GCM_auth_decryption_test_case_192_3),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_AES_GCM_auth_decryption_test_case_192_4),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_AES_GCM_auth_decryption_test_case_192_5),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_AES_GCM_auth_decryption_test_case_192_6),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_AES_GCM_auth_decryption_test_case_192_7),
8855 /** AES GCM Authenticated Encryption 256 bits key */
8856 TEST_CASE_ST(ut_setup, ut_teardown,
8857 test_AES_GCM_auth_encryption_test_case_256_1),
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_AES_GCM_auth_encryption_test_case_256_2),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_AES_GCM_auth_encryption_test_case_256_3),
8862 TEST_CASE_ST(ut_setup, ut_teardown,
8863 test_AES_GCM_auth_encryption_test_case_256_4),
8864 TEST_CASE_ST(ut_setup, ut_teardown,
8865 test_AES_GCM_auth_encryption_test_case_256_5),
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_AES_GCM_auth_encryption_test_case_256_6),
8868 TEST_CASE_ST(ut_setup, ut_teardown,
8869 test_AES_GCM_auth_encryption_test_case_256_7),
8871 /** AES GMAC Authentication */
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_AES_GMAC_authentication_test_case_1),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_AES_GMAC_authentication_verify_test_case_1),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_AES_GMAC_authentication_test_case_2),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_AES_GMAC_authentication_verify_test_case_2),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_AES_GMAC_authentication_test_case_3),
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_AES_GMAC_authentication_verify_test_case_3),
8885 /** SNOW 3G encrypt only (UEA2) */
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 test_snow3g_encryption_test_case_1),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 test_snow3g_encryption_test_case_2),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 test_snow3g_encryption_test_case_3),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_snow3g_encryption_test_case_4),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_snow3g_encryption_test_case_5),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_snow3g_encryption_test_case_1_oop),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_snow3g_decryption_test_case_1_oop),
8902 /** SNOW 3G decrypt only (UEA2) */
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_snow3g_decryption_test_case_1),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_snow3g_decryption_test_case_2),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_snow3g_decryption_test_case_3),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_snow3g_decryption_test_case_4),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_snow3g_decryption_test_case_5),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_snow3g_hash_generate_test_case_1),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_snow3g_hash_generate_test_case_2),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_snow3g_hash_generate_test_case_3),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_snow3g_hash_verify_test_case_1),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_snow3g_hash_verify_test_case_2),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_snow3g_hash_verify_test_case_3),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_snow3g_cipher_auth_test_case_1),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_snow3g_auth_cipher_test_case_1),
8930 /** ZUC encrypt only (EEA3) */
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_zuc_encryption_test_case_1),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_zuc_encryption_test_case_2),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_zuc_encryption_test_case_3),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_zuc_encryption_test_case_4),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_zuc_encryption_test_case_5),
8942 /** ZUC authenticate (EIA3) */
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_zuc_hash_generate_test_case_6),
8945 TEST_CASE_ST(ut_setup, ut_teardown,
8946 test_zuc_hash_generate_test_case_7),
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 test_zuc_hash_generate_test_case_8),
8950 /** ZUC alg-chain (EEA3/EIA3) */
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_zuc_cipher_auth_test_case_1),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_zuc_cipher_auth_test_case_2),
8956 /** HMAC_MD5 Authentication */
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_MD5_HMAC_generate_case_1),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_MD5_HMAC_verify_case_1),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_MD5_HMAC_generate_case_2),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_MD5_HMAC_verify_case_2),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_null_auth_only_operation),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_null_cipher_only_operation),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_null_cipher_auth_operation),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_null_auth_cipher_operation),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_kasumi_hash_generate_test_case_1),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_kasumi_hash_generate_test_case_2),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_kasumi_hash_generate_test_case_3),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_kasumi_hash_generate_test_case_4),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_kasumi_hash_generate_test_case_5),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_kasumi_hash_generate_test_case_6),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_kasumi_hash_verify_test_case_1),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_kasumi_hash_verify_test_case_2),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_kasumi_hash_verify_test_case_3),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_kasumi_hash_verify_test_case_4),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_kasumi_hash_verify_test_case_5),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_kasumi_encryption_test_case_1),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_kasumi_encryption_test_case_3),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_kasumi_auth_cipher_test_case_1),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_kasumi_cipher_auth_test_case_1),
9010 /** Negative tests */
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 authentication_verify_AES128_GMAC_fail_data_corrupt),
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9024 TEST_CASES_END() /**< NULL terminate unit test array */
9028 static struct unit_test_suite cryptodev_virtio_testsuite = {
9029 .suite_name = "Crypto VIRTIO Unit Test Suite",
9030 .setup = testsuite_setup,
9031 .teardown = testsuite_teardown,
9032 .unit_test_cases = {
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_cipheronly_virtio_all),
9036 TEST_CASES_END() /**< NULL terminate unit test array */
9040 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9041 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9042 .setup = testsuite_setup,
9043 .teardown = testsuite_teardown,
9044 .unit_test_cases = {
9045 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9046 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9047 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9048 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_DES_cipheronly_mb_all),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_DES_docsis_mb_all),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_3DES_cipheronly_mb_all),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_CCM_authenticated_encryption_test_case_128_1),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_AES_CCM_authenticated_decryption_test_case_128_1),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_CCM_authenticated_encryption_test_case_128_2),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_CCM_authenticated_decryption_test_case_128_2),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_CCM_authenticated_encryption_test_case_128_3),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_CCM_authenticated_decryption_test_case_128_3),
9068 TEST_CASES_END() /**< NULL terminate unit test array */
9072 static struct unit_test_suite cryptodev_openssl_testsuite = {
9073 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9074 .setup = testsuite_setup,
9075 .teardown = testsuite_teardown,
9076 .unit_test_cases = {
9077 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_multi_session_random_usage),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_chain_openssl_all),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_cipheronly_openssl_all),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_3DES_chain_openssl_all),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_3DES_cipheronly_openssl_all),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_DES_cipheronly_openssl_all),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_DES_docsis_openssl_all),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_authonly_openssl_all),
9095 /** AES GCM Authenticated Encryption */
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_authenticated_encryption_test_case_1),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_authenticated_encryption_test_case_2),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_authenticated_encryption_test_case_3),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_authenticated_encryption_test_case_4),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_encryption_test_case_5),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_authenticated_encryption_test_case_6),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GCM_authenticated_encryption_test_case_7),
9111 /** AES GCM Authenticated Decryption */
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_GCM_authenticated_decryption_test_case_1),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_AES_GCM_authenticated_decryption_test_case_2),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_authenticated_decryption_test_case_3),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_authenticated_decryption_test_case_4),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_GCM_authenticated_decryption_test_case_5),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GCM_authenticated_decryption_test_case_6),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_GCM_authenticated_decryption_test_case_7),
9128 /** AES GCM Authenticated Encryption 192 bits key */
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_AES_GCM_auth_encryption_test_case_192_1),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_AES_GCM_auth_encryption_test_case_192_2),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_AES_GCM_auth_encryption_test_case_192_3),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_AES_GCM_auth_encryption_test_case_192_4),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_AES_GCM_auth_encryption_test_case_192_5),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_AES_GCM_auth_encryption_test_case_192_6),
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_AES_GCM_auth_encryption_test_case_192_7),
9144 /** AES GCM Authenticated Decryption 192 bits key */
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_AES_GCM_auth_decryption_test_case_192_1),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_AES_GCM_auth_decryption_test_case_192_2),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_AES_GCM_auth_decryption_test_case_192_3),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_AES_GCM_auth_decryption_test_case_192_4),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_AES_GCM_auth_decryption_test_case_192_5),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_AES_GCM_auth_decryption_test_case_192_6),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_AES_GCM_auth_decryption_test_case_192_7),
9160 /** AES GCM Authenticated Encryption 256 bits key */
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_AES_GCM_auth_encryption_test_case_256_1),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_AES_GCM_auth_encryption_test_case_256_2),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_AES_GCM_auth_encryption_test_case_256_3),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_AES_GCM_auth_encryption_test_case_256_4),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_AES_GCM_auth_encryption_test_case_256_5),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_AES_GCM_auth_encryption_test_case_256_6),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_AES_GCM_auth_encryption_test_case_256_7),
9176 /** AES GCM Authenticated Decryption 256 bits key */
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_AES_GCM_auth_decryption_test_case_256_1),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_AES_GCM_auth_decryption_test_case_256_2),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_AES_GCM_auth_decryption_test_case_256_3),
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_AES_GCM_auth_decryption_test_case_256_4),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_GCM_auth_decryption_test_case_256_5),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_AES_GCM_auth_decryption_test_case_256_6),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_AES_GCM_auth_decryption_test_case_256_7),
9192 /** AES GMAC Authentication */
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_GMAC_authentication_test_case_1),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_GMAC_authentication_verify_test_case_1),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_AES_GMAC_authentication_test_case_2),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_AES_GMAC_authentication_verify_test_case_2),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_GMAC_authentication_test_case_3),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_AES_GMAC_authentication_verify_test_case_3),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_AES_GMAC_authentication_test_case_4),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_AES_GMAC_authentication_verify_test_case_4),
9210 /** AES CCM Authenticated Encryption 128 bits key */
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_AES_CCM_authenticated_encryption_test_case_128_1),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_AES_CCM_authenticated_encryption_test_case_128_2),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_AES_CCM_authenticated_encryption_test_case_128_3),
9218 /** AES CCM Authenticated Decryption 128 bits key*/
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_AES_CCM_authenticated_decryption_test_case_128_1),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_AES_CCM_authenticated_decryption_test_case_128_2),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_AES_CCM_authenticated_decryption_test_case_128_3),
9226 /** AES CCM Authenticated Encryption 192 bits key */
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_CCM_authenticated_encryption_test_case_192_1),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_AES_CCM_authenticated_encryption_test_case_192_2),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_CCM_authenticated_encryption_test_case_192_3),
9234 /** AES CCM Authenticated Decryption 192 bits key*/
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_AES_CCM_authenticated_decryption_test_case_192_1),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_AES_CCM_authenticated_decryption_test_case_192_2),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_AES_CCM_authenticated_decryption_test_case_192_3),
9242 /** AES CCM Authenticated Encryption 256 bits key */
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_AES_CCM_authenticated_encryption_test_case_256_1),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_AES_CCM_authenticated_encryption_test_case_256_2),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_AES_CCM_authenticated_encryption_test_case_256_3),
9250 /** AES CCM Authenticated Decryption 256 bits key*/
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_AES_CCM_authenticated_decryption_test_case_256_1),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_CCM_authenticated_decryption_test_case_256_2),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_AES_CCM_authenticated_decryption_test_case_256_3),
9258 /** Scatter-Gather */
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9262 /** Negative tests */
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 authentication_verify_AES128_GMAC_fail_data_corrupt),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9276 TEST_CASES_END() /**< NULL terminate unit test array */
9280 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9281 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9282 .setup = testsuite_setup,
9283 .teardown = testsuite_teardown,
9284 .unit_test_cases = {
9285 /** AES GCM Authenticated Encryption */
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_authenticated_encryption_test_case_1),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_authenticated_encryption_test_case_2),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_authenticated_encryption_test_case_3),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_authenticated_encryption_test_case_4),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_authenticated_encryption_test_case_5),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_AES_GCM_authenticated_encryption_test_case_6),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_authenticated_encryption_test_case_7),
9301 /** AES GCM Authenticated Decryption */
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_authenticated_decryption_test_case_1),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_authenticated_decryption_test_case_2),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_authenticated_decryption_test_case_3),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_authenticated_decryption_test_case_4),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_authenticated_decryption_test_case_5),
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_AES_GCM_authenticated_decryption_test_case_6),
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_authenticated_decryption_test_case_7),
9317 /** AES GCM Authenticated Encryption 192 bits key */
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_encryption_test_case_192_1),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_encryption_test_case_192_2),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_encryption_test_case_192_3),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_encryption_test_case_192_4),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_encryption_test_case_192_5),
9328 TEST_CASE_ST(ut_setup, ut_teardown,
9329 test_AES_GCM_auth_encryption_test_case_192_6),
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_encryption_test_case_192_7),
9333 /** AES GCM Authenticated Decryption 192 bits key */
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_decryption_test_case_192_1),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_auth_decryption_test_case_192_2),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_decryption_test_case_192_3),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_auth_decryption_test_case_192_4),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_auth_decryption_test_case_192_5),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GCM_auth_decryption_test_case_192_6),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_auth_decryption_test_case_192_7),
9349 /** AES GCM Authenticated Encryption 256 bits key */
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_auth_encryption_test_case_256_1),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_auth_encryption_test_case_256_2),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_auth_encryption_test_case_256_3),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_GCM_auth_encryption_test_case_256_4),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_auth_encryption_test_case_256_5),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_GCM_auth_encryption_test_case_256_6),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_auth_encryption_test_case_256_7),
9365 /** AES GCM Authenticated Decryption 256 bits key */
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_auth_decryption_test_case_256_1),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_auth_decryption_test_case_256_2),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_auth_decryption_test_case_256_3),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_AES_GCM_auth_decryption_test_case_256_4),
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GCM_auth_decryption_test_case_256_5),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GCM_auth_decryption_test_case_256_6),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GCM_auth_decryption_test_case_256_7),
9381 /** AES GCM Authenticated Encryption big aad size */
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GCM_auth_encryption_test_case_aad_1),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GCM_auth_encryption_test_case_aad_2),
9387 /** AES GCM Authenticated Decryption big aad size */
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_AES_GCM_auth_decryption_test_case_aad_1),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_GCM_auth_decryption_test_case_aad_2),
9393 /** AES GMAC Authentication */
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GMAC_authentication_test_case_1),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GMAC_authentication_verify_test_case_1),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GMAC_authentication_test_case_3),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GMAC_authentication_verify_test_case_3),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GMAC_authentication_test_case_4),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GMAC_authentication_verify_test_case_4),
9407 /** Negative tests */
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 authentication_verify_AES128_GMAC_fail_data_corrupt),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9413 /** Out of place tests */
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9419 /** Session-less tests */
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9425 /** Scatter-Gather */
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9429 TEST_CASES_END() /**< NULL terminate unit test array */
9433 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9434 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9435 .setup = testsuite_setup,
9436 .teardown = testsuite_teardown,
9437 .unit_test_cases = {
9438 /** KASUMI encrypt only (UEA1) */
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_kasumi_encryption_test_case_1),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_kasumi_encryption_test_case_1_sgl),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_kasumi_encryption_test_case_2),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_kasumi_encryption_test_case_3),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_kasumi_encryption_test_case_4),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_kasumi_encryption_test_case_5),
9451 /** KASUMI decrypt only (UEA1) */
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_kasumi_decryption_test_case_1),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_kasumi_decryption_test_case_2),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_kasumi_decryption_test_case_3),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_kasumi_decryption_test_case_4),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_kasumi_decryption_test_case_5),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_kasumi_encryption_test_case_1_oop),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_kasumi_encryption_test_case_1_oop_sgl),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_kasumi_decryption_test_case_1_oop),
9472 /** KASUMI hash only (UIA1) */
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_kasumi_hash_generate_test_case_1),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_kasumi_hash_generate_test_case_2),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_kasumi_hash_generate_test_case_3),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_kasumi_hash_generate_test_case_4),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_kasumi_hash_generate_test_case_5),
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_kasumi_hash_generate_test_case_6),
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_kasumi_hash_verify_test_case_1),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_kasumi_hash_verify_test_case_2),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_kasumi_hash_verify_test_case_3),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_kasumi_hash_verify_test_case_4),
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_kasumi_hash_verify_test_case_5),
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_kasumi_auth_cipher_test_case_1),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_kasumi_cipher_auth_test_case_1),
9499 TEST_CASES_END() /**< NULL terminate unit test array */
9502 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9503 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9504 .setup = testsuite_setup,
9505 .teardown = testsuite_teardown,
9506 .unit_test_cases = {
9507 /** SNOW 3G encrypt only (UEA2) */
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_snow3g_encryption_test_case_1),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_snow3g_encryption_test_case_2),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_snow3g_encryption_test_case_3),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_encryption_test_case_4),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_encryption_test_case_5),
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_snow3g_encryption_test_case_1_oop),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_snow3g_encryption_test_case_1_oop_sgl),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_snow3g_decryption_test_case_1_oop),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_snow3g_encryption_test_case_1_offset_oop),
9529 /** SNOW 3G decrypt only (UEA2) */
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_snow3g_decryption_test_case_1),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_snow3g_decryption_test_case_2),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_snow3g_decryption_test_case_3),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_snow3g_decryption_test_case_4),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_snow3g_decryption_test_case_5),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_snow3g_hash_generate_test_case_1),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_snow3g_hash_generate_test_case_2),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_snow3g_hash_generate_test_case_3),
9546 /* Tests with buffers which length is not byte-aligned */
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_snow3g_hash_generate_test_case_4),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_snow3g_hash_generate_test_case_5),
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_snow3g_hash_generate_test_case_6),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_snow3g_hash_verify_test_case_1),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_snow3g_hash_verify_test_case_2),
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 test_snow3g_hash_verify_test_case_3),
9559 /* Tests with buffers which length is not byte-aligned */
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_snow3g_hash_verify_test_case_4),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_snow3g_hash_verify_test_case_5),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_snow3g_hash_verify_test_case_6),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_snow3g_cipher_auth_test_case_1),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_snow3g_auth_cipher_test_case_1),
9571 TEST_CASES_END() /**< NULL terminate unit test array */
9575 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9576 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9577 .setup = testsuite_setup,
9578 .teardown = testsuite_teardown,
9579 .unit_test_cases = {
9580 /** ZUC encrypt only (EEA3) */
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_zuc_encryption_test_case_1),
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_zuc_encryption_test_case_2),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_zuc_encryption_test_case_3),
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_zuc_encryption_test_case_4),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_zuc_encryption_test_case_5),
9591 TEST_CASE_ST(ut_setup, ut_teardown,
9592 test_zuc_hash_generate_test_case_1),
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_zuc_hash_generate_test_case_2),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_zuc_hash_generate_test_case_3),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_zuc_hash_generate_test_case_4),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_zuc_hash_generate_test_case_5),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_zuc_encryption_test_case_6_sgl),
9603 TEST_CASES_END() /**< NULL terminate unit test array */
9607 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9608 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9609 .setup = testsuite_setup,
9610 .teardown = testsuite_teardown,
9611 .unit_test_cases = {
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_device_configure_invalid_dev_id),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_multi_session),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_chain_dpaa_sec_all),
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_3DES_chain_dpaa_sec_all),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_cipheronly_dpaa_sec_all),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 test_3DES_cipheronly_dpaa_sec_all),
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_authonly_dpaa_sec_all),
9628 /** AES GCM Authenticated Encryption */
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_authenticated_encryption_test_case_1),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_authenticated_encryption_test_case_2),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_authenticated_encryption_test_case_3),
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_authenticated_encryption_test_case_4),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_authenticated_encryption_test_case_5),
9639 TEST_CASE_ST(ut_setup, ut_teardown,
9640 test_AES_GCM_authenticated_encryption_test_case_6),
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_authenticated_encryption_test_case_7),
9644 /** AES GCM Authenticated Decryption */
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_authenticated_decryption_test_case_1),
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_authenticated_decryption_test_case_2),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_authenticated_decryption_test_case_3),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_authenticated_decryption_test_case_4),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_authenticated_decryption_test_case_5),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_authenticated_decryption_test_case_6),
9657 TEST_CASE_ST(ut_setup, ut_teardown,
9658 test_AES_GCM_authenticated_decryption_test_case_7),
9660 /** AES GCM Authenticated Encryption 256 bits key */
9661 TEST_CASE_ST(ut_setup, ut_teardown,
9662 test_AES_GCM_auth_encryption_test_case_256_1),
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_auth_encryption_test_case_256_2),
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_AES_GCM_auth_encryption_test_case_256_3),
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_AES_GCM_auth_encryption_test_case_256_4),
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_auth_encryption_test_case_256_5),
9671 TEST_CASE_ST(ut_setup, ut_teardown,
9672 test_AES_GCM_auth_encryption_test_case_256_6),
9673 TEST_CASE_ST(ut_setup, ut_teardown,
9674 test_AES_GCM_auth_encryption_test_case_256_7),
9676 /** AES GCM Authenticated Decryption 256 bits key */
9677 TEST_CASE_ST(ut_setup, ut_teardown,
9678 test_AES_GCM_auth_decryption_test_case_256_1),
9679 TEST_CASE_ST(ut_setup, ut_teardown,
9680 test_AES_GCM_auth_decryption_test_case_256_2),
9681 TEST_CASE_ST(ut_setup, ut_teardown,
9682 test_AES_GCM_auth_decryption_test_case_256_3),
9683 TEST_CASE_ST(ut_setup, ut_teardown,
9684 test_AES_GCM_auth_decryption_test_case_256_4),
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GCM_auth_decryption_test_case_256_5),
9687 TEST_CASE_ST(ut_setup, ut_teardown,
9688 test_AES_GCM_auth_decryption_test_case_256_6),
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_AES_GCM_auth_decryption_test_case_256_7),
9692 /** Out of place tests */
9693 TEST_CASE_ST(ut_setup, ut_teardown,
9694 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9698 /** Scatter-Gather */
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9708 TEST_CASES_END() /**< NULL terminate unit test array */
9712 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9713 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9714 .setup = testsuite_setup,
9715 .teardown = testsuite_teardown,
9716 .unit_test_cases = {
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_device_configure_invalid_dev_id),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_multi_session),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_chain_dpaa2_sec_all),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_3DES_chain_dpaa2_sec_all),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_cipheronly_dpaa2_sec_all),
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_3DES_cipheronly_dpaa2_sec_all),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_authonly_dpaa2_sec_all),
9733 /** AES GCM Authenticated Encryption */
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_authenticated_encryption_test_case_1),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_authenticated_encryption_test_case_2),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_AES_GCM_authenticated_encryption_test_case_3),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_AES_GCM_authenticated_encryption_test_case_4),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_AES_GCM_authenticated_encryption_test_case_5),
9744 TEST_CASE_ST(ut_setup, ut_teardown,
9745 test_AES_GCM_authenticated_encryption_test_case_6),
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_AES_GCM_authenticated_encryption_test_case_7),
9749 /** AES GCM Authenticated Decryption */
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_AES_GCM_authenticated_decryption_test_case_1),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GCM_authenticated_decryption_test_case_2),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GCM_authenticated_decryption_test_case_3),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GCM_authenticated_decryption_test_case_4),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GCM_authenticated_decryption_test_case_5),
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_AES_GCM_authenticated_decryption_test_case_6),
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_GCM_authenticated_decryption_test_case_7),
9765 /** AES GCM Authenticated Encryption 192 bits key */
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_AES_GCM_auth_encryption_test_case_192_1),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_AES_GCM_auth_encryption_test_case_192_2),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_AES_GCM_auth_encryption_test_case_192_3),
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_auth_encryption_test_case_192_4),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_auth_encryption_test_case_192_5),
9776 TEST_CASE_ST(ut_setup, ut_teardown,
9777 test_AES_GCM_auth_encryption_test_case_192_6),
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 test_AES_GCM_auth_encryption_test_case_192_7),
9781 /** AES GCM Authenticated Decryption 192 bits key */
9782 TEST_CASE_ST(ut_setup, ut_teardown,
9783 test_AES_GCM_auth_decryption_test_case_192_1),
9784 TEST_CASE_ST(ut_setup, ut_teardown,
9785 test_AES_GCM_auth_decryption_test_case_192_2),
9786 TEST_CASE_ST(ut_setup, ut_teardown,
9787 test_AES_GCM_auth_decryption_test_case_192_3),
9788 TEST_CASE_ST(ut_setup, ut_teardown,
9789 test_AES_GCM_auth_decryption_test_case_192_4),
9790 TEST_CASE_ST(ut_setup, ut_teardown,
9791 test_AES_GCM_auth_decryption_test_case_192_5),
9792 TEST_CASE_ST(ut_setup, ut_teardown,
9793 test_AES_GCM_auth_decryption_test_case_192_6),
9794 TEST_CASE_ST(ut_setup, ut_teardown,
9795 test_AES_GCM_auth_decryption_test_case_192_7),
9797 /** AES GCM Authenticated Encryption 256 bits key */
9798 TEST_CASE_ST(ut_setup, ut_teardown,
9799 test_AES_GCM_auth_encryption_test_case_256_1),
9800 TEST_CASE_ST(ut_setup, ut_teardown,
9801 test_AES_GCM_auth_encryption_test_case_256_2),
9802 TEST_CASE_ST(ut_setup, ut_teardown,
9803 test_AES_GCM_auth_encryption_test_case_256_3),
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_AES_GCM_auth_encryption_test_case_256_4),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_AES_GCM_auth_encryption_test_case_256_5),
9808 TEST_CASE_ST(ut_setup, ut_teardown,
9809 test_AES_GCM_auth_encryption_test_case_256_6),
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_AES_GCM_auth_encryption_test_case_256_7),
9813 /** AES GCM Authenticated Decryption 256 bits key */
9814 TEST_CASE_ST(ut_setup, ut_teardown,
9815 test_AES_GCM_auth_decryption_test_case_256_1),
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 test_AES_GCM_auth_decryption_test_case_256_2),
9818 TEST_CASE_ST(ut_setup, ut_teardown,
9819 test_AES_GCM_auth_decryption_test_case_256_3),
9820 TEST_CASE_ST(ut_setup, ut_teardown,
9821 test_AES_GCM_auth_decryption_test_case_256_4),
9822 TEST_CASE_ST(ut_setup, ut_teardown,
9823 test_AES_GCM_auth_decryption_test_case_256_5),
9824 TEST_CASE_ST(ut_setup, ut_teardown,
9825 test_AES_GCM_auth_decryption_test_case_256_6),
9826 TEST_CASE_ST(ut_setup, ut_teardown,
9827 test_AES_GCM_auth_decryption_test_case_256_7),
9829 /** Out of place tests */
9830 TEST_CASE_ST(ut_setup, ut_teardown,
9831 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9832 TEST_CASE_ST(ut_setup, ut_teardown,
9833 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9835 /** Scatter-Gather */
9836 TEST_CASE_ST(ut_setup, ut_teardown,
9837 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9838 TEST_CASE_ST(ut_setup, ut_teardown,
9839 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9840 TEST_CASE_ST(ut_setup, ut_teardown,
9841 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9845 TEST_CASES_END() /**< NULL terminate unit test array */
9849 static struct unit_test_suite cryptodev_null_testsuite = {
9850 .suite_name = "Crypto Device NULL Unit Test Suite",
9851 .setup = testsuite_setup,
9852 .teardown = testsuite_teardown,
9853 .unit_test_cases = {
9854 TEST_CASE_ST(ut_setup, ut_teardown,
9855 test_null_auth_only_operation),
9856 TEST_CASE_ST(ut_setup, ut_teardown,
9857 test_null_cipher_only_operation),
9858 TEST_CASE_ST(ut_setup, ut_teardown,
9859 test_null_cipher_auth_operation),
9860 TEST_CASE_ST(ut_setup, ut_teardown,
9861 test_null_auth_cipher_operation),
9862 TEST_CASE_ST(ut_setup, ut_teardown,
9863 test_null_invalid_operation),
9864 TEST_CASE_ST(ut_setup, ut_teardown,
9865 test_null_burst_operation),
9867 TEST_CASES_END() /**< NULL terminate unit test array */
9871 static struct unit_test_suite cryptodev_armv8_testsuite = {
9872 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9873 .setup = testsuite_setup,
9874 .teardown = testsuite_teardown,
9875 .unit_test_cases = {
9876 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9878 /** Negative tests */
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9884 TEST_CASES_END() /**< NULL terminate unit test array */
9888 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9889 .suite_name = "Crypto Device Marvell Component Test Suite",
9890 .setup = testsuite_setup,
9891 .teardown = testsuite_teardown,
9892 .unit_test_cases = {
9893 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 test_multi_session_random_usage),
9896 TEST_CASE_ST(ut_setup, ut_teardown,
9897 test_AES_chain_mrvl_all),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_AES_cipheronly_mrvl_all),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_authonly_mrvl_all),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_3DES_chain_mrvl_all),
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_3DES_cipheronly_mrvl_all),
9907 /** Negative tests */
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9914 TEST_CASE_ST(ut_setup, ut_teardown,
9915 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9917 TEST_CASES_END() /**< NULL terminate unit test array */
9921 static struct unit_test_suite cryptodev_ccp_testsuite = {
9922 .suite_name = "Crypto Device CCP Unit Test Suite",
9923 .setup = testsuite_setup,
9924 .teardown = testsuite_teardown,
9925 .unit_test_cases = {
9926 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9927 TEST_CASE_ST(ut_setup, ut_teardown,
9928 test_multi_session_random_usage),
9929 TEST_CASE_ST(ut_setup, ut_teardown,
9930 test_AES_chain_ccp_all),
9931 TEST_CASE_ST(ut_setup, ut_teardown,
9932 test_AES_cipheronly_ccp_all),
9933 TEST_CASE_ST(ut_setup, ut_teardown,
9934 test_3DES_chain_ccp_all),
9935 TEST_CASE_ST(ut_setup, ut_teardown,
9936 test_3DES_cipheronly_ccp_all),
9937 TEST_CASE_ST(ut_setup, ut_teardown,
9938 test_authonly_ccp_all),
9940 /** Negative tests */
9941 TEST_CASE_ST(ut_setup, ut_teardown,
9942 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9943 TEST_CASE_ST(ut_setup, ut_teardown,
9944 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9945 TEST_CASE_ST(ut_setup, ut_teardown,
9946 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9947 TEST_CASE_ST(ut_setup, ut_teardown,
9948 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9950 TEST_CASES_END() /**< NULL terminate unit test array */
9955 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9957 gbl_driver_id = rte_cryptodev_driver_id_get(
9958 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9960 if (gbl_driver_id == -1) {
9961 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
9962 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
9963 "are enabled in config file to run this testsuite.\n");
9964 return TEST_SKIPPED;
9967 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9971 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9973 gbl_driver_id = rte_cryptodev_driver_id_get(
9974 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9976 if (gbl_driver_id == -1) {
9977 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9978 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9979 "in config file to run this testsuite.\n");
9983 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9987 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9989 gbl_driver_id = rte_cryptodev_driver_id_get(
9990 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9992 if (gbl_driver_id == -1) {
9993 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9994 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9995 "in config file to run this testsuite.\n");
9996 return TEST_SKIPPED;
9999 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10003 test_cryptodev_openssl(void)
10005 gbl_driver_id = rte_cryptodev_driver_id_get(
10006 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10008 if (gbl_driver_id == -1) {
10009 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10010 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10011 "in config file to run this testsuite.\n");
10012 return TEST_SKIPPED;
10015 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10019 test_cryptodev_aesni_gcm(void)
10021 gbl_driver_id = rte_cryptodev_driver_id_get(
10022 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10024 if (gbl_driver_id == -1) {
10025 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10026 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10027 "in config file to run this testsuite.\n");
10028 return TEST_SKIPPED;
10031 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10035 test_cryptodev_null(void)
10037 gbl_driver_id = rte_cryptodev_driver_id_get(
10038 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10040 if (gbl_driver_id == -1) {
10041 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10042 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10043 "in config file to run this testsuite.\n");
10044 return TEST_SKIPPED;
10047 return unit_test_suite_runner(&cryptodev_null_testsuite);
10051 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10053 gbl_driver_id = rte_cryptodev_driver_id_get(
10054 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10056 if (gbl_driver_id == -1) {
10057 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10058 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10059 "in config file to run this testsuite.\n");
10060 return TEST_SKIPPED;
10063 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10067 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10069 gbl_driver_id = rte_cryptodev_driver_id_get(
10070 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10072 if (gbl_driver_id == -1) {
10073 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10074 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10075 "in config file to run this testsuite.\n");
10076 return TEST_SKIPPED;
10079 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10083 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10085 gbl_driver_id = rte_cryptodev_driver_id_get(
10086 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10088 if (gbl_driver_id == -1) {
10089 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10090 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10091 "in config file to run this testsuite.\n");
10092 return TEST_SKIPPED;
10095 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10099 test_cryptodev_armv8(void)
10101 gbl_driver_id = rte_cryptodev_driver_id_get(
10102 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10104 if (gbl_driver_id == -1) {
10105 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10106 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10107 "in config file to run this testsuite.\n");
10108 return TEST_SKIPPED;
10111 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10115 test_cryptodev_mrvl(void)
10117 gbl_driver_id = rte_cryptodev_driver_id_get(
10118 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10120 if (gbl_driver_id == -1) {
10121 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10122 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10123 "in config file to run this testsuite.\n");
10124 return TEST_SKIPPED;
10127 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10130 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10133 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10135 gbl_driver_id = rte_cryptodev_driver_id_get(
10136 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10138 if (gbl_driver_id == -1) {
10139 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10140 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10141 "in config file to run this testsuite.\n");
10142 return TEST_SKIPPED;
10145 if (rte_cryptodev_driver_id_get(
10146 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10147 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10148 " enabled in config file to run this testsuite.\n");
10149 return TEST_SKIPPED;
10151 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10154 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10159 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10161 gbl_driver_id = rte_cryptodev_driver_id_get(
10162 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10164 if (gbl_driver_id == -1) {
10165 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10166 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10167 "in config file to run this testsuite.\n");
10168 return TEST_SKIPPED;
10171 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10175 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10177 gbl_driver_id = rte_cryptodev_driver_id_get(
10178 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10180 if (gbl_driver_id == -1) {
10181 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10182 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10183 "in config file to run this testsuite.\n");
10184 return TEST_SKIPPED;
10187 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10191 test_cryptodev_ccp(void)
10193 gbl_driver_id = rte_cryptodev_driver_id_get(
10194 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10196 if (gbl_driver_id == -1) {
10197 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10198 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10199 "in config file to run this testsuite.\n");
10200 return TEST_FAILED;
10203 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10206 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10207 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10208 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10209 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10210 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10211 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10212 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10213 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10214 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10215 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10216 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10217 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10218 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10219 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);