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 = MAX_NUM_QPS_PER_QAT_DEVICE;
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 = MAX_NUM_QPS_PER_QAT_DEVICE + 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 = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*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);
3163 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3164 printf("Device doesn't support scatter-gather. "
3169 /* Create KASUMI session */
3170 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3171 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3172 RTE_CRYPTO_CIPHER_KASUMI_F8,
3173 tdata->key.data, tdata->key.len,
3174 tdata->cipher_iv.len);
3178 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3181 /* Append data which is padded to a multiple */
3182 /* of the algorithms block size */
3183 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3185 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3186 plaintext_pad_len, 10, 0);
3188 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3190 /* Create KASUMI operation */
3191 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3192 tdata->cipher_iv.len,
3193 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3194 tdata->validCipherOffsetInBits.len);
3198 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3200 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3202 ut_params->obuf = ut_params->op->sym->m_dst;
3204 if (ut_params->obuf)
3205 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3206 plaintext_len, buffer);
3208 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3209 tdata->validCipherOffsetInBits.len >> 3,
3210 plaintext_len, buffer);
3213 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3215 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3216 (tdata->validCipherOffsetInBits.len >> 3);
3218 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3220 reference_ciphertext,
3221 tdata->validCipherLenInBits.len,
3222 "KASUMI Ciphertext data not as expected");
3227 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3229 struct crypto_testsuite_params *ts_params = &testsuite_params;
3230 struct crypto_unittest_params *ut_params = &unittest_params;
3233 uint8_t *plaintext, *ciphertext;
3234 unsigned plaintext_pad_len;
3235 unsigned plaintext_len;
3237 /* Create KASUMI session */
3238 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3239 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3240 RTE_CRYPTO_CIPHER_KASUMI_F8,
3241 tdata->key.data, tdata->key.len,
3242 tdata->cipher_iv.len);
3246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3247 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3249 /* Clear mbuf payload */
3250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3251 rte_pktmbuf_tailroom(ut_params->ibuf));
3253 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3254 /* Append data which is padded to a multiple */
3255 /* of the algorithms block size */
3256 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3259 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3262 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3264 /* Create KASUMI operation */
3265 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3266 tdata->cipher_iv.len,
3267 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3268 tdata->validCipherOffsetInBits.len);
3272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3276 ut_params->obuf = ut_params->op->sym->m_dst;
3277 if (ut_params->obuf)
3278 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3280 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3282 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3284 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3285 (tdata->validCipherOffsetInBits.len >> 3);
3287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3289 reference_ciphertext,
3290 tdata->validCipherLenInBits.len,
3291 "KASUMI Ciphertext data not as expected");
3296 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3298 struct crypto_testsuite_params *ts_params = &testsuite_params;
3299 struct crypto_unittest_params *ut_params = &unittest_params;
3302 unsigned int plaintext_pad_len;
3303 unsigned int plaintext_len;
3305 const uint8_t *ciphertext;
3306 uint8_t buffer[2048];
3308 struct rte_cryptodev_info dev_info;
3310 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3311 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3312 printf("Device doesn't support scatter-gather. "
3317 /* Create KASUMI session */
3318 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3319 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3320 RTE_CRYPTO_CIPHER_KASUMI_F8,
3321 tdata->key.data, tdata->key.len,
3322 tdata->cipher_iv.len);
3326 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3327 /* Append data which is padded to a multiple */
3328 /* of the algorithms block size */
3329 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3331 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3332 plaintext_pad_len, 10, 0);
3333 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3334 plaintext_pad_len, 3, 0);
3336 /* Append data which is padded to a multiple */
3337 /* of the algorithms block size */
3338 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3340 /* Create KASUMI operation */
3341 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3342 tdata->cipher_iv.len,
3343 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3344 tdata->validCipherOffsetInBits.len);
3348 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3350 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3352 ut_params->obuf = ut_params->op->sym->m_dst;
3353 if (ut_params->obuf)
3354 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3355 plaintext_pad_len, buffer);
3357 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3358 tdata->validCipherOffsetInBits.len >> 3,
3359 plaintext_pad_len, buffer);
3361 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3362 (tdata->validCipherOffsetInBits.len >> 3);
3364 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3366 reference_ciphertext,
3367 tdata->validCipherLenInBits.len,
3368 "KASUMI Ciphertext data not as expected");
3374 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3376 struct crypto_testsuite_params *ts_params = &testsuite_params;
3377 struct crypto_unittest_params *ut_params = &unittest_params;
3380 uint8_t *ciphertext, *plaintext;
3381 unsigned ciphertext_pad_len;
3382 unsigned ciphertext_len;
3384 /* Create KASUMI session */
3385 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3386 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3387 RTE_CRYPTO_CIPHER_KASUMI_F8,
3388 tdata->key.data, tdata->key.len,
3389 tdata->cipher_iv.len);
3393 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3394 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3396 /* Clear mbuf payload */
3397 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3398 rte_pktmbuf_tailroom(ut_params->ibuf));
3400 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3401 /* Append data which is padded to a multiple */
3402 /* of the algorithms block size */
3403 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3404 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3405 ciphertext_pad_len);
3406 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3407 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3409 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3411 /* Create KASUMI operation */
3412 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3413 tdata->cipher_iv.len,
3414 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3415 tdata->validCipherOffsetInBits.len);
3419 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3421 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3423 ut_params->obuf = ut_params->op->sym->m_dst;
3424 if (ut_params->obuf)
3425 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3427 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3429 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3431 const uint8_t *reference_plaintext = tdata->plaintext.data +
3432 (tdata->validCipherOffsetInBits.len >> 3);
3434 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3436 reference_plaintext,
3437 tdata->validCipherLenInBits.len,
3438 "KASUMI Plaintext data not as expected");
3443 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3445 struct crypto_testsuite_params *ts_params = &testsuite_params;
3446 struct crypto_unittest_params *ut_params = &unittest_params;
3449 uint8_t *ciphertext, *plaintext;
3450 unsigned ciphertext_pad_len;
3451 unsigned ciphertext_len;
3453 /* Create KASUMI session */
3454 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3455 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3456 RTE_CRYPTO_CIPHER_KASUMI_F8,
3457 tdata->key.data, tdata->key.len,
3458 tdata->cipher_iv.len);
3462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3464 /* Clear mbuf payload */
3465 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3466 rte_pktmbuf_tailroom(ut_params->ibuf));
3468 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3469 /* Append data which is padded to a multiple */
3470 /* of the algorithms block size */
3471 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3472 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3473 ciphertext_pad_len);
3474 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3476 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3478 /* Create KASUMI operation */
3479 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3480 tdata->cipher_iv.len,
3481 tdata->ciphertext.len,
3482 tdata->validCipherOffsetInBits.len);
3486 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3488 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3490 ut_params->obuf = ut_params->op->sym->m_dst;
3491 if (ut_params->obuf)
3492 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3494 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3496 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3498 const uint8_t *reference_plaintext = tdata->plaintext.data +
3499 (tdata->validCipherOffsetInBits.len >> 3);
3501 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3503 reference_plaintext,
3504 tdata->validCipherLenInBits.len,
3505 "KASUMI Plaintext data not as expected");
3510 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3512 struct crypto_testsuite_params *ts_params = &testsuite_params;
3513 struct crypto_unittest_params *ut_params = &unittest_params;
3516 uint8_t *plaintext, *ciphertext;
3517 unsigned plaintext_pad_len;
3518 unsigned plaintext_len;
3520 /* Create SNOW 3G session */
3521 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3522 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3523 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3524 tdata->key.data, tdata->key.len,
3525 tdata->cipher_iv.len);
3529 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3531 /* Clear mbuf payload */
3532 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3533 rte_pktmbuf_tailroom(ut_params->ibuf));
3535 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3536 /* Append data which is padded to a multiple of */
3537 /* the algorithms block size */
3538 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3539 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3541 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3543 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3545 /* Create SNOW 3G operation */
3546 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3547 tdata->cipher_iv.len,
3548 tdata->validCipherLenInBits.len,
3553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3557 ut_params->obuf = ut_params->op->sym->m_dst;
3558 if (ut_params->obuf)
3559 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3561 ciphertext = plaintext;
3563 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3566 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3568 tdata->ciphertext.data,
3569 tdata->validDataLenInBits.len,
3570 "SNOW 3G Ciphertext data not as expected");
3576 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3578 struct crypto_testsuite_params *ts_params = &testsuite_params;
3579 struct crypto_unittest_params *ut_params = &unittest_params;
3580 uint8_t *plaintext, *ciphertext;
3583 unsigned plaintext_pad_len;
3584 unsigned plaintext_len;
3586 /* Create SNOW 3G session */
3587 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3588 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3589 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3590 tdata->key.data, tdata->key.len,
3591 tdata->cipher_iv.len);
3595 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3596 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3598 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3599 "Failed to allocate input buffer in mempool");
3600 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3601 "Failed to allocate output buffer in mempool");
3603 /* Clear mbuf payload */
3604 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3605 rte_pktmbuf_tailroom(ut_params->ibuf));
3607 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3608 /* Append data which is padded to a multiple of */
3609 /* the algorithms block size */
3610 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3611 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3613 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3614 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3616 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3618 /* Create SNOW 3G operation */
3619 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3620 tdata->cipher_iv.len,
3621 tdata->validCipherLenInBits.len,
3626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3630 ut_params->obuf = ut_params->op->sym->m_dst;
3631 if (ut_params->obuf)
3632 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3634 ciphertext = plaintext;
3636 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3639 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3641 tdata->ciphertext.data,
3642 tdata->validDataLenInBits.len,
3643 "SNOW 3G Ciphertext data not as expected");
3648 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3650 struct crypto_testsuite_params *ts_params = &testsuite_params;
3651 struct crypto_unittest_params *ut_params = &unittest_params;
3654 unsigned int plaintext_pad_len;
3655 unsigned int plaintext_len;
3656 uint8_t buffer[10000];
3657 const uint8_t *ciphertext;
3659 struct rte_cryptodev_info dev_info;
3661 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3662 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3663 printf("Device doesn't support scatter-gather. "
3668 /* Create SNOW 3G session */
3669 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3670 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3671 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3672 tdata->key.data, tdata->key.len,
3673 tdata->cipher_iv.len);
3677 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3678 /* Append data which is padded to a multiple of */
3679 /* the algorithms block size */
3680 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3682 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3683 plaintext_pad_len, 10, 0);
3684 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3685 plaintext_pad_len, 3, 0);
3687 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3688 "Failed to allocate input buffer in mempool");
3689 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3690 "Failed to allocate output buffer in mempool");
3692 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3694 /* Create SNOW 3G operation */
3695 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3696 tdata->cipher_iv.len,
3697 tdata->validCipherLenInBits.len,
3702 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3704 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3706 ut_params->obuf = ut_params->op->sym->m_dst;
3707 if (ut_params->obuf)
3708 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3709 plaintext_len, buffer);
3711 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3712 plaintext_len, buffer);
3714 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3717 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3719 tdata->ciphertext.data,
3720 tdata->validDataLenInBits.len,
3721 "SNOW 3G Ciphertext data not as expected");
3726 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3728 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3730 uint8_t curr_byte, prev_byte;
3731 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3732 uint8_t lower_byte_mask = (1 << offset) - 1;
3735 prev_byte = buffer[0];
3736 buffer[0] >>= offset;
3738 for (i = 1; i < length_in_bytes; i++) {
3739 curr_byte = buffer[i];
3740 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3741 (curr_byte >> offset);
3742 prev_byte = curr_byte;
3747 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3749 struct crypto_testsuite_params *ts_params = &testsuite_params;
3750 struct crypto_unittest_params *ut_params = &unittest_params;
3751 uint8_t *plaintext, *ciphertext;
3753 uint32_t plaintext_len;
3754 uint32_t plaintext_pad_len;
3755 uint8_t extra_offset = 4;
3756 uint8_t *expected_ciphertext_shifted;
3758 /* Create SNOW 3G session */
3759 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3760 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3761 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3762 tdata->key.data, tdata->key.len,
3763 tdata->cipher_iv.len);
3767 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3768 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3770 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3771 "Failed to allocate input buffer in mempool");
3772 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3773 "Failed to allocate output buffer in mempool");
3775 /* Clear mbuf payload */
3776 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3777 rte_pktmbuf_tailroom(ut_params->ibuf));
3779 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3781 * Append data which is padded to a
3782 * multiple of the algorithms block size
3784 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3786 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3789 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3791 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3792 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3794 #ifdef RTE_APP_TEST_DEBUG
3795 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3797 /* Create SNOW 3G operation */
3798 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3799 tdata->cipher_iv.len,
3800 tdata->validCipherLenInBits.len,
3805 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3807 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3809 ut_params->obuf = ut_params->op->sym->m_dst;
3810 if (ut_params->obuf)
3811 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3813 ciphertext = plaintext;
3815 #ifdef RTE_APP_TEST_DEBUG
3816 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3819 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3821 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3822 "failed to reserve memory for ciphertext shifted\n");
3824 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3825 ceil_byte_length(tdata->ciphertext.len));
3826 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3829 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3831 expected_ciphertext_shifted,
3832 tdata->validDataLenInBits.len,
3834 "SNOW 3G Ciphertext data not as expected");
3838 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3840 struct crypto_testsuite_params *ts_params = &testsuite_params;
3841 struct crypto_unittest_params *ut_params = &unittest_params;
3845 uint8_t *plaintext, *ciphertext;
3846 unsigned ciphertext_pad_len;
3847 unsigned ciphertext_len;
3849 /* Create SNOW 3G session */
3850 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3851 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3852 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3853 tdata->key.data, tdata->key.len,
3854 tdata->cipher_iv.len);
3858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3860 /* Clear mbuf payload */
3861 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3862 rte_pktmbuf_tailroom(ut_params->ibuf));
3864 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3865 /* Append data which is padded to a multiple of */
3866 /* the algorithms block size */
3867 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3868 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3869 ciphertext_pad_len);
3870 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3874 /* Create SNOW 3G operation */
3875 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3876 tdata->cipher_iv.len,
3877 tdata->validCipherLenInBits.len,
3882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3885 ut_params->obuf = ut_params->op->sym->m_dst;
3886 if (ut_params->obuf)
3887 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3889 plaintext = ciphertext;
3891 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3895 tdata->plaintext.data,
3896 tdata->validDataLenInBits.len,
3897 "SNOW 3G Plaintext data not as expected");
3901 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3903 struct crypto_testsuite_params *ts_params = &testsuite_params;
3904 struct crypto_unittest_params *ut_params = &unittest_params;
3908 uint8_t *plaintext, *ciphertext;
3909 unsigned ciphertext_pad_len;
3910 unsigned ciphertext_len;
3912 /* Create SNOW 3G session */
3913 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3914 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3915 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3916 tdata->key.data, tdata->key.len,
3917 tdata->cipher_iv.len);
3921 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3922 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3924 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3925 "Failed to allocate input buffer");
3926 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3927 "Failed to allocate output buffer");
3929 /* Clear mbuf payload */
3930 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3931 rte_pktmbuf_tailroom(ut_params->ibuf));
3933 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3934 rte_pktmbuf_tailroom(ut_params->obuf));
3936 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3937 /* Append data which is padded to a multiple of */
3938 /* the algorithms block size */
3939 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3940 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3941 ciphertext_pad_len);
3942 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3943 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3945 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3947 /* Create SNOW 3G operation */
3948 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3949 tdata->cipher_iv.len,
3950 tdata->validCipherLenInBits.len,
3955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3957 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3958 ut_params->obuf = ut_params->op->sym->m_dst;
3959 if (ut_params->obuf)
3960 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3962 plaintext = ciphertext;
3964 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3967 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3968 tdata->plaintext.data,
3969 tdata->validDataLenInBits.len,
3970 "SNOW 3G Plaintext data not as expected");
3975 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3977 struct crypto_testsuite_params *ts_params = &testsuite_params;
3978 struct crypto_unittest_params *ut_params = &unittest_params;
3982 uint8_t *plaintext, *ciphertext;
3983 unsigned int plaintext_pad_len;
3984 unsigned int plaintext_len;
3986 struct rte_cryptodev_sym_capability_idx cap_idx;
3988 /* Check if device supports ZUC EEA3 */
3989 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3990 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3992 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3996 /* Check if device supports ZUC EIA3 */
3997 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3998 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4004 /* Create ZUC session */
4005 retval = create_zuc_cipher_auth_encrypt_generate_session(
4006 ts_params->valid_devs[0],
4010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4012 /* clear mbuf payload */
4013 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4014 rte_pktmbuf_tailroom(ut_params->ibuf));
4016 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4017 /* Append data which is padded to a multiple of */
4018 /* the algorithms block size */
4019 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4020 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4022 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4024 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4026 /* Create ZUC operation */
4027 retval = create_zuc_cipher_hash_generate_operation(tdata);
4031 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4033 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4034 ut_params->obuf = ut_params->op->sym->m_src;
4035 if (ut_params->obuf)
4036 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4038 ciphertext = plaintext;
4040 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4042 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4044 tdata->ciphertext.data,
4045 tdata->validDataLenInBits.len,
4046 "ZUC Ciphertext data not as expected");
4048 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4049 + plaintext_pad_len;
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4056 "ZUC Generated auth tag not as expected");
4061 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4063 struct crypto_testsuite_params *ts_params = &testsuite_params;
4064 struct crypto_unittest_params *ut_params = &unittest_params;
4068 uint8_t *plaintext, *ciphertext;
4069 unsigned plaintext_pad_len;
4070 unsigned plaintext_len;
4072 /* Create SNOW 3G session */
4073 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4074 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4075 RTE_CRYPTO_AUTH_OP_GENERATE,
4076 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4077 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4078 tdata->key.data, tdata->key.len,
4079 tdata->auth_iv.len, tdata->digest.len,
4080 tdata->cipher_iv.len);
4083 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4085 /* clear mbuf payload */
4086 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4087 rte_pktmbuf_tailroom(ut_params->ibuf));
4089 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4090 /* Append data which is padded to a multiple of */
4091 /* the algorithms block size */
4092 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4093 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4095 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4097 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4099 /* Create SNOW 3G operation */
4100 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4101 tdata->digest.len, tdata->auth_iv.data,
4103 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4104 tdata->cipher_iv.data, tdata->cipher_iv.len,
4105 tdata->validCipherLenInBits.len,
4107 tdata->validAuthLenInBits.len,
4113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4116 ut_params->obuf = ut_params->op->sym->m_src;
4117 if (ut_params->obuf)
4118 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4120 ciphertext = plaintext;
4122 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4124 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4126 tdata->ciphertext.data,
4127 tdata->validDataLenInBits.len,
4128 "SNOW 3G Ciphertext data not as expected");
4130 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4131 + plaintext_pad_len;
4134 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4137 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4138 "SNOW 3G Generated auth tag not as expected");
4142 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4144 struct crypto_testsuite_params *ts_params = &testsuite_params;
4145 struct crypto_unittest_params *ut_params = &unittest_params;
4149 uint8_t *plaintext, *ciphertext;
4150 unsigned plaintext_pad_len;
4151 unsigned plaintext_len;
4153 /* Create SNOW 3G session */
4154 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4155 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4156 RTE_CRYPTO_AUTH_OP_GENERATE,
4157 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4158 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4159 tdata->key.data, tdata->key.len,
4160 tdata->auth_iv.len, tdata->digest.len,
4161 tdata->cipher_iv.len);
4165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4167 /* clear mbuf payload */
4168 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4169 rte_pktmbuf_tailroom(ut_params->ibuf));
4171 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4172 /* Append data which is padded to a multiple of */
4173 /* the algorithms block size */
4174 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4175 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4177 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4179 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4181 /* Create SNOW 3G operation */
4182 retval = create_wireless_algo_auth_cipher_operation(
4184 tdata->cipher_iv.data, tdata->cipher_iv.len,
4185 tdata->auth_iv.data, tdata->auth_iv.len,
4187 tdata->validCipherLenInBits.len,
4189 tdata->validAuthLenInBits.len,
4195 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4197 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4198 ut_params->obuf = ut_params->op->sym->m_src;
4199 if (ut_params->obuf)
4200 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4202 ciphertext = plaintext;
4204 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4205 + plaintext_pad_len;
4206 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4211 tdata->ciphertext.data,
4212 tdata->validDataLenInBits.len,
4213 "SNOW 3G Ciphertext data not as expected");
4216 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4219 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4220 "SNOW 3G Generated auth tag not as expected");
4225 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4227 struct crypto_testsuite_params *ts_params = &testsuite_params;
4228 struct crypto_unittest_params *ut_params = &unittest_params;
4232 uint8_t *plaintext, *ciphertext;
4233 unsigned plaintext_pad_len;
4234 unsigned plaintext_len;
4236 /* Create KASUMI session */
4237 retval = create_wireless_algo_auth_cipher_session(
4238 ts_params->valid_devs[0],
4239 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4240 RTE_CRYPTO_AUTH_OP_GENERATE,
4241 RTE_CRYPTO_AUTH_KASUMI_F9,
4242 RTE_CRYPTO_CIPHER_KASUMI_F8,
4243 tdata->key.data, tdata->key.len,
4244 0, tdata->digest.len,
4245 tdata->cipher_iv.len);
4248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4250 /* clear mbuf payload */
4251 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4252 rte_pktmbuf_tailroom(ut_params->ibuf));
4254 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4255 /* Append data which is padded to a multiple of */
4256 /* the algorithms block size */
4257 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4262 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4264 /* Create KASUMI operation */
4265 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4266 tdata->cipher_iv.data, tdata->cipher_iv.len,
4269 tdata->validCipherLenInBits.len,
4270 tdata->validCipherOffsetInBits.len,
4271 tdata->validAuthLenInBits.len,
4278 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4281 if (ut_params->op->sym->m_dst)
4282 ut_params->obuf = ut_params->op->sym->m_dst;
4284 ut_params->obuf = ut_params->op->sym->m_src;
4286 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4287 tdata->validCipherOffsetInBits.len >> 3);
4289 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4290 (tdata->validCipherOffsetInBits.len >> 3);
4292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4294 reference_ciphertext,
4295 tdata->validCipherLenInBits.len,
4296 "KASUMI Ciphertext data not as expected");
4297 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4298 + plaintext_pad_len;
4301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4304 DIGEST_BYTE_LENGTH_KASUMI_F9,
4305 "KASUMI Generated auth tag not as expected");
4310 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4312 struct crypto_testsuite_params *ts_params = &testsuite_params;
4313 struct crypto_unittest_params *ut_params = &unittest_params;
4317 uint8_t *plaintext, *ciphertext;
4318 unsigned plaintext_pad_len;
4319 unsigned plaintext_len;
4321 /* Create KASUMI session */
4322 retval = create_wireless_algo_cipher_auth_session(
4323 ts_params->valid_devs[0],
4324 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4325 RTE_CRYPTO_AUTH_OP_GENERATE,
4326 RTE_CRYPTO_AUTH_KASUMI_F9,
4327 RTE_CRYPTO_CIPHER_KASUMI_F8,
4328 tdata->key.data, tdata->key.len,
4329 0, tdata->digest.len,
4330 tdata->cipher_iv.len);
4334 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4336 /* clear mbuf payload */
4337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4338 rte_pktmbuf_tailroom(ut_params->ibuf));
4340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4341 /* Append data which is padded to a multiple of */
4342 /* the algorithms block size */
4343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4348 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4350 /* Create KASUMI operation */
4351 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4352 tdata->digest.len, NULL, 0,
4353 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4354 tdata->cipher_iv.data, tdata->cipher_iv.len,
4355 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4356 tdata->validCipherOffsetInBits.len,
4357 tdata->validAuthLenInBits.len,
4363 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4365 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4367 if (ut_params->op->sym->m_dst)
4368 ut_params->obuf = ut_params->op->sym->m_dst;
4370 ut_params->obuf = ut_params->op->sym->m_src;
4372 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4373 tdata->validCipherOffsetInBits.len >> 3);
4375 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4376 + plaintext_pad_len;
4378 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4379 (tdata->validCipherOffsetInBits.len >> 3);
4381 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4383 reference_ciphertext,
4384 tdata->validCipherLenInBits.len,
4385 "KASUMI Ciphertext data not as expected");
4388 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4391 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4392 "KASUMI Generated auth tag not as expected");
4397 test_zuc_encryption(const struct wireless_test_data *tdata)
4399 struct crypto_testsuite_params *ts_params = &testsuite_params;
4400 struct crypto_unittest_params *ut_params = &unittest_params;
4403 uint8_t *plaintext, *ciphertext;
4404 unsigned plaintext_pad_len;
4405 unsigned plaintext_len;
4407 struct rte_cryptodev_sym_capability_idx cap_idx;
4409 /* Check if device supports ZUC EEA3 */
4410 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4411 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4413 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4417 /* Create ZUC session */
4418 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4419 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4420 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4421 tdata->key.data, tdata->key.len,
4422 tdata->cipher_iv.len);
4426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4428 /* Clear mbuf payload */
4429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4430 rte_pktmbuf_tailroom(ut_params->ibuf));
4432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4433 /* Append data which is padded to a multiple */
4434 /* of the algorithms block size */
4435 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4436 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4438 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4440 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4442 /* Create ZUC operation */
4443 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4444 tdata->cipher_iv.len,
4445 tdata->plaintext.len,
4450 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4452 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4454 ut_params->obuf = ut_params->op->sym->m_dst;
4455 if (ut_params->obuf)
4456 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4458 ciphertext = plaintext;
4460 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4463 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4465 tdata->ciphertext.data,
4466 tdata->validCipherLenInBits.len,
4467 "ZUC Ciphertext data not as expected");
4472 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4474 struct crypto_testsuite_params *ts_params = &testsuite_params;
4475 struct crypto_unittest_params *ut_params = &unittest_params;
4479 unsigned int plaintext_pad_len;
4480 unsigned int plaintext_len;
4481 const uint8_t *ciphertext;
4482 uint8_t ciphertext_buffer[2048];
4483 struct rte_cryptodev_info dev_info;
4485 struct rte_cryptodev_sym_capability_idx cap_idx;
4487 /* Check if device supports ZUC EEA3 */
4488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4489 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4491 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4495 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4496 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4497 printf("Device doesn't support scatter-gather. "
4502 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4504 /* Append data which is padded to a multiple */
4505 /* of the algorithms block size */
4506 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4508 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4509 plaintext_pad_len, 10, 0);
4511 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4512 tdata->plaintext.data);
4514 /* Create ZUC session */
4515 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4516 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4517 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4518 tdata->key.data, tdata->key.len,
4519 tdata->cipher_iv.len);
4523 /* Clear mbuf payload */
4525 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4527 /* Create ZUC operation */
4528 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4529 tdata->cipher_iv.len, tdata->plaintext.len,
4534 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4536 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4538 ut_params->obuf = ut_params->op->sym->m_dst;
4539 if (ut_params->obuf)
4540 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4541 0, plaintext_len, ciphertext_buffer);
4543 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4544 0, plaintext_len, ciphertext_buffer);
4547 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4550 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4552 tdata->ciphertext.data,
4553 tdata->validCipherLenInBits.len,
4554 "ZUC Ciphertext data not as expected");
4560 test_zuc_authentication(const struct wireless_test_data *tdata)
4562 struct crypto_testsuite_params *ts_params = &testsuite_params;
4563 struct crypto_unittest_params *ut_params = &unittest_params;
4566 unsigned plaintext_pad_len;
4567 unsigned plaintext_len;
4570 struct rte_cryptodev_sym_capability_idx cap_idx;
4572 /* Check if device supports ZUC EIA3 */
4573 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4574 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4576 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4580 /* Create ZUC session */
4581 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4582 tdata->key.data, tdata->key.len,
4583 tdata->auth_iv.len, tdata->digest.len,
4584 RTE_CRYPTO_AUTH_OP_GENERATE,
4585 RTE_CRYPTO_AUTH_ZUC_EIA3);
4589 /* alloc mbuf and set payload */
4590 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4592 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4593 rte_pktmbuf_tailroom(ut_params->ibuf));
4595 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4596 /* Append data which is padded to a multiple of */
4597 /* the algorithms block size */
4598 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4599 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4601 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4603 /* Create ZUC operation */
4604 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4605 tdata->auth_iv.data, tdata->auth_iv.len,
4606 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4607 tdata->validAuthLenInBits.len,
4612 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4614 ut_params->obuf = ut_params->op->sym->m_src;
4615 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4616 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4617 + plaintext_pad_len;
4620 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4623 DIGEST_BYTE_LENGTH_KASUMI_F9,
4624 "ZUC Generated auth tag not as expected");
4630 test_kasumi_encryption_test_case_1(void)
4632 return test_kasumi_encryption(&kasumi_test_case_1);
4636 test_kasumi_encryption_test_case_1_sgl(void)
4638 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4642 test_kasumi_encryption_test_case_1_oop(void)
4644 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4648 test_kasumi_encryption_test_case_1_oop_sgl(void)
4650 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4654 test_kasumi_encryption_test_case_2(void)
4656 return test_kasumi_encryption(&kasumi_test_case_2);
4660 test_kasumi_encryption_test_case_3(void)
4662 return test_kasumi_encryption(&kasumi_test_case_3);
4666 test_kasumi_encryption_test_case_4(void)
4668 return test_kasumi_encryption(&kasumi_test_case_4);
4672 test_kasumi_encryption_test_case_5(void)
4674 return test_kasumi_encryption(&kasumi_test_case_5);
4678 test_kasumi_decryption_test_case_1(void)
4680 return test_kasumi_decryption(&kasumi_test_case_1);
4684 test_kasumi_decryption_test_case_1_oop(void)
4686 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4690 test_kasumi_decryption_test_case_2(void)
4692 return test_kasumi_decryption(&kasumi_test_case_2);
4696 test_kasumi_decryption_test_case_3(void)
4698 return test_kasumi_decryption(&kasumi_test_case_3);
4702 test_kasumi_decryption_test_case_4(void)
4704 return test_kasumi_decryption(&kasumi_test_case_4);
4708 test_kasumi_decryption_test_case_5(void)
4710 return test_kasumi_decryption(&kasumi_test_case_5);
4713 test_snow3g_encryption_test_case_1(void)
4715 return test_snow3g_encryption(&snow3g_test_case_1);
4719 test_snow3g_encryption_test_case_1_oop(void)
4721 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4725 test_snow3g_encryption_test_case_1_oop_sgl(void)
4727 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4732 test_snow3g_encryption_test_case_1_offset_oop(void)
4734 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4738 test_snow3g_encryption_test_case_2(void)
4740 return test_snow3g_encryption(&snow3g_test_case_2);
4744 test_snow3g_encryption_test_case_3(void)
4746 return test_snow3g_encryption(&snow3g_test_case_3);
4750 test_snow3g_encryption_test_case_4(void)
4752 return test_snow3g_encryption(&snow3g_test_case_4);
4756 test_snow3g_encryption_test_case_5(void)
4758 return test_snow3g_encryption(&snow3g_test_case_5);
4762 test_snow3g_decryption_test_case_1(void)
4764 return test_snow3g_decryption(&snow3g_test_case_1);
4768 test_snow3g_decryption_test_case_1_oop(void)
4770 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4774 test_snow3g_decryption_test_case_2(void)
4776 return test_snow3g_decryption(&snow3g_test_case_2);
4780 test_snow3g_decryption_test_case_3(void)
4782 return test_snow3g_decryption(&snow3g_test_case_3);
4786 test_snow3g_decryption_test_case_4(void)
4788 return test_snow3g_decryption(&snow3g_test_case_4);
4792 test_snow3g_decryption_test_case_5(void)
4794 return test_snow3g_decryption(&snow3g_test_case_5);
4797 test_snow3g_cipher_auth_test_case_1(void)
4799 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4803 test_snow3g_auth_cipher_test_case_1(void)
4805 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4809 test_kasumi_auth_cipher_test_case_1(void)
4811 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4815 test_kasumi_cipher_auth_test_case_1(void)
4817 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4821 test_zuc_encryption_test_case_1(void)
4823 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4827 test_zuc_encryption_test_case_2(void)
4829 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4833 test_zuc_encryption_test_case_3(void)
4835 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4839 test_zuc_encryption_test_case_4(void)
4841 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4845 test_zuc_encryption_test_case_5(void)
4847 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4851 test_zuc_encryption_test_case_6_sgl(void)
4853 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4857 test_zuc_hash_generate_test_case_1(void)
4859 return test_zuc_authentication(&zuc_test_case_auth_1b);
4863 test_zuc_hash_generate_test_case_2(void)
4865 return test_zuc_authentication(&zuc_test_case_auth_90b);
4869 test_zuc_hash_generate_test_case_3(void)
4871 return test_zuc_authentication(&zuc_test_case_auth_577b);
4875 test_zuc_hash_generate_test_case_4(void)
4877 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4881 test_zuc_hash_generate_test_case_5(void)
4883 return test_zuc_authentication(&zuc_test_auth_5670b);
4887 test_zuc_hash_generate_test_case_6(void)
4889 return test_zuc_authentication(&zuc_test_case_auth_128b);
4893 test_zuc_hash_generate_test_case_7(void)
4895 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4899 test_zuc_hash_generate_test_case_8(void)
4901 return test_zuc_authentication(&zuc_test_case_auth_584b);
4905 test_zuc_cipher_auth_test_case_1(void)
4907 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4911 test_zuc_cipher_auth_test_case_2(void)
4913 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4917 test_3DES_chain_qat_all(void)
4919 struct crypto_testsuite_params *ts_params = &testsuite_params;
4922 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4923 ts_params->op_mpool,
4924 ts_params->session_mpool,
4925 ts_params->valid_devs[0],
4926 rte_cryptodev_driver_id_get(
4927 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4928 BLKCIPHER_3DES_CHAIN_TYPE);
4930 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4932 return TEST_SUCCESS;
4936 test_DES_cipheronly_qat_all(void)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4941 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4942 ts_params->op_mpool,
4943 ts_params->session_mpool,
4944 ts_params->valid_devs[0],
4945 rte_cryptodev_driver_id_get(
4946 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4947 BLKCIPHER_DES_CIPHERONLY_TYPE);
4949 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4951 return TEST_SUCCESS;
4955 test_DES_cipheronly_openssl_all(void)
4957 struct crypto_testsuite_params *ts_params = &testsuite_params;
4960 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4961 ts_params->op_mpool,
4962 ts_params->session_mpool,
4963 ts_params->valid_devs[0],
4964 rte_cryptodev_driver_id_get(
4965 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4966 BLKCIPHER_DES_CIPHERONLY_TYPE);
4968 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4970 return TEST_SUCCESS;
4974 test_DES_docsis_openssl_all(void)
4976 struct crypto_testsuite_params *ts_params = &testsuite_params;
4979 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4980 ts_params->op_mpool,
4981 ts_params->session_mpool,
4982 ts_params->valid_devs[0],
4983 rte_cryptodev_driver_id_get(
4984 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4985 BLKCIPHER_DES_DOCSIS_TYPE);
4987 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4989 return TEST_SUCCESS;
4993 test_DES_cipheronly_mb_all(void)
4995 struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4999 ts_params->op_mpool,
5000 ts_params->session_mpool,
5001 ts_params->valid_devs[0],
5002 rte_cryptodev_driver_id_get(
5003 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5004 BLKCIPHER_DES_CIPHERONLY_TYPE);
5006 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5008 return TEST_SUCCESS;
5012 test_DES_docsis_mb_all(void)
5014 struct crypto_testsuite_params *ts_params = &testsuite_params;
5017 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5018 ts_params->op_mpool,
5019 ts_params->session_mpool,
5020 ts_params->valid_devs[0],
5021 rte_cryptodev_driver_id_get(
5022 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5023 BLKCIPHER_DES_DOCSIS_TYPE);
5025 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5027 return TEST_SUCCESS;
5031 test_3DES_chain_dpaa_sec_all(void)
5033 struct crypto_testsuite_params *ts_params = &testsuite_params;
5036 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5037 ts_params->op_mpool,
5038 ts_params->session_mpool,
5039 ts_params->valid_devs[0],
5040 rte_cryptodev_driver_id_get(
5041 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5042 BLKCIPHER_3DES_CHAIN_TYPE);
5044 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5046 return TEST_SUCCESS;
5050 test_3DES_cipheronly_dpaa_sec_all(void)
5052 struct crypto_testsuite_params *ts_params = &testsuite_params;
5055 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5056 ts_params->op_mpool,
5057 ts_params->session_mpool,
5058 ts_params->valid_devs[0],
5059 rte_cryptodev_driver_id_get(
5060 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5061 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5063 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5065 return TEST_SUCCESS;
5069 test_3DES_chain_dpaa2_sec_all(void)
5071 struct crypto_testsuite_params *ts_params = &testsuite_params;
5074 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5075 ts_params->op_mpool,
5076 ts_params->session_mpool,
5077 ts_params->valid_devs[0],
5078 rte_cryptodev_driver_id_get(
5079 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5080 BLKCIPHER_3DES_CHAIN_TYPE);
5082 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5084 return TEST_SUCCESS;
5088 test_3DES_cipheronly_dpaa2_sec_all(void)
5090 struct crypto_testsuite_params *ts_params = &testsuite_params;
5093 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5094 ts_params->op_mpool,
5095 ts_params->session_mpool,
5096 ts_params->valid_devs[0],
5097 rte_cryptodev_driver_id_get(
5098 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5099 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5101 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5103 return TEST_SUCCESS;
5107 test_3DES_chain_ccp_all(void)
5109 struct crypto_testsuite_params *ts_params = &testsuite_params;
5112 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5113 ts_params->op_mpool,
5114 ts_params->session_mpool,
5115 ts_params->valid_devs[0],
5116 rte_cryptodev_driver_id_get(
5117 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5118 BLKCIPHER_3DES_CHAIN_TYPE);
5120 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5122 return TEST_SUCCESS;
5126 test_3DES_cipheronly_ccp_all(void)
5128 struct crypto_testsuite_params *ts_params = &testsuite_params;
5131 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5132 ts_params->op_mpool,
5133 ts_params->session_mpool,
5134 ts_params->valid_devs[0],
5135 rte_cryptodev_driver_id_get(
5136 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5137 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5139 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5141 return TEST_SUCCESS;
5145 test_3DES_cipheronly_qat_all(void)
5147 struct crypto_testsuite_params *ts_params = &testsuite_params;
5150 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5151 ts_params->op_mpool,
5152 ts_params->session_mpool,
5153 ts_params->valid_devs[0],
5154 rte_cryptodev_driver_id_get(
5155 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5156 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5158 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5160 return TEST_SUCCESS;
5164 test_3DES_chain_openssl_all(void)
5166 struct crypto_testsuite_params *ts_params = &testsuite_params;
5169 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5170 ts_params->op_mpool,
5171 ts_params->session_mpool,
5172 ts_params->valid_devs[0],
5173 rte_cryptodev_driver_id_get(
5174 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5175 BLKCIPHER_3DES_CHAIN_TYPE);
5177 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5179 return TEST_SUCCESS;
5183 test_3DES_cipheronly_openssl_all(void)
5185 struct crypto_testsuite_params *ts_params = &testsuite_params;
5188 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5189 ts_params->op_mpool,
5190 ts_params->session_mpool,
5191 ts_params->valid_devs[0],
5192 rte_cryptodev_driver_id_get(
5193 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5194 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5196 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5198 return TEST_SUCCESS;
5201 /* ***** AEAD algorithm Tests ***** */
5204 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5205 enum rte_crypto_aead_operation op,
5206 const uint8_t *key, const uint8_t key_len,
5207 const uint16_t aad_len, const uint8_t auth_len,
5210 uint8_t aead_key[key_len];
5212 struct crypto_testsuite_params *ts_params = &testsuite_params;
5213 struct crypto_unittest_params *ut_params = &unittest_params;
5215 memcpy(aead_key, key, key_len);
5217 /* Setup AEAD Parameters */
5218 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5219 ut_params->aead_xform.next = NULL;
5220 ut_params->aead_xform.aead.algo = algo;
5221 ut_params->aead_xform.aead.op = op;
5222 ut_params->aead_xform.aead.key.data = aead_key;
5223 ut_params->aead_xform.aead.key.length = key_len;
5224 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5225 ut_params->aead_xform.aead.iv.length = iv_len;
5226 ut_params->aead_xform.aead.digest_length = auth_len;
5227 ut_params->aead_xform.aead.aad_length = aad_len;
5229 debug_hexdump(stdout, "key:", key, key_len);
5231 /* Create Crypto session*/
5232 ut_params->sess = rte_cryptodev_sym_session_create(
5233 ts_params->session_mpool);
5235 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5236 &ut_params->aead_xform, ts_params->session_mpool);
5238 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5244 create_aead_xform(struct rte_crypto_op *op,
5245 enum rte_crypto_aead_algorithm algo,
5246 enum rte_crypto_aead_operation aead_op,
5247 uint8_t *key, const uint8_t key_len,
5248 const uint8_t aad_len, const uint8_t auth_len,
5251 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5252 "failed to allocate space for crypto transform");
5254 struct rte_crypto_sym_op *sym_op = op->sym;
5256 /* Setup AEAD Parameters */
5257 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5258 sym_op->xform->next = NULL;
5259 sym_op->xform->aead.algo = algo;
5260 sym_op->xform->aead.op = aead_op;
5261 sym_op->xform->aead.key.data = key;
5262 sym_op->xform->aead.key.length = key_len;
5263 sym_op->xform->aead.iv.offset = IV_OFFSET;
5264 sym_op->xform->aead.iv.length = iv_len;
5265 sym_op->xform->aead.digest_length = auth_len;
5266 sym_op->xform->aead.aad_length = aad_len;
5268 debug_hexdump(stdout, "key:", key, key_len);
5274 create_aead_operation(enum rte_crypto_aead_operation op,
5275 const struct aead_test_data *tdata)
5277 struct crypto_testsuite_params *ts_params = &testsuite_params;
5278 struct crypto_unittest_params *ut_params = &unittest_params;
5280 uint8_t *plaintext, *ciphertext;
5281 unsigned int aad_pad_len, plaintext_pad_len;
5283 /* Generate Crypto op data structure */
5284 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5285 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5286 TEST_ASSERT_NOT_NULL(ut_params->op,
5287 "Failed to allocate symmetric crypto operation struct");
5289 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5291 /* Append aad data */
5292 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5293 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5294 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5296 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5297 "no room to append aad");
5299 sym_op->aead.aad.phys_addr =
5300 rte_pktmbuf_iova(ut_params->ibuf);
5301 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5302 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5303 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5306 /* Append IV at the end of the crypto operation*/
5307 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5308 uint8_t *, IV_OFFSET);
5310 /* Copy IV 1 byte after the IV pointer, according to the API */
5311 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5312 debug_hexdump(stdout, "iv:", iv_ptr,
5315 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5316 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5318 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5319 "no room to append aad");
5321 sym_op->aead.aad.phys_addr =
5322 rte_pktmbuf_iova(ut_params->ibuf);
5323 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5324 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5327 /* Append IV at the end of the crypto operation*/
5328 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5329 uint8_t *, IV_OFFSET);
5331 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5332 debug_hexdump(stdout, "iv:", iv_ptr,
5336 /* Append plaintext/ciphertext */
5337 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5338 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5341 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5343 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5344 debug_hexdump(stdout, "plaintext:", plaintext,
5345 tdata->plaintext.len);
5347 if (ut_params->obuf) {
5348 ciphertext = (uint8_t *)rte_pktmbuf_append(
5350 plaintext_pad_len + aad_pad_len);
5351 TEST_ASSERT_NOT_NULL(ciphertext,
5352 "no room to append ciphertext");
5354 memset(ciphertext + aad_pad_len, 0,
5355 tdata->ciphertext.len);
5358 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5359 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5361 TEST_ASSERT_NOT_NULL(ciphertext,
5362 "no room to append ciphertext");
5364 memcpy(ciphertext, tdata->ciphertext.data,
5365 tdata->ciphertext.len);
5366 debug_hexdump(stdout, "ciphertext:", ciphertext,
5367 tdata->ciphertext.len);
5369 if (ut_params->obuf) {
5370 plaintext = (uint8_t *)rte_pktmbuf_append(
5372 plaintext_pad_len + aad_pad_len);
5373 TEST_ASSERT_NOT_NULL(plaintext,
5374 "no room to append plaintext");
5376 memset(plaintext + aad_pad_len, 0,
5377 tdata->plaintext.len);
5381 /* Append digest data */
5382 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5383 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5384 ut_params->obuf ? ut_params->obuf :
5386 tdata->auth_tag.len);
5387 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5388 "no room to append digest");
5389 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5390 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5391 ut_params->obuf ? ut_params->obuf :
5396 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5397 ut_params->ibuf, tdata->auth_tag.len);
5398 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5399 "no room to append digest");
5400 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5402 plaintext_pad_len + aad_pad_len);
5404 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5405 tdata->auth_tag.len);
5406 debug_hexdump(stdout, "digest:",
5407 sym_op->aead.digest.data,
5408 tdata->auth_tag.len);
5411 sym_op->aead.data.length = tdata->plaintext.len;
5412 sym_op->aead.data.offset = aad_pad_len;
5418 test_authenticated_encryption(const struct aead_test_data *tdata)
5420 struct crypto_testsuite_params *ts_params = &testsuite_params;
5421 struct crypto_unittest_params *ut_params = &unittest_params;
5424 uint8_t *ciphertext, *auth_tag;
5425 uint16_t plaintext_pad_len;
5428 /* Create AEAD session */
5429 retval = create_aead_session(ts_params->valid_devs[0],
5431 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5432 tdata->key.data, tdata->key.len,
5433 tdata->aad.len, tdata->auth_tag.len,
5438 if (tdata->aad.len > MBUF_SIZE) {
5439 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5440 /* Populate full size of add data */
5441 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5442 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5446 /* clear mbuf payload */
5447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5448 rte_pktmbuf_tailroom(ut_params->ibuf));
5450 /* Create AEAD operation */
5451 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5455 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5457 ut_params->op->sym->m_src = ut_params->ibuf;
5459 /* Process crypto operation */
5460 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5461 ut_params->op), "failed to process sym crypto op");
5463 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5464 "crypto op processing failed");
5466 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5468 if (ut_params->op->sym->m_dst) {
5469 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5471 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5472 uint8_t *, plaintext_pad_len);
5474 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5476 ut_params->op->sym->cipher.data.offset);
5477 auth_tag = ciphertext + plaintext_pad_len;
5480 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5481 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5484 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5486 tdata->ciphertext.data,
5487 tdata->ciphertext.len,
5488 "Ciphertext data not as expected");
5490 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5492 tdata->auth_tag.data,
5493 tdata->auth_tag.len,
5494 "Generated auth tag not as expected");
5501 test_AES_GCM_authenticated_encryption_test_case_1(void)
5503 return test_authenticated_encryption(&gcm_test_case_1);
5507 test_AES_GCM_authenticated_encryption_test_case_2(void)
5509 return test_authenticated_encryption(&gcm_test_case_2);
5513 test_AES_GCM_authenticated_encryption_test_case_3(void)
5515 return test_authenticated_encryption(&gcm_test_case_3);
5519 test_AES_GCM_authenticated_encryption_test_case_4(void)
5521 return test_authenticated_encryption(&gcm_test_case_4);
5525 test_AES_GCM_authenticated_encryption_test_case_5(void)
5527 return test_authenticated_encryption(&gcm_test_case_5);
5531 test_AES_GCM_authenticated_encryption_test_case_6(void)
5533 return test_authenticated_encryption(&gcm_test_case_6);
5537 test_AES_GCM_authenticated_encryption_test_case_7(void)
5539 return test_authenticated_encryption(&gcm_test_case_7);
5543 test_AES_GCM_auth_encryption_test_case_192_1(void)
5545 return test_authenticated_encryption(&gcm_test_case_192_1);
5549 test_AES_GCM_auth_encryption_test_case_192_2(void)
5551 return test_authenticated_encryption(&gcm_test_case_192_2);
5555 test_AES_GCM_auth_encryption_test_case_192_3(void)
5557 return test_authenticated_encryption(&gcm_test_case_192_3);
5561 test_AES_GCM_auth_encryption_test_case_192_4(void)
5563 return test_authenticated_encryption(&gcm_test_case_192_4);
5567 test_AES_GCM_auth_encryption_test_case_192_5(void)
5569 return test_authenticated_encryption(&gcm_test_case_192_5);
5573 test_AES_GCM_auth_encryption_test_case_192_6(void)
5575 return test_authenticated_encryption(&gcm_test_case_192_6);
5579 test_AES_GCM_auth_encryption_test_case_192_7(void)
5581 return test_authenticated_encryption(&gcm_test_case_192_7);
5585 test_AES_GCM_auth_encryption_test_case_256_1(void)
5587 return test_authenticated_encryption(&gcm_test_case_256_1);
5591 test_AES_GCM_auth_encryption_test_case_256_2(void)
5593 return test_authenticated_encryption(&gcm_test_case_256_2);
5597 test_AES_GCM_auth_encryption_test_case_256_3(void)
5599 return test_authenticated_encryption(&gcm_test_case_256_3);
5603 test_AES_GCM_auth_encryption_test_case_256_4(void)
5605 return test_authenticated_encryption(&gcm_test_case_256_4);
5609 test_AES_GCM_auth_encryption_test_case_256_5(void)
5611 return test_authenticated_encryption(&gcm_test_case_256_5);
5615 test_AES_GCM_auth_encryption_test_case_256_6(void)
5617 return test_authenticated_encryption(&gcm_test_case_256_6);
5621 test_AES_GCM_auth_encryption_test_case_256_7(void)
5623 return test_authenticated_encryption(&gcm_test_case_256_7);
5627 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5629 return test_authenticated_encryption(&gcm_test_case_aad_1);
5633 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5635 return test_authenticated_encryption(&gcm_test_case_aad_2);
5639 test_authenticated_decryption(const struct aead_test_data *tdata)
5641 struct crypto_testsuite_params *ts_params = &testsuite_params;
5642 struct crypto_unittest_params *ut_params = &unittest_params;
5648 /* Create AEAD session */
5649 retval = create_aead_session(ts_params->valid_devs[0],
5651 RTE_CRYPTO_AEAD_OP_DECRYPT,
5652 tdata->key.data, tdata->key.len,
5653 tdata->aad.len, tdata->auth_tag.len,
5658 /* alloc mbuf and set payload */
5659 if (tdata->aad.len > MBUF_SIZE) {
5660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5661 /* Populate full size of add data */
5662 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5663 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5665 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5667 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5668 rte_pktmbuf_tailroom(ut_params->ibuf));
5670 /* Create AEAD operation */
5671 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5675 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5677 ut_params->op->sym->m_src = ut_params->ibuf;
5679 /* Process crypto operation */
5680 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5681 ut_params->op), "failed to process sym crypto op");
5683 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5684 "crypto op processing failed");
5686 if (ut_params->op->sym->m_dst)
5687 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5690 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5692 ut_params->op->sym->cipher.data.offset);
5694 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5697 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5699 tdata->plaintext.data,
5700 tdata->plaintext.len,
5701 "Plaintext data not as expected");
5703 TEST_ASSERT_EQUAL(ut_params->op->status,
5704 RTE_CRYPTO_OP_STATUS_SUCCESS,
5705 "Authentication failed");
5710 test_AES_GCM_authenticated_decryption_test_case_1(void)
5712 return test_authenticated_decryption(&gcm_test_case_1);
5716 test_AES_GCM_authenticated_decryption_test_case_2(void)
5718 return test_authenticated_decryption(&gcm_test_case_2);
5722 test_AES_GCM_authenticated_decryption_test_case_3(void)
5724 return test_authenticated_decryption(&gcm_test_case_3);
5728 test_AES_GCM_authenticated_decryption_test_case_4(void)
5730 return test_authenticated_decryption(&gcm_test_case_4);
5734 test_AES_GCM_authenticated_decryption_test_case_5(void)
5736 return test_authenticated_decryption(&gcm_test_case_5);
5740 test_AES_GCM_authenticated_decryption_test_case_6(void)
5742 return test_authenticated_decryption(&gcm_test_case_6);
5746 test_AES_GCM_authenticated_decryption_test_case_7(void)
5748 return test_authenticated_decryption(&gcm_test_case_7);
5752 test_AES_GCM_auth_decryption_test_case_192_1(void)
5754 return test_authenticated_decryption(&gcm_test_case_192_1);
5758 test_AES_GCM_auth_decryption_test_case_192_2(void)
5760 return test_authenticated_decryption(&gcm_test_case_192_2);
5764 test_AES_GCM_auth_decryption_test_case_192_3(void)
5766 return test_authenticated_decryption(&gcm_test_case_192_3);
5770 test_AES_GCM_auth_decryption_test_case_192_4(void)
5772 return test_authenticated_decryption(&gcm_test_case_192_4);
5776 test_AES_GCM_auth_decryption_test_case_192_5(void)
5778 return test_authenticated_decryption(&gcm_test_case_192_5);
5782 test_AES_GCM_auth_decryption_test_case_192_6(void)
5784 return test_authenticated_decryption(&gcm_test_case_192_6);
5788 test_AES_GCM_auth_decryption_test_case_192_7(void)
5790 return test_authenticated_decryption(&gcm_test_case_192_7);
5794 test_AES_GCM_auth_decryption_test_case_256_1(void)
5796 return test_authenticated_decryption(&gcm_test_case_256_1);
5800 test_AES_GCM_auth_decryption_test_case_256_2(void)
5802 return test_authenticated_decryption(&gcm_test_case_256_2);
5806 test_AES_GCM_auth_decryption_test_case_256_3(void)
5808 return test_authenticated_decryption(&gcm_test_case_256_3);
5812 test_AES_GCM_auth_decryption_test_case_256_4(void)
5814 return test_authenticated_decryption(&gcm_test_case_256_4);
5818 test_AES_GCM_auth_decryption_test_case_256_5(void)
5820 return test_authenticated_decryption(&gcm_test_case_256_5);
5824 test_AES_GCM_auth_decryption_test_case_256_6(void)
5826 return test_authenticated_decryption(&gcm_test_case_256_6);
5830 test_AES_GCM_auth_decryption_test_case_256_7(void)
5832 return test_authenticated_decryption(&gcm_test_case_256_7);
5836 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5838 return test_authenticated_decryption(&gcm_test_case_aad_1);
5842 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5844 return test_authenticated_decryption(&gcm_test_case_aad_2);
5848 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5850 struct crypto_testsuite_params *ts_params = &testsuite_params;
5851 struct crypto_unittest_params *ut_params = &unittest_params;
5854 uint8_t *ciphertext, *auth_tag;
5855 uint16_t plaintext_pad_len;
5857 /* Create AEAD session */
5858 retval = create_aead_session(ts_params->valid_devs[0],
5860 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5861 tdata->key.data, tdata->key.len,
5862 tdata->aad.len, tdata->auth_tag.len,
5867 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5868 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5870 /* clear mbuf payload */
5871 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5872 rte_pktmbuf_tailroom(ut_params->ibuf));
5873 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5874 rte_pktmbuf_tailroom(ut_params->obuf));
5876 /* Create AEAD operation */
5877 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5883 ut_params->op->sym->m_src = ut_params->ibuf;
5884 ut_params->op->sym->m_dst = ut_params->obuf;
5886 /* Process crypto operation */
5887 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5888 ut_params->op), "failed to process sym crypto op");
5890 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5891 "crypto op processing failed");
5893 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5895 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5896 ut_params->op->sym->cipher.data.offset);
5897 auth_tag = ciphertext + plaintext_pad_len;
5899 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5900 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5905 tdata->ciphertext.data,
5906 tdata->ciphertext.len,
5907 "Ciphertext data not as expected");
5909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5911 tdata->auth_tag.data,
5912 tdata->auth_tag.len,
5913 "Generated auth tag not as expected");
5920 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5922 return test_authenticated_encryption_oop(&gcm_test_case_5);
5926 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5928 struct crypto_testsuite_params *ts_params = &testsuite_params;
5929 struct crypto_unittest_params *ut_params = &unittest_params;
5934 /* Create AEAD session */
5935 retval = create_aead_session(ts_params->valid_devs[0],
5937 RTE_CRYPTO_AEAD_OP_DECRYPT,
5938 tdata->key.data, tdata->key.len,
5939 tdata->aad.len, tdata->auth_tag.len,
5944 /* alloc mbuf and set payload */
5945 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5946 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5948 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5949 rte_pktmbuf_tailroom(ut_params->ibuf));
5950 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5951 rte_pktmbuf_tailroom(ut_params->obuf));
5953 /* Create AEAD operation */
5954 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5958 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5960 ut_params->op->sym->m_src = ut_params->ibuf;
5961 ut_params->op->sym->m_dst = ut_params->obuf;
5963 /* Process crypto operation */
5964 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5965 ut_params->op), "failed to process sym crypto op");
5967 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5968 "crypto op processing failed");
5970 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5971 ut_params->op->sym->cipher.data.offset);
5973 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5976 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5978 tdata->plaintext.data,
5979 tdata->plaintext.len,
5980 "Plaintext data not as expected");
5982 TEST_ASSERT_EQUAL(ut_params->op->status,
5983 RTE_CRYPTO_OP_STATUS_SUCCESS,
5984 "Authentication failed");
5989 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5991 return test_authenticated_decryption_oop(&gcm_test_case_5);
5995 test_authenticated_encryption_sessionless(
5996 const struct aead_test_data *tdata)
5998 struct crypto_testsuite_params *ts_params = &testsuite_params;
5999 struct crypto_unittest_params *ut_params = &unittest_params;
6002 uint8_t *ciphertext, *auth_tag;
6003 uint16_t plaintext_pad_len;
6004 uint8_t key[tdata->key.len + 1];
6006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6008 /* clear mbuf payload */
6009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6010 rte_pktmbuf_tailroom(ut_params->ibuf));
6012 /* Create AEAD operation */
6013 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6017 /* Create GCM xform */
6018 memcpy(key, tdata->key.data, tdata->key.len);
6019 retval = create_aead_xform(ut_params->op,
6021 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6022 key, tdata->key.len,
6023 tdata->aad.len, tdata->auth_tag.len,
6028 ut_params->op->sym->m_src = ut_params->ibuf;
6030 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6031 RTE_CRYPTO_OP_SESSIONLESS,
6032 "crypto op session type not sessionless");
6034 /* Process crypto operation */
6035 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6036 ut_params->op), "failed to process sym crypto op");
6038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6040 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6041 "crypto op status not success");
6043 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6045 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6046 ut_params->op->sym->cipher.data.offset);
6047 auth_tag = ciphertext + plaintext_pad_len;
6049 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6050 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6053 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6055 tdata->ciphertext.data,
6056 tdata->ciphertext.len,
6057 "Ciphertext data not as expected");
6059 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6061 tdata->auth_tag.data,
6062 tdata->auth_tag.len,
6063 "Generated auth tag not as expected");
6070 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6072 return test_authenticated_encryption_sessionless(
6077 test_authenticated_decryption_sessionless(
6078 const struct aead_test_data *tdata)
6080 struct crypto_testsuite_params *ts_params = &testsuite_params;
6081 struct crypto_unittest_params *ut_params = &unittest_params;
6085 uint8_t key[tdata->key.len + 1];
6087 /* alloc mbuf and set payload */
6088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6090 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6091 rte_pktmbuf_tailroom(ut_params->ibuf));
6093 /* Create AEAD operation */
6094 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6098 /* Create AEAD xform */
6099 memcpy(key, tdata->key.data, tdata->key.len);
6100 retval = create_aead_xform(ut_params->op,
6102 RTE_CRYPTO_AEAD_OP_DECRYPT,
6103 key, tdata->key.len,
6104 tdata->aad.len, tdata->auth_tag.len,
6109 ut_params->op->sym->m_src = ut_params->ibuf;
6111 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6112 RTE_CRYPTO_OP_SESSIONLESS,
6113 "crypto op session type not sessionless");
6115 /* Process crypto operation */
6116 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6117 ut_params->op), "failed to process sym crypto op");
6119 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6121 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6122 "crypto op status not success");
6124 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6125 ut_params->op->sym->cipher.data.offset);
6127 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6130 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6132 tdata->plaintext.data,
6133 tdata->plaintext.len,
6134 "Plaintext data not as expected");
6136 TEST_ASSERT_EQUAL(ut_params->op->status,
6137 RTE_CRYPTO_OP_STATUS_SUCCESS,
6138 "Authentication failed");
6143 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6145 return test_authenticated_decryption_sessionless(
6150 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6152 return test_authenticated_encryption(&ccm_test_case_128_1);
6156 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6158 return test_authenticated_encryption(&ccm_test_case_128_2);
6162 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6164 return test_authenticated_encryption(&ccm_test_case_128_3);
6168 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6170 return test_authenticated_decryption(&ccm_test_case_128_1);
6174 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6176 return test_authenticated_decryption(&ccm_test_case_128_2);
6180 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6182 return test_authenticated_decryption(&ccm_test_case_128_3);
6186 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6188 return test_authenticated_encryption(&ccm_test_case_192_1);
6192 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6194 return test_authenticated_encryption(&ccm_test_case_192_2);
6198 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6200 return test_authenticated_encryption(&ccm_test_case_192_3);
6204 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6206 return test_authenticated_decryption(&ccm_test_case_192_1);
6210 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6212 return test_authenticated_decryption(&ccm_test_case_192_2);
6216 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6218 return test_authenticated_decryption(&ccm_test_case_192_3);
6222 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6224 return test_authenticated_encryption(&ccm_test_case_256_1);
6228 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6230 return test_authenticated_encryption(&ccm_test_case_256_2);
6234 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6236 return test_authenticated_encryption(&ccm_test_case_256_3);
6240 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6242 return test_authenticated_decryption(&ccm_test_case_256_1);
6246 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6248 return test_authenticated_decryption(&ccm_test_case_256_2);
6252 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6254 return test_authenticated_decryption(&ccm_test_case_256_3);
6260 struct crypto_testsuite_params *ts_params = &testsuite_params;
6261 struct rte_cryptodev_stats stats;
6262 struct rte_cryptodev *dev;
6263 cryptodev_stats_get_t temp_pfn;
6265 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6266 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6267 &stats) == -ENODEV),
6268 "rte_cryptodev_stats_get invalid dev failed");
6269 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6270 "rte_cryptodev_stats_get invalid Param failed");
6271 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6272 temp_pfn = dev->dev_ops->stats_get;
6273 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6274 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6276 "rte_cryptodev_stats_get invalid Param failed");
6277 dev->dev_ops->stats_get = temp_pfn;
6279 /* Test expected values */
6281 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6283 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6285 "rte_cryptodev_stats_get failed");
6286 TEST_ASSERT((stats.enqueued_count == 1),
6287 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6288 TEST_ASSERT((stats.dequeued_count == 1),
6289 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6290 TEST_ASSERT((stats.enqueue_err_count == 0),
6291 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6292 TEST_ASSERT((stats.dequeue_err_count == 0),
6293 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6295 /* invalid device but should ignore and not reset device stats*/
6296 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6297 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6299 "rte_cryptodev_stats_get failed");
6300 TEST_ASSERT((stats.enqueued_count == 1),
6301 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6303 /* check that a valid reset clears stats */
6304 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6305 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6307 "rte_cryptodev_stats_get failed");
6308 TEST_ASSERT((stats.enqueued_count == 0),
6309 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6310 TEST_ASSERT((stats.dequeued_count == 0),
6311 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6313 return TEST_SUCCESS;
6316 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6317 struct crypto_unittest_params *ut_params,
6318 enum rte_crypto_auth_operation op,
6319 const struct HMAC_MD5_vector *test_case)
6323 memcpy(key, test_case->key.data, test_case->key.len);
6325 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6326 ut_params->auth_xform.next = NULL;
6327 ut_params->auth_xform.auth.op = op;
6329 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6331 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6332 ut_params->auth_xform.auth.key.length = test_case->key.len;
6333 ut_params->auth_xform.auth.key.data = key;
6335 ut_params->sess = rte_cryptodev_sym_session_create(
6336 ts_params->session_mpool);
6338 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6339 ut_params->sess, &ut_params->auth_xform,
6340 ts_params->session_mpool);
6342 if (ut_params->sess == NULL)
6345 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6347 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6348 rte_pktmbuf_tailroom(ut_params->ibuf));
6353 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6354 const struct HMAC_MD5_vector *test_case,
6355 uint8_t **plaintext)
6357 uint16_t plaintext_pad_len;
6359 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6361 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6364 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6366 memcpy(*plaintext, test_case->plaintext.data,
6367 test_case->plaintext.len);
6369 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6370 ut_params->ibuf, MD5_DIGEST_LEN);
6371 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6372 "no room to append digest");
6373 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6374 ut_params->ibuf, plaintext_pad_len);
6376 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6377 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6378 test_case->auth_tag.len);
6381 sym_op->auth.data.offset = 0;
6382 sym_op->auth.data.length = test_case->plaintext.len;
6384 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6385 ut_params->op->sym->m_src = ut_params->ibuf;
6391 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6393 uint16_t plaintext_pad_len;
6394 uint8_t *plaintext, *auth_tag;
6396 struct crypto_testsuite_params *ts_params = &testsuite_params;
6397 struct crypto_unittest_params *ut_params = &unittest_params;
6399 if (MD5_HMAC_create_session(ts_params, ut_params,
6400 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6403 /* Generate Crypto op data structure */
6404 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6405 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6406 TEST_ASSERT_NOT_NULL(ut_params->op,
6407 "Failed to allocate symmetric crypto operation struct");
6409 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6412 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6415 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6416 ut_params->op), "failed to process sym crypto op");
6418 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6419 "crypto op processing failed");
6421 if (ut_params->op->sym->m_dst) {
6422 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6423 uint8_t *, plaintext_pad_len);
6425 auth_tag = plaintext + plaintext_pad_len;
6428 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6430 test_case->auth_tag.data,
6431 test_case->auth_tag.len,
6432 "HMAC_MD5 generated tag not as expected");
6434 return TEST_SUCCESS;
6438 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6442 struct crypto_testsuite_params *ts_params = &testsuite_params;
6443 struct crypto_unittest_params *ut_params = &unittest_params;
6445 if (MD5_HMAC_create_session(ts_params, ut_params,
6446 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6450 /* Generate Crypto op data structure */
6451 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6452 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6453 TEST_ASSERT_NOT_NULL(ut_params->op,
6454 "Failed to allocate symmetric crypto operation struct");
6456 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6459 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6460 ut_params->op), "failed to process sym crypto op");
6462 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6463 "HMAC_MD5 crypto op processing failed");
6465 return TEST_SUCCESS;
6469 test_MD5_HMAC_generate_case_1(void)
6471 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6475 test_MD5_HMAC_verify_case_1(void)
6477 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6481 test_MD5_HMAC_generate_case_2(void)
6483 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6487 test_MD5_HMAC_verify_case_2(void)
6489 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6493 test_multi_session(void)
6495 struct crypto_testsuite_params *ts_params = &testsuite_params;
6496 struct crypto_unittest_params *ut_params = &unittest_params;
6498 struct rte_cryptodev_info dev_info;
6499 struct rte_cryptodev_sym_session **sessions;
6503 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6504 aes_cbc_key, hmac_sha512_key);
6507 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6509 sessions = rte_malloc(NULL,
6510 (sizeof(struct rte_cryptodev_sym_session *) *
6511 MAX_NB_SESSIONS) + 1, 0);
6513 /* Create multiple crypto sessions*/
6514 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6516 sessions[i] = rte_cryptodev_sym_session_create(
6517 ts_params->session_mpool);
6519 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6520 sessions[i], &ut_params->auth_xform,
6521 ts_params->session_mpool);
6522 TEST_ASSERT_NOT_NULL(sessions[i],
6523 "Session creation failed at session number %u",
6526 /* Attempt to send a request on each session */
6527 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6531 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6532 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6534 "Failed to perform decrypt on request number %u.", i);
6535 /* free crypto operation structure */
6537 rte_crypto_op_free(ut_params->op);
6540 * free mbuf - both obuf and ibuf are usually the same,
6541 * so check if they point at the same address is necessary,
6542 * to avoid freeing the mbuf twice.
6544 if (ut_params->obuf) {
6545 rte_pktmbuf_free(ut_params->obuf);
6546 if (ut_params->ibuf == ut_params->obuf)
6547 ut_params->ibuf = 0;
6548 ut_params->obuf = 0;
6550 if (ut_params->ibuf) {
6551 rte_pktmbuf_free(ut_params->ibuf);
6552 ut_params->ibuf = 0;
6556 /* Next session create should fail */
6557 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6558 sessions[i], &ut_params->auth_xform,
6559 ts_params->session_mpool);
6560 TEST_ASSERT_NULL(sessions[i],
6561 "Session creation succeeded unexpectedly!");
6563 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6564 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6566 rte_cryptodev_sym_session_free(sessions[i]);
6571 return TEST_SUCCESS;
6574 struct multi_session_params {
6575 struct crypto_unittest_params ut_params;
6576 uint8_t *cipher_key;
6578 const uint8_t *cipher;
6579 const uint8_t *digest;
6583 #define MB_SESSION_NUMBER 3
6586 test_multi_session_random_usage(void)
6588 struct crypto_testsuite_params *ts_params = &testsuite_params;
6589 struct rte_cryptodev_info dev_info;
6590 struct rte_cryptodev_sym_session **sessions;
6592 struct multi_session_params ut_paramz[] = {
6595 .cipher_key = ms_aes_cbc_key0,
6596 .hmac_key = ms_hmac_key0,
6597 .cipher = ms_aes_cbc_cipher0,
6598 .digest = ms_hmac_digest0,
6599 .iv = ms_aes_cbc_iv0
6602 .cipher_key = ms_aes_cbc_key1,
6603 .hmac_key = ms_hmac_key1,
6604 .cipher = ms_aes_cbc_cipher1,
6605 .digest = ms_hmac_digest1,
6606 .iv = ms_aes_cbc_iv1
6609 .cipher_key = ms_aes_cbc_key2,
6610 .hmac_key = ms_hmac_key2,
6611 .cipher = ms_aes_cbc_cipher2,
6612 .digest = ms_hmac_digest2,
6613 .iv = ms_aes_cbc_iv2
6618 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6620 sessions = rte_malloc(NULL,
6621 (sizeof(struct rte_cryptodev_sym_session *)
6622 * MAX_NB_SESSIONS) + 1, 0);
6624 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6625 sessions[i] = rte_cryptodev_sym_session_create(
6626 ts_params->session_mpool);
6628 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6629 sizeof(struct crypto_unittest_params));
6631 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6632 &ut_paramz[i].ut_params,
6633 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6635 /* Create multiple crypto sessions*/
6636 rte_cryptodev_sym_session_init(
6637 ts_params->valid_devs[0],
6639 &ut_paramz[i].ut_params.auth_xform,
6640 ts_params->session_mpool);
6642 TEST_ASSERT_NOT_NULL(sessions[i],
6643 "Session creation failed at session number %u",
6649 for (i = 0; i < 40000; i++) {
6651 j = rand() % MB_SESSION_NUMBER;
6653 TEST_ASSERT_SUCCESS(
6654 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6656 &ut_paramz[j].ut_params,
6657 ts_params, ut_paramz[j].cipher,
6658 ut_paramz[j].digest,
6660 "Failed to perform decrypt on request number %u.", i);
6662 if (ut_paramz[j].ut_params.op)
6663 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6666 * free mbuf - both obuf and ibuf are usually the same,
6667 * so check if they point at the same address is necessary,
6668 * to avoid freeing the mbuf twice.
6670 if (ut_paramz[j].ut_params.obuf) {
6671 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6672 if (ut_paramz[j].ut_params.ibuf
6673 == ut_paramz[j].ut_params.obuf)
6674 ut_paramz[j].ut_params.ibuf = 0;
6675 ut_paramz[j].ut_params.obuf = 0;
6677 if (ut_paramz[j].ut_params.ibuf) {
6678 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6679 ut_paramz[j].ut_params.ibuf = 0;
6683 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6684 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6686 rte_cryptodev_sym_session_free(sessions[i]);
6691 return TEST_SUCCESS;
6695 test_null_cipher_only_operation(void)
6697 struct crypto_testsuite_params *ts_params = &testsuite_params;
6698 struct crypto_unittest_params *ut_params = &unittest_params;
6700 /* Generate test mbuf data and space for digest */
6701 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6702 catch_22_quote, QUOTE_512_BYTES, 0);
6704 /* Setup Cipher Parameters */
6705 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6706 ut_params->cipher_xform.next = NULL;
6708 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6709 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6711 ut_params->sess = rte_cryptodev_sym_session_create(
6712 ts_params->session_mpool);
6714 /* Create Crypto session*/
6715 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6717 &ut_params->cipher_xform,
6718 ts_params->session_mpool);
6719 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6721 /* Generate Crypto op data structure */
6722 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6723 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6724 TEST_ASSERT_NOT_NULL(ut_params->op,
6725 "Failed to allocate symmetric crypto operation struct");
6727 /* Set crypto operation data parameters */
6728 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6730 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6732 /* set crypto operation source mbuf */
6733 sym_op->m_src = ut_params->ibuf;
6735 sym_op->cipher.data.offset = 0;
6736 sym_op->cipher.data.length = QUOTE_512_BYTES;
6738 /* Process crypto operation */
6739 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6741 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6743 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6744 "crypto operation processing failed");
6747 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6748 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6751 "Ciphertext data not as expected");
6753 return TEST_SUCCESS;
6755 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6756 0xab, 0xab, 0xab, 0xab,
6757 0xab, 0xab, 0xab, 0xab,
6758 0xab, 0xab, 0xab, 0xab};
6760 test_null_auth_only_operation(void)
6762 struct crypto_testsuite_params *ts_params = &testsuite_params;
6763 struct crypto_unittest_params *ut_params = &unittest_params;
6766 /* Generate test mbuf data and space for digest */
6767 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6768 catch_22_quote, QUOTE_512_BYTES, 0);
6770 /* create a pointer for digest, but don't expect anything to be written
6771 * here in a NULL auth algo so no mbuf append done.
6773 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6775 /* prefill the memory pointed to by digest */
6776 memcpy(digest, orig_data, sizeof(orig_data));
6778 /* Setup HMAC Parameters */
6779 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6780 ut_params->auth_xform.next = NULL;
6782 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6783 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6785 ut_params->sess = rte_cryptodev_sym_session_create(
6786 ts_params->session_mpool);
6788 /* Create Crypto session*/
6789 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6790 ut_params->sess, &ut_params->auth_xform,
6791 ts_params->session_mpool);
6792 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6794 /* Generate Crypto op data structure */
6795 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6796 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6797 TEST_ASSERT_NOT_NULL(ut_params->op,
6798 "Failed to allocate symmetric crypto operation struct");
6800 /* Set crypto operation data parameters */
6801 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6803 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6805 sym_op->m_src = ut_params->ibuf;
6807 sym_op->auth.data.offset = 0;
6808 sym_op->auth.data.length = QUOTE_512_BYTES;
6809 sym_op->auth.digest.data = digest;
6810 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6813 /* Process crypto operation */
6814 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6816 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6818 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6819 "crypto operation processing failed");
6820 /* Make sure memory pointed to by digest hasn't been overwritten */
6821 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6825 "Memory at digest ptr overwritten unexpectedly");
6827 return TEST_SUCCESS;
6832 test_null_cipher_auth_operation(void)
6834 struct crypto_testsuite_params *ts_params = &testsuite_params;
6835 struct crypto_unittest_params *ut_params = &unittest_params;
6838 /* Generate test mbuf data and space for digest */
6839 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6840 catch_22_quote, QUOTE_512_BYTES, 0);
6842 /* create a pointer for digest, but don't expect anything to be written
6843 * here in a NULL auth algo so no mbuf append done.
6845 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6847 /* prefill the memory pointed to by digest */
6848 memcpy(digest, orig_data, sizeof(orig_data));
6850 /* Setup Cipher Parameters */
6851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6852 ut_params->cipher_xform.next = &ut_params->auth_xform;
6854 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6855 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6857 /* Setup HMAC Parameters */
6858 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6859 ut_params->auth_xform.next = NULL;
6861 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6862 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6864 ut_params->sess = rte_cryptodev_sym_session_create(
6865 ts_params->session_mpool);
6867 /* Create Crypto session*/
6868 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6869 ut_params->sess, &ut_params->cipher_xform,
6870 ts_params->session_mpool);
6871 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6873 /* Generate Crypto op data structure */
6874 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6875 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6876 TEST_ASSERT_NOT_NULL(ut_params->op,
6877 "Failed to allocate symmetric crypto operation struct");
6879 /* Set crypto operation data parameters */
6880 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6884 sym_op->m_src = ut_params->ibuf;
6886 sym_op->cipher.data.offset = 0;
6887 sym_op->cipher.data.length = QUOTE_512_BYTES;
6889 sym_op->auth.data.offset = 0;
6890 sym_op->auth.data.length = QUOTE_512_BYTES;
6891 sym_op->auth.digest.data = digest;
6892 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6895 /* Process crypto operation */
6896 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6898 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6900 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6901 "crypto operation processing failed");
6904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6905 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6908 "Ciphertext data not as expected");
6909 /* Make sure memory pointed to by digest hasn't been overwritten */
6910 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6914 "Memory at digest ptr overwritten unexpectedly");
6916 return TEST_SUCCESS;
6920 test_null_auth_cipher_operation(void)
6922 struct crypto_testsuite_params *ts_params = &testsuite_params;
6923 struct crypto_unittest_params *ut_params = &unittest_params;
6926 /* Generate test mbuf data */
6927 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6928 catch_22_quote, QUOTE_512_BYTES, 0);
6930 /* create a pointer for digest, but don't expect anything to be written
6931 * here in a NULL auth algo so no mbuf append done.
6933 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6935 /* prefill the memory pointed to by digest */
6936 memcpy(digest, orig_data, sizeof(orig_data));
6938 /* Setup Cipher Parameters */
6939 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6940 ut_params->cipher_xform.next = NULL;
6942 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6943 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6945 /* Setup HMAC Parameters */
6946 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6947 ut_params->auth_xform.next = &ut_params->cipher_xform;
6949 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6950 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6952 ut_params->sess = rte_cryptodev_sym_session_create(
6953 ts_params->session_mpool);
6955 /* Create Crypto session*/
6956 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6957 ut_params->sess, &ut_params->cipher_xform,
6958 ts_params->session_mpool);
6959 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6961 /* Generate Crypto op data structure */
6962 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6963 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6964 TEST_ASSERT_NOT_NULL(ut_params->op,
6965 "Failed to allocate symmetric crypto operation struct");
6967 /* Set crypto operation data parameters */
6968 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6970 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6972 sym_op->m_src = ut_params->ibuf;
6974 sym_op->cipher.data.offset = 0;
6975 sym_op->cipher.data.length = QUOTE_512_BYTES;
6977 sym_op->auth.data.offset = 0;
6978 sym_op->auth.data.length = QUOTE_512_BYTES;
6979 sym_op->auth.digest.data = digest;
6980 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6983 /* Process crypto operation */
6984 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6986 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6988 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6989 "crypto operation processing failed");
6992 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6993 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6996 "Ciphertext data not as expected");
6997 /* Make sure memory pointed to by digest hasn't been overwritten */
6998 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7002 "Memory at digest ptr overwritten unexpectedly");
7004 return TEST_SUCCESS;
7009 test_null_invalid_operation(void)
7011 struct crypto_testsuite_params *ts_params = &testsuite_params;
7012 struct crypto_unittest_params *ut_params = &unittest_params;
7015 /* Setup Cipher Parameters */
7016 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7017 ut_params->cipher_xform.next = NULL;
7019 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7020 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7022 ut_params->sess = rte_cryptodev_sym_session_create(
7023 ts_params->session_mpool);
7025 /* Create Crypto session*/
7026 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7027 ut_params->sess, &ut_params->cipher_xform,
7028 ts_params->session_mpool);
7029 TEST_ASSERT(ret < 0,
7030 "Session creation succeeded unexpectedly");
7033 /* Setup HMAC Parameters */
7034 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7035 ut_params->auth_xform.next = NULL;
7037 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7038 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7040 ut_params->sess = rte_cryptodev_sym_session_create(
7041 ts_params->session_mpool);
7043 /* Create Crypto session*/
7044 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7045 ut_params->sess, &ut_params->auth_xform,
7046 ts_params->session_mpool);
7047 TEST_ASSERT(ret < 0,
7048 "Session creation succeeded unexpectedly");
7050 return TEST_SUCCESS;
7054 #define NULL_BURST_LENGTH (32)
7057 test_null_burst_operation(void)
7059 struct crypto_testsuite_params *ts_params = &testsuite_params;
7060 struct crypto_unittest_params *ut_params = &unittest_params;
7062 unsigned i, burst_len = NULL_BURST_LENGTH;
7064 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7065 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7067 /* Setup Cipher Parameters */
7068 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7069 ut_params->cipher_xform.next = &ut_params->auth_xform;
7071 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7072 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7074 /* Setup HMAC Parameters */
7075 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7076 ut_params->auth_xform.next = NULL;
7078 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7079 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7081 ut_params->sess = rte_cryptodev_sym_session_create(
7082 ts_params->session_mpool);
7084 /* Create Crypto session*/
7085 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7086 ut_params->sess, &ut_params->cipher_xform,
7087 ts_params->session_mpool);
7088 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7090 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7091 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7092 burst_len, "failed to generate burst of crypto ops");
7094 /* Generate an operation for each mbuf in burst */
7095 for (i = 0; i < burst_len; i++) {
7096 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7098 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7100 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7104 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7106 burst[i]->sym->m_src = m;
7109 /* Process crypto operation */
7110 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7111 0, burst, burst_len),
7113 "Error enqueuing burst");
7115 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7116 0, burst_dequeued, burst_len),
7118 "Error dequeuing burst");
7121 for (i = 0; i < burst_len; i++) {
7123 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7124 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7126 "data not as expected");
7128 rte_pktmbuf_free(burst[i]->sym->m_src);
7129 rte_crypto_op_free(burst[i]);
7132 return TEST_SUCCESS;
7136 generate_gmac_large_plaintext(uint8_t *data)
7140 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7141 memcpy(&data[i], &data[0], 32);
7145 create_gmac_operation(enum rte_crypto_auth_operation op,
7146 const struct gmac_test_data *tdata)
7148 struct crypto_testsuite_params *ts_params = &testsuite_params;
7149 struct crypto_unittest_params *ut_params = &unittest_params;
7150 struct rte_crypto_sym_op *sym_op;
7152 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7154 /* Generate Crypto op data structure */
7155 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7156 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7157 TEST_ASSERT_NOT_NULL(ut_params->op,
7158 "Failed to allocate symmetric crypto operation struct");
7160 sym_op = ut_params->op->sym;
7162 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7163 ut_params->ibuf, tdata->gmac_tag.len);
7164 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7165 "no room to append digest");
7167 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7168 ut_params->ibuf, plaintext_pad_len);
7170 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7171 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7172 tdata->gmac_tag.len);
7173 debug_hexdump(stdout, "digest:",
7174 sym_op->auth.digest.data,
7175 tdata->gmac_tag.len);
7178 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7179 uint8_t *, IV_OFFSET);
7181 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7183 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7185 sym_op->cipher.data.length = 0;
7186 sym_op->cipher.data.offset = 0;
7188 sym_op->auth.data.offset = 0;
7189 sym_op->auth.data.length = tdata->plaintext.len;
7194 static int create_gmac_session(uint8_t dev_id,
7195 const struct gmac_test_data *tdata,
7196 enum rte_crypto_auth_operation auth_op)
7198 uint8_t auth_key[tdata->key.len];
7200 struct crypto_testsuite_params *ts_params = &testsuite_params;
7201 struct crypto_unittest_params *ut_params = &unittest_params;
7203 memcpy(auth_key, tdata->key.data, tdata->key.len);
7205 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7206 ut_params->auth_xform.next = NULL;
7208 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7209 ut_params->auth_xform.auth.op = auth_op;
7210 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7211 ut_params->auth_xform.auth.key.length = tdata->key.len;
7212 ut_params->auth_xform.auth.key.data = auth_key;
7213 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7214 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7217 ut_params->sess = rte_cryptodev_sym_session_create(
7218 ts_params->session_mpool);
7220 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7221 &ut_params->auth_xform,
7222 ts_params->session_mpool);
7224 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7230 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7232 struct crypto_testsuite_params *ts_params = &testsuite_params;
7233 struct crypto_unittest_params *ut_params = &unittest_params;
7237 uint8_t *auth_tag, *plaintext;
7238 uint16_t plaintext_pad_len;
7240 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7241 "No GMAC length in the source data");
7243 retval = create_gmac_session(ts_params->valid_devs[0],
7244 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7249 if (tdata->plaintext.len > MBUF_SIZE)
7250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7253 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7254 "Failed to allocate input buffer in mempool");
7256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7257 rte_pktmbuf_tailroom(ut_params->ibuf));
7259 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7261 * Runtime generate the large plain text instead of use hard code
7262 * plain text vector. It is done to avoid create huge source file
7263 * with the test vector.
7265 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7266 generate_gmac_large_plaintext(tdata->plaintext.data);
7268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7270 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7272 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7273 debug_hexdump(stdout, "plaintext:", plaintext,
7274 tdata->plaintext.len);
7276 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7282 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7284 ut_params->op->sym->m_src = ut_params->ibuf;
7286 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7287 ut_params->op), "failed to process sym crypto op");
7289 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7290 "crypto op processing failed");
7292 if (ut_params->op->sym->m_dst) {
7293 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7294 uint8_t *, plaintext_pad_len);
7296 auth_tag = plaintext + plaintext_pad_len;
7299 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7303 tdata->gmac_tag.data,
7304 tdata->gmac_tag.len,
7305 "GMAC Generated auth tag not as expected");
7311 test_AES_GMAC_authentication_test_case_1(void)
7313 return test_AES_GMAC_authentication(&gmac_test_case_1);
7317 test_AES_GMAC_authentication_test_case_2(void)
7319 return test_AES_GMAC_authentication(&gmac_test_case_2);
7323 test_AES_GMAC_authentication_test_case_3(void)
7325 return test_AES_GMAC_authentication(&gmac_test_case_3);
7329 test_AES_GMAC_authentication_test_case_4(void)
7331 return test_AES_GMAC_authentication(&gmac_test_case_4);
7335 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7337 struct crypto_testsuite_params *ts_params = &testsuite_params;
7338 struct crypto_unittest_params *ut_params = &unittest_params;
7340 uint32_t plaintext_pad_len;
7343 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7344 "No GMAC length in the source data");
7346 retval = create_gmac_session(ts_params->valid_devs[0],
7347 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7352 if (tdata->plaintext.len > MBUF_SIZE)
7353 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7355 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7356 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7357 "Failed to allocate input buffer in mempool");
7359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7360 rte_pktmbuf_tailroom(ut_params->ibuf));
7362 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7365 * Runtime generate the large plain text instead of use hard code
7366 * plain text vector. It is done to avoid create huge source file
7367 * with the test vector.
7369 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7370 generate_gmac_large_plaintext(tdata->plaintext.data);
7372 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7374 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7376 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7377 debug_hexdump(stdout, "plaintext:", plaintext,
7378 tdata->plaintext.len);
7380 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7386 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7388 ut_params->op->sym->m_src = ut_params->ibuf;
7390 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7391 ut_params->op), "failed to process sym crypto op");
7393 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7394 "crypto op processing failed");
7401 test_AES_GMAC_authentication_verify_test_case_1(void)
7403 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7407 test_AES_GMAC_authentication_verify_test_case_2(void)
7409 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7413 test_AES_GMAC_authentication_verify_test_case_3(void)
7415 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7419 test_AES_GMAC_authentication_verify_test_case_4(void)
7421 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7424 struct test_crypto_vector {
7425 enum rte_crypto_cipher_algorithm crypto_algo;
7438 const uint8_t *data;
7443 const uint8_t *data;
7447 enum rte_crypto_auth_algorithm auth_algo;
7455 const uint8_t *data;
7465 static const struct test_crypto_vector
7466 hmac_sha1_test_crypto_vector = {
7467 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7469 .data = plaintext_hash,
7474 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7475 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7476 0xDE, 0xF4, 0xDE, 0xAD
7482 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7483 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7484 0x3F, 0x91, 0x64, 0x59
7490 static const struct test_crypto_vector
7491 aes128_gmac_test_vector = {
7492 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7494 .data = plaintext_hash,
7499 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7500 0x08, 0x09, 0x0A, 0x0B
7506 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7507 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7513 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7514 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7520 static const struct test_crypto_vector
7521 aes128cbc_hmac_sha1_test_vector = {
7522 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7525 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7526 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7532 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7533 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7538 .data = plaintext_hash,
7542 .data = ciphertext512_aes128cbc,
7545 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7548 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7549 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7550 0xDE, 0xF4, 0xDE, 0xAD
7556 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7557 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7558 0x18, 0x8C, 0x1D, 0x32
7565 data_corruption(uint8_t *data)
7571 tag_corruption(uint8_t *data, unsigned int tag_offset)
7573 data[tag_offset] += 1;
7577 create_auth_session(struct crypto_unittest_params *ut_params,
7579 const struct test_crypto_vector *reference,
7580 enum rte_crypto_auth_operation auth_op)
7582 struct crypto_testsuite_params *ts_params = &testsuite_params;
7583 uint8_t auth_key[reference->auth_key.len + 1];
7585 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7587 /* Setup Authentication Parameters */
7588 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7589 ut_params->auth_xform.auth.op = auth_op;
7590 ut_params->auth_xform.next = NULL;
7591 ut_params->auth_xform.auth.algo = reference->auth_algo;
7592 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7593 ut_params->auth_xform.auth.key.data = auth_key;
7594 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7596 /* Create Crypto session*/
7597 ut_params->sess = rte_cryptodev_sym_session_create(
7598 ts_params->session_mpool);
7600 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7601 &ut_params->auth_xform,
7602 ts_params->session_mpool);
7604 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7610 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7612 const struct test_crypto_vector *reference,
7613 enum rte_crypto_auth_operation auth_op,
7614 enum rte_crypto_cipher_operation cipher_op)
7616 struct crypto_testsuite_params *ts_params = &testsuite_params;
7617 uint8_t cipher_key[reference->cipher_key.len + 1];
7618 uint8_t auth_key[reference->auth_key.len + 1];
7620 memcpy(cipher_key, reference->cipher_key.data,
7621 reference->cipher_key.len);
7622 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7624 /* Setup Authentication Parameters */
7625 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7626 ut_params->auth_xform.auth.op = auth_op;
7627 ut_params->auth_xform.auth.algo = reference->auth_algo;
7628 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7629 ut_params->auth_xform.auth.key.data = auth_key;
7630 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7632 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7633 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7634 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7636 ut_params->auth_xform.next = &ut_params->cipher_xform;
7638 /* Setup Cipher Parameters */
7639 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7640 ut_params->cipher_xform.next = NULL;
7641 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7642 ut_params->cipher_xform.cipher.op = cipher_op;
7643 ut_params->cipher_xform.cipher.key.data = cipher_key;
7644 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7645 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7646 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7649 /* Create Crypto session*/
7650 ut_params->sess = rte_cryptodev_sym_session_create(
7651 ts_params->session_mpool);
7653 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7654 &ut_params->auth_xform,
7655 ts_params->session_mpool);
7657 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7663 create_auth_operation(struct crypto_testsuite_params *ts_params,
7664 struct crypto_unittest_params *ut_params,
7665 const struct test_crypto_vector *reference,
7666 unsigned int auth_generate)
7668 /* Generate Crypto op data structure */
7669 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7670 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7671 TEST_ASSERT_NOT_NULL(ut_params->op,
7672 "Failed to allocate pktmbuf offload");
7674 /* Set crypto operation data parameters */
7675 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7677 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7679 /* set crypto operation source mbuf */
7680 sym_op->m_src = ut_params->ibuf;
7683 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7684 ut_params->ibuf, reference->digest.len);
7686 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7687 "no room to append auth tag");
7689 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7690 ut_params->ibuf, reference->plaintext.len);
7693 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7695 memcpy(sym_op->auth.digest.data,
7696 reference->digest.data,
7697 reference->digest.len);
7699 debug_hexdump(stdout, "digest:",
7700 sym_op->auth.digest.data,
7701 reference->digest.len);
7703 sym_op->auth.data.length = reference->plaintext.len;
7704 sym_op->auth.data.offset = 0;
7710 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7711 struct crypto_unittest_params *ut_params,
7712 const struct test_crypto_vector *reference,
7713 unsigned int auth_generate)
7715 /* Generate Crypto op data structure */
7716 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7717 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7718 TEST_ASSERT_NOT_NULL(ut_params->op,
7719 "Failed to allocate pktmbuf offload");
7721 /* Set crypto operation data parameters */
7722 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7724 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7726 /* set crypto operation source mbuf */
7727 sym_op->m_src = ut_params->ibuf;
7730 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7731 ut_params->ibuf, reference->digest.len);
7733 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7734 "no room to append auth tag");
7736 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7737 ut_params->ibuf, reference->ciphertext.len);
7740 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7742 memcpy(sym_op->auth.digest.data,
7743 reference->digest.data,
7744 reference->digest.len);
7746 debug_hexdump(stdout, "digest:",
7747 sym_op->auth.digest.data,
7748 reference->digest.len);
7750 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7751 reference->iv.data, reference->iv.len);
7753 sym_op->cipher.data.length = 0;
7754 sym_op->cipher.data.offset = 0;
7756 sym_op->auth.data.length = reference->plaintext.len;
7757 sym_op->auth.data.offset = 0;
7763 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7764 struct crypto_unittest_params *ut_params,
7765 const struct test_crypto_vector *reference,
7766 unsigned int auth_generate)
7768 /* Generate Crypto op data structure */
7769 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7770 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7771 TEST_ASSERT_NOT_NULL(ut_params->op,
7772 "Failed to allocate pktmbuf offload");
7774 /* Set crypto operation data parameters */
7775 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7777 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7779 /* set crypto operation source mbuf */
7780 sym_op->m_src = ut_params->ibuf;
7783 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7784 ut_params->ibuf, reference->digest.len);
7786 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7787 "no room to append auth tag");
7789 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7790 ut_params->ibuf, reference->ciphertext.len);
7793 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7795 memcpy(sym_op->auth.digest.data,
7796 reference->digest.data,
7797 reference->digest.len);
7799 debug_hexdump(stdout, "digest:",
7800 sym_op->auth.digest.data,
7801 reference->digest.len);
7803 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7804 reference->iv.data, reference->iv.len);
7806 sym_op->cipher.data.length = reference->ciphertext.len;
7807 sym_op->cipher.data.offset = 0;
7809 sym_op->auth.data.length = reference->ciphertext.len;
7810 sym_op->auth.data.offset = 0;
7816 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7817 struct crypto_unittest_params *ut_params,
7818 const struct test_crypto_vector *reference)
7820 return create_auth_operation(ts_params, ut_params, reference, 0);
7824 create_auth_verify_GMAC_operation(
7825 struct crypto_testsuite_params *ts_params,
7826 struct crypto_unittest_params *ut_params,
7827 const struct test_crypto_vector *reference)
7829 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7833 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7834 struct crypto_unittest_params *ut_params,
7835 const struct test_crypto_vector *reference)
7837 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7841 test_authentication_verify_fail_when_data_corruption(
7842 struct crypto_testsuite_params *ts_params,
7843 struct crypto_unittest_params *ut_params,
7844 const struct test_crypto_vector *reference,
7845 unsigned int data_corrupted)
7851 /* Create session */
7852 retval = create_auth_session(ut_params,
7853 ts_params->valid_devs[0],
7855 RTE_CRYPTO_AUTH_OP_VERIFY);
7859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7860 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7861 "Failed to allocate input buffer in mempool");
7863 /* clear mbuf payload */
7864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7865 rte_pktmbuf_tailroom(ut_params->ibuf));
7867 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7868 reference->plaintext.len);
7869 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7870 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7872 debug_hexdump(stdout, "plaintext:", plaintext,
7873 reference->plaintext.len);
7875 /* Create operation */
7876 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7882 data_corruption(plaintext);
7884 tag_corruption(plaintext, reference->plaintext.len);
7886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7888 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7889 TEST_ASSERT_EQUAL(ut_params->op->status,
7890 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7891 "authentication not failed");
7893 ut_params->obuf = ut_params->op->sym->m_src;
7894 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7900 test_authentication_verify_GMAC_fail_when_corruption(
7901 struct crypto_testsuite_params *ts_params,
7902 struct crypto_unittest_params *ut_params,
7903 const struct test_crypto_vector *reference,
7904 unsigned int data_corrupted)
7909 /* Create session */
7910 retval = create_auth_cipher_session(ut_params,
7911 ts_params->valid_devs[0],
7913 RTE_CRYPTO_AUTH_OP_VERIFY,
7914 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7919 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7920 "Failed to allocate input buffer in mempool");
7922 /* clear mbuf payload */
7923 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7924 rte_pktmbuf_tailroom(ut_params->ibuf));
7926 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7927 reference->plaintext.len);
7928 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7929 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7931 debug_hexdump(stdout, "plaintext:", plaintext,
7932 reference->plaintext.len);
7934 /* Create operation */
7935 retval = create_auth_verify_GMAC_operation(ts_params,
7943 data_corruption(plaintext);
7945 tag_corruption(plaintext, reference->aad.len);
7947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7950 TEST_ASSERT_EQUAL(ut_params->op->status,
7951 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7952 "authentication not failed");
7954 ut_params->obuf = ut_params->op->sym->m_src;
7955 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7961 test_authenticated_decryption_fail_when_corruption(
7962 struct crypto_testsuite_params *ts_params,
7963 struct crypto_unittest_params *ut_params,
7964 const struct test_crypto_vector *reference,
7965 unsigned int data_corrupted)
7969 uint8_t *ciphertext;
7971 /* Create session */
7972 retval = create_auth_cipher_session(ut_params,
7973 ts_params->valid_devs[0],
7975 RTE_CRYPTO_AUTH_OP_VERIFY,
7976 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7981 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7982 "Failed to allocate input buffer in mempool");
7984 /* clear mbuf payload */
7985 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7986 rte_pktmbuf_tailroom(ut_params->ibuf));
7988 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7989 reference->ciphertext.len);
7990 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7991 memcpy(ciphertext, reference->ciphertext.data,
7992 reference->ciphertext.len);
7994 /* Create operation */
7995 retval = create_cipher_auth_verify_operation(ts_params,
8003 data_corruption(ciphertext);
8005 tag_corruption(ciphertext, reference->ciphertext.len);
8007 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8010 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8011 TEST_ASSERT_EQUAL(ut_params->op->status,
8012 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8013 "authentication not failed");
8015 ut_params->obuf = ut_params->op->sym->m_src;
8016 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8022 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8023 const struct aead_test_data *tdata,
8024 void *digest_mem, uint64_t digest_phys)
8026 struct crypto_testsuite_params *ts_params = &testsuite_params;
8027 struct crypto_unittest_params *ut_params = &unittest_params;
8029 const unsigned int auth_tag_len = tdata->auth_tag.len;
8030 const unsigned int iv_len = tdata->iv.len;
8031 unsigned int aad_len = tdata->aad.len;
8033 /* Generate Crypto op data structure */
8034 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8035 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8036 TEST_ASSERT_NOT_NULL(ut_params->op,
8037 "Failed to allocate symmetric crypto operation struct");
8039 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8041 sym_op->aead.digest.data = digest_mem;
8043 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8044 "no room to append digest");
8046 sym_op->aead.digest.phys_addr = digest_phys;
8048 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8049 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8051 debug_hexdump(stdout, "digest:",
8052 sym_op->aead.digest.data,
8056 /* Append aad data */
8057 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8058 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8059 uint8_t *, IV_OFFSET);
8061 /* Copy IV 1 byte after the IV pointer, according to the API */
8062 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8064 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8066 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8067 ut_params->ibuf, aad_len);
8068 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8069 "no room to prepend aad");
8070 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8073 memset(sym_op->aead.aad.data, 0, aad_len);
8074 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8075 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8077 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8078 debug_hexdump(stdout, "aad:",
8079 sym_op->aead.aad.data, aad_len);
8081 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8082 uint8_t *, IV_OFFSET);
8084 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8086 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8087 ut_params->ibuf, aad_len);
8088 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8089 "no room to prepend aad");
8090 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8093 memset(sym_op->aead.aad.data, 0, aad_len);
8094 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8096 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8097 debug_hexdump(stdout, "aad:",
8098 sym_op->aead.aad.data, aad_len);
8101 sym_op->aead.data.length = tdata->plaintext.len;
8102 sym_op->aead.data.offset = aad_len;
8107 #define SGL_MAX_NO 16
8110 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8111 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8113 struct crypto_testsuite_params *ts_params = &testsuite_params;
8114 struct crypto_unittest_params *ut_params = &unittest_params;
8115 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8118 int to_trn_tbl[SGL_MAX_NO];
8120 unsigned int trn_data = 0;
8121 uint8_t *plaintext, *ciphertext, *auth_tag;
8123 if (fragsz > tdata->plaintext.len)
8124 fragsz = tdata->plaintext.len;
8126 uint16_t plaintext_len = fragsz;
8127 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8129 if (fragsz_oop > tdata->plaintext.len)
8130 frag_size_oop = tdata->plaintext.len;
8133 void *digest_mem = NULL;
8135 uint32_t prepend_len = tdata->aad.len;
8137 if (tdata->plaintext.len % fragsz != 0) {
8138 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8141 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8146 * For out-op-place we need to alloc another mbuf
8149 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8150 rte_pktmbuf_append(ut_params->obuf,
8151 frag_size_oop + prepend_len);
8152 buf_oop = ut_params->obuf;
8155 /* Create AEAD session */
8156 retval = create_aead_session(ts_params->valid_devs[0],
8158 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8159 tdata->key.data, tdata->key.len,
8160 tdata->aad.len, tdata->auth_tag.len,
8165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8167 /* clear mbuf payload */
8168 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8169 rte_pktmbuf_tailroom(ut_params->ibuf));
8171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8174 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8176 trn_data += plaintext_len;
8178 buf = ut_params->ibuf;
8181 * Loop until no more fragments
8184 while (trn_data < tdata->plaintext.len) {
8186 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8187 (tdata->plaintext.len - trn_data) : fragsz;
8189 to_trn_tbl[ecx++] = to_trn;
8191 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8194 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8195 rte_pktmbuf_tailroom(buf));
8198 if (oop && !fragsz_oop) {
8199 buf_last_oop = buf_oop->next =
8200 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8201 buf_oop = buf_oop->next;
8202 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8203 0, rte_pktmbuf_tailroom(buf_oop));
8204 rte_pktmbuf_append(buf_oop, to_trn);
8207 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8210 memcpy(plaintext, tdata->plaintext.data + trn_data,
8213 if (trn_data == tdata->plaintext.len) {
8216 digest_mem = rte_pktmbuf_append(buf_oop,
8217 tdata->auth_tag.len);
8219 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8220 tdata->auth_tag.len);
8224 uint64_t digest_phys = 0;
8226 ut_params->ibuf->nb_segs = segs;
8229 if (fragsz_oop && oop) {
8233 if (frag_size_oop == tdata->plaintext.len) {
8234 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8235 tdata->auth_tag.len);
8237 digest_phys = rte_pktmbuf_iova_offset(
8239 tdata->plaintext.len + prepend_len);
8242 trn_data = frag_size_oop;
8243 while (trn_data < tdata->plaintext.len) {
8246 (tdata->plaintext.len - trn_data <
8248 (tdata->plaintext.len - trn_data) :
8251 to_trn_tbl[ecx++] = to_trn;
8253 buf_last_oop = buf_oop->next =
8254 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8255 buf_oop = buf_oop->next;
8256 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8257 0, rte_pktmbuf_tailroom(buf_oop));
8258 rte_pktmbuf_append(buf_oop, to_trn);
8262 if (trn_data == tdata->plaintext.len) {
8263 digest_mem = rte_pktmbuf_append(buf_oop,
8264 tdata->auth_tag.len);
8268 ut_params->obuf->nb_segs = segs;
8272 * Place digest at the end of the last buffer
8275 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8276 if (oop && buf_last_oop)
8277 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8279 if (!digest_mem && !oop) {
8280 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8281 + tdata->auth_tag.len);
8282 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8283 tdata->plaintext.len);
8286 /* Create AEAD operation */
8287 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8288 tdata, digest_mem, digest_phys);
8293 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8295 ut_params->op->sym->m_src = ut_params->ibuf;
8297 ut_params->op->sym->m_dst = ut_params->obuf;
8299 /* Process crypto operation */
8300 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8301 ut_params->op), "failed to process sym crypto op");
8303 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8304 "crypto op processing failed");
8307 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8308 uint8_t *, prepend_len);
8310 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8311 uint8_t *, prepend_len);
8315 fragsz = fragsz_oop;
8317 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8319 tdata->ciphertext.data,
8321 "Ciphertext data not as expected");
8323 buf = ut_params->op->sym->m_src->next;
8325 buf = ut_params->op->sym->m_dst->next;
8327 unsigned int off = fragsz;
8331 ciphertext = rte_pktmbuf_mtod(buf,
8334 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8336 tdata->ciphertext.data + off,
8338 "Ciphertext data not as expected");
8340 off += to_trn_tbl[ecx++];
8344 auth_tag = digest_mem;
8345 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8347 tdata->auth_tag.data,
8348 tdata->auth_tag.len,
8349 "Generated auth tag not as expected");
8355 #define OUT_OF_PLACE 1
8358 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8360 return test_authenticated_encryption_SGL(
8361 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8365 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8367 return test_authenticated_encryption_SGL(
8368 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8372 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8374 return test_authenticated_encryption_SGL(
8375 &gcm_test_case_8, OUT_OF_PLACE, 400,
8376 gcm_test_case_8.plaintext.len);
8380 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8383 return test_authenticated_encryption_SGL(
8384 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8388 test_authentication_verify_fail_when_data_corrupted(
8389 struct crypto_testsuite_params *ts_params,
8390 struct crypto_unittest_params *ut_params,
8391 const struct test_crypto_vector *reference)
8393 return test_authentication_verify_fail_when_data_corruption(
8394 ts_params, ut_params, reference, 1);
8398 test_authentication_verify_fail_when_tag_corrupted(
8399 struct crypto_testsuite_params *ts_params,
8400 struct crypto_unittest_params *ut_params,
8401 const struct test_crypto_vector *reference)
8403 return test_authentication_verify_fail_when_data_corruption(
8404 ts_params, ut_params, reference, 0);
8408 test_authentication_verify_GMAC_fail_when_data_corrupted(
8409 struct crypto_testsuite_params *ts_params,
8410 struct crypto_unittest_params *ut_params,
8411 const struct test_crypto_vector *reference)
8413 return test_authentication_verify_GMAC_fail_when_corruption(
8414 ts_params, ut_params, reference, 1);
8418 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8419 struct crypto_testsuite_params *ts_params,
8420 struct crypto_unittest_params *ut_params,
8421 const struct test_crypto_vector *reference)
8423 return test_authentication_verify_GMAC_fail_when_corruption(
8424 ts_params, ut_params, reference, 0);
8428 test_authenticated_decryption_fail_when_data_corrupted(
8429 struct crypto_testsuite_params *ts_params,
8430 struct crypto_unittest_params *ut_params,
8431 const struct test_crypto_vector *reference)
8433 return test_authenticated_decryption_fail_when_corruption(
8434 ts_params, ut_params, reference, 1);
8438 test_authenticated_decryption_fail_when_tag_corrupted(
8439 struct crypto_testsuite_params *ts_params,
8440 struct crypto_unittest_params *ut_params,
8441 const struct test_crypto_vector *reference)
8443 return test_authenticated_decryption_fail_when_corruption(
8444 ts_params, ut_params, reference, 0);
8448 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8450 return test_authentication_verify_fail_when_data_corrupted(
8451 &testsuite_params, &unittest_params,
8452 &hmac_sha1_test_crypto_vector);
8456 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8458 return test_authentication_verify_fail_when_tag_corrupted(
8459 &testsuite_params, &unittest_params,
8460 &hmac_sha1_test_crypto_vector);
8464 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8466 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8467 &testsuite_params, &unittest_params,
8468 &aes128_gmac_test_vector);
8472 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8474 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8475 &testsuite_params, &unittest_params,
8476 &aes128_gmac_test_vector);
8480 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8482 return test_authenticated_decryption_fail_when_data_corrupted(
8485 &aes128cbc_hmac_sha1_test_vector);
8489 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8491 return test_authenticated_decryption_fail_when_tag_corrupted(
8494 &aes128cbc_hmac_sha1_test_vector);
8497 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8499 /* global AESNI slave IDs for the scheduler test */
8500 uint8_t aesni_ids[2];
8503 test_scheduler_attach_slave_op(void)
8505 struct crypto_testsuite_params *ts_params = &testsuite_params;
8506 uint8_t sched_id = ts_params->valid_devs[0];
8507 uint32_t nb_devs, i, nb_devs_attached = 0;
8511 /* create 2 AESNI_MB if necessary */
8512 nb_devs = rte_cryptodev_device_count_by_driver(
8513 rte_cryptodev_driver_id_get(
8514 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8516 for (i = nb_devs; i < 2; i++) {
8517 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8518 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8520 ret = rte_vdev_init(vdev_name, NULL);
8522 TEST_ASSERT(ret == 0,
8523 "Failed to create instance %u of"
8525 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8529 /* attach 2 AESNI_MB cdevs */
8530 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8532 struct rte_cryptodev_info info;
8534 rte_cryptodev_info_get(i, &info);
8535 if (info.driver_id != rte_cryptodev_driver_id_get(
8536 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8540 * Create the session mempool again, since now there are new devices
8541 * to use the mempool.
8543 if (ts_params->session_mpool) {
8544 rte_mempool_free(ts_params->session_mpool);
8545 ts_params->session_mpool = NULL;
8547 unsigned int session_size =
8548 rte_cryptodev_sym_get_private_session_size(i);
8550 if (info.sym.max_nb_sessions != 0 &&
8551 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8553 "Device does not support "
8554 "at least %u sessions\n",
8559 * Create mempool with maximum number of sessions * 2,
8560 * to include the session headers
8562 if (ts_params->session_mpool == NULL) {
8563 ts_params->session_mpool = rte_mempool_create(
8565 MAX_NB_SESSIONS * 2,
8567 0, 0, NULL, NULL, NULL,
8568 NULL, SOCKET_ID_ANY,
8571 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8572 "session mempool allocation failed");
8575 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8578 TEST_ASSERT(ret == 0,
8579 "Failed to attach device %u of pmd : %s", i,
8580 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8582 aesni_ids[nb_devs_attached] = (uint8_t)i;
8591 test_scheduler_detach_slave_op(void)
8593 struct crypto_testsuite_params *ts_params = &testsuite_params;
8594 uint8_t sched_id = ts_params->valid_devs[0];
8598 for (i = 0; i < 2; i++) {
8599 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8601 TEST_ASSERT(ret == 0,
8602 "Failed to detach device %u", aesni_ids[i]);
8609 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8611 struct crypto_testsuite_params *ts_params = &testsuite_params;
8612 uint8_t sched_id = ts_params->valid_devs[0];
8614 return rte_cryptodev_scheduler_mode_set(sched_id,
8619 test_scheduler_mode_roundrobin_op(void)
8621 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8622 0, "Failed to set roundrobin mode");
8628 test_scheduler_mode_multicore_op(void)
8630 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8631 0, "Failed to set multicore mode");
8637 test_scheduler_mode_failover_op(void)
8639 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8640 0, "Failed to set failover mode");
8646 test_scheduler_mode_pkt_size_distr_op(void)
8648 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8649 0, "Failed to set pktsize mode");
8654 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8655 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8656 .setup = testsuite_setup,
8657 .teardown = testsuite_teardown,
8658 .unit_test_cases = {
8660 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8661 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_AES_chain_scheduler_all),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_AES_cipheronly_scheduler_all),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_authonly_scheduler_all),
8668 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8671 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8672 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_AES_chain_scheduler_all),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_AES_cipheronly_scheduler_all),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_authonly_scheduler_all),
8679 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8682 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8683 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_AES_chain_scheduler_all),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_AES_cipheronly_scheduler_all),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_authonly_scheduler_all),
8690 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8693 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8694 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_AES_chain_scheduler_all),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_AES_cipheronly_scheduler_all),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_authonly_scheduler_all),
8701 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8703 TEST_CASES_END() /**< NULL terminate unit test array */
8707 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8709 static struct unit_test_suite cryptodev_qat_testsuite = {
8710 .suite_name = "Crypto QAT Unit Test Suite",
8711 .setup = testsuite_setup,
8712 .teardown = testsuite_teardown,
8713 .unit_test_cases = {
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_device_configure_invalid_dev_id),
8716 TEST_CASE_ST(ut_setup, ut_teardown,
8717 test_device_configure_invalid_queue_pair_ids),
8718 TEST_CASE_ST(ut_setup, ut_teardown,
8719 test_queue_pair_descriptor_setup),
8720 TEST_CASE_ST(ut_setup, ut_teardown,
8721 test_multi_session),
8723 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 test_AES_cipheronly_qat_all),
8726 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_3DES_cipheronly_qat_all),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_DES_cipheronly_qat_all),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_AES_docsis_qat_all),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_DES_docsis_qat_all),
8735 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8736 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8738 /** AES CCM Authenticated Encryption 128 bits key */
8739 TEST_CASE_ST(ut_setup, ut_teardown,
8740 test_AES_CCM_authenticated_encryption_test_case_128_1),
8741 TEST_CASE_ST(ut_setup, ut_teardown,
8742 test_AES_CCM_authenticated_encryption_test_case_128_2),
8743 TEST_CASE_ST(ut_setup, ut_teardown,
8744 test_AES_CCM_authenticated_encryption_test_case_128_3),
8746 /** AES CCM Authenticated Decryption 128 bits key*/
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_AES_CCM_authenticated_decryption_test_case_128_1),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_AES_CCM_authenticated_decryption_test_case_128_2),
8751 TEST_CASE_ST(ut_setup, ut_teardown,
8752 test_AES_CCM_authenticated_decryption_test_case_128_3),
8754 /** AES GCM Authenticated Encryption */
8755 TEST_CASE_ST(ut_setup, ut_teardown,
8756 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_AES_GCM_authenticated_encryption_test_case_1),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_AES_GCM_authenticated_encryption_test_case_2),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_AES_GCM_authenticated_encryption_test_case_3),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_AES_GCM_authenticated_encryption_test_case_4),
8769 TEST_CASE_ST(ut_setup, ut_teardown,
8770 test_AES_GCM_authenticated_encryption_test_case_5),
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_AES_GCM_authenticated_encryption_test_case_6),
8773 TEST_CASE_ST(ut_setup, ut_teardown,
8774 test_AES_GCM_authenticated_encryption_test_case_7),
8776 /** AES GCM Authenticated Decryption */
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_AES_GCM_authenticated_decryption_test_case_1),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_AES_GCM_authenticated_decryption_test_case_2),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_AES_GCM_authenticated_decryption_test_case_3),
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_GCM_authenticated_decryption_test_case_4),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_GCM_authenticated_decryption_test_case_5),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_GCM_authenticated_decryption_test_case_6),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_AES_GCM_authenticated_decryption_test_case_7),
8792 /** AES GCM Authenticated Encryption 192 bits key */
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_GCM_auth_encryption_test_case_192_1),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_AES_GCM_auth_encryption_test_case_192_2),
8797 TEST_CASE_ST(ut_setup, ut_teardown,
8798 test_AES_GCM_auth_encryption_test_case_192_3),
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_GCM_auth_encryption_test_case_192_4),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_GCM_auth_encryption_test_case_192_5),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_GCM_auth_encryption_test_case_192_6),
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_AES_GCM_auth_encryption_test_case_192_7),
8808 /** AES GCM Authenticated Decryption 192 bits key */
8809 TEST_CASE_ST(ut_setup, ut_teardown,
8810 test_AES_GCM_auth_decryption_test_case_192_1),
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_GCM_auth_decryption_test_case_192_2),
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_AES_GCM_auth_decryption_test_case_192_3),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_decryption_test_case_192_4),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_decryption_test_case_192_5),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_decryption_test_case_192_6),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_AES_GCM_auth_decryption_test_case_192_7),
8824 /** AES GCM Authenticated Encryption 256 bits key */
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_AES_GCM_auth_encryption_test_case_256_1),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_AES_GCM_auth_encryption_test_case_256_2),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_AES_GCM_auth_encryption_test_case_256_3),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_encryption_test_case_256_4),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_encryption_test_case_256_5),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_encryption_test_case_256_6),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_AES_GCM_auth_encryption_test_case_256_7),
8840 /** AES GMAC Authentication */
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_AES_GMAC_authentication_test_case_1),
8843 TEST_CASE_ST(ut_setup, ut_teardown,
8844 test_AES_GMAC_authentication_verify_test_case_1),
8845 TEST_CASE_ST(ut_setup, ut_teardown,
8846 test_AES_GMAC_authentication_test_case_2),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GMAC_authentication_verify_test_case_2),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GMAC_authentication_test_case_3),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_AES_GMAC_authentication_verify_test_case_3),
8854 /** SNOW 3G encrypt only (UEA2) */
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_snow3g_encryption_test_case_1),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_snow3g_encryption_test_case_2),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_snow3g_encryption_test_case_3),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_snow3g_encryption_test_case_4),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_snow3g_encryption_test_case_5),
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_snow3g_encryption_test_case_1_oop),
8868 TEST_CASE_ST(ut_setup, ut_teardown,
8869 test_snow3g_decryption_test_case_1_oop),
8871 /** SNOW 3G decrypt only (UEA2) */
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_snow3g_decryption_test_case_1),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_snow3g_decryption_test_case_2),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_snow3g_decryption_test_case_3),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_snow3g_decryption_test_case_4),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_snow3g_decryption_test_case_5),
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_snow3g_hash_generate_test_case_1),
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 test_snow3g_hash_generate_test_case_2),
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 test_snow3g_hash_generate_test_case_3),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 test_snow3g_hash_verify_test_case_1),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 test_snow3g_hash_verify_test_case_2),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_snow3g_hash_verify_test_case_3),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_snow3g_cipher_auth_test_case_1),
8896 TEST_CASE_ST(ut_setup, ut_teardown,
8897 test_snow3g_auth_cipher_test_case_1),
8899 /** ZUC encrypt only (EEA3) */
8900 TEST_CASE_ST(ut_setup, ut_teardown,
8901 test_zuc_encryption_test_case_1),
8902 TEST_CASE_ST(ut_setup, ut_teardown,
8903 test_zuc_encryption_test_case_2),
8904 TEST_CASE_ST(ut_setup, ut_teardown,
8905 test_zuc_encryption_test_case_3),
8906 TEST_CASE_ST(ut_setup, ut_teardown,
8907 test_zuc_encryption_test_case_4),
8908 TEST_CASE_ST(ut_setup, ut_teardown,
8909 test_zuc_encryption_test_case_5),
8911 /** ZUC authenticate (EIA3) */
8912 TEST_CASE_ST(ut_setup, ut_teardown,
8913 test_zuc_hash_generate_test_case_6),
8914 TEST_CASE_ST(ut_setup, ut_teardown,
8915 test_zuc_hash_generate_test_case_7),
8916 TEST_CASE_ST(ut_setup, ut_teardown,
8917 test_zuc_hash_generate_test_case_8),
8919 /** ZUC alg-chain (EEA3/EIA3) */
8920 TEST_CASE_ST(ut_setup, ut_teardown,
8921 test_zuc_cipher_auth_test_case_1),
8922 TEST_CASE_ST(ut_setup, ut_teardown,
8923 test_zuc_cipher_auth_test_case_2),
8925 /** HMAC_MD5 Authentication */
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_MD5_HMAC_generate_case_1),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_MD5_HMAC_verify_case_1),
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_MD5_HMAC_generate_case_2),
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_MD5_HMAC_verify_case_2),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_null_auth_only_operation),
8938 TEST_CASE_ST(ut_setup, ut_teardown,
8939 test_null_cipher_only_operation),
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_null_cipher_auth_operation),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_null_auth_cipher_operation),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_kasumi_hash_generate_test_case_1),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_kasumi_hash_generate_test_case_2),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_kasumi_hash_generate_test_case_3),
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_kasumi_hash_generate_test_case_4),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_kasumi_hash_generate_test_case_5),
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_kasumi_hash_generate_test_case_6),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_kasumi_hash_verify_test_case_1),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_kasumi_hash_verify_test_case_2),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_kasumi_hash_verify_test_case_3),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_kasumi_hash_verify_test_case_4),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_kasumi_hash_verify_test_case_5),
8970 TEST_CASE_ST(ut_setup, ut_teardown,
8971 test_kasumi_encryption_test_case_1),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_kasumi_encryption_test_case_3),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_kasumi_auth_cipher_test_case_1),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_kasumi_cipher_auth_test_case_1),
8979 /** Negative tests */
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 authentication_verify_AES128_GMAC_fail_data_corrupt),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8993 TEST_CASES_END() /**< NULL terminate unit test array */
8997 static struct unit_test_suite cryptodev_virtio_testsuite = {
8998 .suite_name = "Crypto VIRTIO Unit Test Suite",
8999 .setup = testsuite_setup,
9000 .teardown = testsuite_teardown,
9001 .unit_test_cases = {
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_cipheronly_virtio_all),
9005 TEST_CASES_END() /**< NULL terminate unit test array */
9009 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9010 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9011 .setup = testsuite_setup,
9012 .teardown = testsuite_teardown,
9013 .unit_test_cases = {
9014 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9015 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9016 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9017 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_DES_cipheronly_mb_all),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_DES_docsis_mb_all),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_CCM_authenticated_encryption_test_case_128_1),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_CCM_authenticated_decryption_test_case_128_1),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_CCM_authenticated_encryption_test_case_128_2),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_CCM_authenticated_decryption_test_case_128_2),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_CCM_authenticated_encryption_test_case_128_3),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_CCM_authenticated_decryption_test_case_128_3),
9035 TEST_CASES_END() /**< NULL terminate unit test array */
9039 static struct unit_test_suite cryptodev_openssl_testsuite = {
9040 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9041 .setup = testsuite_setup,
9042 .teardown = testsuite_teardown,
9043 .unit_test_cases = {
9044 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_multi_session_random_usage),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_chain_openssl_all),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_AES_cipheronly_openssl_all),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_3DES_chain_openssl_all),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_3DES_cipheronly_openssl_all),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_DES_cipheronly_openssl_all),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_DES_docsis_openssl_all),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_authonly_openssl_all),
9062 /** AES GCM Authenticated Encryption */
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GCM_authenticated_encryption_test_case_1),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GCM_authenticated_encryption_test_case_2),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_GCM_authenticated_encryption_test_case_3),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GCM_authenticated_encryption_test_case_4),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_GCM_authenticated_encryption_test_case_5),
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_AES_GCM_authenticated_encryption_test_case_6),
9075 TEST_CASE_ST(ut_setup, ut_teardown,
9076 test_AES_GCM_authenticated_encryption_test_case_7),
9078 /** AES GCM Authenticated Decryption */
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GCM_authenticated_decryption_test_case_1),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GCM_authenticated_decryption_test_case_2),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_GCM_authenticated_decryption_test_case_3),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GCM_authenticated_decryption_test_case_4),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_GCM_authenticated_decryption_test_case_5),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_GCM_authenticated_decryption_test_case_6),
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 test_AES_GCM_authenticated_decryption_test_case_7),
9095 /** AES GCM Authenticated Encryption 192 bits key */
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_auth_encryption_test_case_192_1),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_auth_encryption_test_case_192_2),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_auth_encryption_test_case_192_3),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_auth_encryption_test_case_192_4),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_auth_encryption_test_case_192_5),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_auth_encryption_test_case_192_6),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GCM_auth_encryption_test_case_192_7),
9111 /** AES GCM Authenticated Decryption 192 bits key */
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_GCM_auth_decryption_test_case_192_1),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_AES_GCM_auth_decryption_test_case_192_2),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_auth_decryption_test_case_192_3),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_auth_decryption_test_case_192_4),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_GCM_auth_decryption_test_case_192_5),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GCM_auth_decryption_test_case_192_6),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_GCM_auth_decryption_test_case_192_7),
9127 /** AES GCM Authenticated Encryption 256 bits key */
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_GCM_auth_encryption_test_case_256_1),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GCM_auth_encryption_test_case_256_2),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GCM_auth_encryption_test_case_256_3),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_AES_GCM_auth_encryption_test_case_256_4),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_auth_encryption_test_case_256_5),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_auth_encryption_test_case_256_6),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_AES_GCM_auth_encryption_test_case_256_7),
9143 /** AES GCM Authenticated Decryption 256 bits key */
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_auth_decryption_test_case_256_1),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_AES_GCM_auth_decryption_test_case_256_2),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_auth_decryption_test_case_256_3),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_auth_decryption_test_case_256_4),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_auth_decryption_test_case_256_5),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_auth_decryption_test_case_256_6),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_AES_GCM_auth_decryption_test_case_256_7),
9159 /** AES GMAC Authentication */
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GMAC_authentication_test_case_1),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GMAC_authentication_verify_test_case_1),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GMAC_authentication_test_case_2),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GMAC_authentication_verify_test_case_2),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GMAC_authentication_test_case_3),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GMAC_authentication_verify_test_case_3),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_AES_GMAC_authentication_test_case_4),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_AES_GMAC_authentication_verify_test_case_4),
9177 /** AES CCM Authenticated Encryption 128 bits key */
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_AES_CCM_authenticated_encryption_test_case_128_1),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_AES_CCM_authenticated_encryption_test_case_128_2),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_AES_CCM_authenticated_encryption_test_case_128_3),
9185 /** AES CCM Authenticated Decryption 128 bits key*/
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_AES_CCM_authenticated_decryption_test_case_128_1),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_AES_CCM_authenticated_decryption_test_case_128_2),
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_AES_CCM_authenticated_decryption_test_case_128_3),
9193 /** AES CCM Authenticated Encryption 192 bits key */
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_CCM_authenticated_encryption_test_case_192_1),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_CCM_authenticated_encryption_test_case_192_2),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_AES_CCM_authenticated_encryption_test_case_192_3),
9201 /** AES CCM Authenticated Decryption 192 bits key*/
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_AES_CCM_authenticated_decryption_test_case_192_1),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 test_AES_CCM_authenticated_decryption_test_case_192_2),
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_AES_CCM_authenticated_decryption_test_case_192_3),
9209 /** AES CCM Authenticated Encryption 256 bits key */
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_AES_CCM_authenticated_encryption_test_case_256_1),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_CCM_authenticated_encryption_test_case_256_2),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_AES_CCM_authenticated_encryption_test_case_256_3),
9217 /** AES CCM Authenticated Decryption 256 bits key*/
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_CCM_authenticated_decryption_test_case_256_1),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_AES_CCM_authenticated_decryption_test_case_256_2),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_AES_CCM_authenticated_decryption_test_case_256_3),
9225 /** Scatter-Gather */
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9229 /** Negative tests */
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 authentication_verify_AES128_GMAC_fail_data_corrupt),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9243 TEST_CASES_END() /**< NULL terminate unit test array */
9247 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9248 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9249 .setup = testsuite_setup,
9250 .teardown = testsuite_teardown,
9251 .unit_test_cases = {
9252 /** AES GCM Authenticated Encryption */
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_authenticated_encryption_test_case_1),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_AES_GCM_authenticated_encryption_test_case_2),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_AES_GCM_authenticated_encryption_test_case_3),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_authenticated_encryption_test_case_4),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_AES_GCM_authenticated_encryption_test_case_5),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_AES_GCM_authenticated_encryption_test_case_6),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_AES_GCM_authenticated_encryption_test_case_7),
9268 /** AES GCM Authenticated Decryption */
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_AES_GCM_authenticated_decryption_test_case_1),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_GCM_authenticated_decryption_test_case_2),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_GCM_authenticated_decryption_test_case_3),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GCM_authenticated_decryption_test_case_4),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_AES_GCM_authenticated_decryption_test_case_5),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_GCM_authenticated_decryption_test_case_6),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_AES_GCM_authenticated_decryption_test_case_7),
9284 /** AES GCM Authenticated Encryption 192 bits key */
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_auth_encryption_test_case_192_1),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_auth_encryption_test_case_192_2),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_auth_encryption_test_case_192_3),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_auth_encryption_test_case_192_4),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_auth_encryption_test_case_192_5),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_auth_encryption_test_case_192_6),
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_auth_encryption_test_case_192_7),
9300 /** AES GCM Authenticated Decryption 192 bits key */
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_auth_decryption_test_case_192_1),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_auth_decryption_test_case_192_2),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_auth_decryption_test_case_192_3),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_auth_decryption_test_case_192_4),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_auth_decryption_test_case_192_5),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_auth_decryption_test_case_192_6),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_auth_decryption_test_case_192_7),
9316 /** AES GCM Authenticated Encryption 256 bits key */
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_encryption_test_case_256_1),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_auth_encryption_test_case_256_2),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_auth_encryption_test_case_256_3),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_encryption_test_case_256_4),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_auth_encryption_test_case_256_5),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_encryption_test_case_256_6),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_auth_encryption_test_case_256_7),
9332 /** AES GCM Authenticated Decryption 256 bits key */
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_decryption_test_case_256_1),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_decryption_test_case_256_2),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_auth_decryption_test_case_256_3),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_auth_decryption_test_case_256_4),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_decryption_test_case_256_5),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_decryption_test_case_256_6),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GCM_auth_decryption_test_case_256_7),
9348 /** AES GCM Authenticated Encryption big aad size */
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_encryption_test_case_aad_1),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_encryption_test_case_aad_2),
9354 /** AES GCM Authenticated Decryption big aad size */
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_decryption_test_case_aad_1),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_auth_decryption_test_case_aad_2),
9360 /** AES GMAC Authentication */
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GMAC_authentication_test_case_1),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GMAC_authentication_verify_test_case_1),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GMAC_authentication_test_case_3),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GMAC_authentication_verify_test_case_3),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GMAC_authentication_test_case_4),
9371 TEST_CASE_ST(ut_setup, ut_teardown,
9372 test_AES_GMAC_authentication_verify_test_case_4),
9374 /** Negative tests */
9375 TEST_CASE_ST(ut_setup, ut_teardown,
9376 authentication_verify_AES128_GMAC_fail_data_corrupt),
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9380 /** Out of place tests */
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9386 /** Session-less tests */
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9392 /** Scatter-Gather */
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9396 TEST_CASES_END() /**< NULL terminate unit test array */
9400 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9401 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9402 .setup = testsuite_setup,
9403 .teardown = testsuite_teardown,
9404 .unit_test_cases = {
9405 /** KASUMI encrypt only (UEA1) */
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_kasumi_encryption_test_case_1),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_kasumi_encryption_test_case_1_sgl),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_kasumi_encryption_test_case_2),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_kasumi_encryption_test_case_3),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_kasumi_encryption_test_case_4),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_kasumi_encryption_test_case_5),
9418 /** KASUMI decrypt only (UEA1) */
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_kasumi_decryption_test_case_1),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_kasumi_decryption_test_case_2),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_kasumi_decryption_test_case_3),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_kasumi_decryption_test_case_4),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_kasumi_decryption_test_case_5),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_kasumi_encryption_test_case_1_oop),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_kasumi_encryption_test_case_1_oop_sgl),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_kasumi_decryption_test_case_1_oop),
9439 /** KASUMI hash only (UIA1) */
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_kasumi_hash_generate_test_case_1),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_kasumi_hash_generate_test_case_2),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_kasumi_hash_generate_test_case_3),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_kasumi_hash_generate_test_case_4),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_kasumi_hash_generate_test_case_5),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_kasumi_hash_generate_test_case_6),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_kasumi_hash_verify_test_case_1),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_kasumi_hash_verify_test_case_2),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_kasumi_hash_verify_test_case_3),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_kasumi_hash_verify_test_case_4),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_kasumi_hash_verify_test_case_5),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_kasumi_auth_cipher_test_case_1),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_kasumi_cipher_auth_test_case_1),
9466 TEST_CASES_END() /**< NULL terminate unit test array */
9469 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9470 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9471 .setup = testsuite_setup,
9472 .teardown = testsuite_teardown,
9473 .unit_test_cases = {
9474 /** SNOW 3G encrypt only (UEA2) */
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_snow3g_encryption_test_case_1),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_snow3g_encryption_test_case_2),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_snow3g_encryption_test_case_3),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_snow3g_encryption_test_case_4),
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_snow3g_encryption_test_case_5),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_snow3g_encryption_test_case_1_oop),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_snow3g_encryption_test_case_1_oop_sgl),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_snow3g_decryption_test_case_1_oop),
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_snow3g_encryption_test_case_1_offset_oop),
9496 /** SNOW 3G decrypt only (UEA2) */
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_snow3g_decryption_test_case_1),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_snow3g_decryption_test_case_2),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_snow3g_decryption_test_case_3),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_snow3g_decryption_test_case_4),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_snow3g_decryption_test_case_5),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_snow3g_hash_generate_test_case_1),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_snow3g_hash_generate_test_case_2),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_snow3g_hash_generate_test_case_3),
9513 /* Tests with buffers which length is not byte-aligned */
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_hash_generate_test_case_4),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_hash_generate_test_case_5),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_snow3g_hash_generate_test_case_6),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_snow3g_hash_verify_test_case_1),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_snow3g_hash_verify_test_case_2),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_snow3g_hash_verify_test_case_3),
9526 /* Tests with buffers which length is not byte-aligned */
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_snow3g_hash_verify_test_case_4),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_snow3g_hash_verify_test_case_5),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_snow3g_hash_verify_test_case_6),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_snow3g_cipher_auth_test_case_1),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_snow3g_auth_cipher_test_case_1),
9538 TEST_CASES_END() /**< NULL terminate unit test array */
9542 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9543 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9544 .setup = testsuite_setup,
9545 .teardown = testsuite_teardown,
9546 .unit_test_cases = {
9547 /** ZUC encrypt only (EEA3) */
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_zuc_encryption_test_case_1),
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_zuc_encryption_test_case_2),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_zuc_encryption_test_case_3),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_zuc_encryption_test_case_4),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_zuc_encryption_test_case_5),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_zuc_hash_generate_test_case_1),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_zuc_hash_generate_test_case_2),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_zuc_hash_generate_test_case_3),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_zuc_hash_generate_test_case_4),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_zuc_hash_generate_test_case_5),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_zuc_encryption_test_case_6_sgl),
9570 TEST_CASES_END() /**< NULL terminate unit test array */
9574 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9575 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9576 .setup = testsuite_setup,
9577 .teardown = testsuite_teardown,
9578 .unit_test_cases = {
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_device_configure_invalid_dev_id),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_multi_session),
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_AES_chain_dpaa_sec_all),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_3DES_chain_dpaa_sec_all),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_cipheronly_dpaa_sec_all),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_3DES_cipheronly_dpaa_sec_all),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_authonly_dpaa_sec_all),
9595 /** AES GCM Authenticated Encryption */
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_authenticated_encryption_test_case_1),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_encryption_test_case_2),
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_encryption_test_case_3),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_encryption_test_case_4),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_encryption_test_case_5),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_encryption_test_case_6),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_authenticated_encryption_test_case_7),
9611 /** AES GCM Authenticated Decryption */
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_authenticated_decryption_test_case_1),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_authenticated_decryption_test_case_2),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_authenticated_decryption_test_case_3),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_authenticated_decryption_test_case_4),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_authenticated_decryption_test_case_5),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_authenticated_decryption_test_case_6),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_authenticated_decryption_test_case_7),
9627 /** AES GCM Authenticated Encryption 256 bits key */
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_encryption_test_case_256_1),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_encryption_test_case_256_2),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_encryption_test_case_256_3),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_encryption_test_case_256_4),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_encryption_test_case_256_5),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_256_6),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_encryption_test_case_256_7),
9643 /** AES GCM Authenticated Decryption 256 bits key */
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_decryption_test_case_256_1),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_decryption_test_case_256_2),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_decryption_test_case_256_3),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_decryption_test_case_256_4),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_decryption_test_case_256_5),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_256_6),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_decryption_test_case_256_7),
9659 /** Out of place tests */
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9665 /** Scatter-Gather */
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9675 TEST_CASES_END() /**< NULL terminate unit test array */
9679 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9680 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9681 .setup = testsuite_setup,
9682 .teardown = testsuite_teardown,
9683 .unit_test_cases = {
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_device_configure_invalid_dev_id),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_multi_session),
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_AES_chain_dpaa2_sec_all),
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_3DES_chain_dpaa2_sec_all),
9693 TEST_CASE_ST(ut_setup, ut_teardown,
9694 test_AES_cipheronly_dpaa2_sec_all),
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_3DES_cipheronly_dpaa2_sec_all),
9697 TEST_CASE_ST(ut_setup, ut_teardown,
9698 test_authonly_dpaa2_sec_all),
9700 /** AES GCM Authenticated Encryption */
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GCM_authenticated_encryption_test_case_1),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GCM_authenticated_encryption_test_case_2),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_AES_GCM_authenticated_encryption_test_case_3),
9707 TEST_CASE_ST(ut_setup, ut_teardown,
9708 test_AES_GCM_authenticated_encryption_test_case_4),
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_GCM_authenticated_encryption_test_case_5),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_authenticated_encryption_test_case_6),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_GCM_authenticated_encryption_test_case_7),
9716 /** AES GCM Authenticated Decryption */
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_authenticated_decryption_test_case_1),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_AES_GCM_authenticated_decryption_test_case_2),
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_AES_GCM_authenticated_decryption_test_case_3),
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_AES_GCM_authenticated_decryption_test_case_4),
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_AES_GCM_authenticated_decryption_test_case_5),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_authenticated_decryption_test_case_6),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_AES_GCM_authenticated_decryption_test_case_7),
9732 /** AES GCM Authenticated Encryption 192 bits key */
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_AES_GCM_auth_encryption_test_case_192_1),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_AES_GCM_auth_encryption_test_case_192_2),
9737 TEST_CASE_ST(ut_setup, ut_teardown,
9738 test_AES_GCM_auth_encryption_test_case_192_3),
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_AES_GCM_auth_encryption_test_case_192_4),
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_AES_GCM_auth_encryption_test_case_192_5),
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_AES_GCM_auth_encryption_test_case_192_6),
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 test_AES_GCM_auth_encryption_test_case_192_7),
9748 /** AES GCM Authenticated Decryption 192 bits key */
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_AES_GCM_auth_decryption_test_case_192_1),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_AES_GCM_auth_decryption_test_case_192_2),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_AES_GCM_auth_decryption_test_case_192_3),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_AES_GCM_auth_decryption_test_case_192_4),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_AES_GCM_auth_decryption_test_case_192_5),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_AES_GCM_auth_decryption_test_case_192_6),
9761 TEST_CASE_ST(ut_setup, ut_teardown,
9762 test_AES_GCM_auth_decryption_test_case_192_7),
9764 /** AES GCM Authenticated Encryption 256 bits key */
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_AES_GCM_auth_encryption_test_case_256_1),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_GCM_auth_encryption_test_case_256_2),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_GCM_auth_encryption_test_case_256_3),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_GCM_auth_encryption_test_case_256_4),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_AES_GCM_auth_encryption_test_case_256_5),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_AES_GCM_auth_encryption_test_case_256_6),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_AES_GCM_auth_encryption_test_case_256_7),
9780 /** AES GCM Authenticated Decryption 256 bits key */
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_auth_decryption_test_case_256_1),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_decryption_test_case_256_2),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_auth_decryption_test_case_256_3),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_AES_GCM_auth_decryption_test_case_256_4),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_AES_GCM_auth_decryption_test_case_256_5),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_auth_decryption_test_case_256_6),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_AES_GCM_auth_decryption_test_case_256_7),
9796 /** Out of place tests */
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9802 /** Scatter-Gather */
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9809 TEST_CASE_ST(ut_setup, ut_teardown,
9810 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9812 TEST_CASES_END() /**< NULL terminate unit test array */
9816 static struct unit_test_suite cryptodev_null_testsuite = {
9817 .suite_name = "Crypto Device NULL Unit Test Suite",
9818 .setup = testsuite_setup,
9819 .teardown = testsuite_teardown,
9820 .unit_test_cases = {
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_null_auth_only_operation),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_null_cipher_only_operation),
9825 TEST_CASE_ST(ut_setup, ut_teardown,
9826 test_null_cipher_auth_operation),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_null_auth_cipher_operation),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_null_invalid_operation),
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_null_burst_operation),
9834 TEST_CASES_END() /**< NULL terminate unit test array */
9838 static struct unit_test_suite cryptodev_armv8_testsuite = {
9839 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9840 .setup = testsuite_setup,
9841 .teardown = testsuite_teardown,
9842 .unit_test_cases = {
9843 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9845 /** Negative tests */
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9851 TEST_CASES_END() /**< NULL terminate unit test array */
9855 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9856 .suite_name = "Crypto Device Marvell Component Test Suite",
9857 .setup = testsuite_setup,
9858 .teardown = testsuite_teardown,
9859 .unit_test_cases = {
9860 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_multi_session_random_usage),
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 test_AES_chain_mrvl_all),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_AES_cipheronly_mrvl_all),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 test_authonly_mrvl_all),
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 test_3DES_chain_mrvl_all),
9871 TEST_CASE_ST(ut_setup, ut_teardown,
9872 test_3DES_cipheronly_mrvl_all),
9874 /** Negative tests */
9875 TEST_CASE_ST(ut_setup, ut_teardown,
9876 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
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_ccp_testsuite = {
9889 .suite_name = "Crypto Device CCP Unit 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_ccp_all),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_AES_cipheronly_ccp_all),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_3DES_chain_ccp_all),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_3DES_cipheronly_ccp_all),
9904 TEST_CASE_ST(ut_setup, ut_teardown,
9905 test_authonly_ccp_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 */
9922 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9924 gbl_driver_id = rte_cryptodev_driver_id_get(
9925 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9927 if (gbl_driver_id == -1) {
9928 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9929 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9930 "in config file to run this testsuite.\n");
9931 return TEST_SKIPPED;
9934 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9938 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9940 gbl_driver_id = rte_cryptodev_driver_id_get(
9941 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9943 if (gbl_driver_id == -1) {
9944 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9945 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9946 "in config file to run this testsuite.\n");
9950 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9954 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9956 gbl_driver_id = rte_cryptodev_driver_id_get(
9957 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9959 if (gbl_driver_id == -1) {
9960 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9961 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9962 "in config file to run this testsuite.\n");
9963 return TEST_SKIPPED;
9966 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9970 test_cryptodev_openssl(void)
9972 gbl_driver_id = rte_cryptodev_driver_id_get(
9973 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9975 if (gbl_driver_id == -1) {
9976 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9977 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9978 "in config file to run this testsuite.\n");
9979 return TEST_SKIPPED;
9982 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9986 test_cryptodev_aesni_gcm(void)
9988 gbl_driver_id = rte_cryptodev_driver_id_get(
9989 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9991 if (gbl_driver_id == -1) {
9992 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9993 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9994 "in config file to run this testsuite.\n");
9995 return TEST_SKIPPED;
9998 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10002 test_cryptodev_null(void)
10004 gbl_driver_id = rte_cryptodev_driver_id_get(
10005 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10007 if (gbl_driver_id == -1) {
10008 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10009 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10010 "in config file to run this testsuite.\n");
10011 return TEST_SKIPPED;
10014 return unit_test_suite_runner(&cryptodev_null_testsuite);
10018 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10020 gbl_driver_id = rte_cryptodev_driver_id_get(
10021 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10023 if (gbl_driver_id == -1) {
10024 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10025 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10026 "in config file to run this testsuite.\n");
10027 return TEST_SKIPPED;
10030 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10034 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10036 gbl_driver_id = rte_cryptodev_driver_id_get(
10037 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10039 if (gbl_driver_id == -1) {
10040 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10041 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10042 "in config file to run this testsuite.\n");
10043 return TEST_SKIPPED;
10046 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10050 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10052 gbl_driver_id = rte_cryptodev_driver_id_get(
10053 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10055 if (gbl_driver_id == -1) {
10056 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10057 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10058 "in config file to run this testsuite.\n");
10059 return TEST_SKIPPED;
10062 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10066 test_cryptodev_armv8(void)
10068 gbl_driver_id = rte_cryptodev_driver_id_get(
10069 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10071 if (gbl_driver_id == -1) {
10072 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10073 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10074 "in config file to run this testsuite.\n");
10075 return TEST_SKIPPED;
10078 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10082 test_cryptodev_mrvl(void)
10084 gbl_driver_id = rte_cryptodev_driver_id_get(
10085 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10087 if (gbl_driver_id == -1) {
10088 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10089 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10090 "in config file to run this testsuite.\n");
10091 return TEST_SKIPPED;
10094 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10097 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10100 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10102 gbl_driver_id = rte_cryptodev_driver_id_get(
10103 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10105 if (gbl_driver_id == -1) {
10106 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10107 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10108 "in config file to run this testsuite.\n");
10109 return TEST_SKIPPED;
10112 if (rte_cryptodev_driver_id_get(
10113 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10114 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10115 " enabled in config file to run this testsuite.\n");
10116 return TEST_SKIPPED;
10118 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10121 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10126 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10128 gbl_driver_id = rte_cryptodev_driver_id_get(
10129 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10131 if (gbl_driver_id == -1) {
10132 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10133 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10134 "in config file to run this testsuite.\n");
10135 return TEST_SKIPPED;
10138 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10142 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10144 gbl_driver_id = rte_cryptodev_driver_id_get(
10145 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10147 if (gbl_driver_id == -1) {
10148 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10149 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10150 "in config file to run this testsuite.\n");
10151 return TEST_SKIPPED;
10154 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10158 test_cryptodev_ccp(void)
10160 gbl_driver_id = rte_cryptodev_driver_id_get(
10161 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10163 if (gbl_driver_id == -1) {
10164 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10165 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10166 "in config file to run this testsuite.\n");
10167 return TEST_FAILED;
10170 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10173 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10174 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10175 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10176 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10177 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10178 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10179 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10180 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10181 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10182 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10183 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10184 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10185 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10186 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);