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);
3164 uint64_t feat_flags = dev_info.feature_flags;
3166 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3167 printf("Device doesn't support in-place scatter-gather. "
3172 /* Create KASUMI session */
3173 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3174 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3175 RTE_CRYPTO_CIPHER_KASUMI_F8,
3176 tdata->key.data, tdata->key.len,
3177 tdata->cipher_iv.len);
3181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3184 /* Append data which is padded to a multiple */
3185 /* of the algorithms block size */
3186 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3188 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3189 plaintext_pad_len, 10, 0);
3191 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3193 /* Create KASUMI operation */
3194 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3195 tdata->cipher_iv.len,
3196 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3197 tdata->validCipherOffsetInBits.len);
3201 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3205 ut_params->obuf = ut_params->op->sym->m_dst;
3207 if (ut_params->obuf)
3208 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3209 plaintext_len, buffer);
3211 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3212 tdata->validCipherOffsetInBits.len >> 3,
3213 plaintext_len, buffer);
3216 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3218 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3219 (tdata->validCipherOffsetInBits.len >> 3);
3221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3223 reference_ciphertext,
3224 tdata->validCipherLenInBits.len,
3225 "KASUMI Ciphertext data not as expected");
3230 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3232 struct crypto_testsuite_params *ts_params = &testsuite_params;
3233 struct crypto_unittest_params *ut_params = &unittest_params;
3236 uint8_t *plaintext, *ciphertext;
3237 unsigned plaintext_pad_len;
3238 unsigned plaintext_len;
3240 /* Create KASUMI session */
3241 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3242 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3243 RTE_CRYPTO_CIPHER_KASUMI_F8,
3244 tdata->key.data, tdata->key.len,
3245 tdata->cipher_iv.len);
3249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3250 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3252 /* Clear mbuf payload */
3253 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3254 rte_pktmbuf_tailroom(ut_params->ibuf));
3256 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3257 /* Append data which is padded to a multiple */
3258 /* of the algorithms block size */
3259 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3260 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3262 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3263 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3265 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3267 /* Create KASUMI operation */
3268 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3269 tdata->cipher_iv.len,
3270 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3271 tdata->validCipherOffsetInBits.len);
3275 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3277 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3279 ut_params->obuf = ut_params->op->sym->m_dst;
3280 if (ut_params->obuf)
3281 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3283 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3285 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3287 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3288 (tdata->validCipherOffsetInBits.len >> 3);
3290 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3292 reference_ciphertext,
3293 tdata->validCipherLenInBits.len,
3294 "KASUMI Ciphertext data not as expected");
3299 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3301 struct crypto_testsuite_params *ts_params = &testsuite_params;
3302 struct crypto_unittest_params *ut_params = &unittest_params;
3305 unsigned int plaintext_pad_len;
3306 unsigned int plaintext_len;
3308 const uint8_t *ciphertext;
3309 uint8_t buffer[2048];
3311 struct rte_cryptodev_info dev_info;
3313 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3315 uint64_t feat_flags = dev_info.feature_flags;
3316 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3317 printf("Device doesn't support out-of-place scatter-gather "
3318 "in both input and output mbufs. "
3323 /* Create KASUMI session */
3324 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3325 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3326 RTE_CRYPTO_CIPHER_KASUMI_F8,
3327 tdata->key.data, tdata->key.len,
3328 tdata->cipher_iv.len);
3332 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3333 /* Append data which is padded to a multiple */
3334 /* of the algorithms block size */
3335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3337 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3338 plaintext_pad_len, 10, 0);
3339 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3340 plaintext_pad_len, 3, 0);
3342 /* Append data which is padded to a multiple */
3343 /* of the algorithms block size */
3344 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3346 /* Create KASUMI operation */
3347 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3348 tdata->cipher_iv.len,
3349 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3350 tdata->validCipherOffsetInBits.len);
3354 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3358 ut_params->obuf = ut_params->op->sym->m_dst;
3359 if (ut_params->obuf)
3360 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3361 plaintext_pad_len, buffer);
3363 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3364 tdata->validCipherOffsetInBits.len >> 3,
3365 plaintext_pad_len, buffer);
3367 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3368 (tdata->validCipherOffsetInBits.len >> 3);
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3372 reference_ciphertext,
3373 tdata->validCipherLenInBits.len,
3374 "KASUMI Ciphertext data not as expected");
3380 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3382 struct crypto_testsuite_params *ts_params = &testsuite_params;
3383 struct crypto_unittest_params *ut_params = &unittest_params;
3386 uint8_t *ciphertext, *plaintext;
3387 unsigned ciphertext_pad_len;
3388 unsigned ciphertext_len;
3390 /* Create KASUMI session */
3391 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3392 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3393 RTE_CRYPTO_CIPHER_KASUMI_F8,
3394 tdata->key.data, tdata->key.len,
3395 tdata->cipher_iv.len);
3399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3400 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3402 /* Clear mbuf payload */
3403 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3404 rte_pktmbuf_tailroom(ut_params->ibuf));
3406 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3407 /* Append data which is padded to a multiple */
3408 /* of the algorithms block size */
3409 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3410 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3411 ciphertext_pad_len);
3412 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3413 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3415 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3417 /* Create KASUMI operation */
3418 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3419 tdata->cipher_iv.len,
3420 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3421 tdata->validCipherOffsetInBits.len);
3425 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3427 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3429 ut_params->obuf = ut_params->op->sym->m_dst;
3430 if (ut_params->obuf)
3431 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3433 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3435 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3437 const uint8_t *reference_plaintext = tdata->plaintext.data +
3438 (tdata->validCipherOffsetInBits.len >> 3);
3440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3442 reference_plaintext,
3443 tdata->validCipherLenInBits.len,
3444 "KASUMI Plaintext data not as expected");
3449 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3455 uint8_t *ciphertext, *plaintext;
3456 unsigned ciphertext_pad_len;
3457 unsigned ciphertext_len;
3459 /* Create KASUMI session */
3460 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3461 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3462 RTE_CRYPTO_CIPHER_KASUMI_F8,
3463 tdata->key.data, tdata->key.len,
3464 tdata->cipher_iv.len);
3468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3470 /* Clear mbuf payload */
3471 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3472 rte_pktmbuf_tailroom(ut_params->ibuf));
3474 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3475 /* Append data which is padded to a multiple */
3476 /* of the algorithms block size */
3477 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3478 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3479 ciphertext_pad_len);
3480 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3482 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3484 /* Create KASUMI operation */
3485 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3486 tdata->cipher_iv.len,
3487 tdata->ciphertext.len,
3488 tdata->validCipherOffsetInBits.len);
3492 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3494 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3496 ut_params->obuf = ut_params->op->sym->m_dst;
3497 if (ut_params->obuf)
3498 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3500 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3502 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3504 const uint8_t *reference_plaintext = tdata->plaintext.data +
3505 (tdata->validCipherOffsetInBits.len >> 3);
3507 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3509 reference_plaintext,
3510 tdata->validCipherLenInBits.len,
3511 "KASUMI Plaintext data not as expected");
3516 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3518 struct crypto_testsuite_params *ts_params = &testsuite_params;
3519 struct crypto_unittest_params *ut_params = &unittest_params;
3522 uint8_t *plaintext, *ciphertext;
3523 unsigned plaintext_pad_len;
3524 unsigned plaintext_len;
3526 /* Create SNOW 3G session */
3527 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3528 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3529 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3530 tdata->key.data, tdata->key.len,
3531 tdata->cipher_iv.len);
3535 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3537 /* Clear mbuf payload */
3538 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3539 rte_pktmbuf_tailroom(ut_params->ibuf));
3541 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3542 /* Append data which is padded to a multiple of */
3543 /* the algorithms block size */
3544 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3549 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3551 /* Create SNOW 3G operation */
3552 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3553 tdata->cipher_iv.len,
3554 tdata->validCipherLenInBits.len,
3559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3563 ut_params->obuf = ut_params->op->sym->m_dst;
3564 if (ut_params->obuf)
3565 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3567 ciphertext = plaintext;
3569 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3574 tdata->ciphertext.data,
3575 tdata->validDataLenInBits.len,
3576 "SNOW 3G Ciphertext data not as expected");
3582 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3584 struct crypto_testsuite_params *ts_params = &testsuite_params;
3585 struct crypto_unittest_params *ut_params = &unittest_params;
3586 uint8_t *plaintext, *ciphertext;
3589 unsigned plaintext_pad_len;
3590 unsigned plaintext_len;
3592 /* Create SNOW 3G session */
3593 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3594 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3595 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3596 tdata->key.data, tdata->key.len,
3597 tdata->cipher_iv.len);
3601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3602 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3604 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3605 "Failed to allocate input buffer in mempool");
3606 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3607 "Failed to allocate output buffer in mempool");
3609 /* Clear mbuf payload */
3610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3611 rte_pktmbuf_tailroom(ut_params->ibuf));
3613 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3614 /* Append data which is padded to a multiple of */
3615 /* the algorithms block size */
3616 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3617 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3619 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3620 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3622 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3624 /* Create SNOW 3G operation */
3625 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3626 tdata->cipher_iv.len,
3627 tdata->validCipherLenInBits.len,
3632 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3634 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3636 ut_params->obuf = ut_params->op->sym->m_dst;
3637 if (ut_params->obuf)
3638 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3640 ciphertext = plaintext;
3642 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3645 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3647 tdata->ciphertext.data,
3648 tdata->validDataLenInBits.len,
3649 "SNOW 3G Ciphertext data not as expected");
3654 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3656 struct crypto_testsuite_params *ts_params = &testsuite_params;
3657 struct crypto_unittest_params *ut_params = &unittest_params;
3660 unsigned int plaintext_pad_len;
3661 unsigned int plaintext_len;
3662 uint8_t buffer[10000];
3663 const uint8_t *ciphertext;
3665 struct rte_cryptodev_info dev_info;
3667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3669 uint64_t feat_flags = dev_info.feature_flags;
3671 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3672 printf("Device doesn't support out-of-place scatter-gather "
3673 "in both input and output mbufs. "
3678 /* Create SNOW 3G session */
3679 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3680 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3681 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3682 tdata->key.data, tdata->key.len,
3683 tdata->cipher_iv.len);
3687 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3688 /* Append data which is padded to a multiple of */
3689 /* the algorithms block size */
3690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3692 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3693 plaintext_pad_len, 10, 0);
3694 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3695 plaintext_pad_len, 3, 0);
3697 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3698 "Failed to allocate input buffer in mempool");
3699 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3700 "Failed to allocate output buffer in mempool");
3702 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3704 /* Create SNOW 3G operation */
3705 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3706 tdata->cipher_iv.len,
3707 tdata->validCipherLenInBits.len,
3712 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3714 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3716 ut_params->obuf = ut_params->op->sym->m_dst;
3717 if (ut_params->obuf)
3718 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3719 plaintext_len, buffer);
3721 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3722 plaintext_len, buffer);
3724 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3727 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3729 tdata->ciphertext.data,
3730 tdata->validDataLenInBits.len,
3731 "SNOW 3G Ciphertext data not as expected");
3736 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3738 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3740 uint8_t curr_byte, prev_byte;
3741 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3742 uint8_t lower_byte_mask = (1 << offset) - 1;
3745 prev_byte = buffer[0];
3746 buffer[0] >>= offset;
3748 for (i = 1; i < length_in_bytes; i++) {
3749 curr_byte = buffer[i];
3750 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3751 (curr_byte >> offset);
3752 prev_byte = curr_byte;
3757 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3759 struct crypto_testsuite_params *ts_params = &testsuite_params;
3760 struct crypto_unittest_params *ut_params = &unittest_params;
3761 uint8_t *plaintext, *ciphertext;
3763 uint32_t plaintext_len;
3764 uint32_t plaintext_pad_len;
3765 uint8_t extra_offset = 4;
3766 uint8_t *expected_ciphertext_shifted;
3768 /* Create SNOW 3G session */
3769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3770 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3772 tdata->key.data, tdata->key.len,
3773 tdata->cipher_iv.len);
3777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3780 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3781 "Failed to allocate input buffer in mempool");
3782 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3783 "Failed to allocate output buffer in mempool");
3785 /* Clear mbuf payload */
3786 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3787 rte_pktmbuf_tailroom(ut_params->ibuf));
3789 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3791 * Append data which is padded to a
3792 * multiple of the algorithms block size
3794 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3796 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3799 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3801 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3802 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3804 #ifdef RTE_APP_TEST_DEBUG
3805 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3807 /* Create SNOW 3G operation */
3808 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3809 tdata->cipher_iv.len,
3810 tdata->validCipherLenInBits.len,
3815 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3817 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3819 ut_params->obuf = ut_params->op->sym->m_dst;
3820 if (ut_params->obuf)
3821 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3823 ciphertext = plaintext;
3825 #ifdef RTE_APP_TEST_DEBUG
3826 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3829 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3831 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3832 "failed to reserve memory for ciphertext shifted\n");
3834 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3835 ceil_byte_length(tdata->ciphertext.len));
3836 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3839 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3841 expected_ciphertext_shifted,
3842 tdata->validDataLenInBits.len,
3844 "SNOW 3G Ciphertext data not as expected");
3848 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3850 struct crypto_testsuite_params *ts_params = &testsuite_params;
3851 struct crypto_unittest_params *ut_params = &unittest_params;
3855 uint8_t *plaintext, *ciphertext;
3856 unsigned ciphertext_pad_len;
3857 unsigned ciphertext_len;
3859 /* Create SNOW 3G session */
3860 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3861 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3862 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3863 tdata->key.data, tdata->key.len,
3864 tdata->cipher_iv.len);
3868 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3870 /* Clear mbuf payload */
3871 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3872 rte_pktmbuf_tailroom(ut_params->ibuf));
3874 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3875 /* Append data which is padded to a multiple of */
3876 /* the algorithms block size */
3877 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3878 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3879 ciphertext_pad_len);
3880 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3882 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3884 /* Create SNOW 3G operation */
3885 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3886 tdata->cipher_iv.len,
3887 tdata->validCipherLenInBits.len,
3892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3895 ut_params->obuf = ut_params->op->sym->m_dst;
3896 if (ut_params->obuf)
3897 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3899 plaintext = ciphertext;
3901 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3904 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3905 tdata->plaintext.data,
3906 tdata->validDataLenInBits.len,
3907 "SNOW 3G Plaintext data not as expected");
3911 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3913 struct crypto_testsuite_params *ts_params = &testsuite_params;
3914 struct crypto_unittest_params *ut_params = &unittest_params;
3918 uint8_t *plaintext, *ciphertext;
3919 unsigned ciphertext_pad_len;
3920 unsigned ciphertext_len;
3922 /* Create SNOW 3G session */
3923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3924 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3925 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3926 tdata->key.data, tdata->key.len,
3927 tdata->cipher_iv.len);
3931 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3932 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3934 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3935 "Failed to allocate input buffer");
3936 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3937 "Failed to allocate output buffer");
3939 /* Clear mbuf payload */
3940 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3941 rte_pktmbuf_tailroom(ut_params->ibuf));
3943 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3944 rte_pktmbuf_tailroom(ut_params->obuf));
3946 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3947 /* Append data which is padded to a multiple of */
3948 /* the algorithms block size */
3949 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3950 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3951 ciphertext_pad_len);
3952 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3953 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3955 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3957 /* Create SNOW 3G operation */
3958 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3959 tdata->cipher_iv.len,
3960 tdata->validCipherLenInBits.len,
3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3968 ut_params->obuf = ut_params->op->sym->m_dst;
3969 if (ut_params->obuf)
3970 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3972 plaintext = ciphertext;
3974 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3977 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3978 tdata->plaintext.data,
3979 tdata->validDataLenInBits.len,
3980 "SNOW 3G Plaintext data not as expected");
3985 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3987 struct crypto_testsuite_params *ts_params = &testsuite_params;
3988 struct crypto_unittest_params *ut_params = &unittest_params;
3992 uint8_t *plaintext, *ciphertext;
3993 unsigned int plaintext_pad_len;
3994 unsigned int plaintext_len;
3996 struct rte_cryptodev_sym_capability_idx cap_idx;
3998 /* Check if device supports ZUC EEA3 */
3999 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4000 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4002 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4006 /* Check if device supports ZUC EIA3 */
4007 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4008 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4014 /* Create ZUC session */
4015 retval = create_zuc_cipher_auth_encrypt_generate_session(
4016 ts_params->valid_devs[0],
4020 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4022 /* clear mbuf payload */
4023 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4024 rte_pktmbuf_tailroom(ut_params->ibuf));
4026 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4027 /* Append data which is padded to a multiple of */
4028 /* the algorithms block size */
4029 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4030 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4032 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4034 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4036 /* Create ZUC operation */
4037 retval = create_zuc_cipher_hash_generate_operation(tdata);
4041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_src;
4045 if (ut_params->obuf)
4046 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 ciphertext = plaintext;
4050 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4054 tdata->ciphertext.data,
4055 tdata->validDataLenInBits.len,
4056 "ZUC Ciphertext data not as expected");
4058 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4059 + plaintext_pad_len;
4062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4066 "ZUC Generated auth tag not as expected");
4071 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4073 struct crypto_testsuite_params *ts_params = &testsuite_params;
4074 struct crypto_unittest_params *ut_params = &unittest_params;
4078 uint8_t *plaintext, *ciphertext;
4079 unsigned plaintext_pad_len;
4080 unsigned plaintext_len;
4082 /* Create SNOW 3G session */
4083 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4084 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4085 RTE_CRYPTO_AUTH_OP_GENERATE,
4086 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4087 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4088 tdata->key.data, tdata->key.len,
4089 tdata->auth_iv.len, tdata->digest.len,
4090 tdata->cipher_iv.len);
4093 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4095 /* clear mbuf payload */
4096 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4097 rte_pktmbuf_tailroom(ut_params->ibuf));
4099 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4100 /* Append data which is padded to a multiple of */
4101 /* the algorithms block size */
4102 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4103 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4105 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4107 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4109 /* Create SNOW 3G operation */
4110 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4111 tdata->digest.len, tdata->auth_iv.data,
4113 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4114 tdata->cipher_iv.data, tdata->cipher_iv.len,
4115 tdata->validCipherLenInBits.len,
4117 tdata->validAuthLenInBits.len,
4123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4126 ut_params->obuf = ut_params->op->sym->m_src;
4127 if (ut_params->obuf)
4128 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4130 ciphertext = plaintext;
4132 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4134 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4136 tdata->ciphertext.data,
4137 tdata->validDataLenInBits.len,
4138 "SNOW 3G Ciphertext data not as expected");
4140 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4141 + plaintext_pad_len;
4144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4147 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4148 "SNOW 3G Generated auth tag not as expected");
4152 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4159 uint8_t *plaintext, *ciphertext;
4160 unsigned plaintext_pad_len;
4161 unsigned plaintext_len;
4163 /* Create SNOW 3G session */
4164 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4165 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4166 RTE_CRYPTO_AUTH_OP_GENERATE,
4167 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4168 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4169 tdata->key.data, tdata->key.len,
4170 tdata->auth_iv.len, tdata->digest.len,
4171 tdata->cipher_iv.len);
4175 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4177 /* clear mbuf payload */
4178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->ibuf));
4181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4187 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4189 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4191 /* Create SNOW 3G operation */
4192 retval = create_wireless_algo_auth_cipher_operation(
4194 tdata->cipher_iv.data, tdata->cipher_iv.len,
4195 tdata->auth_iv.data, tdata->auth_iv.len,
4197 tdata->validCipherLenInBits.len,
4199 tdata->validAuthLenInBits.len,
4205 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4208 ut_params->obuf = ut_params->op->sym->m_src;
4209 if (ut_params->obuf)
4210 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4212 ciphertext = plaintext;
4214 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4215 + plaintext_pad_len;
4216 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4219 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4221 tdata->ciphertext.data,
4222 tdata->validDataLenInBits.len,
4223 "SNOW 3G Ciphertext data not as expected");
4226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4229 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4230 "SNOW 3G Generated auth tag not as expected");
4235 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4242 uint8_t *plaintext, *ciphertext;
4243 unsigned plaintext_pad_len;
4244 unsigned plaintext_len;
4246 /* Create KASUMI session */
4247 retval = create_wireless_algo_auth_cipher_session(
4248 ts_params->valid_devs[0],
4249 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4250 RTE_CRYPTO_AUTH_OP_GENERATE,
4251 RTE_CRYPTO_AUTH_KASUMI_F9,
4252 RTE_CRYPTO_CIPHER_KASUMI_F8,
4253 tdata->key.data, tdata->key.len,
4254 0, tdata->digest.len,
4255 tdata->cipher_iv.len);
4258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4260 /* clear mbuf payload */
4261 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4262 rte_pktmbuf_tailroom(ut_params->ibuf));
4264 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4265 /* Append data which is padded to a multiple of */
4266 /* the algorithms block size */
4267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4270 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4272 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4274 /* Create KASUMI operation */
4275 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4276 tdata->cipher_iv.data, tdata->cipher_iv.len,
4279 tdata->validCipherLenInBits.len,
4280 tdata->validCipherOffsetInBits.len,
4281 tdata->validAuthLenInBits.len,
4288 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4291 if (ut_params->op->sym->m_dst)
4292 ut_params->obuf = ut_params->op->sym->m_dst;
4294 ut_params->obuf = ut_params->op->sym->m_src;
4296 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4297 tdata->validCipherOffsetInBits.len >> 3);
4299 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4300 (tdata->validCipherOffsetInBits.len >> 3);
4302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4304 reference_ciphertext,
4305 tdata->validCipherLenInBits.len,
4306 "KASUMI Ciphertext data not as expected");
4307 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4308 + plaintext_pad_len;
4311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4314 DIGEST_BYTE_LENGTH_KASUMI_F9,
4315 "KASUMI Generated auth tag not as expected");
4320 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4322 struct crypto_testsuite_params *ts_params = &testsuite_params;
4323 struct crypto_unittest_params *ut_params = &unittest_params;
4327 uint8_t *plaintext, *ciphertext;
4328 unsigned plaintext_pad_len;
4329 unsigned plaintext_len;
4331 /* Create KASUMI session */
4332 retval = create_wireless_algo_cipher_auth_session(
4333 ts_params->valid_devs[0],
4334 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4335 RTE_CRYPTO_AUTH_OP_GENERATE,
4336 RTE_CRYPTO_AUTH_KASUMI_F9,
4337 RTE_CRYPTO_CIPHER_KASUMI_F8,
4338 tdata->key.data, tdata->key.len,
4339 0, tdata->digest.len,
4340 tdata->cipher_iv.len);
4344 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4346 /* clear mbuf payload */
4347 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4348 rte_pktmbuf_tailroom(ut_params->ibuf));
4350 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4351 /* Append data which is padded to a multiple of */
4352 /* the algorithms block size */
4353 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4356 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4358 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4360 /* Create KASUMI operation */
4361 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4362 tdata->digest.len, NULL, 0,
4363 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4364 tdata->cipher_iv.data, tdata->cipher_iv.len,
4365 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4366 tdata->validCipherOffsetInBits.len,
4367 tdata->validAuthLenInBits.len,
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4377 if (ut_params->op->sym->m_dst)
4378 ut_params->obuf = ut_params->op->sym->m_dst;
4380 ut_params->obuf = ut_params->op->sym->m_src;
4382 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4383 tdata->validCipherOffsetInBits.len >> 3);
4385 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4386 + plaintext_pad_len;
4388 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4389 (tdata->validCipherOffsetInBits.len >> 3);
4391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4393 reference_ciphertext,
4394 tdata->validCipherLenInBits.len,
4395 "KASUMI Ciphertext data not as expected");
4398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4401 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4402 "KASUMI Generated auth tag not as expected");
4407 test_zuc_encryption(const struct wireless_test_data *tdata)
4409 struct crypto_testsuite_params *ts_params = &testsuite_params;
4410 struct crypto_unittest_params *ut_params = &unittest_params;
4413 uint8_t *plaintext, *ciphertext;
4414 unsigned plaintext_pad_len;
4415 unsigned plaintext_len;
4417 struct rte_cryptodev_sym_capability_idx cap_idx;
4419 /* Check if device supports ZUC EEA3 */
4420 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4421 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4427 /* Create ZUC session */
4428 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4429 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4430 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4431 tdata->key.data, tdata->key.len,
4432 tdata->cipher_iv.len);
4436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4438 /* Clear mbuf payload */
4439 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4440 rte_pktmbuf_tailroom(ut_params->ibuf));
4442 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4443 /* Append data which is padded to a multiple */
4444 /* of the algorithms block size */
4445 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4446 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4448 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4450 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4452 /* Create ZUC operation */
4453 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4454 tdata->cipher_iv.len,
4455 tdata->plaintext.len,
4460 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4464 ut_params->obuf = ut_params->op->sym->m_dst;
4465 if (ut_params->obuf)
4466 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4468 ciphertext = plaintext;
4470 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4473 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4475 tdata->ciphertext.data,
4476 tdata->validCipherLenInBits.len,
4477 "ZUC Ciphertext data not as expected");
4482 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4484 struct crypto_testsuite_params *ts_params = &testsuite_params;
4485 struct crypto_unittest_params *ut_params = &unittest_params;
4489 unsigned int plaintext_pad_len;
4490 unsigned int plaintext_len;
4491 const uint8_t *ciphertext;
4492 uint8_t ciphertext_buffer[2048];
4493 struct rte_cryptodev_info dev_info;
4495 struct rte_cryptodev_sym_capability_idx cap_idx;
4497 /* Check if device supports ZUC EEA3 */
4498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4499 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4501 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4505 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4507 uint64_t feat_flags = dev_info.feature_flags;
4509 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4510 printf("Device doesn't support in-place scatter-gather. "
4515 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4517 /* Append data which is padded to a multiple */
4518 /* of the algorithms block size */
4519 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4521 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4522 plaintext_pad_len, 10, 0);
4524 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4525 tdata->plaintext.data);
4527 /* Create ZUC session */
4528 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4529 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4530 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4531 tdata->key.data, tdata->key.len,
4532 tdata->cipher_iv.len);
4536 /* Clear mbuf payload */
4538 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4540 /* Create ZUC operation */
4541 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4542 tdata->cipher_iv.len, tdata->plaintext.len,
4547 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4549 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4551 ut_params->obuf = ut_params->op->sym->m_dst;
4552 if (ut_params->obuf)
4553 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4554 0, plaintext_len, ciphertext_buffer);
4556 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4557 0, plaintext_len, ciphertext_buffer);
4560 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4563 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4565 tdata->ciphertext.data,
4566 tdata->validCipherLenInBits.len,
4567 "ZUC Ciphertext data not as expected");
4573 test_zuc_authentication(const struct wireless_test_data *tdata)
4575 struct crypto_testsuite_params *ts_params = &testsuite_params;
4576 struct crypto_unittest_params *ut_params = &unittest_params;
4579 unsigned plaintext_pad_len;
4580 unsigned plaintext_len;
4583 struct rte_cryptodev_sym_capability_idx cap_idx;
4585 /* Check if device supports ZUC EIA3 */
4586 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4587 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4589 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4593 /* Create ZUC session */
4594 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4595 tdata->key.data, tdata->key.len,
4596 tdata->auth_iv.len, tdata->digest.len,
4597 RTE_CRYPTO_AUTH_OP_GENERATE,
4598 RTE_CRYPTO_AUTH_ZUC_EIA3);
4602 /* alloc mbuf and set payload */
4603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4606 rte_pktmbuf_tailroom(ut_params->ibuf));
4608 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4609 /* Append data which is padded to a multiple of */
4610 /* the algorithms block size */
4611 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4612 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4614 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4616 /* Create ZUC operation */
4617 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4618 tdata->auth_iv.data, tdata->auth_iv.len,
4619 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4620 tdata->validAuthLenInBits.len,
4625 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4627 ut_params->obuf = ut_params->op->sym->m_src;
4628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4629 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4630 + plaintext_pad_len;
4633 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4636 DIGEST_BYTE_LENGTH_KASUMI_F9,
4637 "ZUC Generated auth tag not as expected");
4643 test_kasumi_encryption_test_case_1(void)
4645 return test_kasumi_encryption(&kasumi_test_case_1);
4649 test_kasumi_encryption_test_case_1_sgl(void)
4651 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4655 test_kasumi_encryption_test_case_1_oop(void)
4657 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4661 test_kasumi_encryption_test_case_1_oop_sgl(void)
4663 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4667 test_kasumi_encryption_test_case_2(void)
4669 return test_kasumi_encryption(&kasumi_test_case_2);
4673 test_kasumi_encryption_test_case_3(void)
4675 return test_kasumi_encryption(&kasumi_test_case_3);
4679 test_kasumi_encryption_test_case_4(void)
4681 return test_kasumi_encryption(&kasumi_test_case_4);
4685 test_kasumi_encryption_test_case_5(void)
4687 return test_kasumi_encryption(&kasumi_test_case_5);
4691 test_kasumi_decryption_test_case_1(void)
4693 return test_kasumi_decryption(&kasumi_test_case_1);
4697 test_kasumi_decryption_test_case_1_oop(void)
4699 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4703 test_kasumi_decryption_test_case_2(void)
4705 return test_kasumi_decryption(&kasumi_test_case_2);
4709 test_kasumi_decryption_test_case_3(void)
4711 return test_kasumi_decryption(&kasumi_test_case_3);
4715 test_kasumi_decryption_test_case_4(void)
4717 return test_kasumi_decryption(&kasumi_test_case_4);
4721 test_kasumi_decryption_test_case_5(void)
4723 return test_kasumi_decryption(&kasumi_test_case_5);
4726 test_snow3g_encryption_test_case_1(void)
4728 return test_snow3g_encryption(&snow3g_test_case_1);
4732 test_snow3g_encryption_test_case_1_oop(void)
4734 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4738 test_snow3g_encryption_test_case_1_oop_sgl(void)
4740 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4745 test_snow3g_encryption_test_case_1_offset_oop(void)
4747 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4751 test_snow3g_encryption_test_case_2(void)
4753 return test_snow3g_encryption(&snow3g_test_case_2);
4757 test_snow3g_encryption_test_case_3(void)
4759 return test_snow3g_encryption(&snow3g_test_case_3);
4763 test_snow3g_encryption_test_case_4(void)
4765 return test_snow3g_encryption(&snow3g_test_case_4);
4769 test_snow3g_encryption_test_case_5(void)
4771 return test_snow3g_encryption(&snow3g_test_case_5);
4775 test_snow3g_decryption_test_case_1(void)
4777 return test_snow3g_decryption(&snow3g_test_case_1);
4781 test_snow3g_decryption_test_case_1_oop(void)
4783 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4787 test_snow3g_decryption_test_case_2(void)
4789 return test_snow3g_decryption(&snow3g_test_case_2);
4793 test_snow3g_decryption_test_case_3(void)
4795 return test_snow3g_decryption(&snow3g_test_case_3);
4799 test_snow3g_decryption_test_case_4(void)
4801 return test_snow3g_decryption(&snow3g_test_case_4);
4805 test_snow3g_decryption_test_case_5(void)
4807 return test_snow3g_decryption(&snow3g_test_case_5);
4810 test_snow3g_cipher_auth_test_case_1(void)
4812 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4816 test_snow3g_auth_cipher_test_case_1(void)
4818 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4822 test_kasumi_auth_cipher_test_case_1(void)
4824 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4828 test_kasumi_cipher_auth_test_case_1(void)
4830 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4834 test_zuc_encryption_test_case_1(void)
4836 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4840 test_zuc_encryption_test_case_2(void)
4842 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4846 test_zuc_encryption_test_case_3(void)
4848 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4852 test_zuc_encryption_test_case_4(void)
4854 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4858 test_zuc_encryption_test_case_5(void)
4860 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4864 test_zuc_encryption_test_case_6_sgl(void)
4866 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4870 test_zuc_hash_generate_test_case_1(void)
4872 return test_zuc_authentication(&zuc_test_case_auth_1b);
4876 test_zuc_hash_generate_test_case_2(void)
4878 return test_zuc_authentication(&zuc_test_case_auth_90b);
4882 test_zuc_hash_generate_test_case_3(void)
4884 return test_zuc_authentication(&zuc_test_case_auth_577b);
4888 test_zuc_hash_generate_test_case_4(void)
4890 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4894 test_zuc_hash_generate_test_case_5(void)
4896 return test_zuc_authentication(&zuc_test_auth_5670b);
4900 test_zuc_hash_generate_test_case_6(void)
4902 return test_zuc_authentication(&zuc_test_case_auth_128b);
4906 test_zuc_hash_generate_test_case_7(void)
4908 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4912 test_zuc_hash_generate_test_case_8(void)
4914 return test_zuc_authentication(&zuc_test_case_auth_584b);
4918 test_zuc_cipher_auth_test_case_1(void)
4920 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4924 test_zuc_cipher_auth_test_case_2(void)
4926 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4930 test_3DES_chain_qat_all(void)
4932 struct crypto_testsuite_params *ts_params = &testsuite_params;
4935 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4936 ts_params->op_mpool,
4937 ts_params->session_mpool,
4938 ts_params->valid_devs[0],
4939 rte_cryptodev_driver_id_get(
4940 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4941 BLKCIPHER_3DES_CHAIN_TYPE);
4943 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4945 return TEST_SUCCESS;
4949 test_DES_cipheronly_qat_all(void)
4951 struct crypto_testsuite_params *ts_params = &testsuite_params;
4954 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4955 ts_params->op_mpool,
4956 ts_params->session_mpool,
4957 ts_params->valid_devs[0],
4958 rte_cryptodev_driver_id_get(
4959 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4960 BLKCIPHER_DES_CIPHERONLY_TYPE);
4962 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4964 return TEST_SUCCESS;
4968 test_DES_cipheronly_openssl_all(void)
4970 struct crypto_testsuite_params *ts_params = &testsuite_params;
4973 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4974 ts_params->op_mpool,
4975 ts_params->session_mpool,
4976 ts_params->valid_devs[0],
4977 rte_cryptodev_driver_id_get(
4978 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4979 BLKCIPHER_DES_CIPHERONLY_TYPE);
4981 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4983 return TEST_SUCCESS;
4987 test_DES_docsis_openssl_all(void)
4989 struct crypto_testsuite_params *ts_params = &testsuite_params;
4992 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4993 ts_params->op_mpool,
4994 ts_params->session_mpool,
4995 ts_params->valid_devs[0],
4996 rte_cryptodev_driver_id_get(
4997 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4998 BLKCIPHER_DES_DOCSIS_TYPE);
5000 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5002 return TEST_SUCCESS;
5006 test_DES_cipheronly_mb_all(void)
5008 struct crypto_testsuite_params *ts_params = &testsuite_params;
5011 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5012 ts_params->op_mpool,
5013 ts_params->session_mpool,
5014 ts_params->valid_devs[0],
5015 rte_cryptodev_driver_id_get(
5016 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5017 BLKCIPHER_DES_CIPHERONLY_TYPE);
5019 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5021 return TEST_SUCCESS;
5025 test_DES_docsis_mb_all(void)
5027 struct crypto_testsuite_params *ts_params = &testsuite_params;
5030 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5031 ts_params->op_mpool,
5032 ts_params->session_mpool,
5033 ts_params->valid_devs[0],
5034 rte_cryptodev_driver_id_get(
5035 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5036 BLKCIPHER_DES_DOCSIS_TYPE);
5038 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5040 return TEST_SUCCESS;
5044 test_3DES_chain_dpaa_sec_all(void)
5046 struct crypto_testsuite_params *ts_params = &testsuite_params;
5049 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5050 ts_params->op_mpool,
5051 ts_params->session_mpool,
5052 ts_params->valid_devs[0],
5053 rte_cryptodev_driver_id_get(
5054 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5055 BLKCIPHER_3DES_CHAIN_TYPE);
5057 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5059 return TEST_SUCCESS;
5063 test_3DES_cipheronly_dpaa_sec_all(void)
5065 struct crypto_testsuite_params *ts_params = &testsuite_params;
5068 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5069 ts_params->op_mpool,
5070 ts_params->session_mpool,
5071 ts_params->valid_devs[0],
5072 rte_cryptodev_driver_id_get(
5073 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5074 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5076 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5078 return TEST_SUCCESS;
5082 test_3DES_chain_dpaa2_sec_all(void)
5084 struct crypto_testsuite_params *ts_params = &testsuite_params;
5087 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5088 ts_params->op_mpool,
5089 ts_params->session_mpool,
5090 ts_params->valid_devs[0],
5091 rte_cryptodev_driver_id_get(
5092 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5093 BLKCIPHER_3DES_CHAIN_TYPE);
5095 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5097 return TEST_SUCCESS;
5101 test_3DES_cipheronly_dpaa2_sec_all(void)
5103 struct crypto_testsuite_params *ts_params = &testsuite_params;
5106 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5107 ts_params->op_mpool,
5108 ts_params->session_mpool,
5109 ts_params->valid_devs[0],
5110 rte_cryptodev_driver_id_get(
5111 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5112 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5114 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5116 return TEST_SUCCESS;
5120 test_3DES_chain_ccp_all(void)
5122 struct crypto_testsuite_params *ts_params = &testsuite_params;
5125 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5126 ts_params->op_mpool,
5127 ts_params->session_mpool,
5128 ts_params->valid_devs[0],
5129 rte_cryptodev_driver_id_get(
5130 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5131 BLKCIPHER_3DES_CHAIN_TYPE);
5133 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5135 return TEST_SUCCESS;
5139 test_3DES_cipheronly_ccp_all(void)
5141 struct crypto_testsuite_params *ts_params = &testsuite_params;
5144 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5145 ts_params->op_mpool,
5146 ts_params->session_mpool,
5147 ts_params->valid_devs[0],
5148 rte_cryptodev_driver_id_get(
5149 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5150 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5152 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5154 return TEST_SUCCESS;
5158 test_3DES_cipheronly_qat_all(void)
5160 struct crypto_testsuite_params *ts_params = &testsuite_params;
5163 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5164 ts_params->op_mpool,
5165 ts_params->session_mpool,
5166 ts_params->valid_devs[0],
5167 rte_cryptodev_driver_id_get(
5168 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5169 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5171 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5173 return TEST_SUCCESS;
5177 test_3DES_chain_openssl_all(void)
5179 struct crypto_testsuite_params *ts_params = &testsuite_params;
5182 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5183 ts_params->op_mpool,
5184 ts_params->session_mpool,
5185 ts_params->valid_devs[0],
5186 rte_cryptodev_driver_id_get(
5187 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5188 BLKCIPHER_3DES_CHAIN_TYPE);
5190 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5192 return TEST_SUCCESS;
5196 test_3DES_cipheronly_openssl_all(void)
5198 struct crypto_testsuite_params *ts_params = &testsuite_params;
5201 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5202 ts_params->op_mpool,
5203 ts_params->session_mpool,
5204 ts_params->valid_devs[0],
5205 rte_cryptodev_driver_id_get(
5206 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5207 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5209 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5211 return TEST_SUCCESS;
5214 /* ***** AEAD algorithm Tests ***** */
5217 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5218 enum rte_crypto_aead_operation op,
5219 const uint8_t *key, const uint8_t key_len,
5220 const uint16_t aad_len, const uint8_t auth_len,
5223 uint8_t aead_key[key_len];
5225 struct crypto_testsuite_params *ts_params = &testsuite_params;
5226 struct crypto_unittest_params *ut_params = &unittest_params;
5228 memcpy(aead_key, key, key_len);
5230 /* Setup AEAD Parameters */
5231 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5232 ut_params->aead_xform.next = NULL;
5233 ut_params->aead_xform.aead.algo = algo;
5234 ut_params->aead_xform.aead.op = op;
5235 ut_params->aead_xform.aead.key.data = aead_key;
5236 ut_params->aead_xform.aead.key.length = key_len;
5237 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5238 ut_params->aead_xform.aead.iv.length = iv_len;
5239 ut_params->aead_xform.aead.digest_length = auth_len;
5240 ut_params->aead_xform.aead.aad_length = aad_len;
5242 debug_hexdump(stdout, "key:", key, key_len);
5244 /* Create Crypto session*/
5245 ut_params->sess = rte_cryptodev_sym_session_create(
5246 ts_params->session_mpool);
5248 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5249 &ut_params->aead_xform, ts_params->session_mpool);
5251 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5257 create_aead_xform(struct rte_crypto_op *op,
5258 enum rte_crypto_aead_algorithm algo,
5259 enum rte_crypto_aead_operation aead_op,
5260 uint8_t *key, const uint8_t key_len,
5261 const uint8_t aad_len, const uint8_t auth_len,
5264 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5265 "failed to allocate space for crypto transform");
5267 struct rte_crypto_sym_op *sym_op = op->sym;
5269 /* Setup AEAD Parameters */
5270 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5271 sym_op->xform->next = NULL;
5272 sym_op->xform->aead.algo = algo;
5273 sym_op->xform->aead.op = aead_op;
5274 sym_op->xform->aead.key.data = key;
5275 sym_op->xform->aead.key.length = key_len;
5276 sym_op->xform->aead.iv.offset = IV_OFFSET;
5277 sym_op->xform->aead.iv.length = iv_len;
5278 sym_op->xform->aead.digest_length = auth_len;
5279 sym_op->xform->aead.aad_length = aad_len;
5281 debug_hexdump(stdout, "key:", key, key_len);
5287 create_aead_operation(enum rte_crypto_aead_operation op,
5288 const struct aead_test_data *tdata)
5290 struct crypto_testsuite_params *ts_params = &testsuite_params;
5291 struct crypto_unittest_params *ut_params = &unittest_params;
5293 uint8_t *plaintext, *ciphertext;
5294 unsigned int aad_pad_len, plaintext_pad_len;
5296 /* Generate Crypto op data structure */
5297 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5298 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5299 TEST_ASSERT_NOT_NULL(ut_params->op,
5300 "Failed to allocate symmetric crypto operation struct");
5302 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5304 /* Append aad data */
5305 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5306 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5307 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5309 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5310 "no room to append aad");
5312 sym_op->aead.aad.phys_addr =
5313 rte_pktmbuf_iova(ut_params->ibuf);
5314 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5315 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5316 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5319 /* Append IV at the end of the crypto operation*/
5320 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5321 uint8_t *, IV_OFFSET);
5323 /* Copy IV 1 byte after the IV pointer, according to the API */
5324 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5325 debug_hexdump(stdout, "iv:", iv_ptr,
5328 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5329 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5331 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5332 "no room to append aad");
5334 sym_op->aead.aad.phys_addr =
5335 rte_pktmbuf_iova(ut_params->ibuf);
5336 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5337 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5340 /* Append IV at the end of the crypto operation*/
5341 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5342 uint8_t *, IV_OFFSET);
5344 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5345 debug_hexdump(stdout, "iv:", iv_ptr,
5349 /* Append plaintext/ciphertext */
5350 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5351 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5352 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5354 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5356 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5357 debug_hexdump(stdout, "plaintext:", plaintext,
5358 tdata->plaintext.len);
5360 if (ut_params->obuf) {
5361 ciphertext = (uint8_t *)rte_pktmbuf_append(
5363 plaintext_pad_len + aad_pad_len);
5364 TEST_ASSERT_NOT_NULL(ciphertext,
5365 "no room to append ciphertext");
5367 memset(ciphertext + aad_pad_len, 0,
5368 tdata->ciphertext.len);
5371 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5372 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5374 TEST_ASSERT_NOT_NULL(ciphertext,
5375 "no room to append ciphertext");
5377 memcpy(ciphertext, tdata->ciphertext.data,
5378 tdata->ciphertext.len);
5379 debug_hexdump(stdout, "ciphertext:", ciphertext,
5380 tdata->ciphertext.len);
5382 if (ut_params->obuf) {
5383 plaintext = (uint8_t *)rte_pktmbuf_append(
5385 plaintext_pad_len + aad_pad_len);
5386 TEST_ASSERT_NOT_NULL(plaintext,
5387 "no room to append plaintext");
5389 memset(plaintext + aad_pad_len, 0,
5390 tdata->plaintext.len);
5394 /* Append digest data */
5395 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5396 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5397 ut_params->obuf ? ut_params->obuf :
5399 tdata->auth_tag.len);
5400 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5401 "no room to append digest");
5402 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5403 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5404 ut_params->obuf ? ut_params->obuf :
5409 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5410 ut_params->ibuf, tdata->auth_tag.len);
5411 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5412 "no room to append digest");
5413 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5415 plaintext_pad_len + aad_pad_len);
5417 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5418 tdata->auth_tag.len);
5419 debug_hexdump(stdout, "digest:",
5420 sym_op->aead.digest.data,
5421 tdata->auth_tag.len);
5424 sym_op->aead.data.length = tdata->plaintext.len;
5425 sym_op->aead.data.offset = aad_pad_len;
5431 test_authenticated_encryption(const struct aead_test_data *tdata)
5433 struct crypto_testsuite_params *ts_params = &testsuite_params;
5434 struct crypto_unittest_params *ut_params = &unittest_params;
5437 uint8_t *ciphertext, *auth_tag;
5438 uint16_t plaintext_pad_len;
5441 /* Create AEAD session */
5442 retval = create_aead_session(ts_params->valid_devs[0],
5444 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5445 tdata->key.data, tdata->key.len,
5446 tdata->aad.len, tdata->auth_tag.len,
5451 if (tdata->aad.len > MBUF_SIZE) {
5452 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5453 /* Populate full size of add data */
5454 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5455 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5457 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5459 /* clear mbuf payload */
5460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5461 rte_pktmbuf_tailroom(ut_params->ibuf));
5463 /* Create AEAD operation */
5464 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5468 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5470 ut_params->op->sym->m_src = ut_params->ibuf;
5472 /* Process crypto operation */
5473 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5474 ut_params->op), "failed to process sym crypto op");
5476 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5477 "crypto op processing failed");
5479 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5481 if (ut_params->op->sym->m_dst) {
5482 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5484 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5485 uint8_t *, plaintext_pad_len);
5487 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5489 ut_params->op->sym->cipher.data.offset);
5490 auth_tag = ciphertext + plaintext_pad_len;
5493 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5494 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5497 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5499 tdata->ciphertext.data,
5500 tdata->ciphertext.len,
5501 "Ciphertext data not as expected");
5503 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5505 tdata->auth_tag.data,
5506 tdata->auth_tag.len,
5507 "Generated auth tag not as expected");
5514 test_AES_GCM_authenticated_encryption_test_case_1(void)
5516 return test_authenticated_encryption(&gcm_test_case_1);
5520 test_AES_GCM_authenticated_encryption_test_case_2(void)
5522 return test_authenticated_encryption(&gcm_test_case_2);
5526 test_AES_GCM_authenticated_encryption_test_case_3(void)
5528 return test_authenticated_encryption(&gcm_test_case_3);
5532 test_AES_GCM_authenticated_encryption_test_case_4(void)
5534 return test_authenticated_encryption(&gcm_test_case_4);
5538 test_AES_GCM_authenticated_encryption_test_case_5(void)
5540 return test_authenticated_encryption(&gcm_test_case_5);
5544 test_AES_GCM_authenticated_encryption_test_case_6(void)
5546 return test_authenticated_encryption(&gcm_test_case_6);
5550 test_AES_GCM_authenticated_encryption_test_case_7(void)
5552 return test_authenticated_encryption(&gcm_test_case_7);
5556 test_AES_GCM_auth_encryption_test_case_192_1(void)
5558 return test_authenticated_encryption(&gcm_test_case_192_1);
5562 test_AES_GCM_auth_encryption_test_case_192_2(void)
5564 return test_authenticated_encryption(&gcm_test_case_192_2);
5568 test_AES_GCM_auth_encryption_test_case_192_3(void)
5570 return test_authenticated_encryption(&gcm_test_case_192_3);
5574 test_AES_GCM_auth_encryption_test_case_192_4(void)
5576 return test_authenticated_encryption(&gcm_test_case_192_4);
5580 test_AES_GCM_auth_encryption_test_case_192_5(void)
5582 return test_authenticated_encryption(&gcm_test_case_192_5);
5586 test_AES_GCM_auth_encryption_test_case_192_6(void)
5588 return test_authenticated_encryption(&gcm_test_case_192_6);
5592 test_AES_GCM_auth_encryption_test_case_192_7(void)
5594 return test_authenticated_encryption(&gcm_test_case_192_7);
5598 test_AES_GCM_auth_encryption_test_case_256_1(void)
5600 return test_authenticated_encryption(&gcm_test_case_256_1);
5604 test_AES_GCM_auth_encryption_test_case_256_2(void)
5606 return test_authenticated_encryption(&gcm_test_case_256_2);
5610 test_AES_GCM_auth_encryption_test_case_256_3(void)
5612 return test_authenticated_encryption(&gcm_test_case_256_3);
5616 test_AES_GCM_auth_encryption_test_case_256_4(void)
5618 return test_authenticated_encryption(&gcm_test_case_256_4);
5622 test_AES_GCM_auth_encryption_test_case_256_5(void)
5624 return test_authenticated_encryption(&gcm_test_case_256_5);
5628 test_AES_GCM_auth_encryption_test_case_256_6(void)
5630 return test_authenticated_encryption(&gcm_test_case_256_6);
5634 test_AES_GCM_auth_encryption_test_case_256_7(void)
5636 return test_authenticated_encryption(&gcm_test_case_256_7);
5640 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5642 return test_authenticated_encryption(&gcm_test_case_aad_1);
5646 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5648 return test_authenticated_encryption(&gcm_test_case_aad_2);
5652 test_authenticated_decryption(const struct aead_test_data *tdata)
5654 struct crypto_testsuite_params *ts_params = &testsuite_params;
5655 struct crypto_unittest_params *ut_params = &unittest_params;
5661 /* Create AEAD session */
5662 retval = create_aead_session(ts_params->valid_devs[0],
5664 RTE_CRYPTO_AEAD_OP_DECRYPT,
5665 tdata->key.data, tdata->key.len,
5666 tdata->aad.len, tdata->auth_tag.len,
5671 /* alloc mbuf and set payload */
5672 if (tdata->aad.len > MBUF_SIZE) {
5673 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5674 /* Populate full size of add data */
5675 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5676 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5680 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5681 rte_pktmbuf_tailroom(ut_params->ibuf));
5683 /* Create AEAD operation */
5684 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5688 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5690 ut_params->op->sym->m_src = ut_params->ibuf;
5692 /* Process crypto operation */
5693 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5694 ut_params->op), "failed to process sym crypto op");
5696 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5697 "crypto op processing failed");
5699 if (ut_params->op->sym->m_dst)
5700 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5703 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5705 ut_params->op->sym->cipher.data.offset);
5707 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5710 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5712 tdata->plaintext.data,
5713 tdata->plaintext.len,
5714 "Plaintext data not as expected");
5716 TEST_ASSERT_EQUAL(ut_params->op->status,
5717 RTE_CRYPTO_OP_STATUS_SUCCESS,
5718 "Authentication failed");
5723 test_AES_GCM_authenticated_decryption_test_case_1(void)
5725 return test_authenticated_decryption(&gcm_test_case_1);
5729 test_AES_GCM_authenticated_decryption_test_case_2(void)
5731 return test_authenticated_decryption(&gcm_test_case_2);
5735 test_AES_GCM_authenticated_decryption_test_case_3(void)
5737 return test_authenticated_decryption(&gcm_test_case_3);
5741 test_AES_GCM_authenticated_decryption_test_case_4(void)
5743 return test_authenticated_decryption(&gcm_test_case_4);
5747 test_AES_GCM_authenticated_decryption_test_case_5(void)
5749 return test_authenticated_decryption(&gcm_test_case_5);
5753 test_AES_GCM_authenticated_decryption_test_case_6(void)
5755 return test_authenticated_decryption(&gcm_test_case_6);
5759 test_AES_GCM_authenticated_decryption_test_case_7(void)
5761 return test_authenticated_decryption(&gcm_test_case_7);
5765 test_AES_GCM_auth_decryption_test_case_192_1(void)
5767 return test_authenticated_decryption(&gcm_test_case_192_1);
5771 test_AES_GCM_auth_decryption_test_case_192_2(void)
5773 return test_authenticated_decryption(&gcm_test_case_192_2);
5777 test_AES_GCM_auth_decryption_test_case_192_3(void)
5779 return test_authenticated_decryption(&gcm_test_case_192_3);
5783 test_AES_GCM_auth_decryption_test_case_192_4(void)
5785 return test_authenticated_decryption(&gcm_test_case_192_4);
5789 test_AES_GCM_auth_decryption_test_case_192_5(void)
5791 return test_authenticated_decryption(&gcm_test_case_192_5);
5795 test_AES_GCM_auth_decryption_test_case_192_6(void)
5797 return test_authenticated_decryption(&gcm_test_case_192_6);
5801 test_AES_GCM_auth_decryption_test_case_192_7(void)
5803 return test_authenticated_decryption(&gcm_test_case_192_7);
5807 test_AES_GCM_auth_decryption_test_case_256_1(void)
5809 return test_authenticated_decryption(&gcm_test_case_256_1);
5813 test_AES_GCM_auth_decryption_test_case_256_2(void)
5815 return test_authenticated_decryption(&gcm_test_case_256_2);
5819 test_AES_GCM_auth_decryption_test_case_256_3(void)
5821 return test_authenticated_decryption(&gcm_test_case_256_3);
5825 test_AES_GCM_auth_decryption_test_case_256_4(void)
5827 return test_authenticated_decryption(&gcm_test_case_256_4);
5831 test_AES_GCM_auth_decryption_test_case_256_5(void)
5833 return test_authenticated_decryption(&gcm_test_case_256_5);
5837 test_AES_GCM_auth_decryption_test_case_256_6(void)
5839 return test_authenticated_decryption(&gcm_test_case_256_6);
5843 test_AES_GCM_auth_decryption_test_case_256_7(void)
5845 return test_authenticated_decryption(&gcm_test_case_256_7);
5849 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5851 return test_authenticated_decryption(&gcm_test_case_aad_1);
5855 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5857 return test_authenticated_decryption(&gcm_test_case_aad_2);
5861 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5863 struct crypto_testsuite_params *ts_params = &testsuite_params;
5864 struct crypto_unittest_params *ut_params = &unittest_params;
5867 uint8_t *ciphertext, *auth_tag;
5868 uint16_t plaintext_pad_len;
5870 /* Create AEAD session */
5871 retval = create_aead_session(ts_params->valid_devs[0],
5873 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5874 tdata->key.data, tdata->key.len,
5875 tdata->aad.len, tdata->auth_tag.len,
5880 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5881 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5883 /* clear mbuf payload */
5884 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5885 rte_pktmbuf_tailroom(ut_params->ibuf));
5886 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5887 rte_pktmbuf_tailroom(ut_params->obuf));
5889 /* Create AEAD operation */
5890 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5894 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5896 ut_params->op->sym->m_src = ut_params->ibuf;
5897 ut_params->op->sym->m_dst = ut_params->obuf;
5899 /* Process crypto operation */
5900 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5901 ut_params->op), "failed to process sym crypto op");
5903 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5904 "crypto op processing failed");
5906 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5908 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5909 ut_params->op->sym->cipher.data.offset);
5910 auth_tag = ciphertext + plaintext_pad_len;
5912 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5913 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5916 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5918 tdata->ciphertext.data,
5919 tdata->ciphertext.len,
5920 "Ciphertext data not as expected");
5922 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5924 tdata->auth_tag.data,
5925 tdata->auth_tag.len,
5926 "Generated auth tag not as expected");
5933 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5935 return test_authenticated_encryption_oop(&gcm_test_case_5);
5939 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5941 struct crypto_testsuite_params *ts_params = &testsuite_params;
5942 struct crypto_unittest_params *ut_params = &unittest_params;
5947 /* Create AEAD session */
5948 retval = create_aead_session(ts_params->valid_devs[0],
5950 RTE_CRYPTO_AEAD_OP_DECRYPT,
5951 tdata->key.data, tdata->key.len,
5952 tdata->aad.len, tdata->auth_tag.len,
5957 /* alloc mbuf and set payload */
5958 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5959 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5961 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5962 rte_pktmbuf_tailroom(ut_params->ibuf));
5963 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5964 rte_pktmbuf_tailroom(ut_params->obuf));
5966 /* Create AEAD operation */
5967 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5971 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5973 ut_params->op->sym->m_src = ut_params->ibuf;
5974 ut_params->op->sym->m_dst = ut_params->obuf;
5976 /* Process crypto operation */
5977 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5978 ut_params->op), "failed to process sym crypto op");
5980 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5981 "crypto op processing failed");
5983 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5984 ut_params->op->sym->cipher.data.offset);
5986 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5989 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5991 tdata->plaintext.data,
5992 tdata->plaintext.len,
5993 "Plaintext data not as expected");
5995 TEST_ASSERT_EQUAL(ut_params->op->status,
5996 RTE_CRYPTO_OP_STATUS_SUCCESS,
5997 "Authentication failed");
6002 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6004 return test_authenticated_decryption_oop(&gcm_test_case_5);
6008 test_authenticated_encryption_sessionless(
6009 const struct aead_test_data *tdata)
6011 struct crypto_testsuite_params *ts_params = &testsuite_params;
6012 struct crypto_unittest_params *ut_params = &unittest_params;
6015 uint8_t *ciphertext, *auth_tag;
6016 uint16_t plaintext_pad_len;
6017 uint8_t key[tdata->key.len + 1];
6019 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6021 /* clear mbuf payload */
6022 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6023 rte_pktmbuf_tailroom(ut_params->ibuf));
6025 /* Create AEAD operation */
6026 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6030 /* Create GCM xform */
6031 memcpy(key, tdata->key.data, tdata->key.len);
6032 retval = create_aead_xform(ut_params->op,
6034 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6035 key, tdata->key.len,
6036 tdata->aad.len, tdata->auth_tag.len,
6041 ut_params->op->sym->m_src = ut_params->ibuf;
6043 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6044 RTE_CRYPTO_OP_SESSIONLESS,
6045 "crypto op session type not sessionless");
6047 /* Process crypto operation */
6048 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6049 ut_params->op), "failed to process sym crypto op");
6051 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6053 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6054 "crypto op status not success");
6056 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6058 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6059 ut_params->op->sym->cipher.data.offset);
6060 auth_tag = ciphertext + plaintext_pad_len;
6062 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6063 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6066 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6068 tdata->ciphertext.data,
6069 tdata->ciphertext.len,
6070 "Ciphertext data not as expected");
6072 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6074 tdata->auth_tag.data,
6075 tdata->auth_tag.len,
6076 "Generated auth tag not as expected");
6083 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6085 return test_authenticated_encryption_sessionless(
6090 test_authenticated_decryption_sessionless(
6091 const struct aead_test_data *tdata)
6093 struct crypto_testsuite_params *ts_params = &testsuite_params;
6094 struct crypto_unittest_params *ut_params = &unittest_params;
6098 uint8_t key[tdata->key.len + 1];
6100 /* alloc mbuf and set payload */
6101 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6103 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6104 rte_pktmbuf_tailroom(ut_params->ibuf));
6106 /* Create AEAD operation */
6107 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6111 /* Create AEAD xform */
6112 memcpy(key, tdata->key.data, tdata->key.len);
6113 retval = create_aead_xform(ut_params->op,
6115 RTE_CRYPTO_AEAD_OP_DECRYPT,
6116 key, tdata->key.len,
6117 tdata->aad.len, tdata->auth_tag.len,
6122 ut_params->op->sym->m_src = ut_params->ibuf;
6124 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6125 RTE_CRYPTO_OP_SESSIONLESS,
6126 "crypto op session type not sessionless");
6128 /* Process crypto operation */
6129 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6130 ut_params->op), "failed to process sym crypto op");
6132 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6134 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6135 "crypto op status not success");
6137 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6138 ut_params->op->sym->cipher.data.offset);
6140 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6143 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6145 tdata->plaintext.data,
6146 tdata->plaintext.len,
6147 "Plaintext data not as expected");
6149 TEST_ASSERT_EQUAL(ut_params->op->status,
6150 RTE_CRYPTO_OP_STATUS_SUCCESS,
6151 "Authentication failed");
6156 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6158 return test_authenticated_decryption_sessionless(
6163 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6165 return test_authenticated_encryption(&ccm_test_case_128_1);
6169 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6171 return test_authenticated_encryption(&ccm_test_case_128_2);
6175 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6177 return test_authenticated_encryption(&ccm_test_case_128_3);
6181 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6183 return test_authenticated_decryption(&ccm_test_case_128_1);
6187 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6189 return test_authenticated_decryption(&ccm_test_case_128_2);
6193 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6195 return test_authenticated_decryption(&ccm_test_case_128_3);
6199 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6201 return test_authenticated_encryption(&ccm_test_case_192_1);
6205 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6207 return test_authenticated_encryption(&ccm_test_case_192_2);
6211 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6213 return test_authenticated_encryption(&ccm_test_case_192_3);
6217 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6219 return test_authenticated_decryption(&ccm_test_case_192_1);
6223 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6225 return test_authenticated_decryption(&ccm_test_case_192_2);
6229 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6231 return test_authenticated_decryption(&ccm_test_case_192_3);
6235 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6237 return test_authenticated_encryption(&ccm_test_case_256_1);
6241 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6243 return test_authenticated_encryption(&ccm_test_case_256_2);
6247 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6249 return test_authenticated_encryption(&ccm_test_case_256_3);
6253 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6255 return test_authenticated_decryption(&ccm_test_case_256_1);
6259 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6261 return test_authenticated_decryption(&ccm_test_case_256_2);
6265 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6267 return test_authenticated_decryption(&ccm_test_case_256_3);
6273 struct crypto_testsuite_params *ts_params = &testsuite_params;
6274 struct rte_cryptodev_stats stats;
6275 struct rte_cryptodev *dev;
6276 cryptodev_stats_get_t temp_pfn;
6278 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6279 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6280 &stats) == -ENODEV),
6281 "rte_cryptodev_stats_get invalid dev failed");
6282 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6283 "rte_cryptodev_stats_get invalid Param failed");
6284 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6285 temp_pfn = dev->dev_ops->stats_get;
6286 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6287 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6289 "rte_cryptodev_stats_get invalid Param failed");
6290 dev->dev_ops->stats_get = temp_pfn;
6292 /* Test expected values */
6294 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6296 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6298 "rte_cryptodev_stats_get failed");
6299 TEST_ASSERT((stats.enqueued_count == 1),
6300 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6301 TEST_ASSERT((stats.dequeued_count == 1),
6302 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6303 TEST_ASSERT((stats.enqueue_err_count == 0),
6304 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6305 TEST_ASSERT((stats.dequeue_err_count == 0),
6306 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6308 /* invalid device but should ignore and not reset device stats*/
6309 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6310 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6312 "rte_cryptodev_stats_get failed");
6313 TEST_ASSERT((stats.enqueued_count == 1),
6314 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6316 /* check that a valid reset clears stats */
6317 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6318 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6320 "rte_cryptodev_stats_get failed");
6321 TEST_ASSERT((stats.enqueued_count == 0),
6322 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6323 TEST_ASSERT((stats.dequeued_count == 0),
6324 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6326 return TEST_SUCCESS;
6329 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6330 struct crypto_unittest_params *ut_params,
6331 enum rte_crypto_auth_operation op,
6332 const struct HMAC_MD5_vector *test_case)
6336 memcpy(key, test_case->key.data, test_case->key.len);
6338 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6339 ut_params->auth_xform.next = NULL;
6340 ut_params->auth_xform.auth.op = op;
6342 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6344 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6345 ut_params->auth_xform.auth.key.length = test_case->key.len;
6346 ut_params->auth_xform.auth.key.data = key;
6348 ut_params->sess = rte_cryptodev_sym_session_create(
6349 ts_params->session_mpool);
6351 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6352 ut_params->sess, &ut_params->auth_xform,
6353 ts_params->session_mpool);
6355 if (ut_params->sess == NULL)
6358 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6360 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6361 rte_pktmbuf_tailroom(ut_params->ibuf));
6366 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6367 const struct HMAC_MD5_vector *test_case,
6368 uint8_t **plaintext)
6370 uint16_t plaintext_pad_len;
6372 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6374 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6377 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6379 memcpy(*plaintext, test_case->plaintext.data,
6380 test_case->plaintext.len);
6382 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6383 ut_params->ibuf, MD5_DIGEST_LEN);
6384 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6385 "no room to append digest");
6386 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6387 ut_params->ibuf, plaintext_pad_len);
6389 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6390 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6391 test_case->auth_tag.len);
6394 sym_op->auth.data.offset = 0;
6395 sym_op->auth.data.length = test_case->plaintext.len;
6397 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6398 ut_params->op->sym->m_src = ut_params->ibuf;
6404 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6406 uint16_t plaintext_pad_len;
6407 uint8_t *plaintext, *auth_tag;
6409 struct crypto_testsuite_params *ts_params = &testsuite_params;
6410 struct crypto_unittest_params *ut_params = &unittest_params;
6412 if (MD5_HMAC_create_session(ts_params, ut_params,
6413 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6416 /* Generate Crypto op data structure */
6417 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6418 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6419 TEST_ASSERT_NOT_NULL(ut_params->op,
6420 "Failed to allocate symmetric crypto operation struct");
6422 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6425 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6428 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6429 ut_params->op), "failed to process sym crypto op");
6431 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6432 "crypto op processing failed");
6434 if (ut_params->op->sym->m_dst) {
6435 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6436 uint8_t *, plaintext_pad_len);
6438 auth_tag = plaintext + plaintext_pad_len;
6441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6443 test_case->auth_tag.data,
6444 test_case->auth_tag.len,
6445 "HMAC_MD5 generated tag not as expected");
6447 return TEST_SUCCESS;
6451 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6455 struct crypto_testsuite_params *ts_params = &testsuite_params;
6456 struct crypto_unittest_params *ut_params = &unittest_params;
6458 if (MD5_HMAC_create_session(ts_params, ut_params,
6459 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6463 /* Generate Crypto op data structure */
6464 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6465 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6466 TEST_ASSERT_NOT_NULL(ut_params->op,
6467 "Failed to allocate symmetric crypto operation struct");
6469 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6472 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6473 ut_params->op), "failed to process sym crypto op");
6475 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6476 "HMAC_MD5 crypto op processing failed");
6478 return TEST_SUCCESS;
6482 test_MD5_HMAC_generate_case_1(void)
6484 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6488 test_MD5_HMAC_verify_case_1(void)
6490 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6494 test_MD5_HMAC_generate_case_2(void)
6496 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6500 test_MD5_HMAC_verify_case_2(void)
6502 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6506 test_multi_session(void)
6508 struct crypto_testsuite_params *ts_params = &testsuite_params;
6509 struct crypto_unittest_params *ut_params = &unittest_params;
6511 struct rte_cryptodev_info dev_info;
6512 struct rte_cryptodev_sym_session **sessions;
6516 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6517 aes_cbc_key, hmac_sha512_key);
6520 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6522 sessions = rte_malloc(NULL,
6523 (sizeof(struct rte_cryptodev_sym_session *) *
6524 MAX_NB_SESSIONS) + 1, 0);
6526 /* Create multiple crypto sessions*/
6527 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6529 sessions[i] = rte_cryptodev_sym_session_create(
6530 ts_params->session_mpool);
6532 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6533 sessions[i], &ut_params->auth_xform,
6534 ts_params->session_mpool);
6535 TEST_ASSERT_NOT_NULL(sessions[i],
6536 "Session creation failed at session number %u",
6539 /* Attempt to send a request on each session */
6540 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6544 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6545 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6547 "Failed to perform decrypt on request number %u.", i);
6548 /* free crypto operation structure */
6550 rte_crypto_op_free(ut_params->op);
6553 * free mbuf - both obuf and ibuf are usually the same,
6554 * so check if they point at the same address is necessary,
6555 * to avoid freeing the mbuf twice.
6557 if (ut_params->obuf) {
6558 rte_pktmbuf_free(ut_params->obuf);
6559 if (ut_params->ibuf == ut_params->obuf)
6560 ut_params->ibuf = 0;
6561 ut_params->obuf = 0;
6563 if (ut_params->ibuf) {
6564 rte_pktmbuf_free(ut_params->ibuf);
6565 ut_params->ibuf = 0;
6569 /* Next session create should fail */
6570 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6571 sessions[i], &ut_params->auth_xform,
6572 ts_params->session_mpool);
6573 TEST_ASSERT_NULL(sessions[i],
6574 "Session creation succeeded unexpectedly!");
6576 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6577 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6579 rte_cryptodev_sym_session_free(sessions[i]);
6584 return TEST_SUCCESS;
6587 struct multi_session_params {
6588 struct crypto_unittest_params ut_params;
6589 uint8_t *cipher_key;
6591 const uint8_t *cipher;
6592 const uint8_t *digest;
6596 #define MB_SESSION_NUMBER 3
6599 test_multi_session_random_usage(void)
6601 struct crypto_testsuite_params *ts_params = &testsuite_params;
6602 struct rte_cryptodev_info dev_info;
6603 struct rte_cryptodev_sym_session **sessions;
6605 struct multi_session_params ut_paramz[] = {
6608 .cipher_key = ms_aes_cbc_key0,
6609 .hmac_key = ms_hmac_key0,
6610 .cipher = ms_aes_cbc_cipher0,
6611 .digest = ms_hmac_digest0,
6612 .iv = ms_aes_cbc_iv0
6615 .cipher_key = ms_aes_cbc_key1,
6616 .hmac_key = ms_hmac_key1,
6617 .cipher = ms_aes_cbc_cipher1,
6618 .digest = ms_hmac_digest1,
6619 .iv = ms_aes_cbc_iv1
6622 .cipher_key = ms_aes_cbc_key2,
6623 .hmac_key = ms_hmac_key2,
6624 .cipher = ms_aes_cbc_cipher2,
6625 .digest = ms_hmac_digest2,
6626 .iv = ms_aes_cbc_iv2
6631 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6633 sessions = rte_malloc(NULL,
6634 (sizeof(struct rte_cryptodev_sym_session *)
6635 * MAX_NB_SESSIONS) + 1, 0);
6637 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6638 sessions[i] = rte_cryptodev_sym_session_create(
6639 ts_params->session_mpool);
6641 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6642 sizeof(struct crypto_unittest_params));
6644 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6645 &ut_paramz[i].ut_params,
6646 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6648 /* Create multiple crypto sessions*/
6649 rte_cryptodev_sym_session_init(
6650 ts_params->valid_devs[0],
6652 &ut_paramz[i].ut_params.auth_xform,
6653 ts_params->session_mpool);
6655 TEST_ASSERT_NOT_NULL(sessions[i],
6656 "Session creation failed at session number %u",
6662 for (i = 0; i < 40000; i++) {
6664 j = rand() % MB_SESSION_NUMBER;
6666 TEST_ASSERT_SUCCESS(
6667 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6669 &ut_paramz[j].ut_params,
6670 ts_params, ut_paramz[j].cipher,
6671 ut_paramz[j].digest,
6673 "Failed to perform decrypt on request number %u.", i);
6675 if (ut_paramz[j].ut_params.op)
6676 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6679 * free mbuf - both obuf and ibuf are usually the same,
6680 * so check if they point at the same address is necessary,
6681 * to avoid freeing the mbuf twice.
6683 if (ut_paramz[j].ut_params.obuf) {
6684 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6685 if (ut_paramz[j].ut_params.ibuf
6686 == ut_paramz[j].ut_params.obuf)
6687 ut_paramz[j].ut_params.ibuf = 0;
6688 ut_paramz[j].ut_params.obuf = 0;
6690 if (ut_paramz[j].ut_params.ibuf) {
6691 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6692 ut_paramz[j].ut_params.ibuf = 0;
6696 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6697 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6699 rte_cryptodev_sym_session_free(sessions[i]);
6704 return TEST_SUCCESS;
6708 test_null_cipher_only_operation(void)
6710 struct crypto_testsuite_params *ts_params = &testsuite_params;
6711 struct crypto_unittest_params *ut_params = &unittest_params;
6713 /* Generate test mbuf data and space for digest */
6714 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6715 catch_22_quote, QUOTE_512_BYTES, 0);
6717 /* Setup Cipher Parameters */
6718 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6719 ut_params->cipher_xform.next = NULL;
6721 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6722 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6724 ut_params->sess = rte_cryptodev_sym_session_create(
6725 ts_params->session_mpool);
6727 /* Create Crypto session*/
6728 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6730 &ut_params->cipher_xform,
6731 ts_params->session_mpool);
6732 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6734 /* Generate Crypto op data structure */
6735 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6736 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6737 TEST_ASSERT_NOT_NULL(ut_params->op,
6738 "Failed to allocate symmetric crypto operation struct");
6740 /* Set crypto operation data parameters */
6741 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6743 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6745 /* set crypto operation source mbuf */
6746 sym_op->m_src = ut_params->ibuf;
6748 sym_op->cipher.data.offset = 0;
6749 sym_op->cipher.data.length = QUOTE_512_BYTES;
6751 /* Process crypto operation */
6752 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6754 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6756 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6757 "crypto operation processing failed");
6760 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6761 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6764 "Ciphertext data not as expected");
6766 return TEST_SUCCESS;
6768 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6769 0xab, 0xab, 0xab, 0xab,
6770 0xab, 0xab, 0xab, 0xab,
6771 0xab, 0xab, 0xab, 0xab};
6773 test_null_auth_only_operation(void)
6775 struct crypto_testsuite_params *ts_params = &testsuite_params;
6776 struct crypto_unittest_params *ut_params = &unittest_params;
6779 /* Generate test mbuf data and space for digest */
6780 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6781 catch_22_quote, QUOTE_512_BYTES, 0);
6783 /* create a pointer for digest, but don't expect anything to be written
6784 * here in a NULL auth algo so no mbuf append done.
6786 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6788 /* prefill the memory pointed to by digest */
6789 memcpy(digest, orig_data, sizeof(orig_data));
6791 /* Setup HMAC Parameters */
6792 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6793 ut_params->auth_xform.next = NULL;
6795 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6796 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6798 ut_params->sess = rte_cryptodev_sym_session_create(
6799 ts_params->session_mpool);
6801 /* Create Crypto session*/
6802 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6803 ut_params->sess, &ut_params->auth_xform,
6804 ts_params->session_mpool);
6805 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6807 /* Generate Crypto op data structure */
6808 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6809 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6810 TEST_ASSERT_NOT_NULL(ut_params->op,
6811 "Failed to allocate symmetric crypto operation struct");
6813 /* Set crypto operation data parameters */
6814 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6816 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6818 sym_op->m_src = ut_params->ibuf;
6820 sym_op->auth.data.offset = 0;
6821 sym_op->auth.data.length = QUOTE_512_BYTES;
6822 sym_op->auth.digest.data = digest;
6823 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6826 /* Process crypto operation */
6827 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6829 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6831 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6832 "crypto operation processing failed");
6833 /* Make sure memory pointed to by digest hasn't been overwritten */
6834 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6838 "Memory at digest ptr overwritten unexpectedly");
6840 return TEST_SUCCESS;
6845 test_null_cipher_auth_operation(void)
6847 struct crypto_testsuite_params *ts_params = &testsuite_params;
6848 struct crypto_unittest_params *ut_params = &unittest_params;
6851 /* Generate test mbuf data and space for digest */
6852 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6853 catch_22_quote, QUOTE_512_BYTES, 0);
6855 /* create a pointer for digest, but don't expect anything to be written
6856 * here in a NULL auth algo so no mbuf append done.
6858 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6860 /* prefill the memory pointed to by digest */
6861 memcpy(digest, orig_data, sizeof(orig_data));
6863 /* Setup Cipher Parameters */
6864 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6865 ut_params->cipher_xform.next = &ut_params->auth_xform;
6867 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6868 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6870 /* Setup HMAC Parameters */
6871 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6872 ut_params->auth_xform.next = NULL;
6874 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6875 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6877 ut_params->sess = rte_cryptodev_sym_session_create(
6878 ts_params->session_mpool);
6880 /* Create Crypto session*/
6881 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6882 ut_params->sess, &ut_params->cipher_xform,
6883 ts_params->session_mpool);
6884 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6886 /* Generate Crypto op data structure */
6887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6889 TEST_ASSERT_NOT_NULL(ut_params->op,
6890 "Failed to allocate symmetric crypto operation struct");
6892 /* Set crypto operation data parameters */
6893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6897 sym_op->m_src = ut_params->ibuf;
6899 sym_op->cipher.data.offset = 0;
6900 sym_op->cipher.data.length = QUOTE_512_BYTES;
6902 sym_op->auth.data.offset = 0;
6903 sym_op->auth.data.length = QUOTE_512_BYTES;
6904 sym_op->auth.digest.data = digest;
6905 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6908 /* Process crypto operation */
6909 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6911 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6913 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6914 "crypto operation processing failed");
6917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6918 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6921 "Ciphertext data not as expected");
6922 /* Make sure memory pointed to by digest hasn't been overwritten */
6923 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6927 "Memory at digest ptr overwritten unexpectedly");
6929 return TEST_SUCCESS;
6933 test_null_auth_cipher_operation(void)
6935 struct crypto_testsuite_params *ts_params = &testsuite_params;
6936 struct crypto_unittest_params *ut_params = &unittest_params;
6939 /* Generate test mbuf data */
6940 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6941 catch_22_quote, QUOTE_512_BYTES, 0);
6943 /* create a pointer for digest, but don't expect anything to be written
6944 * here in a NULL auth algo so no mbuf append done.
6946 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6948 /* prefill the memory pointed to by digest */
6949 memcpy(digest, orig_data, sizeof(orig_data));
6951 /* Setup Cipher Parameters */
6952 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6953 ut_params->cipher_xform.next = NULL;
6955 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6956 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6958 /* Setup HMAC Parameters */
6959 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6960 ut_params->auth_xform.next = &ut_params->cipher_xform;
6962 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6963 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6965 ut_params->sess = rte_cryptodev_sym_session_create(
6966 ts_params->session_mpool);
6968 /* Create Crypto session*/
6969 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6970 ut_params->sess, &ut_params->cipher_xform,
6971 ts_params->session_mpool);
6972 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6974 /* Generate Crypto op data structure */
6975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6976 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6977 TEST_ASSERT_NOT_NULL(ut_params->op,
6978 "Failed to allocate symmetric crypto operation struct");
6980 /* Set crypto operation data parameters */
6981 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6983 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6985 sym_op->m_src = ut_params->ibuf;
6987 sym_op->cipher.data.offset = 0;
6988 sym_op->cipher.data.length = QUOTE_512_BYTES;
6990 sym_op->auth.data.offset = 0;
6991 sym_op->auth.data.length = QUOTE_512_BYTES;
6992 sym_op->auth.digest.data = digest;
6993 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6996 /* Process crypto operation */
6997 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6999 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7001 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7002 "crypto operation processing failed");
7005 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7006 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7009 "Ciphertext data not as expected");
7010 /* Make sure memory pointed to by digest hasn't been overwritten */
7011 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7015 "Memory at digest ptr overwritten unexpectedly");
7017 return TEST_SUCCESS;
7022 test_null_invalid_operation(void)
7024 struct crypto_testsuite_params *ts_params = &testsuite_params;
7025 struct crypto_unittest_params *ut_params = &unittest_params;
7028 /* Setup Cipher Parameters */
7029 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7030 ut_params->cipher_xform.next = NULL;
7032 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7033 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7035 ut_params->sess = rte_cryptodev_sym_session_create(
7036 ts_params->session_mpool);
7038 /* Create Crypto session*/
7039 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7040 ut_params->sess, &ut_params->cipher_xform,
7041 ts_params->session_mpool);
7042 TEST_ASSERT(ret < 0,
7043 "Session creation succeeded unexpectedly");
7046 /* Setup HMAC Parameters */
7047 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7048 ut_params->auth_xform.next = NULL;
7050 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7051 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7053 ut_params->sess = rte_cryptodev_sym_session_create(
7054 ts_params->session_mpool);
7056 /* Create Crypto session*/
7057 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7058 ut_params->sess, &ut_params->auth_xform,
7059 ts_params->session_mpool);
7060 TEST_ASSERT(ret < 0,
7061 "Session creation succeeded unexpectedly");
7063 return TEST_SUCCESS;
7067 #define NULL_BURST_LENGTH (32)
7070 test_null_burst_operation(void)
7072 struct crypto_testsuite_params *ts_params = &testsuite_params;
7073 struct crypto_unittest_params *ut_params = &unittest_params;
7075 unsigned i, burst_len = NULL_BURST_LENGTH;
7077 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7078 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7080 /* Setup Cipher Parameters */
7081 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7082 ut_params->cipher_xform.next = &ut_params->auth_xform;
7084 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7085 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7087 /* Setup HMAC Parameters */
7088 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7089 ut_params->auth_xform.next = NULL;
7091 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7092 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7094 ut_params->sess = rte_cryptodev_sym_session_create(
7095 ts_params->session_mpool);
7097 /* Create Crypto session*/
7098 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7099 ut_params->sess, &ut_params->cipher_xform,
7100 ts_params->session_mpool);
7101 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7103 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7104 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7105 burst_len, "failed to generate burst of crypto ops");
7107 /* Generate an operation for each mbuf in burst */
7108 for (i = 0; i < burst_len; i++) {
7109 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7111 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7113 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7117 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7119 burst[i]->sym->m_src = m;
7122 /* Process crypto operation */
7123 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7124 0, burst, burst_len),
7126 "Error enqueuing burst");
7128 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7129 0, burst_dequeued, burst_len),
7131 "Error dequeuing burst");
7134 for (i = 0; i < burst_len; i++) {
7136 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7137 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7139 "data not as expected");
7141 rte_pktmbuf_free(burst[i]->sym->m_src);
7142 rte_crypto_op_free(burst[i]);
7145 return TEST_SUCCESS;
7149 generate_gmac_large_plaintext(uint8_t *data)
7153 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7154 memcpy(&data[i], &data[0], 32);
7158 create_gmac_operation(enum rte_crypto_auth_operation op,
7159 const struct gmac_test_data *tdata)
7161 struct crypto_testsuite_params *ts_params = &testsuite_params;
7162 struct crypto_unittest_params *ut_params = &unittest_params;
7163 struct rte_crypto_sym_op *sym_op;
7165 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7167 /* Generate Crypto op data structure */
7168 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7169 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7170 TEST_ASSERT_NOT_NULL(ut_params->op,
7171 "Failed to allocate symmetric crypto operation struct");
7173 sym_op = ut_params->op->sym;
7175 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7176 ut_params->ibuf, tdata->gmac_tag.len);
7177 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7178 "no room to append digest");
7180 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7181 ut_params->ibuf, plaintext_pad_len);
7183 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7184 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7185 tdata->gmac_tag.len);
7186 debug_hexdump(stdout, "digest:",
7187 sym_op->auth.digest.data,
7188 tdata->gmac_tag.len);
7191 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7192 uint8_t *, IV_OFFSET);
7194 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7196 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7198 sym_op->cipher.data.length = 0;
7199 sym_op->cipher.data.offset = 0;
7201 sym_op->auth.data.offset = 0;
7202 sym_op->auth.data.length = tdata->plaintext.len;
7207 static int create_gmac_session(uint8_t dev_id,
7208 const struct gmac_test_data *tdata,
7209 enum rte_crypto_auth_operation auth_op)
7211 uint8_t auth_key[tdata->key.len];
7213 struct crypto_testsuite_params *ts_params = &testsuite_params;
7214 struct crypto_unittest_params *ut_params = &unittest_params;
7216 memcpy(auth_key, tdata->key.data, tdata->key.len);
7218 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7219 ut_params->auth_xform.next = NULL;
7221 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7222 ut_params->auth_xform.auth.op = auth_op;
7223 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7224 ut_params->auth_xform.auth.key.length = tdata->key.len;
7225 ut_params->auth_xform.auth.key.data = auth_key;
7226 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7227 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7230 ut_params->sess = rte_cryptodev_sym_session_create(
7231 ts_params->session_mpool);
7233 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7234 &ut_params->auth_xform,
7235 ts_params->session_mpool);
7237 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7243 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7245 struct crypto_testsuite_params *ts_params = &testsuite_params;
7246 struct crypto_unittest_params *ut_params = &unittest_params;
7250 uint8_t *auth_tag, *plaintext;
7251 uint16_t plaintext_pad_len;
7253 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7254 "No GMAC length in the source data");
7256 retval = create_gmac_session(ts_params->valid_devs[0],
7257 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7262 if (tdata->plaintext.len > MBUF_SIZE)
7263 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7265 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7266 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7267 "Failed to allocate input buffer in mempool");
7269 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7270 rte_pktmbuf_tailroom(ut_params->ibuf));
7272 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7274 * Runtime generate the large plain text instead of use hard code
7275 * plain text vector. It is done to avoid create huge source file
7276 * with the test vector.
7278 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7279 generate_gmac_large_plaintext(tdata->plaintext.data);
7281 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7283 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7285 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7286 debug_hexdump(stdout, "plaintext:", plaintext,
7287 tdata->plaintext.len);
7289 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7295 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7297 ut_params->op->sym->m_src = ut_params->ibuf;
7299 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7300 ut_params->op), "failed to process sym crypto op");
7302 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7303 "crypto op processing failed");
7305 if (ut_params->op->sym->m_dst) {
7306 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7307 uint8_t *, plaintext_pad_len);
7309 auth_tag = plaintext + plaintext_pad_len;
7312 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7316 tdata->gmac_tag.data,
7317 tdata->gmac_tag.len,
7318 "GMAC Generated auth tag not as expected");
7324 test_AES_GMAC_authentication_test_case_1(void)
7326 return test_AES_GMAC_authentication(&gmac_test_case_1);
7330 test_AES_GMAC_authentication_test_case_2(void)
7332 return test_AES_GMAC_authentication(&gmac_test_case_2);
7336 test_AES_GMAC_authentication_test_case_3(void)
7338 return test_AES_GMAC_authentication(&gmac_test_case_3);
7342 test_AES_GMAC_authentication_test_case_4(void)
7344 return test_AES_GMAC_authentication(&gmac_test_case_4);
7348 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7350 struct crypto_testsuite_params *ts_params = &testsuite_params;
7351 struct crypto_unittest_params *ut_params = &unittest_params;
7353 uint32_t plaintext_pad_len;
7356 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7357 "No GMAC length in the source data");
7359 retval = create_gmac_session(ts_params->valid_devs[0],
7360 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7365 if (tdata->plaintext.len > MBUF_SIZE)
7366 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7368 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7369 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7370 "Failed to allocate input buffer in mempool");
7372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7373 rte_pktmbuf_tailroom(ut_params->ibuf));
7375 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7378 * Runtime generate the large plain text instead of use hard code
7379 * plain text vector. It is done to avoid create huge source file
7380 * with the test vector.
7382 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7383 generate_gmac_large_plaintext(tdata->plaintext.data);
7385 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7387 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7389 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7390 debug_hexdump(stdout, "plaintext:", plaintext,
7391 tdata->plaintext.len);
7393 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7399 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7401 ut_params->op->sym->m_src = ut_params->ibuf;
7403 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7404 ut_params->op), "failed to process sym crypto op");
7406 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7407 "crypto op processing failed");
7414 test_AES_GMAC_authentication_verify_test_case_1(void)
7416 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7420 test_AES_GMAC_authentication_verify_test_case_2(void)
7422 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7426 test_AES_GMAC_authentication_verify_test_case_3(void)
7428 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7432 test_AES_GMAC_authentication_verify_test_case_4(void)
7434 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7437 struct test_crypto_vector {
7438 enum rte_crypto_cipher_algorithm crypto_algo;
7451 const uint8_t *data;
7456 const uint8_t *data;
7460 enum rte_crypto_auth_algorithm auth_algo;
7468 const uint8_t *data;
7478 static const struct test_crypto_vector
7479 hmac_sha1_test_crypto_vector = {
7480 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7482 .data = plaintext_hash,
7487 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7488 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7489 0xDE, 0xF4, 0xDE, 0xAD
7495 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7496 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7497 0x3F, 0x91, 0x64, 0x59
7503 static const struct test_crypto_vector
7504 aes128_gmac_test_vector = {
7505 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7507 .data = plaintext_hash,
7512 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7513 0x08, 0x09, 0x0A, 0x0B
7519 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7520 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7526 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7527 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7533 static const struct test_crypto_vector
7534 aes128cbc_hmac_sha1_test_vector = {
7535 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7538 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7539 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7545 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7546 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7551 .data = plaintext_hash,
7555 .data = ciphertext512_aes128cbc,
7558 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7561 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7562 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7563 0xDE, 0xF4, 0xDE, 0xAD
7569 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7570 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7571 0x18, 0x8C, 0x1D, 0x32
7578 data_corruption(uint8_t *data)
7584 tag_corruption(uint8_t *data, unsigned int tag_offset)
7586 data[tag_offset] += 1;
7590 create_auth_session(struct crypto_unittest_params *ut_params,
7592 const struct test_crypto_vector *reference,
7593 enum rte_crypto_auth_operation auth_op)
7595 struct crypto_testsuite_params *ts_params = &testsuite_params;
7596 uint8_t auth_key[reference->auth_key.len + 1];
7598 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7600 /* Setup Authentication Parameters */
7601 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7602 ut_params->auth_xform.auth.op = auth_op;
7603 ut_params->auth_xform.next = NULL;
7604 ut_params->auth_xform.auth.algo = reference->auth_algo;
7605 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7606 ut_params->auth_xform.auth.key.data = auth_key;
7607 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7609 /* Create Crypto session*/
7610 ut_params->sess = rte_cryptodev_sym_session_create(
7611 ts_params->session_mpool);
7613 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7614 &ut_params->auth_xform,
7615 ts_params->session_mpool);
7617 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7623 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7625 const struct test_crypto_vector *reference,
7626 enum rte_crypto_auth_operation auth_op,
7627 enum rte_crypto_cipher_operation cipher_op)
7629 struct crypto_testsuite_params *ts_params = &testsuite_params;
7630 uint8_t cipher_key[reference->cipher_key.len + 1];
7631 uint8_t auth_key[reference->auth_key.len + 1];
7633 memcpy(cipher_key, reference->cipher_key.data,
7634 reference->cipher_key.len);
7635 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7637 /* Setup Authentication Parameters */
7638 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7639 ut_params->auth_xform.auth.op = auth_op;
7640 ut_params->auth_xform.auth.algo = reference->auth_algo;
7641 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7642 ut_params->auth_xform.auth.key.data = auth_key;
7643 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7645 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7646 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7647 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7649 ut_params->auth_xform.next = &ut_params->cipher_xform;
7651 /* Setup Cipher Parameters */
7652 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7653 ut_params->cipher_xform.next = NULL;
7654 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7655 ut_params->cipher_xform.cipher.op = cipher_op;
7656 ut_params->cipher_xform.cipher.key.data = cipher_key;
7657 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7658 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7659 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7662 /* Create Crypto session*/
7663 ut_params->sess = rte_cryptodev_sym_session_create(
7664 ts_params->session_mpool);
7666 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7667 &ut_params->auth_xform,
7668 ts_params->session_mpool);
7670 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7676 create_auth_operation(struct crypto_testsuite_params *ts_params,
7677 struct crypto_unittest_params *ut_params,
7678 const struct test_crypto_vector *reference,
7679 unsigned int auth_generate)
7681 /* Generate Crypto op data structure */
7682 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7683 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7684 TEST_ASSERT_NOT_NULL(ut_params->op,
7685 "Failed to allocate pktmbuf offload");
7687 /* Set crypto operation data parameters */
7688 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7690 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7692 /* set crypto operation source mbuf */
7693 sym_op->m_src = ut_params->ibuf;
7696 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7697 ut_params->ibuf, reference->digest.len);
7699 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7700 "no room to append auth tag");
7702 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7703 ut_params->ibuf, reference->plaintext.len);
7706 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7708 memcpy(sym_op->auth.digest.data,
7709 reference->digest.data,
7710 reference->digest.len);
7712 debug_hexdump(stdout, "digest:",
7713 sym_op->auth.digest.data,
7714 reference->digest.len);
7716 sym_op->auth.data.length = reference->plaintext.len;
7717 sym_op->auth.data.offset = 0;
7723 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7724 struct crypto_unittest_params *ut_params,
7725 const struct test_crypto_vector *reference,
7726 unsigned int auth_generate)
7728 /* Generate Crypto op data structure */
7729 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7730 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7731 TEST_ASSERT_NOT_NULL(ut_params->op,
7732 "Failed to allocate pktmbuf offload");
7734 /* Set crypto operation data parameters */
7735 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7737 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7739 /* set crypto operation source mbuf */
7740 sym_op->m_src = ut_params->ibuf;
7743 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7744 ut_params->ibuf, reference->digest.len);
7746 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7747 "no room to append auth tag");
7749 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7750 ut_params->ibuf, reference->ciphertext.len);
7753 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7755 memcpy(sym_op->auth.digest.data,
7756 reference->digest.data,
7757 reference->digest.len);
7759 debug_hexdump(stdout, "digest:",
7760 sym_op->auth.digest.data,
7761 reference->digest.len);
7763 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7764 reference->iv.data, reference->iv.len);
7766 sym_op->cipher.data.length = 0;
7767 sym_op->cipher.data.offset = 0;
7769 sym_op->auth.data.length = reference->plaintext.len;
7770 sym_op->auth.data.offset = 0;
7776 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7777 struct crypto_unittest_params *ut_params,
7778 const struct test_crypto_vector *reference,
7779 unsigned int auth_generate)
7781 /* Generate Crypto op data structure */
7782 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7783 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7784 TEST_ASSERT_NOT_NULL(ut_params->op,
7785 "Failed to allocate pktmbuf offload");
7787 /* Set crypto operation data parameters */
7788 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7790 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7792 /* set crypto operation source mbuf */
7793 sym_op->m_src = ut_params->ibuf;
7796 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7797 ut_params->ibuf, reference->digest.len);
7799 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7800 "no room to append auth tag");
7802 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7803 ut_params->ibuf, reference->ciphertext.len);
7806 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7808 memcpy(sym_op->auth.digest.data,
7809 reference->digest.data,
7810 reference->digest.len);
7812 debug_hexdump(stdout, "digest:",
7813 sym_op->auth.digest.data,
7814 reference->digest.len);
7816 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7817 reference->iv.data, reference->iv.len);
7819 sym_op->cipher.data.length = reference->ciphertext.len;
7820 sym_op->cipher.data.offset = 0;
7822 sym_op->auth.data.length = reference->ciphertext.len;
7823 sym_op->auth.data.offset = 0;
7829 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7830 struct crypto_unittest_params *ut_params,
7831 const struct test_crypto_vector *reference)
7833 return create_auth_operation(ts_params, ut_params, reference, 0);
7837 create_auth_verify_GMAC_operation(
7838 struct crypto_testsuite_params *ts_params,
7839 struct crypto_unittest_params *ut_params,
7840 const struct test_crypto_vector *reference)
7842 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7846 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7847 struct crypto_unittest_params *ut_params,
7848 const struct test_crypto_vector *reference)
7850 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7854 test_authentication_verify_fail_when_data_corruption(
7855 struct crypto_testsuite_params *ts_params,
7856 struct crypto_unittest_params *ut_params,
7857 const struct test_crypto_vector *reference,
7858 unsigned int data_corrupted)
7864 /* Create session */
7865 retval = create_auth_session(ut_params,
7866 ts_params->valid_devs[0],
7868 RTE_CRYPTO_AUTH_OP_VERIFY);
7872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7873 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7874 "Failed to allocate input buffer in mempool");
7876 /* clear mbuf payload */
7877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7878 rte_pktmbuf_tailroom(ut_params->ibuf));
7880 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7881 reference->plaintext.len);
7882 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7883 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7885 debug_hexdump(stdout, "plaintext:", plaintext,
7886 reference->plaintext.len);
7888 /* Create operation */
7889 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7895 data_corruption(plaintext);
7897 tag_corruption(plaintext, reference->plaintext.len);
7899 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7901 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7902 TEST_ASSERT_EQUAL(ut_params->op->status,
7903 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7904 "authentication not failed");
7906 ut_params->obuf = ut_params->op->sym->m_src;
7907 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7913 test_authentication_verify_GMAC_fail_when_corruption(
7914 struct crypto_testsuite_params *ts_params,
7915 struct crypto_unittest_params *ut_params,
7916 const struct test_crypto_vector *reference,
7917 unsigned int data_corrupted)
7922 /* Create session */
7923 retval = create_auth_cipher_session(ut_params,
7924 ts_params->valid_devs[0],
7926 RTE_CRYPTO_AUTH_OP_VERIFY,
7927 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7931 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7932 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7933 "Failed to allocate input buffer in mempool");
7935 /* clear mbuf payload */
7936 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7937 rte_pktmbuf_tailroom(ut_params->ibuf));
7939 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7940 reference->plaintext.len);
7941 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7942 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7944 debug_hexdump(stdout, "plaintext:", plaintext,
7945 reference->plaintext.len);
7947 /* Create operation */
7948 retval = create_auth_verify_GMAC_operation(ts_params,
7956 data_corruption(plaintext);
7958 tag_corruption(plaintext, reference->aad.len);
7960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7963 TEST_ASSERT_EQUAL(ut_params->op->status,
7964 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7965 "authentication not failed");
7967 ut_params->obuf = ut_params->op->sym->m_src;
7968 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7974 test_authenticated_decryption_fail_when_corruption(
7975 struct crypto_testsuite_params *ts_params,
7976 struct crypto_unittest_params *ut_params,
7977 const struct test_crypto_vector *reference,
7978 unsigned int data_corrupted)
7982 uint8_t *ciphertext;
7984 /* Create session */
7985 retval = create_auth_cipher_session(ut_params,
7986 ts_params->valid_devs[0],
7988 RTE_CRYPTO_AUTH_OP_VERIFY,
7989 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7993 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7994 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7995 "Failed to allocate input buffer in mempool");
7997 /* clear mbuf payload */
7998 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7999 rte_pktmbuf_tailroom(ut_params->ibuf));
8001 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8002 reference->ciphertext.len);
8003 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8004 memcpy(ciphertext, reference->ciphertext.data,
8005 reference->ciphertext.len);
8007 /* Create operation */
8008 retval = create_cipher_auth_verify_operation(ts_params,
8016 data_corruption(ciphertext);
8018 tag_corruption(ciphertext, reference->ciphertext.len);
8020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8024 TEST_ASSERT_EQUAL(ut_params->op->status,
8025 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8026 "authentication not failed");
8028 ut_params->obuf = ut_params->op->sym->m_src;
8029 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8035 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8036 const struct aead_test_data *tdata,
8037 void *digest_mem, uint64_t digest_phys)
8039 struct crypto_testsuite_params *ts_params = &testsuite_params;
8040 struct crypto_unittest_params *ut_params = &unittest_params;
8042 const unsigned int auth_tag_len = tdata->auth_tag.len;
8043 const unsigned int iv_len = tdata->iv.len;
8044 unsigned int aad_len = tdata->aad.len;
8046 /* Generate Crypto op data structure */
8047 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8048 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8049 TEST_ASSERT_NOT_NULL(ut_params->op,
8050 "Failed to allocate symmetric crypto operation struct");
8052 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8054 sym_op->aead.digest.data = digest_mem;
8056 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8057 "no room to append digest");
8059 sym_op->aead.digest.phys_addr = digest_phys;
8061 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8062 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8064 debug_hexdump(stdout, "digest:",
8065 sym_op->aead.digest.data,
8069 /* Append aad data */
8070 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8071 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8072 uint8_t *, IV_OFFSET);
8074 /* Copy IV 1 byte after the IV pointer, according to the API */
8075 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8077 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8079 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8080 ut_params->ibuf, aad_len);
8081 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8082 "no room to prepend aad");
8083 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8086 memset(sym_op->aead.aad.data, 0, aad_len);
8087 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8088 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8090 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8091 debug_hexdump(stdout, "aad:",
8092 sym_op->aead.aad.data, aad_len);
8094 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8095 uint8_t *, IV_OFFSET);
8097 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8099 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8100 ut_params->ibuf, aad_len);
8101 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8102 "no room to prepend aad");
8103 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8106 memset(sym_op->aead.aad.data, 0, aad_len);
8107 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8109 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8110 debug_hexdump(stdout, "aad:",
8111 sym_op->aead.aad.data, aad_len);
8114 sym_op->aead.data.length = tdata->plaintext.len;
8115 sym_op->aead.data.offset = aad_len;
8120 #define SGL_MAX_NO 16
8123 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8124 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8126 struct crypto_testsuite_params *ts_params = &testsuite_params;
8127 struct crypto_unittest_params *ut_params = &unittest_params;
8128 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8131 int to_trn_tbl[SGL_MAX_NO];
8133 unsigned int trn_data = 0;
8134 uint8_t *plaintext, *ciphertext, *auth_tag;
8136 if (fragsz > tdata->plaintext.len)
8137 fragsz = tdata->plaintext.len;
8139 uint16_t plaintext_len = fragsz;
8140 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8142 if (fragsz_oop > tdata->plaintext.len)
8143 frag_size_oop = tdata->plaintext.len;
8146 void *digest_mem = NULL;
8148 uint32_t prepend_len = tdata->aad.len;
8150 if (tdata->plaintext.len % fragsz != 0) {
8151 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8154 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8159 * For out-op-place we need to alloc another mbuf
8162 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8163 rte_pktmbuf_append(ut_params->obuf,
8164 frag_size_oop + prepend_len);
8165 buf_oop = ut_params->obuf;
8168 /* Create AEAD session */
8169 retval = create_aead_session(ts_params->valid_devs[0],
8171 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8172 tdata->key.data, tdata->key.len,
8173 tdata->aad.len, tdata->auth_tag.len,
8178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8180 /* clear mbuf payload */
8181 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8182 rte_pktmbuf_tailroom(ut_params->ibuf));
8184 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8187 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8189 trn_data += plaintext_len;
8191 buf = ut_params->ibuf;
8194 * Loop until no more fragments
8197 while (trn_data < tdata->plaintext.len) {
8199 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8200 (tdata->plaintext.len - trn_data) : fragsz;
8202 to_trn_tbl[ecx++] = to_trn;
8204 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8207 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8208 rte_pktmbuf_tailroom(buf));
8211 if (oop && !fragsz_oop) {
8212 buf_last_oop = buf_oop->next =
8213 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8214 buf_oop = buf_oop->next;
8215 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8216 0, rte_pktmbuf_tailroom(buf_oop));
8217 rte_pktmbuf_append(buf_oop, to_trn);
8220 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8223 memcpy(plaintext, tdata->plaintext.data + trn_data,
8226 if (trn_data == tdata->plaintext.len) {
8229 digest_mem = rte_pktmbuf_append(buf_oop,
8230 tdata->auth_tag.len);
8232 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8233 tdata->auth_tag.len);
8237 uint64_t digest_phys = 0;
8239 ut_params->ibuf->nb_segs = segs;
8242 if (fragsz_oop && oop) {
8246 if (frag_size_oop == tdata->plaintext.len) {
8247 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8248 tdata->auth_tag.len);
8250 digest_phys = rte_pktmbuf_iova_offset(
8252 tdata->plaintext.len + prepend_len);
8255 trn_data = frag_size_oop;
8256 while (trn_data < tdata->plaintext.len) {
8259 (tdata->plaintext.len - trn_data <
8261 (tdata->plaintext.len - trn_data) :
8264 to_trn_tbl[ecx++] = to_trn;
8266 buf_last_oop = buf_oop->next =
8267 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8268 buf_oop = buf_oop->next;
8269 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8270 0, rte_pktmbuf_tailroom(buf_oop));
8271 rte_pktmbuf_append(buf_oop, to_trn);
8275 if (trn_data == tdata->plaintext.len) {
8276 digest_mem = rte_pktmbuf_append(buf_oop,
8277 tdata->auth_tag.len);
8281 ut_params->obuf->nb_segs = segs;
8285 * Place digest at the end of the last buffer
8288 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8289 if (oop && buf_last_oop)
8290 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8292 if (!digest_mem && !oop) {
8293 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8294 + tdata->auth_tag.len);
8295 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8296 tdata->plaintext.len);
8299 /* Create AEAD operation */
8300 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8301 tdata, digest_mem, digest_phys);
8306 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8308 ut_params->op->sym->m_src = ut_params->ibuf;
8310 ut_params->op->sym->m_dst = ut_params->obuf;
8312 /* Process crypto operation */
8313 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8314 ut_params->op), "failed to process sym crypto op");
8316 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8317 "crypto op processing failed");
8320 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8321 uint8_t *, prepend_len);
8323 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8324 uint8_t *, prepend_len);
8328 fragsz = fragsz_oop;
8330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8332 tdata->ciphertext.data,
8334 "Ciphertext data not as expected");
8336 buf = ut_params->op->sym->m_src->next;
8338 buf = ut_params->op->sym->m_dst->next;
8340 unsigned int off = fragsz;
8344 ciphertext = rte_pktmbuf_mtod(buf,
8347 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8349 tdata->ciphertext.data + off,
8351 "Ciphertext data not as expected");
8353 off += to_trn_tbl[ecx++];
8357 auth_tag = digest_mem;
8358 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8360 tdata->auth_tag.data,
8361 tdata->auth_tag.len,
8362 "Generated auth tag not as expected");
8368 #define OUT_OF_PLACE 1
8371 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8373 return test_authenticated_encryption_SGL(
8374 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8378 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8380 return test_authenticated_encryption_SGL(
8381 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8385 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8387 return test_authenticated_encryption_SGL(
8388 &gcm_test_case_8, OUT_OF_PLACE, 400,
8389 gcm_test_case_8.plaintext.len);
8393 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8396 return test_authenticated_encryption_SGL(
8397 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8401 test_authentication_verify_fail_when_data_corrupted(
8402 struct crypto_testsuite_params *ts_params,
8403 struct crypto_unittest_params *ut_params,
8404 const struct test_crypto_vector *reference)
8406 return test_authentication_verify_fail_when_data_corruption(
8407 ts_params, ut_params, reference, 1);
8411 test_authentication_verify_fail_when_tag_corrupted(
8412 struct crypto_testsuite_params *ts_params,
8413 struct crypto_unittest_params *ut_params,
8414 const struct test_crypto_vector *reference)
8416 return test_authentication_verify_fail_when_data_corruption(
8417 ts_params, ut_params, reference, 0);
8421 test_authentication_verify_GMAC_fail_when_data_corrupted(
8422 struct crypto_testsuite_params *ts_params,
8423 struct crypto_unittest_params *ut_params,
8424 const struct test_crypto_vector *reference)
8426 return test_authentication_verify_GMAC_fail_when_corruption(
8427 ts_params, ut_params, reference, 1);
8431 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8432 struct crypto_testsuite_params *ts_params,
8433 struct crypto_unittest_params *ut_params,
8434 const struct test_crypto_vector *reference)
8436 return test_authentication_verify_GMAC_fail_when_corruption(
8437 ts_params, ut_params, reference, 0);
8441 test_authenticated_decryption_fail_when_data_corrupted(
8442 struct crypto_testsuite_params *ts_params,
8443 struct crypto_unittest_params *ut_params,
8444 const struct test_crypto_vector *reference)
8446 return test_authenticated_decryption_fail_when_corruption(
8447 ts_params, ut_params, reference, 1);
8451 test_authenticated_decryption_fail_when_tag_corrupted(
8452 struct crypto_testsuite_params *ts_params,
8453 struct crypto_unittest_params *ut_params,
8454 const struct test_crypto_vector *reference)
8456 return test_authenticated_decryption_fail_when_corruption(
8457 ts_params, ut_params, reference, 0);
8461 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8463 return test_authentication_verify_fail_when_data_corrupted(
8464 &testsuite_params, &unittest_params,
8465 &hmac_sha1_test_crypto_vector);
8469 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8471 return test_authentication_verify_fail_when_tag_corrupted(
8472 &testsuite_params, &unittest_params,
8473 &hmac_sha1_test_crypto_vector);
8477 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8479 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8480 &testsuite_params, &unittest_params,
8481 &aes128_gmac_test_vector);
8485 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8487 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8488 &testsuite_params, &unittest_params,
8489 &aes128_gmac_test_vector);
8493 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8495 return test_authenticated_decryption_fail_when_data_corrupted(
8498 &aes128cbc_hmac_sha1_test_vector);
8502 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8504 return test_authenticated_decryption_fail_when_tag_corrupted(
8507 &aes128cbc_hmac_sha1_test_vector);
8510 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8512 /* global AESNI slave IDs for the scheduler test */
8513 uint8_t aesni_ids[2];
8516 test_scheduler_attach_slave_op(void)
8518 struct crypto_testsuite_params *ts_params = &testsuite_params;
8519 uint8_t sched_id = ts_params->valid_devs[0];
8520 uint32_t nb_devs, i, nb_devs_attached = 0;
8524 /* create 2 AESNI_MB if necessary */
8525 nb_devs = rte_cryptodev_device_count_by_driver(
8526 rte_cryptodev_driver_id_get(
8527 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8529 for (i = nb_devs; i < 2; i++) {
8530 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8531 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8533 ret = rte_vdev_init(vdev_name, NULL);
8535 TEST_ASSERT(ret == 0,
8536 "Failed to create instance %u of"
8538 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8542 /* attach 2 AESNI_MB cdevs */
8543 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8545 struct rte_cryptodev_info info;
8547 rte_cryptodev_info_get(i, &info);
8548 if (info.driver_id != rte_cryptodev_driver_id_get(
8549 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8553 * Create the session mempool again, since now there are new devices
8554 * to use the mempool.
8556 if (ts_params->session_mpool) {
8557 rte_mempool_free(ts_params->session_mpool);
8558 ts_params->session_mpool = NULL;
8560 unsigned int session_size =
8561 rte_cryptodev_sym_get_private_session_size(i);
8563 if (info.sym.max_nb_sessions != 0 &&
8564 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8566 "Device does not support "
8567 "at least %u sessions\n",
8572 * Create mempool with maximum number of sessions * 2,
8573 * to include the session headers
8575 if (ts_params->session_mpool == NULL) {
8576 ts_params->session_mpool = rte_mempool_create(
8578 MAX_NB_SESSIONS * 2,
8580 0, 0, NULL, NULL, NULL,
8581 NULL, SOCKET_ID_ANY,
8584 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8585 "session mempool allocation failed");
8588 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8591 TEST_ASSERT(ret == 0,
8592 "Failed to attach device %u of pmd : %s", i,
8593 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8595 aesni_ids[nb_devs_attached] = (uint8_t)i;
8604 test_scheduler_detach_slave_op(void)
8606 struct crypto_testsuite_params *ts_params = &testsuite_params;
8607 uint8_t sched_id = ts_params->valid_devs[0];
8611 for (i = 0; i < 2; i++) {
8612 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8614 TEST_ASSERT(ret == 0,
8615 "Failed to detach device %u", aesni_ids[i]);
8622 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8624 struct crypto_testsuite_params *ts_params = &testsuite_params;
8625 uint8_t sched_id = ts_params->valid_devs[0];
8627 return rte_cryptodev_scheduler_mode_set(sched_id,
8632 test_scheduler_mode_roundrobin_op(void)
8634 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8635 0, "Failed to set roundrobin mode");
8641 test_scheduler_mode_multicore_op(void)
8643 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8644 0, "Failed to set multicore mode");
8650 test_scheduler_mode_failover_op(void)
8652 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8653 0, "Failed to set failover mode");
8659 test_scheduler_mode_pkt_size_distr_op(void)
8661 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8662 0, "Failed to set pktsize mode");
8667 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8668 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8669 .setup = testsuite_setup,
8670 .teardown = testsuite_teardown,
8671 .unit_test_cases = {
8673 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8674 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_AES_chain_scheduler_all),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_AES_cipheronly_scheduler_all),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_authonly_scheduler_all),
8681 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8684 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8685 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_AES_chain_scheduler_all),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_AES_cipheronly_scheduler_all),
8690 TEST_CASE_ST(ut_setup, ut_teardown,
8691 test_authonly_scheduler_all),
8692 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8695 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8696 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_AES_chain_scheduler_all),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_AES_cipheronly_scheduler_all),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_authonly_scheduler_all),
8703 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8706 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8707 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_AES_chain_scheduler_all),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_AES_cipheronly_scheduler_all),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_authonly_scheduler_all),
8714 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8716 TEST_CASES_END() /**< NULL terminate unit test array */
8720 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8722 static struct unit_test_suite cryptodev_qat_testsuite = {
8723 .suite_name = "Crypto QAT Unit Test Suite",
8724 .setup = testsuite_setup,
8725 .teardown = testsuite_teardown,
8726 .unit_test_cases = {
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_device_configure_invalid_dev_id),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_device_configure_invalid_queue_pair_ids),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_queue_pair_descriptor_setup),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_multi_session),
8736 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8737 TEST_CASE_ST(ut_setup, ut_teardown,
8738 test_AES_cipheronly_qat_all),
8739 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_3DES_cipheronly_qat_all),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_DES_cipheronly_qat_all),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_docsis_qat_all),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_DES_docsis_qat_all),
8748 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8749 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8751 /** AES CCM Authenticated Encryption 128 bits key */
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_CCM_authenticated_encryption_test_case_128_1),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_CCM_authenticated_encryption_test_case_128_2),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_AES_CCM_authenticated_encryption_test_case_128_3),
8759 /** AES CCM Authenticated Decryption 128 bits key*/
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_CCM_authenticated_decryption_test_case_128_1),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_CCM_authenticated_decryption_test_case_128_2),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_CCM_authenticated_decryption_test_case_128_3),
8767 /** AES GCM Authenticated Encryption */
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_authenticated_encryption_test_case_1),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_authenticated_encryption_test_case_2),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_authenticated_encryption_test_case_3),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_authenticated_encryption_test_case_4),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_authenticated_encryption_test_case_5),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_authenticated_encryption_test_case_6),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_authenticated_encryption_test_case_7),
8789 /** AES GCM Authenticated Decryption */
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_authenticated_decryption_test_case_1),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_authenticated_decryption_test_case_2),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_authenticated_decryption_test_case_3),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_authenticated_decryption_test_case_4),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_authenticated_decryption_test_case_5),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_authenticated_decryption_test_case_6),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_authenticated_decryption_test_case_7),
8805 /** AES GCM Authenticated Encryption 192 bits key */
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_auth_encryption_test_case_192_1),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_auth_encryption_test_case_192_2),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_192_3),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_auth_encryption_test_case_192_4),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_encryption_test_case_192_5),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_encryption_test_case_192_6),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_encryption_test_case_192_7),
8821 /** AES GCM Authenticated Decryption 192 bits key */
8822 TEST_CASE_ST(ut_setup, ut_teardown,
8823 test_AES_GCM_auth_decryption_test_case_192_1),
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GCM_auth_decryption_test_case_192_2),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_auth_decryption_test_case_192_3),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GCM_auth_decryption_test_case_192_4),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GCM_auth_decryption_test_case_192_5),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GCM_auth_decryption_test_case_192_6),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GCM_auth_decryption_test_case_192_7),
8837 /** AES GCM Authenticated Encryption 256 bits key */
8838 TEST_CASE_ST(ut_setup, ut_teardown,
8839 test_AES_GCM_auth_encryption_test_case_256_1),
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_AES_GCM_auth_encryption_test_case_256_2),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_AES_GCM_auth_encryption_test_case_256_3),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_AES_GCM_auth_encryption_test_case_256_4),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_AES_GCM_auth_encryption_test_case_256_5),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_AES_GCM_auth_encryption_test_case_256_6),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_AES_GCM_auth_encryption_test_case_256_7),
8853 /** AES GMAC Authentication */
8854 TEST_CASE_ST(ut_setup, ut_teardown,
8855 test_AES_GMAC_authentication_test_case_1),
8856 TEST_CASE_ST(ut_setup, ut_teardown,
8857 test_AES_GMAC_authentication_verify_test_case_1),
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_AES_GMAC_authentication_test_case_2),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_AES_GMAC_authentication_verify_test_case_2),
8862 TEST_CASE_ST(ut_setup, ut_teardown,
8863 test_AES_GMAC_authentication_test_case_3),
8864 TEST_CASE_ST(ut_setup, ut_teardown,
8865 test_AES_GMAC_authentication_verify_test_case_3),
8867 /** SNOW 3G encrypt only (UEA2) */
8868 TEST_CASE_ST(ut_setup, ut_teardown,
8869 test_snow3g_encryption_test_case_1),
8870 TEST_CASE_ST(ut_setup, ut_teardown,
8871 test_snow3g_encryption_test_case_2),
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_snow3g_encryption_test_case_3),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_snow3g_encryption_test_case_4),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_snow3g_encryption_test_case_5),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_snow3g_encryption_test_case_1_oop),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_snow3g_decryption_test_case_1_oop),
8884 /** SNOW 3G decrypt only (UEA2) */
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_snow3g_decryption_test_case_1),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_snow3g_decryption_test_case_2),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_snow3g_decryption_test_case_3),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_snow3g_decryption_test_case_4),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_snow3g_decryption_test_case_5),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_snow3g_hash_generate_test_case_1),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_snow3g_hash_generate_test_case_2),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_snow3g_hash_generate_test_case_3),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_snow3g_hash_verify_test_case_1),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_snow3g_hash_verify_test_case_2),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_snow3g_hash_verify_test_case_3),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_snow3g_cipher_auth_test_case_1),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_snow3g_auth_cipher_test_case_1),
8912 /** ZUC encrypt only (EEA3) */
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_zuc_encryption_test_case_1),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_zuc_encryption_test_case_2),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_zuc_encryption_test_case_3),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_zuc_encryption_test_case_4),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_zuc_encryption_test_case_5),
8924 /** ZUC authenticate (EIA3) */
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_zuc_hash_generate_test_case_6),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_zuc_hash_generate_test_case_7),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_zuc_hash_generate_test_case_8),
8932 /** ZUC alg-chain (EEA3/EIA3) */
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_zuc_cipher_auth_test_case_1),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_zuc_cipher_auth_test_case_2),
8938 /** HMAC_MD5 Authentication */
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_MD5_HMAC_generate_case_1),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_MD5_HMAC_verify_case_1),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_MD5_HMAC_generate_case_2),
8945 TEST_CASE_ST(ut_setup, ut_teardown,
8946 test_MD5_HMAC_verify_case_2),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_null_auth_only_operation),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_null_cipher_only_operation),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_null_cipher_auth_operation),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_null_auth_cipher_operation),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_kasumi_hash_generate_test_case_1),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_kasumi_hash_generate_test_case_2),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_kasumi_hash_generate_test_case_3),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_kasumi_hash_generate_test_case_4),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_kasumi_hash_generate_test_case_5),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_kasumi_hash_generate_test_case_6),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_kasumi_hash_verify_test_case_1),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_kasumi_hash_verify_test_case_2),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_kasumi_hash_verify_test_case_3),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_kasumi_hash_verify_test_case_4),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_kasumi_hash_verify_test_case_5),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_kasumi_encryption_test_case_1),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_kasumi_encryption_test_case_3),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_kasumi_auth_cipher_test_case_1),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_kasumi_cipher_auth_test_case_1),
8992 /** Negative tests */
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 authentication_verify_AES128_GMAC_fail_data_corrupt),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9006 TEST_CASES_END() /**< NULL terminate unit test array */
9010 static struct unit_test_suite cryptodev_virtio_testsuite = {
9011 .suite_name = "Crypto VIRTIO Unit Test Suite",
9012 .setup = testsuite_setup,
9013 .teardown = testsuite_teardown,
9014 .unit_test_cases = {
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_cipheronly_virtio_all),
9018 TEST_CASES_END() /**< NULL terminate unit test array */
9022 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9023 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9024 .setup = testsuite_setup,
9025 .teardown = testsuite_teardown,
9026 .unit_test_cases = {
9027 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9028 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9029 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9030 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_DES_cipheronly_mb_all),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_DES_docsis_mb_all),
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_CCM_authenticated_encryption_test_case_128_1),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_CCM_authenticated_decryption_test_case_128_1),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_CCM_authenticated_encryption_test_case_128_2),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_AES_CCM_authenticated_decryption_test_case_128_2),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_CCM_authenticated_encryption_test_case_128_3),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_CCM_authenticated_decryption_test_case_128_3),
9048 TEST_CASES_END() /**< NULL terminate unit test array */
9052 static struct unit_test_suite cryptodev_openssl_testsuite = {
9053 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9054 .setup = testsuite_setup,
9055 .teardown = testsuite_teardown,
9056 .unit_test_cases = {
9057 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_multi_session_random_usage),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_chain_openssl_all),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_cipheronly_openssl_all),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_3DES_chain_openssl_all),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_3DES_cipheronly_openssl_all),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_DES_cipheronly_openssl_all),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_DES_docsis_openssl_all),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_authonly_openssl_all),
9075 /** AES GCM Authenticated Encryption */
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GCM_authenticated_encryption_test_case_1),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GCM_authenticated_encryption_test_case_2),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_authenticated_encryption_test_case_3),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GCM_authenticated_encryption_test_case_4),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_authenticated_encryption_test_case_5),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_authenticated_encryption_test_case_6),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GCM_authenticated_encryption_test_case_7),
9091 /** AES GCM Authenticated Decryption */
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_GCM_authenticated_decryption_test_case_1),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_authenticated_decryption_test_case_2),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_authenticated_decryption_test_case_3),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_authenticated_decryption_test_case_4),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_authenticated_decryption_test_case_5),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_authenticated_decryption_test_case_6),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_decryption_test_case_7),
9108 /** AES GCM Authenticated Encryption 192 bits key */
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_AES_GCM_auth_encryption_test_case_192_1),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_AES_GCM_auth_encryption_test_case_192_2),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_AES_GCM_auth_encryption_test_case_192_3),
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_AES_GCM_auth_encryption_test_case_192_4),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_AES_GCM_auth_encryption_test_case_192_5),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_AES_GCM_auth_encryption_test_case_192_6),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_AES_GCM_auth_encryption_test_case_192_7),
9124 /** AES GCM Authenticated Decryption 192 bits key */
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_AES_GCM_auth_decryption_test_case_192_1),
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_AES_GCM_auth_decryption_test_case_192_2),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_AES_GCM_auth_decryption_test_case_192_3),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_AES_GCM_auth_decryption_test_case_192_4),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_AES_GCM_auth_decryption_test_case_192_5),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_AES_GCM_auth_decryption_test_case_192_6),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_AES_GCM_auth_decryption_test_case_192_7),
9140 /** AES GCM Authenticated Encryption 256 bits key */
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_AES_GCM_auth_encryption_test_case_256_1),
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_AES_GCM_auth_encryption_test_case_256_2),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_AES_GCM_auth_encryption_test_case_256_3),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_AES_GCM_auth_encryption_test_case_256_4),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_AES_GCM_auth_encryption_test_case_256_5),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_AES_GCM_auth_encryption_test_case_256_6),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_AES_GCM_auth_encryption_test_case_256_7),
9156 /** AES GCM Authenticated Decryption 256 bits key */
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_AES_GCM_auth_decryption_test_case_256_1),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_AES_GCM_auth_decryption_test_case_256_2),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_AES_GCM_auth_decryption_test_case_256_3),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_AES_GCM_auth_decryption_test_case_256_4),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_AES_GCM_auth_decryption_test_case_256_5),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_AES_GCM_auth_decryption_test_case_256_6),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_AES_GCM_auth_decryption_test_case_256_7),
9172 /** AES GMAC Authentication */
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_AES_GMAC_authentication_test_case_1),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_AES_GMAC_authentication_verify_test_case_1),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_AES_GMAC_authentication_test_case_2),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_AES_GMAC_authentication_verify_test_case_2),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_AES_GMAC_authentication_test_case_3),
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_AES_GMAC_authentication_verify_test_case_3),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_GMAC_authentication_test_case_4),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_AES_GMAC_authentication_verify_test_case_4),
9190 /** AES CCM Authenticated Encryption 128 bits key */
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_AES_CCM_authenticated_encryption_test_case_128_1),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_CCM_authenticated_encryption_test_case_128_2),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_CCM_authenticated_encryption_test_case_128_3),
9198 /** AES CCM Authenticated Decryption 128 bits key*/
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_AES_CCM_authenticated_decryption_test_case_128_1),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_CCM_authenticated_decryption_test_case_128_2),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_AES_CCM_authenticated_decryption_test_case_128_3),
9206 /** AES CCM Authenticated Encryption 192 bits key */
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_AES_CCM_authenticated_encryption_test_case_192_1),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_AES_CCM_authenticated_encryption_test_case_192_2),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_AES_CCM_authenticated_encryption_test_case_192_3),
9214 /** AES CCM Authenticated Decryption 192 bits key*/
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_AES_CCM_authenticated_decryption_test_case_192_1),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_AES_CCM_authenticated_decryption_test_case_192_2),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_AES_CCM_authenticated_decryption_test_case_192_3),
9222 /** AES CCM Authenticated Encryption 256 bits key */
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_AES_CCM_authenticated_encryption_test_case_256_1),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_AES_CCM_authenticated_encryption_test_case_256_2),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_CCM_authenticated_encryption_test_case_256_3),
9230 /** AES CCM Authenticated Decryption 256 bits key*/
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_CCM_authenticated_decryption_test_case_256_1),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_AES_CCM_authenticated_decryption_test_case_256_2),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_AES_CCM_authenticated_decryption_test_case_256_3),
9238 /** Scatter-Gather */
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9242 /** Negative tests */
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 authentication_verify_AES128_GMAC_fail_data_corrupt),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9256 TEST_CASES_END() /**< NULL terminate unit test array */
9260 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9261 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9262 .setup = testsuite_setup,
9263 .teardown = testsuite_teardown,
9264 .unit_test_cases = {
9265 /** AES GCM Authenticated Encryption */
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_AES_GCM_authenticated_encryption_test_case_1),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_AES_GCM_authenticated_encryption_test_case_2),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_GCM_authenticated_encryption_test_case_3),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_AES_GCM_authenticated_encryption_test_case_4),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_GCM_authenticated_encryption_test_case_5),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_AES_GCM_authenticated_encryption_test_case_6),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_AES_GCM_authenticated_encryption_test_case_7),
9281 /** AES GCM Authenticated Decryption */
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_authenticated_decryption_test_case_1),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_authenticated_decryption_test_case_2),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_authenticated_decryption_test_case_3),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_authenticated_decryption_test_case_4),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_authenticated_decryption_test_case_5),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_authenticated_decryption_test_case_6),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_authenticated_decryption_test_case_7),
9297 /** AES GCM Authenticated Encryption 192 bits key */
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_auth_encryption_test_case_192_1),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_auth_encryption_test_case_192_2),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_auth_encryption_test_case_192_3),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_auth_encryption_test_case_192_4),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_auth_encryption_test_case_192_5),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_auth_encryption_test_case_192_6),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_auth_encryption_test_case_192_7),
9313 /** AES GCM Authenticated Decryption 192 bits key */
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_auth_decryption_test_case_192_1),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_decryption_test_case_192_2),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_decryption_test_case_192_3),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_decryption_test_case_192_4),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_decryption_test_case_192_5),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_decryption_test_case_192_6),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_decryption_test_case_192_7),
9329 /** AES GCM Authenticated Encryption 256 bits key */
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_encryption_test_case_256_1),
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_auth_encryption_test_case_256_2),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_encryption_test_case_256_3),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_auth_encryption_test_case_256_4),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_encryption_test_case_256_5),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_auth_encryption_test_case_256_6),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_auth_encryption_test_case_256_7),
9345 /** AES GCM Authenticated Decryption 256 bits key */
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_auth_decryption_test_case_256_1),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_auth_decryption_test_case_256_2),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_auth_decryption_test_case_256_3),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_auth_decryption_test_case_256_4),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_auth_decryption_test_case_256_5),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_GCM_auth_decryption_test_case_256_6),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_auth_decryption_test_case_256_7),
9361 /** AES GCM Authenticated Encryption big aad size */
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_auth_encryption_test_case_aad_1),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_auth_encryption_test_case_aad_2),
9367 /** AES GCM Authenticated Decryption big aad size */
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_auth_decryption_test_case_aad_1),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_auth_decryption_test_case_aad_2),
9373 /** AES GMAC Authentication */
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GMAC_authentication_test_case_1),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GMAC_authentication_verify_test_case_1),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GMAC_authentication_test_case_3),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_AES_GMAC_authentication_verify_test_case_3),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GMAC_authentication_test_case_4),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GMAC_authentication_verify_test_case_4),
9387 /** Negative tests */
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 authentication_verify_AES128_GMAC_fail_data_corrupt),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9393 /** Out of place tests */
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9399 /** Session-less tests */
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9405 /** Scatter-Gather */
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9409 TEST_CASES_END() /**< NULL terminate unit test array */
9413 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9414 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9415 .setup = testsuite_setup,
9416 .teardown = testsuite_teardown,
9417 .unit_test_cases = {
9418 /** KASUMI encrypt only (UEA1) */
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_kasumi_encryption_test_case_1),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_kasumi_encryption_test_case_1_sgl),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_kasumi_encryption_test_case_2),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_kasumi_encryption_test_case_3),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_kasumi_encryption_test_case_4),
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_kasumi_encryption_test_case_5),
9431 /** KASUMI decrypt only (UEA1) */
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_kasumi_decryption_test_case_1),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_kasumi_decryption_test_case_2),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_kasumi_decryption_test_case_3),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_kasumi_decryption_test_case_4),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_kasumi_decryption_test_case_5),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_kasumi_encryption_test_case_1_oop),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_kasumi_encryption_test_case_1_oop_sgl),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_kasumi_decryption_test_case_1_oop),
9452 /** KASUMI hash only (UIA1) */
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_kasumi_hash_generate_test_case_1),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_kasumi_hash_generate_test_case_2),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_kasumi_hash_generate_test_case_3),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_kasumi_hash_generate_test_case_4),
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_kasumi_hash_generate_test_case_5),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_kasumi_hash_generate_test_case_6),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_kasumi_hash_verify_test_case_1),
9467 TEST_CASE_ST(ut_setup, ut_teardown,
9468 test_kasumi_hash_verify_test_case_2),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_kasumi_hash_verify_test_case_3),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_kasumi_hash_verify_test_case_4),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_kasumi_hash_verify_test_case_5),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_kasumi_auth_cipher_test_case_1),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_kasumi_cipher_auth_test_case_1),
9479 TEST_CASES_END() /**< NULL terminate unit test array */
9482 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9483 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9484 .setup = testsuite_setup,
9485 .teardown = testsuite_teardown,
9486 .unit_test_cases = {
9487 /** SNOW 3G encrypt only (UEA2) */
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_snow3g_encryption_test_case_1),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_snow3g_encryption_test_case_2),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_snow3g_encryption_test_case_3),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_snow3g_encryption_test_case_4),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_snow3g_encryption_test_case_5),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_snow3g_encryption_test_case_1_oop),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_snow3g_encryption_test_case_1_oop_sgl),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_snow3g_decryption_test_case_1_oop),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_snow3g_encryption_test_case_1_offset_oop),
9509 /** SNOW 3G decrypt only (UEA2) */
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_snow3g_decryption_test_case_1),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_snow3g_decryption_test_case_2),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_decryption_test_case_3),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_decryption_test_case_4),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_snow3g_decryption_test_case_5),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_snow3g_hash_generate_test_case_1),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_snow3g_hash_generate_test_case_2),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_snow3g_hash_generate_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_generate_test_case_4),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_snow3g_hash_generate_test_case_5),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_snow3g_hash_generate_test_case_6),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_snow3g_hash_verify_test_case_1),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_snow3g_hash_verify_test_case_2),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_snow3g_hash_verify_test_case_3),
9539 /* Tests with buffers which length is not byte-aligned */
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_snow3g_hash_verify_test_case_4),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_snow3g_hash_verify_test_case_5),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_snow3g_hash_verify_test_case_6),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_snow3g_cipher_auth_test_case_1),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_snow3g_auth_cipher_test_case_1),
9551 TEST_CASES_END() /**< NULL terminate unit test array */
9555 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9556 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9557 .setup = testsuite_setup,
9558 .teardown = testsuite_teardown,
9559 .unit_test_cases = {
9560 /** ZUC encrypt only (EEA3) */
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_zuc_encryption_test_case_1),
9563 TEST_CASE_ST(ut_setup, ut_teardown,
9564 test_zuc_encryption_test_case_2),
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 test_zuc_encryption_test_case_3),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_zuc_encryption_test_case_4),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_zuc_encryption_test_case_5),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_zuc_hash_generate_test_case_1),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_zuc_hash_generate_test_case_2),
9575 TEST_CASE_ST(ut_setup, ut_teardown,
9576 test_zuc_hash_generate_test_case_3),
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_zuc_hash_generate_test_case_4),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_zuc_hash_generate_test_case_5),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_zuc_encryption_test_case_6_sgl),
9583 TEST_CASES_END() /**< NULL terminate unit test array */
9587 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9588 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9589 .setup = testsuite_setup,
9590 .teardown = testsuite_teardown,
9591 .unit_test_cases = {
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_device_configure_invalid_dev_id),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_multi_session),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_chain_dpaa_sec_all),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_3DES_chain_dpaa_sec_all),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_cipheronly_dpaa_sec_all),
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_3DES_cipheronly_dpaa_sec_all),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_authonly_dpaa_sec_all),
9608 /** AES GCM Authenticated Encryption */
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_GCM_authenticated_encryption_test_case_1),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_authenticated_encryption_test_case_2),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_GCM_authenticated_encryption_test_case_3),
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_authenticated_encryption_test_case_4),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_authenticated_encryption_test_case_5),
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_AES_GCM_authenticated_encryption_test_case_6),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_authenticated_encryption_test_case_7),
9624 /** AES GCM Authenticated Decryption */
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_AES_GCM_authenticated_decryption_test_case_1),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_authenticated_decryption_test_case_2),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_authenticated_decryption_test_case_3),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_authenticated_decryption_test_case_4),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_authenticated_decryption_test_case_5),
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_authenticated_decryption_test_case_6),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_authenticated_decryption_test_case_7),
9640 /** AES GCM Authenticated Encryption 256 bits key */
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_auth_encryption_test_case_256_1),
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_auth_encryption_test_case_256_2),
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_auth_encryption_test_case_256_3),
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_auth_encryption_test_case_256_4),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_auth_encryption_test_case_256_5),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_auth_encryption_test_case_256_6),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_encryption_test_case_256_7),
9656 /** AES GCM Authenticated Decryption 256 bits key */
9657 TEST_CASE_ST(ut_setup, ut_teardown,
9658 test_AES_GCM_auth_decryption_test_case_256_1),
9659 TEST_CASE_ST(ut_setup, ut_teardown,
9660 test_AES_GCM_auth_decryption_test_case_256_2),
9661 TEST_CASE_ST(ut_setup, ut_teardown,
9662 test_AES_GCM_auth_decryption_test_case_256_3),
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_auth_decryption_test_case_256_4),
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_AES_GCM_auth_decryption_test_case_256_5),
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_AES_GCM_auth_decryption_test_case_256_6),
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_auth_decryption_test_case_256_7),
9672 /** Out of place tests */
9673 TEST_CASE_ST(ut_setup, ut_teardown,
9674 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9675 TEST_CASE_ST(ut_setup, ut_teardown,
9676 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9678 /** Scatter-Gather */
9679 TEST_CASE_ST(ut_setup, ut_teardown,
9680 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9681 TEST_CASE_ST(ut_setup, ut_teardown,
9682 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9683 TEST_CASE_ST(ut_setup, ut_teardown,
9684 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9688 TEST_CASES_END() /**< NULL terminate unit test array */
9692 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9693 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9694 .setup = testsuite_setup,
9695 .teardown = testsuite_teardown,
9696 .unit_test_cases = {
9697 TEST_CASE_ST(ut_setup, ut_teardown,
9698 test_device_configure_invalid_dev_id),
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_multi_session),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_chain_dpaa2_sec_all),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_3DES_chain_dpaa2_sec_all),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_cipheronly_dpaa2_sec_all),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_3DES_cipheronly_dpaa2_sec_all),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 test_authonly_dpaa2_sec_all),
9713 /** AES GCM Authenticated Encryption */
9714 TEST_CASE_ST(ut_setup, ut_teardown,
9715 test_AES_GCM_authenticated_encryption_test_case_1),
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_GCM_authenticated_encryption_test_case_2),
9718 TEST_CASE_ST(ut_setup, ut_teardown,
9719 test_AES_GCM_authenticated_encryption_test_case_3),
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_GCM_authenticated_encryption_test_case_4),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_GCM_authenticated_encryption_test_case_5),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_GCM_authenticated_encryption_test_case_6),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_GCM_authenticated_encryption_test_case_7),
9729 /** AES GCM Authenticated Decryption */
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_GCM_authenticated_decryption_test_case_1),
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_GCM_authenticated_decryption_test_case_2),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_authenticated_decryption_test_case_3),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_authenticated_decryption_test_case_4),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_AES_GCM_authenticated_decryption_test_case_5),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_AES_GCM_authenticated_decryption_test_case_6),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_AES_GCM_authenticated_decryption_test_case_7),
9745 /** AES GCM Authenticated Encryption 192 bits key */
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_AES_GCM_auth_encryption_test_case_192_1),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_AES_GCM_auth_encryption_test_case_192_2),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_AES_GCM_auth_encryption_test_case_192_3),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GCM_auth_encryption_test_case_192_4),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GCM_auth_encryption_test_case_192_5),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GCM_auth_encryption_test_case_192_6),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GCM_auth_encryption_test_case_192_7),
9761 /** AES GCM Authenticated Decryption 192 bits key */
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_GCM_auth_decryption_test_case_192_1),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_AES_GCM_auth_decryption_test_case_192_2),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_AES_GCM_auth_decryption_test_case_192_3),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_AES_GCM_auth_decryption_test_case_192_4),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_AES_GCM_auth_decryption_test_case_192_5),
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_auth_decryption_test_case_192_6),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_auth_decryption_test_case_192_7),
9777 /** AES GCM Authenticated Encryption 256 bits key */
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 test_AES_GCM_auth_encryption_test_case_256_1),
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 test_AES_GCM_auth_encryption_test_case_256_2),
9782 TEST_CASE_ST(ut_setup, ut_teardown,
9783 test_AES_GCM_auth_encryption_test_case_256_3),
9784 TEST_CASE_ST(ut_setup, ut_teardown,
9785 test_AES_GCM_auth_encryption_test_case_256_4),
9786 TEST_CASE_ST(ut_setup, ut_teardown,
9787 test_AES_GCM_auth_encryption_test_case_256_5),
9788 TEST_CASE_ST(ut_setup, ut_teardown,
9789 test_AES_GCM_auth_encryption_test_case_256_6),
9790 TEST_CASE_ST(ut_setup, ut_teardown,
9791 test_AES_GCM_auth_encryption_test_case_256_7),
9793 /** AES GCM Authenticated Decryption 256 bits key */
9794 TEST_CASE_ST(ut_setup, ut_teardown,
9795 test_AES_GCM_auth_decryption_test_case_256_1),
9796 TEST_CASE_ST(ut_setup, ut_teardown,
9797 test_AES_GCM_auth_decryption_test_case_256_2),
9798 TEST_CASE_ST(ut_setup, ut_teardown,
9799 test_AES_GCM_auth_decryption_test_case_256_3),
9800 TEST_CASE_ST(ut_setup, ut_teardown,
9801 test_AES_GCM_auth_decryption_test_case_256_4),
9802 TEST_CASE_ST(ut_setup, ut_teardown,
9803 test_AES_GCM_auth_decryption_test_case_256_5),
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_AES_GCM_auth_decryption_test_case_256_6),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_AES_GCM_auth_decryption_test_case_256_7),
9809 /** Out of place tests */
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9815 /** Scatter-Gather */
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9818 TEST_CASE_ST(ut_setup, ut_teardown,
9819 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9820 TEST_CASE_ST(ut_setup, ut_teardown,
9821 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9822 TEST_CASE_ST(ut_setup, ut_teardown,
9823 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9825 TEST_CASES_END() /**< NULL terminate unit test array */
9829 static struct unit_test_suite cryptodev_null_testsuite = {
9830 .suite_name = "Crypto Device NULL Unit Test Suite",
9831 .setup = testsuite_setup,
9832 .teardown = testsuite_teardown,
9833 .unit_test_cases = {
9834 TEST_CASE_ST(ut_setup, ut_teardown,
9835 test_null_auth_only_operation),
9836 TEST_CASE_ST(ut_setup, ut_teardown,
9837 test_null_cipher_only_operation),
9838 TEST_CASE_ST(ut_setup, ut_teardown,
9839 test_null_cipher_auth_operation),
9840 TEST_CASE_ST(ut_setup, ut_teardown,
9841 test_null_auth_cipher_operation),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_null_invalid_operation),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_null_burst_operation),
9847 TEST_CASES_END() /**< NULL terminate unit test array */
9851 static struct unit_test_suite cryptodev_armv8_testsuite = {
9852 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9853 .setup = testsuite_setup,
9854 .teardown = testsuite_teardown,
9855 .unit_test_cases = {
9856 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9858 /** Negative tests */
9859 TEST_CASE_ST(ut_setup, ut_teardown,
9860 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9864 TEST_CASES_END() /**< NULL terminate unit test array */
9868 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9869 .suite_name = "Crypto Device Marvell Component Test Suite",
9870 .setup = testsuite_setup,
9871 .teardown = testsuite_teardown,
9872 .unit_test_cases = {
9873 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9874 TEST_CASE_ST(ut_setup, ut_teardown,
9875 test_multi_session_random_usage),
9876 TEST_CASE_ST(ut_setup, ut_teardown,
9877 test_AES_chain_mrvl_all),
9878 TEST_CASE_ST(ut_setup, ut_teardown,
9879 test_AES_cipheronly_mrvl_all),
9880 TEST_CASE_ST(ut_setup, ut_teardown,
9881 test_authonly_mrvl_all),
9882 TEST_CASE_ST(ut_setup, ut_teardown,
9883 test_3DES_chain_mrvl_all),
9884 TEST_CASE_ST(ut_setup, ut_teardown,
9885 test_3DES_cipheronly_mrvl_all),
9887 /** Negative tests */
9888 TEST_CASE_ST(ut_setup, ut_teardown,
9889 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9890 TEST_CASE_ST(ut_setup, ut_teardown,
9891 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9892 TEST_CASE_ST(ut_setup, ut_teardown,
9893 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9897 TEST_CASES_END() /**< NULL terminate unit test array */
9901 static struct unit_test_suite cryptodev_ccp_testsuite = {
9902 .suite_name = "Crypto Device CCP Unit Test Suite",
9903 .setup = testsuite_setup,
9904 .teardown = testsuite_teardown,
9905 .unit_test_cases = {
9906 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9907 TEST_CASE_ST(ut_setup, ut_teardown,
9908 test_multi_session_random_usage),
9909 TEST_CASE_ST(ut_setup, ut_teardown,
9910 test_AES_chain_ccp_all),
9911 TEST_CASE_ST(ut_setup, ut_teardown,
9912 test_AES_cipheronly_ccp_all),
9913 TEST_CASE_ST(ut_setup, ut_teardown,
9914 test_3DES_chain_ccp_all),
9915 TEST_CASE_ST(ut_setup, ut_teardown,
9916 test_3DES_cipheronly_ccp_all),
9917 TEST_CASE_ST(ut_setup, ut_teardown,
9918 test_authonly_ccp_all),
9920 /** Negative tests */
9921 TEST_CASE_ST(ut_setup, ut_teardown,
9922 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9923 TEST_CASE_ST(ut_setup, ut_teardown,
9924 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9925 TEST_CASE_ST(ut_setup, ut_teardown,
9926 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9927 TEST_CASE_ST(ut_setup, ut_teardown,
9928 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9930 TEST_CASES_END() /**< NULL terminate unit test array */
9935 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9937 gbl_driver_id = rte_cryptodev_driver_id_get(
9938 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9940 if (gbl_driver_id == -1) {
9941 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9942 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9943 "in config file to run this testsuite.\n");
9944 return TEST_SKIPPED;
9947 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9951 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9953 gbl_driver_id = rte_cryptodev_driver_id_get(
9954 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9956 if (gbl_driver_id == -1) {
9957 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9958 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9959 "in config file to run this testsuite.\n");
9963 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9967 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9969 gbl_driver_id = rte_cryptodev_driver_id_get(
9970 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9972 if (gbl_driver_id == -1) {
9973 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9974 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9975 "in config file to run this testsuite.\n");
9976 return TEST_SKIPPED;
9979 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9983 test_cryptodev_openssl(void)
9985 gbl_driver_id = rte_cryptodev_driver_id_get(
9986 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9988 if (gbl_driver_id == -1) {
9989 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9990 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9991 "in config file to run this testsuite.\n");
9992 return TEST_SKIPPED;
9995 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9999 test_cryptodev_aesni_gcm(void)
10001 gbl_driver_id = rte_cryptodev_driver_id_get(
10002 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10004 if (gbl_driver_id == -1) {
10005 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10006 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10007 "in config file to run this testsuite.\n");
10008 return TEST_SKIPPED;
10011 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10015 test_cryptodev_null(void)
10017 gbl_driver_id = rte_cryptodev_driver_id_get(
10018 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10020 if (gbl_driver_id == -1) {
10021 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10022 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10023 "in config file to run this testsuite.\n");
10024 return TEST_SKIPPED;
10027 return unit_test_suite_runner(&cryptodev_null_testsuite);
10031 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10033 gbl_driver_id = rte_cryptodev_driver_id_get(
10034 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10036 if (gbl_driver_id == -1) {
10037 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10038 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10039 "in config file to run this testsuite.\n");
10040 return TEST_SKIPPED;
10043 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10047 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10049 gbl_driver_id = rte_cryptodev_driver_id_get(
10050 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10052 if (gbl_driver_id == -1) {
10053 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10054 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10055 "in config file to run this testsuite.\n");
10056 return TEST_SKIPPED;
10059 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10063 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10065 gbl_driver_id = rte_cryptodev_driver_id_get(
10066 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10068 if (gbl_driver_id == -1) {
10069 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10070 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10071 "in config file to run this testsuite.\n");
10072 return TEST_SKIPPED;
10075 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10079 test_cryptodev_armv8(void)
10081 gbl_driver_id = rte_cryptodev_driver_id_get(
10082 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10084 if (gbl_driver_id == -1) {
10085 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10086 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10087 "in config file to run this testsuite.\n");
10088 return TEST_SKIPPED;
10091 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10095 test_cryptodev_mrvl(void)
10097 gbl_driver_id = rte_cryptodev_driver_id_get(
10098 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10100 if (gbl_driver_id == -1) {
10101 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10102 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10103 "in config file to run this testsuite.\n");
10104 return TEST_SKIPPED;
10107 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10110 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10113 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10115 gbl_driver_id = rte_cryptodev_driver_id_get(
10116 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10118 if (gbl_driver_id == -1) {
10119 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10120 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10121 "in config file to run this testsuite.\n");
10122 return TEST_SKIPPED;
10125 if (rte_cryptodev_driver_id_get(
10126 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10127 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10128 " enabled in config file to run this testsuite.\n");
10129 return TEST_SKIPPED;
10131 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10134 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10139 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10141 gbl_driver_id = rte_cryptodev_driver_id_get(
10142 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10144 if (gbl_driver_id == -1) {
10145 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10146 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10147 "in config file to run this testsuite.\n");
10148 return TEST_SKIPPED;
10151 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10155 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10157 gbl_driver_id = rte_cryptodev_driver_id_get(
10158 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10160 if (gbl_driver_id == -1) {
10161 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10162 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10163 "in config file to run this testsuite.\n");
10164 return TEST_SKIPPED;
10167 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10171 test_cryptodev_ccp(void)
10173 gbl_driver_id = rte_cryptodev_driver_id_get(
10174 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10176 if (gbl_driver_id == -1) {
10177 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10178 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10179 "in config file to run this testsuite.\n");
10180 return TEST_FAILED;
10183 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10186 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10187 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10188 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10189 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10190 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10191 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10192 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10193 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10194 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10195 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10196 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10197 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10198 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10199 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);