4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
81 struct rte_cryptodev_sym_session *sess;
83 struct rte_crypto_op *op;
85 struct rte_mbuf *obuf, *ibuf;
90 #define ALIGN_POW2_ROUNDUP(num, align) \
91 (((num) + (align) - 1) & ~((align) - 1))
94 * Forward declarations.
97 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
98 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
102 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
103 struct crypto_unittest_params *ut_params,
104 struct crypto_testsuite_params *ts_param,
105 const uint8_t *cipher,
106 const uint8_t *digest,
109 static struct rte_mbuf *
110 setup_test_string(struct rte_mempool *mpool,
111 const char *string, size_t len, uint8_t blocksize)
113 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
114 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
116 memset(m->buf_addr, 0, m->buf_len);
118 char *dst = rte_pktmbuf_append(m, t_len);
125 rte_memcpy(dst, string, t_len);
127 memset(dst, 0, t_len);
133 /* Get number of bytes in X bits (rounding up) */
135 ceil_byte_length(uint32_t num_bits)
138 return ((num_bits >> 3) + 1);
140 return (num_bits >> 3);
143 static struct rte_crypto_op *
144 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
146 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
147 printf("Error sending packet for encryption");
153 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
159 static struct crypto_testsuite_params testsuite_params = { NULL };
160 static struct crypto_unittest_params unittest_params;
163 testsuite_setup(void)
165 struct crypto_testsuite_params *ts_params = &testsuite_params;
166 struct rte_cryptodev_info info;
167 uint32_t i = 0, nb_devs, dev_id;
171 memset(ts_params, 0, sizeof(*ts_params));
173 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
174 if (ts_params->mbuf_pool == NULL) {
175 /* Not already created so create */
176 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
178 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
180 if (ts_params->mbuf_pool == NULL) {
181 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 ts_params->large_mbuf_pool = rte_mempool_lookup(
187 "CRYPTO_LARGE_MBUFPOOL");
188 if (ts_params->large_mbuf_pool == NULL) {
189 /* Not already created so create */
190 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
191 "CRYPTO_LARGE_MBUFPOOL",
194 if (ts_params->large_mbuf_pool == NULL) {
196 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 ts_params->op_mpool = rte_crypto_op_pool_create(
202 "MBUF_CRYPTO_SYM_OP_POOL",
203 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
204 NUM_MBUFS, MBUF_CACHE_SIZE,
206 sizeof(struct rte_crypto_sym_xform) +
209 if (ts_params->op_mpool == NULL) {
210 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
214 /* Create an AESNI MB device if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_MB
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_MB_PMD);
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
236 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(
242 RTE_CRYPTODEV_AESNI_GCM_PMD);
244 TEST_ASSERT_SUCCESS(rte_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
246 "Failed to create instance of"
248 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
252 /* Create a SNOW 3G device if required */
253 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
254 #ifndef RTE_LIBRTE_PMD_SNOW3G
255 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
256 " enabled in config file to run this testsuite.\n");
259 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
261 TEST_ASSERT_SUCCESS(rte_vdev_init(
262 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
263 "Failed to create instance of"
265 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create a KASUMI device if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 TEST_ASSERT_SUCCESS(rte_vdev_init(
279 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
280 "Failed to create instance of"
282 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
286 /* Create a ZUC device if required */
287 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
288 #ifndef RTE_LIBRTE_PMD_ZUC
289 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
290 " enabled in config file to run this testsuite.\n");
293 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
295 TEST_ASSERT_SUCCESS(rte_vdev_init(
296 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
297 "Failed to create instance of"
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
303 /* Create a NULL device if required */
304 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
305 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
306 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
307 " enabled in config file to run this testsuite.\n");
310 nb_devs = rte_cryptodev_count_devtype(
311 RTE_CRYPTODEV_NULL_PMD);
314 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
316 TEST_ASSERT(ret == 0,
317 "Failed to create instance of"
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
323 /* Create an OPENSSL device if required */
324 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
325 #ifndef RTE_LIBRTE_PMD_OPENSSL
326 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
327 " enabled in config file to run this testsuite.\n");
330 nb_devs = rte_cryptodev_count_devtype(
331 RTE_CRYPTODEV_OPENSSL_PMD);
334 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
343 /* Create a ARMv8 device if required */
344 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
345 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
346 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
347 " enabled in config file to run this testsuite.\n");
350 nb_devs = rte_cryptodev_count_devtype(
351 RTE_CRYPTODEV_ARMV8_PMD);
354 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
366 #ifndef RTE_LIBRTE_PMD_AESNI_MB
367 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
368 " enabled in config file to run this testsuite.\n");
371 nb_devs = rte_cryptodev_count_devtype(
372 RTE_CRYPTODEV_SCHEDULER_PMD);
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
378 TEST_ASSERT(ret == 0,
379 "Failed to create instance %u of"
381 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
384 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
386 #ifndef RTE_LIBRTE_PMD_QAT
387 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
388 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
389 "in config file to run this testsuite.\n");
394 nb_devs = rte_cryptodev_count();
396 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
400 /* Create list of valid crypto devs */
401 for (i = 0; i < nb_devs; i++) {
402 rte_cryptodev_info_get(i, &info);
403 if (info.dev_type == gbl_cryptodev_type)
404 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
407 if (ts_params->valid_dev_count < 1)
410 /* Set up all the qps on the first of the valid devices found */
412 dev_id = ts_params->valid_devs[0];
414 rte_cryptodev_info_get(dev_id, &info);
416 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
417 ts_params->conf.socket_id = SOCKET_ID_ANY;
418 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
422 "Failed to configure cryptodev %u with %u qps",
423 dev_id, ts_params->conf.nb_queue_pairs);
425 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
427 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
428 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
429 dev_id, qp_id, &ts_params->qp_conf,
430 rte_cryptodev_socket_id(dev_id)),
431 "Failed to setup queue pair %u on cryptodev %u",
439 testsuite_teardown(void)
441 struct crypto_testsuite_params *ts_params = &testsuite_params;
443 if (ts_params->mbuf_pool != NULL) {
444 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
445 rte_mempool_avail_count(ts_params->mbuf_pool));
448 if (ts_params->op_mpool != NULL) {
449 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
450 rte_mempool_avail_count(ts_params->op_mpool));
458 struct crypto_testsuite_params *ts_params = &testsuite_params;
459 struct crypto_unittest_params *ut_params = &unittest_params;
463 /* Clear unit test parameters before running test */
464 memset(ut_params, 0, sizeof(*ut_params));
466 /* Reconfigure device to default parameters */
467 ts_params->conf.socket_id = SOCKET_ID_ANY;
468 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
470 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
475 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 ts_params->valid_devs[0], qp_id,
479 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
480 "Failed to setup queue pair %u on cryptodev %u",
481 qp_id, ts_params->valid_devs[0]);
485 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
487 /* Start the device */
488 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
489 "Failed to start cryptodev %u",
490 ts_params->valid_devs[0]);
498 struct crypto_testsuite_params *ts_params = &testsuite_params;
499 struct crypto_unittest_params *ut_params = &unittest_params;
500 struct rte_cryptodev_stats stats;
502 /* free crypto session structure */
503 if (ut_params->sess) {
504 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
506 ut_params->sess = NULL;
509 /* free crypto operation structure */
511 rte_crypto_op_free(ut_params->op);
514 * free mbuf - both obuf and ibuf are usually the same,
515 * so check if they point at the same address is necessary,
516 * to avoid freeing the mbuf twice.
518 if (ut_params->obuf) {
519 rte_pktmbuf_free(ut_params->obuf);
520 if (ut_params->ibuf == ut_params->obuf)
524 if (ut_params->ibuf) {
525 rte_pktmbuf_free(ut_params->ibuf);
529 if (ts_params->mbuf_pool != NULL)
530 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
531 rte_mempool_avail_count(ts_params->mbuf_pool));
533 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
535 /* Stop the device */
536 rte_cryptodev_stop(ts_params->valid_devs[0]);
540 test_device_configure_invalid_dev_id(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 uint16_t dev_id, num_devs = 0;
545 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
546 "Need at least %d devices for test", 1);
548 /* valid dev_id values */
549 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
551 /* Stop the device in case it's started so it can be configured */
552 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
554 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
558 /* invalid dev_id values */
561 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
562 "Failed test for rte_cryptodev_configure: "
563 "invalid dev_num %u", dev_id);
567 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
568 "Failed test for rte_cryptodev_configure:"
569 "invalid dev_num %u", dev_id);
575 test_device_configure_invalid_queue_pair_ids(void)
577 struct crypto_testsuite_params *ts_params = &testsuite_params;
578 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
580 /* Stop the device in case it's started so it can be configured */
581 rte_cryptodev_stop(ts_params->valid_devs[0]);
583 /* valid - one queue pairs */
584 ts_params->conf.nb_queue_pairs = 1;
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
588 "Failed to configure cryptodev: dev_id %u, qp_id %u",
589 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
592 /* valid - max value queue pairs */
593 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
595 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed to configure cryptodev: dev_id %u, qp_id %u",
598 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
601 /* invalid - zero queue pairs */
602 ts_params->conf.nb_queue_pairs = 0;
604 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed test for rte_cryptodev_configure, dev_id %u,"
608 ts_params->valid_devs[0],
609 ts_params->conf.nb_queue_pairs);
612 /* invalid - max value supported by field queue pairs */
613 ts_params->conf.nb_queue_pairs = UINT16_MAX;
615 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
617 "Failed test for rte_cryptodev_configure, dev_id %u,"
619 ts_params->valid_devs[0],
620 ts_params->conf.nb_queue_pairs);
623 /* invalid - max value + 1 queue pairs */
624 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
626 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
628 "Failed test for rte_cryptodev_configure, dev_id %u,"
630 ts_params->valid_devs[0],
631 ts_params->conf.nb_queue_pairs);
633 /* revert to original testsuite value */
634 ts_params->conf.nb_queue_pairs = orig_nb_qps;
640 test_queue_pair_descriptor_setup(void)
642 struct crypto_testsuite_params *ts_params = &testsuite_params;
643 struct rte_cryptodev_info dev_info;
644 struct rte_cryptodev_qp_conf qp_conf = {
645 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
650 /* Stop the device in case it's started so it can be configured */
651 rte_cryptodev_stop(ts_params->valid_devs[0]);
654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
656 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
658 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
659 &ts_params->conf), "Failed to configure cryptodev %u",
660 ts_params->valid_devs[0]);
664 * Test various ring sizes on this device. memzones can't be
665 * freed so are re-used if ring is released and re-created.
667 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
669 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
670 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
671 ts_params->valid_devs[0], qp_id, &qp_conf,
672 rte_cryptodev_socket_id(
673 ts_params->valid_devs[0])),
675 "rte_cryptodev_queue_pair_setup: num_inflights "
676 "%u on qp %u on cryptodev %u",
677 qp_conf.nb_descriptors, qp_id,
678 ts_params->valid_devs[0]);
681 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0])),
689 " rte_cryptodev_queue_pair_setup: num_inflights"
690 " %u on qp %u on cryptodev %u",
691 qp_conf.nb_descriptors, qp_id,
692 ts_params->valid_devs[0]);
695 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
697 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
698 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
699 ts_params->valid_devs[0], qp_id, &qp_conf,
700 rte_cryptodev_socket_id(
701 ts_params->valid_devs[0])),
703 "rte_cryptodev_queue_pair_setup: num_inflights"
704 " %u on qp %u on cryptodev %u",
705 qp_conf.nb_descriptors, qp_id,
706 ts_params->valid_devs[0]);
709 /* invalid number of descriptors - max supported + 2 */
710 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0])),
717 "Unexpectedly passed test for "
718 "rte_cryptodev_queue_pair_setup:"
719 "num_inflights %u on qp %u on cryptodev %u",
720 qp_conf.nb_descriptors, qp_id,
721 ts_params->valid_devs[0]);
724 /* invalid number of descriptors - max value of parameter */
725 qp_conf.nb_descriptors = UINT32_MAX-1;
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0])),
732 "Unexpectedly passed test for "
733 "rte_cryptodev_queue_pair_setup:"
734 "num_inflights %u on qp %u on cryptodev %u",
735 qp_conf.nb_descriptors, qp_id,
736 ts_params->valid_devs[0]);
739 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
741 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
742 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0], qp_id, &qp_conf,
744 rte_cryptodev_socket_id(
745 ts_params->valid_devs[0])),
747 " rte_cryptodev_queue_pair_setup:"
748 "num_inflights %u on qp %u on cryptodev %u",
749 qp_conf.nb_descriptors, qp_id,
750 ts_params->valid_devs[0]);
753 /* invalid number of descriptors - max supported + 1 */
754 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
756 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
757 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
758 ts_params->valid_devs[0], qp_id, &qp_conf,
759 rte_cryptodev_socket_id(
760 ts_params->valid_devs[0])),
761 "Unexpectedly passed test for "
762 "rte_cryptodev_queue_pair_setup:"
763 "num_inflights %u on qp %u on cryptodev %u",
764 qp_conf.nb_descriptors, qp_id,
765 ts_params->valid_devs[0]);
768 /* test invalid queue pair id */
769 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
771 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
773 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
774 ts_params->valid_devs[0],
776 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
777 "Failed test for rte_cryptodev_queue_pair_setup:"
778 "invalid qp %u on cryptodev %u",
779 qp_id, ts_params->valid_devs[0]);
781 qp_id = 0xffff; /*invalid*/
783 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0],
786 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
787 "Failed test for rte_cryptodev_queue_pair_setup:"
788 "invalid qp %u on cryptodev %u",
789 qp_id, ts_params->valid_devs[0]);
794 /* ***** Plaintext data for tests ***** */
796 const char catch_22_quote_1[] =
797 "There was only one catch and that was Catch-22, which "
798 "specified that a concern for one's safety in the face of "
799 "dangers that were real and immediate was the process of a "
800 "rational mind. Orr was crazy and could be grounded. All he "
801 "had to do was ask; and as soon as he did, he would no longer "
802 "be crazy and would have to fly more missions. Orr would be "
803 "crazy to fly more missions and sane if he didn't, but if he "
804 "was sane he had to fly them. If he flew them he was crazy "
805 "and didn't have to; but if he didn't want to he was sane and "
806 "had to. Yossarian was moved very deeply by the absolute "
807 "simplicity of this clause of Catch-22 and let out a "
808 "respectful whistle. \"That's some catch, that Catch-22\", he "
809 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
811 const char catch_22_quote[] =
812 "What a lousy earth! He wondered how many people were "
813 "destitute that same night even in his own prosperous country, "
814 "how many homes were shanties, how many husbands were drunk "
815 "and wives socked, and how many children were bullied, abused, "
816 "or abandoned. How many families hungered for food they could "
817 "not afford to buy? How many hearts were broken? How many "
818 "suicides would take place that same night, how many people "
819 "would go insane? How many cockroaches and landlords would "
820 "triumph? How many winners were losers, successes failures, "
821 "and rich men poor men? How many wise guys were stupid? How "
822 "many happy endings were unhappy endings? How many honest men "
823 "were liars, brave men cowards, loyal men traitors, how many "
824 "sainted men were corrupt, how many people in positions of "
825 "trust had sold their souls to bodyguards, how many had never "
826 "had souls? How many straight-and-narrow paths were crooked "
827 "paths? How many best families were worst families and how "
828 "many good people were bad people? When you added them all up "
829 "and then subtracted, you might be left with only the children, "
830 "and perhaps with Albert Einstein and an old violinist or "
831 "sculptor somewhere.";
833 #define QUOTE_480_BYTES (480)
834 #define QUOTE_512_BYTES (512)
835 #define QUOTE_768_BYTES (768)
836 #define QUOTE_1024_BYTES (1024)
840 /* ***** SHA1 Hash Tests ***** */
842 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
844 static uint8_t hmac_sha1_key[] = {
845 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
846 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
847 0xDE, 0xF4, 0xDE, 0xAD };
849 /* ***** SHA224 Hash Tests ***** */
851 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
854 /* ***** AES-CBC Cipher Tests ***** */
856 #define CIPHER_KEY_LENGTH_AES_CBC (16)
857 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
859 static uint8_t aes_cbc_key[] = {
860 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
861 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
863 static uint8_t aes_cbc_iv[] = {
864 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
865 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
868 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
870 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
871 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
872 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
873 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
874 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
875 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
876 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
877 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
878 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
879 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
880 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
881 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
882 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
883 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
884 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
885 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
886 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
887 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
888 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
889 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
890 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
891 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
892 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
893 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
894 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
895 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
896 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
897 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
898 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
899 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
900 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
901 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
902 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
903 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
904 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
905 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
906 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
907 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
908 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
909 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
910 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
911 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
912 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
913 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
914 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
915 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
916 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
917 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
918 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
919 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
920 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
921 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
922 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
923 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
924 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
925 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
926 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
927 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
928 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
929 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
930 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
931 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
932 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
933 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
934 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
937 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
938 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
939 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
940 0x18, 0x8c, 0x1d, 0x32
944 /* Multisession Vector context Test */
946 static uint8_t ms_aes_cbc_key0[] = {
947 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
951 static uint8_t ms_aes_cbc_iv0[] = {
952 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
953 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
956 static const uint8_t ms_aes_cbc_cipher0[] = {
957 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
958 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
959 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
960 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
961 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
962 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
963 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
964 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
965 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
966 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
967 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
968 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
969 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
970 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
971 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
972 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
973 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
974 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
975 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
976 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
977 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
978 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
979 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
980 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
981 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
982 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
983 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
984 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
985 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
986 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
987 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
988 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
989 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
990 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
991 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
992 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
993 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
994 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
995 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
996 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
997 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
998 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
999 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1000 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1001 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1002 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1003 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1004 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1005 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1006 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1007 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1008 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1009 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1010 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1011 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1012 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1013 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1014 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1015 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1016 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1017 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1018 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1019 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1020 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1024 static uint8_t ms_hmac_key0[] = {
1025 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1026 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1027 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1028 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1029 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1030 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1031 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1032 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1035 static const uint8_t ms_hmac_digest0[] = {
1036 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1037 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1038 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1039 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1040 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1041 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1042 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1043 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1047 /* Begin session 1 */
1049 static uint8_t ms_aes_cbc_key1[] = {
1050 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static uint8_t ms_aes_cbc_iv1[] = {
1055 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1056 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1059 static const uint8_t ms_aes_cbc_cipher1[] = {
1060 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1061 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1062 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1063 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1064 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1065 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1066 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1067 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1068 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1069 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1070 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1071 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1072 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1073 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1074 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1075 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1076 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1077 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1078 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1079 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1080 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1081 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1082 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1083 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1084 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1085 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1086 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1087 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1088 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1089 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1090 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1091 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1092 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1093 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1094 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1095 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1096 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1097 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1098 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1099 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1100 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1101 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1102 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1103 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1104 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1105 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1106 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1107 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1108 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1109 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1110 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1111 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1112 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1113 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1114 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1115 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1116 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1117 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1118 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1119 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1120 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1121 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1122 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1123 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1127 static uint8_t ms_hmac_key1[] = {
1128 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1129 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1130 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1131 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1132 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1133 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1134 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1135 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1138 static const uint8_t ms_hmac_digest1[] = {
1139 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1140 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1141 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1142 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1143 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1144 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1145 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1146 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1149 /* Begin Session 2 */
1150 static uint8_t ms_aes_cbc_key2[] = {
1151 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1152 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 static uint8_t ms_aes_cbc_iv2[] = {
1156 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1157 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1160 static const uint8_t ms_aes_cbc_cipher2[] = {
1161 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1162 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1163 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1164 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1165 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1166 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1167 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1168 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1169 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1170 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1171 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1172 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1173 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1174 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1175 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1176 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1177 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1178 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1179 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1180 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1181 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1182 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1183 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1184 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1185 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1186 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1187 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1188 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1189 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1190 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1191 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1192 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1193 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1194 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1195 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1196 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1197 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1198 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1199 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1200 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1201 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1202 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1203 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1204 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1205 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1206 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1207 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1208 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1209 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1210 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1211 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1212 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1213 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1214 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1215 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1216 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1217 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1218 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1219 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1220 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1221 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1222 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1223 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1224 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1227 static uint8_t ms_hmac_key2[] = {
1228 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest2[] = {
1239 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1240 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1241 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1242 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1243 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1244 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1245 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1246 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1253 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1255 struct crypto_testsuite_params *ts_params = &testsuite_params;
1256 struct crypto_unittest_params *ut_params = &unittest_params;
1258 /* Generate test mbuf data and space for digest */
1259 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1260 catch_22_quote, QUOTE_512_BYTES, 0);
1262 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1263 DIGEST_BYTE_LENGTH_SHA1);
1264 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1266 /* Setup Cipher Parameters */
1267 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1268 ut_params->cipher_xform.next = &ut_params->auth_xform;
1270 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1271 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1272 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1273 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1275 /* Setup HMAC Parameters */
1276 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1278 ut_params->auth_xform.next = NULL;
1280 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1281 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1282 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1283 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1284 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1286 /* Create crypto session*/
1287 ut_params->sess = rte_cryptodev_sym_session_create(
1288 ts_params->valid_devs[0],
1289 &ut_params->cipher_xform);
1290 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1292 /* Generate crypto op data structure */
1293 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1294 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1295 TEST_ASSERT_NOT_NULL(ut_params->op,
1296 "Failed to allocate symmetric crypto operation struct");
1298 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1300 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1302 /* set crypto operation source mbuf */
1303 sym_op->m_src = ut_params->ibuf;
1305 /* Set crypto operation authentication parameters */
1306 sym_op->auth.digest.data = ut_params->digest;
1307 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1308 ut_params->ibuf, QUOTE_512_BYTES);
1309 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1311 sym_op->auth.data.offset = 0;
1312 sym_op->auth.data.length = QUOTE_512_BYTES;
1314 /* Set crypto operation cipher parameters */
1315 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
1316 uint8_t *, IV_OFFSET);
1317 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
1319 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1321 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1323 sym_op->cipher.data.offset = 0;
1324 sym_op->cipher.data.length = QUOTE_512_BYTES;
1326 /* Process crypto operation */
1327 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1328 ut_params->op), "failed to process sym crypto op");
1330 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1331 "crypto op processing failed");
1334 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1337 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1338 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1340 "ciphertext data not as expected");
1342 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1344 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1345 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1346 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1347 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1348 DIGEST_BYTE_LENGTH_SHA1,
1349 "Generated digest data not as expected");
1351 return TEST_SUCCESS;
1354 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1356 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1358 static uint8_t hmac_sha512_key[] = {
1359 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1360 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1361 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1362 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1363 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1364 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1365 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1366 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1368 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1369 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1370 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1371 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1372 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1373 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1374 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1375 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1376 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1381 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1382 struct crypto_unittest_params *ut_params,
1383 uint8_t *cipher_key,
1387 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1388 struct crypto_unittest_params *ut_params,
1389 struct crypto_testsuite_params *ts_params,
1390 const uint8_t *cipher,
1391 const uint8_t *digest,
1396 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1397 struct crypto_unittest_params *ut_params,
1398 uint8_t *cipher_key,
1402 /* Setup Cipher Parameters */
1403 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1404 ut_params->cipher_xform.next = NULL;
1406 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1407 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1408 ut_params->cipher_xform.cipher.key.data = cipher_key;
1409 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1411 /* Setup HMAC Parameters */
1412 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1413 ut_params->auth_xform.next = &ut_params->cipher_xform;
1415 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1417 ut_params->auth_xform.auth.key.data = hmac_key;
1418 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1419 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1421 return TEST_SUCCESS;
1426 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1427 struct crypto_unittest_params *ut_params,
1428 struct crypto_testsuite_params *ts_params,
1429 const uint8_t *cipher,
1430 const uint8_t *digest,
1433 /* Generate test mbuf data and digest */
1434 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA512);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 rte_memcpy(ut_params->digest,
1445 DIGEST_BYTE_LENGTH_SHA512);
1447 /* Generate Crypto op data structure */
1448 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1449 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1450 TEST_ASSERT_NOT_NULL(ut_params->op,
1451 "Failed to allocate symmetric crypto operation struct");
1453 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1455 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1457 /* set crypto operation source mbuf */
1458 sym_op->m_src = ut_params->ibuf;
1460 sym_op->auth.digest.data = ut_params->digest;
1461 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1462 ut_params->ibuf, QUOTE_512_BYTES);
1463 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1465 sym_op->auth.data.offset = 0;
1466 sym_op->auth.data.length = QUOTE_512_BYTES;
1468 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
1469 uint8_t *, IV_OFFSET);
1470 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
1472 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1474 rte_memcpy(sym_op->cipher.iv.data, iv, CIPHER_IV_LENGTH_AES_CBC);
1476 sym_op->cipher.data.offset = 0;
1477 sym_op->cipher.data.length = QUOTE_512_BYTES;
1479 /* Process crypto operation */
1480 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1481 ut_params->op), "failed to process sym crypto op");
1483 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1484 "crypto op processing failed");
1486 ut_params->obuf = ut_params->op->sym->m_src;
1489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1490 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1493 "Plaintext data not as expected");
1496 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1497 "Digest verification failed");
1499 return TEST_SUCCESS;
1503 test_AES_cipheronly_mb_all(void)
1505 struct crypto_testsuite_params *ts_params = &testsuite_params;
1508 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1509 ts_params->op_mpool, ts_params->valid_devs[0],
1510 RTE_CRYPTODEV_AESNI_MB_PMD,
1511 BLKCIPHER_AES_CIPHERONLY_TYPE);
1513 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1515 return TEST_SUCCESS;
1519 test_AES_docsis_mb_all(void)
1521 struct crypto_testsuite_params *ts_params = &testsuite_params;
1524 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1525 ts_params->op_mpool, ts_params->valid_devs[0],
1526 RTE_CRYPTODEV_AESNI_MB_PMD,
1527 BLKCIPHER_AES_DOCSIS_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_AES_docsis_qat_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool, ts_params->valid_devs[0],
1542 RTE_CRYPTODEV_QAT_SYM_PMD,
1543 BLKCIPHER_AES_DOCSIS_TYPE);
1545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1547 return TEST_SUCCESS;
1551 test_DES_docsis_qat_all(void)
1553 struct crypto_testsuite_params *ts_params = &testsuite_params;
1556 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1557 ts_params->op_mpool, ts_params->valid_devs[0],
1558 RTE_CRYPTODEV_QAT_SYM_PMD,
1559 BLKCIPHER_DES_DOCSIS_TYPE);
1561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1563 return TEST_SUCCESS;
1567 test_authonly_mb_all(void)
1569 struct crypto_testsuite_params *ts_params = &testsuite_params;
1572 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1573 ts_params->op_mpool, ts_params->valid_devs[0],
1574 RTE_CRYPTODEV_AESNI_MB_PMD,
1575 BLKCIPHER_AUTHONLY_TYPE);
1577 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1579 return TEST_SUCCESS;
1583 test_AES_chain_mb_all(void)
1585 struct crypto_testsuite_params *ts_params = &testsuite_params;
1588 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1589 ts_params->op_mpool, ts_params->valid_devs[0],
1590 RTE_CRYPTODEV_AESNI_MB_PMD,
1591 BLKCIPHER_AES_CHAIN_TYPE);
1593 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1595 return TEST_SUCCESS;
1598 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1601 test_AES_cipheronly_scheduler_all(void)
1603 struct crypto_testsuite_params *ts_params = &testsuite_params;
1606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 ts_params->op_mpool, ts_params->valid_devs[0],
1608 RTE_CRYPTODEV_SCHEDULER_PMD,
1609 BLKCIPHER_AES_CIPHERONLY_TYPE);
1611 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1613 return TEST_SUCCESS;
1617 test_AES_chain_scheduler_all(void)
1619 struct crypto_testsuite_params *ts_params = &testsuite_params;
1622 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1623 ts_params->op_mpool, ts_params->valid_devs[0],
1624 RTE_CRYPTODEV_SCHEDULER_PMD,
1625 BLKCIPHER_AES_CHAIN_TYPE);
1627 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1629 return TEST_SUCCESS;
1633 test_authonly_scheduler_all(void)
1635 struct crypto_testsuite_params *ts_params = &testsuite_params;
1638 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1639 ts_params->op_mpool, ts_params->valid_devs[0],
1640 RTE_CRYPTODEV_SCHEDULER_PMD,
1641 BLKCIPHER_AUTHONLY_TYPE);
1643 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1645 return TEST_SUCCESS;
1648 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1651 test_AES_chain_openssl_all(void)
1653 struct crypto_testsuite_params *ts_params = &testsuite_params;
1656 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1657 ts_params->op_mpool, ts_params->valid_devs[0],
1658 RTE_CRYPTODEV_OPENSSL_PMD,
1659 BLKCIPHER_AES_CHAIN_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1667 test_AES_cipheronly_openssl_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, ts_params->valid_devs[0],
1674 RTE_CRYPTODEV_OPENSSL_PMD,
1675 BLKCIPHER_AES_CIPHERONLY_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_AES_chain_qat_all(void)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1688 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1689 ts_params->op_mpool, ts_params->valid_devs[0],
1690 RTE_CRYPTODEV_QAT_SYM_PMD,
1691 BLKCIPHER_AES_CHAIN_TYPE);
1693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1695 return TEST_SUCCESS;
1699 test_AES_cipheronly_qat_all(void)
1701 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1705 ts_params->op_mpool, ts_params->valid_devs[0],
1706 RTE_CRYPTODEV_QAT_SYM_PMD,
1707 BLKCIPHER_AES_CIPHERONLY_TYPE);
1709 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 return TEST_SUCCESS;
1715 test_AES_chain_dpaa2_sec_all(void)
1717 struct crypto_testsuite_params *ts_params = &testsuite_params;
1720 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1721 ts_params->op_mpool, ts_params->valid_devs[0],
1722 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1723 BLKCIPHER_AES_CHAIN_TYPE);
1725 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1727 return TEST_SUCCESS;
1731 test_AES_cipheronly_dpaa2_sec_all(void)
1733 struct crypto_testsuite_params *ts_params = &testsuite_params;
1736 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1737 ts_params->op_mpool, ts_params->valid_devs[0],
1738 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1739 BLKCIPHER_AES_CIPHERONLY_TYPE);
1741 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1743 return TEST_SUCCESS;
1747 test_authonly_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, ts_params->valid_devs[0],
1754 RTE_CRYPTODEV_OPENSSL_PMD,
1755 BLKCIPHER_AUTHONLY_TYPE);
1757 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1759 return TEST_SUCCESS;
1763 test_AES_chain_armv8_all(void)
1765 struct crypto_testsuite_params *ts_params = &testsuite_params;
1768 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1769 ts_params->op_mpool, ts_params->valid_devs[0],
1770 RTE_CRYPTODEV_ARMV8_PMD,
1771 BLKCIPHER_AES_CHAIN_TYPE);
1773 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1775 return TEST_SUCCESS;
1778 /* ***** SNOW 3G Tests ***** */
1780 create_wireless_algo_hash_session(uint8_t dev_id,
1781 const uint8_t *key, const uint8_t key_len,
1782 const uint8_t aad_len, const uint8_t auth_len,
1783 enum rte_crypto_auth_operation op,
1784 enum rte_crypto_auth_algorithm algo)
1786 uint8_t hash_key[key_len];
1788 struct crypto_unittest_params *ut_params = &unittest_params;
1790 memcpy(hash_key, key, key_len);
1792 TEST_HEXDUMP(stdout, "key:", key, key_len);
1794 /* Setup Authentication Parameters */
1795 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1796 ut_params->auth_xform.next = NULL;
1798 ut_params->auth_xform.auth.op = op;
1799 ut_params->auth_xform.auth.algo = algo;
1800 ut_params->auth_xform.auth.key.length = key_len;
1801 ut_params->auth_xform.auth.key.data = hash_key;
1802 ut_params->auth_xform.auth.digest_length = auth_len;
1803 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1804 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1805 &ut_params->auth_xform);
1806 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1811 create_wireless_algo_cipher_session(uint8_t dev_id,
1812 enum rte_crypto_cipher_operation op,
1813 enum rte_crypto_cipher_algorithm algo,
1814 const uint8_t *key, const uint8_t key_len)
1816 uint8_t cipher_key[key_len];
1818 struct crypto_unittest_params *ut_params = &unittest_params;
1820 memcpy(cipher_key, key, key_len);
1822 /* Setup Cipher Parameters */
1823 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1824 ut_params->cipher_xform.next = NULL;
1826 ut_params->cipher_xform.cipher.algo = algo;
1827 ut_params->cipher_xform.cipher.op = op;
1828 ut_params->cipher_xform.cipher.key.data = cipher_key;
1829 ut_params->cipher_xform.cipher.key.length = key_len;
1831 TEST_HEXDUMP(stdout, "key:", key, key_len);
1833 /* Create Crypto session */
1834 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1837 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1842 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1843 unsigned int cipher_len,
1844 unsigned int cipher_offset)
1846 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 struct crypto_unittest_params *ut_params = &unittest_params;
1849 /* Generate Crypto op data structure */
1850 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1851 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1852 TEST_ASSERT_NOT_NULL(ut_params->op,
1853 "Failed to allocate pktmbuf offload");
1855 /* Set crypto operation data parameters */
1856 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1858 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1860 /* set crypto operation source mbuf */
1861 sym_op->m_src = ut_params->ibuf;
1864 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
1865 uint8_t *, IV_OFFSET);
1866 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
1868 sym_op->cipher.iv.length = iv_len;
1870 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1871 sym_op->cipher.data.length = cipher_len;
1872 sym_op->cipher.data.offset = cipher_offset;
1877 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1878 unsigned int cipher_len,
1879 unsigned int cipher_offset)
1881 struct crypto_testsuite_params *ts_params = &testsuite_params;
1882 struct crypto_unittest_params *ut_params = &unittest_params;
1884 /* Generate Crypto op data structure */
1885 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1886 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1887 TEST_ASSERT_NOT_NULL(ut_params->op,
1888 "Failed to allocate pktmbuf offload");
1890 /* Set crypto operation data parameters */
1891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1893 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1895 /* set crypto operation source mbuf */
1896 sym_op->m_src = ut_params->ibuf;
1897 sym_op->m_dst = ut_params->obuf;
1900 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
1901 uint8_t *, IV_OFFSET);
1902 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
1904 sym_op->cipher.iv.length = iv_len;
1906 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1907 sym_op->cipher.data.length = cipher_len;
1908 sym_op->cipher.data.offset = cipher_offset;
1913 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1914 enum rte_crypto_cipher_operation cipher_op,
1915 enum rte_crypto_auth_operation auth_op,
1916 enum rte_crypto_auth_algorithm auth_algo,
1917 enum rte_crypto_cipher_algorithm cipher_algo,
1918 const uint8_t *key, const uint8_t key_len,
1919 const uint8_t aad_len, const uint8_t auth_len)
1922 uint8_t cipher_auth_key[key_len];
1924 struct crypto_unittest_params *ut_params = &unittest_params;
1926 memcpy(cipher_auth_key, key, key_len);
1928 /* Setup Authentication Parameters */
1929 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1930 ut_params->auth_xform.next = NULL;
1932 ut_params->auth_xform.auth.op = auth_op;
1933 ut_params->auth_xform.auth.algo = auth_algo;
1934 ut_params->auth_xform.auth.key.length = key_len;
1935 /* Hash key = cipher key */
1936 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1937 ut_params->auth_xform.auth.digest_length = auth_len;
1938 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1940 /* Setup Cipher Parameters */
1941 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1942 ut_params->cipher_xform.next = &ut_params->auth_xform;
1944 ut_params->cipher_xform.cipher.algo = cipher_algo;
1945 ut_params->cipher_xform.cipher.op = cipher_op;
1946 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1947 ut_params->cipher_xform.cipher.key.length = key_len;
1949 TEST_HEXDUMP(stdout, "key:", key, key_len);
1951 /* Create Crypto session*/
1952 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1953 &ut_params->cipher_xform);
1955 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1960 create_wireless_cipher_auth_session(uint8_t dev_id,
1961 enum rte_crypto_cipher_operation cipher_op,
1962 enum rte_crypto_auth_operation auth_op,
1963 enum rte_crypto_auth_algorithm auth_algo,
1964 enum rte_crypto_cipher_algorithm cipher_algo,
1965 const struct wireless_test_data *tdata)
1967 const uint8_t key_len = tdata->key.len;
1968 uint8_t cipher_auth_key[key_len];
1970 struct crypto_unittest_params *ut_params = &unittest_params;
1971 const uint8_t *key = tdata->key.data;
1972 const uint8_t aad_len = tdata->aad.len;
1973 const uint8_t auth_len = tdata->digest.len;
1975 memcpy(cipher_auth_key, key, key_len);
1977 /* Setup Authentication Parameters */
1978 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1979 ut_params->auth_xform.next = NULL;
1981 ut_params->auth_xform.auth.op = auth_op;
1982 ut_params->auth_xform.auth.algo = auth_algo;
1983 ut_params->auth_xform.auth.key.length = key_len;
1984 /* Hash key = cipher key */
1985 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1986 ut_params->auth_xform.auth.digest_length = auth_len;
1987 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1989 /* Setup Cipher Parameters */
1990 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1991 ut_params->cipher_xform.next = &ut_params->auth_xform;
1993 ut_params->cipher_xform.cipher.algo = cipher_algo;
1994 ut_params->cipher_xform.cipher.op = cipher_op;
1995 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1996 ut_params->cipher_xform.cipher.key.length = key_len;
1998 TEST_HEXDUMP(stdout, "key:", key, key_len);
2000 /* Create Crypto session*/
2001 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2002 &ut_params->cipher_xform);
2004 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2009 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2010 const struct wireless_test_data *tdata)
2012 return create_wireless_cipher_auth_session(dev_id,
2013 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2014 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2015 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2019 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2020 enum rte_crypto_cipher_operation cipher_op,
2021 enum rte_crypto_auth_operation auth_op,
2022 enum rte_crypto_auth_algorithm auth_algo,
2023 enum rte_crypto_cipher_algorithm cipher_algo,
2024 const uint8_t *key, const uint8_t key_len,
2025 const uint8_t aad_len, const uint8_t auth_len)
2027 uint8_t auth_cipher_key[key_len];
2029 struct crypto_unittest_params *ut_params = &unittest_params;
2031 memcpy(auth_cipher_key, key, key_len);
2033 /* Setup Authentication Parameters */
2034 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2035 ut_params->auth_xform.auth.op = auth_op;
2036 ut_params->auth_xform.next = &ut_params->cipher_xform;
2037 ut_params->auth_xform.auth.algo = auth_algo;
2038 ut_params->auth_xform.auth.key.length = key_len;
2039 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2040 ut_params->auth_xform.auth.digest_length = auth_len;
2041 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
2043 /* Setup Cipher Parameters */
2044 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2045 ut_params->cipher_xform.next = NULL;
2046 ut_params->cipher_xform.cipher.algo = cipher_algo;
2047 ut_params->cipher_xform.cipher.op = cipher_op;
2048 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2049 ut_params->cipher_xform.cipher.key.length = key_len;
2051 TEST_HEXDUMP(stdout, "key:", key, key_len);
2053 /* Create Crypto session*/
2054 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2055 &ut_params->auth_xform);
2057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2063 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2064 const unsigned auth_tag_len,
2065 const uint8_t *aad, const unsigned aad_len,
2066 unsigned data_pad_len,
2067 enum rte_crypto_auth_operation op,
2068 enum rte_crypto_auth_algorithm algo,
2069 const unsigned auth_len, const unsigned auth_offset)
2071 struct crypto_testsuite_params *ts_params = &testsuite_params;
2073 struct crypto_unittest_params *ut_params = &unittest_params;
2075 unsigned aad_buffer_len;
2077 /* Generate Crypto op data structure */
2078 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2079 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2080 TEST_ASSERT_NOT_NULL(ut_params->op,
2081 "Failed to allocate pktmbuf offload");
2083 /* Set crypto operation data parameters */
2084 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2086 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2088 /* set crypto operation source mbuf */
2089 sym_op->m_src = ut_params->ibuf;
2093 * Always allocate the aad up to the block size.
2094 * The cryptodev API calls out -
2095 * - the array must be big enough to hold the AAD, plus any
2096 * space to round this up to the nearest multiple of the
2097 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2099 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2100 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2102 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2103 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2104 ut_params->ibuf, aad_buffer_len);
2105 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2106 "no room to prepend aad");
2107 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2109 sym_op->auth.aad.length = aad_len;
2111 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2112 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2114 TEST_HEXDUMP(stdout, "aad:",
2115 sym_op->auth.aad.data, aad_len);
2118 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2119 ut_params->ibuf, auth_tag_len);
2121 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2122 "no room to append auth tag");
2123 ut_params->digest = sym_op->auth.digest.data;
2124 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2125 ut_params->ibuf, data_pad_len + aad_len);
2126 sym_op->auth.digest.length = auth_tag_len;
2127 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2128 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2130 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2132 TEST_HEXDUMP(stdout, "digest:",
2133 sym_op->auth.digest.data,
2134 sym_op->auth.digest.length);
2136 sym_op->auth.data.length = auth_len;
2137 sym_op->auth.data.offset = auth_offset;
2143 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2144 enum rte_crypto_auth_operation op,
2145 enum rte_crypto_auth_algorithm auth_algo)
2147 struct crypto_testsuite_params *ts_params = &testsuite_params;
2148 struct crypto_unittest_params *ut_params = &unittest_params;
2150 const uint8_t *auth_tag = tdata->digest.data;
2151 const unsigned int auth_tag_len = tdata->digest.len;
2152 const uint8_t *aad = tdata->aad.data;
2153 const uint8_t aad_len = tdata->aad.len;
2154 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2155 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2157 const uint8_t *iv = tdata->iv.data;
2158 const uint8_t iv_len = tdata->iv.len;
2159 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2160 const unsigned int cipher_offset = 0;
2161 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2162 const unsigned int auth_offset = tdata->aad.len << 3;
2164 unsigned int aad_buffer_len;
2166 /* Generate Crypto op data structure */
2167 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2168 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2169 TEST_ASSERT_NOT_NULL(ut_params->op,
2170 "Failed to allocate pktmbuf offload");
2171 /* Set crypto operation data parameters */
2172 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2174 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2176 /* set crypto operation source mbuf */
2177 sym_op->m_src = ut_params->ibuf;
2180 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2181 ut_params->ibuf, auth_tag_len);
2183 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2184 "no room to append auth tag");
2185 ut_params->digest = sym_op->auth.digest.data;
2186 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2187 ut_params->ibuf, data_pad_len);
2188 sym_op->auth.digest.length = auth_tag_len;
2189 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2190 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2192 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2194 TEST_HEXDUMP(stdout, "digest:",
2195 sym_op->auth.digest.data,
2196 sym_op->auth.digest.length);
2200 * Always allocate the aad up to the block size.
2201 * The cryptodev API calls out -
2202 * - the array must be big enough to hold the AAD, plus any
2203 * space to round this up to the nearest multiple of the
2204 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2206 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2207 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2209 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2210 sym_op->auth.aad.data =
2211 (uint8_t *)rte_pktmbuf_prepend(
2212 ut_params->ibuf, aad_buffer_len);
2213 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2214 "no room to prepend aad");
2215 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2217 sym_op->auth.aad.length = aad_len;
2218 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2219 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2220 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2223 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
2224 uint8_t *, IV_OFFSET);
2225 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
2227 sym_op->cipher.iv.length = iv_len;
2229 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2230 sym_op->cipher.data.length = cipher_len;
2231 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2232 sym_op->auth.data.length = auth_len;
2233 sym_op->auth.data.offset = auth_offset + cipher_offset;
2239 create_zuc_cipher_hash_generate_operation(
2240 const struct wireless_test_data *tdata)
2242 return create_wireless_cipher_hash_operation(tdata,
2243 RTE_CRYPTO_AUTH_OP_GENERATE,
2244 RTE_CRYPTO_AUTH_ZUC_EIA3);
2248 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2249 const unsigned auth_tag_len,
2250 const uint8_t *aad, const uint8_t aad_len,
2251 unsigned data_pad_len,
2252 enum rte_crypto_auth_operation op,
2253 enum rte_crypto_auth_algorithm auth_algo,
2254 const uint8_t *iv, const uint8_t iv_len,
2255 const unsigned cipher_len, const unsigned cipher_offset,
2256 const unsigned auth_len, const unsigned auth_offset)
2258 struct crypto_testsuite_params *ts_params = &testsuite_params;
2259 struct crypto_unittest_params *ut_params = &unittest_params;
2261 unsigned aad_buffer_len;
2263 /* Generate Crypto op data structure */
2264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2266 TEST_ASSERT_NOT_NULL(ut_params->op,
2267 "Failed to allocate pktmbuf offload");
2268 /* Set crypto operation data parameters */
2269 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2273 /* set crypto operation source mbuf */
2274 sym_op->m_src = ut_params->ibuf;
2277 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2278 ut_params->ibuf, auth_tag_len);
2280 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2281 "no room to append auth tag");
2282 ut_params->digest = sym_op->auth.digest.data;
2283 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2284 ut_params->ibuf, data_pad_len);
2285 sym_op->auth.digest.length = auth_tag_len;
2286 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2287 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2289 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2291 TEST_HEXDUMP(stdout, "digest:",
2292 sym_op->auth.digest.data,
2293 sym_op->auth.digest.length);
2297 * Always allocate the aad up to the block size.
2298 * The cryptodev API calls out -
2299 * - the array must be big enough to hold the AAD, plus any
2300 * space to round this up to the nearest multiple of the
2301 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2303 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2304 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2306 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2307 sym_op->auth.aad.data =
2308 (uint8_t *)rte_pktmbuf_prepend(
2309 ut_params->ibuf, aad_buffer_len);
2310 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2311 "no room to prepend aad");
2312 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2314 sym_op->auth.aad.length = aad_len;
2315 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2316 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2317 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2320 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
2321 uint8_t *, IV_OFFSET);
2322 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
2324 sym_op->cipher.iv.length = iv_len;
2326 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2327 sym_op->cipher.data.length = cipher_len;
2328 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2329 sym_op->auth.data.length = auth_len;
2330 sym_op->auth.data.offset = auth_offset + cipher_offset;
2336 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2337 const uint8_t *iv, const uint8_t iv_len,
2338 const uint8_t *aad, const uint8_t aad_len,
2339 unsigned data_pad_len,
2340 const unsigned cipher_len, const unsigned cipher_offset,
2341 const unsigned auth_len, const unsigned auth_offset,
2342 enum rte_crypto_auth_algorithm auth_algo)
2344 struct crypto_testsuite_params *ts_params = &testsuite_params;
2345 struct crypto_unittest_params *ut_params = &unittest_params;
2347 unsigned aad_buffer_len = 0;
2349 /* Generate Crypto op data structure */
2350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2352 TEST_ASSERT_NOT_NULL(ut_params->op,
2353 "Failed to allocate pktmbuf offload");
2355 /* Set crypto operation data parameters */
2356 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2360 /* set crypto operation source mbuf */
2361 sym_op->m_src = ut_params->ibuf;
2364 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2365 ut_params->ibuf, auth_tag_len);
2367 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2368 "no room to append auth tag");
2370 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2371 ut_params->ibuf, data_pad_len);
2372 sym_op->auth.digest.length = auth_tag_len;
2374 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2376 TEST_HEXDUMP(stdout, "digest:",
2377 sym_op->auth.digest.data,
2378 sym_op->auth.digest.length);
2382 * Always allocate the aad up to the block size.
2383 * The cryptodev API calls out -
2384 * - the array must be big enough to hold the AAD, plus any
2385 * space to round this up to the nearest multiple of the
2386 * block size (8 bytes for KASUMI 16 bytes).
2388 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2389 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2391 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2392 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2393 ut_params->ibuf, aad_buffer_len);
2394 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2395 "no room to prepend aad");
2396 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2398 sym_op->auth.aad.length = aad_len;
2399 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2400 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2401 TEST_HEXDUMP(stdout, "aad:",
2402 sym_op->auth.aad.data, aad_len);
2405 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
2406 uint8_t *, IV_OFFSET);
2407 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
2409 sym_op->cipher.iv.length = iv_len;
2411 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2413 sym_op->cipher.data.length = cipher_len;
2414 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2416 sym_op->auth.data.length = auth_len;
2417 sym_op->auth.data.offset = auth_offset + cipher_offset;
2423 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2425 struct crypto_testsuite_params *ts_params = &testsuite_params;
2426 struct crypto_unittest_params *ut_params = &unittest_params;
2429 unsigned plaintext_pad_len;
2430 unsigned plaintext_len;
2433 /* Create SNOW 3G session */
2434 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2435 tdata->key.data, tdata->key.len,
2436 tdata->aad.len, tdata->digest.len,
2437 RTE_CRYPTO_AUTH_OP_GENERATE,
2438 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2442 /* alloc mbuf and set payload */
2443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2445 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2446 rte_pktmbuf_tailroom(ut_params->ibuf));
2448 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2449 /* Append data which is padded to a multiple of */
2450 /* the algorithms block size */
2451 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2452 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2454 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2456 /* Create SNOW 3G operation */
2457 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2458 tdata->aad.data, tdata->aad.len,
2459 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2460 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2461 tdata->validAuthLenInBits.len,
2462 (tdata->aad.len << 3));
2466 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2468 ut_params->obuf = ut_params->op->sym->m_src;
2469 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2470 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2471 + plaintext_pad_len + tdata->aad.len;
2474 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2477 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2478 "SNOW 3G Generated auth tag not as expected");
2484 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2486 struct crypto_testsuite_params *ts_params = &testsuite_params;
2487 struct crypto_unittest_params *ut_params = &unittest_params;
2490 unsigned plaintext_pad_len;
2491 unsigned plaintext_len;
2494 /* Create SNOW 3G session */
2495 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2496 tdata->key.data, tdata->key.len,
2497 tdata->aad.len, tdata->digest.len,
2498 RTE_CRYPTO_AUTH_OP_VERIFY,
2499 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2502 /* alloc mbuf and set payload */
2503 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2505 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2506 rte_pktmbuf_tailroom(ut_params->ibuf));
2508 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2509 /* Append data which is padded to a multiple of */
2510 /* the algorithms block size */
2511 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2512 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2514 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2516 /* Create SNOW 3G operation */
2517 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2519 tdata->aad.data, tdata->aad.len,
2521 RTE_CRYPTO_AUTH_OP_VERIFY,
2522 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2523 tdata->validAuthLenInBits.len,
2524 (tdata->aad.len << 3));
2528 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2530 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2531 ut_params->obuf = ut_params->op->sym->m_src;
2532 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2533 + plaintext_pad_len + tdata->aad.len;
2536 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2545 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2547 struct crypto_testsuite_params *ts_params = &testsuite_params;
2548 struct crypto_unittest_params *ut_params = &unittest_params;
2551 unsigned plaintext_pad_len;
2552 unsigned plaintext_len;
2555 /* Create KASUMI session */
2556 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2557 tdata->key.data, tdata->key.len,
2558 tdata->aad.len, tdata->digest.len,
2559 RTE_CRYPTO_AUTH_OP_GENERATE,
2560 RTE_CRYPTO_AUTH_KASUMI_F9);
2564 /* alloc mbuf and set payload */
2565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2567 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2568 rte_pktmbuf_tailroom(ut_params->ibuf));
2570 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2571 /* Append data which is padded to a multiple of */
2572 /* the algorithms block size */
2573 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2574 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2576 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2578 /* Create KASUMI operation */
2579 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2580 tdata->aad.data, tdata->aad.len,
2581 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2582 RTE_CRYPTO_AUTH_KASUMI_F9,
2583 tdata->validAuthLenInBits.len,
2584 (tdata->aad.len << 3));
2588 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2590 ut_params->obuf = ut_params->op->sym->m_src;
2591 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2592 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2593 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2596 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2599 DIGEST_BYTE_LENGTH_KASUMI_F9,
2600 "KASUMI Generated auth tag not as expected");
2606 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2608 struct crypto_testsuite_params *ts_params = &testsuite_params;
2609 struct crypto_unittest_params *ut_params = &unittest_params;
2612 unsigned plaintext_pad_len;
2613 unsigned plaintext_len;
2616 /* Create KASUMI session */
2617 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2618 tdata->key.data, tdata->key.len,
2619 tdata->aad.len, tdata->digest.len,
2620 RTE_CRYPTO_AUTH_OP_VERIFY,
2621 RTE_CRYPTO_AUTH_KASUMI_F9);
2624 /* alloc mbuf and set payload */
2625 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2628 rte_pktmbuf_tailroom(ut_params->ibuf));
2630 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2631 /* Append data which is padded to a multiple */
2632 /* of the algorithms block size */
2633 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2634 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2636 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2638 /* Create KASUMI operation */
2639 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2641 tdata->aad.data, tdata->aad.len,
2643 RTE_CRYPTO_AUTH_OP_VERIFY,
2644 RTE_CRYPTO_AUTH_KASUMI_F9,
2645 tdata->validAuthLenInBits.len,
2646 (tdata->aad.len << 3));
2650 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2652 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2653 ut_params->obuf = ut_params->op->sym->m_src;
2654 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2655 + plaintext_pad_len + tdata->aad.len;
2658 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2667 test_snow3g_hash_generate_test_case_1(void)
2669 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2673 test_snow3g_hash_generate_test_case_2(void)
2675 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2679 test_snow3g_hash_generate_test_case_3(void)
2681 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2685 test_snow3g_hash_generate_test_case_4(void)
2687 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2691 test_snow3g_hash_generate_test_case_5(void)
2693 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2697 test_snow3g_hash_generate_test_case_6(void)
2699 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2703 test_snow3g_hash_verify_test_case_1(void)
2705 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2710 test_snow3g_hash_verify_test_case_2(void)
2712 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2716 test_snow3g_hash_verify_test_case_3(void)
2718 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2722 test_snow3g_hash_verify_test_case_4(void)
2724 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2728 test_snow3g_hash_verify_test_case_5(void)
2730 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2734 test_snow3g_hash_verify_test_case_6(void)
2736 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2740 test_kasumi_hash_generate_test_case_1(void)
2742 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2746 test_kasumi_hash_generate_test_case_2(void)
2748 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2752 test_kasumi_hash_generate_test_case_3(void)
2754 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2758 test_kasumi_hash_generate_test_case_4(void)
2760 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2764 test_kasumi_hash_generate_test_case_5(void)
2766 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2770 test_kasumi_hash_generate_test_case_6(void)
2772 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2776 test_kasumi_hash_verify_test_case_1(void)
2778 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2782 test_kasumi_hash_verify_test_case_2(void)
2784 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2788 test_kasumi_hash_verify_test_case_3(void)
2790 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2794 test_kasumi_hash_verify_test_case_4(void)
2796 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2800 test_kasumi_hash_verify_test_case_5(void)
2802 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2806 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2808 struct crypto_testsuite_params *ts_params = &testsuite_params;
2809 struct crypto_unittest_params *ut_params = &unittest_params;
2812 uint8_t *plaintext, *ciphertext;
2813 unsigned plaintext_pad_len;
2814 unsigned plaintext_len;
2816 /* Create KASUMI session */
2817 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2818 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2819 RTE_CRYPTO_CIPHER_KASUMI_F8,
2820 tdata->key.data, tdata->key.len);
2824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2826 /* Clear mbuf payload */
2827 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2828 rte_pktmbuf_tailroom(ut_params->ibuf));
2830 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2831 /* Append data which is padded to a multiple */
2832 /* of the algorithms block size */
2833 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2834 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2836 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2838 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2840 /* Create KASUMI operation */
2841 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2842 tdata->plaintext.len,
2847 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2849 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2851 ut_params->obuf = ut_params->op->sym->m_dst;
2852 if (ut_params->obuf)
2853 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2855 ciphertext = plaintext;
2857 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2860 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2862 tdata->ciphertext.data,
2863 tdata->validCipherLenInBits.len,
2864 "KASUMI Ciphertext data not as expected");
2869 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2871 struct crypto_testsuite_params *ts_params = &testsuite_params;
2872 struct crypto_unittest_params *ut_params = &unittest_params;
2876 unsigned int plaintext_pad_len;
2877 unsigned int plaintext_len;
2879 uint8_t buffer[10000];
2880 const uint8_t *ciphertext;
2882 struct rte_cryptodev_info dev_info;
2884 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2885 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2886 printf("Device doesn't support scatter-gather. "
2891 /* Create KASUMI session */
2892 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2893 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2894 RTE_CRYPTO_CIPHER_KASUMI_F8,
2895 tdata->key.data, tdata->key.len);
2899 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2902 /* Append data which is padded to a multiple */
2903 /* of the algorithms block size */
2904 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2906 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2907 plaintext_pad_len, 10, 0);
2909 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2911 /* Create KASUMI operation */
2912 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2914 tdata->plaintext.len,
2919 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2921 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2923 ut_params->obuf = ut_params->op->sym->m_dst;
2925 if (ut_params->obuf)
2926 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2927 plaintext_len, buffer);
2929 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2930 plaintext_len, buffer);
2933 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2936 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2938 tdata->ciphertext.data,
2939 tdata->validCipherLenInBits.len,
2940 "KASUMI Ciphertext data not as expected");
2945 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2947 struct crypto_testsuite_params *ts_params = &testsuite_params;
2948 struct crypto_unittest_params *ut_params = &unittest_params;
2951 uint8_t *plaintext, *ciphertext;
2952 unsigned plaintext_pad_len;
2953 unsigned plaintext_len;
2955 /* Create KASUMI session */
2956 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2957 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2958 RTE_CRYPTO_CIPHER_KASUMI_F8,
2959 tdata->key.data, tdata->key.len);
2963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2964 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2966 /* Clear mbuf payload */
2967 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2968 rte_pktmbuf_tailroom(ut_params->ibuf));
2970 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2971 /* Append data which is padded to a multiple */
2972 /* of the algorithms block size */
2973 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2974 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2976 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2977 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2979 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2981 /* Create KASUMI operation */
2982 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2984 tdata->plaintext.len,
2989 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2991 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2993 ut_params->obuf = ut_params->op->sym->m_dst;
2994 if (ut_params->obuf)
2995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2997 ciphertext = plaintext;
2999 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3004 tdata->ciphertext.data,
3005 tdata->validCipherLenInBits.len,
3006 "KASUMI Ciphertext data not as expected");
3011 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3013 struct crypto_testsuite_params *ts_params = &testsuite_params;
3014 struct crypto_unittest_params *ut_params = &unittest_params;
3017 unsigned int plaintext_pad_len;
3018 unsigned int plaintext_len;
3020 const uint8_t *ciphertext;
3021 uint8_t buffer[2048];
3023 struct rte_cryptodev_info dev_info;
3025 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3026 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3027 printf("Device doesn't support scatter-gather. "
3032 /* Create KASUMI session */
3033 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3034 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3035 RTE_CRYPTO_CIPHER_KASUMI_F8,
3036 tdata->key.data, tdata->key.len);
3040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3041 /* Append data which is padded to a multiple */
3042 /* of the algorithms block size */
3043 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3045 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3046 plaintext_pad_len, 10, 0);
3047 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3048 plaintext_pad_len, 3, 0);
3050 /* Append data which is padded to a multiple */
3051 /* of the algorithms block size */
3052 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3054 /* Create KASUMI operation */
3055 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3057 tdata->plaintext.len,
3062 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3064 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3066 ut_params->obuf = ut_params->op->sym->m_dst;
3067 if (ut_params->obuf)
3068 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3069 plaintext_pad_len, buffer);
3071 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3072 plaintext_pad_len, buffer);
3075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3077 tdata->ciphertext.data,
3078 tdata->validCipherLenInBits.len,
3079 "KASUMI Ciphertext data not as expected");
3085 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3087 struct crypto_testsuite_params *ts_params = &testsuite_params;
3088 struct crypto_unittest_params *ut_params = &unittest_params;
3091 uint8_t *ciphertext, *plaintext;
3092 unsigned ciphertext_pad_len;
3093 unsigned ciphertext_len;
3095 /* Create KASUMI session */
3096 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3097 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3098 RTE_CRYPTO_CIPHER_KASUMI_F8,
3099 tdata->key.data, tdata->key.len);
3103 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3104 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3106 /* Clear mbuf payload */
3107 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3108 rte_pktmbuf_tailroom(ut_params->ibuf));
3110 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3111 /* Append data which is padded to a multiple */
3112 /* of the algorithms block size */
3113 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3114 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3115 ciphertext_pad_len);
3116 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3117 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3119 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3121 /* Create KASUMI operation */
3122 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3124 tdata->ciphertext.len,
3129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3133 ut_params->obuf = ut_params->op->sym->m_dst;
3134 if (ut_params->obuf)
3135 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3137 plaintext = ciphertext;
3139 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3142 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3144 tdata->plaintext.data,
3145 tdata->validCipherLenInBits.len,
3146 "KASUMI Plaintext data not as expected");
3151 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3153 struct crypto_testsuite_params *ts_params = &testsuite_params;
3154 struct crypto_unittest_params *ut_params = &unittest_params;
3157 uint8_t *ciphertext, *plaintext;
3158 unsigned ciphertext_pad_len;
3159 unsigned ciphertext_len;
3161 /* Create KASUMI session */
3162 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3163 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3164 RTE_CRYPTO_CIPHER_KASUMI_F8,
3165 tdata->key.data, tdata->key.len);
3169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3171 /* Clear mbuf payload */
3172 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3173 rte_pktmbuf_tailroom(ut_params->ibuf));
3175 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3176 /* Append data which is padded to a multiple */
3177 /* of the algorithms block size */
3178 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3179 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3180 ciphertext_pad_len);
3181 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3183 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3185 /* Create KASUMI operation */
3186 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3188 tdata->ciphertext.len,
3193 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3195 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3197 ut_params->obuf = ut_params->op->sym->m_dst;
3198 if (ut_params->obuf)
3199 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3201 plaintext = ciphertext;
3203 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3206 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3208 tdata->plaintext.data,
3209 tdata->validCipherLenInBits.len,
3210 "KASUMI Plaintext data not as expected");
3215 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3217 struct crypto_testsuite_params *ts_params = &testsuite_params;
3218 struct crypto_unittest_params *ut_params = &unittest_params;
3221 uint8_t *plaintext, *ciphertext;
3222 unsigned plaintext_pad_len;
3223 unsigned plaintext_len;
3225 /* Create SNOW 3G session */
3226 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3227 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3228 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3229 tdata->key.data, tdata->key.len);
3233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3235 /* Clear mbuf payload */
3236 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3237 rte_pktmbuf_tailroom(ut_params->ibuf));
3239 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3240 /* Append data which is padded to a multiple of */
3241 /* the algorithms block size */
3242 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3243 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3245 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3247 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3249 /* Create SNOW 3G operation */
3250 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3251 tdata->validCipherLenInBits.len,
3256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3258 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3260 ut_params->obuf = ut_params->op->sym->m_dst;
3261 if (ut_params->obuf)
3262 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3264 ciphertext = plaintext;
3266 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3269 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3271 tdata->ciphertext.data,
3272 tdata->validDataLenInBits.len,
3273 "SNOW 3G Ciphertext data not as expected");
3279 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3281 struct crypto_testsuite_params *ts_params = &testsuite_params;
3282 struct crypto_unittest_params *ut_params = &unittest_params;
3283 uint8_t *plaintext, *ciphertext;
3286 unsigned plaintext_pad_len;
3287 unsigned plaintext_len;
3289 /* Create SNOW 3G session */
3290 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3291 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3292 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3293 tdata->key.data, tdata->key.len);
3297 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3298 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3300 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3301 "Failed to allocate input buffer in mempool");
3302 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3303 "Failed to allocate output buffer in mempool");
3305 /* Clear mbuf payload */
3306 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3307 rte_pktmbuf_tailroom(ut_params->ibuf));
3309 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3310 /* Append data which is padded to a multiple of */
3311 /* the algorithms block size */
3312 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3313 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3315 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3316 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3318 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3320 /* Create SNOW 3G operation */
3321 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3323 tdata->validCipherLenInBits.len,
3328 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3330 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3332 ut_params->obuf = ut_params->op->sym->m_dst;
3333 if (ut_params->obuf)
3334 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3336 ciphertext = plaintext;
3338 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3341 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3343 tdata->ciphertext.data,
3344 tdata->validDataLenInBits.len,
3345 "SNOW 3G Ciphertext data not as expected");
3350 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3352 struct crypto_testsuite_params *ts_params = &testsuite_params;
3353 struct crypto_unittest_params *ut_params = &unittest_params;
3356 unsigned int plaintext_pad_len;
3357 unsigned int plaintext_len;
3358 uint8_t buffer[10000];
3359 const uint8_t *ciphertext;
3361 struct rte_cryptodev_info dev_info;
3363 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3364 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3365 printf("Device doesn't support scatter-gather. "
3370 /* Create SNOW 3G session */
3371 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3372 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3373 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3374 tdata->key.data, tdata->key.len);
3378 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3379 /* Append data which is padded to a multiple of */
3380 /* the algorithms block size */
3381 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3383 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3384 plaintext_pad_len, 10, 0);
3385 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3386 plaintext_pad_len, 3, 0);
3388 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3389 "Failed to allocate input buffer in mempool");
3390 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3391 "Failed to allocate output buffer in mempool");
3393 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3395 /* Create SNOW 3G operation */
3396 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3398 tdata->validCipherLenInBits.len,
3403 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3407 ut_params->obuf = ut_params->op->sym->m_dst;
3408 if (ut_params->obuf)
3409 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3410 plaintext_len, buffer);
3412 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3413 plaintext_len, buffer);
3415 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3418 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3420 tdata->ciphertext.data,
3421 tdata->validDataLenInBits.len,
3422 "SNOW 3G Ciphertext data not as expected");
3427 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3429 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3431 uint8_t curr_byte, prev_byte;
3432 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3433 uint8_t lower_byte_mask = (1 << offset) - 1;
3436 prev_byte = buffer[0];
3437 buffer[0] >>= offset;
3439 for (i = 1; i < length_in_bytes; i++) {
3440 curr_byte = buffer[i];
3441 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3442 (curr_byte >> offset);
3443 prev_byte = curr_byte;
3448 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3450 struct crypto_testsuite_params *ts_params = &testsuite_params;
3451 struct crypto_unittest_params *ut_params = &unittest_params;
3452 uint8_t *plaintext, *ciphertext;
3454 uint32_t plaintext_len;
3455 uint32_t plaintext_pad_len;
3456 uint8_t extra_offset = 4;
3457 uint8_t *expected_ciphertext_shifted;
3459 /* Create SNOW 3G session */
3460 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3461 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3462 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3463 tdata->key.data, tdata->key.len);
3467 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3468 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3470 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3471 "Failed to allocate input buffer in mempool");
3472 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3473 "Failed to allocate output buffer in mempool");
3475 /* Clear mbuf payload */
3476 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3477 rte_pktmbuf_tailroom(ut_params->ibuf));
3479 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3481 * Append data which is padded to a
3482 * multiple of the algorithms block size
3484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3486 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3489 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3491 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3492 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3494 #ifdef RTE_APP_TEST_DEBUG
3495 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3497 /* Create SNOW 3G operation */
3498 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3500 tdata->validCipherLenInBits.len,
3505 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3507 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3509 ut_params->obuf = ut_params->op->sym->m_dst;
3510 if (ut_params->obuf)
3511 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3513 ciphertext = plaintext;
3515 #ifdef RTE_APP_TEST_DEBUG
3516 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3519 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3521 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3522 "failed to reserve memory for ciphertext shifted\n");
3524 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3525 ceil_byte_length(tdata->ciphertext.len));
3526 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3529 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3531 expected_ciphertext_shifted,
3532 tdata->validDataLenInBits.len,
3534 "SNOW 3G Ciphertext data not as expected");
3538 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3540 struct crypto_testsuite_params *ts_params = &testsuite_params;
3541 struct crypto_unittest_params *ut_params = &unittest_params;
3545 uint8_t *plaintext, *ciphertext;
3546 unsigned ciphertext_pad_len;
3547 unsigned ciphertext_len;
3549 /* Create SNOW 3G session */
3550 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3551 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3552 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3553 tdata->key.data, tdata->key.len);
3557 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3559 /* Clear mbuf payload */
3560 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3561 rte_pktmbuf_tailroom(ut_params->ibuf));
3563 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3564 /* Append data which is padded to a multiple of */
3565 /* the algorithms block size */
3566 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3567 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3568 ciphertext_pad_len);
3569 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3571 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3573 /* Create SNOW 3G operation */
3574 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3575 tdata->validCipherLenInBits.len,
3580 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3582 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3583 ut_params->obuf = ut_params->op->sym->m_dst;
3584 if (ut_params->obuf)
3585 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3587 plaintext = ciphertext;
3589 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3592 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3593 tdata->plaintext.data,
3594 tdata->validDataLenInBits.len,
3595 "SNOW 3G Plaintext data not as expected");
3599 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3601 struct crypto_testsuite_params *ts_params = &testsuite_params;
3602 struct crypto_unittest_params *ut_params = &unittest_params;
3606 uint8_t *plaintext, *ciphertext;
3607 unsigned ciphertext_pad_len;
3608 unsigned ciphertext_len;
3610 /* Create SNOW 3G session */
3611 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3612 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3613 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3614 tdata->key.data, tdata->key.len);
3618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3619 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3621 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3622 "Failed to allocate input buffer");
3623 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3624 "Failed to allocate output buffer");
3626 /* Clear mbuf payload */
3627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3628 rte_pktmbuf_tailroom(ut_params->ibuf));
3630 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3631 rte_pktmbuf_tailroom(ut_params->obuf));
3633 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3634 /* Append data which is padded to a multiple of */
3635 /* the algorithms block size */
3636 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3637 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3638 ciphertext_pad_len);
3639 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3640 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3642 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3644 /* Create SNOW 3G operation */
3645 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3647 tdata->validCipherLenInBits.len,
3652 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3654 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3655 ut_params->obuf = ut_params->op->sym->m_dst;
3656 if (ut_params->obuf)
3657 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3659 plaintext = ciphertext;
3661 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3664 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3665 tdata->plaintext.data,
3666 tdata->validDataLenInBits.len,
3667 "SNOW 3G Plaintext data not as expected");
3672 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3674 struct crypto_testsuite_params *ts_params = &testsuite_params;
3675 struct crypto_unittest_params *ut_params = &unittest_params;
3679 uint8_t *plaintext, *ciphertext;
3680 unsigned int plaintext_pad_len;
3681 unsigned int plaintext_len;
3683 struct rte_cryptodev_sym_capability_idx cap_idx;
3685 /* Check if device supports ZUC EEA3 */
3686 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3687 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3689 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3693 /* Check if device supports ZUC EIA3 */
3694 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3695 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3697 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3701 /* Create ZUC session */
3702 retval = create_zuc_cipher_auth_encrypt_generate_session(
3703 ts_params->valid_devs[0],
3707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3709 /* clear mbuf payload */
3710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3711 rte_pktmbuf_tailroom(ut_params->ibuf));
3713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3714 /* Append data which is padded to a multiple of */
3715 /* the algorithms block size */
3716 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3717 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3719 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3721 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3723 /* Create ZUC operation */
3724 retval = create_zuc_cipher_hash_generate_operation(tdata);
3728 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3730 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 ut_params->obuf = ut_params->op->sym->m_src;
3732 if (ut_params->obuf)
3733 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3736 ciphertext = plaintext;
3738 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3742 tdata->ciphertext.data,
3743 tdata->validDataLenInBits.len,
3744 "ZUC Ciphertext data not as expected");
3746 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3747 + plaintext_pad_len + tdata->aad.len;
3750 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3754 "ZUC Generated auth tag not as expected");
3759 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3761 struct crypto_testsuite_params *ts_params = &testsuite_params;
3762 struct crypto_unittest_params *ut_params = &unittest_params;
3766 uint8_t *plaintext, *ciphertext;
3767 unsigned plaintext_pad_len;
3768 unsigned plaintext_len;
3770 /* Create SNOW 3G session */
3771 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3772 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3773 RTE_CRYPTO_AUTH_OP_GENERATE,
3774 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3775 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3776 tdata->key.data, tdata->key.len,
3777 tdata->aad.len, tdata->digest.len);
3780 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3782 /* clear mbuf payload */
3783 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3784 rte_pktmbuf_tailroom(ut_params->ibuf));
3786 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3787 /* Append data which is padded to a multiple of */
3788 /* the algorithms block size */
3789 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3790 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3792 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3794 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3796 /* Create SNOW 3G operation */
3797 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3798 tdata->digest.len, tdata->aad.data,
3799 tdata->aad.len, /*tdata->plaintext.len,*/
3800 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3801 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3802 tdata->iv.data, tdata->iv.len,
3803 tdata->validCipherLenInBits.len,
3805 tdata->validAuthLenInBits.len,
3806 (tdata->aad.len << 3)
3811 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3813 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3814 ut_params->obuf = ut_params->op->sym->m_src;
3815 if (ut_params->obuf)
3816 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3819 ciphertext = plaintext;
3821 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3823 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3825 tdata->ciphertext.data,
3826 tdata->validDataLenInBits.len,
3827 "SNOW 3G Ciphertext data not as expected");
3829 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3830 + plaintext_pad_len + tdata->aad.len;
3833 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3836 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3837 "SNOW 3G Generated auth tag not as expected");
3841 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3843 struct crypto_testsuite_params *ts_params = &testsuite_params;
3844 struct crypto_unittest_params *ut_params = &unittest_params;
3848 uint8_t *plaintext, *ciphertext;
3849 unsigned plaintext_pad_len;
3850 unsigned plaintext_len;
3852 /* Create SNOW 3G session */
3853 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3854 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3855 RTE_CRYPTO_AUTH_OP_GENERATE,
3856 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3857 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3858 tdata->key.data, tdata->key.len,
3859 tdata->aad.len, tdata->digest.len);
3863 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3865 /* clear mbuf payload */
3866 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3867 rte_pktmbuf_tailroom(ut_params->ibuf));
3869 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3870 /* Append data which is padded to a multiple of */
3871 /* the algorithms block size */
3872 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3873 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3875 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3877 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3879 /* Create SNOW 3G operation */
3880 retval = create_wireless_algo_auth_cipher_operation(
3882 tdata->iv.data, tdata->iv.len,
3883 tdata->aad.data, tdata->aad.len,
3885 tdata->validCipherLenInBits.len,
3887 tdata->validAuthLenInBits.len,
3888 (tdata->aad.len << 3),
3889 RTE_CRYPTO_AUTH_SNOW3G_UIA2
3895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3897 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3898 ut_params->obuf = ut_params->op->sym->m_src;
3899 if (ut_params->obuf)
3900 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3903 ciphertext = plaintext;
3905 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3906 + plaintext_pad_len + tdata->aad.len;
3907 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3910 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3912 tdata->ciphertext.data,
3913 tdata->validDataLenInBits.len,
3914 "SNOW 3G Ciphertext data not as expected");
3917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3920 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3921 "SNOW 3G Generated auth tag not as expected");
3926 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3928 struct crypto_testsuite_params *ts_params = &testsuite_params;
3929 struct crypto_unittest_params *ut_params = &unittest_params;
3933 uint8_t *plaintext, *ciphertext;
3934 unsigned plaintext_pad_len;
3935 unsigned plaintext_len;
3937 /* Create KASUMI session */
3938 retval = create_wireless_algo_auth_cipher_session(
3939 ts_params->valid_devs[0],
3940 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3941 RTE_CRYPTO_AUTH_OP_GENERATE,
3942 RTE_CRYPTO_AUTH_KASUMI_F9,
3943 RTE_CRYPTO_CIPHER_KASUMI_F8,
3944 tdata->key.data, tdata->key.len,
3945 tdata->aad.len, tdata->digest.len);
3948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3950 /* clear mbuf payload */
3951 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3952 rte_pktmbuf_tailroom(ut_params->ibuf));
3954 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3955 /* Append data which is padded to a multiple of */
3956 /* the algorithms block size */
3957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3958 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3960 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3962 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3964 /* Create KASUMI operation */
3965 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3966 tdata->iv.data, tdata->iv.len,
3967 tdata->aad.data, tdata->aad.len,
3969 tdata->validCipherLenInBits.len,
3971 tdata->validAuthLenInBits.len,
3972 (tdata->aad.len << 3),
3973 RTE_CRYPTO_AUTH_KASUMI_F9
3979 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3982 ut_params->obuf = ut_params->op->sym->m_src;
3983 if (ut_params->obuf)
3984 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3987 ciphertext = plaintext;
3990 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3992 tdata->ciphertext.data,
3993 tdata->validCipherLenInBits.len,
3994 "KASUMI Ciphertext data not as expected");
3995 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3996 + plaintext_pad_len + tdata->aad.len;
3999 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4002 DIGEST_BYTE_LENGTH_KASUMI_F9,
4003 "KASUMI Generated auth tag not as expected");
4008 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4010 struct crypto_testsuite_params *ts_params = &testsuite_params;
4011 struct crypto_unittest_params *ut_params = &unittest_params;
4015 uint8_t *plaintext, *ciphertext;
4016 unsigned plaintext_pad_len;
4017 unsigned plaintext_len;
4019 /* Create KASUMI session */
4020 retval = create_wireless_algo_cipher_auth_session(
4021 ts_params->valid_devs[0],
4022 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4023 RTE_CRYPTO_AUTH_OP_GENERATE,
4024 RTE_CRYPTO_AUTH_KASUMI_F9,
4025 RTE_CRYPTO_CIPHER_KASUMI_F8,
4026 tdata->key.data, tdata->key.len,
4027 tdata->aad.len, tdata->digest.len);
4031 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4033 /* clear mbuf payload */
4034 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4035 rte_pktmbuf_tailroom(ut_params->ibuf));
4037 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4038 /* Append data which is padded to a multiple of */
4039 /* the algorithms block size */
4040 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4041 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4043 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4045 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4047 /* Create KASUMI operation */
4048 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4049 tdata->digest.len, tdata->aad.data,
4051 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4052 RTE_CRYPTO_AUTH_KASUMI_F9,
4053 tdata->iv.data, tdata->iv.len,
4054 tdata->validCipherLenInBits.len,
4056 tdata->validAuthLenInBits.len,
4057 (tdata->aad.len << 3)
4062 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4064 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4065 ut_params->obuf = ut_params->op->sym->m_src;
4066 if (ut_params->obuf)
4067 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4070 ciphertext = plaintext;
4072 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4073 + plaintext_pad_len + tdata->aad.len;
4076 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4078 tdata->ciphertext.data,
4079 tdata->validCipherLenInBits.len,
4080 "KASUMI Ciphertext data not as expected");
4083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4086 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4087 "KASUMI Generated auth tag not as expected");
4092 test_zuc_encryption(const struct wireless_test_data *tdata)
4094 struct crypto_testsuite_params *ts_params = &testsuite_params;
4095 struct crypto_unittest_params *ut_params = &unittest_params;
4098 uint8_t *plaintext, *ciphertext;
4099 unsigned plaintext_pad_len;
4100 unsigned plaintext_len;
4102 struct rte_cryptodev_sym_capability_idx cap_idx;
4104 /* Check if device supports ZUC EEA3 */
4105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4106 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4108 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4112 /* Create ZUC session */
4113 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4115 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4116 tdata->key.data, tdata->key.len);
4120 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4122 /* Clear mbuf payload */
4123 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4124 rte_pktmbuf_tailroom(ut_params->ibuf));
4126 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4127 /* Append data which is padded to a multiple */
4128 /* of the algorithms block size */
4129 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4130 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4132 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4134 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4136 /* Create ZUC operation */
4137 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
4138 tdata->plaintext.len,
4143 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4145 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4147 ut_params->obuf = ut_params->op->sym->m_dst;
4148 if (ut_params->obuf)
4149 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4151 ciphertext = plaintext;
4153 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4156 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4158 tdata->ciphertext.data,
4159 tdata->validCipherLenInBits.len,
4160 "ZUC Ciphertext data not as expected");
4165 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4167 struct crypto_testsuite_params *ts_params = &testsuite_params;
4168 struct crypto_unittest_params *ut_params = &unittest_params;
4172 unsigned int plaintext_pad_len;
4173 unsigned int plaintext_len;
4174 const uint8_t *ciphertext;
4175 uint8_t ciphertext_buffer[2048];
4176 struct rte_cryptodev_info dev_info;
4178 struct rte_cryptodev_sym_capability_idx cap_idx;
4180 /* Check if device supports ZUC EEA3 */
4181 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4182 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4184 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4188 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4189 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4190 printf("Device doesn't support scatter-gather. "
4195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4197 /* Append data which is padded to a multiple */
4198 /* of the algorithms block size */
4199 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4201 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4202 plaintext_pad_len, 10, 0);
4204 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4205 tdata->plaintext.data);
4207 /* Create ZUC session */
4208 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4209 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4210 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4211 tdata->key.data, tdata->key.len);
4215 /* Clear mbuf payload */
4217 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4219 /* Create ZUC operation */
4220 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4221 tdata->iv.len, tdata->plaintext.len,
4226 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4230 ut_params->obuf = ut_params->op->sym->m_dst;
4231 if (ut_params->obuf)
4232 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4233 0, plaintext_len, ciphertext_buffer);
4235 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4236 0, plaintext_len, ciphertext_buffer);
4239 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4242 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4244 tdata->ciphertext.data,
4245 tdata->validCipherLenInBits.len,
4246 "ZUC Ciphertext data not as expected");
4252 test_zuc_authentication(const struct wireless_test_data *tdata)
4254 struct crypto_testsuite_params *ts_params = &testsuite_params;
4255 struct crypto_unittest_params *ut_params = &unittest_params;
4258 unsigned plaintext_pad_len;
4259 unsigned plaintext_len;
4262 struct rte_cryptodev_sym_capability_idx cap_idx;
4264 /* Check if device supports ZUC EIA3 */
4265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4266 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4272 /* Create ZUC session */
4273 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4274 tdata->key.data, tdata->key.len,
4275 tdata->aad.len, tdata->digest.len,
4276 RTE_CRYPTO_AUTH_OP_GENERATE,
4277 RTE_CRYPTO_AUTH_ZUC_EIA3);
4281 /* alloc mbuf and set payload */
4282 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4284 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4285 rte_pktmbuf_tailroom(ut_params->ibuf));
4287 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4288 /* Append data which is padded to a multiple of */
4289 /* the algorithms block size */
4290 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4291 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4293 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4295 /* Create ZUC operation */
4296 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4297 tdata->aad.data, tdata->aad.len,
4298 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4299 RTE_CRYPTO_AUTH_ZUC_EIA3,
4300 tdata->validAuthLenInBits.len,
4301 (tdata->aad.len << 3));
4305 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4307 ut_params->obuf = ut_params->op->sym->m_src;
4308 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4309 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4310 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4316 DIGEST_BYTE_LENGTH_KASUMI_F9,
4317 "ZUC Generated auth tag not as expected");
4323 test_kasumi_encryption_test_case_1(void)
4325 return test_kasumi_encryption(&kasumi_test_case_1);
4329 test_kasumi_encryption_test_case_1_sgl(void)
4331 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4335 test_kasumi_encryption_test_case_1_oop(void)
4337 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4341 test_kasumi_encryption_test_case_1_oop_sgl(void)
4343 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4347 test_kasumi_encryption_test_case_2(void)
4349 return test_kasumi_encryption(&kasumi_test_case_2);
4353 test_kasumi_encryption_test_case_3(void)
4355 return test_kasumi_encryption(&kasumi_test_case_3);
4359 test_kasumi_encryption_test_case_4(void)
4361 return test_kasumi_encryption(&kasumi_test_case_4);
4365 test_kasumi_encryption_test_case_5(void)
4367 return test_kasumi_encryption(&kasumi_test_case_5);
4371 test_kasumi_decryption_test_case_1(void)
4373 return test_kasumi_decryption(&kasumi_test_case_1);
4377 test_kasumi_decryption_test_case_1_oop(void)
4379 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4383 test_kasumi_decryption_test_case_2(void)
4385 return test_kasumi_decryption(&kasumi_test_case_2);
4389 test_kasumi_decryption_test_case_3(void)
4391 return test_kasumi_decryption(&kasumi_test_case_3);
4395 test_kasumi_decryption_test_case_4(void)
4397 return test_kasumi_decryption(&kasumi_test_case_4);
4401 test_kasumi_decryption_test_case_5(void)
4403 return test_kasumi_decryption(&kasumi_test_case_5);
4406 test_snow3g_encryption_test_case_1(void)
4408 return test_snow3g_encryption(&snow3g_test_case_1);
4412 test_snow3g_encryption_test_case_1_oop(void)
4414 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4418 test_snow3g_encryption_test_case_1_oop_sgl(void)
4420 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4425 test_snow3g_encryption_test_case_1_offset_oop(void)
4427 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4431 test_snow3g_encryption_test_case_2(void)
4433 return test_snow3g_encryption(&snow3g_test_case_2);
4437 test_snow3g_encryption_test_case_3(void)
4439 return test_snow3g_encryption(&snow3g_test_case_3);
4443 test_snow3g_encryption_test_case_4(void)
4445 return test_snow3g_encryption(&snow3g_test_case_4);
4449 test_snow3g_encryption_test_case_5(void)
4451 return test_snow3g_encryption(&snow3g_test_case_5);
4455 test_snow3g_decryption_test_case_1(void)
4457 return test_snow3g_decryption(&snow3g_test_case_1);
4461 test_snow3g_decryption_test_case_1_oop(void)
4463 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4467 test_snow3g_decryption_test_case_2(void)
4469 return test_snow3g_decryption(&snow3g_test_case_2);
4473 test_snow3g_decryption_test_case_3(void)
4475 return test_snow3g_decryption(&snow3g_test_case_3);
4479 test_snow3g_decryption_test_case_4(void)
4481 return test_snow3g_decryption(&snow3g_test_case_4);
4485 test_snow3g_decryption_test_case_5(void)
4487 return test_snow3g_decryption(&snow3g_test_case_5);
4490 test_snow3g_cipher_auth_test_case_1(void)
4492 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4496 test_snow3g_auth_cipher_test_case_1(void)
4498 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4502 test_kasumi_auth_cipher_test_case_1(void)
4504 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4508 test_kasumi_cipher_auth_test_case_1(void)
4510 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4514 test_zuc_encryption_test_case_1(void)
4516 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4520 test_zuc_encryption_test_case_2(void)
4522 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4526 test_zuc_encryption_test_case_3(void)
4528 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4532 test_zuc_encryption_test_case_4(void)
4534 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4538 test_zuc_encryption_test_case_5(void)
4540 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4544 test_zuc_encryption_test_case_6_sgl(void)
4546 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4550 test_zuc_hash_generate_test_case_1(void)
4552 return test_zuc_authentication(&zuc_test_case_auth_1b);
4556 test_zuc_hash_generate_test_case_2(void)
4558 return test_zuc_authentication(&zuc_test_case_auth_90b);
4562 test_zuc_hash_generate_test_case_3(void)
4564 return test_zuc_authentication(&zuc_test_case_auth_577b);
4568 test_zuc_hash_generate_test_case_4(void)
4570 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4574 test_zuc_hash_generate_test_case_5(void)
4576 return test_zuc_authentication(&zuc_test_auth_5670b);
4580 test_zuc_hash_generate_test_case_6(void)
4582 return test_zuc_authentication(&zuc_test_case_auth_128b);
4586 test_zuc_hash_generate_test_case_7(void)
4588 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4592 test_zuc_hash_generate_test_case_8(void)
4594 return test_zuc_authentication(&zuc_test_case_auth_584b);
4598 test_zuc_cipher_auth_test_case_1(void)
4600 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4604 test_zuc_cipher_auth_test_case_2(void)
4606 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4610 test_3DES_chain_qat_all(void)
4612 struct crypto_testsuite_params *ts_params = &testsuite_params;
4615 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4616 ts_params->op_mpool, ts_params->valid_devs[0],
4617 RTE_CRYPTODEV_QAT_SYM_PMD,
4618 BLKCIPHER_3DES_CHAIN_TYPE);
4620 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4622 return TEST_SUCCESS;
4626 test_DES_cipheronly_qat_all(void)
4628 struct crypto_testsuite_params *ts_params = &testsuite_params;
4631 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4632 ts_params->op_mpool, ts_params->valid_devs[0],
4633 RTE_CRYPTODEV_QAT_SYM_PMD,
4634 BLKCIPHER_DES_CIPHERONLY_TYPE);
4636 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4638 return TEST_SUCCESS;
4642 test_DES_docsis_openssl_all(void)
4644 struct crypto_testsuite_params *ts_params = &testsuite_params;
4647 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4648 ts_params->op_mpool, ts_params->valid_devs[0],
4649 RTE_CRYPTODEV_OPENSSL_PMD,
4650 BLKCIPHER_DES_DOCSIS_TYPE);
4652 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4654 return TEST_SUCCESS;
4658 test_3DES_chain_dpaa2_sec_all(void)
4660 struct crypto_testsuite_params *ts_params = &testsuite_params;
4663 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4664 ts_params->op_mpool, ts_params->valid_devs[0],
4665 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4666 BLKCIPHER_3DES_CHAIN_TYPE);
4668 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4670 return TEST_SUCCESS;
4674 test_3DES_cipheronly_dpaa2_sec_all(void)
4676 struct crypto_testsuite_params *ts_params = &testsuite_params;
4679 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4680 ts_params->op_mpool, ts_params->valid_devs[0],
4681 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4682 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4684 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4686 return TEST_SUCCESS;
4690 test_3DES_cipheronly_qat_all(void)
4692 struct crypto_testsuite_params *ts_params = &testsuite_params;
4695 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4696 ts_params->op_mpool, ts_params->valid_devs[0],
4697 RTE_CRYPTODEV_QAT_SYM_PMD,
4698 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4700 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4702 return TEST_SUCCESS;
4706 test_3DES_chain_openssl_all(void)
4708 struct crypto_testsuite_params *ts_params = &testsuite_params;
4711 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4712 ts_params->op_mpool, ts_params->valid_devs[0],
4713 RTE_CRYPTODEV_OPENSSL_PMD,
4714 BLKCIPHER_3DES_CHAIN_TYPE);
4716 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4718 return TEST_SUCCESS;
4722 test_3DES_cipheronly_openssl_all(void)
4724 struct crypto_testsuite_params *ts_params = &testsuite_params;
4727 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4728 ts_params->op_mpool, ts_params->valid_devs[0],
4729 RTE_CRYPTODEV_OPENSSL_PMD,
4730 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4732 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4734 return TEST_SUCCESS;
4737 /* ***** AES-GCM Tests ***** */
4740 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4741 const uint8_t *key, const uint8_t key_len,
4742 const uint8_t aad_len, const uint8_t auth_len,
4743 enum rte_crypto_auth_operation auth_op)
4745 uint8_t cipher_key[key_len];
4747 struct crypto_unittest_params *ut_params = &unittest_params;
4749 memcpy(cipher_key, key, key_len);
4751 /* Setup Cipher Parameters */
4752 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4753 ut_params->cipher_xform.next = NULL;
4755 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4756 ut_params->auth_xform.auth.op = auth_op;
4757 ut_params->cipher_xform.cipher.op = op;
4758 ut_params->cipher_xform.cipher.key.data = cipher_key;
4759 ut_params->cipher_xform.cipher.key.length = key_len;
4761 TEST_HEXDUMP(stdout, "key:", key, key_len);
4763 /* Setup Authentication Parameters */
4764 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4765 ut_params->auth_xform.next = NULL;
4767 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4769 ut_params->auth_xform.auth.digest_length = auth_len;
4770 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4771 ut_params->auth_xform.auth.key.length = 0;
4772 ut_params->auth_xform.auth.key.data = NULL;
4774 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4775 ut_params->cipher_xform.next = &ut_params->auth_xform;
4777 /* Create Crypto session*/
4778 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4779 &ut_params->cipher_xform);
4780 } else {/* Create Crypto session*/
4781 ut_params->auth_xform.next = &ut_params->cipher_xform;
4782 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4783 &ut_params->auth_xform);
4786 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4792 create_gcm_xforms(struct rte_crypto_op *op,
4793 enum rte_crypto_cipher_operation cipher_op,
4794 uint8_t *key, const uint8_t key_len,
4795 const uint8_t aad_len, const uint8_t auth_len,
4796 enum rte_crypto_auth_operation auth_op)
4798 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4799 "failed to allocate space for crypto transforms");
4801 struct rte_crypto_sym_op *sym_op = op->sym;
4803 /* Setup Cipher Parameters */
4804 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4805 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4806 sym_op->xform->cipher.op = cipher_op;
4807 sym_op->xform->cipher.key.data = key;
4808 sym_op->xform->cipher.key.length = key_len;
4810 TEST_HEXDUMP(stdout, "key:", key, key_len);
4812 /* Setup Authentication Parameters */
4813 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4814 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4815 sym_op->xform->next->auth.op = auth_op;
4816 sym_op->xform->next->auth.digest_length = auth_len;
4817 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4818 sym_op->xform->next->auth.key.length = 0;
4819 sym_op->xform->next->auth.key.data = NULL;
4820 sym_op->xform->next->next = NULL;
4826 create_gcm_operation(enum rte_crypto_cipher_operation op,
4827 const struct gcm_test_data *tdata)
4829 struct crypto_testsuite_params *ts_params = &testsuite_params;
4830 struct crypto_unittest_params *ut_params = &unittest_params;
4832 uint8_t *plaintext, *ciphertext;
4833 unsigned int aad_pad_len, plaintext_pad_len;
4835 /* Generate Crypto op data structure */
4836 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4837 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4838 TEST_ASSERT_NOT_NULL(ut_params->op,
4839 "Failed to allocate symmetric crypto operation struct");
4841 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4843 /* Append aad data */
4844 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4845 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4847 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4848 "no room to append aad");
4850 sym_op->auth.aad.length = tdata->aad.len;
4851 sym_op->auth.aad.phys_addr =
4852 rte_pktmbuf_mtophys(ut_params->ibuf);
4853 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4854 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4855 sym_op->auth.aad.length);
4857 /* Append IV at the end of the crypto operation*/
4858 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
4859 uint8_t *, IV_OFFSET);
4860 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
4862 sym_op->cipher.iv.length = tdata->iv.len;
4864 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4865 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4866 sym_op->cipher.iv.length);
4868 /* Append plaintext/ciphertext */
4869 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4870 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4873 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4875 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4876 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4877 tdata->plaintext.len);
4879 if (ut_params->obuf) {
4880 ciphertext = (uint8_t *)rte_pktmbuf_append(
4882 plaintext_pad_len + aad_pad_len);
4883 TEST_ASSERT_NOT_NULL(ciphertext,
4884 "no room to append ciphertext");
4886 memset(ciphertext + aad_pad_len, 0,
4887 tdata->ciphertext.len);
4890 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4891 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4893 TEST_ASSERT_NOT_NULL(ciphertext,
4894 "no room to append ciphertext");
4896 memcpy(ciphertext, tdata->ciphertext.data,
4897 tdata->ciphertext.len);
4898 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4899 tdata->ciphertext.len);
4901 if (ut_params->obuf) {
4902 plaintext = (uint8_t *)rte_pktmbuf_append(
4904 plaintext_pad_len + aad_pad_len);
4905 TEST_ASSERT_NOT_NULL(plaintext,
4906 "no room to append plaintext");
4908 memset(plaintext + aad_pad_len, 0,
4909 tdata->plaintext.len);
4913 /* Append digest data */
4914 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4915 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4916 ut_params->obuf ? ut_params->obuf :
4918 tdata->auth_tag.len);
4919 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4920 "no room to append digest");
4921 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4922 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4923 ut_params->obuf ? ut_params->obuf :
4927 sym_op->auth.digest.length = tdata->auth_tag.len;
4929 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4930 ut_params->ibuf, tdata->auth_tag.len);
4931 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4932 "no room to append digest");
4933 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4935 plaintext_pad_len + aad_pad_len);
4936 sym_op->auth.digest.length = tdata->auth_tag.len;
4938 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4939 tdata->auth_tag.len);
4940 TEST_HEXDUMP(stdout, "digest:",
4941 sym_op->auth.digest.data,
4942 sym_op->auth.digest.length);
4945 sym_op->cipher.data.length = tdata->plaintext.len;
4946 sym_op->cipher.data.offset = aad_pad_len;
4948 sym_op->auth.data.length = tdata->plaintext.len;
4949 sym_op->auth.data.offset = aad_pad_len;
4955 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4957 struct crypto_testsuite_params *ts_params = &testsuite_params;
4958 struct crypto_unittest_params *ut_params = &unittest_params;
4961 uint8_t *ciphertext, *auth_tag;
4962 uint16_t plaintext_pad_len;
4965 /* Create GCM session */
4966 retval = create_gcm_session(ts_params->valid_devs[0],
4967 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4968 tdata->key.data, tdata->key.len,
4969 tdata->aad.len, tdata->auth_tag.len,
4970 RTE_CRYPTO_AUTH_OP_GENERATE);
4974 if (tdata->aad.len > MBUF_SIZE) {
4975 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4976 /* Populate full size of add data */
4977 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4978 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4982 /* clear mbuf payload */
4983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4984 rte_pktmbuf_tailroom(ut_params->ibuf));
4986 /* Create GCM operation */
4987 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4991 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4993 ut_params->op->sym->m_src = ut_params->ibuf;
4995 /* Process crypto operation */
4996 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4997 ut_params->op), "failed to process sym crypto op");
4999 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5000 "crypto op processing failed");
5002 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5004 if (ut_params->op->sym->m_dst) {
5005 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5007 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5008 uint8_t *, plaintext_pad_len);
5010 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5012 ut_params->op->sym->cipher.data.offset);
5013 auth_tag = ciphertext + plaintext_pad_len;
5016 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5017 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5020 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5022 tdata->ciphertext.data,
5023 tdata->ciphertext.len,
5024 "GCM Ciphertext data not as expected");
5026 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5028 tdata->auth_tag.data,
5029 tdata->auth_tag.len,
5030 "GCM Generated auth tag not as expected");
5037 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
5039 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5043 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
5045 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5049 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
5051 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5055 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
5057 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5061 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
5063 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5067 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
5069 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5073 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
5075 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5079 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
5081 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5085 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
5087 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5091 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
5093 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5097 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5099 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5103 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5105 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5109 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5111 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5115 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5117 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5121 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5123 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5127 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5129 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5133 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5135 struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 struct crypto_unittest_params *ut_params = &unittest_params;
5142 /* Create GCM session */
5143 retval = create_gcm_session(ts_params->valid_devs[0],
5144 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5145 tdata->key.data, tdata->key.len,
5146 tdata->aad.len, tdata->auth_tag.len,
5147 RTE_CRYPTO_AUTH_OP_VERIFY);
5151 /* alloc mbuf and set payload */
5152 if (tdata->aad.len > MBUF_SIZE) {
5153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5154 /* Populate full size of add data */
5155 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5156 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5158 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5160 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5161 rte_pktmbuf_tailroom(ut_params->ibuf));
5163 /* Create GCM operation */
5164 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5168 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5170 ut_params->op->sym->m_src = ut_params->ibuf;
5172 /* Process crypto operation */
5173 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5174 ut_params->op), "failed to process sym crypto op");
5176 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5177 "crypto op processing failed");
5179 if (ut_params->op->sym->m_dst)
5180 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5183 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5185 ut_params->op->sym->cipher.data.offset);
5187 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5190 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5192 tdata->plaintext.data,
5193 tdata->plaintext.len,
5194 "GCM plaintext data not as expected");
5196 TEST_ASSERT_EQUAL(ut_params->op->status,
5197 RTE_CRYPTO_OP_STATUS_SUCCESS,
5198 "GCM authentication failed");
5203 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5205 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5209 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5211 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5215 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5217 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5221 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5223 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5227 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5229 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5233 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5235 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5239 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5241 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5245 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5247 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5251 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5253 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5257 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5259 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5263 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5265 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5269 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5271 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5275 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5277 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5281 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5283 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5287 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5289 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5293 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5295 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5299 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5301 struct crypto_testsuite_params *ts_params = &testsuite_params;
5302 struct crypto_unittest_params *ut_params = &unittest_params;
5305 uint8_t *ciphertext, *auth_tag;
5306 uint16_t plaintext_pad_len;
5308 /* Create GCM session */
5309 retval = create_gcm_session(ts_params->valid_devs[0],
5310 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5311 tdata->key.data, tdata->key.len,
5312 tdata->aad.len, tdata->auth_tag.len,
5313 RTE_CRYPTO_AUTH_OP_GENERATE);
5317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5318 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5320 /* clear mbuf payload */
5321 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5322 rte_pktmbuf_tailroom(ut_params->ibuf));
5323 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5324 rte_pktmbuf_tailroom(ut_params->obuf));
5326 /* Create GCM operation */
5327 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5331 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5333 ut_params->op->sym->m_src = ut_params->ibuf;
5334 ut_params->op->sym->m_dst = ut_params->obuf;
5336 /* Process crypto operation */
5337 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5338 ut_params->op), "failed to process sym crypto op");
5340 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5341 "crypto op processing failed");
5343 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5345 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5346 ut_params->op->sym->cipher.data.offset);
5347 auth_tag = ciphertext + plaintext_pad_len;
5349 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5350 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5353 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5355 tdata->ciphertext.data,
5356 tdata->ciphertext.len,
5357 "GCM Ciphertext data not as expected");
5359 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5361 tdata->auth_tag.data,
5362 tdata->auth_tag.len,
5363 "GCM Generated auth tag not as expected");
5370 test_mb_AES_GCM_authenticated_encryption_oop(void)
5372 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5376 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5378 struct crypto_testsuite_params *ts_params = &testsuite_params;
5379 struct crypto_unittest_params *ut_params = &unittest_params;
5384 /* Create GCM session */
5385 retval = create_gcm_session(ts_params->valid_devs[0],
5386 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5387 tdata->key.data, tdata->key.len,
5388 tdata->aad.len, tdata->auth_tag.len,
5389 RTE_CRYPTO_AUTH_OP_VERIFY);
5393 /* alloc mbuf and set payload */
5394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5395 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5397 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5398 rte_pktmbuf_tailroom(ut_params->ibuf));
5399 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5400 rte_pktmbuf_tailroom(ut_params->obuf));
5402 /* Create GCM operation */
5403 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5407 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5409 ut_params->op->sym->m_src = ut_params->ibuf;
5410 ut_params->op->sym->m_dst = ut_params->obuf;
5412 /* Process crypto operation */
5413 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5414 ut_params->op), "failed to process sym crypto op");
5416 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5417 "crypto op processing failed");
5419 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5420 ut_params->op->sym->cipher.data.offset);
5422 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5425 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5427 tdata->plaintext.data,
5428 tdata->plaintext.len,
5429 "GCM plaintext data not as expected");
5431 TEST_ASSERT_EQUAL(ut_params->op->status,
5432 RTE_CRYPTO_OP_STATUS_SUCCESS,
5433 "GCM authentication failed");
5438 test_mb_AES_GCM_authenticated_decryption_oop(void)
5440 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5444 test_AES_GCM_authenticated_encryption_sessionless(
5445 const struct gcm_test_data *tdata)
5447 struct crypto_testsuite_params *ts_params = &testsuite_params;
5448 struct crypto_unittest_params *ut_params = &unittest_params;
5451 uint8_t *ciphertext, *auth_tag;
5452 uint16_t plaintext_pad_len;
5453 uint8_t key[tdata->key.len + 1];
5455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5457 /* clear mbuf payload */
5458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5459 rte_pktmbuf_tailroom(ut_params->ibuf));
5461 /* Create GCM operation */
5462 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5466 /* Create GCM xforms */
5467 memcpy(key, tdata->key.data, tdata->key.len);
5468 retval = create_gcm_xforms(ut_params->op,
5469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5470 key, tdata->key.len,
5471 tdata->aad.len, tdata->auth_tag.len,
5472 RTE_CRYPTO_AUTH_OP_GENERATE);
5476 ut_params->op->sym->m_src = ut_params->ibuf;
5478 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5479 RTE_CRYPTO_OP_SESSIONLESS,
5480 "crypto op session type not sessionless");
5482 /* Process crypto operation */
5483 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5484 ut_params->op), "failed to process sym crypto op");
5486 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5488 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5489 "crypto op status not success");
5491 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5493 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5494 ut_params->op->sym->cipher.data.offset);
5495 auth_tag = ciphertext + plaintext_pad_len;
5497 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5498 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5501 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5503 tdata->ciphertext.data,
5504 tdata->ciphertext.len,
5505 "GCM Ciphertext data not as expected");
5507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5509 tdata->auth_tag.data,
5510 tdata->auth_tag.len,
5511 "GCM Generated auth tag not as expected");
5518 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5520 return test_AES_GCM_authenticated_encryption_sessionless(
5525 test_AES_GCM_authenticated_decryption_sessionless(
5526 const struct gcm_test_data *tdata)
5528 struct crypto_testsuite_params *ts_params = &testsuite_params;
5529 struct crypto_unittest_params *ut_params = &unittest_params;
5533 uint8_t key[tdata->key.len + 1];
5535 /* alloc mbuf and set payload */
5536 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5538 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5539 rte_pktmbuf_tailroom(ut_params->ibuf));
5541 /* Create GCM operation */
5542 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5546 /* Create GCM xforms */
5547 memcpy(key, tdata->key.data, tdata->key.len);
5548 retval = create_gcm_xforms(ut_params->op,
5549 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5550 key, tdata->key.len,
5551 tdata->aad.len, tdata->auth_tag.len,
5552 RTE_CRYPTO_AUTH_OP_VERIFY);
5556 ut_params->op->sym->m_src = ut_params->ibuf;
5558 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5559 RTE_CRYPTO_OP_SESSIONLESS,
5560 "crypto op session type not sessionless");
5562 /* Process crypto operation */
5563 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5564 ut_params->op), "failed to process sym crypto op");
5566 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5568 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5569 "crypto op status not success");
5571 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5572 ut_params->op->sym->cipher.data.offset);
5574 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5577 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5579 tdata->plaintext.data,
5580 tdata->plaintext.len,
5581 "GCM plaintext data not as expected");
5583 TEST_ASSERT_EQUAL(ut_params->op->status,
5584 RTE_CRYPTO_OP_STATUS_SUCCESS,
5585 "GCM authentication failed");
5590 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5592 return test_AES_GCM_authenticated_decryption_sessionless(
5599 struct crypto_testsuite_params *ts_params = &testsuite_params;
5600 struct rte_cryptodev_stats stats;
5601 struct rte_cryptodev *dev;
5602 cryptodev_stats_get_t temp_pfn;
5604 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5605 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5606 &stats) == -ENODEV),
5607 "rte_cryptodev_stats_get invalid dev failed");
5608 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5609 "rte_cryptodev_stats_get invalid Param failed");
5610 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5611 temp_pfn = dev->dev_ops->stats_get;
5612 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5613 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5615 "rte_cryptodev_stats_get invalid Param failed");
5616 dev->dev_ops->stats_get = temp_pfn;
5618 /* Test expected values */
5620 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5622 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5624 "rte_cryptodev_stats_get failed");
5625 TEST_ASSERT((stats.enqueued_count == 1),
5626 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5627 TEST_ASSERT((stats.dequeued_count == 1),
5628 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5629 TEST_ASSERT((stats.enqueue_err_count == 0),
5630 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5631 TEST_ASSERT((stats.dequeue_err_count == 0),
5632 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5634 /* invalid device but should ignore and not reset device stats*/
5635 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5636 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5638 "rte_cryptodev_stats_get failed");
5639 TEST_ASSERT((stats.enqueued_count == 1),
5640 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5642 /* check that a valid reset clears stats */
5643 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5644 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5646 "rte_cryptodev_stats_get failed");
5647 TEST_ASSERT((stats.enqueued_count == 0),
5648 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5649 TEST_ASSERT((stats.dequeued_count == 0),
5650 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5652 return TEST_SUCCESS;
5655 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5656 struct crypto_unittest_params *ut_params,
5657 enum rte_crypto_auth_operation op,
5658 const struct HMAC_MD5_vector *test_case)
5662 memcpy(key, test_case->key.data, test_case->key.len);
5664 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5665 ut_params->auth_xform.next = NULL;
5666 ut_params->auth_xform.auth.op = op;
5668 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5670 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5671 ut_params->auth_xform.auth.add_auth_data_length = 0;
5672 ut_params->auth_xform.auth.key.length = test_case->key.len;
5673 ut_params->auth_xform.auth.key.data = key;
5675 ut_params->sess = rte_cryptodev_sym_session_create(
5676 ts_params->valid_devs[0], &ut_params->auth_xform);
5678 if (ut_params->sess == NULL)
5681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5683 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5684 rte_pktmbuf_tailroom(ut_params->ibuf));
5689 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5690 const struct HMAC_MD5_vector *test_case,
5691 uint8_t **plaintext)
5693 uint16_t plaintext_pad_len;
5695 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5697 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5700 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5702 memcpy(*plaintext, test_case->plaintext.data,
5703 test_case->plaintext.len);
5705 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5706 ut_params->ibuf, MD5_DIGEST_LEN);
5707 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5708 "no room to append digest");
5709 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5710 ut_params->ibuf, plaintext_pad_len);
5711 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5713 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5714 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5715 test_case->auth_tag.len);
5718 sym_op->auth.data.offset = 0;
5719 sym_op->auth.data.length = test_case->plaintext.len;
5721 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5722 ut_params->op->sym->m_src = ut_params->ibuf;
5728 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5730 uint16_t plaintext_pad_len;
5731 uint8_t *plaintext, *auth_tag;
5733 struct crypto_testsuite_params *ts_params = &testsuite_params;
5734 struct crypto_unittest_params *ut_params = &unittest_params;
5736 if (MD5_HMAC_create_session(ts_params, ut_params,
5737 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5740 /* Generate Crypto op data structure */
5741 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5742 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5743 TEST_ASSERT_NOT_NULL(ut_params->op,
5744 "Failed to allocate symmetric crypto operation struct");
5746 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5749 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5752 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5753 ut_params->op), "failed to process sym crypto op");
5755 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5756 "crypto op processing failed");
5758 if (ut_params->op->sym->m_dst) {
5759 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5760 uint8_t *, plaintext_pad_len);
5762 auth_tag = plaintext + plaintext_pad_len;
5765 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5767 test_case->auth_tag.data,
5768 test_case->auth_tag.len,
5769 "HMAC_MD5 generated tag not as expected");
5771 return TEST_SUCCESS;
5775 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5779 struct crypto_testsuite_params *ts_params = &testsuite_params;
5780 struct crypto_unittest_params *ut_params = &unittest_params;
5782 if (MD5_HMAC_create_session(ts_params, ut_params,
5783 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5787 /* Generate Crypto op data structure */
5788 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5789 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5790 TEST_ASSERT_NOT_NULL(ut_params->op,
5791 "Failed to allocate symmetric crypto operation struct");
5793 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5796 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5797 ut_params->op), "failed to process sym crypto op");
5799 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5800 "HMAC_MD5 crypto op processing failed");
5802 return TEST_SUCCESS;
5806 test_MD5_HMAC_generate_case_1(void)
5808 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5812 test_MD5_HMAC_verify_case_1(void)
5814 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5818 test_MD5_HMAC_generate_case_2(void)
5820 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5824 test_MD5_HMAC_verify_case_2(void)
5826 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5830 test_multi_session(void)
5832 struct crypto_testsuite_params *ts_params = &testsuite_params;
5833 struct crypto_unittest_params *ut_params = &unittest_params;
5835 struct rte_cryptodev_info dev_info;
5836 struct rte_cryptodev_sym_session **sessions;
5840 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5841 aes_cbc_key, hmac_sha512_key);
5844 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5846 sessions = rte_malloc(NULL,
5847 (sizeof(struct rte_cryptodev_sym_session *) *
5848 dev_info.sym.max_nb_sessions) + 1, 0);
5850 /* Create multiple crypto sessions*/
5851 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5852 sessions[i] = rte_cryptodev_sym_session_create(
5853 ts_params->valid_devs[0],
5854 &ut_params->auth_xform);
5855 TEST_ASSERT_NOT_NULL(sessions[i],
5856 "Session creation failed at session number %u",
5859 /* Attempt to send a request on each session */
5860 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5864 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5865 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5867 "Failed to perform decrypt on request number %u.", i);
5868 /* free crypto operation structure */
5870 rte_crypto_op_free(ut_params->op);
5873 * free mbuf - both obuf and ibuf are usually the same,
5874 * so check if they point at the same address is necessary,
5875 * to avoid freeing the mbuf twice.
5877 if (ut_params->obuf) {
5878 rte_pktmbuf_free(ut_params->obuf);
5879 if (ut_params->ibuf == ut_params->obuf)
5880 ut_params->ibuf = 0;
5881 ut_params->obuf = 0;
5883 if (ut_params->ibuf) {
5884 rte_pktmbuf_free(ut_params->ibuf);
5885 ut_params->ibuf = 0;
5889 /* Next session create should fail */
5890 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5891 &ut_params->auth_xform);
5892 TEST_ASSERT_NULL(sessions[i],
5893 "Session creation succeeded unexpectedly!");
5895 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5896 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5901 return TEST_SUCCESS;
5904 struct multi_session_params {
5905 struct crypto_unittest_params ut_params;
5906 uint8_t *cipher_key;
5908 const uint8_t *cipher;
5909 const uint8_t *digest;
5913 #define MB_SESSION_NUMBER 3
5916 test_multi_session_random_usage(void)
5918 struct crypto_testsuite_params *ts_params = &testsuite_params;
5919 struct rte_cryptodev_info dev_info;
5920 struct rte_cryptodev_sym_session **sessions;
5922 struct multi_session_params ut_paramz[] = {
5925 .cipher_key = ms_aes_cbc_key0,
5926 .hmac_key = ms_hmac_key0,
5927 .cipher = ms_aes_cbc_cipher0,
5928 .digest = ms_hmac_digest0,
5929 .iv = ms_aes_cbc_iv0
5932 .cipher_key = ms_aes_cbc_key1,
5933 .hmac_key = ms_hmac_key1,
5934 .cipher = ms_aes_cbc_cipher1,
5935 .digest = ms_hmac_digest1,
5936 .iv = ms_aes_cbc_iv1
5939 .cipher_key = ms_aes_cbc_key2,
5940 .hmac_key = ms_hmac_key2,
5941 .cipher = ms_aes_cbc_cipher2,
5942 .digest = ms_hmac_digest2,
5943 .iv = ms_aes_cbc_iv2
5948 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5950 sessions = rte_malloc(NULL,
5951 (sizeof(struct rte_cryptodev_sym_session *)
5952 * dev_info.sym.max_nb_sessions) + 1, 0);
5954 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5955 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5956 sizeof(struct crypto_unittest_params));
5958 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5959 &ut_paramz[i].ut_params,
5960 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5962 /* Create multiple crypto sessions*/
5963 sessions[i] = rte_cryptodev_sym_session_create(
5964 ts_params->valid_devs[0],
5965 &ut_paramz[i].ut_params.auth_xform);
5967 TEST_ASSERT_NOT_NULL(sessions[i],
5968 "Session creation failed at session number %u",
5974 for (i = 0; i < 40000; i++) {
5976 j = rand() % MB_SESSION_NUMBER;
5978 TEST_ASSERT_SUCCESS(
5979 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5981 &ut_paramz[j].ut_params,
5982 ts_params, ut_paramz[j].cipher,
5983 ut_paramz[j].digest,
5985 "Failed to perform decrypt on request number %u.", i);
5987 if (ut_paramz[j].ut_params.op)
5988 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5991 * free mbuf - both obuf and ibuf are usually the same,
5992 * so check if they point at the same address is necessary,
5993 * to avoid freeing the mbuf twice.
5995 if (ut_paramz[j].ut_params.obuf) {
5996 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5997 if (ut_paramz[j].ut_params.ibuf
5998 == ut_paramz[j].ut_params.obuf)
5999 ut_paramz[j].ut_params.ibuf = 0;
6000 ut_paramz[j].ut_params.obuf = 0;
6002 if (ut_paramz[j].ut_params.ibuf) {
6003 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6004 ut_paramz[j].ut_params.ibuf = 0;
6008 for (i = 0; i < MB_SESSION_NUMBER; i++)
6009 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
6014 return TEST_SUCCESS;
6018 test_null_cipher_only_operation(void)
6020 struct crypto_testsuite_params *ts_params = &testsuite_params;
6021 struct crypto_unittest_params *ut_params = &unittest_params;
6023 /* Generate test mbuf data and space for digest */
6024 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6025 catch_22_quote, QUOTE_512_BYTES, 0);
6027 /* Setup Cipher Parameters */
6028 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6029 ut_params->cipher_xform.next = NULL;
6031 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6032 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6034 /* Create Crypto session*/
6035 ut_params->sess = rte_cryptodev_sym_session_create(
6036 ts_params->valid_devs[0], &ut_params->cipher_xform);
6037 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6039 /* Generate Crypto op data structure */
6040 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6041 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6042 TEST_ASSERT_NOT_NULL(ut_params->op,
6043 "Failed to allocate symmetric crypto operation struct");
6045 /* Set crypto operation data parameters */
6046 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6048 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6050 /* set crypto operation source mbuf */
6051 sym_op->m_src = ut_params->ibuf;
6053 sym_op->cipher.data.offset = 0;
6054 sym_op->cipher.data.length = QUOTE_512_BYTES;
6056 /* Process crypto operation */
6057 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6059 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6061 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6062 "crypto operation processing failed");
6065 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6066 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6069 "Ciphertext data not as expected");
6071 return TEST_SUCCESS;
6075 test_null_auth_only_operation(void)
6077 struct crypto_testsuite_params *ts_params = &testsuite_params;
6078 struct crypto_unittest_params *ut_params = &unittest_params;
6080 /* Generate test mbuf data and space for digest */
6081 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6082 catch_22_quote, QUOTE_512_BYTES, 0);
6084 /* Setup HMAC Parameters */
6085 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6086 ut_params->auth_xform.next = NULL;
6088 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6089 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6091 /* Create Crypto session*/
6092 ut_params->sess = rte_cryptodev_sym_session_create(
6093 ts_params->valid_devs[0], &ut_params->auth_xform);
6094 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6096 /* Generate Crypto op data structure */
6097 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6098 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6099 TEST_ASSERT_NOT_NULL(ut_params->op,
6100 "Failed to allocate symmetric crypto operation struct");
6102 /* Set crypto operation data parameters */
6103 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6105 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6107 sym_op->m_src = ut_params->ibuf;
6109 sym_op->auth.data.offset = 0;
6110 sym_op->auth.data.length = QUOTE_512_BYTES;
6112 /* Process crypto operation */
6113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6115 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6117 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6118 "crypto operation processing failed");
6120 return TEST_SUCCESS;
6124 test_null_cipher_auth_operation(void)
6126 struct crypto_testsuite_params *ts_params = &testsuite_params;
6127 struct crypto_unittest_params *ut_params = &unittest_params;
6129 /* Generate test mbuf data and space for digest */
6130 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6131 catch_22_quote, QUOTE_512_BYTES, 0);
6133 /* Setup Cipher Parameters */
6134 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6135 ut_params->cipher_xform.next = &ut_params->auth_xform;
6137 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6138 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6140 /* Setup HMAC Parameters */
6141 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6142 ut_params->auth_xform.next = NULL;
6144 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6145 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6147 /* Create Crypto session*/
6148 ut_params->sess = rte_cryptodev_sym_session_create(
6149 ts_params->valid_devs[0], &ut_params->cipher_xform);
6150 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6152 /* Generate Crypto op data structure */
6153 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6154 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6155 TEST_ASSERT_NOT_NULL(ut_params->op,
6156 "Failed to allocate symmetric crypto operation struct");
6158 /* Set crypto operation data parameters */
6159 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6161 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6163 sym_op->m_src = ut_params->ibuf;
6165 sym_op->cipher.data.offset = 0;
6166 sym_op->cipher.data.length = QUOTE_512_BYTES;
6168 sym_op->auth.data.offset = 0;
6169 sym_op->auth.data.length = QUOTE_512_BYTES;
6171 /* Process crypto operation */
6172 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6174 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6176 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6177 "crypto operation processing failed");
6180 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6181 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6184 "Ciphertext data not as expected");
6186 return TEST_SUCCESS;
6190 test_null_auth_cipher_operation(void)
6192 struct crypto_testsuite_params *ts_params = &testsuite_params;
6193 struct crypto_unittest_params *ut_params = &unittest_params;
6195 /* Generate test mbuf data and space for digest */
6196 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6197 catch_22_quote, QUOTE_512_BYTES, 0);
6199 /* Setup Cipher Parameters */
6200 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6201 ut_params->cipher_xform.next = NULL;
6203 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6204 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6206 /* Setup HMAC Parameters */
6207 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6208 ut_params->auth_xform.next = &ut_params->cipher_xform;
6210 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6211 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6213 /* Create Crypto session*/
6214 ut_params->sess = rte_cryptodev_sym_session_create(
6215 ts_params->valid_devs[0], &ut_params->cipher_xform);
6216 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6218 /* Generate Crypto op data structure */
6219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6221 TEST_ASSERT_NOT_NULL(ut_params->op,
6222 "Failed to allocate symmetric crypto operation struct");
6224 /* Set crypto operation data parameters */
6225 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6227 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6229 sym_op->m_src = ut_params->ibuf;
6231 sym_op->cipher.data.offset = 0;
6232 sym_op->cipher.data.length = QUOTE_512_BYTES;
6234 sym_op->auth.data.offset = 0;
6235 sym_op->auth.data.length = QUOTE_512_BYTES;
6237 /* Process crypto operation */
6238 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6240 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6242 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6243 "crypto operation processing failed");
6246 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6247 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6250 "Ciphertext data not as expected");
6252 return TEST_SUCCESS;
6257 test_null_invalid_operation(void)
6259 struct crypto_testsuite_params *ts_params = &testsuite_params;
6260 struct crypto_unittest_params *ut_params = &unittest_params;
6262 /* Setup Cipher Parameters */
6263 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6264 ut_params->cipher_xform.next = NULL;
6266 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6267 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6269 /* Create Crypto session*/
6270 ut_params->sess = rte_cryptodev_sym_session_create(
6271 ts_params->valid_devs[0], &ut_params->cipher_xform);
6272 TEST_ASSERT_NULL(ut_params->sess,
6273 "Session creation succeeded unexpectedly");
6276 /* Setup HMAC Parameters */
6277 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6278 ut_params->auth_xform.next = NULL;
6280 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6281 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6283 /* Create Crypto session*/
6284 ut_params->sess = rte_cryptodev_sym_session_create(
6285 ts_params->valid_devs[0], &ut_params->auth_xform);
6286 TEST_ASSERT_NULL(ut_params->sess,
6287 "Session creation succeeded unexpectedly");
6289 return TEST_SUCCESS;
6293 #define NULL_BURST_LENGTH (32)
6296 test_null_burst_operation(void)
6298 struct crypto_testsuite_params *ts_params = &testsuite_params;
6299 struct crypto_unittest_params *ut_params = &unittest_params;
6301 unsigned i, burst_len = NULL_BURST_LENGTH;
6303 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6304 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6306 /* Setup Cipher Parameters */
6307 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6308 ut_params->cipher_xform.next = &ut_params->auth_xform;
6310 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6311 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6313 /* Setup HMAC Parameters */
6314 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6315 ut_params->auth_xform.next = NULL;
6317 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6318 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6320 /* Create Crypto session*/
6321 ut_params->sess = rte_cryptodev_sym_session_create(
6322 ts_params->valid_devs[0], &ut_params->cipher_xform);
6323 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6325 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6326 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6327 burst_len, "failed to generate burst of crypto ops");
6329 /* Generate an operation for each mbuf in burst */
6330 for (i = 0; i < burst_len; i++) {
6331 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6333 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6335 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6339 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6341 burst[i]->sym->m_src = m;
6344 /* Process crypto operation */
6345 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6346 0, burst, burst_len),
6348 "Error enqueuing burst");
6350 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6351 0, burst_dequeued, burst_len),
6353 "Error dequeuing burst");
6356 for (i = 0; i < burst_len; i++) {
6358 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6359 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6361 "data not as expected");
6363 rte_pktmbuf_free(burst[i]->sym->m_src);
6364 rte_crypto_op_free(burst[i]);
6367 return TEST_SUCCESS;
6371 generate_gmac_large_plaintext(uint8_t *data)
6375 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6376 memcpy(&data[i], &data[0], 32);
6380 create_gmac_operation(enum rte_crypto_auth_operation op,
6381 const struct gmac_test_data *tdata)
6383 struct crypto_testsuite_params *ts_params = &testsuite_params;
6384 struct crypto_unittest_params *ut_params = &unittest_params;
6385 struct rte_crypto_sym_op *sym_op;
6387 unsigned aad_pad_len;
6389 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6392 * Runtime generate the large plain text instead of use hard code
6393 * plain text vector. It is done to avoid create huge source file
6394 * with the test vector.
6396 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6397 generate_gmac_large_plaintext(tdata->aad.data);
6399 /* Generate Crypto op data structure */
6400 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6401 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6402 TEST_ASSERT_NOT_NULL(ut_params->op,
6403 "Failed to allocate symmetric crypto operation struct");
6405 sym_op = ut_params->op->sym;
6406 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6408 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6409 "no room to append aad");
6411 sym_op->auth.aad.length = tdata->aad.len;
6412 sym_op->auth.aad.phys_addr =
6413 rte_pktmbuf_mtophys(ut_params->ibuf);
6414 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6416 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6417 ut_params->ibuf, tdata->gmac_tag.len);
6418 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6419 "no room to append digest");
6421 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6422 ut_params->ibuf, aad_pad_len);
6423 sym_op->auth.digest.length = tdata->gmac_tag.len;
6425 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6426 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6427 tdata->gmac_tag.len);
6428 TEST_HEXDUMP(stdout, "digest:",
6429 sym_op->auth.digest.data,
6430 sym_op->auth.digest.length);
6433 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
6434 uint8_t *, IV_OFFSET);
6435 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
6437 sym_op->cipher.iv.length = tdata->iv.len;
6439 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6441 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, tdata->iv.len);
6443 sym_op->cipher.data.length = 0;
6444 sym_op->cipher.data.offset = 0;
6446 sym_op->auth.data.offset = 0;
6447 sym_op->auth.data.length = 0;
6452 static int create_gmac_session(uint8_t dev_id,
6453 enum rte_crypto_cipher_operation op,
6454 const struct gmac_test_data *tdata,
6455 enum rte_crypto_auth_operation auth_op)
6457 uint8_t cipher_key[tdata->key.len];
6459 struct crypto_unittest_params *ut_params = &unittest_params;
6461 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6463 /* For GMAC we setup cipher parameters */
6464 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6465 ut_params->cipher_xform.next = NULL;
6466 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6467 ut_params->cipher_xform.cipher.op = op;
6468 ut_params->cipher_xform.cipher.key.data = cipher_key;
6469 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6471 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6472 ut_params->auth_xform.next = NULL;
6474 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6475 ut_params->auth_xform.auth.op = auth_op;
6476 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6477 ut_params->auth_xform.auth.add_auth_data_length = 0;
6478 ut_params->auth_xform.auth.key.length = 0;
6479 ut_params->auth_xform.auth.key.data = NULL;
6481 ut_params->cipher_xform.next = &ut_params->auth_xform;
6483 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6484 &ut_params->cipher_xform);
6486 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6492 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6494 struct crypto_testsuite_params *ts_params = &testsuite_params;
6495 struct crypto_unittest_params *ut_params = &unittest_params;
6499 uint8_t *auth_tag, *p;
6500 uint16_t aad_pad_len;
6502 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6503 "No GMAC length in the source data");
6505 retval = create_gmac_session(ts_params->valid_devs[0],
6506 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6507 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6512 if (tdata->aad.len > MBUF_SIZE)
6513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6515 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6516 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6517 "Failed to allocate input buffer in mempool");
6519 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6520 rte_pktmbuf_tailroom(ut_params->ibuf));
6522 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6524 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6526 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6532 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6534 ut_params->op->sym->m_src = ut_params->ibuf;
6536 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6537 ut_params->op), "failed to process sym crypto op");
6539 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6540 "crypto op processing failed");
6542 if (ut_params->op->sym->m_dst) {
6543 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6544 uint8_t *, aad_pad_len);
6546 auth_tag = p + aad_pad_len;
6549 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6551 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6553 tdata->gmac_tag.data,
6554 tdata->gmac_tag.len,
6555 "GMAC Generated auth tag not as expected");
6561 test_AES_GMAC_authentication_test_case_1(void)
6563 return test_AES_GMAC_authentication(&gmac_test_case_1);
6567 test_AES_GMAC_authentication_test_case_2(void)
6569 return test_AES_GMAC_authentication(&gmac_test_case_2);
6573 test_AES_GMAC_authentication_test_case_3(void)
6575 return test_AES_GMAC_authentication(&gmac_test_case_3);
6579 test_AES_GMAC_authentication_test_case_4(void)
6581 return test_AES_GMAC_authentication(&gmac_test_case_4);
6585 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6587 struct crypto_testsuite_params *ts_params = &testsuite_params;
6588 struct crypto_unittest_params *ut_params = &unittest_params;
6591 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6592 "No GMAC length in the source data");
6594 retval = create_gmac_session(ts_params->valid_devs[0],
6595 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6596 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6601 if (tdata->aad.len > MBUF_SIZE)
6602 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6605 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6606 "Failed to allocate input buffer in mempool");
6608 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6609 rte_pktmbuf_tailroom(ut_params->ibuf));
6611 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6617 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6619 ut_params->op->sym->m_src = ut_params->ibuf;
6621 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6622 ut_params->op), "failed to process sym crypto op");
6624 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6625 "crypto op processing failed");
6632 test_AES_GMAC_authentication_verify_test_case_1(void)
6634 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6638 test_AES_GMAC_authentication_verify_test_case_2(void)
6640 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6644 test_AES_GMAC_authentication_verify_test_case_3(void)
6646 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6650 test_AES_GMAC_authentication_verify_test_case_4(void)
6652 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6655 struct test_crypto_vector {
6656 enum rte_crypto_cipher_algorithm crypto_algo;
6669 const uint8_t *data;
6674 const uint8_t *data;
6678 enum rte_crypto_auth_algorithm auth_algo;
6686 const uint8_t *data;
6696 static const struct test_crypto_vector
6697 hmac_sha1_test_crypto_vector = {
6698 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6700 .data = plaintext_hash,
6705 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6706 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6707 0xDE, 0xF4, 0xDE, 0xAD
6713 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6714 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6715 0x3F, 0x91, 0x64, 0x59
6721 static const struct test_crypto_vector
6722 aes128_gmac_test_vector = {
6723 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6724 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6726 .data = plaintext_hash,
6731 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6732 0x08, 0x09, 0x0A, 0x0B
6738 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6739 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6745 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6746 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6752 static const struct test_crypto_vector
6753 aes128cbc_hmac_sha1_test_vector = {
6754 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6757 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6758 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6764 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6765 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6770 .data = plaintext_hash,
6774 .data = ciphertext512_aes128cbc,
6777 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6780 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6781 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6782 0xDE, 0xF4, 0xDE, 0xAD
6788 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6789 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6790 0x18, 0x8C, 0x1D, 0x32
6797 data_corruption(uint8_t *data)
6803 tag_corruption(uint8_t *data, unsigned int tag_offset)
6805 data[tag_offset] += 1;
6809 create_auth_session(struct crypto_unittest_params *ut_params,
6811 const struct test_crypto_vector *reference,
6812 enum rte_crypto_auth_operation auth_op)
6814 uint8_t auth_key[reference->auth_key.len + 1];
6816 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6818 /* Setup Authentication Parameters */
6819 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6820 ut_params->auth_xform.auth.op = auth_op;
6821 ut_params->auth_xform.next = NULL;
6822 ut_params->auth_xform.auth.algo = reference->auth_algo;
6823 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6824 ut_params->auth_xform.auth.key.data = auth_key;
6825 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6826 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6828 /* Create Crypto session*/
6829 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6830 &ut_params->auth_xform);
6832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6838 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6840 const struct test_crypto_vector *reference,
6841 enum rte_crypto_auth_operation auth_op,
6842 enum rte_crypto_cipher_operation cipher_op)
6844 uint8_t cipher_key[reference->cipher_key.len + 1];
6845 uint8_t auth_key[reference->auth_key.len + 1];
6847 memcpy(cipher_key, reference->cipher_key.data,
6848 reference->cipher_key.len);
6849 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6851 /* Setup Authentication Parameters */
6852 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6853 ut_params->auth_xform.auth.op = auth_op;
6854 ut_params->auth_xform.next = &ut_params->cipher_xform;
6855 ut_params->auth_xform.auth.algo = reference->auth_algo;
6856 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6857 ut_params->auth_xform.auth.key.data = auth_key;
6858 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6859 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6861 /* Setup Cipher Parameters */
6862 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6863 ut_params->cipher_xform.next = NULL;
6864 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6865 ut_params->cipher_xform.cipher.op = cipher_op;
6866 ut_params->cipher_xform.cipher.key.data = cipher_key;
6867 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6869 /* Create Crypto session*/
6870 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6871 &ut_params->auth_xform);
6873 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6879 create_auth_operation(struct crypto_testsuite_params *ts_params,
6880 struct crypto_unittest_params *ut_params,
6881 const struct test_crypto_vector *reference,
6882 unsigned int auth_generate)
6884 /* Generate Crypto op data structure */
6885 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6886 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6887 TEST_ASSERT_NOT_NULL(ut_params->op,
6888 "Failed to allocate pktmbuf offload");
6890 /* Set crypto operation data parameters */
6891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6893 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6895 /* set crypto operation source mbuf */
6896 sym_op->m_src = ut_params->ibuf;
6899 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6900 ut_params->ibuf, reference->digest.len);
6902 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6903 "no room to append auth tag");
6905 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6906 ut_params->ibuf, reference->plaintext.len);
6907 sym_op->auth.digest.length = reference->digest.len;
6910 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6912 memcpy(sym_op->auth.digest.data,
6913 reference->digest.data,
6914 reference->digest.len);
6916 TEST_HEXDUMP(stdout, "digest:",
6917 sym_op->auth.digest.data,
6918 sym_op->auth.digest.length);
6920 sym_op->auth.data.length = reference->plaintext.len;
6921 sym_op->auth.data.offset = 0;
6927 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6928 struct crypto_unittest_params *ut_params,
6929 const struct test_crypto_vector *reference,
6930 unsigned int auth_generate)
6932 /* Generate Crypto op data structure */
6933 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6934 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6935 TEST_ASSERT_NOT_NULL(ut_params->op,
6936 "Failed to allocate pktmbuf offload");
6938 /* Set crypto operation data parameters */
6939 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6941 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6943 /* set crypto operation source mbuf */
6944 sym_op->m_src = ut_params->ibuf;
6947 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6948 reference->aad.len);
6949 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6950 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6952 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6954 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6955 sym_op->auth.aad.length = reference->aad.len;
6958 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6959 ut_params->ibuf, reference->digest.len);
6961 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6962 "no room to append auth tag");
6964 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6965 ut_params->ibuf, reference->ciphertext.len);
6966 sym_op->auth.digest.length = reference->digest.len;
6969 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6971 memcpy(sym_op->auth.digest.data,
6972 reference->digest.data,
6973 reference->digest.len);
6975 TEST_HEXDUMP(stdout, "digest:",
6976 sym_op->auth.digest.data,
6977 sym_op->auth.digest.length);
6979 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
6980 uint8_t *, IV_OFFSET);
6981 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
6983 sym_op->cipher.iv.length = reference->iv.len;
6985 rte_memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6987 sym_op->cipher.data.length = 0;
6988 sym_op->cipher.data.offset = 0;
6990 sym_op->auth.data.length = 0;
6991 sym_op->auth.data.offset = 0;
6997 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6998 struct crypto_unittest_params *ut_params,
6999 const struct test_crypto_vector *reference,
7000 unsigned int auth_generate)
7002 /* Generate Crypto op data structure */
7003 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7004 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7005 TEST_ASSERT_NOT_NULL(ut_params->op,
7006 "Failed to allocate pktmbuf offload");
7008 /* Set crypto operation data parameters */
7009 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7011 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7013 /* set crypto operation source mbuf */
7014 sym_op->m_src = ut_params->ibuf;
7017 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7018 ut_params->ibuf, reference->digest.len);
7020 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7021 "no room to append auth tag");
7023 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7024 ut_params->ibuf, reference->ciphertext.len);
7025 sym_op->auth.digest.length = reference->digest.len;
7028 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7030 memcpy(sym_op->auth.digest.data,
7031 reference->digest.data,
7032 reference->digest.len);
7034 TEST_HEXDUMP(stdout, "digest:",
7035 sym_op->auth.digest.data,
7036 sym_op->auth.digest.length);
7038 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
7039 uint8_t *, IV_OFFSET);
7040 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
7042 sym_op->cipher.iv.length = reference->iv.len;
7044 rte_memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
7046 sym_op->cipher.data.length = reference->ciphertext.len;
7047 sym_op->cipher.data.offset = 0;
7049 sym_op->auth.data.length = reference->ciphertext.len;
7050 sym_op->auth.data.offset = 0;
7056 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7057 struct crypto_unittest_params *ut_params,
7058 const struct test_crypto_vector *reference)
7060 return create_auth_operation(ts_params, ut_params, reference, 0);
7064 create_auth_verify_GMAC_operation(
7065 struct crypto_testsuite_params *ts_params,
7066 struct crypto_unittest_params *ut_params,
7067 const struct test_crypto_vector *reference)
7069 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7073 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7074 struct crypto_unittest_params *ut_params,
7075 const struct test_crypto_vector *reference)
7077 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7081 test_authentication_verify_fail_when_data_corruption(
7082 struct crypto_testsuite_params *ts_params,
7083 struct crypto_unittest_params *ut_params,
7084 const struct test_crypto_vector *reference,
7085 unsigned int data_corrupted)
7091 /* Create session */
7092 retval = create_auth_session(ut_params,
7093 ts_params->valid_devs[0],
7095 RTE_CRYPTO_AUTH_OP_VERIFY);
7099 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7100 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7101 "Failed to allocate input buffer in mempool");
7103 /* clear mbuf payload */
7104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7105 rte_pktmbuf_tailroom(ut_params->ibuf));
7107 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7108 reference->plaintext.len);
7109 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7110 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7112 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7114 /* Create operation */
7115 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7121 data_corruption(plaintext);
7123 tag_corruption(plaintext, reference->plaintext.len);
7125 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7127 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7128 TEST_ASSERT_EQUAL(ut_params->op->status,
7129 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7130 "authentication not failed");
7132 ut_params->obuf = ut_params->op->sym->m_src;
7133 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7139 test_authentication_verify_GMAC_fail_when_corruption(
7140 struct crypto_testsuite_params *ts_params,
7141 struct crypto_unittest_params *ut_params,
7142 const struct test_crypto_vector *reference,
7143 unsigned int data_corrupted)
7147 /* Create session */
7148 retval = create_auth_cipher_session(ut_params,
7149 ts_params->valid_devs[0],
7151 RTE_CRYPTO_AUTH_OP_VERIFY,
7152 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7157 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7158 "Failed to allocate input buffer in mempool");
7160 /* clear mbuf payload */
7161 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7162 rte_pktmbuf_tailroom(ut_params->ibuf));
7164 /* Create operation */
7165 retval = create_auth_verify_GMAC_operation(ts_params,
7173 data_corruption(ut_params->op->sym->auth.aad.data);
7175 tag_corruption(ut_params->op->sym->auth.aad.data,
7176 reference->aad.len);
7178 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7181 TEST_ASSERT_EQUAL(ut_params->op->status,
7182 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7183 "authentication not failed");
7185 ut_params->obuf = ut_params->op->sym->m_src;
7186 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7192 test_authenticated_decryption_fail_when_corruption(
7193 struct crypto_testsuite_params *ts_params,
7194 struct crypto_unittest_params *ut_params,
7195 const struct test_crypto_vector *reference,
7196 unsigned int data_corrupted)
7200 uint8_t *ciphertext;
7202 /* Create session */
7203 retval = create_auth_cipher_session(ut_params,
7204 ts_params->valid_devs[0],
7206 RTE_CRYPTO_AUTH_OP_VERIFY,
7207 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7211 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7212 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7213 "Failed to allocate input buffer in mempool");
7215 /* clear mbuf payload */
7216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7217 rte_pktmbuf_tailroom(ut_params->ibuf));
7219 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7220 reference->ciphertext.len);
7221 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7222 memcpy(ciphertext, reference->ciphertext.data,
7223 reference->ciphertext.len);
7225 /* Create operation */
7226 retval = create_cipher_auth_verify_operation(ts_params,
7234 data_corruption(ciphertext);
7236 tag_corruption(ciphertext, reference->ciphertext.len);
7238 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7242 TEST_ASSERT_EQUAL(ut_params->op->status,
7243 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7244 "authentication not failed");
7246 ut_params->obuf = ut_params->op->sym->m_src;
7247 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7253 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7254 const struct gcm_test_data *tdata,
7255 void *digest_mem, uint64_t digest_phys)
7257 struct crypto_testsuite_params *ts_params = &testsuite_params;
7258 struct crypto_unittest_params *ut_params = &unittest_params;
7260 const unsigned int auth_tag_len = tdata->auth_tag.len;
7261 const unsigned int iv_len = tdata->iv.len;
7262 const unsigned int aad_len = tdata->aad.len;
7264 /* Generate Crypto op data structure */
7265 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7266 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7267 TEST_ASSERT_NOT_NULL(ut_params->op,
7268 "Failed to allocate symmetric crypto operation struct");
7270 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7272 sym_op->auth.digest.data = digest_mem;
7274 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7275 "no room to append digest");
7277 sym_op->auth.digest.phys_addr = digest_phys;
7278 sym_op->auth.digest.length = auth_tag_len;
7280 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7281 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7283 TEST_HEXDUMP(stdout, "digest:",
7284 sym_op->auth.digest.data,
7285 sym_op->auth.digest.length);
7288 sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
7289 uint8_t *, IV_OFFSET);
7290 sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
7292 sym_op->cipher.iv.length = iv_len;
7294 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_len);
7296 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7297 ut_params->ibuf, aad_len);
7298 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7299 "no room to prepend aad");
7300 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7302 sym_op->auth.aad.length = aad_len;
7304 memset(sym_op->auth.aad.data, 0, aad_len);
7305 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7307 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_len);
7308 TEST_HEXDUMP(stdout, "aad:",
7309 sym_op->auth.aad.data, aad_len);
7311 sym_op->cipher.data.length = tdata->plaintext.len;
7312 sym_op->cipher.data.offset = aad_len;
7314 sym_op->auth.data.offset = aad_len;
7315 sym_op->auth.data.length = tdata->plaintext.len;
7320 #define SGL_MAX_NO 16
7323 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7324 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7326 struct crypto_testsuite_params *ts_params = &testsuite_params;
7327 struct crypto_unittest_params *ut_params = &unittest_params;
7328 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7331 int to_trn_tbl[SGL_MAX_NO];
7333 unsigned int trn_data = 0;
7334 uint8_t *plaintext, *ciphertext, *auth_tag;
7336 if (fragsz > tdata->plaintext.len)
7337 fragsz = tdata->plaintext.len;
7339 uint16_t plaintext_len = fragsz;
7340 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7342 if (fragsz_oop > tdata->plaintext.len)
7343 frag_size_oop = tdata->plaintext.len;
7346 void *digest_mem = NULL;
7348 uint32_t prepend_len = tdata->aad.len;
7350 if (tdata->plaintext.len % fragsz != 0) {
7351 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7354 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7359 * For out-op-place we need to alloc another mbuf
7362 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7363 rte_pktmbuf_append(ut_params->obuf,
7364 frag_size_oop + prepend_len);
7365 buf_oop = ut_params->obuf;
7368 /* Create GCM session */
7369 retval = create_gcm_session(ts_params->valid_devs[0],
7370 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7371 tdata->key.data, tdata->key.len,
7372 tdata->aad.len, tdata->auth_tag.len,
7373 RTE_CRYPTO_AUTH_OP_GENERATE);
7377 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7379 /* clear mbuf payload */
7380 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7381 rte_pktmbuf_tailroom(ut_params->ibuf));
7383 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7386 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7388 trn_data += plaintext_len;
7390 buf = ut_params->ibuf;
7393 * Loop until no more fragments
7396 while (trn_data < tdata->plaintext.len) {
7398 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7399 (tdata->plaintext.len - trn_data) : fragsz;
7401 to_trn_tbl[ecx++] = to_trn;
7403 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7406 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7407 rte_pktmbuf_tailroom(buf));
7410 if (oop && !fragsz_oop) {
7411 buf_last_oop = buf_oop->next =
7412 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7413 buf_oop = buf_oop->next;
7414 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7415 0, rte_pktmbuf_tailroom(buf_oop));
7416 rte_pktmbuf_append(buf_oop, to_trn);
7419 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7422 memcpy(plaintext, tdata->plaintext.data + trn_data,
7425 if (trn_data == tdata->plaintext.len) {
7428 digest_mem = rte_pktmbuf_append(buf_oop,
7429 tdata->auth_tag.len);
7431 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7432 tdata->auth_tag.len);
7436 uint64_t digest_phys = 0;
7438 ut_params->ibuf->nb_segs = segs;
7441 if (fragsz_oop && oop) {
7445 if (frag_size_oop == tdata->plaintext.len) {
7446 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7447 tdata->auth_tag.len);
7449 digest_phys = rte_pktmbuf_mtophys_offset(
7451 tdata->plaintext.len + prepend_len);
7454 trn_data = frag_size_oop;
7455 while (trn_data < tdata->plaintext.len) {
7458 (tdata->plaintext.len - trn_data <
7460 (tdata->plaintext.len - trn_data) :
7463 to_trn_tbl[ecx++] = to_trn;
7465 buf_last_oop = buf_oop->next =
7466 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7467 buf_oop = buf_oop->next;
7468 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7469 0, rte_pktmbuf_tailroom(buf_oop));
7470 rte_pktmbuf_append(buf_oop, to_trn);
7474 if (trn_data == tdata->plaintext.len) {
7475 digest_mem = rte_pktmbuf_append(buf_oop,
7476 tdata->auth_tag.len);
7480 ut_params->obuf->nb_segs = segs;
7484 * Place digest at the end of the last buffer
7487 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7488 if (oop && buf_last_oop)
7489 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7491 if (!digest_mem && !oop) {
7492 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7493 + tdata->auth_tag.len);
7494 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7495 tdata->plaintext.len);
7498 /* Create GCM opertaion */
7499 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7500 tdata, digest_mem, digest_phys);
7505 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7507 ut_params->op->sym->m_src = ut_params->ibuf;
7509 ut_params->op->sym->m_dst = ut_params->obuf;
7511 /* Process crypto operation */
7512 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7513 ut_params->op), "failed to process sym crypto op");
7515 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7516 "crypto op processing failed");
7519 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7520 uint8_t *, prepend_len);
7522 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7523 uint8_t *, prepend_len);
7527 fragsz = fragsz_oop;
7529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7531 tdata->ciphertext.data,
7533 "GCM Ciphertext data not as expected");
7535 buf = ut_params->op->sym->m_src->next;
7537 buf = ut_params->op->sym->m_dst->next;
7539 unsigned int off = fragsz;
7543 ciphertext = rte_pktmbuf_mtod(buf,
7546 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7548 tdata->ciphertext.data + off,
7550 "GCM Ciphertext data not as expected");
7552 off += to_trn_tbl[ecx++];
7556 auth_tag = digest_mem;
7557 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7559 tdata->auth_tag.data,
7560 tdata->auth_tag.len,
7561 "GCM Generated auth tag not as expected");
7567 #define OUT_OF_PLACE 1
7570 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7572 return test_AES_GCM_authenticated_encryption_SGL(
7573 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7577 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7579 return test_AES_GCM_authenticated_encryption_SGL(
7580 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7584 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7586 return test_AES_GCM_authenticated_encryption_SGL(
7587 &gcm_test_case_8, OUT_OF_PLACE, 400,
7588 gcm_test_case_8.plaintext.len);
7592 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7595 return test_AES_GCM_authenticated_encryption_SGL(
7596 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7600 test_authentication_verify_fail_when_data_corrupted(
7601 struct crypto_testsuite_params *ts_params,
7602 struct crypto_unittest_params *ut_params,
7603 const struct test_crypto_vector *reference)
7605 return test_authentication_verify_fail_when_data_corruption(
7606 ts_params, ut_params, reference, 1);
7610 test_authentication_verify_fail_when_tag_corrupted(
7611 struct crypto_testsuite_params *ts_params,
7612 struct crypto_unittest_params *ut_params,
7613 const struct test_crypto_vector *reference)
7615 return test_authentication_verify_fail_when_data_corruption(
7616 ts_params, ut_params, reference, 0);
7620 test_authentication_verify_GMAC_fail_when_data_corrupted(
7621 struct crypto_testsuite_params *ts_params,
7622 struct crypto_unittest_params *ut_params,
7623 const struct test_crypto_vector *reference)
7625 return test_authentication_verify_GMAC_fail_when_corruption(
7626 ts_params, ut_params, reference, 1);
7630 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7631 struct crypto_testsuite_params *ts_params,
7632 struct crypto_unittest_params *ut_params,
7633 const struct test_crypto_vector *reference)
7635 return test_authentication_verify_GMAC_fail_when_corruption(
7636 ts_params, ut_params, reference, 0);
7640 test_authenticated_decryption_fail_when_data_corrupted(
7641 struct crypto_testsuite_params *ts_params,
7642 struct crypto_unittest_params *ut_params,
7643 const struct test_crypto_vector *reference)
7645 return test_authenticated_decryption_fail_when_corruption(
7646 ts_params, ut_params, reference, 1);
7650 test_authenticated_decryption_fail_when_tag_corrupted(
7651 struct crypto_testsuite_params *ts_params,
7652 struct crypto_unittest_params *ut_params,
7653 const struct test_crypto_vector *reference)
7655 return test_authenticated_decryption_fail_when_corruption(
7656 ts_params, ut_params, reference, 0);
7660 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7662 return test_authentication_verify_fail_when_data_corrupted(
7663 &testsuite_params, &unittest_params,
7664 &hmac_sha1_test_crypto_vector);
7668 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7670 return test_authentication_verify_fail_when_tag_corrupted(
7671 &testsuite_params, &unittest_params,
7672 &hmac_sha1_test_crypto_vector);
7676 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7678 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7679 &testsuite_params, &unittest_params,
7680 &aes128_gmac_test_vector);
7684 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7686 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7687 &testsuite_params, &unittest_params,
7688 &aes128_gmac_test_vector);
7692 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7694 return test_authenticated_decryption_fail_when_data_corrupted(
7697 &aes128cbc_hmac_sha1_test_vector);
7701 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7703 return test_authenticated_decryption_fail_when_tag_corrupted(
7706 &aes128cbc_hmac_sha1_test_vector);
7709 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7711 /* global AESNI slave IDs for the scheduler test */
7712 uint8_t aesni_ids[2];
7715 test_scheduler_attach_slave_op(void)
7717 struct crypto_testsuite_params *ts_params = &testsuite_params;
7718 uint8_t sched_id = ts_params->valid_devs[0];
7719 uint32_t nb_devs, i, nb_devs_attached = 0;
7723 /* create 2 AESNI_MB if necessary */
7724 nb_devs = rte_cryptodev_count_devtype(
7725 RTE_CRYPTODEV_AESNI_MB_PMD);
7727 for (i = nb_devs; i < 2; i++) {
7728 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7729 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7731 ret = rte_vdev_init(vdev_name, NULL);
7733 TEST_ASSERT(ret == 0,
7734 "Failed to create instance %u of"
7736 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7740 /* attach 2 AESNI_MB cdevs */
7741 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7743 struct rte_cryptodev_info info;
7745 rte_cryptodev_info_get(i, &info);
7746 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7749 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7752 TEST_ASSERT(ret == 0,
7753 "Failed to attach device %u of pmd : %s", i,
7754 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7756 aesni_ids[nb_devs_attached] = (uint8_t)i;
7765 test_scheduler_detach_slave_op(void)
7767 struct crypto_testsuite_params *ts_params = &testsuite_params;
7768 uint8_t sched_id = ts_params->valid_devs[0];
7772 for (i = 0; i < 2; i++) {
7773 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7775 TEST_ASSERT(ret == 0,
7776 "Failed to detach device %u", aesni_ids[i]);
7783 test_scheduler_mode_op(void)
7785 struct crypto_testsuite_params *ts_params = &testsuite_params;
7786 uint8_t sched_id = ts_params->valid_devs[0];
7787 struct rte_cryptodev_scheduler_ops op = {0};
7788 struct rte_cryptodev_scheduler dummy_scheduler = {
7789 .description = "dummy scheduler to test mode",
7790 .name = "dummy scheduler",
7791 .mode = CDEV_SCHED_MODE_USERDEFINED,
7796 /* set user defined mode */
7797 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7799 TEST_ASSERT(ret == 0,
7800 "Failed to set cdev %u to user defined mode", sched_id);
7802 /* set round robin mode */
7803 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7804 CDEV_SCHED_MODE_ROUNDROBIN);
7805 TEST_ASSERT(ret == 0,
7806 "Failed to set cdev %u to round-robin mode", sched_id);
7807 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7808 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7814 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7815 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7816 .setup = testsuite_setup,
7817 .teardown = testsuite_teardown,
7818 .unit_test_cases = {
7819 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7820 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_AES_chain_scheduler_all),
7823 TEST_CASE_ST(ut_setup, ut_teardown,
7824 test_AES_cipheronly_scheduler_all),
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_authonly_scheduler_all),
7827 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7828 TEST_CASES_END() /**< NULL terminate unit test array */
7832 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7834 static struct unit_test_suite cryptodev_qat_testsuite = {
7835 .suite_name = "Crypto QAT Unit Test Suite",
7836 .setup = testsuite_setup,
7837 .teardown = testsuite_teardown,
7838 .unit_test_cases = {
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_device_configure_invalid_dev_id),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_device_configure_invalid_queue_pair_ids),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_queue_pair_descriptor_setup),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_multi_session),
7848 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_AES_cipheronly_qat_all),
7851 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_3DES_cipheronly_qat_all),
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_DES_cipheronly_qat_all),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_AES_docsis_qat_all),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_DES_docsis_qat_all),
7860 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7862 /** AES GCM Authenticated Encryption */
7863 TEST_CASE_ST(ut_setup, ut_teardown,
7864 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7884 /** AES GCM Authenticated Decryption */
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7887 TEST_CASE_ST(ut_setup, ut_teardown,
7888 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7900 /** AES GMAC Authentication */
7901 TEST_CASE_ST(ut_setup, ut_teardown,
7902 test_AES_GMAC_authentication_test_case_1),
7903 TEST_CASE_ST(ut_setup, ut_teardown,
7904 test_AES_GMAC_authentication_verify_test_case_1),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_AES_GMAC_authentication_test_case_2),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 test_AES_GMAC_authentication_verify_test_case_2),
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_AES_GMAC_authentication_test_case_3),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_AES_GMAC_authentication_verify_test_case_3),
7914 /** SNOW 3G encrypt only (UEA2) */
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_snow3g_encryption_test_case_1),
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_snow3g_encryption_test_case_2),
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_snow3g_encryption_test_case_3),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_snow3g_encryption_test_case_4),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_snow3g_encryption_test_case_5),
7926 TEST_CASE_ST(ut_setup, ut_teardown,
7927 test_snow3g_encryption_test_case_1_oop),
7928 TEST_CASE_ST(ut_setup, ut_teardown,
7929 test_snow3g_decryption_test_case_1_oop),
7931 /** SNOW 3G decrypt only (UEA2) */
7932 TEST_CASE_ST(ut_setup, ut_teardown,
7933 test_snow3g_decryption_test_case_1),
7934 TEST_CASE_ST(ut_setup, ut_teardown,
7935 test_snow3g_decryption_test_case_2),
7936 TEST_CASE_ST(ut_setup, ut_teardown,
7937 test_snow3g_decryption_test_case_3),
7938 TEST_CASE_ST(ut_setup, ut_teardown,
7939 test_snow3g_decryption_test_case_4),
7940 TEST_CASE_ST(ut_setup, ut_teardown,
7941 test_snow3g_decryption_test_case_5),
7942 TEST_CASE_ST(ut_setup, ut_teardown,
7943 test_snow3g_hash_generate_test_case_1),
7944 TEST_CASE_ST(ut_setup, ut_teardown,
7945 test_snow3g_hash_generate_test_case_2),
7946 TEST_CASE_ST(ut_setup, ut_teardown,
7947 test_snow3g_hash_generate_test_case_3),
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_snow3g_hash_verify_test_case_1),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_snow3g_hash_verify_test_case_2),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_snow3g_hash_verify_test_case_3),
7954 TEST_CASE_ST(ut_setup, ut_teardown,
7955 test_snow3g_cipher_auth_test_case_1),
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_snow3g_auth_cipher_test_case_1),
7959 /** ZUC encrypt only (EEA3) */
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_zuc_encryption_test_case_1),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_zuc_encryption_test_case_2),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_zuc_encryption_test_case_3),
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_zuc_encryption_test_case_4),
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_zuc_encryption_test_case_5),
7971 /** ZUC authenticate (EIA3) */
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_zuc_hash_generate_test_case_6),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_zuc_hash_generate_test_case_7),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_zuc_hash_generate_test_case_8),
7979 /** ZUC alg-chain (EEA3/EIA3) */
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_zuc_cipher_auth_test_case_1),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_zuc_cipher_auth_test_case_2),
7985 /** HMAC_MD5 Authentication */
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 test_MD5_HMAC_generate_case_1),
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 test_MD5_HMAC_verify_case_1),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_MD5_HMAC_generate_case_2),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_MD5_HMAC_verify_case_2),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_null_auth_only_operation),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_null_cipher_only_operation),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_null_cipher_auth_operation),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_null_auth_cipher_operation),
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 test_kasumi_hash_generate_test_case_6),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_kasumi_encryption_test_case_1),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 test_kasumi_encryption_test_case_3),
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 test_kasumi_auth_cipher_test_case_1),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_kasumi_cipher_auth_test_case_1),
8018 /** Negative tests */
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8021 TEST_CASE_ST(ut_setup, ut_teardown,
8022 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8023 TEST_CASE_ST(ut_setup, ut_teardown,
8024 authentication_verify_AES128_GMAC_fail_data_corrupt),
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8029 TEST_CASE_ST(ut_setup, ut_teardown,
8030 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8032 TEST_CASES_END() /**< NULL terminate unit test array */
8036 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8037 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8038 .setup = testsuite_setup,
8039 .teardown = testsuite_teardown,
8040 .unit_test_cases = {
8041 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8042 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8043 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8044 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8046 TEST_CASES_END() /**< NULL terminate unit test array */
8050 static struct unit_test_suite cryptodev_openssl_testsuite = {
8051 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8052 .setup = testsuite_setup,
8053 .teardown = testsuite_teardown,
8054 .unit_test_cases = {
8055 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_multi_session_random_usage),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_AES_chain_openssl_all),
8060 TEST_CASE_ST(ut_setup, ut_teardown,
8061 test_AES_cipheronly_openssl_all),
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_3DES_chain_openssl_all),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_3DES_cipheronly_openssl_all),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_DES_docsis_openssl_all),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_authonly_openssl_all),
8071 /** AES GCM Authenticated Encryption */
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8087 /** AES GCM Authenticated Decryption */
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8103 /** AES GMAC Authentication */
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_AES_GMAC_authentication_test_case_1),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_AES_GMAC_authentication_verify_test_case_1),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_AES_GMAC_authentication_test_case_2),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_AES_GMAC_authentication_verify_test_case_2),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_AES_GMAC_authentication_test_case_3),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_AES_GMAC_authentication_verify_test_case_3),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_AES_GMAC_authentication_test_case_4),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_AES_GMAC_authentication_verify_test_case_4),
8121 /** Scatter-Gather */
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8125 /** Negative tests */
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 authentication_verify_AES128_GMAC_fail_data_corrupt),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8139 TEST_CASES_END() /**< NULL terminate unit test array */
8143 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8144 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8145 .setup = testsuite_setup,
8146 .teardown = testsuite_teardown,
8147 .unit_test_cases = {
8148 /** AES GCM Authenticated Encryption */
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8155 TEST_CASE_ST(ut_setup, ut_teardown,
8156 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8161 TEST_CASE_ST(ut_setup, ut_teardown,
8162 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8164 /** AES GCM Authenticated Decryption */
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8180 /** AES GCM Authenticated Encryption 256 bits key */
8181 TEST_CASE_ST(ut_setup, ut_teardown,
8182 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8196 /** AES GCM Authenticated Decryption 256 bits key */
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8212 /** AES GCM Authenticated Encryption big aad size */
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8218 /** AES GCM Authenticated Decryption big aad size */
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8224 /** AES GMAC Authentication */
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_AES_GMAC_authentication_test_case_1),
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_AES_GMAC_authentication_verify_test_case_1),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_AES_GMAC_authentication_test_case_3),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_AES_GMAC_authentication_verify_test_case_3),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_AES_GMAC_authentication_test_case_4),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_AES_GMAC_authentication_verify_test_case_4),
8238 /** Negative tests */
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 authentication_verify_AES128_GMAC_fail_data_corrupt),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8244 /** Out of place tests */
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_mb_AES_GCM_authenticated_encryption_oop),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_mb_AES_GCM_authenticated_decryption_oop),
8250 /** Session-less tests */
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_mb_AES_GCM_authenticated_encryption_sessionless),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_mb_AES_GCM_authenticated_decryption_sessionless),
8256 /** Scatter-Gather */
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8260 TEST_CASES_END() /**< NULL terminate unit test array */
8264 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8265 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8266 .setup = testsuite_setup,
8267 .teardown = testsuite_teardown,
8268 .unit_test_cases = {
8269 /** KASUMI encrypt only (UEA1) */
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_kasumi_encryption_test_case_1),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_kasumi_encryption_test_case_1_sgl),
8274 TEST_CASE_ST(ut_setup, ut_teardown,
8275 test_kasumi_encryption_test_case_2),
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_kasumi_encryption_test_case_3),
8278 TEST_CASE_ST(ut_setup, ut_teardown,
8279 test_kasumi_encryption_test_case_4),
8280 TEST_CASE_ST(ut_setup, ut_teardown,
8281 test_kasumi_encryption_test_case_5),
8282 /** KASUMI decrypt only (UEA1) */
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_kasumi_decryption_test_case_1),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_kasumi_decryption_test_case_2),
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 test_kasumi_decryption_test_case_3),
8289 TEST_CASE_ST(ut_setup, ut_teardown,
8290 test_kasumi_decryption_test_case_4),
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_kasumi_decryption_test_case_5),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_kasumi_encryption_test_case_1_oop),
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_kasumi_encryption_test_case_1_oop_sgl),
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_kasumi_decryption_test_case_1_oop),
8303 /** KASUMI hash only (UIA1) */
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_kasumi_hash_generate_test_case_1),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_kasumi_hash_generate_test_case_2),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_kasumi_hash_generate_test_case_3),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_kasumi_hash_generate_test_case_4),
8312 TEST_CASE_ST(ut_setup, ut_teardown,
8313 test_kasumi_hash_generate_test_case_5),
8314 TEST_CASE_ST(ut_setup, ut_teardown,
8315 test_kasumi_hash_generate_test_case_6),
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_kasumi_hash_verify_test_case_1),
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_kasumi_hash_verify_test_case_2),
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_kasumi_hash_verify_test_case_3),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_kasumi_hash_verify_test_case_4),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_kasumi_hash_verify_test_case_5),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_kasumi_auth_cipher_test_case_1),
8328 TEST_CASE_ST(ut_setup, ut_teardown,
8329 test_kasumi_cipher_auth_test_case_1),
8330 TEST_CASES_END() /**< NULL terminate unit test array */
8333 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8334 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8335 .setup = testsuite_setup,
8336 .teardown = testsuite_teardown,
8337 .unit_test_cases = {
8338 /** SNOW 3G encrypt only (UEA2) */
8339 TEST_CASE_ST(ut_setup, ut_teardown,
8340 test_snow3g_encryption_test_case_1),
8341 TEST_CASE_ST(ut_setup, ut_teardown,
8342 test_snow3g_encryption_test_case_2),
8343 TEST_CASE_ST(ut_setup, ut_teardown,
8344 test_snow3g_encryption_test_case_3),
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 test_snow3g_encryption_test_case_4),
8347 TEST_CASE_ST(ut_setup, ut_teardown,
8348 test_snow3g_encryption_test_case_5),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_snow3g_encryption_test_case_1_oop),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_snow3g_encryption_test_case_1_oop_sgl),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_snow3g_decryption_test_case_1_oop),
8357 TEST_CASE_ST(ut_setup, ut_teardown,
8358 test_snow3g_encryption_test_case_1_offset_oop),
8360 /** SNOW 3G decrypt only (UEA2) */
8361 TEST_CASE_ST(ut_setup, ut_teardown,
8362 test_snow3g_decryption_test_case_1),
8363 TEST_CASE_ST(ut_setup, ut_teardown,
8364 test_snow3g_decryption_test_case_2),
8365 TEST_CASE_ST(ut_setup, ut_teardown,
8366 test_snow3g_decryption_test_case_3),
8367 TEST_CASE_ST(ut_setup, ut_teardown,
8368 test_snow3g_decryption_test_case_4),
8369 TEST_CASE_ST(ut_setup, ut_teardown,
8370 test_snow3g_decryption_test_case_5),
8371 TEST_CASE_ST(ut_setup, ut_teardown,
8372 test_snow3g_hash_generate_test_case_1),
8373 TEST_CASE_ST(ut_setup, ut_teardown,
8374 test_snow3g_hash_generate_test_case_2),
8375 TEST_CASE_ST(ut_setup, ut_teardown,
8376 test_snow3g_hash_generate_test_case_3),
8377 /* Tests with buffers which length is not byte-aligned */
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_snow3g_hash_generate_test_case_4),
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 test_snow3g_hash_generate_test_case_5),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 test_snow3g_hash_generate_test_case_6),
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 test_snow3g_hash_verify_test_case_1),
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 test_snow3g_hash_verify_test_case_2),
8388 TEST_CASE_ST(ut_setup, ut_teardown,
8389 test_snow3g_hash_verify_test_case_3),
8390 /* Tests with buffers which length is not byte-aligned */
8391 TEST_CASE_ST(ut_setup, ut_teardown,
8392 test_snow3g_hash_verify_test_case_4),
8393 TEST_CASE_ST(ut_setup, ut_teardown,
8394 test_snow3g_hash_verify_test_case_5),
8395 TEST_CASE_ST(ut_setup, ut_teardown,
8396 test_snow3g_hash_verify_test_case_6),
8397 TEST_CASE_ST(ut_setup, ut_teardown,
8398 test_snow3g_cipher_auth_test_case_1),
8399 TEST_CASE_ST(ut_setup, ut_teardown,
8400 test_snow3g_auth_cipher_test_case_1),
8402 TEST_CASES_END() /**< NULL terminate unit test array */
8406 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8407 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8408 .setup = testsuite_setup,
8409 .teardown = testsuite_teardown,
8410 .unit_test_cases = {
8411 /** ZUC encrypt only (EEA3) */
8412 TEST_CASE_ST(ut_setup, ut_teardown,
8413 test_zuc_encryption_test_case_1),
8414 TEST_CASE_ST(ut_setup, ut_teardown,
8415 test_zuc_encryption_test_case_2),
8416 TEST_CASE_ST(ut_setup, ut_teardown,
8417 test_zuc_encryption_test_case_3),
8418 TEST_CASE_ST(ut_setup, ut_teardown,
8419 test_zuc_encryption_test_case_4),
8420 TEST_CASE_ST(ut_setup, ut_teardown,
8421 test_zuc_encryption_test_case_5),
8422 TEST_CASE_ST(ut_setup, ut_teardown,
8423 test_zuc_hash_generate_test_case_1),
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_zuc_hash_generate_test_case_2),
8426 TEST_CASE_ST(ut_setup, ut_teardown,
8427 test_zuc_hash_generate_test_case_3),
8428 TEST_CASE_ST(ut_setup, ut_teardown,
8429 test_zuc_hash_generate_test_case_4),
8430 TEST_CASE_ST(ut_setup, ut_teardown,
8431 test_zuc_hash_generate_test_case_5),
8432 TEST_CASE_ST(ut_setup, ut_teardown,
8433 test_zuc_encryption_test_case_6_sgl),
8434 TEST_CASES_END() /**< NULL terminate unit test array */
8438 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8439 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8440 .setup = testsuite_setup,
8441 .teardown = testsuite_teardown,
8442 .unit_test_cases = {
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_device_configure_invalid_dev_id),
8445 TEST_CASE_ST(ut_setup, ut_teardown,
8446 test_multi_session),
8448 TEST_CASE_ST(ut_setup, ut_teardown,
8449 test_AES_chain_dpaa2_sec_all),
8450 TEST_CASE_ST(ut_setup, ut_teardown,
8451 test_3DES_chain_dpaa2_sec_all),
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_AES_cipheronly_dpaa2_sec_all),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_3DES_cipheronly_dpaa2_sec_all),
8457 /** HMAC_MD5 Authentication */
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_MD5_HMAC_generate_case_1),
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_MD5_HMAC_verify_case_1),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_MD5_HMAC_generate_case_2),
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_MD5_HMAC_verify_case_2),
8467 TEST_CASES_END() /**< NULL terminate unit test array */
8471 static struct unit_test_suite cryptodev_null_testsuite = {
8472 .suite_name = "Crypto Device NULL Unit Test Suite",
8473 .setup = testsuite_setup,
8474 .teardown = testsuite_teardown,
8475 .unit_test_cases = {
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_null_auth_only_operation),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_null_cipher_only_operation),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_null_cipher_auth_operation),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_null_auth_cipher_operation),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_null_invalid_operation),
8486 TEST_CASE_ST(ut_setup, ut_teardown,
8487 test_null_burst_operation),
8489 TEST_CASES_END() /**< NULL terminate unit test array */
8493 static struct unit_test_suite cryptodev_armv8_testsuite = {
8494 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8495 .setup = testsuite_setup,
8496 .teardown = testsuite_teardown,
8497 .unit_test_cases = {
8498 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8500 /** Negative tests */
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8506 TEST_CASES_END() /**< NULL terminate unit test array */
8511 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8513 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8514 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8518 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8520 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8522 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8526 test_cryptodev_openssl(void)
8528 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8530 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8534 test_cryptodev_aesni_gcm(void)
8536 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8538 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8542 test_cryptodev_null(void)
8544 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8546 return unit_test_suite_runner(&cryptodev_null_testsuite);
8550 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8552 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8554 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8558 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8560 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8562 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8566 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8568 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8570 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8574 test_cryptodev_armv8(void)
8576 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8578 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8581 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8584 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8586 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8587 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8590 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8595 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8597 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8598 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8601 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8602 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8603 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8604 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8605 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8606 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8607 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8608 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8609 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8610 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);