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;
1274 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1275 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1277 /* Setup HMAC Parameters */
1278 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1280 ut_params->auth_xform.next = NULL;
1282 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1283 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1284 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1285 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1286 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1288 /* Create crypto session*/
1289 ut_params->sess = rte_cryptodev_sym_session_create(
1290 ts_params->valid_devs[0],
1291 &ut_params->cipher_xform);
1292 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1294 /* Generate crypto op data structure */
1295 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1296 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1297 TEST_ASSERT_NOT_NULL(ut_params->op,
1298 "Failed to allocate symmetric crypto operation struct");
1300 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1302 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1304 /* set crypto operation source mbuf */
1305 sym_op->m_src = ut_params->ibuf;
1307 /* Set crypto operation authentication parameters */
1308 sym_op->auth.digest.data = ut_params->digest;
1309 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1310 ut_params->ibuf, QUOTE_512_BYTES);
1311 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1345 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1346 DIGEST_BYTE_LENGTH_SHA1,
1347 "Generated digest data not as expected");
1349 return TEST_SUCCESS;
1352 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1354 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1356 static uint8_t hmac_sha512_key[] = {
1357 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1358 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1359 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1360 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1361 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1362 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1363 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1364 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1366 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1367 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1368 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1369 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1370 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1371 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1372 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1373 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1374 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1379 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1380 struct crypto_unittest_params *ut_params,
1381 uint8_t *cipher_key,
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1395 struct crypto_unittest_params *ut_params,
1396 uint8_t *cipher_key,
1400 /* Setup Cipher Parameters */
1401 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1402 ut_params->cipher_xform.next = NULL;
1404 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1405 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1406 ut_params->cipher_xform.cipher.key.data = cipher_key;
1407 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1409 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_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 /* Copy IV at the end of the crypto operation */
1469 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1470 iv, CIPHER_IV_LENGTH_AES_CBC);
1472 sym_op->cipher.data.offset = 0;
1473 sym_op->cipher.data.length = QUOTE_512_BYTES;
1475 /* Process crypto operation */
1476 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1477 ut_params->op), "failed to process sym crypto op");
1479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1480 "crypto op processing failed");
1482 ut_params->obuf = ut_params->op->sym->m_src;
1485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1486 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1489 "Plaintext data not as expected");
1492 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1493 "Digest verification failed");
1495 return TEST_SUCCESS;
1499 test_AES_cipheronly_mb_all(void)
1501 struct crypto_testsuite_params *ts_params = &testsuite_params;
1504 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1505 ts_params->op_mpool, ts_params->valid_devs[0],
1506 RTE_CRYPTODEV_AESNI_MB_PMD,
1507 BLKCIPHER_AES_CIPHERONLY_TYPE);
1509 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1511 return TEST_SUCCESS;
1515 test_AES_docsis_mb_all(void)
1517 struct crypto_testsuite_params *ts_params = &testsuite_params;
1520 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1521 ts_params->op_mpool, ts_params->valid_devs[0],
1522 RTE_CRYPTODEV_AESNI_MB_PMD,
1523 BLKCIPHER_AES_DOCSIS_TYPE);
1525 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1527 return TEST_SUCCESS;
1531 test_AES_docsis_qat_all(void)
1533 struct crypto_testsuite_params *ts_params = &testsuite_params;
1536 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1537 ts_params->op_mpool, ts_params->valid_devs[0],
1538 RTE_CRYPTODEV_QAT_SYM_PMD,
1539 BLKCIPHER_AES_DOCSIS_TYPE);
1541 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1543 return TEST_SUCCESS;
1547 test_DES_docsis_qat_all(void)
1549 struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1553 ts_params->op_mpool, ts_params->valid_devs[0],
1554 RTE_CRYPTODEV_QAT_SYM_PMD,
1555 BLKCIPHER_DES_DOCSIS_TYPE);
1557 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1559 return TEST_SUCCESS;
1563 test_authonly_mb_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool, ts_params->valid_devs[0],
1570 RTE_CRYPTODEV_AESNI_MB_PMD,
1571 BLKCIPHER_AUTHONLY_TYPE);
1573 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1575 return TEST_SUCCESS;
1579 test_AES_chain_mb_all(void)
1581 struct crypto_testsuite_params *ts_params = &testsuite_params;
1584 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1585 ts_params->op_mpool, ts_params->valid_devs[0],
1586 RTE_CRYPTODEV_AESNI_MB_PMD,
1587 BLKCIPHER_AES_CHAIN_TYPE);
1589 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1591 return TEST_SUCCESS;
1594 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1597 test_AES_cipheronly_scheduler_all(void)
1599 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1603 ts_params->op_mpool, ts_params->valid_devs[0],
1604 RTE_CRYPTODEV_SCHEDULER_PMD,
1605 BLKCIPHER_AES_CIPHERONLY_TYPE);
1607 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1609 return TEST_SUCCESS;
1613 test_AES_chain_scheduler_all(void)
1615 struct crypto_testsuite_params *ts_params = &testsuite_params;
1618 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1619 ts_params->op_mpool, ts_params->valid_devs[0],
1620 RTE_CRYPTODEV_SCHEDULER_PMD,
1621 BLKCIPHER_AES_CHAIN_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1629 test_authonly_scheduler_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool, ts_params->valid_devs[0],
1636 RTE_CRYPTODEV_SCHEDULER_PMD,
1637 BLKCIPHER_AUTHONLY_TYPE);
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1644 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1647 test_AES_chain_openssl_all(void)
1649 struct crypto_testsuite_params *ts_params = &testsuite_params;
1652 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1653 ts_params->op_mpool, ts_params->valid_devs[0],
1654 RTE_CRYPTODEV_OPENSSL_PMD,
1655 BLKCIPHER_AES_CHAIN_TYPE);
1657 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1659 return TEST_SUCCESS;
1663 test_AES_cipheronly_openssl_all(void)
1665 struct crypto_testsuite_params *ts_params = &testsuite_params;
1668 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1669 ts_params->op_mpool, ts_params->valid_devs[0],
1670 RTE_CRYPTODEV_OPENSSL_PMD,
1671 BLKCIPHER_AES_CIPHERONLY_TYPE);
1673 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1675 return TEST_SUCCESS;
1679 test_AES_chain_qat_all(void)
1681 struct crypto_testsuite_params *ts_params = &testsuite_params;
1684 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1685 ts_params->op_mpool, ts_params->valid_devs[0],
1686 RTE_CRYPTODEV_QAT_SYM_PMD,
1687 BLKCIPHER_AES_CHAIN_TYPE);
1689 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1691 return TEST_SUCCESS;
1695 test_AES_cipheronly_qat_all(void)
1697 struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1701 ts_params->op_mpool, ts_params->valid_devs[0],
1702 RTE_CRYPTODEV_QAT_SYM_PMD,
1703 BLKCIPHER_AES_CIPHERONLY_TYPE);
1705 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1707 return TEST_SUCCESS;
1711 test_AES_chain_dpaa2_sec_all(void)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1717 ts_params->op_mpool, ts_params->valid_devs[0],
1718 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1719 BLKCIPHER_AES_CHAIN_TYPE);
1721 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1723 return TEST_SUCCESS;
1727 test_AES_cipheronly_dpaa2_sec_all(void)
1729 struct crypto_testsuite_params *ts_params = &testsuite_params;
1732 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1733 ts_params->op_mpool, ts_params->valid_devs[0],
1734 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1735 BLKCIPHER_AES_CIPHERONLY_TYPE);
1737 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1739 return TEST_SUCCESS;
1743 test_authonly_openssl_all(void)
1745 struct crypto_testsuite_params *ts_params = &testsuite_params;
1748 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1749 ts_params->op_mpool, ts_params->valid_devs[0],
1750 RTE_CRYPTODEV_OPENSSL_PMD,
1751 BLKCIPHER_AUTHONLY_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1759 test_AES_chain_armv8_all(void)
1761 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1765 ts_params->op_mpool, ts_params->valid_devs[0],
1766 RTE_CRYPTODEV_ARMV8_PMD,
1767 BLKCIPHER_AES_CHAIN_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1774 /* ***** SNOW 3G Tests ***** */
1776 create_wireless_algo_hash_session(uint8_t dev_id,
1777 const uint8_t *key, const uint8_t key_len,
1778 const uint8_t iv_len, const uint8_t auth_len,
1779 enum rte_crypto_auth_operation op,
1780 enum rte_crypto_auth_algorithm algo)
1782 uint8_t hash_key[key_len];
1784 struct crypto_unittest_params *ut_params = &unittest_params;
1786 memcpy(hash_key, key, key_len);
1788 TEST_HEXDUMP(stdout, "key:", key, key_len);
1790 /* Setup Authentication Parameters */
1791 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1792 ut_params->auth_xform.next = NULL;
1794 ut_params->auth_xform.auth.op = op;
1795 ut_params->auth_xform.auth.algo = algo;
1796 ut_params->auth_xform.auth.key.length = key_len;
1797 ut_params->auth_xform.auth.key.data = hash_key;
1798 ut_params->auth_xform.auth.digest_length = auth_len;
1799 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1800 ut_params->auth_xform.auth.iv.length = iv_len;
1801 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1802 &ut_params->auth_xform);
1803 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1808 create_wireless_algo_cipher_session(uint8_t dev_id,
1809 enum rte_crypto_cipher_operation op,
1810 enum rte_crypto_cipher_algorithm algo,
1811 const uint8_t *key, const uint8_t key_len,
1814 uint8_t cipher_key[key_len];
1816 struct crypto_unittest_params *ut_params = &unittest_params;
1818 memcpy(cipher_key, key, key_len);
1820 /* Setup Cipher Parameters */
1821 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1822 ut_params->cipher_xform.next = NULL;
1824 ut_params->cipher_xform.cipher.algo = algo;
1825 ut_params->cipher_xform.cipher.op = op;
1826 ut_params->cipher_xform.cipher.key.data = cipher_key;
1827 ut_params->cipher_xform.cipher.key.length = key_len;
1828 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1829 ut_params->cipher_xform.cipher.iv.length = iv_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 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1866 sym_op->cipher.data.length = cipher_len;
1867 sym_op->cipher.data.offset = cipher_offset;
1872 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1873 unsigned int cipher_len,
1874 unsigned int cipher_offset)
1876 struct crypto_testsuite_params *ts_params = &testsuite_params;
1877 struct crypto_unittest_params *ut_params = &unittest_params;
1879 /* Generate Crypto op data structure */
1880 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1881 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1882 TEST_ASSERT_NOT_NULL(ut_params->op,
1883 "Failed to allocate pktmbuf offload");
1885 /* Set crypto operation data parameters */
1886 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1888 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1890 /* set crypto operation source mbuf */
1891 sym_op->m_src = ut_params->ibuf;
1892 sym_op->m_dst = ut_params->obuf;
1895 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1897 sym_op->cipher.data.length = cipher_len;
1898 sym_op->cipher.data.offset = cipher_offset;
1903 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1904 enum rte_crypto_cipher_operation cipher_op,
1905 enum rte_crypto_auth_operation auth_op,
1906 enum rte_crypto_auth_algorithm auth_algo,
1907 enum rte_crypto_cipher_algorithm cipher_algo,
1908 const uint8_t *key, uint8_t key_len,
1909 uint8_t auth_iv_len, uint8_t auth_len,
1910 uint8_t cipher_iv_len)
1913 uint8_t cipher_auth_key[key_len];
1915 struct crypto_unittest_params *ut_params = &unittest_params;
1917 memcpy(cipher_auth_key, key, key_len);
1919 /* Setup Authentication Parameters */
1920 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1921 ut_params->auth_xform.next = NULL;
1923 ut_params->auth_xform.auth.op = auth_op;
1924 ut_params->auth_xform.auth.algo = auth_algo;
1925 ut_params->auth_xform.auth.key.length = key_len;
1926 /* Hash key = cipher key */
1927 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1928 ut_params->auth_xform.auth.digest_length = auth_len;
1929 /* Auth IV will be after cipher IV */
1930 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1931 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1933 /* Setup Cipher Parameters */
1934 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1935 ut_params->cipher_xform.next = &ut_params->auth_xform;
1937 ut_params->cipher_xform.cipher.algo = cipher_algo;
1938 ut_params->cipher_xform.cipher.op = cipher_op;
1939 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1940 ut_params->cipher_xform.cipher.key.length = key_len;
1941 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1942 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1944 TEST_HEXDUMP(stdout, "key:", key, key_len);
1946 /* Create Crypto session*/
1947 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1948 &ut_params->cipher_xform);
1950 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1955 create_wireless_cipher_auth_session(uint8_t dev_id,
1956 enum rte_crypto_cipher_operation cipher_op,
1957 enum rte_crypto_auth_operation auth_op,
1958 enum rte_crypto_auth_algorithm auth_algo,
1959 enum rte_crypto_cipher_algorithm cipher_algo,
1960 const struct wireless_test_data *tdata)
1962 const uint8_t key_len = tdata->key.len;
1963 uint8_t cipher_auth_key[key_len];
1965 struct crypto_unittest_params *ut_params = &unittest_params;
1966 const uint8_t *key = tdata->key.data;
1967 const uint8_t auth_len = tdata->digest.len;
1968 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1969 uint8_t auth_iv_len = tdata->auth_iv.len;
1971 memcpy(cipher_auth_key, key, key_len);
1973 /* Setup Authentication Parameters */
1974 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1975 ut_params->auth_xform.next = NULL;
1977 ut_params->auth_xform.auth.op = auth_op;
1978 ut_params->auth_xform.auth.algo = auth_algo;
1979 ut_params->auth_xform.auth.key.length = key_len;
1980 /* Hash key = cipher key */
1981 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1982 ut_params->auth_xform.auth.digest_length = auth_len;
1983 /* Auth IV will be after cipher IV */
1984 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1985 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1987 /* Setup Cipher Parameters */
1988 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1989 ut_params->cipher_xform.next = &ut_params->auth_xform;
1991 ut_params->cipher_xform.cipher.algo = cipher_algo;
1992 ut_params->cipher_xform.cipher.op = cipher_op;
1993 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1994 ut_params->cipher_xform.cipher.key.length = key_len;
1995 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1996 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1999 TEST_HEXDUMP(stdout, "key:", key, key_len);
2001 /* Create Crypto session*/
2002 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2003 &ut_params->cipher_xform);
2005 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2010 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2011 const struct wireless_test_data *tdata)
2013 return create_wireless_cipher_auth_session(dev_id,
2014 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2015 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2016 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2020 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2021 enum rte_crypto_cipher_operation cipher_op,
2022 enum rte_crypto_auth_operation auth_op,
2023 enum rte_crypto_auth_algorithm auth_algo,
2024 enum rte_crypto_cipher_algorithm cipher_algo,
2025 const uint8_t *key, const uint8_t key_len,
2026 uint8_t auth_iv_len, uint8_t auth_len,
2027 uint8_t cipher_iv_len)
2029 uint8_t auth_cipher_key[key_len];
2031 struct crypto_unittest_params *ut_params = &unittest_params;
2033 memcpy(auth_cipher_key, key, key_len);
2035 /* Setup Authentication Parameters */
2036 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2037 ut_params->auth_xform.auth.op = auth_op;
2038 ut_params->auth_xform.next = &ut_params->cipher_xform;
2039 ut_params->auth_xform.auth.algo = auth_algo;
2040 ut_params->auth_xform.auth.key.length = key_len;
2041 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2042 ut_params->auth_xform.auth.digest_length = auth_len;
2043 /* Auth IV will be after cipher IV */
2044 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2045 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2047 /* Setup Cipher Parameters */
2048 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2049 ut_params->cipher_xform.next = NULL;
2050 ut_params->cipher_xform.cipher.algo = cipher_algo;
2051 ut_params->cipher_xform.cipher.op = cipher_op;
2052 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2053 ut_params->cipher_xform.cipher.key.length = key_len;
2054 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2055 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2057 TEST_HEXDUMP(stdout, "key:", key, key_len);
2059 /* Create Crypto session*/
2060 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2061 &ut_params->auth_xform);
2063 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2069 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2070 unsigned int auth_tag_len,
2071 const uint8_t *iv, unsigned int iv_len,
2072 unsigned int data_pad_len,
2073 enum rte_crypto_auth_operation op,
2074 unsigned int auth_len, unsigned int auth_offset)
2076 struct crypto_testsuite_params *ts_params = &testsuite_params;
2078 struct crypto_unittest_params *ut_params = &unittest_params;
2080 /* Generate Crypto op data structure */
2081 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2082 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2083 TEST_ASSERT_NOT_NULL(ut_params->op,
2084 "Failed to allocate pktmbuf offload");
2086 /* Set crypto operation data parameters */
2087 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2089 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2091 /* set crypto operation source mbuf */
2092 sym_op->m_src = ut_params->ibuf;
2095 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2098 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2099 ut_params->ibuf, auth_tag_len);
2101 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2102 "no room to append auth tag");
2103 ut_params->digest = sym_op->auth.digest.data;
2104 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2105 ut_params->ibuf, data_pad_len);
2106 sym_op->auth.digest.length = auth_tag_len;
2107 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2108 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2110 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2112 TEST_HEXDUMP(stdout, "digest:",
2113 sym_op->auth.digest.data,
2114 sym_op->auth.digest.length);
2116 sym_op->auth.data.length = auth_len;
2117 sym_op->auth.data.offset = auth_offset;
2123 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2124 enum rte_crypto_auth_operation op)
2126 struct crypto_testsuite_params *ts_params = &testsuite_params;
2127 struct crypto_unittest_params *ut_params = &unittest_params;
2129 const uint8_t *auth_tag = tdata->digest.data;
2130 const unsigned int auth_tag_len = tdata->digest.len;
2131 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2132 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2134 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2135 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2136 const uint8_t *auth_iv = tdata->auth_iv.data;
2137 const uint8_t auth_iv_len = tdata->auth_iv.len;
2138 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2139 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2141 /* Generate Crypto op data structure */
2142 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2143 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2144 TEST_ASSERT_NOT_NULL(ut_params->op,
2145 "Failed to allocate pktmbuf offload");
2146 /* Set crypto operation data parameters */
2147 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2149 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2151 /* set crypto operation source mbuf */
2152 sym_op->m_src = ut_params->ibuf;
2155 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2156 ut_params->ibuf, auth_tag_len);
2158 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2159 "no room to append auth tag");
2160 ut_params->digest = sym_op->auth.digest.data;
2161 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2162 ut_params->ibuf, data_pad_len);
2163 sym_op->auth.digest.length = auth_tag_len;
2164 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2165 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2167 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2169 TEST_HEXDUMP(stdout, "digest:",
2170 sym_op->auth.digest.data,
2171 sym_op->auth.digest.length);
2173 /* Copy cipher and auth IVs at the end of the crypto operation */
2174 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2176 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2177 iv_ptr += cipher_iv_len;
2178 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2180 sym_op->cipher.data.length = cipher_len;
2181 sym_op->cipher.data.offset = 0;
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = 0;
2189 create_zuc_cipher_hash_generate_operation(
2190 const struct wireless_test_data *tdata)
2192 return create_wireless_cipher_hash_operation(tdata,
2193 RTE_CRYPTO_AUTH_OP_GENERATE);
2197 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2198 const unsigned auth_tag_len,
2199 const uint8_t *auth_iv, uint8_t auth_iv_len,
2200 unsigned data_pad_len,
2201 enum rte_crypto_auth_operation op,
2202 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2203 const unsigned cipher_len, const unsigned cipher_offset,
2204 const unsigned auth_len, const unsigned auth_offset)
2206 struct crypto_testsuite_params *ts_params = &testsuite_params;
2207 struct crypto_unittest_params *ut_params = &unittest_params;
2209 /* Generate Crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate pktmbuf offload");
2214 /* Set crypto operation data parameters */
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2223 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2224 ut_params->ibuf, auth_tag_len);
2226 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2227 "no room to append auth tag");
2228 ut_params->digest = sym_op->auth.digest.data;
2229 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2230 ut_params->ibuf, data_pad_len);
2231 sym_op->auth.digest.length = auth_tag_len;
2232 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2233 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2235 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2237 TEST_HEXDUMP(stdout, "digest:",
2238 sym_op->auth.digest.data,
2239 sym_op->auth.digest.length);
2241 /* Copy cipher and auth IVs at the end of the crypto operation */
2242 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2244 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2245 iv_ptr += cipher_iv_len;
2246 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2248 sym_op->cipher.data.length = cipher_len;
2249 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2250 sym_op->auth.data.length = auth_len;
2251 sym_op->auth.data.offset = auth_offset + cipher_offset;
2257 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2258 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2259 const uint8_t *auth_iv, uint8_t auth_iv_len,
2260 unsigned int data_pad_len,
2261 unsigned int cipher_len, unsigned int cipher_offset,
2262 unsigned int auth_len, unsigned int auth_offset)
2264 struct crypto_testsuite_params *ts_params = &testsuite_params;
2265 struct crypto_unittest_params *ut_params = &unittest_params;
2267 /* Generate Crypto op data structure */
2268 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2269 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2270 TEST_ASSERT_NOT_NULL(ut_params->op,
2271 "Failed to allocate pktmbuf offload");
2273 /* Set crypto operation data parameters */
2274 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2276 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2278 /* set crypto operation source mbuf */
2279 sym_op->m_src = ut_params->ibuf;
2282 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2283 ut_params->ibuf, auth_tag_len);
2285 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2286 "no room to append auth tag");
2288 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2289 ut_params->ibuf, data_pad_len);
2290 sym_op->auth.digest.length = auth_tag_len;
2292 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2294 TEST_HEXDUMP(stdout, "digest:",
2295 sym_op->auth.digest.data,
2296 sym_op->auth.digest.length);
2298 /* Copy cipher and auth IVs at the end of the crypto operation */
2299 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2301 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2302 iv_ptr += cipher_iv_len;
2303 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2305 sym_op->cipher.data.length = cipher_len;
2306 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2308 sym_op->auth.data.length = auth_len;
2309 sym_op->auth.data.offset = auth_offset + cipher_offset;
2315 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2317 struct crypto_testsuite_params *ts_params = &testsuite_params;
2318 struct crypto_unittest_params *ut_params = &unittest_params;
2321 unsigned plaintext_pad_len;
2322 unsigned plaintext_len;
2325 /* Create SNOW 3G session */
2326 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2327 tdata->key.data, tdata->key.len,
2328 tdata->auth_iv.len, tdata->digest.len,
2329 RTE_CRYPTO_AUTH_OP_GENERATE,
2330 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2334 /* alloc mbuf and set payload */
2335 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2338 rte_pktmbuf_tailroom(ut_params->ibuf));
2340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2341 /* Append data which is padded to a multiple of */
2342 /* the algorithms block size */
2343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2348 /* Create SNOW 3G operation */
2349 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2350 tdata->auth_iv.data, tdata->auth_iv.len,
2351 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2352 tdata->validAuthLenInBits.len,
2357 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2359 ut_params->obuf = ut_params->op->sym->m_src;
2360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2361 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2362 + plaintext_pad_len;
2365 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2368 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2369 "SNOW 3G Generated auth tag not as expected");
2375 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2377 struct crypto_testsuite_params *ts_params = &testsuite_params;
2378 struct crypto_unittest_params *ut_params = &unittest_params;
2381 unsigned plaintext_pad_len;
2382 unsigned plaintext_len;
2385 /* Create SNOW 3G session */
2386 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2387 tdata->key.data, tdata->key.len,
2388 tdata->auth_iv.len, tdata->digest.len,
2389 RTE_CRYPTO_AUTH_OP_VERIFY,
2390 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2393 /* alloc mbuf and set payload */
2394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2396 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2397 rte_pktmbuf_tailroom(ut_params->ibuf));
2399 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2400 /* Append data which is padded to a multiple of */
2401 /* the algorithms block size */
2402 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2403 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2405 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2407 /* Create SNOW 3G operation */
2408 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2410 tdata->auth_iv.data, tdata->auth_iv.len,
2412 RTE_CRYPTO_AUTH_OP_VERIFY,
2413 tdata->validAuthLenInBits.len,
2418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2421 ut_params->obuf = ut_params->op->sym->m_src;
2422 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2423 + plaintext_pad_len;
2426 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2435 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2437 struct crypto_testsuite_params *ts_params = &testsuite_params;
2438 struct crypto_unittest_params *ut_params = &unittest_params;
2441 unsigned plaintext_pad_len;
2442 unsigned plaintext_len;
2445 /* Create KASUMI session */
2446 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2447 tdata->key.data, tdata->key.len,
2448 tdata->auth_iv.len, tdata->digest.len,
2449 RTE_CRYPTO_AUTH_OP_GENERATE,
2450 RTE_CRYPTO_AUTH_KASUMI_F9);
2454 /* alloc mbuf and set payload */
2455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2458 rte_pktmbuf_tailroom(ut_params->ibuf));
2460 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2461 /* Append data which is padded to a multiple of */
2462 /* the algorithms block size */
2463 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2464 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2466 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2468 /* Create KASUMI operation */
2469 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2470 tdata->auth_iv.data, tdata->auth_iv.len,
2471 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2472 tdata->validAuthLenInBits.len,
2477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2479 ut_params->obuf = ut_params->op->sym->m_src;
2480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2481 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2482 + plaintext_pad_len;
2485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2488 DIGEST_BYTE_LENGTH_KASUMI_F9,
2489 "KASUMI Generated auth tag not as expected");
2495 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2497 struct crypto_testsuite_params *ts_params = &testsuite_params;
2498 struct crypto_unittest_params *ut_params = &unittest_params;
2501 unsigned plaintext_pad_len;
2502 unsigned plaintext_len;
2505 /* Create KASUMI session */
2506 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2507 tdata->key.data, tdata->key.len,
2508 tdata->auth_iv.len, tdata->digest.len,
2509 RTE_CRYPTO_AUTH_OP_VERIFY,
2510 RTE_CRYPTO_AUTH_KASUMI_F9);
2513 /* alloc mbuf and set payload */
2514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2517 rte_pktmbuf_tailroom(ut_params->ibuf));
2519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2520 /* Append data which is padded to a multiple */
2521 /* of the algorithms block size */
2522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2523 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2527 /* Create KASUMI operation */
2528 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2530 tdata->auth_iv.data, tdata->auth_iv.len,
2532 RTE_CRYPTO_AUTH_OP_VERIFY,
2533 tdata->validAuthLenInBits.len,
2538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2541 ut_params->obuf = ut_params->op->sym->m_src;
2542 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2543 + plaintext_pad_len;
2546 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2555 test_snow3g_hash_generate_test_case_1(void)
2557 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2561 test_snow3g_hash_generate_test_case_2(void)
2563 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2567 test_snow3g_hash_generate_test_case_3(void)
2569 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2573 test_snow3g_hash_generate_test_case_4(void)
2575 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2579 test_snow3g_hash_generate_test_case_5(void)
2581 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2585 test_snow3g_hash_generate_test_case_6(void)
2587 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2591 test_snow3g_hash_verify_test_case_1(void)
2593 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2598 test_snow3g_hash_verify_test_case_2(void)
2600 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2604 test_snow3g_hash_verify_test_case_3(void)
2606 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2610 test_snow3g_hash_verify_test_case_4(void)
2612 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2616 test_snow3g_hash_verify_test_case_5(void)
2618 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2622 test_snow3g_hash_verify_test_case_6(void)
2624 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2628 test_kasumi_hash_generate_test_case_1(void)
2630 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2634 test_kasumi_hash_generate_test_case_2(void)
2636 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2640 test_kasumi_hash_generate_test_case_3(void)
2642 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2646 test_kasumi_hash_generate_test_case_4(void)
2648 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2652 test_kasumi_hash_generate_test_case_5(void)
2654 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2658 test_kasumi_hash_generate_test_case_6(void)
2660 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2664 test_kasumi_hash_verify_test_case_1(void)
2666 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2670 test_kasumi_hash_verify_test_case_2(void)
2672 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2676 test_kasumi_hash_verify_test_case_3(void)
2678 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2682 test_kasumi_hash_verify_test_case_4(void)
2684 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2688 test_kasumi_hash_verify_test_case_5(void)
2690 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2694 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2696 struct crypto_testsuite_params *ts_params = &testsuite_params;
2697 struct crypto_unittest_params *ut_params = &unittest_params;
2700 uint8_t *plaintext, *ciphertext;
2701 unsigned plaintext_pad_len;
2702 unsigned plaintext_len;
2704 /* Create KASUMI session */
2705 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2706 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2707 RTE_CRYPTO_CIPHER_KASUMI_F8,
2708 tdata->key.data, tdata->key.len,
2709 tdata->cipher_iv.len);
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 /* Clear mbuf payload */
2716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2717 rte_pktmbuf_tailroom(ut_params->ibuf));
2719 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2720 /* Append data which is padded to a multiple */
2721 /* of the algorithms block size */
2722 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2725 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2727 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2729 /* Create KASUMI operation */
2730 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2731 tdata->cipher_iv.len,
2732 tdata->plaintext.len,
2737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2741 ut_params->obuf = ut_params->op->sym->m_dst;
2742 if (ut_params->obuf)
2743 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2745 ciphertext = plaintext;
2747 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2750 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2752 tdata->ciphertext.data,
2753 tdata->validCipherLenInBits.len,
2754 "KASUMI Ciphertext data not as expected");
2759 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2761 struct crypto_testsuite_params *ts_params = &testsuite_params;
2762 struct crypto_unittest_params *ut_params = &unittest_params;
2766 unsigned int plaintext_pad_len;
2767 unsigned int plaintext_len;
2769 uint8_t buffer[10000];
2770 const uint8_t *ciphertext;
2772 struct rte_cryptodev_info dev_info;
2774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2775 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2776 printf("Device doesn't support scatter-gather. "
2781 /* Create KASUMI session */
2782 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 RTE_CRYPTO_CIPHER_KASUMI_F8,
2785 tdata->key.data, tdata->key.len,
2786 tdata->cipher_iv.len);
2790 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2793 /* Append data which is padded to a multiple */
2794 /* of the algorithms block size */
2795 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2797 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2798 plaintext_pad_len, 10, 0);
2800 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2802 /* Create KASUMI operation */
2803 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2804 tdata->cipher_iv.len,
2805 tdata->plaintext.len,
2810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2812 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2814 ut_params->obuf = ut_params->op->sym->m_dst;
2816 if (ut_params->obuf)
2817 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2818 plaintext_len, buffer);
2820 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2821 plaintext_len, buffer);
2824 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2827 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2829 tdata->ciphertext.data,
2830 tdata->validCipherLenInBits.len,
2831 "KASUMI Ciphertext data not as expected");
2836 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2838 struct crypto_testsuite_params *ts_params = &testsuite_params;
2839 struct crypto_unittest_params *ut_params = &unittest_params;
2842 uint8_t *plaintext, *ciphertext;
2843 unsigned plaintext_pad_len;
2844 unsigned plaintext_len;
2846 /* Create KASUMI session */
2847 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2848 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2849 RTE_CRYPTO_CIPHER_KASUMI_F8,
2850 tdata->key.data, tdata->key.len,
2851 tdata->cipher_iv.len);
2855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2856 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2858 /* Clear mbuf payload */
2859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2860 rte_pktmbuf_tailroom(ut_params->ibuf));
2862 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2863 /* Append data which is padded to a multiple */
2864 /* of the algorithms block size */
2865 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2868 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2869 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2871 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2873 /* Create KASUMI operation */
2874 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2875 tdata->cipher_iv.len,
2876 tdata->plaintext.len,
2881 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2885 ut_params->obuf = ut_params->op->sym->m_dst;
2886 if (ut_params->obuf)
2887 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2889 ciphertext = plaintext;
2891 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2896 tdata->ciphertext.data,
2897 tdata->validCipherLenInBits.len,
2898 "KASUMI Ciphertext data not as expected");
2903 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2905 struct crypto_testsuite_params *ts_params = &testsuite_params;
2906 struct crypto_unittest_params *ut_params = &unittest_params;
2909 unsigned int plaintext_pad_len;
2910 unsigned int plaintext_len;
2912 const uint8_t *ciphertext;
2913 uint8_t buffer[2048];
2915 struct rte_cryptodev_info dev_info;
2917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2918 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2919 printf("Device doesn't support scatter-gather. "
2924 /* Create KASUMI session */
2925 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2926 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2927 RTE_CRYPTO_CIPHER_KASUMI_F8,
2928 tdata->key.data, tdata->key.len,
2929 tdata->cipher_iv.len);
2933 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2934 /* Append data which is padded to a multiple */
2935 /* of the algorithms block size */
2936 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2938 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2939 plaintext_pad_len, 10, 0);
2940 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2941 plaintext_pad_len, 3, 0);
2943 /* Append data which is padded to a multiple */
2944 /* of the algorithms block size */
2945 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2947 /* Create KASUMI operation */
2948 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2949 tdata->cipher_iv.len,
2950 tdata->plaintext.len,
2955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2957 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2959 ut_params->obuf = ut_params->op->sym->m_dst;
2960 if (ut_params->obuf)
2961 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2962 plaintext_pad_len, buffer);
2964 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2965 plaintext_pad_len, buffer);
2968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2970 tdata->ciphertext.data,
2971 tdata->validCipherLenInBits.len,
2972 "KASUMI Ciphertext data not as expected");
2978 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2980 struct crypto_testsuite_params *ts_params = &testsuite_params;
2981 struct crypto_unittest_params *ut_params = &unittest_params;
2984 uint8_t *ciphertext, *plaintext;
2985 unsigned ciphertext_pad_len;
2986 unsigned ciphertext_len;
2988 /* Create KASUMI session */
2989 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2990 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2991 RTE_CRYPTO_CIPHER_KASUMI_F8,
2992 tdata->key.data, tdata->key.len,
2993 tdata->cipher_iv.len);
2997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2998 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3000 /* Clear mbuf payload */
3001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3002 rte_pktmbuf_tailroom(ut_params->ibuf));
3004 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3005 /* Append data which is padded to a multiple */
3006 /* of the algorithms block size */
3007 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3008 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3009 ciphertext_pad_len);
3010 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3011 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3013 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3015 /* Create KASUMI operation */
3016 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3017 tdata->cipher_iv.len,
3018 tdata->ciphertext.len,
3023 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3025 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3027 ut_params->obuf = ut_params->op->sym->m_dst;
3028 if (ut_params->obuf)
3029 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3031 plaintext = ciphertext;
3033 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3036 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3038 tdata->plaintext.data,
3039 tdata->validCipherLenInBits.len,
3040 "KASUMI Plaintext data not as expected");
3045 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3047 struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 struct crypto_unittest_params *ut_params = &unittest_params;
3051 uint8_t *ciphertext, *plaintext;
3052 unsigned ciphertext_pad_len;
3053 unsigned ciphertext_len;
3055 /* Create KASUMI session */
3056 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3057 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3058 RTE_CRYPTO_CIPHER_KASUMI_F8,
3059 tdata->key.data, tdata->key.len,
3060 tdata->cipher_iv.len);
3064 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3066 /* Clear mbuf payload */
3067 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3068 rte_pktmbuf_tailroom(ut_params->ibuf));
3070 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3071 /* Append data which is padded to a multiple */
3072 /* of the algorithms block size */
3073 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3074 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3075 ciphertext_pad_len);
3076 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3078 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3080 /* Create KASUMI operation */
3081 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3082 tdata->cipher_iv.len,
3083 tdata->ciphertext.len,
3088 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3090 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3092 ut_params->obuf = ut_params->op->sym->m_dst;
3093 if (ut_params->obuf)
3094 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3096 plaintext = ciphertext;
3098 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3103 tdata->plaintext.data,
3104 tdata->validCipherLenInBits.len,
3105 "KASUMI Plaintext data not as expected");
3110 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3112 struct crypto_testsuite_params *ts_params = &testsuite_params;
3113 struct crypto_unittest_params *ut_params = &unittest_params;
3116 uint8_t *plaintext, *ciphertext;
3117 unsigned plaintext_pad_len;
3118 unsigned plaintext_len;
3120 /* Create SNOW 3G session */
3121 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3122 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3123 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3124 tdata->key.data, tdata->key.len,
3125 tdata->cipher_iv.len);
3129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3131 /* Clear mbuf payload */
3132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3133 rte_pktmbuf_tailroom(ut_params->ibuf));
3135 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3136 /* Append data which is padded to a multiple of */
3137 /* the algorithms block size */
3138 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3139 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3141 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3143 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3145 /* Create SNOW 3G operation */
3146 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3147 tdata->cipher_iv.len,
3148 tdata->validCipherLenInBits.len,
3153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3155 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3157 ut_params->obuf = ut_params->op->sym->m_dst;
3158 if (ut_params->obuf)
3159 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3161 ciphertext = plaintext;
3163 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3168 tdata->ciphertext.data,
3169 tdata->validDataLenInBits.len,
3170 "SNOW 3G Ciphertext data not as expected");
3176 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3178 struct crypto_testsuite_params *ts_params = &testsuite_params;
3179 struct crypto_unittest_params *ut_params = &unittest_params;
3180 uint8_t *plaintext, *ciphertext;
3183 unsigned plaintext_pad_len;
3184 unsigned plaintext_len;
3186 /* Create SNOW 3G session */
3187 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3188 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3189 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3190 tdata->key.data, tdata->key.len,
3191 tdata->cipher_iv.len);
3195 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3198 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3199 "Failed to allocate input buffer in mempool");
3200 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3201 "Failed to allocate output buffer in mempool");
3203 /* Clear mbuf payload */
3204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3205 rte_pktmbuf_tailroom(ut_params->ibuf));
3207 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3208 /* Append data which is padded to a multiple of */
3209 /* the algorithms block size */
3210 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3213 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3214 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3216 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3218 /* Create SNOW 3G operation */
3219 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3220 tdata->cipher_iv.len,
3221 tdata->validCipherLenInBits.len,
3226 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3230 ut_params->obuf = ut_params->op->sym->m_dst;
3231 if (ut_params->obuf)
3232 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3234 ciphertext = plaintext;
3236 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3239 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3241 tdata->ciphertext.data,
3242 tdata->validDataLenInBits.len,
3243 "SNOW 3G Ciphertext data not as expected");
3248 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3250 struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 struct crypto_unittest_params *ut_params = &unittest_params;
3254 unsigned int plaintext_pad_len;
3255 unsigned int plaintext_len;
3256 uint8_t buffer[10000];
3257 const uint8_t *ciphertext;
3259 struct rte_cryptodev_info dev_info;
3261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3262 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3263 printf("Device doesn't support scatter-gather. "
3268 /* Create SNOW 3G session */
3269 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3270 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3271 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3272 tdata->key.data, tdata->key.len,
3273 tdata->cipher_iv.len);
3277 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3278 /* Append data which is padded to a multiple of */
3279 /* the algorithms block size */
3280 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3282 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3283 plaintext_pad_len, 10, 0);
3284 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3285 plaintext_pad_len, 3, 0);
3287 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3288 "Failed to allocate input buffer in mempool");
3289 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3290 "Failed to allocate output buffer in mempool");
3292 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3294 /* Create SNOW 3G operation */
3295 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3296 tdata->cipher_iv.len,
3297 tdata->validCipherLenInBits.len,
3302 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3304 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3306 ut_params->obuf = ut_params->op->sym->m_dst;
3307 if (ut_params->obuf)
3308 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3309 plaintext_len, buffer);
3311 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3312 plaintext_len, buffer);
3314 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3317 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3319 tdata->ciphertext.data,
3320 tdata->validDataLenInBits.len,
3321 "SNOW 3G Ciphertext data not as expected");
3326 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3328 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3330 uint8_t curr_byte, prev_byte;
3331 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3332 uint8_t lower_byte_mask = (1 << offset) - 1;
3335 prev_byte = buffer[0];
3336 buffer[0] >>= offset;
3338 for (i = 1; i < length_in_bytes; i++) {
3339 curr_byte = buffer[i];
3340 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3341 (curr_byte >> offset);
3342 prev_byte = curr_byte;
3347 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3349 struct crypto_testsuite_params *ts_params = &testsuite_params;
3350 struct crypto_unittest_params *ut_params = &unittest_params;
3351 uint8_t *plaintext, *ciphertext;
3353 uint32_t plaintext_len;
3354 uint32_t plaintext_pad_len;
3355 uint8_t extra_offset = 4;
3356 uint8_t *expected_ciphertext_shifted;
3358 /* Create SNOW 3G session */
3359 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3360 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3361 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3362 tdata->key.data, tdata->key.len,
3363 tdata->cipher_iv.len);
3367 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3368 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3370 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3371 "Failed to allocate input buffer in mempool");
3372 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3373 "Failed to allocate output buffer in mempool");
3375 /* Clear mbuf payload */
3376 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3377 rte_pktmbuf_tailroom(ut_params->ibuf));
3379 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3381 * Append data which is padded to a
3382 * multiple of the algorithms block size
3384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3386 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3389 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3391 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3392 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3394 #ifdef RTE_APP_TEST_DEBUG
3395 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3397 /* Create SNOW 3G operation */
3398 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3399 tdata->cipher_iv.len,
3400 tdata->validCipherLenInBits.len,
3405 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3407 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3409 ut_params->obuf = ut_params->op->sym->m_dst;
3410 if (ut_params->obuf)
3411 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3413 ciphertext = plaintext;
3415 #ifdef RTE_APP_TEST_DEBUG
3416 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3419 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3421 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3422 "failed to reserve memory for ciphertext shifted\n");
3424 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3425 ceil_byte_length(tdata->ciphertext.len));
3426 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3429 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3431 expected_ciphertext_shifted,
3432 tdata->validDataLenInBits.len,
3434 "SNOW 3G Ciphertext data not as expected");
3438 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3440 struct crypto_testsuite_params *ts_params = &testsuite_params;
3441 struct crypto_unittest_params *ut_params = &unittest_params;
3445 uint8_t *plaintext, *ciphertext;
3446 unsigned ciphertext_pad_len;
3447 unsigned ciphertext_len;
3449 /* Create SNOW 3G session */
3450 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3451 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3452 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3453 tdata->key.data, tdata->key.len,
3454 tdata->cipher_iv.len);
3458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3460 /* Clear mbuf payload */
3461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3462 rte_pktmbuf_tailroom(ut_params->ibuf));
3464 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3465 /* Append data which is padded to a multiple of */
3466 /* the algorithms block size */
3467 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3468 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3469 ciphertext_pad_len);
3470 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3472 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3474 /* Create SNOW 3G operation */
3475 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3476 tdata->cipher_iv.len,
3477 tdata->validCipherLenInBits.len,
3482 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3485 ut_params->obuf = ut_params->op->sym->m_dst;
3486 if (ut_params->obuf)
3487 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3489 plaintext = ciphertext;
3491 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3495 tdata->plaintext.data,
3496 tdata->validDataLenInBits.len,
3497 "SNOW 3G Plaintext data not as expected");
3501 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3503 struct crypto_testsuite_params *ts_params = &testsuite_params;
3504 struct crypto_unittest_params *ut_params = &unittest_params;
3508 uint8_t *plaintext, *ciphertext;
3509 unsigned ciphertext_pad_len;
3510 unsigned ciphertext_len;
3512 /* Create SNOW 3G session */
3513 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3514 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3515 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3516 tdata->key.data, tdata->key.len,
3517 tdata->cipher_iv.len);
3521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3522 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3524 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3525 "Failed to allocate input buffer");
3526 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3527 "Failed to allocate output buffer");
3529 /* Clear mbuf payload */
3530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3531 rte_pktmbuf_tailroom(ut_params->ibuf));
3533 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3534 rte_pktmbuf_tailroom(ut_params->obuf));
3536 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3537 /* Append data which is padded to a multiple of */
3538 /* the algorithms block size */
3539 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3540 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3541 ciphertext_pad_len);
3542 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3543 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3545 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3547 /* Create SNOW 3G operation */
3548 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3549 tdata->cipher_iv.len,
3550 tdata->validCipherLenInBits.len,
3555 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3557 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3558 ut_params->obuf = ut_params->op->sym->m_dst;
3559 if (ut_params->obuf)
3560 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3562 plaintext = ciphertext;
3564 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3568 tdata->plaintext.data,
3569 tdata->validDataLenInBits.len,
3570 "SNOW 3G Plaintext data not as expected");
3575 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3577 struct crypto_testsuite_params *ts_params = &testsuite_params;
3578 struct crypto_unittest_params *ut_params = &unittest_params;
3582 uint8_t *plaintext, *ciphertext;
3583 unsigned int plaintext_pad_len;
3584 unsigned int plaintext_len;
3586 struct rte_cryptodev_sym_capability_idx cap_idx;
3588 /* Check if device supports ZUC EEA3 */
3589 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3590 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3592 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3596 /* Check if device supports ZUC EIA3 */
3597 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3598 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3600 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3604 /* Create ZUC session */
3605 retval = create_zuc_cipher_auth_encrypt_generate_session(
3606 ts_params->valid_devs[0],
3610 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3612 /* clear mbuf payload */
3613 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3614 rte_pktmbuf_tailroom(ut_params->ibuf));
3616 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3617 /* Append data which is padded to a multiple of */
3618 /* the algorithms block size */
3619 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3620 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3622 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3624 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3626 /* Create ZUC operation */
3627 retval = create_zuc_cipher_hash_generate_operation(tdata);
3631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3633 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3634 ut_params->obuf = ut_params->op->sym->m_src;
3635 if (ut_params->obuf)
3636 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3638 ciphertext = plaintext;
3640 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3642 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3644 tdata->ciphertext.data,
3645 tdata->validDataLenInBits.len,
3646 "ZUC Ciphertext data not as expected");
3648 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3649 + plaintext_pad_len;
3652 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3656 "ZUC Generated auth tag not as expected");
3661 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3663 struct crypto_testsuite_params *ts_params = &testsuite_params;
3664 struct crypto_unittest_params *ut_params = &unittest_params;
3668 uint8_t *plaintext, *ciphertext;
3669 unsigned plaintext_pad_len;
3670 unsigned plaintext_len;
3672 /* Create SNOW 3G session */
3673 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3674 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3675 RTE_CRYPTO_AUTH_OP_GENERATE,
3676 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3677 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3678 tdata->key.data, tdata->key.len,
3679 tdata->auth_iv.len, tdata->digest.len,
3680 tdata->cipher_iv.len);
3683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3685 /* clear mbuf payload */
3686 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3687 rte_pktmbuf_tailroom(ut_params->ibuf));
3689 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3690 /* Append data which is padded to a multiple of */
3691 /* the algorithms block size */
3692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3693 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3695 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3697 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3699 /* Create SNOW 3G operation */
3700 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3701 tdata->digest.len, tdata->auth_iv.data,
3703 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3704 tdata->cipher_iv.data, tdata->cipher_iv.len,
3705 tdata->validCipherLenInBits.len,
3707 tdata->validAuthLenInBits.len,
3713 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3715 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3716 ut_params->obuf = ut_params->op->sym->m_src;
3717 if (ut_params->obuf)
3718 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3720 ciphertext = plaintext;
3722 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3726 tdata->ciphertext.data,
3727 tdata->validDataLenInBits.len,
3728 "SNOW 3G Ciphertext data not as expected");
3730 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3731 + plaintext_pad_len;
3734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3737 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3738 "SNOW 3G Generated auth tag not as expected");
3742 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3744 struct crypto_testsuite_params *ts_params = &testsuite_params;
3745 struct crypto_unittest_params *ut_params = &unittest_params;
3749 uint8_t *plaintext, *ciphertext;
3750 unsigned plaintext_pad_len;
3751 unsigned plaintext_len;
3753 /* Create SNOW 3G session */
3754 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3755 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3756 RTE_CRYPTO_AUTH_OP_GENERATE,
3757 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3758 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3759 tdata->key.data, tdata->key.len,
3760 tdata->auth_iv.len, tdata->digest.len,
3761 tdata->cipher_iv.len);
3765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3767 /* clear mbuf payload */
3768 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3769 rte_pktmbuf_tailroom(ut_params->ibuf));
3771 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3772 /* Append data which is padded to a multiple of */
3773 /* the algorithms block size */
3774 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3775 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3777 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3779 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3781 /* Create SNOW 3G operation */
3782 retval = create_wireless_algo_auth_cipher_operation(
3784 tdata->cipher_iv.data, tdata->cipher_iv.len,
3785 tdata->auth_iv.data, tdata->auth_iv.len,
3787 tdata->validCipherLenInBits.len,
3789 tdata->validAuthLenInBits.len,
3795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3798 ut_params->obuf = ut_params->op->sym->m_src;
3799 if (ut_params->obuf)
3800 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3802 ciphertext = plaintext;
3804 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3805 + plaintext_pad_len;
3806 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3809 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3811 tdata->ciphertext.data,
3812 tdata->validDataLenInBits.len,
3813 "SNOW 3G Ciphertext data not as expected");
3816 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3819 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3820 "SNOW 3G Generated auth tag not as expected");
3825 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3827 struct crypto_testsuite_params *ts_params = &testsuite_params;
3828 struct crypto_unittest_params *ut_params = &unittest_params;
3832 uint8_t *plaintext, *ciphertext;
3833 unsigned plaintext_pad_len;
3834 unsigned plaintext_len;
3836 /* Create KASUMI session */
3837 retval = create_wireless_algo_auth_cipher_session(
3838 ts_params->valid_devs[0],
3839 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3840 RTE_CRYPTO_AUTH_OP_GENERATE,
3841 RTE_CRYPTO_AUTH_KASUMI_F9,
3842 RTE_CRYPTO_CIPHER_KASUMI_F8,
3843 tdata->key.data, tdata->key.len,
3844 tdata->auth_iv.len, tdata->digest.len,
3845 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3850 /* clear mbuf payload */
3851 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3852 rte_pktmbuf_tailroom(ut_params->ibuf));
3854 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3855 /* Append data which is padded to a multiple of */
3856 /* the algorithms block size */
3857 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3858 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3860 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3862 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3864 /* Create KASUMI operation */
3865 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3866 tdata->cipher_iv.data, tdata->cipher_iv.len,
3867 tdata->auth_iv.data, tdata->auth_iv.len,
3869 tdata->validCipherLenInBits.len,
3871 tdata->validAuthLenInBits.len,
3878 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3880 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3881 ut_params->obuf = ut_params->op->sym->m_src;
3882 if (ut_params->obuf)
3883 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3885 ciphertext = plaintext;
3888 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3890 tdata->ciphertext.data,
3891 tdata->validCipherLenInBits.len,
3892 "KASUMI Ciphertext data not as expected");
3893 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3894 + plaintext_pad_len;
3897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3900 DIGEST_BYTE_LENGTH_KASUMI_F9,
3901 "KASUMI Generated auth tag not as expected");
3906 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3908 struct crypto_testsuite_params *ts_params = &testsuite_params;
3909 struct crypto_unittest_params *ut_params = &unittest_params;
3913 uint8_t *plaintext, *ciphertext;
3914 unsigned plaintext_pad_len;
3915 unsigned plaintext_len;
3917 /* Create KASUMI session */
3918 retval = create_wireless_algo_cipher_auth_session(
3919 ts_params->valid_devs[0],
3920 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3921 RTE_CRYPTO_AUTH_OP_GENERATE,
3922 RTE_CRYPTO_AUTH_KASUMI_F9,
3923 RTE_CRYPTO_CIPHER_KASUMI_F8,
3924 tdata->key.data, tdata->key.len,
3925 tdata->auth_iv.len, tdata->digest.len,
3926 tdata->cipher_iv.len);
3930 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3932 /* clear mbuf payload */
3933 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3934 rte_pktmbuf_tailroom(ut_params->ibuf));
3936 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3937 /* Append data which is padded to a multiple of */
3938 /* the algorithms block size */
3939 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3940 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3942 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3944 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3946 /* Create KASUMI operation */
3947 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3948 tdata->digest.len, tdata->auth_iv.data,
3950 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3951 tdata->cipher_iv.data, tdata->cipher_iv.len,
3952 tdata->validCipherLenInBits.len,
3954 tdata->validAuthLenInBits.len,
3960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3963 ut_params->obuf = ut_params->op->sym->m_src;
3964 if (ut_params->obuf)
3965 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3967 ciphertext = plaintext;
3969 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3970 + plaintext_pad_len;
3973 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3975 tdata->ciphertext.data,
3976 tdata->validCipherLenInBits.len,
3977 "KASUMI Ciphertext data not as expected");
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3983 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3984 "KASUMI Generated auth tag not as expected");
3989 test_zuc_encryption(const struct wireless_test_data *tdata)
3991 struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 struct crypto_unittest_params *ut_params = &unittest_params;
3995 uint8_t *plaintext, *ciphertext;
3996 unsigned plaintext_pad_len;
3997 unsigned plaintext_len;
3999 struct rte_cryptodev_sym_capability_idx cap_idx;
4001 /* Check if device supports ZUC EEA3 */
4002 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4003 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4005 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4009 /* Create ZUC session */
4010 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4011 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4012 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4013 tdata->key.data, tdata->key.len,
4014 tdata->cipher_iv.len);
4018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4020 /* Clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4025 /* Append data which is padded to a multiple */
4026 /* of the algorithms block size */
4027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4028 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4030 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4032 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4034 /* Create ZUC operation */
4035 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4036 tdata->cipher_iv.len,
4037 tdata->plaintext.len,
4042 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4044 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4046 ut_params->obuf = ut_params->op->sym->m_dst;
4047 if (ut_params->obuf)
4048 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4050 ciphertext = plaintext;
4052 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4055 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4057 tdata->ciphertext.data,
4058 tdata->validCipherLenInBits.len,
4059 "ZUC Ciphertext data not as expected");
4064 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4066 struct crypto_testsuite_params *ts_params = &testsuite_params;
4067 struct crypto_unittest_params *ut_params = &unittest_params;
4071 unsigned int plaintext_pad_len;
4072 unsigned int plaintext_len;
4073 const uint8_t *ciphertext;
4074 uint8_t ciphertext_buffer[2048];
4075 struct rte_cryptodev_info dev_info;
4077 struct rte_cryptodev_sym_capability_idx cap_idx;
4079 /* Check if device supports ZUC EEA3 */
4080 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4081 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4083 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4088 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4089 printf("Device doesn't support scatter-gather. "
4094 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4096 /* Append data which is padded to a multiple */
4097 /* of the algorithms block size */
4098 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4100 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4101 plaintext_pad_len, 10, 0);
4103 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4104 tdata->plaintext.data);
4106 /* Create ZUC session */
4107 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4108 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4109 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4110 tdata->key.data, tdata->key.len,
4111 tdata->cipher_iv.len);
4115 /* Clear mbuf payload */
4117 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4119 /* Create ZUC operation */
4120 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121 tdata->cipher_iv.len, tdata->plaintext.len,
4126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4130 ut_params->obuf = ut_params->op->sym->m_dst;
4131 if (ut_params->obuf)
4132 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4133 0, plaintext_len, ciphertext_buffer);
4135 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4136 0, plaintext_len, ciphertext_buffer);
4139 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4142 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4144 tdata->ciphertext.data,
4145 tdata->validCipherLenInBits.len,
4146 "ZUC Ciphertext data not as expected");
4152 test_zuc_authentication(const struct wireless_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4158 unsigned plaintext_pad_len;
4159 unsigned plaintext_len;
4162 struct rte_cryptodev_sym_capability_idx cap_idx;
4164 /* Check if device supports ZUC EIA3 */
4165 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4166 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4168 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4172 /* Create ZUC session */
4173 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4174 tdata->key.data, tdata->key.len,
4175 tdata->auth_iv.len, tdata->digest.len,
4176 RTE_CRYPTO_AUTH_OP_GENERATE,
4177 RTE_CRYPTO_AUTH_ZUC_EIA3);
4181 /* alloc mbuf and set payload */
4182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4185 rte_pktmbuf_tailroom(ut_params->ibuf));
4187 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4188 /* Append data which is padded to a multiple of */
4189 /* the algorithms block size */
4190 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4191 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4193 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4195 /* Create ZUC operation */
4196 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4197 tdata->auth_iv.data, tdata->auth_iv.len,
4198 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4199 tdata->validAuthLenInBits.len,
4204 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4206 ut_params->obuf = ut_params->op->sym->m_src;
4207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4208 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4209 + plaintext_pad_len;
4212 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4215 DIGEST_BYTE_LENGTH_KASUMI_F9,
4216 "ZUC Generated auth tag not as expected");
4222 test_kasumi_encryption_test_case_1(void)
4224 return test_kasumi_encryption(&kasumi_test_case_1);
4228 test_kasumi_encryption_test_case_1_sgl(void)
4230 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4234 test_kasumi_encryption_test_case_1_oop(void)
4236 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4240 test_kasumi_encryption_test_case_1_oop_sgl(void)
4242 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4246 test_kasumi_encryption_test_case_2(void)
4248 return test_kasumi_encryption(&kasumi_test_case_2);
4252 test_kasumi_encryption_test_case_3(void)
4254 return test_kasumi_encryption(&kasumi_test_case_3);
4258 test_kasumi_encryption_test_case_4(void)
4260 return test_kasumi_encryption(&kasumi_test_case_4);
4264 test_kasumi_encryption_test_case_5(void)
4266 return test_kasumi_encryption(&kasumi_test_case_5);
4270 test_kasumi_decryption_test_case_1(void)
4272 return test_kasumi_decryption(&kasumi_test_case_1);
4276 test_kasumi_decryption_test_case_1_oop(void)
4278 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4282 test_kasumi_decryption_test_case_2(void)
4284 return test_kasumi_decryption(&kasumi_test_case_2);
4288 test_kasumi_decryption_test_case_3(void)
4290 return test_kasumi_decryption(&kasumi_test_case_3);
4294 test_kasumi_decryption_test_case_4(void)
4296 return test_kasumi_decryption(&kasumi_test_case_4);
4300 test_kasumi_decryption_test_case_5(void)
4302 return test_kasumi_decryption(&kasumi_test_case_5);
4305 test_snow3g_encryption_test_case_1(void)
4307 return test_snow3g_encryption(&snow3g_test_case_1);
4311 test_snow3g_encryption_test_case_1_oop(void)
4313 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4317 test_snow3g_encryption_test_case_1_oop_sgl(void)
4319 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4324 test_snow3g_encryption_test_case_1_offset_oop(void)
4326 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4330 test_snow3g_encryption_test_case_2(void)
4332 return test_snow3g_encryption(&snow3g_test_case_2);
4336 test_snow3g_encryption_test_case_3(void)
4338 return test_snow3g_encryption(&snow3g_test_case_3);
4342 test_snow3g_encryption_test_case_4(void)
4344 return test_snow3g_encryption(&snow3g_test_case_4);
4348 test_snow3g_encryption_test_case_5(void)
4350 return test_snow3g_encryption(&snow3g_test_case_5);
4354 test_snow3g_decryption_test_case_1(void)
4356 return test_snow3g_decryption(&snow3g_test_case_1);
4360 test_snow3g_decryption_test_case_1_oop(void)
4362 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4366 test_snow3g_decryption_test_case_2(void)
4368 return test_snow3g_decryption(&snow3g_test_case_2);
4372 test_snow3g_decryption_test_case_3(void)
4374 return test_snow3g_decryption(&snow3g_test_case_3);
4378 test_snow3g_decryption_test_case_4(void)
4380 return test_snow3g_decryption(&snow3g_test_case_4);
4384 test_snow3g_decryption_test_case_5(void)
4386 return test_snow3g_decryption(&snow3g_test_case_5);
4389 test_snow3g_cipher_auth_test_case_1(void)
4391 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4395 test_snow3g_auth_cipher_test_case_1(void)
4397 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4401 test_kasumi_auth_cipher_test_case_1(void)
4403 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4407 test_kasumi_cipher_auth_test_case_1(void)
4409 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4413 test_zuc_encryption_test_case_1(void)
4415 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4419 test_zuc_encryption_test_case_2(void)
4421 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4425 test_zuc_encryption_test_case_3(void)
4427 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4431 test_zuc_encryption_test_case_4(void)
4433 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4437 test_zuc_encryption_test_case_5(void)
4439 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4443 test_zuc_encryption_test_case_6_sgl(void)
4445 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4449 test_zuc_hash_generate_test_case_1(void)
4451 return test_zuc_authentication(&zuc_test_case_auth_1b);
4455 test_zuc_hash_generate_test_case_2(void)
4457 return test_zuc_authentication(&zuc_test_case_auth_90b);
4461 test_zuc_hash_generate_test_case_3(void)
4463 return test_zuc_authentication(&zuc_test_case_auth_577b);
4467 test_zuc_hash_generate_test_case_4(void)
4469 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4473 test_zuc_hash_generate_test_case_5(void)
4475 return test_zuc_authentication(&zuc_test_auth_5670b);
4479 test_zuc_hash_generate_test_case_6(void)
4481 return test_zuc_authentication(&zuc_test_case_auth_128b);
4485 test_zuc_hash_generate_test_case_7(void)
4487 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4491 test_zuc_hash_generate_test_case_8(void)
4493 return test_zuc_authentication(&zuc_test_case_auth_584b);
4497 test_zuc_cipher_auth_test_case_1(void)
4499 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4503 test_zuc_cipher_auth_test_case_2(void)
4505 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4509 test_3DES_chain_qat_all(void)
4511 struct crypto_testsuite_params *ts_params = &testsuite_params;
4514 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4515 ts_params->op_mpool, ts_params->valid_devs[0],
4516 RTE_CRYPTODEV_QAT_SYM_PMD,
4517 BLKCIPHER_3DES_CHAIN_TYPE);
4519 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4521 return TEST_SUCCESS;
4525 test_DES_cipheronly_qat_all(void)
4527 struct crypto_testsuite_params *ts_params = &testsuite_params;
4530 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4531 ts_params->op_mpool, ts_params->valid_devs[0],
4532 RTE_CRYPTODEV_QAT_SYM_PMD,
4533 BLKCIPHER_DES_CIPHERONLY_TYPE);
4535 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4537 return TEST_SUCCESS;
4541 test_DES_docsis_openssl_all(void)
4543 struct crypto_testsuite_params *ts_params = &testsuite_params;
4546 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4547 ts_params->op_mpool, ts_params->valid_devs[0],
4548 RTE_CRYPTODEV_OPENSSL_PMD,
4549 BLKCIPHER_DES_DOCSIS_TYPE);
4551 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4553 return TEST_SUCCESS;
4557 test_3DES_chain_dpaa2_sec_all(void)
4559 struct crypto_testsuite_params *ts_params = &testsuite_params;
4562 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4563 ts_params->op_mpool, ts_params->valid_devs[0],
4564 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4565 BLKCIPHER_3DES_CHAIN_TYPE);
4567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4569 return TEST_SUCCESS;
4573 test_3DES_cipheronly_dpaa2_sec_all(void)
4575 struct crypto_testsuite_params *ts_params = &testsuite_params;
4578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4579 ts_params->op_mpool, ts_params->valid_devs[0],
4580 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4581 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4583 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4585 return TEST_SUCCESS;
4589 test_3DES_cipheronly_qat_all(void)
4591 struct crypto_testsuite_params *ts_params = &testsuite_params;
4594 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4595 ts_params->op_mpool, ts_params->valid_devs[0],
4596 RTE_CRYPTODEV_QAT_SYM_PMD,
4597 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4599 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4601 return TEST_SUCCESS;
4605 test_3DES_chain_openssl_all(void)
4607 struct crypto_testsuite_params *ts_params = &testsuite_params;
4610 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4611 ts_params->op_mpool, ts_params->valid_devs[0],
4612 RTE_CRYPTODEV_OPENSSL_PMD,
4613 BLKCIPHER_3DES_CHAIN_TYPE);
4615 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4617 return TEST_SUCCESS;
4621 test_3DES_cipheronly_openssl_all(void)
4623 struct crypto_testsuite_params *ts_params = &testsuite_params;
4626 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4627 ts_params->op_mpool, ts_params->valid_devs[0],
4628 RTE_CRYPTODEV_OPENSSL_PMD,
4629 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4631 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4633 return TEST_SUCCESS;
4636 /* ***** AES-GCM Tests ***** */
4639 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4640 const uint8_t *key, const uint8_t key_len,
4641 const uint8_t aad_len, const uint8_t auth_len,
4643 enum rte_crypto_auth_operation auth_op)
4645 uint8_t cipher_key[key_len];
4647 struct crypto_unittest_params *ut_params = &unittest_params;
4649 memcpy(cipher_key, key, key_len);
4651 /* Setup Cipher Parameters */
4652 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4653 ut_params->cipher_xform.next = NULL;
4655 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4656 ut_params->auth_xform.auth.op = auth_op;
4657 ut_params->cipher_xform.cipher.op = op;
4658 ut_params->cipher_xform.cipher.key.data = cipher_key;
4659 ut_params->cipher_xform.cipher.key.length = key_len;
4660 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
4661 ut_params->cipher_xform.cipher.iv.length = iv_len;
4663 TEST_HEXDUMP(stdout, "key:", key, key_len);
4665 /* Setup Authentication Parameters */
4666 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4667 ut_params->auth_xform.next = NULL;
4669 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4671 ut_params->auth_xform.auth.digest_length = auth_len;
4672 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4673 ut_params->auth_xform.auth.key.length = 0;
4674 ut_params->auth_xform.auth.key.data = NULL;
4676 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4677 ut_params->cipher_xform.next = &ut_params->auth_xform;
4679 /* Create Crypto session*/
4680 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4681 &ut_params->cipher_xform);
4682 } else {/* Create Crypto session*/
4683 ut_params->auth_xform.next = &ut_params->cipher_xform;
4684 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4685 &ut_params->auth_xform);
4688 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4694 create_gcm_xforms(struct rte_crypto_op *op,
4695 enum rte_crypto_cipher_operation cipher_op,
4696 uint8_t *key, const uint8_t key_len,
4697 const uint8_t aad_len, const uint8_t auth_len,
4699 enum rte_crypto_auth_operation auth_op)
4701 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4702 "failed to allocate space for crypto transforms");
4704 struct rte_crypto_sym_op *sym_op = op->sym;
4706 /* Setup Cipher Parameters */
4707 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4708 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4709 sym_op->xform->cipher.op = cipher_op;
4710 sym_op->xform->cipher.key.data = key;
4711 sym_op->xform->cipher.key.length = key_len;
4712 sym_op->xform->cipher.iv.offset = IV_OFFSET;
4713 sym_op->xform->cipher.iv.length = iv_len;
4715 TEST_HEXDUMP(stdout, "key:", key, key_len);
4717 /* Setup Authentication Parameters */
4718 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4719 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4720 sym_op->xform->next->auth.op = auth_op;
4721 sym_op->xform->next->auth.digest_length = auth_len;
4722 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4723 sym_op->xform->next->auth.key.length = 0;
4724 sym_op->xform->next->auth.key.data = NULL;
4725 sym_op->xform->next->next = NULL;
4731 create_gcm_operation(enum rte_crypto_cipher_operation op,
4732 const struct gcm_test_data *tdata)
4734 struct crypto_testsuite_params *ts_params = &testsuite_params;
4735 struct crypto_unittest_params *ut_params = &unittest_params;
4737 uint8_t *plaintext, *ciphertext;
4738 unsigned int aad_pad_len, plaintext_pad_len;
4740 /* Generate Crypto op data structure */
4741 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4742 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4743 TEST_ASSERT_NOT_NULL(ut_params->op,
4744 "Failed to allocate symmetric crypto operation struct");
4746 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4748 /* Append aad data */
4749 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4750 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4752 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4753 "no room to append aad");
4755 sym_op->auth.aad.length = tdata->aad.len;
4756 sym_op->auth.aad.phys_addr =
4757 rte_pktmbuf_mtophys(ut_params->ibuf);
4758 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4759 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4760 sym_op->auth.aad.length);
4762 /* Append IV at the end of the crypto operation*/
4763 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4764 uint8_t *, IV_OFFSET);
4766 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4767 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4770 /* Append plaintext/ciphertext */
4771 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4772 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4775 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4777 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4778 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4779 tdata->plaintext.len);
4781 if (ut_params->obuf) {
4782 ciphertext = (uint8_t *)rte_pktmbuf_append(
4784 plaintext_pad_len + aad_pad_len);
4785 TEST_ASSERT_NOT_NULL(ciphertext,
4786 "no room to append ciphertext");
4788 memset(ciphertext + aad_pad_len, 0,
4789 tdata->ciphertext.len);
4792 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4793 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4795 TEST_ASSERT_NOT_NULL(ciphertext,
4796 "no room to append ciphertext");
4798 memcpy(ciphertext, tdata->ciphertext.data,
4799 tdata->ciphertext.len);
4800 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4801 tdata->ciphertext.len);
4803 if (ut_params->obuf) {
4804 plaintext = (uint8_t *)rte_pktmbuf_append(
4806 plaintext_pad_len + aad_pad_len);
4807 TEST_ASSERT_NOT_NULL(plaintext,
4808 "no room to append plaintext");
4810 memset(plaintext + aad_pad_len, 0,
4811 tdata->plaintext.len);
4815 /* Append digest data */
4816 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4817 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4818 ut_params->obuf ? ut_params->obuf :
4820 tdata->auth_tag.len);
4821 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4822 "no room to append digest");
4823 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4824 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4825 ut_params->obuf ? ut_params->obuf :
4829 sym_op->auth.digest.length = tdata->auth_tag.len;
4831 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4832 ut_params->ibuf, tdata->auth_tag.len);
4833 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4834 "no room to append digest");
4835 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4837 plaintext_pad_len + aad_pad_len);
4838 sym_op->auth.digest.length = tdata->auth_tag.len;
4840 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4841 tdata->auth_tag.len);
4842 TEST_HEXDUMP(stdout, "digest:",
4843 sym_op->auth.digest.data,
4844 sym_op->auth.digest.length);
4847 sym_op->cipher.data.length = tdata->plaintext.len;
4848 sym_op->cipher.data.offset = aad_pad_len;
4850 sym_op->auth.data.length = tdata->plaintext.len;
4851 sym_op->auth.data.offset = aad_pad_len;
4857 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4859 struct crypto_testsuite_params *ts_params = &testsuite_params;
4860 struct crypto_unittest_params *ut_params = &unittest_params;
4863 uint8_t *ciphertext, *auth_tag;
4864 uint16_t plaintext_pad_len;
4867 /* Create GCM session */
4868 retval = create_gcm_session(ts_params->valid_devs[0],
4869 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4870 tdata->key.data, tdata->key.len,
4871 tdata->aad.len, tdata->auth_tag.len,
4873 RTE_CRYPTO_AUTH_OP_GENERATE);
4877 if (tdata->aad.len > MBUF_SIZE) {
4878 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4879 /* Populate full size of add data */
4880 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4881 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4885 /* clear mbuf payload */
4886 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4887 rte_pktmbuf_tailroom(ut_params->ibuf));
4889 /* Create GCM operation */
4890 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4894 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4896 ut_params->op->sym->m_src = ut_params->ibuf;
4898 /* Process crypto operation */
4899 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4900 ut_params->op), "failed to process sym crypto op");
4902 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4903 "crypto op processing failed");
4905 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4907 if (ut_params->op->sym->m_dst) {
4908 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4910 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4911 uint8_t *, plaintext_pad_len);
4913 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4915 ut_params->op->sym->cipher.data.offset);
4916 auth_tag = ciphertext + plaintext_pad_len;
4919 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4920 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4923 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4925 tdata->ciphertext.data,
4926 tdata->ciphertext.len,
4927 "GCM Ciphertext data not as expected");
4929 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4931 tdata->auth_tag.data,
4932 tdata->auth_tag.len,
4933 "GCM Generated auth tag not as expected");
4940 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4942 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4946 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4948 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4952 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4954 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4958 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4960 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4964 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4966 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4970 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4972 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4976 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4978 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4982 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4984 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4988 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4990 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4994 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4996 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5000 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5002 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5006 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5008 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5012 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5014 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5018 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5020 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5024 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5026 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5030 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5032 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5036 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5038 struct crypto_testsuite_params *ts_params = &testsuite_params;
5039 struct crypto_unittest_params *ut_params = &unittest_params;
5045 /* Create GCM session */
5046 retval = create_gcm_session(ts_params->valid_devs[0],
5047 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5048 tdata->key.data, tdata->key.len,
5049 tdata->aad.len, tdata->auth_tag.len,
5051 RTE_CRYPTO_AUTH_OP_VERIFY);
5055 /* alloc mbuf and set payload */
5056 if (tdata->aad.len > MBUF_SIZE) {
5057 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5058 /* Populate full size of add data */
5059 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5060 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5062 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5064 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5065 rte_pktmbuf_tailroom(ut_params->ibuf));
5067 /* Create GCM operation */
5068 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5072 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5074 ut_params->op->sym->m_src = ut_params->ibuf;
5076 /* Process crypto operation */
5077 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5078 ut_params->op), "failed to process sym crypto op");
5080 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5081 "crypto op processing failed");
5083 if (ut_params->op->sym->m_dst)
5084 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5087 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5089 ut_params->op->sym->cipher.data.offset);
5091 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5094 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5096 tdata->plaintext.data,
5097 tdata->plaintext.len,
5098 "GCM plaintext data not as expected");
5100 TEST_ASSERT_EQUAL(ut_params->op->status,
5101 RTE_CRYPTO_OP_STATUS_SUCCESS,
5102 "GCM authentication failed");
5107 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5109 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5113 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5115 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5119 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5121 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5125 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5127 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5131 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5133 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5137 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5139 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5143 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5145 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5149 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5151 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5155 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5157 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5161 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5163 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5167 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5169 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5173 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5175 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5179 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5181 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5185 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5187 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5191 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5193 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5197 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5199 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5203 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5205 struct crypto_testsuite_params *ts_params = &testsuite_params;
5206 struct crypto_unittest_params *ut_params = &unittest_params;
5209 uint8_t *ciphertext, *auth_tag;
5210 uint16_t plaintext_pad_len;
5212 /* Create GCM session */
5213 retval = create_gcm_session(ts_params->valid_devs[0],
5214 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5215 tdata->key.data, tdata->key.len,
5216 tdata->aad.len, tdata->auth_tag.len,
5218 RTE_CRYPTO_AUTH_OP_GENERATE);
5222 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5223 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5225 /* clear mbuf payload */
5226 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5227 rte_pktmbuf_tailroom(ut_params->ibuf));
5228 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5229 rte_pktmbuf_tailroom(ut_params->obuf));
5231 /* Create GCM operation */
5232 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5236 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5238 ut_params->op->sym->m_src = ut_params->ibuf;
5239 ut_params->op->sym->m_dst = ut_params->obuf;
5241 /* Process crypto operation */
5242 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5243 ut_params->op), "failed to process sym crypto op");
5245 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5246 "crypto op processing failed");
5248 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5250 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5251 ut_params->op->sym->cipher.data.offset);
5252 auth_tag = ciphertext + plaintext_pad_len;
5254 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5255 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5260 tdata->ciphertext.data,
5261 tdata->ciphertext.len,
5262 "GCM Ciphertext data not as expected");
5264 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5266 tdata->auth_tag.data,
5267 tdata->auth_tag.len,
5268 "GCM Generated auth tag not as expected");
5275 test_mb_AES_GCM_authenticated_encryption_oop(void)
5277 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5281 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5283 struct crypto_testsuite_params *ts_params = &testsuite_params;
5284 struct crypto_unittest_params *ut_params = &unittest_params;
5289 /* Create GCM session */
5290 retval = create_gcm_session(ts_params->valid_devs[0],
5291 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5292 tdata->key.data, tdata->key.len,
5293 tdata->aad.len, tdata->auth_tag.len,
5295 RTE_CRYPTO_AUTH_OP_VERIFY);
5299 /* alloc mbuf and set payload */
5300 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5301 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5303 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5304 rte_pktmbuf_tailroom(ut_params->ibuf));
5305 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5306 rte_pktmbuf_tailroom(ut_params->obuf));
5308 /* Create GCM operation */
5309 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5315 ut_params->op->sym->m_src = ut_params->ibuf;
5316 ut_params->op->sym->m_dst = ut_params->obuf;
5318 /* Process crypto operation */
5319 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5320 ut_params->op), "failed to process sym crypto op");
5322 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5323 "crypto op processing failed");
5325 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5326 ut_params->op->sym->cipher.data.offset);
5328 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5331 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5333 tdata->plaintext.data,
5334 tdata->plaintext.len,
5335 "GCM plaintext data not as expected");
5337 TEST_ASSERT_EQUAL(ut_params->op->status,
5338 RTE_CRYPTO_OP_STATUS_SUCCESS,
5339 "GCM authentication failed");
5344 test_mb_AES_GCM_authenticated_decryption_oop(void)
5346 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5350 test_AES_GCM_authenticated_encryption_sessionless(
5351 const struct gcm_test_data *tdata)
5353 struct crypto_testsuite_params *ts_params = &testsuite_params;
5354 struct crypto_unittest_params *ut_params = &unittest_params;
5357 uint8_t *ciphertext, *auth_tag;
5358 uint16_t plaintext_pad_len;
5359 uint8_t key[tdata->key.len + 1];
5361 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5363 /* clear mbuf payload */
5364 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5365 rte_pktmbuf_tailroom(ut_params->ibuf));
5367 /* Create GCM operation */
5368 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5372 /* Create GCM xforms */
5373 memcpy(key, tdata->key.data, tdata->key.len);
5374 retval = create_gcm_xforms(ut_params->op,
5375 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5376 key, tdata->key.len,
5377 tdata->aad.len, tdata->auth_tag.len,
5379 RTE_CRYPTO_AUTH_OP_GENERATE);
5383 ut_params->op->sym->m_src = ut_params->ibuf;
5385 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5386 RTE_CRYPTO_OP_SESSIONLESS,
5387 "crypto op session type not sessionless");
5389 /* Process crypto operation */
5390 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5391 ut_params->op), "failed to process sym crypto op");
5393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5396 "crypto op status not success");
5398 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5400 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5401 ut_params->op->sym->cipher.data.offset);
5402 auth_tag = ciphertext + plaintext_pad_len;
5404 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5405 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5408 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5410 tdata->ciphertext.data,
5411 tdata->ciphertext.len,
5412 "GCM Ciphertext data not as expected");
5414 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5416 tdata->auth_tag.data,
5417 tdata->auth_tag.len,
5418 "GCM Generated auth tag not as expected");
5425 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5427 return test_AES_GCM_authenticated_encryption_sessionless(
5432 test_AES_GCM_authenticated_decryption_sessionless(
5433 const struct gcm_test_data *tdata)
5435 struct crypto_testsuite_params *ts_params = &testsuite_params;
5436 struct crypto_unittest_params *ut_params = &unittest_params;
5440 uint8_t key[tdata->key.len + 1];
5442 /* alloc mbuf and set payload */
5443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5445 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5446 rte_pktmbuf_tailroom(ut_params->ibuf));
5448 /* Create GCM operation */
5449 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5453 /* Create GCM xforms */
5454 memcpy(key, tdata->key.data, tdata->key.len);
5455 retval = create_gcm_xforms(ut_params->op,
5456 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5457 key, tdata->key.len,
5458 tdata->aad.len, tdata->auth_tag.len,
5460 RTE_CRYPTO_AUTH_OP_VERIFY);
5464 ut_params->op->sym->m_src = ut_params->ibuf;
5466 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5467 RTE_CRYPTO_OP_SESSIONLESS,
5468 "crypto op session type not sessionless");
5470 /* Process crypto operation */
5471 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5472 ut_params->op), "failed to process sym crypto op");
5474 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5476 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5477 "crypto op status not success");
5479 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5480 ut_params->op->sym->cipher.data.offset);
5482 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5487 tdata->plaintext.data,
5488 tdata->plaintext.len,
5489 "GCM plaintext data not as expected");
5491 TEST_ASSERT_EQUAL(ut_params->op->status,
5492 RTE_CRYPTO_OP_STATUS_SUCCESS,
5493 "GCM authentication failed");
5498 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5500 return test_AES_GCM_authenticated_decryption_sessionless(
5507 struct crypto_testsuite_params *ts_params = &testsuite_params;
5508 struct rte_cryptodev_stats stats;
5509 struct rte_cryptodev *dev;
5510 cryptodev_stats_get_t temp_pfn;
5512 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5513 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5514 &stats) == -ENODEV),
5515 "rte_cryptodev_stats_get invalid dev failed");
5516 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5517 "rte_cryptodev_stats_get invalid Param failed");
5518 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5519 temp_pfn = dev->dev_ops->stats_get;
5520 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5521 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5523 "rte_cryptodev_stats_get invalid Param failed");
5524 dev->dev_ops->stats_get = temp_pfn;
5526 /* Test expected values */
5528 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5530 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5532 "rte_cryptodev_stats_get failed");
5533 TEST_ASSERT((stats.enqueued_count == 1),
5534 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5535 TEST_ASSERT((stats.dequeued_count == 1),
5536 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5537 TEST_ASSERT((stats.enqueue_err_count == 0),
5538 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5539 TEST_ASSERT((stats.dequeue_err_count == 0),
5540 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5542 /* invalid device but should ignore and not reset device stats*/
5543 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5544 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5546 "rte_cryptodev_stats_get failed");
5547 TEST_ASSERT((stats.enqueued_count == 1),
5548 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5550 /* check that a valid reset clears stats */
5551 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5552 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5554 "rte_cryptodev_stats_get failed");
5555 TEST_ASSERT((stats.enqueued_count == 0),
5556 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5557 TEST_ASSERT((stats.dequeued_count == 0),
5558 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5560 return TEST_SUCCESS;
5563 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5564 struct crypto_unittest_params *ut_params,
5565 enum rte_crypto_auth_operation op,
5566 const struct HMAC_MD5_vector *test_case)
5570 memcpy(key, test_case->key.data, test_case->key.len);
5572 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5573 ut_params->auth_xform.next = NULL;
5574 ut_params->auth_xform.auth.op = op;
5576 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5578 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5579 ut_params->auth_xform.auth.add_auth_data_length = 0;
5580 ut_params->auth_xform.auth.key.length = test_case->key.len;
5581 ut_params->auth_xform.auth.key.data = key;
5583 ut_params->sess = rte_cryptodev_sym_session_create(
5584 ts_params->valid_devs[0], &ut_params->auth_xform);
5586 if (ut_params->sess == NULL)
5589 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5591 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5592 rte_pktmbuf_tailroom(ut_params->ibuf));
5597 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5598 const struct HMAC_MD5_vector *test_case,
5599 uint8_t **plaintext)
5601 uint16_t plaintext_pad_len;
5603 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5605 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5608 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5610 memcpy(*plaintext, test_case->plaintext.data,
5611 test_case->plaintext.len);
5613 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5614 ut_params->ibuf, MD5_DIGEST_LEN);
5615 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5616 "no room to append digest");
5617 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5618 ut_params->ibuf, plaintext_pad_len);
5619 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5621 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5622 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5623 test_case->auth_tag.len);
5626 sym_op->auth.data.offset = 0;
5627 sym_op->auth.data.length = test_case->plaintext.len;
5629 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5630 ut_params->op->sym->m_src = ut_params->ibuf;
5636 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5638 uint16_t plaintext_pad_len;
5639 uint8_t *plaintext, *auth_tag;
5641 struct crypto_testsuite_params *ts_params = &testsuite_params;
5642 struct crypto_unittest_params *ut_params = &unittest_params;
5644 if (MD5_HMAC_create_session(ts_params, ut_params,
5645 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5648 /* Generate Crypto op data structure */
5649 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5650 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5651 TEST_ASSERT_NOT_NULL(ut_params->op,
5652 "Failed to allocate symmetric crypto operation struct");
5654 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5657 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5660 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5661 ut_params->op), "failed to process sym crypto op");
5663 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5664 "crypto op processing failed");
5666 if (ut_params->op->sym->m_dst) {
5667 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5668 uint8_t *, plaintext_pad_len);
5670 auth_tag = plaintext + plaintext_pad_len;
5673 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5675 test_case->auth_tag.data,
5676 test_case->auth_tag.len,
5677 "HMAC_MD5 generated tag not as expected");
5679 return TEST_SUCCESS;
5683 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5687 struct crypto_testsuite_params *ts_params = &testsuite_params;
5688 struct crypto_unittest_params *ut_params = &unittest_params;
5690 if (MD5_HMAC_create_session(ts_params, ut_params,
5691 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5695 /* Generate Crypto op data structure */
5696 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5697 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5698 TEST_ASSERT_NOT_NULL(ut_params->op,
5699 "Failed to allocate symmetric crypto operation struct");
5701 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5704 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5705 ut_params->op), "failed to process sym crypto op");
5707 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5708 "HMAC_MD5 crypto op processing failed");
5710 return TEST_SUCCESS;
5714 test_MD5_HMAC_generate_case_1(void)
5716 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5720 test_MD5_HMAC_verify_case_1(void)
5722 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5726 test_MD5_HMAC_generate_case_2(void)
5728 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5732 test_MD5_HMAC_verify_case_2(void)
5734 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5738 test_multi_session(void)
5740 struct crypto_testsuite_params *ts_params = &testsuite_params;
5741 struct crypto_unittest_params *ut_params = &unittest_params;
5743 struct rte_cryptodev_info dev_info;
5744 struct rte_cryptodev_sym_session **sessions;
5748 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5749 aes_cbc_key, hmac_sha512_key);
5752 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5754 sessions = rte_malloc(NULL,
5755 (sizeof(struct rte_cryptodev_sym_session *) *
5756 dev_info.sym.max_nb_sessions) + 1, 0);
5758 /* Create multiple crypto sessions*/
5759 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5760 sessions[i] = rte_cryptodev_sym_session_create(
5761 ts_params->valid_devs[0],
5762 &ut_params->auth_xform);
5763 TEST_ASSERT_NOT_NULL(sessions[i],
5764 "Session creation failed at session number %u",
5767 /* Attempt to send a request on each session */
5768 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5772 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5773 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5775 "Failed to perform decrypt on request number %u.", i);
5776 /* free crypto operation structure */
5778 rte_crypto_op_free(ut_params->op);
5781 * free mbuf - both obuf and ibuf are usually the same,
5782 * so check if they point at the same address is necessary,
5783 * to avoid freeing the mbuf twice.
5785 if (ut_params->obuf) {
5786 rte_pktmbuf_free(ut_params->obuf);
5787 if (ut_params->ibuf == ut_params->obuf)
5788 ut_params->ibuf = 0;
5789 ut_params->obuf = 0;
5791 if (ut_params->ibuf) {
5792 rte_pktmbuf_free(ut_params->ibuf);
5793 ut_params->ibuf = 0;
5797 /* Next session create should fail */
5798 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5799 &ut_params->auth_xform);
5800 TEST_ASSERT_NULL(sessions[i],
5801 "Session creation succeeded unexpectedly!");
5803 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5804 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5809 return TEST_SUCCESS;
5812 struct multi_session_params {
5813 struct crypto_unittest_params ut_params;
5814 uint8_t *cipher_key;
5816 const uint8_t *cipher;
5817 const uint8_t *digest;
5821 #define MB_SESSION_NUMBER 3
5824 test_multi_session_random_usage(void)
5826 struct crypto_testsuite_params *ts_params = &testsuite_params;
5827 struct rte_cryptodev_info dev_info;
5828 struct rte_cryptodev_sym_session **sessions;
5830 struct multi_session_params ut_paramz[] = {
5833 .cipher_key = ms_aes_cbc_key0,
5834 .hmac_key = ms_hmac_key0,
5835 .cipher = ms_aes_cbc_cipher0,
5836 .digest = ms_hmac_digest0,
5837 .iv = ms_aes_cbc_iv0
5840 .cipher_key = ms_aes_cbc_key1,
5841 .hmac_key = ms_hmac_key1,
5842 .cipher = ms_aes_cbc_cipher1,
5843 .digest = ms_hmac_digest1,
5844 .iv = ms_aes_cbc_iv1
5847 .cipher_key = ms_aes_cbc_key2,
5848 .hmac_key = ms_hmac_key2,
5849 .cipher = ms_aes_cbc_cipher2,
5850 .digest = ms_hmac_digest2,
5851 .iv = ms_aes_cbc_iv2
5856 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5858 sessions = rte_malloc(NULL,
5859 (sizeof(struct rte_cryptodev_sym_session *)
5860 * dev_info.sym.max_nb_sessions) + 1, 0);
5862 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5863 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5864 sizeof(struct crypto_unittest_params));
5866 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5867 &ut_paramz[i].ut_params,
5868 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5870 /* Create multiple crypto sessions*/
5871 sessions[i] = rte_cryptodev_sym_session_create(
5872 ts_params->valid_devs[0],
5873 &ut_paramz[i].ut_params.auth_xform);
5875 TEST_ASSERT_NOT_NULL(sessions[i],
5876 "Session creation failed at session number %u",
5882 for (i = 0; i < 40000; i++) {
5884 j = rand() % MB_SESSION_NUMBER;
5886 TEST_ASSERT_SUCCESS(
5887 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5889 &ut_paramz[j].ut_params,
5890 ts_params, ut_paramz[j].cipher,
5891 ut_paramz[j].digest,
5893 "Failed to perform decrypt on request number %u.", i);
5895 if (ut_paramz[j].ut_params.op)
5896 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5899 * free mbuf - both obuf and ibuf are usually the same,
5900 * so check if they point at the same address is necessary,
5901 * to avoid freeing the mbuf twice.
5903 if (ut_paramz[j].ut_params.obuf) {
5904 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5905 if (ut_paramz[j].ut_params.ibuf
5906 == ut_paramz[j].ut_params.obuf)
5907 ut_paramz[j].ut_params.ibuf = 0;
5908 ut_paramz[j].ut_params.obuf = 0;
5910 if (ut_paramz[j].ut_params.ibuf) {
5911 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5912 ut_paramz[j].ut_params.ibuf = 0;
5916 for (i = 0; i < MB_SESSION_NUMBER; i++)
5917 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5922 return TEST_SUCCESS;
5926 test_null_cipher_only_operation(void)
5928 struct crypto_testsuite_params *ts_params = &testsuite_params;
5929 struct crypto_unittest_params *ut_params = &unittest_params;
5931 /* Generate test mbuf data and space for digest */
5932 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5933 catch_22_quote, QUOTE_512_BYTES, 0);
5935 /* Setup Cipher Parameters */
5936 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5937 ut_params->cipher_xform.next = NULL;
5939 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5940 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5942 /* Create Crypto session*/
5943 ut_params->sess = rte_cryptodev_sym_session_create(
5944 ts_params->valid_devs[0], &ut_params->cipher_xform);
5945 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5947 /* Generate Crypto op data structure */
5948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5950 TEST_ASSERT_NOT_NULL(ut_params->op,
5951 "Failed to allocate symmetric crypto operation struct");
5953 /* Set crypto operation data parameters */
5954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5956 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5958 /* set crypto operation source mbuf */
5959 sym_op->m_src = ut_params->ibuf;
5961 sym_op->cipher.data.offset = 0;
5962 sym_op->cipher.data.length = QUOTE_512_BYTES;
5964 /* Process crypto operation */
5965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5967 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5969 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5970 "crypto operation processing failed");
5973 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5974 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5977 "Ciphertext data not as expected");
5979 return TEST_SUCCESS;
5983 test_null_auth_only_operation(void)
5985 struct crypto_testsuite_params *ts_params = &testsuite_params;
5986 struct crypto_unittest_params *ut_params = &unittest_params;
5988 /* Generate test mbuf data and space for digest */
5989 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5990 catch_22_quote, QUOTE_512_BYTES, 0);
5992 /* Setup HMAC Parameters */
5993 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5994 ut_params->auth_xform.next = NULL;
5996 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5997 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5999 /* Create Crypto session*/
6000 ut_params->sess = rte_cryptodev_sym_session_create(
6001 ts_params->valid_devs[0], &ut_params->auth_xform);
6002 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6004 /* Generate Crypto op data structure */
6005 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6006 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6007 TEST_ASSERT_NOT_NULL(ut_params->op,
6008 "Failed to allocate symmetric crypto operation struct");
6010 /* Set crypto operation data parameters */
6011 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6013 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6015 sym_op->m_src = ut_params->ibuf;
6017 sym_op->auth.data.offset = 0;
6018 sym_op->auth.data.length = QUOTE_512_BYTES;
6020 /* Process crypto operation */
6021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6023 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6025 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6026 "crypto operation processing failed");
6028 return TEST_SUCCESS;
6032 test_null_cipher_auth_operation(void)
6034 struct crypto_testsuite_params *ts_params = &testsuite_params;
6035 struct crypto_unittest_params *ut_params = &unittest_params;
6037 /* Generate test mbuf data and space for digest */
6038 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6039 catch_22_quote, QUOTE_512_BYTES, 0);
6041 /* Setup Cipher Parameters */
6042 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6043 ut_params->cipher_xform.next = &ut_params->auth_xform;
6045 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6046 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6048 /* Setup HMAC Parameters */
6049 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6050 ut_params->auth_xform.next = NULL;
6052 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6053 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6055 /* Create Crypto session*/
6056 ut_params->sess = rte_cryptodev_sym_session_create(
6057 ts_params->valid_devs[0], &ut_params->cipher_xform);
6058 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6060 /* Generate Crypto op data structure */
6061 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6062 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6063 TEST_ASSERT_NOT_NULL(ut_params->op,
6064 "Failed to allocate symmetric crypto operation struct");
6066 /* Set crypto operation data parameters */
6067 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6069 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6071 sym_op->m_src = ut_params->ibuf;
6073 sym_op->cipher.data.offset = 0;
6074 sym_op->cipher.data.length = QUOTE_512_BYTES;
6076 sym_op->auth.data.offset = 0;
6077 sym_op->auth.data.length = QUOTE_512_BYTES;
6079 /* Process crypto operation */
6080 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6082 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6084 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6085 "crypto operation processing failed");
6088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6089 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6092 "Ciphertext data not as expected");
6094 return TEST_SUCCESS;
6098 test_null_auth_cipher_operation(void)
6100 struct crypto_testsuite_params *ts_params = &testsuite_params;
6101 struct crypto_unittest_params *ut_params = &unittest_params;
6103 /* Generate test mbuf data and space for digest */
6104 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6105 catch_22_quote, QUOTE_512_BYTES, 0);
6107 /* Setup Cipher Parameters */
6108 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6109 ut_params->cipher_xform.next = NULL;
6111 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6112 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6114 /* Setup HMAC Parameters */
6115 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6116 ut_params->auth_xform.next = &ut_params->cipher_xform;
6118 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6119 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6121 /* Create Crypto session*/
6122 ut_params->sess = rte_cryptodev_sym_session_create(
6123 ts_params->valid_devs[0], &ut_params->cipher_xform);
6124 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6126 /* Generate Crypto op data structure */
6127 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6128 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6129 TEST_ASSERT_NOT_NULL(ut_params->op,
6130 "Failed to allocate symmetric crypto operation struct");
6132 /* Set crypto operation data parameters */
6133 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6135 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6137 sym_op->m_src = ut_params->ibuf;
6139 sym_op->cipher.data.offset = 0;
6140 sym_op->cipher.data.length = QUOTE_512_BYTES;
6142 sym_op->auth.data.offset = 0;
6143 sym_op->auth.data.length = QUOTE_512_BYTES;
6145 /* Process crypto operation */
6146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6148 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6150 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6151 "crypto operation processing failed");
6154 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6155 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6158 "Ciphertext data not as expected");
6160 return TEST_SUCCESS;
6165 test_null_invalid_operation(void)
6167 struct crypto_testsuite_params *ts_params = &testsuite_params;
6168 struct crypto_unittest_params *ut_params = &unittest_params;
6170 /* Setup Cipher Parameters */
6171 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6172 ut_params->cipher_xform.next = NULL;
6174 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6175 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6177 /* Create Crypto session*/
6178 ut_params->sess = rte_cryptodev_sym_session_create(
6179 ts_params->valid_devs[0], &ut_params->cipher_xform);
6180 TEST_ASSERT_NULL(ut_params->sess,
6181 "Session creation succeeded unexpectedly");
6184 /* Setup HMAC Parameters */
6185 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6186 ut_params->auth_xform.next = NULL;
6188 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6189 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6191 /* Create Crypto session*/
6192 ut_params->sess = rte_cryptodev_sym_session_create(
6193 ts_params->valid_devs[0], &ut_params->auth_xform);
6194 TEST_ASSERT_NULL(ut_params->sess,
6195 "Session creation succeeded unexpectedly");
6197 return TEST_SUCCESS;
6201 #define NULL_BURST_LENGTH (32)
6204 test_null_burst_operation(void)
6206 struct crypto_testsuite_params *ts_params = &testsuite_params;
6207 struct crypto_unittest_params *ut_params = &unittest_params;
6209 unsigned i, burst_len = NULL_BURST_LENGTH;
6211 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6212 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6214 /* Setup Cipher Parameters */
6215 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6216 ut_params->cipher_xform.next = &ut_params->auth_xform;
6218 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6219 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6221 /* Setup HMAC Parameters */
6222 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6223 ut_params->auth_xform.next = NULL;
6225 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6226 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6228 /* Create Crypto session*/
6229 ut_params->sess = rte_cryptodev_sym_session_create(
6230 ts_params->valid_devs[0], &ut_params->cipher_xform);
6231 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6233 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6234 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6235 burst_len, "failed to generate burst of crypto ops");
6237 /* Generate an operation for each mbuf in burst */
6238 for (i = 0; i < burst_len; i++) {
6239 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6241 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6243 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6247 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6249 burst[i]->sym->m_src = m;
6252 /* Process crypto operation */
6253 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6254 0, burst, burst_len),
6256 "Error enqueuing burst");
6258 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6259 0, burst_dequeued, burst_len),
6261 "Error dequeuing burst");
6264 for (i = 0; i < burst_len; i++) {
6266 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6267 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6269 "data not as expected");
6271 rte_pktmbuf_free(burst[i]->sym->m_src);
6272 rte_crypto_op_free(burst[i]);
6275 return TEST_SUCCESS;
6279 generate_gmac_large_plaintext(uint8_t *data)
6283 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6284 memcpy(&data[i], &data[0], 32);
6288 create_gmac_operation(enum rte_crypto_auth_operation op,
6289 const struct gmac_test_data *tdata)
6291 struct crypto_testsuite_params *ts_params = &testsuite_params;
6292 struct crypto_unittest_params *ut_params = &unittest_params;
6293 struct rte_crypto_sym_op *sym_op;
6295 unsigned aad_pad_len;
6297 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6300 * Runtime generate the large plain text instead of use hard code
6301 * plain text vector. It is done to avoid create huge source file
6302 * with the test vector.
6304 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6305 generate_gmac_large_plaintext(tdata->aad.data);
6307 /* Generate Crypto op data structure */
6308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6310 TEST_ASSERT_NOT_NULL(ut_params->op,
6311 "Failed to allocate symmetric crypto operation struct");
6313 sym_op = ut_params->op->sym;
6314 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6316 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6317 "no room to append aad");
6319 sym_op->auth.aad.length = tdata->aad.len;
6320 sym_op->auth.aad.phys_addr =
6321 rte_pktmbuf_mtophys(ut_params->ibuf);
6322 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6324 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6325 ut_params->ibuf, tdata->gmac_tag.len);
6326 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6327 "no room to append digest");
6329 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6330 ut_params->ibuf, aad_pad_len);
6331 sym_op->auth.digest.length = tdata->gmac_tag.len;
6333 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6334 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6335 tdata->gmac_tag.len);
6336 TEST_HEXDUMP(stdout, "digest:",
6337 sym_op->auth.digest.data,
6338 sym_op->auth.digest.length);
6341 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6342 uint8_t *, IV_OFFSET);
6344 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6346 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6348 sym_op->cipher.data.length = 0;
6349 sym_op->cipher.data.offset = 0;
6351 sym_op->auth.data.offset = 0;
6352 sym_op->auth.data.length = 0;
6357 static int create_gmac_session(uint8_t dev_id,
6358 enum rte_crypto_cipher_operation op,
6359 const struct gmac_test_data *tdata,
6360 enum rte_crypto_auth_operation auth_op)
6362 uint8_t cipher_key[tdata->key.len];
6364 struct crypto_unittest_params *ut_params = &unittest_params;
6366 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6368 /* For GMAC we setup cipher parameters */
6369 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6370 ut_params->cipher_xform.next = NULL;
6371 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6372 ut_params->cipher_xform.cipher.op = op;
6373 ut_params->cipher_xform.cipher.key.data = cipher_key;
6374 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6375 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6376 ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
6378 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6379 ut_params->auth_xform.next = NULL;
6381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6382 ut_params->auth_xform.auth.op = auth_op;
6383 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6384 ut_params->auth_xform.auth.add_auth_data_length = 0;
6385 ut_params->auth_xform.auth.key.length = 0;
6386 ut_params->auth_xform.auth.key.data = NULL;
6388 ut_params->cipher_xform.next = &ut_params->auth_xform;
6390 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6391 &ut_params->cipher_xform);
6393 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6399 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6401 struct crypto_testsuite_params *ts_params = &testsuite_params;
6402 struct crypto_unittest_params *ut_params = &unittest_params;
6406 uint8_t *auth_tag, *p;
6407 uint16_t aad_pad_len;
6409 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6410 "No GMAC length in the source data");
6412 retval = create_gmac_session(ts_params->valid_devs[0],
6413 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6414 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6419 if (tdata->aad.len > MBUF_SIZE)
6420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6422 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6423 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6424 "Failed to allocate input buffer in mempool");
6426 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6427 rte_pktmbuf_tailroom(ut_params->ibuf));
6429 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6431 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6433 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6439 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6441 ut_params->op->sym->m_src = ut_params->ibuf;
6443 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6444 ut_params->op), "failed to process sym crypto op");
6446 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6447 "crypto op processing failed");
6449 if (ut_params->op->sym->m_dst) {
6450 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6451 uint8_t *, aad_pad_len);
6453 auth_tag = p + aad_pad_len;
6456 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6458 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6460 tdata->gmac_tag.data,
6461 tdata->gmac_tag.len,
6462 "GMAC Generated auth tag not as expected");
6468 test_AES_GMAC_authentication_test_case_1(void)
6470 return test_AES_GMAC_authentication(&gmac_test_case_1);
6474 test_AES_GMAC_authentication_test_case_2(void)
6476 return test_AES_GMAC_authentication(&gmac_test_case_2);
6480 test_AES_GMAC_authentication_test_case_3(void)
6482 return test_AES_GMAC_authentication(&gmac_test_case_3);
6486 test_AES_GMAC_authentication_test_case_4(void)
6488 return test_AES_GMAC_authentication(&gmac_test_case_4);
6492 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6494 struct crypto_testsuite_params *ts_params = &testsuite_params;
6495 struct crypto_unittest_params *ut_params = &unittest_params;
6498 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6499 "No GMAC length in the source data");
6501 retval = create_gmac_session(ts_params->valid_devs[0],
6502 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6503 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6508 if (tdata->aad.len > MBUF_SIZE)
6509 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6512 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6513 "Failed to allocate input buffer in mempool");
6515 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6516 rte_pktmbuf_tailroom(ut_params->ibuf));
6518 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6524 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6526 ut_params->op->sym->m_src = ut_params->ibuf;
6528 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6529 ut_params->op), "failed to process sym crypto op");
6531 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6532 "crypto op processing failed");
6539 test_AES_GMAC_authentication_verify_test_case_1(void)
6541 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6545 test_AES_GMAC_authentication_verify_test_case_2(void)
6547 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6551 test_AES_GMAC_authentication_verify_test_case_3(void)
6553 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6557 test_AES_GMAC_authentication_verify_test_case_4(void)
6559 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6562 struct test_crypto_vector {
6563 enum rte_crypto_cipher_algorithm crypto_algo;
6576 const uint8_t *data;
6581 const uint8_t *data;
6585 enum rte_crypto_auth_algorithm auth_algo;
6593 const uint8_t *data;
6603 static const struct test_crypto_vector
6604 hmac_sha1_test_crypto_vector = {
6605 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6607 .data = plaintext_hash,
6612 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6613 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6614 0xDE, 0xF4, 0xDE, 0xAD
6620 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6621 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6622 0x3F, 0x91, 0x64, 0x59
6628 static const struct test_crypto_vector
6629 aes128_gmac_test_vector = {
6630 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6631 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6633 .data = plaintext_hash,
6638 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6639 0x08, 0x09, 0x0A, 0x0B
6645 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6646 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6652 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6653 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6659 static const struct test_crypto_vector
6660 aes128cbc_hmac_sha1_test_vector = {
6661 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6664 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6665 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6671 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6672 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6677 .data = plaintext_hash,
6681 .data = ciphertext512_aes128cbc,
6684 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6687 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6688 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6689 0xDE, 0xF4, 0xDE, 0xAD
6695 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6696 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6697 0x18, 0x8C, 0x1D, 0x32
6704 data_corruption(uint8_t *data)
6710 tag_corruption(uint8_t *data, unsigned int tag_offset)
6712 data[tag_offset] += 1;
6716 create_auth_session(struct crypto_unittest_params *ut_params,
6718 const struct test_crypto_vector *reference,
6719 enum rte_crypto_auth_operation auth_op)
6721 uint8_t auth_key[reference->auth_key.len + 1];
6723 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6725 /* Setup Authentication Parameters */
6726 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6727 ut_params->auth_xform.auth.op = auth_op;
6728 ut_params->auth_xform.next = NULL;
6729 ut_params->auth_xform.auth.algo = reference->auth_algo;
6730 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6731 ut_params->auth_xform.auth.key.data = auth_key;
6732 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6733 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6735 /* Create Crypto session*/
6736 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6737 &ut_params->auth_xform);
6739 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6745 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6747 const struct test_crypto_vector *reference,
6748 enum rte_crypto_auth_operation auth_op,
6749 enum rte_crypto_cipher_operation cipher_op)
6751 uint8_t cipher_key[reference->cipher_key.len + 1];
6752 uint8_t auth_key[reference->auth_key.len + 1];
6754 memcpy(cipher_key, reference->cipher_key.data,
6755 reference->cipher_key.len);
6756 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6758 /* Setup Authentication Parameters */
6759 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6760 ut_params->auth_xform.auth.op = auth_op;
6761 ut_params->auth_xform.next = &ut_params->cipher_xform;
6762 ut_params->auth_xform.auth.algo = reference->auth_algo;
6763 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6764 ut_params->auth_xform.auth.key.data = auth_key;
6765 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6766 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6768 /* Setup Cipher Parameters */
6769 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6770 ut_params->cipher_xform.next = NULL;
6771 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6772 ut_params->cipher_xform.cipher.op = cipher_op;
6773 ut_params->cipher_xform.cipher.key.data = cipher_key;
6774 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6775 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6776 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6778 /* Create Crypto session*/
6779 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6780 &ut_params->auth_xform);
6782 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6788 create_auth_operation(struct crypto_testsuite_params *ts_params,
6789 struct crypto_unittest_params *ut_params,
6790 const struct test_crypto_vector *reference,
6791 unsigned int auth_generate)
6793 /* Generate Crypto op data structure */
6794 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6795 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6796 TEST_ASSERT_NOT_NULL(ut_params->op,
6797 "Failed to allocate pktmbuf offload");
6799 /* Set crypto operation data parameters */
6800 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6802 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6804 /* set crypto operation source mbuf */
6805 sym_op->m_src = ut_params->ibuf;
6808 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6809 ut_params->ibuf, reference->digest.len);
6811 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6812 "no room to append auth tag");
6814 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6815 ut_params->ibuf, reference->plaintext.len);
6816 sym_op->auth.digest.length = reference->digest.len;
6819 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6821 memcpy(sym_op->auth.digest.data,
6822 reference->digest.data,
6823 reference->digest.len);
6825 TEST_HEXDUMP(stdout, "digest:",
6826 sym_op->auth.digest.data,
6827 sym_op->auth.digest.length);
6829 sym_op->auth.data.length = reference->plaintext.len;
6830 sym_op->auth.data.offset = 0;
6836 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6837 struct crypto_unittest_params *ut_params,
6838 const struct test_crypto_vector *reference,
6839 unsigned int auth_generate)
6841 /* Generate Crypto op data structure */
6842 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6843 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6844 TEST_ASSERT_NOT_NULL(ut_params->op,
6845 "Failed to allocate pktmbuf offload");
6847 /* Set crypto operation data parameters */
6848 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6850 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6852 /* set crypto operation source mbuf */
6853 sym_op->m_src = ut_params->ibuf;
6856 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6857 reference->aad.len);
6858 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6859 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6861 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6863 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6864 sym_op->auth.aad.length = reference->aad.len;
6867 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6868 ut_params->ibuf, reference->digest.len);
6870 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6871 "no room to append auth tag");
6873 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6874 ut_params->ibuf, reference->ciphertext.len);
6875 sym_op->auth.digest.length = reference->digest.len;
6878 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6880 memcpy(sym_op->auth.digest.data,
6881 reference->digest.data,
6882 reference->digest.len);
6884 TEST_HEXDUMP(stdout, "digest:",
6885 sym_op->auth.digest.data,
6886 sym_op->auth.digest.length);
6888 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6889 reference->iv.data, reference->iv.len);
6891 sym_op->cipher.data.length = 0;
6892 sym_op->cipher.data.offset = 0;
6894 sym_op->auth.data.length = 0;
6895 sym_op->auth.data.offset = 0;
6901 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6902 struct crypto_unittest_params *ut_params,
6903 const struct test_crypto_vector *reference,
6904 unsigned int auth_generate)
6906 /* Generate Crypto op data structure */
6907 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6908 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6909 TEST_ASSERT_NOT_NULL(ut_params->op,
6910 "Failed to allocate pktmbuf offload");
6912 /* Set crypto operation data parameters */
6913 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6915 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6917 /* set crypto operation source mbuf */
6918 sym_op->m_src = ut_params->ibuf;
6921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6922 ut_params->ibuf, reference->digest.len);
6924 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6925 "no room to append auth tag");
6927 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6928 ut_params->ibuf, reference->ciphertext.len);
6929 sym_op->auth.digest.length = reference->digest.len;
6932 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6934 memcpy(sym_op->auth.digest.data,
6935 reference->digest.data,
6936 reference->digest.len);
6938 TEST_HEXDUMP(stdout, "digest:",
6939 sym_op->auth.digest.data,
6940 sym_op->auth.digest.length);
6942 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6943 reference->iv.data, reference->iv.len);
6945 sym_op->cipher.data.length = reference->ciphertext.len;
6946 sym_op->cipher.data.offset = 0;
6948 sym_op->auth.data.length = reference->ciphertext.len;
6949 sym_op->auth.data.offset = 0;
6955 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6956 struct crypto_unittest_params *ut_params,
6957 const struct test_crypto_vector *reference)
6959 return create_auth_operation(ts_params, ut_params, reference, 0);
6963 create_auth_verify_GMAC_operation(
6964 struct crypto_testsuite_params *ts_params,
6965 struct crypto_unittest_params *ut_params,
6966 const struct test_crypto_vector *reference)
6968 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6972 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6973 struct crypto_unittest_params *ut_params,
6974 const struct test_crypto_vector *reference)
6976 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6980 test_authentication_verify_fail_when_data_corruption(
6981 struct crypto_testsuite_params *ts_params,
6982 struct crypto_unittest_params *ut_params,
6983 const struct test_crypto_vector *reference,
6984 unsigned int data_corrupted)
6990 /* Create session */
6991 retval = create_auth_session(ut_params,
6992 ts_params->valid_devs[0],
6994 RTE_CRYPTO_AUTH_OP_VERIFY);
6998 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6999 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7000 "Failed to allocate input buffer in mempool");
7002 /* clear mbuf payload */
7003 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7004 rte_pktmbuf_tailroom(ut_params->ibuf));
7006 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7007 reference->plaintext.len);
7008 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7009 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7011 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7013 /* Create operation */
7014 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7020 data_corruption(plaintext);
7022 tag_corruption(plaintext, reference->plaintext.len);
7024 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7026 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7027 TEST_ASSERT_EQUAL(ut_params->op->status,
7028 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7029 "authentication not failed");
7031 ut_params->obuf = ut_params->op->sym->m_src;
7032 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7038 test_authentication_verify_GMAC_fail_when_corruption(
7039 struct crypto_testsuite_params *ts_params,
7040 struct crypto_unittest_params *ut_params,
7041 const struct test_crypto_vector *reference,
7042 unsigned int data_corrupted)
7046 /* Create session */
7047 retval = create_auth_cipher_session(ut_params,
7048 ts_params->valid_devs[0],
7050 RTE_CRYPTO_AUTH_OP_VERIFY,
7051 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7055 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7056 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7057 "Failed to allocate input buffer in mempool");
7059 /* clear mbuf payload */
7060 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7061 rte_pktmbuf_tailroom(ut_params->ibuf));
7063 /* Create operation */
7064 retval = create_auth_verify_GMAC_operation(ts_params,
7072 data_corruption(ut_params->op->sym->auth.aad.data);
7074 tag_corruption(ut_params->op->sym->auth.aad.data,
7075 reference->aad.len);
7077 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7079 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7080 TEST_ASSERT_EQUAL(ut_params->op->status,
7081 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7082 "authentication not failed");
7084 ut_params->obuf = ut_params->op->sym->m_src;
7085 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7091 test_authenticated_decryption_fail_when_corruption(
7092 struct crypto_testsuite_params *ts_params,
7093 struct crypto_unittest_params *ut_params,
7094 const struct test_crypto_vector *reference,
7095 unsigned int data_corrupted)
7099 uint8_t *ciphertext;
7101 /* Create session */
7102 retval = create_auth_cipher_session(ut_params,
7103 ts_params->valid_devs[0],
7105 RTE_CRYPTO_AUTH_OP_VERIFY,
7106 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7110 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7111 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7112 "Failed to allocate input buffer in mempool");
7114 /* clear mbuf payload */
7115 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7116 rte_pktmbuf_tailroom(ut_params->ibuf));
7118 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7119 reference->ciphertext.len);
7120 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7121 memcpy(ciphertext, reference->ciphertext.data,
7122 reference->ciphertext.len);
7124 /* Create operation */
7125 retval = create_cipher_auth_verify_operation(ts_params,
7133 data_corruption(ciphertext);
7135 tag_corruption(ciphertext, reference->ciphertext.len);
7137 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7140 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7141 TEST_ASSERT_EQUAL(ut_params->op->status,
7142 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7143 "authentication not failed");
7145 ut_params->obuf = ut_params->op->sym->m_src;
7146 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7152 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7153 const struct gcm_test_data *tdata,
7154 void *digest_mem, uint64_t digest_phys)
7156 struct crypto_testsuite_params *ts_params = &testsuite_params;
7157 struct crypto_unittest_params *ut_params = &unittest_params;
7159 const unsigned int auth_tag_len = tdata->auth_tag.len;
7160 const unsigned int iv_len = tdata->iv.len;
7161 const unsigned int aad_len = tdata->aad.len;
7163 /* Generate Crypto op data structure */
7164 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7165 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7166 TEST_ASSERT_NOT_NULL(ut_params->op,
7167 "Failed to allocate symmetric crypto operation struct");
7169 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7171 sym_op->auth.digest.data = digest_mem;
7173 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7174 "no room to append digest");
7176 sym_op->auth.digest.phys_addr = digest_phys;
7177 sym_op->auth.digest.length = auth_tag_len;
7179 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7180 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7182 TEST_HEXDUMP(stdout, "digest:",
7183 sym_op->auth.digest.data,
7184 sym_op->auth.digest.length);
7187 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7188 uint8_t *, IV_OFFSET);
7190 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7192 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7193 ut_params->ibuf, aad_len);
7194 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7195 "no room to prepend aad");
7196 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7198 sym_op->auth.aad.length = aad_len;
7200 memset(sym_op->auth.aad.data, 0, aad_len);
7201 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7203 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7204 TEST_HEXDUMP(stdout, "aad:",
7205 sym_op->auth.aad.data, aad_len);
7207 sym_op->cipher.data.length = tdata->plaintext.len;
7208 sym_op->cipher.data.offset = aad_len;
7210 sym_op->auth.data.offset = aad_len;
7211 sym_op->auth.data.length = tdata->plaintext.len;
7216 #define SGL_MAX_NO 16
7219 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7220 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7222 struct crypto_testsuite_params *ts_params = &testsuite_params;
7223 struct crypto_unittest_params *ut_params = &unittest_params;
7224 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7227 int to_trn_tbl[SGL_MAX_NO];
7229 unsigned int trn_data = 0;
7230 uint8_t *plaintext, *ciphertext, *auth_tag;
7232 if (fragsz > tdata->plaintext.len)
7233 fragsz = tdata->plaintext.len;
7235 uint16_t plaintext_len = fragsz;
7236 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7238 if (fragsz_oop > tdata->plaintext.len)
7239 frag_size_oop = tdata->plaintext.len;
7242 void *digest_mem = NULL;
7244 uint32_t prepend_len = tdata->aad.len;
7246 if (tdata->plaintext.len % fragsz != 0) {
7247 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7250 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7255 * For out-op-place we need to alloc another mbuf
7258 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7259 rte_pktmbuf_append(ut_params->obuf,
7260 frag_size_oop + prepend_len);
7261 buf_oop = ut_params->obuf;
7264 /* Create GCM session */
7265 retval = create_gcm_session(ts_params->valid_devs[0],
7266 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7267 tdata->key.data, tdata->key.len,
7268 tdata->aad.len, tdata->auth_tag.len,
7270 RTE_CRYPTO_AUTH_OP_GENERATE);
7274 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7276 /* clear mbuf payload */
7277 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7278 rte_pktmbuf_tailroom(ut_params->ibuf));
7280 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7283 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7285 trn_data += plaintext_len;
7287 buf = ut_params->ibuf;
7290 * Loop until no more fragments
7293 while (trn_data < tdata->plaintext.len) {
7295 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7296 (tdata->plaintext.len - trn_data) : fragsz;
7298 to_trn_tbl[ecx++] = to_trn;
7300 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7303 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7304 rte_pktmbuf_tailroom(buf));
7307 if (oop && !fragsz_oop) {
7308 buf_last_oop = buf_oop->next =
7309 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7310 buf_oop = buf_oop->next;
7311 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7312 0, rte_pktmbuf_tailroom(buf_oop));
7313 rte_pktmbuf_append(buf_oop, to_trn);
7316 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7319 memcpy(plaintext, tdata->plaintext.data + trn_data,
7322 if (trn_data == tdata->plaintext.len) {
7325 digest_mem = rte_pktmbuf_append(buf_oop,
7326 tdata->auth_tag.len);
7328 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7329 tdata->auth_tag.len);
7333 uint64_t digest_phys = 0;
7335 ut_params->ibuf->nb_segs = segs;
7338 if (fragsz_oop && oop) {
7342 if (frag_size_oop == tdata->plaintext.len) {
7343 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7344 tdata->auth_tag.len);
7346 digest_phys = rte_pktmbuf_mtophys_offset(
7348 tdata->plaintext.len + prepend_len);
7351 trn_data = frag_size_oop;
7352 while (trn_data < tdata->plaintext.len) {
7355 (tdata->plaintext.len - trn_data <
7357 (tdata->plaintext.len - trn_data) :
7360 to_trn_tbl[ecx++] = to_trn;
7362 buf_last_oop = buf_oop->next =
7363 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7364 buf_oop = buf_oop->next;
7365 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7366 0, rte_pktmbuf_tailroom(buf_oop));
7367 rte_pktmbuf_append(buf_oop, to_trn);
7371 if (trn_data == tdata->plaintext.len) {
7372 digest_mem = rte_pktmbuf_append(buf_oop,
7373 tdata->auth_tag.len);
7377 ut_params->obuf->nb_segs = segs;
7381 * Place digest at the end of the last buffer
7384 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7385 if (oop && buf_last_oop)
7386 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7388 if (!digest_mem && !oop) {
7389 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7390 + tdata->auth_tag.len);
7391 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7392 tdata->plaintext.len);
7395 /* Create GCM opertaion */
7396 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7397 tdata, digest_mem, digest_phys);
7402 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7404 ut_params->op->sym->m_src = ut_params->ibuf;
7406 ut_params->op->sym->m_dst = ut_params->obuf;
7408 /* Process crypto operation */
7409 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7410 ut_params->op), "failed to process sym crypto op");
7412 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7413 "crypto op processing failed");
7416 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7417 uint8_t *, prepend_len);
7419 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7420 uint8_t *, prepend_len);
7424 fragsz = fragsz_oop;
7426 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7428 tdata->ciphertext.data,
7430 "GCM Ciphertext data not as expected");
7432 buf = ut_params->op->sym->m_src->next;
7434 buf = ut_params->op->sym->m_dst->next;
7436 unsigned int off = fragsz;
7440 ciphertext = rte_pktmbuf_mtod(buf,
7443 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7445 tdata->ciphertext.data + off,
7447 "GCM Ciphertext data not as expected");
7449 off += to_trn_tbl[ecx++];
7453 auth_tag = digest_mem;
7454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7456 tdata->auth_tag.data,
7457 tdata->auth_tag.len,
7458 "GCM Generated auth tag not as expected");
7464 #define OUT_OF_PLACE 1
7467 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7469 return test_AES_GCM_authenticated_encryption_SGL(
7470 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7474 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7476 return test_AES_GCM_authenticated_encryption_SGL(
7477 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7481 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7483 return test_AES_GCM_authenticated_encryption_SGL(
7484 &gcm_test_case_8, OUT_OF_PLACE, 400,
7485 gcm_test_case_8.plaintext.len);
7489 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7492 return test_AES_GCM_authenticated_encryption_SGL(
7493 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7497 test_authentication_verify_fail_when_data_corrupted(
7498 struct crypto_testsuite_params *ts_params,
7499 struct crypto_unittest_params *ut_params,
7500 const struct test_crypto_vector *reference)
7502 return test_authentication_verify_fail_when_data_corruption(
7503 ts_params, ut_params, reference, 1);
7507 test_authentication_verify_fail_when_tag_corrupted(
7508 struct crypto_testsuite_params *ts_params,
7509 struct crypto_unittest_params *ut_params,
7510 const struct test_crypto_vector *reference)
7512 return test_authentication_verify_fail_when_data_corruption(
7513 ts_params, ut_params, reference, 0);
7517 test_authentication_verify_GMAC_fail_when_data_corrupted(
7518 struct crypto_testsuite_params *ts_params,
7519 struct crypto_unittest_params *ut_params,
7520 const struct test_crypto_vector *reference)
7522 return test_authentication_verify_GMAC_fail_when_corruption(
7523 ts_params, ut_params, reference, 1);
7527 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7528 struct crypto_testsuite_params *ts_params,
7529 struct crypto_unittest_params *ut_params,
7530 const struct test_crypto_vector *reference)
7532 return test_authentication_verify_GMAC_fail_when_corruption(
7533 ts_params, ut_params, reference, 0);
7537 test_authenticated_decryption_fail_when_data_corrupted(
7538 struct crypto_testsuite_params *ts_params,
7539 struct crypto_unittest_params *ut_params,
7540 const struct test_crypto_vector *reference)
7542 return test_authenticated_decryption_fail_when_corruption(
7543 ts_params, ut_params, reference, 1);
7547 test_authenticated_decryption_fail_when_tag_corrupted(
7548 struct crypto_testsuite_params *ts_params,
7549 struct crypto_unittest_params *ut_params,
7550 const struct test_crypto_vector *reference)
7552 return test_authenticated_decryption_fail_when_corruption(
7553 ts_params, ut_params, reference, 0);
7557 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7559 return test_authentication_verify_fail_when_data_corrupted(
7560 &testsuite_params, &unittest_params,
7561 &hmac_sha1_test_crypto_vector);
7565 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7567 return test_authentication_verify_fail_when_tag_corrupted(
7568 &testsuite_params, &unittest_params,
7569 &hmac_sha1_test_crypto_vector);
7573 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7575 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7576 &testsuite_params, &unittest_params,
7577 &aes128_gmac_test_vector);
7581 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7583 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7584 &testsuite_params, &unittest_params,
7585 &aes128_gmac_test_vector);
7589 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7591 return test_authenticated_decryption_fail_when_data_corrupted(
7594 &aes128cbc_hmac_sha1_test_vector);
7598 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7600 return test_authenticated_decryption_fail_when_tag_corrupted(
7603 &aes128cbc_hmac_sha1_test_vector);
7606 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7608 /* global AESNI slave IDs for the scheduler test */
7609 uint8_t aesni_ids[2];
7612 test_scheduler_attach_slave_op(void)
7614 struct crypto_testsuite_params *ts_params = &testsuite_params;
7615 uint8_t sched_id = ts_params->valid_devs[0];
7616 uint32_t nb_devs, i, nb_devs_attached = 0;
7620 /* create 2 AESNI_MB if necessary */
7621 nb_devs = rte_cryptodev_count_devtype(
7622 RTE_CRYPTODEV_AESNI_MB_PMD);
7624 for (i = nb_devs; i < 2; i++) {
7625 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7626 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7628 ret = rte_vdev_init(vdev_name, NULL);
7630 TEST_ASSERT(ret == 0,
7631 "Failed to create instance %u of"
7633 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7637 /* attach 2 AESNI_MB cdevs */
7638 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7640 struct rte_cryptodev_info info;
7642 rte_cryptodev_info_get(i, &info);
7643 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7646 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7649 TEST_ASSERT(ret == 0,
7650 "Failed to attach device %u of pmd : %s", i,
7651 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7653 aesni_ids[nb_devs_attached] = (uint8_t)i;
7662 test_scheduler_detach_slave_op(void)
7664 struct crypto_testsuite_params *ts_params = &testsuite_params;
7665 uint8_t sched_id = ts_params->valid_devs[0];
7669 for (i = 0; i < 2; i++) {
7670 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7672 TEST_ASSERT(ret == 0,
7673 "Failed to detach device %u", aesni_ids[i]);
7680 test_scheduler_mode_op(void)
7682 struct crypto_testsuite_params *ts_params = &testsuite_params;
7683 uint8_t sched_id = ts_params->valid_devs[0];
7684 struct rte_cryptodev_scheduler_ops op = {0};
7685 struct rte_cryptodev_scheduler dummy_scheduler = {
7686 .description = "dummy scheduler to test mode",
7687 .name = "dummy scheduler",
7688 .mode = CDEV_SCHED_MODE_USERDEFINED,
7693 /* set user defined mode */
7694 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7696 TEST_ASSERT(ret == 0,
7697 "Failed to set cdev %u to user defined mode", sched_id);
7699 /* set round robin mode */
7700 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7701 CDEV_SCHED_MODE_ROUNDROBIN);
7702 TEST_ASSERT(ret == 0,
7703 "Failed to set cdev %u to round-robin mode", sched_id);
7704 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7705 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7711 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7712 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7713 .setup = testsuite_setup,
7714 .teardown = testsuite_teardown,
7715 .unit_test_cases = {
7716 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7717 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7718 TEST_CASE_ST(ut_setup, ut_teardown,
7719 test_AES_chain_scheduler_all),
7720 TEST_CASE_ST(ut_setup, ut_teardown,
7721 test_AES_cipheronly_scheduler_all),
7722 TEST_CASE_ST(ut_setup, ut_teardown,
7723 test_authonly_scheduler_all),
7724 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7725 TEST_CASES_END() /**< NULL terminate unit test array */
7729 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7731 static struct unit_test_suite cryptodev_qat_testsuite = {
7732 .suite_name = "Crypto QAT Unit Test Suite",
7733 .setup = testsuite_setup,
7734 .teardown = testsuite_teardown,
7735 .unit_test_cases = {
7736 TEST_CASE_ST(ut_setup, ut_teardown,
7737 test_device_configure_invalid_dev_id),
7738 TEST_CASE_ST(ut_setup, ut_teardown,
7739 test_device_configure_invalid_queue_pair_ids),
7740 TEST_CASE_ST(ut_setup, ut_teardown,
7741 test_queue_pair_descriptor_setup),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_multi_session),
7745 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7746 TEST_CASE_ST(ut_setup, ut_teardown,
7747 test_AES_cipheronly_qat_all),
7748 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_3DES_cipheronly_qat_all),
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_DES_cipheronly_qat_all),
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_AES_docsis_qat_all),
7755 TEST_CASE_ST(ut_setup, ut_teardown,
7756 test_DES_docsis_qat_all),
7757 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7759 /** AES GCM Authenticated Encryption */
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7762 TEST_CASE_ST(ut_setup, ut_teardown,
7763 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7764 TEST_CASE_ST(ut_setup, ut_teardown,
7765 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7766 TEST_CASE_ST(ut_setup, ut_teardown,
7767 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7781 /** AES GCM Authenticated Decryption */
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7792 TEST_CASE_ST(ut_setup, ut_teardown,
7793 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7797 /** AES GMAC Authentication */
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_AES_GMAC_authentication_test_case_1),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_AES_GMAC_authentication_verify_test_case_1),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_AES_GMAC_authentication_test_case_2),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_AES_GMAC_authentication_verify_test_case_2),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_AES_GMAC_authentication_test_case_3),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_AES_GMAC_authentication_verify_test_case_3),
7811 /** SNOW 3G encrypt only (UEA2) */
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_snow3g_encryption_test_case_1),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_snow3g_encryption_test_case_2),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_snow3g_encryption_test_case_3),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_snow3g_encryption_test_case_4),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_snow3g_encryption_test_case_5),
7823 TEST_CASE_ST(ut_setup, ut_teardown,
7824 test_snow3g_encryption_test_case_1_oop),
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_snow3g_decryption_test_case_1_oop),
7828 /** SNOW 3G decrypt only (UEA2) */
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_snow3g_decryption_test_case_1),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_snow3g_decryption_test_case_2),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_snow3g_decryption_test_case_3),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_snow3g_decryption_test_case_4),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_snow3g_decryption_test_case_5),
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_snow3g_hash_generate_test_case_1),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_snow3g_hash_generate_test_case_2),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_snow3g_hash_generate_test_case_3),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_snow3g_hash_verify_test_case_1),
7847 TEST_CASE_ST(ut_setup, ut_teardown,
7848 test_snow3g_hash_verify_test_case_2),
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_snow3g_hash_verify_test_case_3),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_snow3g_cipher_auth_test_case_1),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_snow3g_auth_cipher_test_case_1),
7856 /** ZUC encrypt only (EEA3) */
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_zuc_encryption_test_case_1),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_zuc_encryption_test_case_2),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_zuc_encryption_test_case_3),
7863 TEST_CASE_ST(ut_setup, ut_teardown,
7864 test_zuc_encryption_test_case_4),
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_zuc_encryption_test_case_5),
7868 /** ZUC authenticate (EIA3) */
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_zuc_hash_generate_test_case_6),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_zuc_hash_generate_test_case_7),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_zuc_hash_generate_test_case_8),
7876 /** ZUC alg-chain (EEA3/EIA3) */
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_zuc_cipher_auth_test_case_1),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_zuc_cipher_auth_test_case_2),
7882 /** HMAC_MD5 Authentication */
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 test_MD5_HMAC_generate_case_1),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_MD5_HMAC_verify_case_1),
7887 TEST_CASE_ST(ut_setup, ut_teardown,
7888 test_MD5_HMAC_generate_case_2),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_MD5_HMAC_verify_case_2),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_null_auth_only_operation),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_null_cipher_only_operation),
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_null_cipher_auth_operation),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_null_auth_cipher_operation),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_kasumi_hash_generate_test_case_6),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_kasumi_encryption_test_case_1),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_kasumi_encryption_test_case_3),
7910 TEST_CASE_ST(ut_setup, ut_teardown,
7911 test_kasumi_auth_cipher_test_case_1),
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 test_kasumi_cipher_auth_test_case_1),
7915 /** Negative tests */
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 authentication_verify_AES128_GMAC_fail_data_corrupt),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7924 TEST_CASE_ST(ut_setup, ut_teardown,
7925 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7926 TEST_CASE_ST(ut_setup, ut_teardown,
7927 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7929 TEST_CASES_END() /**< NULL terminate unit test array */
7933 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7934 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7935 .setup = testsuite_setup,
7936 .teardown = testsuite_teardown,
7937 .unit_test_cases = {
7938 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7939 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7940 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7941 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7943 TEST_CASES_END() /**< NULL terminate unit test array */
7947 static struct unit_test_suite cryptodev_openssl_testsuite = {
7948 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7949 .setup = testsuite_setup,
7950 .teardown = testsuite_teardown,
7951 .unit_test_cases = {
7952 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_multi_session_random_usage),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_AES_chain_openssl_all),
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_AES_cipheronly_openssl_all),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_3DES_chain_openssl_all),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_3DES_cipheronly_openssl_all),
7963 TEST_CASE_ST(ut_setup, ut_teardown,
7964 test_DES_docsis_openssl_all),
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_authonly_openssl_all),
7968 /** AES GCM Authenticated Encryption */
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7979 TEST_CASE_ST(ut_setup, ut_teardown,
7980 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7984 /** AES GCM Authenticated Decryption */
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8000 /** AES GMAC Authentication */
8001 TEST_CASE_ST(ut_setup, ut_teardown,
8002 test_AES_GMAC_authentication_test_case_1),
8003 TEST_CASE_ST(ut_setup, ut_teardown,
8004 test_AES_GMAC_authentication_verify_test_case_1),
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 test_AES_GMAC_authentication_test_case_2),
8007 TEST_CASE_ST(ut_setup, ut_teardown,
8008 test_AES_GMAC_authentication_verify_test_case_2),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_AES_GMAC_authentication_test_case_3),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 test_AES_GMAC_authentication_verify_test_case_3),
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 test_AES_GMAC_authentication_test_case_4),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_AES_GMAC_authentication_verify_test_case_4),
8018 /** Scatter-Gather */
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8022 /** Negative tests */
8023 TEST_CASE_ST(ut_setup, ut_teardown,
8024 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 authentication_verify_AES128_GMAC_fail_data_corrupt),
8029 TEST_CASE_ST(ut_setup, ut_teardown,
8030 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8031 TEST_CASE_ST(ut_setup, ut_teardown,
8032 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8033 TEST_CASE_ST(ut_setup, ut_teardown,
8034 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8036 TEST_CASES_END() /**< NULL terminate unit test array */
8040 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8041 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8042 .setup = testsuite_setup,
8043 .teardown = testsuite_teardown,
8044 .unit_test_cases = {
8045 /** AES GCM Authenticated Encryption */
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8061 /** AES GCM Authenticated Decryption */
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8077 /** AES GCM Authenticated Encryption 256 bits key */
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8093 /** AES GCM Authenticated Decryption 256 bits key */
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8109 /** AES GCM Authenticated Encryption big aad size */
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8115 /** AES GCM Authenticated Decryption big aad size */
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8121 /** AES GMAC Authentication */
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_AES_GMAC_authentication_test_case_1),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_AES_GMAC_authentication_verify_test_case_1),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_AES_GMAC_authentication_test_case_3),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_AES_GMAC_authentication_verify_test_case_3),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_AES_GMAC_authentication_test_case_4),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_AES_GMAC_authentication_verify_test_case_4),
8135 /** Negative tests */
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 authentication_verify_AES128_GMAC_fail_data_corrupt),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8141 /** Out of place tests */
8142 TEST_CASE_ST(ut_setup, ut_teardown,
8143 test_mb_AES_GCM_authenticated_encryption_oop),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_mb_AES_GCM_authenticated_decryption_oop),
8147 /** Session-less tests */
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_mb_AES_GCM_authenticated_encryption_sessionless),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_mb_AES_GCM_authenticated_decryption_sessionless),
8153 /** Scatter-Gather */
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8157 TEST_CASES_END() /**< NULL terminate unit test array */
8161 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8162 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8163 .setup = testsuite_setup,
8164 .teardown = testsuite_teardown,
8165 .unit_test_cases = {
8166 /** KASUMI encrypt only (UEA1) */
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_kasumi_encryption_test_case_1),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_kasumi_encryption_test_case_1_sgl),
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_kasumi_encryption_test_case_2),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_kasumi_encryption_test_case_3),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_kasumi_encryption_test_case_4),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_kasumi_encryption_test_case_5),
8179 /** KASUMI decrypt only (UEA1) */
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_kasumi_decryption_test_case_1),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_kasumi_decryption_test_case_2),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_kasumi_decryption_test_case_3),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 test_kasumi_decryption_test_case_4),
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_kasumi_decryption_test_case_5),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_kasumi_encryption_test_case_1_oop),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_kasumi_encryption_test_case_1_oop_sgl),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_kasumi_decryption_test_case_1_oop),
8200 /** KASUMI hash only (UIA1) */
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_kasumi_hash_generate_test_case_1),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_kasumi_hash_generate_test_case_2),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_kasumi_hash_generate_test_case_3),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_kasumi_hash_generate_test_case_4),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_kasumi_hash_generate_test_case_5),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_kasumi_hash_generate_test_case_6),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_kasumi_hash_verify_test_case_1),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_kasumi_hash_verify_test_case_2),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_kasumi_hash_verify_test_case_3),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_kasumi_hash_verify_test_case_4),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_kasumi_hash_verify_test_case_5),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_kasumi_auth_cipher_test_case_1),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_kasumi_cipher_auth_test_case_1),
8227 TEST_CASES_END() /**< NULL terminate unit test array */
8230 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8231 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8232 .setup = testsuite_setup,
8233 .teardown = testsuite_teardown,
8234 .unit_test_cases = {
8235 /** SNOW 3G encrypt only (UEA2) */
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_snow3g_encryption_test_case_1),
8238 TEST_CASE_ST(ut_setup, ut_teardown,
8239 test_snow3g_encryption_test_case_2),
8240 TEST_CASE_ST(ut_setup, ut_teardown,
8241 test_snow3g_encryption_test_case_3),
8242 TEST_CASE_ST(ut_setup, ut_teardown,
8243 test_snow3g_encryption_test_case_4),
8244 TEST_CASE_ST(ut_setup, ut_teardown,
8245 test_snow3g_encryption_test_case_5),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_snow3g_encryption_test_case_1_oop),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_snow3g_encryption_test_case_1_oop_sgl),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_snow3g_decryption_test_case_1_oop),
8254 TEST_CASE_ST(ut_setup, ut_teardown,
8255 test_snow3g_encryption_test_case_1_offset_oop),
8257 /** SNOW 3G decrypt only (UEA2) */
8258 TEST_CASE_ST(ut_setup, ut_teardown,
8259 test_snow3g_decryption_test_case_1),
8260 TEST_CASE_ST(ut_setup, ut_teardown,
8261 test_snow3g_decryption_test_case_2),
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_snow3g_decryption_test_case_3),
8264 TEST_CASE_ST(ut_setup, ut_teardown,
8265 test_snow3g_decryption_test_case_4),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_snow3g_decryption_test_case_5),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_snow3g_hash_generate_test_case_1),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_snow3g_hash_generate_test_case_2),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_snow3g_hash_generate_test_case_3),
8274 /* Tests with buffers which length is not byte-aligned */
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_snow3g_hash_generate_test_case_4),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_snow3g_hash_generate_test_case_5),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_snow3g_hash_generate_test_case_6),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_snow3g_hash_verify_test_case_1),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_snow3g_hash_verify_test_case_2),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_snow3g_hash_verify_test_case_3),
8287 /* Tests with buffers which length is not byte-aligned */
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_snow3g_hash_verify_test_case_4),
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_snow3g_hash_verify_test_case_5),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_snow3g_hash_verify_test_case_6),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_snow3g_cipher_auth_test_case_1),
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_snow3g_auth_cipher_test_case_1),
8299 TEST_CASES_END() /**< NULL terminate unit test array */
8303 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8304 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8305 .setup = testsuite_setup,
8306 .teardown = testsuite_teardown,
8307 .unit_test_cases = {
8308 /** ZUC encrypt only (EEA3) */
8309 TEST_CASE_ST(ut_setup, ut_teardown,
8310 test_zuc_encryption_test_case_1),
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_zuc_encryption_test_case_2),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_zuc_encryption_test_case_3),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_zuc_encryption_test_case_4),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_zuc_encryption_test_case_5),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_zuc_hash_generate_test_case_1),
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 test_zuc_hash_generate_test_case_2),
8323 TEST_CASE_ST(ut_setup, ut_teardown,
8324 test_zuc_hash_generate_test_case_3),
8325 TEST_CASE_ST(ut_setup, ut_teardown,
8326 test_zuc_hash_generate_test_case_4),
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 test_zuc_hash_generate_test_case_5),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_zuc_encryption_test_case_6_sgl),
8331 TEST_CASES_END() /**< NULL terminate unit test array */
8335 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8336 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8337 .setup = testsuite_setup,
8338 .teardown = testsuite_teardown,
8339 .unit_test_cases = {
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_device_configure_invalid_dev_id),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_multi_session),
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 test_AES_chain_dpaa2_sec_all),
8347 TEST_CASE_ST(ut_setup, ut_teardown,
8348 test_3DES_chain_dpaa2_sec_all),
8349 TEST_CASE_ST(ut_setup, ut_teardown,
8350 test_AES_cipheronly_dpaa2_sec_all),
8351 TEST_CASE_ST(ut_setup, ut_teardown,
8352 test_3DES_cipheronly_dpaa2_sec_all),
8354 /** HMAC_MD5 Authentication */
8355 TEST_CASE_ST(ut_setup, ut_teardown,
8356 test_MD5_HMAC_generate_case_1),
8357 TEST_CASE_ST(ut_setup, ut_teardown,
8358 test_MD5_HMAC_verify_case_1),
8359 TEST_CASE_ST(ut_setup, ut_teardown,
8360 test_MD5_HMAC_generate_case_2),
8361 TEST_CASE_ST(ut_setup, ut_teardown,
8362 test_MD5_HMAC_verify_case_2),
8364 TEST_CASES_END() /**< NULL terminate unit test array */
8368 static struct unit_test_suite cryptodev_null_testsuite = {
8369 .suite_name = "Crypto Device NULL Unit Test Suite",
8370 .setup = testsuite_setup,
8371 .teardown = testsuite_teardown,
8372 .unit_test_cases = {
8373 TEST_CASE_ST(ut_setup, ut_teardown,
8374 test_null_auth_only_operation),
8375 TEST_CASE_ST(ut_setup, ut_teardown,
8376 test_null_cipher_only_operation),
8377 TEST_CASE_ST(ut_setup, ut_teardown,
8378 test_null_cipher_auth_operation),
8379 TEST_CASE_ST(ut_setup, ut_teardown,
8380 test_null_auth_cipher_operation),
8381 TEST_CASE_ST(ut_setup, ut_teardown,
8382 test_null_invalid_operation),
8383 TEST_CASE_ST(ut_setup, ut_teardown,
8384 test_null_burst_operation),
8386 TEST_CASES_END() /**< NULL terminate unit test array */
8390 static struct unit_test_suite cryptodev_armv8_testsuite = {
8391 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8392 .setup = testsuite_setup,
8393 .teardown = testsuite_teardown,
8394 .unit_test_cases = {
8395 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8397 /** Negative tests */
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8400 TEST_CASE_ST(ut_setup, ut_teardown,
8401 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8403 TEST_CASES_END() /**< NULL terminate unit test array */
8408 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8410 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8411 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8415 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8417 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8419 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8423 test_cryptodev_openssl(void)
8425 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8427 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8431 test_cryptodev_aesni_gcm(void)
8433 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8435 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8439 test_cryptodev_null(void)
8441 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8443 return unit_test_suite_runner(&cryptodev_null_testsuite);
8447 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8449 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8451 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8455 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8457 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8459 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8463 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8465 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8467 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8471 test_cryptodev_armv8(void)
8473 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8475 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8478 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8481 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8483 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8484 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8487 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8492 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8494 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8495 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8498 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8499 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8500 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8501 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8502 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8503 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8504 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8505 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8506 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8507 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);