4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
81 struct rte_cryptodev_sym_session *sess;
83 struct rte_crypto_op *op;
85 struct rte_mbuf *obuf, *ibuf;
90 #define ALIGN_POW2_ROUNDUP(num, align) \
91 (((num) + (align) - 1) & ~((align) - 1))
94 * Forward declarations.
97 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
98 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
102 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
103 struct crypto_unittest_params *ut_params,
104 struct crypto_testsuite_params *ts_param,
105 const uint8_t *cipher,
106 const uint8_t *digest,
109 static struct rte_mbuf *
110 setup_test_string(struct rte_mempool *mpool,
111 const char *string, size_t len, uint8_t blocksize)
113 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
114 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
116 memset(m->buf_addr, 0, m->buf_len);
118 char *dst = rte_pktmbuf_append(m, t_len);
125 rte_memcpy(dst, string, t_len);
127 memset(dst, 0, t_len);
133 /* Get number of bytes in X bits (rounding up) */
135 ceil_byte_length(uint32_t num_bits)
138 return ((num_bits >> 3) + 1);
140 return (num_bits >> 3);
143 static struct rte_crypto_op *
144 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
146 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
147 printf("Error sending packet for encryption");
153 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
159 static struct crypto_testsuite_params testsuite_params = { NULL };
160 static struct crypto_unittest_params unittest_params;
163 testsuite_setup(void)
165 struct crypto_testsuite_params *ts_params = &testsuite_params;
166 struct rte_cryptodev_info info;
167 uint32_t i = 0, nb_devs, dev_id;
171 memset(ts_params, 0, sizeof(*ts_params));
173 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
174 if (ts_params->mbuf_pool == NULL) {
175 /* Not already created so create */
176 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
178 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
180 if (ts_params->mbuf_pool == NULL) {
181 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 ts_params->large_mbuf_pool = rte_mempool_lookup(
187 "CRYPTO_LARGE_MBUFPOOL");
188 if (ts_params->large_mbuf_pool == NULL) {
189 /* Not already created so create */
190 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
191 "CRYPTO_LARGE_MBUFPOOL",
194 if (ts_params->large_mbuf_pool == NULL) {
196 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 ts_params->op_mpool = rte_crypto_op_pool_create(
202 "MBUF_CRYPTO_SYM_OP_POOL",
203 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
204 NUM_MBUFS, MBUF_CACHE_SIZE,
206 sizeof(struct rte_crypto_sym_xform) +
209 if (ts_params->op_mpool == NULL) {
210 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
214 /* Create an AESNI MB device if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_MB
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_MB_PMD);
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
236 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(
242 RTE_CRYPTODEV_AESNI_GCM_PMD);
244 TEST_ASSERT_SUCCESS(rte_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
246 "Failed to create instance of"
248 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
252 /* Create a SNOW 3G device if required */
253 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
254 #ifndef RTE_LIBRTE_PMD_SNOW3G
255 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
256 " enabled in config file to run this testsuite.\n");
259 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
261 TEST_ASSERT_SUCCESS(rte_vdev_init(
262 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
263 "Failed to create instance of"
265 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create a KASUMI device if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 TEST_ASSERT_SUCCESS(rte_vdev_init(
279 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
280 "Failed to create instance of"
282 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
286 /* Create a ZUC device if required */
287 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
288 #ifndef RTE_LIBRTE_PMD_ZUC
289 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
290 " enabled in config file to run this testsuite.\n");
293 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
295 TEST_ASSERT_SUCCESS(rte_vdev_init(
296 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
297 "Failed to create instance of"
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
303 /* Create a NULL device if required */
304 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
305 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
306 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
307 " enabled in config file to run this testsuite.\n");
310 nb_devs = rte_cryptodev_count_devtype(
311 RTE_CRYPTODEV_NULL_PMD);
314 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
316 TEST_ASSERT(ret == 0,
317 "Failed to create instance of"
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
323 /* Create an OPENSSL device if required */
324 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
325 #ifndef RTE_LIBRTE_PMD_OPENSSL
326 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
327 " enabled in config file to run this testsuite.\n");
330 nb_devs = rte_cryptodev_count_devtype(
331 RTE_CRYPTODEV_OPENSSL_PMD);
334 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
343 /* Create a ARMv8 device if required */
344 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
345 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
346 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
347 " enabled in config file to run this testsuite.\n");
350 nb_devs = rte_cryptodev_count_devtype(
351 RTE_CRYPTODEV_ARMV8_PMD);
354 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
366 #ifndef RTE_LIBRTE_PMD_AESNI_MB
367 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
368 " enabled in config file to run this testsuite.\n");
371 nb_devs = rte_cryptodev_count_devtype(
372 RTE_CRYPTODEV_SCHEDULER_PMD);
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
378 TEST_ASSERT(ret == 0,
379 "Failed to create instance %u of"
381 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
384 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
386 #ifndef RTE_LIBRTE_PMD_QAT
387 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
388 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
389 "in config file to run this testsuite.\n");
394 nb_devs = rte_cryptodev_count();
396 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
400 /* Create list of valid crypto devs */
401 for (i = 0; i < nb_devs; i++) {
402 rte_cryptodev_info_get(i, &info);
403 if (info.dev_type == gbl_cryptodev_type)
404 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
407 if (ts_params->valid_dev_count < 1)
410 /* Set up all the qps on the first of the valid devices found */
412 dev_id = ts_params->valid_devs[0];
414 rte_cryptodev_info_get(dev_id, &info);
416 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
417 ts_params->conf.socket_id = SOCKET_ID_ANY;
418 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
422 "Failed to configure cryptodev %u with %u qps",
423 dev_id, ts_params->conf.nb_queue_pairs);
425 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
427 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
428 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
429 dev_id, qp_id, &ts_params->qp_conf,
430 rte_cryptodev_socket_id(dev_id)),
431 "Failed to setup queue pair %u on cryptodev %u",
439 testsuite_teardown(void)
441 struct crypto_testsuite_params *ts_params = &testsuite_params;
443 if (ts_params->mbuf_pool != NULL) {
444 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
445 rte_mempool_avail_count(ts_params->mbuf_pool));
448 if (ts_params->op_mpool != NULL) {
449 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
450 rte_mempool_avail_count(ts_params->op_mpool));
458 struct crypto_testsuite_params *ts_params = &testsuite_params;
459 struct crypto_unittest_params *ut_params = &unittest_params;
463 /* Clear unit test parameters before running test */
464 memset(ut_params, 0, sizeof(*ut_params));
466 /* Reconfigure device to default parameters */
467 ts_params->conf.socket_id = SOCKET_ID_ANY;
468 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
470 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
475 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 ts_params->valid_devs[0], qp_id,
479 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
480 "Failed to setup queue pair %u on cryptodev %u",
481 qp_id, ts_params->valid_devs[0]);
485 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
487 /* Start the device */
488 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
489 "Failed to start cryptodev %u",
490 ts_params->valid_devs[0]);
498 struct crypto_testsuite_params *ts_params = &testsuite_params;
499 struct crypto_unittest_params *ut_params = &unittest_params;
500 struct rte_cryptodev_stats stats;
502 /* free crypto session structure */
503 if (ut_params->sess) {
504 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
506 ut_params->sess = NULL;
509 /* free crypto operation structure */
511 rte_crypto_op_free(ut_params->op);
514 * free mbuf - both obuf and ibuf are usually the same,
515 * so check if they point at the same address is necessary,
516 * to avoid freeing the mbuf twice.
518 if (ut_params->obuf) {
519 rte_pktmbuf_free(ut_params->obuf);
520 if (ut_params->ibuf == ut_params->obuf)
524 if (ut_params->ibuf) {
525 rte_pktmbuf_free(ut_params->ibuf);
529 if (ts_params->mbuf_pool != NULL)
530 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
531 rte_mempool_avail_count(ts_params->mbuf_pool));
533 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
535 /* Stop the device */
536 rte_cryptodev_stop(ts_params->valid_devs[0]);
540 test_device_configure_invalid_dev_id(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 uint16_t dev_id, num_devs = 0;
545 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
546 "Need at least %d devices for test", 1);
548 /* valid dev_id values */
549 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
551 /* Stop the device in case it's started so it can be configured */
552 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
554 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
558 /* invalid dev_id values */
561 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
562 "Failed test for rte_cryptodev_configure: "
563 "invalid dev_num %u", dev_id);
567 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
568 "Failed test for rte_cryptodev_configure:"
569 "invalid dev_num %u", dev_id);
575 test_device_configure_invalid_queue_pair_ids(void)
577 struct crypto_testsuite_params *ts_params = &testsuite_params;
578 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
580 /* Stop the device in case it's started so it can be configured */
581 rte_cryptodev_stop(ts_params->valid_devs[0]);
583 /* valid - one queue pairs */
584 ts_params->conf.nb_queue_pairs = 1;
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
588 "Failed to configure cryptodev: dev_id %u, qp_id %u",
589 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
592 /* valid - max value queue pairs */
593 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
595 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed to configure cryptodev: dev_id %u, qp_id %u",
598 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
601 /* invalid - zero queue pairs */
602 ts_params->conf.nb_queue_pairs = 0;
604 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed test for rte_cryptodev_configure, dev_id %u,"
608 ts_params->valid_devs[0],
609 ts_params->conf.nb_queue_pairs);
612 /* invalid - max value supported by field queue pairs */
613 ts_params->conf.nb_queue_pairs = UINT16_MAX;
615 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
617 "Failed test for rte_cryptodev_configure, dev_id %u,"
619 ts_params->valid_devs[0],
620 ts_params->conf.nb_queue_pairs);
623 /* invalid - max value + 1 queue pairs */
624 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
626 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
628 "Failed test for rte_cryptodev_configure, dev_id %u,"
630 ts_params->valid_devs[0],
631 ts_params->conf.nb_queue_pairs);
633 /* revert to original testsuite value */
634 ts_params->conf.nb_queue_pairs = orig_nb_qps;
640 test_queue_pair_descriptor_setup(void)
642 struct crypto_testsuite_params *ts_params = &testsuite_params;
643 struct rte_cryptodev_info dev_info;
644 struct rte_cryptodev_qp_conf qp_conf = {
645 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
650 /* Stop the device in case it's started so it can be configured */
651 rte_cryptodev_stop(ts_params->valid_devs[0]);
654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
656 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
658 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
659 &ts_params->conf), "Failed to configure cryptodev %u",
660 ts_params->valid_devs[0]);
664 * Test various ring sizes on this device. memzones can't be
665 * freed so are re-used if ring is released and re-created.
667 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
669 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
670 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
671 ts_params->valid_devs[0], qp_id, &qp_conf,
672 rte_cryptodev_socket_id(
673 ts_params->valid_devs[0])),
675 "rte_cryptodev_queue_pair_setup: num_inflights "
676 "%u on qp %u on cryptodev %u",
677 qp_conf.nb_descriptors, qp_id,
678 ts_params->valid_devs[0]);
681 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0])),
689 " rte_cryptodev_queue_pair_setup: num_inflights"
690 " %u on qp %u on cryptodev %u",
691 qp_conf.nb_descriptors, qp_id,
692 ts_params->valid_devs[0]);
695 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
697 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
698 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
699 ts_params->valid_devs[0], qp_id, &qp_conf,
700 rte_cryptodev_socket_id(
701 ts_params->valid_devs[0])),
703 "rte_cryptodev_queue_pair_setup: num_inflights"
704 " %u on qp %u on cryptodev %u",
705 qp_conf.nb_descriptors, qp_id,
706 ts_params->valid_devs[0]);
709 /* invalid number of descriptors - max supported + 2 */
710 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0])),
717 "Unexpectedly passed test for "
718 "rte_cryptodev_queue_pair_setup:"
719 "num_inflights %u on qp %u on cryptodev %u",
720 qp_conf.nb_descriptors, qp_id,
721 ts_params->valid_devs[0]);
724 /* invalid number of descriptors - max value of parameter */
725 qp_conf.nb_descriptors = UINT32_MAX-1;
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0])),
732 "Unexpectedly passed test for "
733 "rte_cryptodev_queue_pair_setup:"
734 "num_inflights %u on qp %u on cryptodev %u",
735 qp_conf.nb_descriptors, qp_id,
736 ts_params->valid_devs[0]);
739 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
741 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
742 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0], qp_id, &qp_conf,
744 rte_cryptodev_socket_id(
745 ts_params->valid_devs[0])),
747 " rte_cryptodev_queue_pair_setup:"
748 "num_inflights %u on qp %u on cryptodev %u",
749 qp_conf.nb_descriptors, qp_id,
750 ts_params->valid_devs[0]);
753 /* invalid number of descriptors - max supported + 1 */
754 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
756 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
757 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
758 ts_params->valid_devs[0], qp_id, &qp_conf,
759 rte_cryptodev_socket_id(
760 ts_params->valid_devs[0])),
761 "Unexpectedly passed test for "
762 "rte_cryptodev_queue_pair_setup:"
763 "num_inflights %u on qp %u on cryptodev %u",
764 qp_conf.nb_descriptors, qp_id,
765 ts_params->valid_devs[0]);
768 /* test invalid queue pair id */
769 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
771 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
773 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
774 ts_params->valid_devs[0],
776 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
777 "Failed test for rte_cryptodev_queue_pair_setup:"
778 "invalid qp %u on cryptodev %u",
779 qp_id, ts_params->valid_devs[0]);
781 qp_id = 0xffff; /*invalid*/
783 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0],
786 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
787 "Failed test for rte_cryptodev_queue_pair_setup:"
788 "invalid qp %u on cryptodev %u",
789 qp_id, ts_params->valid_devs[0]);
794 /* ***** Plaintext data for tests ***** */
796 const char catch_22_quote_1[] =
797 "There was only one catch and that was Catch-22, which "
798 "specified that a concern for one's safety in the face of "
799 "dangers that were real and immediate was the process of a "
800 "rational mind. Orr was crazy and could be grounded. All he "
801 "had to do was ask; and as soon as he did, he would no longer "
802 "be crazy and would have to fly more missions. Orr would be "
803 "crazy to fly more missions and sane if he didn't, but if he "
804 "was sane he had to fly them. If he flew them he was crazy "
805 "and didn't have to; but if he didn't want to he was sane and "
806 "had to. Yossarian was moved very deeply by the absolute "
807 "simplicity of this clause of Catch-22 and let out a "
808 "respectful whistle. \"That's some catch, that Catch-22\", he "
809 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
811 const char catch_22_quote[] =
812 "What a lousy earth! He wondered how many people were "
813 "destitute that same night even in his own prosperous country, "
814 "how many homes were shanties, how many husbands were drunk "
815 "and wives socked, and how many children were bullied, abused, "
816 "or abandoned. How many families hungered for food they could "
817 "not afford to buy? How many hearts were broken? How many "
818 "suicides would take place that same night, how many people "
819 "would go insane? How many cockroaches and landlords would "
820 "triumph? How many winners were losers, successes failures, "
821 "and rich men poor men? How many wise guys were stupid? How "
822 "many happy endings were unhappy endings? How many honest men "
823 "were liars, brave men cowards, loyal men traitors, how many "
824 "sainted men were corrupt, how many people in positions of "
825 "trust had sold their souls to bodyguards, how many had never "
826 "had souls? How many straight-and-narrow paths were crooked "
827 "paths? How many best families were worst families and how "
828 "many good people were bad people? When you added them all up "
829 "and then subtracted, you might be left with only the children, "
830 "and perhaps with Albert Einstein and an old violinist or "
831 "sculptor somewhere.";
833 #define QUOTE_480_BYTES (480)
834 #define QUOTE_512_BYTES (512)
835 #define QUOTE_768_BYTES (768)
836 #define QUOTE_1024_BYTES (1024)
840 /* ***** SHA1 Hash Tests ***** */
842 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
844 static uint8_t hmac_sha1_key[] = {
845 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
846 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
847 0xDE, 0xF4, 0xDE, 0xAD };
849 /* ***** SHA224 Hash Tests ***** */
851 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
854 /* ***** AES-CBC Cipher Tests ***** */
856 #define CIPHER_KEY_LENGTH_AES_CBC (16)
857 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
859 static uint8_t aes_cbc_key[] = {
860 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
861 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
863 static uint8_t aes_cbc_iv[] = {
864 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
865 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
868 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
870 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
871 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
872 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
873 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
874 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
875 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
876 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
877 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
878 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
879 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
880 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
881 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
882 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
883 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
884 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
885 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
886 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
887 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
888 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
889 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
890 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
891 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
892 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
893 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
894 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
895 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
896 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
897 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
898 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
899 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
900 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
901 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
902 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
903 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
904 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
905 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
906 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
907 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
908 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
909 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
910 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
911 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
912 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
913 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
914 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
915 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
916 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
917 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
918 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
919 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
920 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
921 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
922 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
923 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
924 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
925 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
926 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
927 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
928 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
929 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
930 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
931 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
932 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
933 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
934 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
937 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
938 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
939 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
940 0x18, 0x8c, 0x1d, 0x32
944 /* Multisession Vector context Test */
946 static uint8_t ms_aes_cbc_key0[] = {
947 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
951 static uint8_t ms_aes_cbc_iv0[] = {
952 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
953 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
956 static const uint8_t ms_aes_cbc_cipher0[] = {
957 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
958 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
959 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
960 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
961 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
962 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
963 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
964 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
965 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
966 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
967 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
968 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
969 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
970 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
971 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
972 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
973 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
974 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
975 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
976 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
977 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
978 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
979 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
980 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
981 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
982 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
983 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
984 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
985 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
986 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
987 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
988 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
989 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
990 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
991 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
992 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
993 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
994 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
995 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
996 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
997 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
998 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
999 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1000 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1001 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1002 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1003 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1004 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1005 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1006 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1007 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1008 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1009 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1010 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1011 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1012 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1013 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1014 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1015 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1016 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1017 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1018 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1019 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1020 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1024 static uint8_t ms_hmac_key0[] = {
1025 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1026 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1027 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1028 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1029 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1030 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1031 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1032 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1035 static const uint8_t ms_hmac_digest0[] = {
1036 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1037 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1038 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1039 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1040 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1041 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1042 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1043 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1047 /* Begin session 1 */
1049 static uint8_t ms_aes_cbc_key1[] = {
1050 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static uint8_t ms_aes_cbc_iv1[] = {
1055 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1056 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1059 static const uint8_t ms_aes_cbc_cipher1[] = {
1060 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1061 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1062 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1063 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1064 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1065 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1066 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1067 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1068 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1069 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1070 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1071 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1072 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1073 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1074 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1075 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1076 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1077 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1078 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1079 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1080 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1081 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1082 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1083 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1084 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1085 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1086 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1087 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1088 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1089 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1090 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1091 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1092 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1093 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1094 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1095 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1096 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1097 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1098 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1099 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1100 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1101 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1102 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1103 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1104 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1105 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1106 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1107 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1108 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1109 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1110 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1111 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1112 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1113 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1114 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1115 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1116 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1117 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1118 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1119 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1120 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1121 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1122 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1123 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1127 static uint8_t ms_hmac_key1[] = {
1128 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1129 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1130 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1131 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1132 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1133 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1134 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1135 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1138 static const uint8_t ms_hmac_digest1[] = {
1139 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1140 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1141 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1142 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1143 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1144 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1145 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1146 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1149 /* Begin Session 2 */
1150 static uint8_t ms_aes_cbc_key2[] = {
1151 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1152 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 static uint8_t ms_aes_cbc_iv2[] = {
1156 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1157 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1160 static const uint8_t ms_aes_cbc_cipher2[] = {
1161 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1162 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1163 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1164 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1165 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1166 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1167 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1168 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1169 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1170 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1171 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1172 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1173 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1174 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1175 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1176 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1177 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1178 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1179 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1180 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1181 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1182 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1183 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1184 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1185 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1186 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1187 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1188 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1189 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1190 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1191 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1192 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1193 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1194 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1195 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1196 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1197 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1198 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1199 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1200 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1201 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1202 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1203 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1204 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1205 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1206 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1207 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1208 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1209 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1210 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1211 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1212 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1213 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1214 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1215 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1216 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1217 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1218 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1219 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1220 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1221 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1222 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1223 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1224 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1227 static uint8_t ms_hmac_key2[] = {
1228 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest2[] = {
1239 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1240 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1241 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1242 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1243 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1244 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1245 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1246 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1253 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1255 struct crypto_testsuite_params *ts_params = &testsuite_params;
1256 struct crypto_unittest_params *ut_params = &unittest_params;
1258 /* Generate test mbuf data and space for digest */
1259 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1260 catch_22_quote, QUOTE_512_BYTES, 0);
1262 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1263 DIGEST_BYTE_LENGTH_SHA1);
1264 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1266 /* Setup Cipher Parameters */
1267 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1268 ut_params->cipher_xform.next = &ut_params->auth_xform;
1270 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1271 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1272 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1273 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1275 /* Setup HMAC Parameters */
1276 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1278 ut_params->auth_xform.next = NULL;
1280 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1281 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1282 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1283 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1284 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1286 /* Create crypto session*/
1287 ut_params->sess = rte_cryptodev_sym_session_create(
1288 ts_params->valid_devs[0],
1289 &ut_params->cipher_xform);
1290 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1292 /* Generate crypto op data structure */
1293 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1294 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1295 TEST_ASSERT_NOT_NULL(ut_params->op,
1296 "Failed to allocate symmetric crypto operation struct");
1298 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1300 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1302 /* set crypto operation source mbuf */
1303 sym_op->m_src = ut_params->ibuf;
1305 /* Set crypto operation authentication parameters */
1306 sym_op->auth.digest.data = ut_params->digest;
1307 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1308 ut_params->ibuf, QUOTE_512_BYTES);
1309 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1311 sym_op->auth.data.offset = 0;
1312 sym_op->auth.data.length = QUOTE_512_BYTES;
1314 /* Set crypto operation cipher parameters */
1315 sym_op->cipher.iv.offset = IV_OFFSET;
1316 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1318 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1319 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
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;
1409 /* Setup HMAC Parameters */
1410 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1411 ut_params->auth_xform.next = &ut_params->cipher_xform;
1413 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1414 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1415 ut_params->auth_xform.auth.key.data = hmac_key;
1416 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1417 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1419 return TEST_SUCCESS;
1424 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1425 struct crypto_unittest_params *ut_params,
1426 struct crypto_testsuite_params *ts_params,
1427 const uint8_t *cipher,
1428 const uint8_t *digest,
1431 /* Generate test mbuf data and digest */
1432 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1435 QUOTE_512_BYTES, 0);
1437 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1438 DIGEST_BYTE_LENGTH_SHA512);
1439 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1441 rte_memcpy(ut_params->digest,
1443 DIGEST_BYTE_LENGTH_SHA512);
1445 /* Generate Crypto op data structure */
1446 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1447 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1448 TEST_ASSERT_NOT_NULL(ut_params->op,
1449 "Failed to allocate symmetric crypto operation struct");
1451 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1453 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1455 /* set crypto operation source mbuf */
1456 sym_op->m_src = ut_params->ibuf;
1458 sym_op->auth.digest.data = ut_params->digest;
1459 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1460 ut_params->ibuf, QUOTE_512_BYTES);
1461 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1463 sym_op->auth.data.offset = 0;
1464 sym_op->auth.data.length = QUOTE_512_BYTES;
1466 sym_op->cipher.iv.offset = IV_OFFSET;
1467 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
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 aad_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.add_auth_data_length = aad_len;
1800 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1801 &ut_params->auth_xform);
1802 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1807 create_wireless_algo_cipher_session(uint8_t dev_id,
1808 enum rte_crypto_cipher_operation op,
1809 enum rte_crypto_cipher_algorithm algo,
1810 const uint8_t *key, const uint8_t key_len)
1812 uint8_t cipher_key[key_len];
1814 struct crypto_unittest_params *ut_params = &unittest_params;
1816 memcpy(cipher_key, key, key_len);
1818 /* Setup Cipher Parameters */
1819 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1820 ut_params->cipher_xform.next = NULL;
1822 ut_params->cipher_xform.cipher.algo = algo;
1823 ut_params->cipher_xform.cipher.op = op;
1824 ut_params->cipher_xform.cipher.key.data = cipher_key;
1825 ut_params->cipher_xform.cipher.key.length = key_len;
1827 TEST_HEXDUMP(stdout, "key:", key, key_len);
1829 /* Create Crypto session */
1830 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1833 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1838 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1839 unsigned int cipher_len,
1840 unsigned int cipher_offset)
1842 struct crypto_testsuite_params *ts_params = &testsuite_params;
1843 struct crypto_unittest_params *ut_params = &unittest_params;
1845 /* Generate Crypto op data structure */
1846 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1847 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1848 TEST_ASSERT_NOT_NULL(ut_params->op,
1849 "Failed to allocate pktmbuf offload");
1851 /* Set crypto operation data parameters */
1852 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1854 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1856 /* set crypto operation source mbuf */
1857 sym_op->m_src = ut_params->ibuf;
1860 sym_op->cipher.iv.offset = IV_OFFSET;
1861 sym_op->cipher.iv.length = iv_len;
1863 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1865 sym_op->cipher.data.length = cipher_len;
1866 sym_op->cipher.data.offset = cipher_offset;
1871 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1872 unsigned int cipher_len,
1873 unsigned int cipher_offset)
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 struct crypto_unittest_params *ut_params = &unittest_params;
1878 /* Generate Crypto op data structure */
1879 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1880 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1881 TEST_ASSERT_NOT_NULL(ut_params->op,
1882 "Failed to allocate pktmbuf offload");
1884 /* Set crypto operation data parameters */
1885 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1887 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1889 /* set crypto operation source mbuf */
1890 sym_op->m_src = ut_params->ibuf;
1891 sym_op->m_dst = ut_params->obuf;
1894 sym_op->cipher.iv.offset = IV_OFFSET;
1895 sym_op->cipher.iv.length = iv_len;
1897 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1899 sym_op->cipher.data.length = cipher_len;
1900 sym_op->cipher.data.offset = cipher_offset;
1905 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1906 enum rte_crypto_cipher_operation cipher_op,
1907 enum rte_crypto_auth_operation auth_op,
1908 enum rte_crypto_auth_algorithm auth_algo,
1909 enum rte_crypto_cipher_algorithm cipher_algo,
1910 const uint8_t *key, const uint8_t key_len,
1911 const uint8_t aad_len, const uint8_t auth_len)
1914 uint8_t cipher_auth_key[key_len];
1916 struct crypto_unittest_params *ut_params = &unittest_params;
1918 memcpy(cipher_auth_key, key, key_len);
1920 /* Setup Authentication Parameters */
1921 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1922 ut_params->auth_xform.next = NULL;
1924 ut_params->auth_xform.auth.op = auth_op;
1925 ut_params->auth_xform.auth.algo = auth_algo;
1926 ut_params->auth_xform.auth.key.length = key_len;
1927 /* Hash key = cipher key */
1928 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1929 ut_params->auth_xform.auth.digest_length = auth_len;
1930 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1932 /* Setup Cipher Parameters */
1933 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1934 ut_params->cipher_xform.next = &ut_params->auth_xform;
1936 ut_params->cipher_xform.cipher.algo = cipher_algo;
1937 ut_params->cipher_xform.cipher.op = cipher_op;
1938 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1939 ut_params->cipher_xform.cipher.key.length = key_len;
1941 TEST_HEXDUMP(stdout, "key:", key, key_len);
1943 /* Create Crypto session*/
1944 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1945 &ut_params->cipher_xform);
1947 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1952 create_wireless_cipher_auth_session(uint8_t dev_id,
1953 enum rte_crypto_cipher_operation cipher_op,
1954 enum rte_crypto_auth_operation auth_op,
1955 enum rte_crypto_auth_algorithm auth_algo,
1956 enum rte_crypto_cipher_algorithm cipher_algo,
1957 const struct wireless_test_data *tdata)
1959 const uint8_t key_len = tdata->key.len;
1960 uint8_t cipher_auth_key[key_len];
1962 struct crypto_unittest_params *ut_params = &unittest_params;
1963 const uint8_t *key = tdata->key.data;
1964 const uint8_t aad_len = tdata->aad.len;
1965 const uint8_t auth_len = tdata->digest.len;
1967 memcpy(cipher_auth_key, key, key_len);
1969 /* Setup Authentication Parameters */
1970 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1971 ut_params->auth_xform.next = NULL;
1973 ut_params->auth_xform.auth.op = auth_op;
1974 ut_params->auth_xform.auth.algo = auth_algo;
1975 ut_params->auth_xform.auth.key.length = key_len;
1976 /* Hash key = cipher key */
1977 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1978 ut_params->auth_xform.auth.digest_length = auth_len;
1979 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1981 /* Setup Cipher Parameters */
1982 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1983 ut_params->cipher_xform.next = &ut_params->auth_xform;
1985 ut_params->cipher_xform.cipher.algo = cipher_algo;
1986 ut_params->cipher_xform.cipher.op = cipher_op;
1987 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1988 ut_params->cipher_xform.cipher.key.length = key_len;
1990 TEST_HEXDUMP(stdout, "key:", key, key_len);
1992 /* Create Crypto session*/
1993 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1994 &ut_params->cipher_xform);
1996 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2001 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2002 const struct wireless_test_data *tdata)
2004 return create_wireless_cipher_auth_session(dev_id,
2005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2006 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2007 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2011 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2012 enum rte_crypto_cipher_operation cipher_op,
2013 enum rte_crypto_auth_operation auth_op,
2014 enum rte_crypto_auth_algorithm auth_algo,
2015 enum rte_crypto_cipher_algorithm cipher_algo,
2016 const uint8_t *key, const uint8_t key_len,
2017 const uint8_t aad_len, const uint8_t auth_len)
2019 uint8_t auth_cipher_key[key_len];
2021 struct crypto_unittest_params *ut_params = &unittest_params;
2023 memcpy(auth_cipher_key, key, key_len);
2025 /* Setup Authentication Parameters */
2026 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2027 ut_params->auth_xform.auth.op = auth_op;
2028 ut_params->auth_xform.next = &ut_params->cipher_xform;
2029 ut_params->auth_xform.auth.algo = auth_algo;
2030 ut_params->auth_xform.auth.key.length = key_len;
2031 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2032 ut_params->auth_xform.auth.digest_length = auth_len;
2033 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
2035 /* Setup Cipher Parameters */
2036 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2037 ut_params->cipher_xform.next = NULL;
2038 ut_params->cipher_xform.cipher.algo = cipher_algo;
2039 ut_params->cipher_xform.cipher.op = cipher_op;
2040 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2041 ut_params->cipher_xform.cipher.key.length = key_len;
2043 TEST_HEXDUMP(stdout, "key:", key, key_len);
2045 /* Create Crypto session*/
2046 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2047 &ut_params->auth_xform);
2049 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2055 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2056 const unsigned auth_tag_len,
2057 const uint8_t *aad, const unsigned aad_len,
2058 unsigned data_pad_len,
2059 enum rte_crypto_auth_operation op,
2060 enum rte_crypto_auth_algorithm algo,
2061 const unsigned auth_len, const unsigned auth_offset)
2063 struct crypto_testsuite_params *ts_params = &testsuite_params;
2065 struct crypto_unittest_params *ut_params = &unittest_params;
2067 unsigned aad_buffer_len;
2069 /* Generate Crypto op data structure */
2070 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2071 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2072 TEST_ASSERT_NOT_NULL(ut_params->op,
2073 "Failed to allocate pktmbuf offload");
2075 /* Set crypto operation data parameters */
2076 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2078 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2080 /* set crypto operation source mbuf */
2081 sym_op->m_src = ut_params->ibuf;
2085 * Always allocate the aad up to the block size.
2086 * The cryptodev API calls out -
2087 * - the array must be big enough to hold the AAD, plus any
2088 * space to round this up to the nearest multiple of the
2089 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2091 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2092 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2094 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2095 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2096 ut_params->ibuf, aad_buffer_len);
2097 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2098 "no room to prepend aad");
2099 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2101 sym_op->auth.aad.length = aad_len;
2103 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2104 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2106 TEST_HEXDUMP(stdout, "aad:",
2107 sym_op->auth.aad.data, aad_len);
2110 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2111 ut_params->ibuf, auth_tag_len);
2113 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2114 "no room to append auth tag");
2115 ut_params->digest = sym_op->auth.digest.data;
2116 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2117 ut_params->ibuf, data_pad_len + aad_len);
2118 sym_op->auth.digest.length = auth_tag_len;
2119 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2120 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2122 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2124 TEST_HEXDUMP(stdout, "digest:",
2125 sym_op->auth.digest.data,
2126 sym_op->auth.digest.length);
2128 sym_op->auth.data.length = auth_len;
2129 sym_op->auth.data.offset = auth_offset;
2135 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2136 enum rte_crypto_auth_operation op,
2137 enum rte_crypto_auth_algorithm auth_algo)
2139 struct crypto_testsuite_params *ts_params = &testsuite_params;
2140 struct crypto_unittest_params *ut_params = &unittest_params;
2142 const uint8_t *auth_tag = tdata->digest.data;
2143 const unsigned int auth_tag_len = tdata->digest.len;
2144 const uint8_t *aad = tdata->aad.data;
2145 const uint8_t aad_len = tdata->aad.len;
2146 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2147 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2149 const uint8_t *iv = tdata->iv.data;
2150 const uint8_t iv_len = tdata->iv.len;
2151 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2152 const unsigned int cipher_offset = 0;
2153 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2154 const unsigned int auth_offset = tdata->aad.len << 3;
2156 unsigned int aad_buffer_len;
2158 /* Generate Crypto op data structure */
2159 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2160 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2161 TEST_ASSERT_NOT_NULL(ut_params->op,
2162 "Failed to allocate pktmbuf offload");
2163 /* Set crypto operation data parameters */
2164 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2166 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2168 /* set crypto operation source mbuf */
2169 sym_op->m_src = ut_params->ibuf;
2172 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2173 ut_params->ibuf, auth_tag_len);
2175 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2176 "no room to append auth tag");
2177 ut_params->digest = sym_op->auth.digest.data;
2178 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2179 ut_params->ibuf, data_pad_len);
2180 sym_op->auth.digest.length = auth_tag_len;
2181 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2182 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2184 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2186 TEST_HEXDUMP(stdout, "digest:",
2187 sym_op->auth.digest.data,
2188 sym_op->auth.digest.length);
2192 * Always allocate the aad up to the block size.
2193 * The cryptodev API calls out -
2194 * - the array must be big enough to hold the AAD, plus any
2195 * space to round this up to the nearest multiple of the
2196 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2198 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2199 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2201 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2202 sym_op->auth.aad.data =
2203 (uint8_t *)rte_pktmbuf_prepend(
2204 ut_params->ibuf, aad_buffer_len);
2205 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2206 "no room to prepend aad");
2207 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2209 sym_op->auth.aad.length = aad_len;
2210 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2211 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2212 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2215 sym_op->cipher.iv.offset = IV_OFFSET;
2216 sym_op->cipher.iv.length = iv_len;
2218 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2220 sym_op->cipher.data.length = cipher_len;
2221 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2222 sym_op->auth.data.length = auth_len;
2223 sym_op->auth.data.offset = auth_offset + cipher_offset;
2229 create_zuc_cipher_hash_generate_operation(
2230 const struct wireless_test_data *tdata)
2232 return create_wireless_cipher_hash_operation(tdata,
2233 RTE_CRYPTO_AUTH_OP_GENERATE,
2234 RTE_CRYPTO_AUTH_ZUC_EIA3);
2238 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2239 const unsigned auth_tag_len,
2240 const uint8_t *aad, const uint8_t aad_len,
2241 unsigned data_pad_len,
2242 enum rte_crypto_auth_operation op,
2243 enum rte_crypto_auth_algorithm auth_algo,
2244 const uint8_t *iv, const uint8_t iv_len,
2245 const unsigned cipher_len, const unsigned cipher_offset,
2246 const unsigned auth_len, const unsigned auth_offset)
2248 struct crypto_testsuite_params *ts_params = &testsuite_params;
2249 struct crypto_unittest_params *ut_params = &unittest_params;
2251 unsigned aad_buffer_len;
2253 /* Generate Crypto op data structure */
2254 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2255 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2256 TEST_ASSERT_NOT_NULL(ut_params->op,
2257 "Failed to allocate pktmbuf offload");
2258 /* Set crypto operation data parameters */
2259 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2261 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2263 /* set crypto operation source mbuf */
2264 sym_op->m_src = ut_params->ibuf;
2267 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2268 ut_params->ibuf, auth_tag_len);
2270 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2271 "no room to append auth tag");
2272 ut_params->digest = sym_op->auth.digest.data;
2273 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2274 ut_params->ibuf, data_pad_len);
2275 sym_op->auth.digest.length = auth_tag_len;
2276 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2277 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2279 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2281 TEST_HEXDUMP(stdout, "digest:",
2282 sym_op->auth.digest.data,
2283 sym_op->auth.digest.length);
2287 * Always allocate the aad up to the block size.
2288 * The cryptodev API calls out -
2289 * - the array must be big enough to hold the AAD, plus any
2290 * space to round this up to the nearest multiple of the
2291 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2293 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2294 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2296 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2297 sym_op->auth.aad.data =
2298 (uint8_t *)rte_pktmbuf_prepend(
2299 ut_params->ibuf, aad_buffer_len);
2300 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2301 "no room to prepend aad");
2302 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2304 sym_op->auth.aad.length = aad_len;
2305 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2306 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2307 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2310 sym_op->cipher.iv.offset = IV_OFFSET;
2311 sym_op->cipher.iv.length = iv_len;
2313 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2315 sym_op->cipher.data.length = cipher_len;
2316 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2317 sym_op->auth.data.length = auth_len;
2318 sym_op->auth.data.offset = auth_offset + cipher_offset;
2324 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2325 const uint8_t *iv, const uint8_t iv_len,
2326 const uint8_t *aad, const uint8_t aad_len,
2327 unsigned data_pad_len,
2328 const unsigned cipher_len, const unsigned cipher_offset,
2329 const unsigned auth_len, const unsigned auth_offset,
2330 enum rte_crypto_auth_algorithm auth_algo)
2332 struct crypto_testsuite_params *ts_params = &testsuite_params;
2333 struct crypto_unittest_params *ut_params = &unittest_params;
2335 unsigned aad_buffer_len = 0;
2337 /* Generate Crypto op data structure */
2338 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2339 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2340 TEST_ASSERT_NOT_NULL(ut_params->op,
2341 "Failed to allocate pktmbuf offload");
2343 /* Set crypto operation data parameters */
2344 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2346 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2348 /* set crypto operation source mbuf */
2349 sym_op->m_src = ut_params->ibuf;
2352 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2353 ut_params->ibuf, auth_tag_len);
2355 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2356 "no room to append auth tag");
2358 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2359 ut_params->ibuf, data_pad_len);
2360 sym_op->auth.digest.length = auth_tag_len;
2362 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2364 TEST_HEXDUMP(stdout, "digest:",
2365 sym_op->auth.digest.data,
2366 sym_op->auth.digest.length);
2370 * Always allocate the aad up to the block size.
2371 * The cryptodev API calls out -
2372 * - the array must be big enough to hold the AAD, plus any
2373 * space to round this up to the nearest multiple of the
2374 * block size (8 bytes for KASUMI 16 bytes).
2376 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2377 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2379 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2380 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2381 ut_params->ibuf, aad_buffer_len);
2382 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2383 "no room to prepend aad");
2384 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2386 sym_op->auth.aad.length = aad_len;
2387 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2388 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2389 TEST_HEXDUMP(stdout, "aad:",
2390 sym_op->auth.aad.data, aad_len);
2393 sym_op->cipher.iv.offset = IV_OFFSET;
2394 sym_op->cipher.iv.length = iv_len;
2396 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2398 sym_op->cipher.data.length = cipher_len;
2399 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2401 sym_op->auth.data.length = auth_len;
2402 sym_op->auth.data.offset = auth_offset + cipher_offset;
2408 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2410 struct crypto_testsuite_params *ts_params = &testsuite_params;
2411 struct crypto_unittest_params *ut_params = &unittest_params;
2414 unsigned plaintext_pad_len;
2415 unsigned plaintext_len;
2418 /* Create SNOW 3G session */
2419 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2420 tdata->key.data, tdata->key.len,
2421 tdata->aad.len, tdata->digest.len,
2422 RTE_CRYPTO_AUTH_OP_GENERATE,
2423 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2427 /* alloc mbuf and set payload */
2428 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2430 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2431 rte_pktmbuf_tailroom(ut_params->ibuf));
2433 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2434 /* Append data which is padded to a multiple of */
2435 /* the algorithms block size */
2436 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2437 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2439 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2441 /* Create SNOW 3G operation */
2442 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2443 tdata->aad.data, tdata->aad.len,
2444 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2445 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2446 tdata->validAuthLenInBits.len,
2447 (tdata->aad.len << 3));
2451 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2453 ut_params->obuf = ut_params->op->sym->m_src;
2454 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2455 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2456 + plaintext_pad_len + tdata->aad.len;
2459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2462 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2463 "SNOW 3G Generated auth tag not as expected");
2469 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2471 struct crypto_testsuite_params *ts_params = &testsuite_params;
2472 struct crypto_unittest_params *ut_params = &unittest_params;
2475 unsigned plaintext_pad_len;
2476 unsigned plaintext_len;
2479 /* Create SNOW 3G session */
2480 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2481 tdata->key.data, tdata->key.len,
2482 tdata->aad.len, tdata->digest.len,
2483 RTE_CRYPTO_AUTH_OP_VERIFY,
2484 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2487 /* alloc mbuf and set payload */
2488 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2490 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2491 rte_pktmbuf_tailroom(ut_params->ibuf));
2493 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2494 /* Append data which is padded to a multiple of */
2495 /* the algorithms block size */
2496 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2497 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2499 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2501 /* Create SNOW 3G operation */
2502 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2504 tdata->aad.data, tdata->aad.len,
2506 RTE_CRYPTO_AUTH_OP_VERIFY,
2507 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2508 tdata->validAuthLenInBits.len,
2509 (tdata->aad.len << 3));
2513 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2515 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2516 ut_params->obuf = ut_params->op->sym->m_src;
2517 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2518 + plaintext_pad_len + tdata->aad.len;
2521 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2530 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2532 struct crypto_testsuite_params *ts_params = &testsuite_params;
2533 struct crypto_unittest_params *ut_params = &unittest_params;
2536 unsigned plaintext_pad_len;
2537 unsigned plaintext_len;
2540 /* Create KASUMI session */
2541 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2542 tdata->key.data, tdata->key.len,
2543 tdata->aad.len, tdata->digest.len,
2544 RTE_CRYPTO_AUTH_OP_GENERATE,
2545 RTE_CRYPTO_AUTH_KASUMI_F9);
2549 /* alloc mbuf and set payload */
2550 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2552 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2553 rte_pktmbuf_tailroom(ut_params->ibuf));
2555 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2556 /* Append data which is padded to a multiple of */
2557 /* the algorithms block size */
2558 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2559 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2561 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2563 /* Create KASUMI operation */
2564 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2565 tdata->aad.data, tdata->aad.len,
2566 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2567 RTE_CRYPTO_AUTH_KASUMI_F9,
2568 tdata->validAuthLenInBits.len,
2569 (tdata->aad.len << 3));
2573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2575 ut_params->obuf = ut_params->op->sym->m_src;
2576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2577 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2578 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2581 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2584 DIGEST_BYTE_LENGTH_KASUMI_F9,
2585 "KASUMI Generated auth tag not as expected");
2591 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2593 struct crypto_testsuite_params *ts_params = &testsuite_params;
2594 struct crypto_unittest_params *ut_params = &unittest_params;
2597 unsigned plaintext_pad_len;
2598 unsigned plaintext_len;
2601 /* Create KASUMI session */
2602 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2603 tdata->key.data, tdata->key.len,
2604 tdata->aad.len, tdata->digest.len,
2605 RTE_CRYPTO_AUTH_OP_VERIFY,
2606 RTE_CRYPTO_AUTH_KASUMI_F9);
2609 /* alloc mbuf and set payload */
2610 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2612 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2613 rte_pktmbuf_tailroom(ut_params->ibuf));
2615 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2616 /* Append data which is padded to a multiple */
2617 /* of the algorithms block size */
2618 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2619 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2621 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2623 /* Create KASUMI operation */
2624 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2626 tdata->aad.data, tdata->aad.len,
2628 RTE_CRYPTO_AUTH_OP_VERIFY,
2629 RTE_CRYPTO_AUTH_KASUMI_F9,
2630 tdata->validAuthLenInBits.len,
2631 (tdata->aad.len << 3));
2635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2637 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2638 ut_params->obuf = ut_params->op->sym->m_src;
2639 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2640 + plaintext_pad_len + tdata->aad.len;
2643 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2652 test_snow3g_hash_generate_test_case_1(void)
2654 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2658 test_snow3g_hash_generate_test_case_2(void)
2660 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2664 test_snow3g_hash_generate_test_case_3(void)
2666 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2670 test_snow3g_hash_generate_test_case_4(void)
2672 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2676 test_snow3g_hash_generate_test_case_5(void)
2678 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2682 test_snow3g_hash_generate_test_case_6(void)
2684 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2688 test_snow3g_hash_verify_test_case_1(void)
2690 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2695 test_snow3g_hash_verify_test_case_2(void)
2697 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2701 test_snow3g_hash_verify_test_case_3(void)
2703 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2707 test_snow3g_hash_verify_test_case_4(void)
2709 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2713 test_snow3g_hash_verify_test_case_5(void)
2715 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2719 test_snow3g_hash_verify_test_case_6(void)
2721 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2725 test_kasumi_hash_generate_test_case_1(void)
2727 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2731 test_kasumi_hash_generate_test_case_2(void)
2733 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2737 test_kasumi_hash_generate_test_case_3(void)
2739 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2743 test_kasumi_hash_generate_test_case_4(void)
2745 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2749 test_kasumi_hash_generate_test_case_5(void)
2751 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2755 test_kasumi_hash_generate_test_case_6(void)
2757 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2761 test_kasumi_hash_verify_test_case_1(void)
2763 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2767 test_kasumi_hash_verify_test_case_2(void)
2769 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2773 test_kasumi_hash_verify_test_case_3(void)
2775 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2779 test_kasumi_hash_verify_test_case_4(void)
2781 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2785 test_kasumi_hash_verify_test_case_5(void)
2787 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2791 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2793 struct crypto_testsuite_params *ts_params = &testsuite_params;
2794 struct crypto_unittest_params *ut_params = &unittest_params;
2797 uint8_t *plaintext, *ciphertext;
2798 unsigned plaintext_pad_len;
2799 unsigned plaintext_len;
2801 /* Create KASUMI session */
2802 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2803 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2804 RTE_CRYPTO_CIPHER_KASUMI_F8,
2805 tdata->key.data, tdata->key.len);
2809 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2811 /* Clear mbuf payload */
2812 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2813 rte_pktmbuf_tailroom(ut_params->ibuf));
2815 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2816 /* Append data which is padded to a multiple */
2817 /* of the algorithms block size */
2818 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2819 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2821 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2823 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2825 /* Create KASUMI operation */
2826 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2827 tdata->plaintext.len,
2832 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2834 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2836 ut_params->obuf = ut_params->op->sym->m_dst;
2837 if (ut_params->obuf)
2838 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2840 ciphertext = plaintext;
2842 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2845 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2847 tdata->ciphertext.data,
2848 tdata->validCipherLenInBits.len,
2849 "KASUMI Ciphertext data not as expected");
2854 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2856 struct crypto_testsuite_params *ts_params = &testsuite_params;
2857 struct crypto_unittest_params *ut_params = &unittest_params;
2861 unsigned int plaintext_pad_len;
2862 unsigned int plaintext_len;
2864 uint8_t buffer[10000];
2865 const uint8_t *ciphertext;
2867 struct rte_cryptodev_info dev_info;
2869 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2870 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2871 printf("Device doesn't support scatter-gather. "
2876 /* Create KASUMI session */
2877 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2878 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2879 RTE_CRYPTO_CIPHER_KASUMI_F8,
2880 tdata->key.data, tdata->key.len);
2884 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2887 /* Append data which is padded to a multiple */
2888 /* of the algorithms block size */
2889 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2891 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2892 plaintext_pad_len, 10, 0);
2894 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2896 /* Create KASUMI operation */
2897 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2899 tdata->plaintext.len,
2904 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2906 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2908 ut_params->obuf = ut_params->op->sym->m_dst;
2910 if (ut_params->obuf)
2911 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2912 plaintext_len, buffer);
2914 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2915 plaintext_len, buffer);
2918 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2921 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2923 tdata->ciphertext.data,
2924 tdata->validCipherLenInBits.len,
2925 "KASUMI Ciphertext data not as expected");
2930 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2932 struct crypto_testsuite_params *ts_params = &testsuite_params;
2933 struct crypto_unittest_params *ut_params = &unittest_params;
2936 uint8_t *plaintext, *ciphertext;
2937 unsigned plaintext_pad_len;
2938 unsigned plaintext_len;
2940 /* Create KASUMI session */
2941 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2942 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2943 RTE_CRYPTO_CIPHER_KASUMI_F8,
2944 tdata->key.data, tdata->key.len);
2948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2949 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2951 /* Clear mbuf payload */
2952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2953 rte_pktmbuf_tailroom(ut_params->ibuf));
2955 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2956 /* Append data which is padded to a multiple */
2957 /* of the algorithms block size */
2958 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2959 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2961 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2964 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2966 /* Create KASUMI operation */
2967 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2969 tdata->plaintext.len,
2974 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2978 ut_params->obuf = ut_params->op->sym->m_dst;
2979 if (ut_params->obuf)
2980 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2982 ciphertext = plaintext;
2984 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2989 tdata->ciphertext.data,
2990 tdata->validCipherLenInBits.len,
2991 "KASUMI Ciphertext data not as expected");
2996 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 struct crypto_unittest_params *ut_params = &unittest_params;
3002 unsigned int plaintext_pad_len;
3003 unsigned int plaintext_len;
3005 const uint8_t *ciphertext;
3006 uint8_t buffer[2048];
3008 struct rte_cryptodev_info dev_info;
3010 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3011 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3012 printf("Device doesn't support scatter-gather. "
3017 /* Create KASUMI session */
3018 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3019 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3020 RTE_CRYPTO_CIPHER_KASUMI_F8,
3021 tdata->key.data, tdata->key.len);
3025 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3026 /* Append data which is padded to a multiple */
3027 /* of the algorithms block size */
3028 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3030 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3031 plaintext_pad_len, 10, 0);
3032 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3033 plaintext_pad_len, 3, 0);
3035 /* Append data which is padded to a multiple */
3036 /* of the algorithms block size */
3037 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3039 /* Create KASUMI operation */
3040 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3042 tdata->plaintext.len,
3047 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3049 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3051 ut_params->obuf = ut_params->op->sym->m_dst;
3052 if (ut_params->obuf)
3053 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3054 plaintext_pad_len, buffer);
3056 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3057 plaintext_pad_len, buffer);
3060 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3062 tdata->ciphertext.data,
3063 tdata->validCipherLenInBits.len,
3064 "KASUMI Ciphertext data not as expected");
3070 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3072 struct crypto_testsuite_params *ts_params = &testsuite_params;
3073 struct crypto_unittest_params *ut_params = &unittest_params;
3076 uint8_t *ciphertext, *plaintext;
3077 unsigned ciphertext_pad_len;
3078 unsigned ciphertext_len;
3080 /* Create KASUMI session */
3081 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3082 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3083 RTE_CRYPTO_CIPHER_KASUMI_F8,
3084 tdata->key.data, tdata->key.len);
3088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3089 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3091 /* Clear mbuf payload */
3092 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3093 rte_pktmbuf_tailroom(ut_params->ibuf));
3095 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3096 /* Append data which is padded to a multiple */
3097 /* of the algorithms block size */
3098 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3099 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3100 ciphertext_pad_len);
3101 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3102 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3104 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3106 /* Create KASUMI operation */
3107 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3109 tdata->ciphertext.len,
3114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3116 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3118 ut_params->obuf = ut_params->op->sym->m_dst;
3119 if (ut_params->obuf)
3120 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3122 plaintext = ciphertext;
3124 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3127 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3129 tdata->plaintext.data,
3130 tdata->validCipherLenInBits.len,
3131 "KASUMI Plaintext data not as expected");
3136 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3138 struct crypto_testsuite_params *ts_params = &testsuite_params;
3139 struct crypto_unittest_params *ut_params = &unittest_params;
3142 uint8_t *ciphertext, *plaintext;
3143 unsigned ciphertext_pad_len;
3144 unsigned ciphertext_len;
3146 /* Create KASUMI session */
3147 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3148 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3149 RTE_CRYPTO_CIPHER_KASUMI_F8,
3150 tdata->key.data, tdata->key.len);
3154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3156 /* Clear mbuf payload */
3157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3158 rte_pktmbuf_tailroom(ut_params->ibuf));
3160 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3161 /* Append data which is padded to a multiple */
3162 /* of the algorithms block size */
3163 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3164 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3165 ciphertext_pad_len);
3166 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3168 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3170 /* Create KASUMI operation */
3171 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3173 tdata->ciphertext.len,
3178 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3182 ut_params->obuf = ut_params->op->sym->m_dst;
3183 if (ut_params->obuf)
3184 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3186 plaintext = ciphertext;
3188 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3191 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3193 tdata->plaintext.data,
3194 tdata->validCipherLenInBits.len,
3195 "KASUMI Plaintext data not as expected");
3200 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3202 struct crypto_testsuite_params *ts_params = &testsuite_params;
3203 struct crypto_unittest_params *ut_params = &unittest_params;
3206 uint8_t *plaintext, *ciphertext;
3207 unsigned plaintext_pad_len;
3208 unsigned plaintext_len;
3210 /* Create SNOW 3G session */
3211 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3212 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3213 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3214 tdata->key.data, tdata->key.len);
3218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3220 /* Clear mbuf payload */
3221 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3222 rte_pktmbuf_tailroom(ut_params->ibuf));
3224 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3225 /* Append data which is padded to a multiple of */
3226 /* the algorithms block size */
3227 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3228 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3230 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3232 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3234 /* Create SNOW 3G operation */
3235 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3236 tdata->validCipherLenInBits.len,
3241 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3243 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3245 ut_params->obuf = ut_params->op->sym->m_dst;
3246 if (ut_params->obuf)
3247 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3249 ciphertext = plaintext;
3251 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3256 tdata->ciphertext.data,
3257 tdata->validDataLenInBits.len,
3258 "SNOW 3G Ciphertext data not as expected");
3264 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3266 struct crypto_testsuite_params *ts_params = &testsuite_params;
3267 struct crypto_unittest_params *ut_params = &unittest_params;
3268 uint8_t *plaintext, *ciphertext;
3271 unsigned plaintext_pad_len;
3272 unsigned plaintext_len;
3274 /* Create SNOW 3G session */
3275 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3276 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3277 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3278 tdata->key.data, tdata->key.len);
3282 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3283 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3285 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3286 "Failed to allocate input buffer in mempool");
3287 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3288 "Failed to allocate output buffer in mempool");
3290 /* Clear mbuf payload */
3291 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3292 rte_pktmbuf_tailroom(ut_params->ibuf));
3294 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3295 /* Append data which is padded to a multiple of */
3296 /* the algorithms block size */
3297 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3298 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3300 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3301 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3303 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3305 /* Create SNOW 3G operation */
3306 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3308 tdata->validCipherLenInBits.len,
3313 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3315 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3317 ut_params->obuf = ut_params->op->sym->m_dst;
3318 if (ut_params->obuf)
3319 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3321 ciphertext = plaintext;
3323 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3326 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3328 tdata->ciphertext.data,
3329 tdata->validDataLenInBits.len,
3330 "SNOW 3G Ciphertext data not as expected");
3335 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3337 struct crypto_testsuite_params *ts_params = &testsuite_params;
3338 struct crypto_unittest_params *ut_params = &unittest_params;
3341 unsigned int plaintext_pad_len;
3342 unsigned int plaintext_len;
3343 uint8_t buffer[10000];
3344 const uint8_t *ciphertext;
3346 struct rte_cryptodev_info dev_info;
3348 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3349 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3350 printf("Device doesn't support scatter-gather. "
3355 /* Create SNOW 3G session */
3356 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3357 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3358 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3359 tdata->key.data, tdata->key.len);
3363 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3364 /* Append data which is padded to a multiple of */
3365 /* the algorithms block size */
3366 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3368 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3369 plaintext_pad_len, 10, 0);
3370 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3371 plaintext_pad_len, 3, 0);
3373 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3374 "Failed to allocate input buffer in mempool");
3375 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3376 "Failed to allocate output buffer in mempool");
3378 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3380 /* Create SNOW 3G operation */
3381 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3383 tdata->validCipherLenInBits.len,
3388 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3390 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3392 ut_params->obuf = ut_params->op->sym->m_dst;
3393 if (ut_params->obuf)
3394 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3395 plaintext_len, buffer);
3397 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3398 plaintext_len, buffer);
3400 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3403 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3405 tdata->ciphertext.data,
3406 tdata->validDataLenInBits.len,
3407 "SNOW 3G Ciphertext data not as expected");
3412 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3414 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3416 uint8_t curr_byte, prev_byte;
3417 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3418 uint8_t lower_byte_mask = (1 << offset) - 1;
3421 prev_byte = buffer[0];
3422 buffer[0] >>= offset;
3424 for (i = 1; i < length_in_bytes; i++) {
3425 curr_byte = buffer[i];
3426 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3427 (curr_byte >> offset);
3428 prev_byte = curr_byte;
3433 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3435 struct crypto_testsuite_params *ts_params = &testsuite_params;
3436 struct crypto_unittest_params *ut_params = &unittest_params;
3437 uint8_t *plaintext, *ciphertext;
3439 uint32_t plaintext_len;
3440 uint32_t plaintext_pad_len;
3441 uint8_t extra_offset = 4;
3442 uint8_t *expected_ciphertext_shifted;
3444 /* Create SNOW 3G session */
3445 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3446 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3447 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3448 tdata->key.data, tdata->key.len);
3452 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3453 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3455 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3456 "Failed to allocate input buffer in mempool");
3457 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3458 "Failed to allocate output buffer in mempool");
3460 /* Clear mbuf payload */
3461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3462 rte_pktmbuf_tailroom(ut_params->ibuf));
3464 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3466 * Append data which is padded to a
3467 * multiple of the algorithms block size
3469 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3471 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3474 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3476 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3477 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3479 #ifdef RTE_APP_TEST_DEBUG
3480 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3482 /* Create SNOW 3G operation */
3483 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3485 tdata->validCipherLenInBits.len,
3490 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3492 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3494 ut_params->obuf = ut_params->op->sym->m_dst;
3495 if (ut_params->obuf)
3496 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3498 ciphertext = plaintext;
3500 #ifdef RTE_APP_TEST_DEBUG
3501 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3504 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3506 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3507 "failed to reserve memory for ciphertext shifted\n");
3509 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3510 ceil_byte_length(tdata->ciphertext.len));
3511 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3514 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3516 expected_ciphertext_shifted,
3517 tdata->validDataLenInBits.len,
3519 "SNOW 3G Ciphertext data not as expected");
3523 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3525 struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 struct crypto_unittest_params *ut_params = &unittest_params;
3530 uint8_t *plaintext, *ciphertext;
3531 unsigned ciphertext_pad_len;
3532 unsigned ciphertext_len;
3534 /* Create SNOW 3G session */
3535 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3536 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3537 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3538 tdata->key.data, tdata->key.len);
3542 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3544 /* Clear mbuf payload */
3545 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3546 rte_pktmbuf_tailroom(ut_params->ibuf));
3548 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3549 /* Append data which is padded to a multiple of */
3550 /* the algorithms block size */
3551 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3552 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3553 ciphertext_pad_len);
3554 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3556 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3558 /* Create SNOW 3G operation */
3559 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3560 tdata->validCipherLenInBits.len,
3565 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3567 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3568 ut_params->obuf = ut_params->op->sym->m_dst;
3569 if (ut_params->obuf)
3570 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3572 plaintext = ciphertext;
3574 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3577 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3578 tdata->plaintext.data,
3579 tdata->validDataLenInBits.len,
3580 "SNOW 3G Plaintext data not as expected");
3584 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3586 struct crypto_testsuite_params *ts_params = &testsuite_params;
3587 struct crypto_unittest_params *ut_params = &unittest_params;
3591 uint8_t *plaintext, *ciphertext;
3592 unsigned ciphertext_pad_len;
3593 unsigned ciphertext_len;
3595 /* Create SNOW 3G session */
3596 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3597 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3598 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3599 tdata->key.data, tdata->key.len);
3603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3604 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3606 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3607 "Failed to allocate input buffer");
3608 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3609 "Failed to allocate output buffer");
3611 /* Clear mbuf payload */
3612 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3613 rte_pktmbuf_tailroom(ut_params->ibuf));
3615 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3616 rte_pktmbuf_tailroom(ut_params->obuf));
3618 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3619 /* Append data which is padded to a multiple of */
3620 /* the algorithms block size */
3621 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3622 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3623 ciphertext_pad_len);
3624 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3625 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3627 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3629 /* Create SNOW 3G operation */
3630 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3632 tdata->validCipherLenInBits.len,
3637 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3639 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3640 ut_params->obuf = ut_params->op->sym->m_dst;
3641 if (ut_params->obuf)
3642 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3644 plaintext = ciphertext;
3646 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3649 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3650 tdata->plaintext.data,
3651 tdata->validDataLenInBits.len,
3652 "SNOW 3G Plaintext data not as expected");
3657 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3659 struct crypto_testsuite_params *ts_params = &testsuite_params;
3660 struct crypto_unittest_params *ut_params = &unittest_params;
3664 uint8_t *plaintext, *ciphertext;
3665 unsigned int plaintext_pad_len;
3666 unsigned int plaintext_len;
3668 struct rte_cryptodev_sym_capability_idx cap_idx;
3670 /* Check if device supports ZUC EEA3 */
3671 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3672 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3674 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3678 /* Check if device supports ZUC EIA3 */
3679 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3680 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3682 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3686 /* Create ZUC session */
3687 retval = create_zuc_cipher_auth_encrypt_generate_session(
3688 ts_params->valid_devs[0],
3692 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3694 /* clear mbuf payload */
3695 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3696 rte_pktmbuf_tailroom(ut_params->ibuf));
3698 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3699 /* Append data which is padded to a multiple of */
3700 /* the algorithms block size */
3701 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3702 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3704 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3706 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3708 /* Create ZUC operation */
3709 retval = create_zuc_cipher_hash_generate_operation(tdata);
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 *)
3721 ciphertext = plaintext;
3723 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3725 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3727 tdata->ciphertext.data,
3728 tdata->validDataLenInBits.len,
3729 "ZUC Ciphertext data not as expected");
3731 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3732 + plaintext_pad_len + tdata->aad.len;
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3739 "ZUC Generated auth tag not as expected");
3744 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3746 struct crypto_testsuite_params *ts_params = &testsuite_params;
3747 struct crypto_unittest_params *ut_params = &unittest_params;
3751 uint8_t *plaintext, *ciphertext;
3752 unsigned plaintext_pad_len;
3753 unsigned plaintext_len;
3755 /* Create SNOW 3G session */
3756 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3757 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3758 RTE_CRYPTO_AUTH_OP_GENERATE,
3759 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3760 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3761 tdata->key.data, tdata->key.len,
3762 tdata->aad.len, tdata->digest.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_cipher_hash_operation(tdata->digest.data,
3783 tdata->digest.len, tdata->aad.data,
3784 tdata->aad.len, /*tdata->plaintext.len,*/
3785 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3786 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3787 tdata->iv.data, tdata->iv.len,
3788 tdata->validCipherLenInBits.len,
3790 tdata->validAuthLenInBits.len,
3791 (tdata->aad.len << 3)
3796 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3798 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3799 ut_params->obuf = ut_params->op->sym->m_src;
3800 if (ut_params->obuf)
3801 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3804 ciphertext = plaintext;
3806 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3808 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3810 tdata->ciphertext.data,
3811 tdata->validDataLenInBits.len,
3812 "SNOW 3G Ciphertext data not as expected");
3814 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3815 + plaintext_pad_len + tdata->aad.len;
3818 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3821 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3822 "SNOW 3G Generated auth tag not as expected");
3826 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3828 struct crypto_testsuite_params *ts_params = &testsuite_params;
3829 struct crypto_unittest_params *ut_params = &unittest_params;
3833 uint8_t *plaintext, *ciphertext;
3834 unsigned plaintext_pad_len;
3835 unsigned plaintext_len;
3837 /* Create SNOW 3G session */
3838 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3839 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3840 RTE_CRYPTO_AUTH_OP_GENERATE,
3841 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3842 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3843 tdata->key.data, tdata->key.len,
3844 tdata->aad.len, tdata->digest.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 SNOW 3G operation */
3865 retval = create_wireless_algo_auth_cipher_operation(
3867 tdata->iv.data, tdata->iv.len,
3868 tdata->aad.data, tdata->aad.len,
3870 tdata->validCipherLenInBits.len,
3872 tdata->validAuthLenInBits.len,
3873 (tdata->aad.len << 3),
3874 RTE_CRYPTO_AUTH_SNOW3G_UIA2
3880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3883 ut_params->obuf = ut_params->op->sym->m_src;
3884 if (ut_params->obuf)
3885 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3888 ciphertext = plaintext;
3890 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3891 + plaintext_pad_len + tdata->aad.len;
3892 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3895 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3897 tdata->ciphertext.data,
3898 tdata->validDataLenInBits.len,
3899 "SNOW 3G Ciphertext data not as expected");
3902 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3905 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3906 "SNOW 3G Generated auth tag not as expected");
3911 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3913 struct crypto_testsuite_params *ts_params = &testsuite_params;
3914 struct crypto_unittest_params *ut_params = &unittest_params;
3918 uint8_t *plaintext, *ciphertext;
3919 unsigned plaintext_pad_len;
3920 unsigned plaintext_len;
3922 /* Create KASUMI session */
3923 retval = create_wireless_algo_auth_cipher_session(
3924 ts_params->valid_devs[0],
3925 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3926 RTE_CRYPTO_AUTH_OP_GENERATE,
3927 RTE_CRYPTO_AUTH_KASUMI_F9,
3928 RTE_CRYPTO_CIPHER_KASUMI_F8,
3929 tdata->key.data, tdata->key.len,
3930 tdata->aad.len, tdata->digest.len);
3933 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3935 /* clear mbuf payload */
3936 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3937 rte_pktmbuf_tailroom(ut_params->ibuf));
3939 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3940 /* Append data which is padded to a multiple of */
3941 /* the algorithms block size */
3942 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3943 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3945 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3947 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3949 /* Create KASUMI operation */
3950 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3951 tdata->iv.data, tdata->iv.len,
3952 tdata->aad.data, tdata->aad.len,
3954 tdata->validCipherLenInBits.len,
3956 tdata->validAuthLenInBits.len,
3957 (tdata->aad.len << 3),
3958 RTE_CRYPTO_AUTH_KASUMI_F9
3964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3966 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3967 ut_params->obuf = ut_params->op->sym->m_src;
3968 if (ut_params->obuf)
3969 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3972 ciphertext = plaintext;
3975 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3977 tdata->ciphertext.data,
3978 tdata->validCipherLenInBits.len,
3979 "KASUMI Ciphertext data not as expected");
3980 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3981 + plaintext_pad_len + tdata->aad.len;
3984 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3987 DIGEST_BYTE_LENGTH_KASUMI_F9,
3988 "KASUMI Generated auth tag not as expected");
3993 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3995 struct crypto_testsuite_params *ts_params = &testsuite_params;
3996 struct crypto_unittest_params *ut_params = &unittest_params;
4000 uint8_t *plaintext, *ciphertext;
4001 unsigned plaintext_pad_len;
4002 unsigned plaintext_len;
4004 /* Create KASUMI session */
4005 retval = create_wireless_algo_cipher_auth_session(
4006 ts_params->valid_devs[0],
4007 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4008 RTE_CRYPTO_AUTH_OP_GENERATE,
4009 RTE_CRYPTO_AUTH_KASUMI_F9,
4010 RTE_CRYPTO_CIPHER_KASUMI_F8,
4011 tdata->key.data, tdata->key.len,
4012 tdata->aad.len, tdata->digest.len);
4016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4018 /* clear mbuf payload */
4019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4020 rte_pktmbuf_tailroom(ut_params->ibuf));
4022 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4023 /* Append data which is padded to a multiple of */
4024 /* the algorithms block size */
4025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4026 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4028 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4030 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4032 /* Create KASUMI operation */
4033 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4034 tdata->digest.len, tdata->aad.data,
4036 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4037 RTE_CRYPTO_AUTH_KASUMI_F9,
4038 tdata->iv.data, tdata->iv.len,
4039 tdata->validCipherLenInBits.len,
4041 tdata->validAuthLenInBits.len,
4042 (tdata->aad.len << 3)
4047 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4049 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4050 ut_params->obuf = ut_params->op->sym->m_src;
4051 if (ut_params->obuf)
4052 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4055 ciphertext = plaintext;
4057 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4058 + plaintext_pad_len + tdata->aad.len;
4061 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4063 tdata->ciphertext.data,
4064 tdata->validCipherLenInBits.len,
4065 "KASUMI Ciphertext data not as expected");
4068 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4071 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4072 "KASUMI Generated auth tag not as expected");
4077 test_zuc_encryption(const struct wireless_test_data *tdata)
4079 struct crypto_testsuite_params *ts_params = &testsuite_params;
4080 struct crypto_unittest_params *ut_params = &unittest_params;
4083 uint8_t *plaintext, *ciphertext;
4084 unsigned plaintext_pad_len;
4085 unsigned plaintext_len;
4087 struct rte_cryptodev_sym_capability_idx cap_idx;
4089 /* Check if device supports ZUC EEA3 */
4090 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4091 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4093 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4097 /* Create ZUC session */
4098 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4099 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4100 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4101 tdata->key.data, tdata->key.len);
4105 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4107 /* Clear mbuf payload */
4108 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4109 rte_pktmbuf_tailroom(ut_params->ibuf));
4111 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4112 /* Append data which is padded to a multiple */
4113 /* of the algorithms block size */
4114 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4115 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4117 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4119 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4121 /* Create ZUC operation */
4122 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
4123 tdata->plaintext.len,
4128 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4130 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4132 ut_params->obuf = ut_params->op->sym->m_dst;
4133 if (ut_params->obuf)
4134 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4136 ciphertext = plaintext;
4138 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4141 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4143 tdata->ciphertext.data,
4144 tdata->validCipherLenInBits.len,
4145 "ZUC Ciphertext data not as expected");
4150 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4152 struct crypto_testsuite_params *ts_params = &testsuite_params;
4153 struct crypto_unittest_params *ut_params = &unittest_params;
4157 unsigned int plaintext_pad_len;
4158 unsigned int plaintext_len;
4159 const uint8_t *ciphertext;
4160 uint8_t ciphertext_buffer[2048];
4161 struct rte_cryptodev_info dev_info;
4163 struct rte_cryptodev_sym_capability_idx cap_idx;
4165 /* Check if device supports ZUC EEA3 */
4166 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4167 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4169 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4173 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4174 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4175 printf("Device doesn't support scatter-gather. "
4180 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 /* Append data which is padded to a multiple */
4183 /* of the algorithms block size */
4184 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4186 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4187 plaintext_pad_len, 10, 0);
4189 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4190 tdata->plaintext.data);
4192 /* Create ZUC session */
4193 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4194 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4195 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4196 tdata->key.data, tdata->key.len);
4200 /* Clear mbuf payload */
4202 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4204 /* Create ZUC operation */
4205 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4206 tdata->iv.len, tdata->plaintext.len,
4211 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4213 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4215 ut_params->obuf = ut_params->op->sym->m_dst;
4216 if (ut_params->obuf)
4217 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4218 0, plaintext_len, ciphertext_buffer);
4220 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4221 0, plaintext_len, ciphertext_buffer);
4224 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4229 tdata->ciphertext.data,
4230 tdata->validCipherLenInBits.len,
4231 "ZUC Ciphertext data not as expected");
4237 test_zuc_authentication(const struct wireless_test_data *tdata)
4239 struct crypto_testsuite_params *ts_params = &testsuite_params;
4240 struct crypto_unittest_params *ut_params = &unittest_params;
4243 unsigned plaintext_pad_len;
4244 unsigned plaintext_len;
4247 struct rte_cryptodev_sym_capability_idx cap_idx;
4249 /* Check if device supports ZUC EIA3 */
4250 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4251 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4253 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4257 /* Create ZUC session */
4258 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4259 tdata->key.data, tdata->key.len,
4260 tdata->aad.len, tdata->digest.len,
4261 RTE_CRYPTO_AUTH_OP_GENERATE,
4262 RTE_CRYPTO_AUTH_ZUC_EIA3);
4266 /* alloc mbuf and set payload */
4267 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4269 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4270 rte_pktmbuf_tailroom(ut_params->ibuf));
4272 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4273 /* Append data which is padded to a multiple of */
4274 /* the algorithms block size */
4275 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4276 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4278 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4280 /* Create ZUC operation */
4281 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4282 tdata->aad.data, tdata->aad.len,
4283 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4284 RTE_CRYPTO_AUTH_ZUC_EIA3,
4285 tdata->validAuthLenInBits.len,
4286 (tdata->aad.len << 3));
4290 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4292 ut_params->obuf = ut_params->op->sym->m_src;
4293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4294 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4295 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4298 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4301 DIGEST_BYTE_LENGTH_KASUMI_F9,
4302 "ZUC Generated auth tag not as expected");
4308 test_kasumi_encryption_test_case_1(void)
4310 return test_kasumi_encryption(&kasumi_test_case_1);
4314 test_kasumi_encryption_test_case_1_sgl(void)
4316 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4320 test_kasumi_encryption_test_case_1_oop(void)
4322 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4326 test_kasumi_encryption_test_case_1_oop_sgl(void)
4328 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4332 test_kasumi_encryption_test_case_2(void)
4334 return test_kasumi_encryption(&kasumi_test_case_2);
4338 test_kasumi_encryption_test_case_3(void)
4340 return test_kasumi_encryption(&kasumi_test_case_3);
4344 test_kasumi_encryption_test_case_4(void)
4346 return test_kasumi_encryption(&kasumi_test_case_4);
4350 test_kasumi_encryption_test_case_5(void)
4352 return test_kasumi_encryption(&kasumi_test_case_5);
4356 test_kasumi_decryption_test_case_1(void)
4358 return test_kasumi_decryption(&kasumi_test_case_1);
4362 test_kasumi_decryption_test_case_1_oop(void)
4364 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4368 test_kasumi_decryption_test_case_2(void)
4370 return test_kasumi_decryption(&kasumi_test_case_2);
4374 test_kasumi_decryption_test_case_3(void)
4376 return test_kasumi_decryption(&kasumi_test_case_3);
4380 test_kasumi_decryption_test_case_4(void)
4382 return test_kasumi_decryption(&kasumi_test_case_4);
4386 test_kasumi_decryption_test_case_5(void)
4388 return test_kasumi_decryption(&kasumi_test_case_5);
4391 test_snow3g_encryption_test_case_1(void)
4393 return test_snow3g_encryption(&snow3g_test_case_1);
4397 test_snow3g_encryption_test_case_1_oop(void)
4399 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4403 test_snow3g_encryption_test_case_1_oop_sgl(void)
4405 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4410 test_snow3g_encryption_test_case_1_offset_oop(void)
4412 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4416 test_snow3g_encryption_test_case_2(void)
4418 return test_snow3g_encryption(&snow3g_test_case_2);
4422 test_snow3g_encryption_test_case_3(void)
4424 return test_snow3g_encryption(&snow3g_test_case_3);
4428 test_snow3g_encryption_test_case_4(void)
4430 return test_snow3g_encryption(&snow3g_test_case_4);
4434 test_snow3g_encryption_test_case_5(void)
4436 return test_snow3g_encryption(&snow3g_test_case_5);
4440 test_snow3g_decryption_test_case_1(void)
4442 return test_snow3g_decryption(&snow3g_test_case_1);
4446 test_snow3g_decryption_test_case_1_oop(void)
4448 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4452 test_snow3g_decryption_test_case_2(void)
4454 return test_snow3g_decryption(&snow3g_test_case_2);
4458 test_snow3g_decryption_test_case_3(void)
4460 return test_snow3g_decryption(&snow3g_test_case_3);
4464 test_snow3g_decryption_test_case_4(void)
4466 return test_snow3g_decryption(&snow3g_test_case_4);
4470 test_snow3g_decryption_test_case_5(void)
4472 return test_snow3g_decryption(&snow3g_test_case_5);
4475 test_snow3g_cipher_auth_test_case_1(void)
4477 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4481 test_snow3g_auth_cipher_test_case_1(void)
4483 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4487 test_kasumi_auth_cipher_test_case_1(void)
4489 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4493 test_kasumi_cipher_auth_test_case_1(void)
4495 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4499 test_zuc_encryption_test_case_1(void)
4501 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4505 test_zuc_encryption_test_case_2(void)
4507 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4511 test_zuc_encryption_test_case_3(void)
4513 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4517 test_zuc_encryption_test_case_4(void)
4519 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4523 test_zuc_encryption_test_case_5(void)
4525 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4529 test_zuc_encryption_test_case_6_sgl(void)
4531 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4535 test_zuc_hash_generate_test_case_1(void)
4537 return test_zuc_authentication(&zuc_test_case_auth_1b);
4541 test_zuc_hash_generate_test_case_2(void)
4543 return test_zuc_authentication(&zuc_test_case_auth_90b);
4547 test_zuc_hash_generate_test_case_3(void)
4549 return test_zuc_authentication(&zuc_test_case_auth_577b);
4553 test_zuc_hash_generate_test_case_4(void)
4555 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4559 test_zuc_hash_generate_test_case_5(void)
4561 return test_zuc_authentication(&zuc_test_auth_5670b);
4565 test_zuc_hash_generate_test_case_6(void)
4567 return test_zuc_authentication(&zuc_test_case_auth_128b);
4571 test_zuc_hash_generate_test_case_7(void)
4573 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4577 test_zuc_hash_generate_test_case_8(void)
4579 return test_zuc_authentication(&zuc_test_case_auth_584b);
4583 test_zuc_cipher_auth_test_case_1(void)
4585 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4589 test_zuc_cipher_auth_test_case_2(void)
4591 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4595 test_3DES_chain_qat_all(void)
4597 struct crypto_testsuite_params *ts_params = &testsuite_params;
4600 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4601 ts_params->op_mpool, ts_params->valid_devs[0],
4602 RTE_CRYPTODEV_QAT_SYM_PMD,
4603 BLKCIPHER_3DES_CHAIN_TYPE);
4605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4607 return TEST_SUCCESS;
4611 test_DES_cipheronly_qat_all(void)
4613 struct crypto_testsuite_params *ts_params = &testsuite_params;
4616 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4617 ts_params->op_mpool, ts_params->valid_devs[0],
4618 RTE_CRYPTODEV_QAT_SYM_PMD,
4619 BLKCIPHER_DES_CIPHERONLY_TYPE);
4621 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4623 return TEST_SUCCESS;
4627 test_DES_docsis_openssl_all(void)
4629 struct crypto_testsuite_params *ts_params = &testsuite_params;
4632 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4633 ts_params->op_mpool, ts_params->valid_devs[0],
4634 RTE_CRYPTODEV_OPENSSL_PMD,
4635 BLKCIPHER_DES_DOCSIS_TYPE);
4637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4639 return TEST_SUCCESS;
4643 test_3DES_chain_dpaa2_sec_all(void)
4645 struct crypto_testsuite_params *ts_params = &testsuite_params;
4648 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4649 ts_params->op_mpool, ts_params->valid_devs[0],
4650 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4651 BLKCIPHER_3DES_CHAIN_TYPE);
4653 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4655 return TEST_SUCCESS;
4659 test_3DES_cipheronly_dpaa2_sec_all(void)
4661 struct crypto_testsuite_params *ts_params = &testsuite_params;
4664 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4665 ts_params->op_mpool, ts_params->valid_devs[0],
4666 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4667 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4671 return TEST_SUCCESS;
4675 test_3DES_cipheronly_qat_all(void)
4677 struct crypto_testsuite_params *ts_params = &testsuite_params;
4680 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4681 ts_params->op_mpool, ts_params->valid_devs[0],
4682 RTE_CRYPTODEV_QAT_SYM_PMD,
4683 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4685 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4687 return TEST_SUCCESS;
4691 test_3DES_chain_openssl_all(void)
4693 struct crypto_testsuite_params *ts_params = &testsuite_params;
4696 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4697 ts_params->op_mpool, ts_params->valid_devs[0],
4698 RTE_CRYPTODEV_OPENSSL_PMD,
4699 BLKCIPHER_3DES_CHAIN_TYPE);
4701 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4703 return TEST_SUCCESS;
4707 test_3DES_cipheronly_openssl_all(void)
4709 struct crypto_testsuite_params *ts_params = &testsuite_params;
4712 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4713 ts_params->op_mpool, ts_params->valid_devs[0],
4714 RTE_CRYPTODEV_OPENSSL_PMD,
4715 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4717 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4719 return TEST_SUCCESS;
4722 /* ***** AES-GCM Tests ***** */
4725 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4726 const uint8_t *key, const uint8_t key_len,
4727 const uint8_t aad_len, const uint8_t auth_len,
4728 enum rte_crypto_auth_operation auth_op)
4730 uint8_t cipher_key[key_len];
4732 struct crypto_unittest_params *ut_params = &unittest_params;
4734 memcpy(cipher_key, key, key_len);
4736 /* Setup Cipher Parameters */
4737 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4738 ut_params->cipher_xform.next = NULL;
4740 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4741 ut_params->auth_xform.auth.op = auth_op;
4742 ut_params->cipher_xform.cipher.op = op;
4743 ut_params->cipher_xform.cipher.key.data = cipher_key;
4744 ut_params->cipher_xform.cipher.key.length = key_len;
4746 TEST_HEXDUMP(stdout, "key:", key, key_len);
4748 /* Setup Authentication Parameters */
4749 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4750 ut_params->auth_xform.next = NULL;
4752 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4754 ut_params->auth_xform.auth.digest_length = auth_len;
4755 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4756 ut_params->auth_xform.auth.key.length = 0;
4757 ut_params->auth_xform.auth.key.data = NULL;
4759 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4760 ut_params->cipher_xform.next = &ut_params->auth_xform;
4762 /* Create Crypto session*/
4763 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4764 &ut_params->cipher_xform);
4765 } else {/* Create Crypto session*/
4766 ut_params->auth_xform.next = &ut_params->cipher_xform;
4767 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4768 &ut_params->auth_xform);
4771 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4777 create_gcm_xforms(struct rte_crypto_op *op,
4778 enum rte_crypto_cipher_operation cipher_op,
4779 uint8_t *key, const uint8_t key_len,
4780 const uint8_t aad_len, const uint8_t auth_len,
4781 enum rte_crypto_auth_operation auth_op)
4783 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4784 "failed to allocate space for crypto transforms");
4786 struct rte_crypto_sym_op *sym_op = op->sym;
4788 /* Setup Cipher Parameters */
4789 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4790 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4791 sym_op->xform->cipher.op = cipher_op;
4792 sym_op->xform->cipher.key.data = key;
4793 sym_op->xform->cipher.key.length = key_len;
4795 TEST_HEXDUMP(stdout, "key:", key, key_len);
4797 /* Setup Authentication Parameters */
4798 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4799 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4800 sym_op->xform->next->auth.op = auth_op;
4801 sym_op->xform->next->auth.digest_length = auth_len;
4802 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4803 sym_op->xform->next->auth.key.length = 0;
4804 sym_op->xform->next->auth.key.data = NULL;
4805 sym_op->xform->next->next = NULL;
4811 create_gcm_operation(enum rte_crypto_cipher_operation op,
4812 const struct gcm_test_data *tdata)
4814 struct crypto_testsuite_params *ts_params = &testsuite_params;
4815 struct crypto_unittest_params *ut_params = &unittest_params;
4817 uint8_t *plaintext, *ciphertext;
4818 unsigned int aad_pad_len, plaintext_pad_len;
4820 /* Generate Crypto op data structure */
4821 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4822 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4823 TEST_ASSERT_NOT_NULL(ut_params->op,
4824 "Failed to allocate symmetric crypto operation struct");
4826 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4828 /* Append aad data */
4829 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4830 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4832 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4833 "no room to append aad");
4835 sym_op->auth.aad.length = tdata->aad.len;
4836 sym_op->auth.aad.phys_addr =
4837 rte_pktmbuf_mtophys(ut_params->ibuf);
4838 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4839 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4840 sym_op->auth.aad.length);
4842 /* Append IV at the end of the crypto operation*/
4843 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4844 uint8_t *, IV_OFFSET);
4845 sym_op->cipher.iv.offset = IV_OFFSET;
4846 sym_op->cipher.iv.length = tdata->iv.len;
4848 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4849 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4850 sym_op->cipher.iv.length);
4852 /* Append plaintext/ciphertext */
4853 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4854 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4855 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4857 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4859 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4860 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4861 tdata->plaintext.len);
4863 if (ut_params->obuf) {
4864 ciphertext = (uint8_t *)rte_pktmbuf_append(
4866 plaintext_pad_len + aad_pad_len);
4867 TEST_ASSERT_NOT_NULL(ciphertext,
4868 "no room to append ciphertext");
4870 memset(ciphertext + aad_pad_len, 0,
4871 tdata->ciphertext.len);
4874 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4875 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4877 TEST_ASSERT_NOT_NULL(ciphertext,
4878 "no room to append ciphertext");
4880 memcpy(ciphertext, tdata->ciphertext.data,
4881 tdata->ciphertext.len);
4882 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4883 tdata->ciphertext.len);
4885 if (ut_params->obuf) {
4886 plaintext = (uint8_t *)rte_pktmbuf_append(
4888 plaintext_pad_len + aad_pad_len);
4889 TEST_ASSERT_NOT_NULL(plaintext,
4890 "no room to append plaintext");
4892 memset(plaintext + aad_pad_len, 0,
4893 tdata->plaintext.len);
4897 /* Append digest data */
4898 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4899 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4900 ut_params->obuf ? ut_params->obuf :
4902 tdata->auth_tag.len);
4903 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4904 "no room to append digest");
4905 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4906 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4907 ut_params->obuf ? ut_params->obuf :
4911 sym_op->auth.digest.length = tdata->auth_tag.len;
4913 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4914 ut_params->ibuf, tdata->auth_tag.len);
4915 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4916 "no room to append digest");
4917 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4919 plaintext_pad_len + aad_pad_len);
4920 sym_op->auth.digest.length = tdata->auth_tag.len;
4922 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4923 tdata->auth_tag.len);
4924 TEST_HEXDUMP(stdout, "digest:",
4925 sym_op->auth.digest.data,
4926 sym_op->auth.digest.length);
4929 sym_op->cipher.data.length = tdata->plaintext.len;
4930 sym_op->cipher.data.offset = aad_pad_len;
4932 sym_op->auth.data.length = tdata->plaintext.len;
4933 sym_op->auth.data.offset = aad_pad_len;
4939 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4941 struct crypto_testsuite_params *ts_params = &testsuite_params;
4942 struct crypto_unittest_params *ut_params = &unittest_params;
4945 uint8_t *ciphertext, *auth_tag;
4946 uint16_t plaintext_pad_len;
4949 /* Create GCM session */
4950 retval = create_gcm_session(ts_params->valid_devs[0],
4951 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4952 tdata->key.data, tdata->key.len,
4953 tdata->aad.len, tdata->auth_tag.len,
4954 RTE_CRYPTO_AUTH_OP_GENERATE);
4958 if (tdata->aad.len > MBUF_SIZE) {
4959 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4960 /* Populate full size of add data */
4961 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4962 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4964 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4966 /* clear mbuf payload */
4967 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4968 rte_pktmbuf_tailroom(ut_params->ibuf));
4970 /* Create GCM operation */
4971 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4975 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4977 ut_params->op->sym->m_src = ut_params->ibuf;
4979 /* Process crypto operation */
4980 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4981 ut_params->op), "failed to process sym crypto op");
4983 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4984 "crypto op processing failed");
4986 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4988 if (ut_params->op->sym->m_dst) {
4989 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4991 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4992 uint8_t *, plaintext_pad_len);
4994 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4996 ut_params->op->sym->cipher.data.offset);
4997 auth_tag = ciphertext + plaintext_pad_len;
5000 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5001 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5006 tdata->ciphertext.data,
5007 tdata->ciphertext.len,
5008 "GCM Ciphertext data not as expected");
5010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5012 tdata->auth_tag.data,
5013 tdata->auth_tag.len,
5014 "GCM Generated auth tag not as expected");
5021 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
5023 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5027 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
5029 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5033 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
5035 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5039 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
5041 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5045 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
5047 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5051 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
5053 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5057 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
5059 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5063 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
5065 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5069 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
5071 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5075 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
5077 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5081 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5083 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5087 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5089 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5093 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5095 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5099 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5101 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5105 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5107 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5111 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5113 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5117 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5119 struct crypto_testsuite_params *ts_params = &testsuite_params;
5120 struct crypto_unittest_params *ut_params = &unittest_params;
5126 /* Create GCM session */
5127 retval = create_gcm_session(ts_params->valid_devs[0],
5128 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5129 tdata->key.data, tdata->key.len,
5130 tdata->aad.len, tdata->auth_tag.len,
5131 RTE_CRYPTO_AUTH_OP_VERIFY);
5135 /* alloc mbuf and set payload */
5136 if (tdata->aad.len > MBUF_SIZE) {
5137 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5138 /* Populate full size of add data */
5139 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5140 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5142 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5145 rte_pktmbuf_tailroom(ut_params->ibuf));
5147 /* Create GCM operation */
5148 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5152 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5154 ut_params->op->sym->m_src = ut_params->ibuf;
5156 /* Process crypto operation */
5157 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5158 ut_params->op), "failed to process sym crypto op");
5160 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5161 "crypto op processing failed");
5163 if (ut_params->op->sym->m_dst)
5164 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5167 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5169 ut_params->op->sym->cipher.data.offset);
5171 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5174 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 tdata->plaintext.data,
5177 tdata->plaintext.len,
5178 "GCM plaintext data not as expected");
5180 TEST_ASSERT_EQUAL(ut_params->op->status,
5181 RTE_CRYPTO_OP_STATUS_SUCCESS,
5182 "GCM authentication failed");
5187 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5189 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5193 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5195 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5199 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5201 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5205 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5207 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5211 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5213 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5217 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5219 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5223 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5225 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5229 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5231 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5235 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5237 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5241 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5243 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5247 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5249 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5253 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5255 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5259 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5261 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5265 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5267 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5271 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5273 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5277 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5279 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5283 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5285 struct crypto_testsuite_params *ts_params = &testsuite_params;
5286 struct crypto_unittest_params *ut_params = &unittest_params;
5289 uint8_t *ciphertext, *auth_tag;
5290 uint16_t plaintext_pad_len;
5292 /* Create GCM session */
5293 retval = create_gcm_session(ts_params->valid_devs[0],
5294 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5295 tdata->key.data, tdata->key.len,
5296 tdata->aad.len, tdata->auth_tag.len,
5297 RTE_CRYPTO_AUTH_OP_GENERATE);
5301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5302 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5304 /* clear mbuf payload */
5305 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5306 rte_pktmbuf_tailroom(ut_params->ibuf));
5307 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5308 rte_pktmbuf_tailroom(ut_params->obuf));
5310 /* Create GCM operation */
5311 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5315 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5317 ut_params->op->sym->m_src = ut_params->ibuf;
5318 ut_params->op->sym->m_dst = ut_params->obuf;
5320 /* Process crypto operation */
5321 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5322 ut_params->op), "failed to process sym crypto op");
5324 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5325 "crypto op processing failed");
5327 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5329 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5330 ut_params->op->sym->cipher.data.offset);
5331 auth_tag = ciphertext + plaintext_pad_len;
5333 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5334 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5337 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5339 tdata->ciphertext.data,
5340 tdata->ciphertext.len,
5341 "GCM Ciphertext data not as expected");
5343 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5345 tdata->auth_tag.data,
5346 tdata->auth_tag.len,
5347 "GCM Generated auth tag not as expected");
5354 test_mb_AES_GCM_authenticated_encryption_oop(void)
5356 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5360 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5362 struct crypto_testsuite_params *ts_params = &testsuite_params;
5363 struct crypto_unittest_params *ut_params = &unittest_params;
5368 /* Create GCM session */
5369 retval = create_gcm_session(ts_params->valid_devs[0],
5370 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5371 tdata->key.data, tdata->key.len,
5372 tdata->aad.len, tdata->auth_tag.len,
5373 RTE_CRYPTO_AUTH_OP_VERIFY);
5377 /* alloc mbuf and set payload */
5378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5379 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5382 rte_pktmbuf_tailroom(ut_params->ibuf));
5383 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5384 rte_pktmbuf_tailroom(ut_params->obuf));
5386 /* Create GCM operation */
5387 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5391 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5393 ut_params->op->sym->m_src = ut_params->ibuf;
5394 ut_params->op->sym->m_dst = ut_params->obuf;
5396 /* Process crypto operation */
5397 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5398 ut_params->op), "failed to process sym crypto op");
5400 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5401 "crypto op processing failed");
5403 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5404 ut_params->op->sym->cipher.data.offset);
5406 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5409 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5411 tdata->plaintext.data,
5412 tdata->plaintext.len,
5413 "GCM plaintext data not as expected");
5415 TEST_ASSERT_EQUAL(ut_params->op->status,
5416 RTE_CRYPTO_OP_STATUS_SUCCESS,
5417 "GCM authentication failed");
5422 test_mb_AES_GCM_authenticated_decryption_oop(void)
5424 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5428 test_AES_GCM_authenticated_encryption_sessionless(
5429 const struct gcm_test_data *tdata)
5431 struct crypto_testsuite_params *ts_params = &testsuite_params;
5432 struct crypto_unittest_params *ut_params = &unittest_params;
5435 uint8_t *ciphertext, *auth_tag;
5436 uint16_t plaintext_pad_len;
5437 uint8_t key[tdata->key.len + 1];
5439 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5441 /* clear mbuf payload */
5442 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5443 rte_pktmbuf_tailroom(ut_params->ibuf));
5445 /* Create GCM operation */
5446 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5450 /* Create GCM xforms */
5451 memcpy(key, tdata->key.data, tdata->key.len);
5452 retval = create_gcm_xforms(ut_params->op,
5453 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5454 key, tdata->key.len,
5455 tdata->aad.len, tdata->auth_tag.len,
5456 RTE_CRYPTO_AUTH_OP_GENERATE);
5460 ut_params->op->sym->m_src = ut_params->ibuf;
5462 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5463 RTE_CRYPTO_OP_SESSIONLESS,
5464 "crypto op session type not sessionless");
5466 /* Process crypto operation */
5467 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5468 ut_params->op), "failed to process sym crypto op");
5470 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5472 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5473 "crypto op status not success");
5475 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5477 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5478 ut_params->op->sym->cipher.data.offset);
5479 auth_tag = ciphertext + plaintext_pad_len;
5481 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5482 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5487 tdata->ciphertext.data,
5488 tdata->ciphertext.len,
5489 "GCM Ciphertext data not as expected");
5491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5493 tdata->auth_tag.data,
5494 tdata->auth_tag.len,
5495 "GCM Generated auth tag not as expected");
5502 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5504 return test_AES_GCM_authenticated_encryption_sessionless(
5509 test_AES_GCM_authenticated_decryption_sessionless(
5510 const struct gcm_test_data *tdata)
5512 struct crypto_testsuite_params *ts_params = &testsuite_params;
5513 struct crypto_unittest_params *ut_params = &unittest_params;
5517 uint8_t key[tdata->key.len + 1];
5519 /* alloc mbuf and set payload */
5520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5523 rte_pktmbuf_tailroom(ut_params->ibuf));
5525 /* Create GCM operation */
5526 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5530 /* Create GCM xforms */
5531 memcpy(key, tdata->key.data, tdata->key.len);
5532 retval = create_gcm_xforms(ut_params->op,
5533 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5534 key, tdata->key.len,
5535 tdata->aad.len, tdata->auth_tag.len,
5536 RTE_CRYPTO_AUTH_OP_VERIFY);
5540 ut_params->op->sym->m_src = ut_params->ibuf;
5542 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5543 RTE_CRYPTO_OP_SESSIONLESS,
5544 "crypto op session type not sessionless");
5546 /* Process crypto operation */
5547 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5548 ut_params->op), "failed to process sym crypto op");
5550 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5553 "crypto op status not success");
5555 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5556 ut_params->op->sym->cipher.data.offset);
5558 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5561 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5563 tdata->plaintext.data,
5564 tdata->plaintext.len,
5565 "GCM plaintext data not as expected");
5567 TEST_ASSERT_EQUAL(ut_params->op->status,
5568 RTE_CRYPTO_OP_STATUS_SUCCESS,
5569 "GCM authentication failed");
5574 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5576 return test_AES_GCM_authenticated_decryption_sessionless(
5583 struct crypto_testsuite_params *ts_params = &testsuite_params;
5584 struct rte_cryptodev_stats stats;
5585 struct rte_cryptodev *dev;
5586 cryptodev_stats_get_t temp_pfn;
5588 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5589 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5590 &stats) == -ENODEV),
5591 "rte_cryptodev_stats_get invalid dev failed");
5592 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5593 "rte_cryptodev_stats_get invalid Param failed");
5594 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5595 temp_pfn = dev->dev_ops->stats_get;
5596 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5597 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5599 "rte_cryptodev_stats_get invalid Param failed");
5600 dev->dev_ops->stats_get = temp_pfn;
5602 /* Test expected values */
5604 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5606 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5608 "rte_cryptodev_stats_get failed");
5609 TEST_ASSERT((stats.enqueued_count == 1),
5610 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5611 TEST_ASSERT((stats.dequeued_count == 1),
5612 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5613 TEST_ASSERT((stats.enqueue_err_count == 0),
5614 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5615 TEST_ASSERT((stats.dequeue_err_count == 0),
5616 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5618 /* invalid device but should ignore and not reset device stats*/
5619 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5620 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5622 "rte_cryptodev_stats_get failed");
5623 TEST_ASSERT((stats.enqueued_count == 1),
5624 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5626 /* check that a valid reset clears stats */
5627 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5628 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5630 "rte_cryptodev_stats_get failed");
5631 TEST_ASSERT((stats.enqueued_count == 0),
5632 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5633 TEST_ASSERT((stats.dequeued_count == 0),
5634 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5636 return TEST_SUCCESS;
5639 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5640 struct crypto_unittest_params *ut_params,
5641 enum rte_crypto_auth_operation op,
5642 const struct HMAC_MD5_vector *test_case)
5646 memcpy(key, test_case->key.data, test_case->key.len);
5648 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5649 ut_params->auth_xform.next = NULL;
5650 ut_params->auth_xform.auth.op = op;
5652 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5654 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5655 ut_params->auth_xform.auth.add_auth_data_length = 0;
5656 ut_params->auth_xform.auth.key.length = test_case->key.len;
5657 ut_params->auth_xform.auth.key.data = key;
5659 ut_params->sess = rte_cryptodev_sym_session_create(
5660 ts_params->valid_devs[0], &ut_params->auth_xform);
5662 if (ut_params->sess == NULL)
5665 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5667 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5668 rte_pktmbuf_tailroom(ut_params->ibuf));
5673 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5674 const struct HMAC_MD5_vector *test_case,
5675 uint8_t **plaintext)
5677 uint16_t plaintext_pad_len;
5679 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5681 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5684 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5686 memcpy(*plaintext, test_case->plaintext.data,
5687 test_case->plaintext.len);
5689 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5690 ut_params->ibuf, MD5_DIGEST_LEN);
5691 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5692 "no room to append digest");
5693 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5694 ut_params->ibuf, plaintext_pad_len);
5695 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5697 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5698 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5699 test_case->auth_tag.len);
5702 sym_op->auth.data.offset = 0;
5703 sym_op->auth.data.length = test_case->plaintext.len;
5705 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5706 ut_params->op->sym->m_src = ut_params->ibuf;
5712 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5714 uint16_t plaintext_pad_len;
5715 uint8_t *plaintext, *auth_tag;
5717 struct crypto_testsuite_params *ts_params = &testsuite_params;
5718 struct crypto_unittest_params *ut_params = &unittest_params;
5720 if (MD5_HMAC_create_session(ts_params, ut_params,
5721 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5724 /* Generate Crypto op data structure */
5725 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5726 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5727 TEST_ASSERT_NOT_NULL(ut_params->op,
5728 "Failed to allocate symmetric crypto operation struct");
5730 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5733 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5736 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5737 ut_params->op), "failed to process sym crypto op");
5739 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5740 "crypto op processing failed");
5742 if (ut_params->op->sym->m_dst) {
5743 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5744 uint8_t *, plaintext_pad_len);
5746 auth_tag = plaintext + plaintext_pad_len;
5749 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5751 test_case->auth_tag.data,
5752 test_case->auth_tag.len,
5753 "HMAC_MD5 generated tag not as expected");
5755 return TEST_SUCCESS;
5759 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5763 struct crypto_testsuite_params *ts_params = &testsuite_params;
5764 struct crypto_unittest_params *ut_params = &unittest_params;
5766 if (MD5_HMAC_create_session(ts_params, ut_params,
5767 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5771 /* Generate Crypto op data structure */
5772 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5773 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5774 TEST_ASSERT_NOT_NULL(ut_params->op,
5775 "Failed to allocate symmetric crypto operation struct");
5777 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5780 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5781 ut_params->op), "failed to process sym crypto op");
5783 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5784 "HMAC_MD5 crypto op processing failed");
5786 return TEST_SUCCESS;
5790 test_MD5_HMAC_generate_case_1(void)
5792 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5796 test_MD5_HMAC_verify_case_1(void)
5798 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5802 test_MD5_HMAC_generate_case_2(void)
5804 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5808 test_MD5_HMAC_verify_case_2(void)
5810 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5814 test_multi_session(void)
5816 struct crypto_testsuite_params *ts_params = &testsuite_params;
5817 struct crypto_unittest_params *ut_params = &unittest_params;
5819 struct rte_cryptodev_info dev_info;
5820 struct rte_cryptodev_sym_session **sessions;
5824 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5825 aes_cbc_key, hmac_sha512_key);
5828 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5830 sessions = rte_malloc(NULL,
5831 (sizeof(struct rte_cryptodev_sym_session *) *
5832 dev_info.sym.max_nb_sessions) + 1, 0);
5834 /* Create multiple crypto sessions*/
5835 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5836 sessions[i] = rte_cryptodev_sym_session_create(
5837 ts_params->valid_devs[0],
5838 &ut_params->auth_xform);
5839 TEST_ASSERT_NOT_NULL(sessions[i],
5840 "Session creation failed at session number %u",
5843 /* Attempt to send a request on each session */
5844 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5848 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5849 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5851 "Failed to perform decrypt on request number %u.", i);
5852 /* free crypto operation structure */
5854 rte_crypto_op_free(ut_params->op);
5857 * free mbuf - both obuf and ibuf are usually the same,
5858 * so check if they point at the same address is necessary,
5859 * to avoid freeing the mbuf twice.
5861 if (ut_params->obuf) {
5862 rte_pktmbuf_free(ut_params->obuf);
5863 if (ut_params->ibuf == ut_params->obuf)
5864 ut_params->ibuf = 0;
5865 ut_params->obuf = 0;
5867 if (ut_params->ibuf) {
5868 rte_pktmbuf_free(ut_params->ibuf);
5869 ut_params->ibuf = 0;
5873 /* Next session create should fail */
5874 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5875 &ut_params->auth_xform);
5876 TEST_ASSERT_NULL(sessions[i],
5877 "Session creation succeeded unexpectedly!");
5879 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5880 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5885 return TEST_SUCCESS;
5888 struct multi_session_params {
5889 struct crypto_unittest_params ut_params;
5890 uint8_t *cipher_key;
5892 const uint8_t *cipher;
5893 const uint8_t *digest;
5897 #define MB_SESSION_NUMBER 3
5900 test_multi_session_random_usage(void)
5902 struct crypto_testsuite_params *ts_params = &testsuite_params;
5903 struct rte_cryptodev_info dev_info;
5904 struct rte_cryptodev_sym_session **sessions;
5906 struct multi_session_params ut_paramz[] = {
5909 .cipher_key = ms_aes_cbc_key0,
5910 .hmac_key = ms_hmac_key0,
5911 .cipher = ms_aes_cbc_cipher0,
5912 .digest = ms_hmac_digest0,
5913 .iv = ms_aes_cbc_iv0
5916 .cipher_key = ms_aes_cbc_key1,
5917 .hmac_key = ms_hmac_key1,
5918 .cipher = ms_aes_cbc_cipher1,
5919 .digest = ms_hmac_digest1,
5920 .iv = ms_aes_cbc_iv1
5923 .cipher_key = ms_aes_cbc_key2,
5924 .hmac_key = ms_hmac_key2,
5925 .cipher = ms_aes_cbc_cipher2,
5926 .digest = ms_hmac_digest2,
5927 .iv = ms_aes_cbc_iv2
5932 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5934 sessions = rte_malloc(NULL,
5935 (sizeof(struct rte_cryptodev_sym_session *)
5936 * dev_info.sym.max_nb_sessions) + 1, 0);
5938 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5939 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5940 sizeof(struct crypto_unittest_params));
5942 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5943 &ut_paramz[i].ut_params,
5944 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5946 /* Create multiple crypto sessions*/
5947 sessions[i] = rte_cryptodev_sym_session_create(
5948 ts_params->valid_devs[0],
5949 &ut_paramz[i].ut_params.auth_xform);
5951 TEST_ASSERT_NOT_NULL(sessions[i],
5952 "Session creation failed at session number %u",
5958 for (i = 0; i < 40000; i++) {
5960 j = rand() % MB_SESSION_NUMBER;
5962 TEST_ASSERT_SUCCESS(
5963 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5965 &ut_paramz[j].ut_params,
5966 ts_params, ut_paramz[j].cipher,
5967 ut_paramz[j].digest,
5969 "Failed to perform decrypt on request number %u.", i);
5971 if (ut_paramz[j].ut_params.op)
5972 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5975 * free mbuf - both obuf and ibuf are usually the same,
5976 * so check if they point at the same address is necessary,
5977 * to avoid freeing the mbuf twice.
5979 if (ut_paramz[j].ut_params.obuf) {
5980 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5981 if (ut_paramz[j].ut_params.ibuf
5982 == ut_paramz[j].ut_params.obuf)
5983 ut_paramz[j].ut_params.ibuf = 0;
5984 ut_paramz[j].ut_params.obuf = 0;
5986 if (ut_paramz[j].ut_params.ibuf) {
5987 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5988 ut_paramz[j].ut_params.ibuf = 0;
5992 for (i = 0; i < MB_SESSION_NUMBER; i++)
5993 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5998 return TEST_SUCCESS;
6002 test_null_cipher_only_operation(void)
6004 struct crypto_testsuite_params *ts_params = &testsuite_params;
6005 struct crypto_unittest_params *ut_params = &unittest_params;
6007 /* Generate test mbuf data and space for digest */
6008 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6009 catch_22_quote, QUOTE_512_BYTES, 0);
6011 /* Setup Cipher Parameters */
6012 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6013 ut_params->cipher_xform.next = NULL;
6015 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6016 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6018 /* Create Crypto session*/
6019 ut_params->sess = rte_cryptodev_sym_session_create(
6020 ts_params->valid_devs[0], &ut_params->cipher_xform);
6021 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6023 /* Generate Crypto op data structure */
6024 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6025 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6026 TEST_ASSERT_NOT_NULL(ut_params->op,
6027 "Failed to allocate symmetric crypto operation struct");
6029 /* Set crypto operation data parameters */
6030 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6032 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6034 /* set crypto operation source mbuf */
6035 sym_op->m_src = ut_params->ibuf;
6037 sym_op->cipher.data.offset = 0;
6038 sym_op->cipher.data.length = QUOTE_512_BYTES;
6040 /* Process crypto operation */
6041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6043 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6045 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6046 "crypto operation processing failed");
6049 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6050 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6053 "Ciphertext data not as expected");
6055 return TEST_SUCCESS;
6059 test_null_auth_only_operation(void)
6061 struct crypto_testsuite_params *ts_params = &testsuite_params;
6062 struct crypto_unittest_params *ut_params = &unittest_params;
6064 /* Generate test mbuf data and space for digest */
6065 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6066 catch_22_quote, QUOTE_512_BYTES, 0);
6068 /* Setup HMAC Parameters */
6069 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6070 ut_params->auth_xform.next = NULL;
6072 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6073 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6075 /* Create Crypto session*/
6076 ut_params->sess = rte_cryptodev_sym_session_create(
6077 ts_params->valid_devs[0], &ut_params->auth_xform);
6078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6080 /* Generate Crypto op data structure */
6081 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6082 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6083 TEST_ASSERT_NOT_NULL(ut_params->op,
6084 "Failed to allocate symmetric crypto operation struct");
6086 /* Set crypto operation data parameters */
6087 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6089 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6091 sym_op->m_src = ut_params->ibuf;
6093 sym_op->auth.data.offset = 0;
6094 sym_op->auth.data.length = QUOTE_512_BYTES;
6096 /* Process crypto operation */
6097 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6099 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6101 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6102 "crypto operation processing failed");
6104 return TEST_SUCCESS;
6108 test_null_cipher_auth_operation(void)
6110 struct crypto_testsuite_params *ts_params = &testsuite_params;
6111 struct crypto_unittest_params *ut_params = &unittest_params;
6113 /* Generate test mbuf data and space for digest */
6114 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6115 catch_22_quote, QUOTE_512_BYTES, 0);
6117 /* Setup Cipher Parameters */
6118 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6119 ut_params->cipher_xform.next = &ut_params->auth_xform;
6121 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6122 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6124 /* Setup HMAC Parameters */
6125 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6126 ut_params->auth_xform.next = NULL;
6128 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6129 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6131 /* Create Crypto session*/
6132 ut_params->sess = rte_cryptodev_sym_session_create(
6133 ts_params->valid_devs[0], &ut_params->cipher_xform);
6134 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6136 /* Generate Crypto op data structure */
6137 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6138 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6139 TEST_ASSERT_NOT_NULL(ut_params->op,
6140 "Failed to allocate symmetric crypto operation struct");
6142 /* Set crypto operation data parameters */
6143 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6145 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6147 sym_op->m_src = ut_params->ibuf;
6149 sym_op->cipher.data.offset = 0;
6150 sym_op->cipher.data.length = QUOTE_512_BYTES;
6152 sym_op->auth.data.offset = 0;
6153 sym_op->auth.data.length = QUOTE_512_BYTES;
6155 /* Process crypto operation */
6156 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6158 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6160 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6161 "crypto operation processing failed");
6164 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6165 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6168 "Ciphertext data not as expected");
6170 return TEST_SUCCESS;
6174 test_null_auth_cipher_operation(void)
6176 struct crypto_testsuite_params *ts_params = &testsuite_params;
6177 struct crypto_unittest_params *ut_params = &unittest_params;
6179 /* Generate test mbuf data and space for digest */
6180 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6181 catch_22_quote, QUOTE_512_BYTES, 0);
6183 /* Setup Cipher Parameters */
6184 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6185 ut_params->cipher_xform.next = NULL;
6187 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6188 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6190 /* Setup HMAC Parameters */
6191 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6192 ut_params->auth_xform.next = &ut_params->cipher_xform;
6194 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6195 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6197 /* Create Crypto session*/
6198 ut_params->sess = rte_cryptodev_sym_session_create(
6199 ts_params->valid_devs[0], &ut_params->cipher_xform);
6200 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6202 /* Generate Crypto op data structure */
6203 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6204 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6205 TEST_ASSERT_NOT_NULL(ut_params->op,
6206 "Failed to allocate symmetric crypto operation struct");
6208 /* Set crypto operation data parameters */
6209 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6211 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6213 sym_op->m_src = ut_params->ibuf;
6215 sym_op->cipher.data.offset = 0;
6216 sym_op->cipher.data.length = QUOTE_512_BYTES;
6218 sym_op->auth.data.offset = 0;
6219 sym_op->auth.data.length = QUOTE_512_BYTES;
6221 /* Process crypto operation */
6222 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6224 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6226 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6227 "crypto operation processing failed");
6230 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6231 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6234 "Ciphertext data not as expected");
6236 return TEST_SUCCESS;
6241 test_null_invalid_operation(void)
6243 struct crypto_testsuite_params *ts_params = &testsuite_params;
6244 struct crypto_unittest_params *ut_params = &unittest_params;
6246 /* Setup Cipher Parameters */
6247 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6248 ut_params->cipher_xform.next = NULL;
6250 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6251 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6253 /* Create Crypto session*/
6254 ut_params->sess = rte_cryptodev_sym_session_create(
6255 ts_params->valid_devs[0], &ut_params->cipher_xform);
6256 TEST_ASSERT_NULL(ut_params->sess,
6257 "Session creation succeeded unexpectedly");
6260 /* Setup HMAC Parameters */
6261 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6262 ut_params->auth_xform.next = NULL;
6264 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6265 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6267 /* Create Crypto session*/
6268 ut_params->sess = rte_cryptodev_sym_session_create(
6269 ts_params->valid_devs[0], &ut_params->auth_xform);
6270 TEST_ASSERT_NULL(ut_params->sess,
6271 "Session creation succeeded unexpectedly");
6273 return TEST_SUCCESS;
6277 #define NULL_BURST_LENGTH (32)
6280 test_null_burst_operation(void)
6282 struct crypto_testsuite_params *ts_params = &testsuite_params;
6283 struct crypto_unittest_params *ut_params = &unittest_params;
6285 unsigned i, burst_len = NULL_BURST_LENGTH;
6287 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6288 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6290 /* Setup Cipher Parameters */
6291 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6292 ut_params->cipher_xform.next = &ut_params->auth_xform;
6294 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6295 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6297 /* Setup HMAC Parameters */
6298 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6299 ut_params->auth_xform.next = NULL;
6301 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6302 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6304 /* Create Crypto session*/
6305 ut_params->sess = rte_cryptodev_sym_session_create(
6306 ts_params->valid_devs[0], &ut_params->cipher_xform);
6307 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6309 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6310 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6311 burst_len, "failed to generate burst of crypto ops");
6313 /* Generate an operation for each mbuf in burst */
6314 for (i = 0; i < burst_len; i++) {
6315 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6317 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6319 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6323 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6325 burst[i]->sym->m_src = m;
6328 /* Process crypto operation */
6329 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6330 0, burst, burst_len),
6332 "Error enqueuing burst");
6334 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6335 0, burst_dequeued, burst_len),
6337 "Error dequeuing burst");
6340 for (i = 0; i < burst_len; i++) {
6342 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6343 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6345 "data not as expected");
6347 rte_pktmbuf_free(burst[i]->sym->m_src);
6348 rte_crypto_op_free(burst[i]);
6351 return TEST_SUCCESS;
6355 generate_gmac_large_plaintext(uint8_t *data)
6359 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6360 memcpy(&data[i], &data[0], 32);
6364 create_gmac_operation(enum rte_crypto_auth_operation op,
6365 const struct gmac_test_data *tdata)
6367 struct crypto_testsuite_params *ts_params = &testsuite_params;
6368 struct crypto_unittest_params *ut_params = &unittest_params;
6369 struct rte_crypto_sym_op *sym_op;
6371 unsigned aad_pad_len;
6373 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6376 * Runtime generate the large plain text instead of use hard code
6377 * plain text vector. It is done to avoid create huge source file
6378 * with the test vector.
6380 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6381 generate_gmac_large_plaintext(tdata->aad.data);
6383 /* Generate Crypto op data structure */
6384 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6385 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6386 TEST_ASSERT_NOT_NULL(ut_params->op,
6387 "Failed to allocate symmetric crypto operation struct");
6389 sym_op = ut_params->op->sym;
6390 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6392 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6393 "no room to append aad");
6395 sym_op->auth.aad.length = tdata->aad.len;
6396 sym_op->auth.aad.phys_addr =
6397 rte_pktmbuf_mtophys(ut_params->ibuf);
6398 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6400 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6401 ut_params->ibuf, tdata->gmac_tag.len);
6402 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6403 "no room to append digest");
6405 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6406 ut_params->ibuf, aad_pad_len);
6407 sym_op->auth.digest.length = tdata->gmac_tag.len;
6409 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6410 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6411 tdata->gmac_tag.len);
6412 TEST_HEXDUMP(stdout, "digest:",
6413 sym_op->auth.digest.data,
6414 sym_op->auth.digest.length);
6417 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6418 uint8_t *, IV_OFFSET);
6420 sym_op->cipher.iv.offset = IV_OFFSET;
6421 sym_op->cipher.iv.length = tdata->iv.len;
6423 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6425 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6427 sym_op->cipher.data.length = 0;
6428 sym_op->cipher.data.offset = 0;
6430 sym_op->auth.data.offset = 0;
6431 sym_op->auth.data.length = 0;
6436 static int create_gmac_session(uint8_t dev_id,
6437 enum rte_crypto_cipher_operation op,
6438 const struct gmac_test_data *tdata,
6439 enum rte_crypto_auth_operation auth_op)
6441 uint8_t cipher_key[tdata->key.len];
6443 struct crypto_unittest_params *ut_params = &unittest_params;
6445 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6447 /* For GMAC we setup cipher parameters */
6448 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6449 ut_params->cipher_xform.next = NULL;
6450 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6451 ut_params->cipher_xform.cipher.op = op;
6452 ut_params->cipher_xform.cipher.key.data = cipher_key;
6453 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6455 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6456 ut_params->auth_xform.next = NULL;
6458 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6459 ut_params->auth_xform.auth.op = auth_op;
6460 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6461 ut_params->auth_xform.auth.add_auth_data_length = 0;
6462 ut_params->auth_xform.auth.key.length = 0;
6463 ut_params->auth_xform.auth.key.data = NULL;
6465 ut_params->cipher_xform.next = &ut_params->auth_xform;
6467 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6468 &ut_params->cipher_xform);
6470 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6476 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6478 struct crypto_testsuite_params *ts_params = &testsuite_params;
6479 struct crypto_unittest_params *ut_params = &unittest_params;
6483 uint8_t *auth_tag, *p;
6484 uint16_t aad_pad_len;
6486 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6487 "No GMAC length in the source data");
6489 retval = create_gmac_session(ts_params->valid_devs[0],
6490 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6491 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6496 if (tdata->aad.len > MBUF_SIZE)
6497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6499 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6500 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6501 "Failed to allocate input buffer in mempool");
6503 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6504 rte_pktmbuf_tailroom(ut_params->ibuf));
6506 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6508 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6510 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6516 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6518 ut_params->op->sym->m_src = ut_params->ibuf;
6520 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6521 ut_params->op), "failed to process sym crypto op");
6523 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6524 "crypto op processing failed");
6526 if (ut_params->op->sym->m_dst) {
6527 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6528 uint8_t *, aad_pad_len);
6530 auth_tag = p + aad_pad_len;
6533 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6537 tdata->gmac_tag.data,
6538 tdata->gmac_tag.len,
6539 "GMAC Generated auth tag not as expected");
6545 test_AES_GMAC_authentication_test_case_1(void)
6547 return test_AES_GMAC_authentication(&gmac_test_case_1);
6551 test_AES_GMAC_authentication_test_case_2(void)
6553 return test_AES_GMAC_authentication(&gmac_test_case_2);
6557 test_AES_GMAC_authentication_test_case_3(void)
6559 return test_AES_GMAC_authentication(&gmac_test_case_3);
6563 test_AES_GMAC_authentication_test_case_4(void)
6565 return test_AES_GMAC_authentication(&gmac_test_case_4);
6569 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6571 struct crypto_testsuite_params *ts_params = &testsuite_params;
6572 struct crypto_unittest_params *ut_params = &unittest_params;
6575 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6576 "No GMAC length in the source data");
6578 retval = create_gmac_session(ts_params->valid_devs[0],
6579 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6580 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6585 if (tdata->aad.len > MBUF_SIZE)
6586 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6588 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6589 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6590 "Failed to allocate input buffer in mempool");
6592 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6593 rte_pktmbuf_tailroom(ut_params->ibuf));
6595 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6601 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6603 ut_params->op->sym->m_src = ut_params->ibuf;
6605 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6606 ut_params->op), "failed to process sym crypto op");
6608 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6609 "crypto op processing failed");
6616 test_AES_GMAC_authentication_verify_test_case_1(void)
6618 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6622 test_AES_GMAC_authentication_verify_test_case_2(void)
6624 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6628 test_AES_GMAC_authentication_verify_test_case_3(void)
6630 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6634 test_AES_GMAC_authentication_verify_test_case_4(void)
6636 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6639 struct test_crypto_vector {
6640 enum rte_crypto_cipher_algorithm crypto_algo;
6653 const uint8_t *data;
6658 const uint8_t *data;
6662 enum rte_crypto_auth_algorithm auth_algo;
6670 const uint8_t *data;
6680 static const struct test_crypto_vector
6681 hmac_sha1_test_crypto_vector = {
6682 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6684 .data = plaintext_hash,
6689 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6690 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6691 0xDE, 0xF4, 0xDE, 0xAD
6697 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6698 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6699 0x3F, 0x91, 0x64, 0x59
6705 static const struct test_crypto_vector
6706 aes128_gmac_test_vector = {
6707 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6708 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6710 .data = plaintext_hash,
6715 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6716 0x08, 0x09, 0x0A, 0x0B
6722 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6723 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6729 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6730 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6736 static const struct test_crypto_vector
6737 aes128cbc_hmac_sha1_test_vector = {
6738 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6741 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6742 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6748 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6749 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6754 .data = plaintext_hash,
6758 .data = ciphertext512_aes128cbc,
6761 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6764 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6765 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6766 0xDE, 0xF4, 0xDE, 0xAD
6772 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6773 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6774 0x18, 0x8C, 0x1D, 0x32
6781 data_corruption(uint8_t *data)
6787 tag_corruption(uint8_t *data, unsigned int tag_offset)
6789 data[tag_offset] += 1;
6793 create_auth_session(struct crypto_unittest_params *ut_params,
6795 const struct test_crypto_vector *reference,
6796 enum rte_crypto_auth_operation auth_op)
6798 uint8_t auth_key[reference->auth_key.len + 1];
6800 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6802 /* Setup Authentication Parameters */
6803 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6804 ut_params->auth_xform.auth.op = auth_op;
6805 ut_params->auth_xform.next = NULL;
6806 ut_params->auth_xform.auth.algo = reference->auth_algo;
6807 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6808 ut_params->auth_xform.auth.key.data = auth_key;
6809 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6810 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6812 /* Create Crypto session*/
6813 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6814 &ut_params->auth_xform);
6816 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6822 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6824 const struct test_crypto_vector *reference,
6825 enum rte_crypto_auth_operation auth_op,
6826 enum rte_crypto_cipher_operation cipher_op)
6828 uint8_t cipher_key[reference->cipher_key.len + 1];
6829 uint8_t auth_key[reference->auth_key.len + 1];
6831 memcpy(cipher_key, reference->cipher_key.data,
6832 reference->cipher_key.len);
6833 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6835 /* Setup Authentication Parameters */
6836 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6837 ut_params->auth_xform.auth.op = auth_op;
6838 ut_params->auth_xform.next = &ut_params->cipher_xform;
6839 ut_params->auth_xform.auth.algo = reference->auth_algo;
6840 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6841 ut_params->auth_xform.auth.key.data = auth_key;
6842 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6843 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6845 /* Setup Cipher Parameters */
6846 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6847 ut_params->cipher_xform.next = NULL;
6848 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6849 ut_params->cipher_xform.cipher.op = cipher_op;
6850 ut_params->cipher_xform.cipher.key.data = cipher_key;
6851 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6853 /* Create Crypto session*/
6854 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6855 &ut_params->auth_xform);
6857 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6863 create_auth_operation(struct crypto_testsuite_params *ts_params,
6864 struct crypto_unittest_params *ut_params,
6865 const struct test_crypto_vector *reference,
6866 unsigned int auth_generate)
6868 /* Generate Crypto op data structure */
6869 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6870 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6871 TEST_ASSERT_NOT_NULL(ut_params->op,
6872 "Failed to allocate pktmbuf offload");
6874 /* Set crypto operation data parameters */
6875 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6877 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6879 /* set crypto operation source mbuf */
6880 sym_op->m_src = ut_params->ibuf;
6883 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6884 ut_params->ibuf, reference->digest.len);
6886 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6887 "no room to append auth tag");
6889 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6890 ut_params->ibuf, reference->plaintext.len);
6891 sym_op->auth.digest.length = reference->digest.len;
6894 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6896 memcpy(sym_op->auth.digest.data,
6897 reference->digest.data,
6898 reference->digest.len);
6900 TEST_HEXDUMP(stdout, "digest:",
6901 sym_op->auth.digest.data,
6902 sym_op->auth.digest.length);
6904 sym_op->auth.data.length = reference->plaintext.len;
6905 sym_op->auth.data.offset = 0;
6911 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6912 struct crypto_unittest_params *ut_params,
6913 const struct test_crypto_vector *reference,
6914 unsigned int auth_generate)
6916 /* Generate Crypto op data structure */
6917 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6918 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6919 TEST_ASSERT_NOT_NULL(ut_params->op,
6920 "Failed to allocate pktmbuf offload");
6922 /* Set crypto operation data parameters */
6923 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6925 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6927 /* set crypto operation source mbuf */
6928 sym_op->m_src = ut_params->ibuf;
6931 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6932 reference->aad.len);
6933 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6934 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6936 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6938 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6939 sym_op->auth.aad.length = reference->aad.len;
6942 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6943 ut_params->ibuf, reference->digest.len);
6945 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6946 "no room to append auth tag");
6948 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6949 ut_params->ibuf, reference->ciphertext.len);
6950 sym_op->auth.digest.length = reference->digest.len;
6953 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6955 memcpy(sym_op->auth.digest.data,
6956 reference->digest.data,
6957 reference->digest.len);
6959 TEST_HEXDUMP(stdout, "digest:",
6960 sym_op->auth.digest.data,
6961 sym_op->auth.digest.length);
6963 sym_op->cipher.iv.offset = IV_OFFSET;
6964 sym_op->cipher.iv.length = reference->iv.len;
6966 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6967 reference->iv.data, reference->iv.len);
6969 sym_op->cipher.data.length = 0;
6970 sym_op->cipher.data.offset = 0;
6972 sym_op->auth.data.length = 0;
6973 sym_op->auth.data.offset = 0;
6979 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6980 struct crypto_unittest_params *ut_params,
6981 const struct test_crypto_vector *reference,
6982 unsigned int auth_generate)
6984 /* Generate Crypto op data structure */
6985 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6986 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6987 TEST_ASSERT_NOT_NULL(ut_params->op,
6988 "Failed to allocate pktmbuf offload");
6990 /* Set crypto operation data parameters */
6991 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6993 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6995 /* set crypto operation source mbuf */
6996 sym_op->m_src = ut_params->ibuf;
6999 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7000 ut_params->ibuf, reference->digest.len);
7002 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7003 "no room to append auth tag");
7005 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7006 ut_params->ibuf, reference->ciphertext.len);
7007 sym_op->auth.digest.length = reference->digest.len;
7010 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7012 memcpy(sym_op->auth.digest.data,
7013 reference->digest.data,
7014 reference->digest.len);
7016 TEST_HEXDUMP(stdout, "digest:",
7017 sym_op->auth.digest.data,
7018 sym_op->auth.digest.length);
7020 sym_op->cipher.iv.offset = IV_OFFSET;
7021 sym_op->cipher.iv.length = reference->iv.len;
7023 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7024 reference->iv.data, reference->iv.len);
7026 sym_op->cipher.data.length = reference->ciphertext.len;
7027 sym_op->cipher.data.offset = 0;
7029 sym_op->auth.data.length = reference->ciphertext.len;
7030 sym_op->auth.data.offset = 0;
7036 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7037 struct crypto_unittest_params *ut_params,
7038 const struct test_crypto_vector *reference)
7040 return create_auth_operation(ts_params, ut_params, reference, 0);
7044 create_auth_verify_GMAC_operation(
7045 struct crypto_testsuite_params *ts_params,
7046 struct crypto_unittest_params *ut_params,
7047 const struct test_crypto_vector *reference)
7049 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7053 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7054 struct crypto_unittest_params *ut_params,
7055 const struct test_crypto_vector *reference)
7057 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7061 test_authentication_verify_fail_when_data_corruption(
7062 struct crypto_testsuite_params *ts_params,
7063 struct crypto_unittest_params *ut_params,
7064 const struct test_crypto_vector *reference,
7065 unsigned int data_corrupted)
7071 /* Create session */
7072 retval = create_auth_session(ut_params,
7073 ts_params->valid_devs[0],
7075 RTE_CRYPTO_AUTH_OP_VERIFY);
7079 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7080 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7081 "Failed to allocate input buffer in mempool");
7083 /* clear mbuf payload */
7084 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7085 rte_pktmbuf_tailroom(ut_params->ibuf));
7087 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7088 reference->plaintext.len);
7089 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7090 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7092 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7094 /* Create operation */
7095 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7101 data_corruption(plaintext);
7103 tag_corruption(plaintext, reference->plaintext.len);
7105 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7107 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7108 TEST_ASSERT_EQUAL(ut_params->op->status,
7109 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7110 "authentication not failed");
7112 ut_params->obuf = ut_params->op->sym->m_src;
7113 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7119 test_authentication_verify_GMAC_fail_when_corruption(
7120 struct crypto_testsuite_params *ts_params,
7121 struct crypto_unittest_params *ut_params,
7122 const struct test_crypto_vector *reference,
7123 unsigned int data_corrupted)
7127 /* Create session */
7128 retval = create_auth_cipher_session(ut_params,
7129 ts_params->valid_devs[0],
7131 RTE_CRYPTO_AUTH_OP_VERIFY,
7132 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7137 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7138 "Failed to allocate input buffer in mempool");
7140 /* clear mbuf payload */
7141 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7142 rte_pktmbuf_tailroom(ut_params->ibuf));
7144 /* Create operation */
7145 retval = create_auth_verify_GMAC_operation(ts_params,
7153 data_corruption(ut_params->op->sym->auth.aad.data);
7155 tag_corruption(ut_params->op->sym->auth.aad.data,
7156 reference->aad.len);
7158 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7160 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7161 TEST_ASSERT_EQUAL(ut_params->op->status,
7162 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7163 "authentication not failed");
7165 ut_params->obuf = ut_params->op->sym->m_src;
7166 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7172 test_authenticated_decryption_fail_when_corruption(
7173 struct crypto_testsuite_params *ts_params,
7174 struct crypto_unittest_params *ut_params,
7175 const struct test_crypto_vector *reference,
7176 unsigned int data_corrupted)
7180 uint8_t *ciphertext;
7182 /* Create session */
7183 retval = create_auth_cipher_session(ut_params,
7184 ts_params->valid_devs[0],
7186 RTE_CRYPTO_AUTH_OP_VERIFY,
7187 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7192 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7193 "Failed to allocate input buffer in mempool");
7195 /* clear mbuf payload */
7196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7197 rte_pktmbuf_tailroom(ut_params->ibuf));
7199 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7200 reference->ciphertext.len);
7201 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7202 memcpy(ciphertext, reference->ciphertext.data,
7203 reference->ciphertext.len);
7205 /* Create operation */
7206 retval = create_cipher_auth_verify_operation(ts_params,
7214 data_corruption(ciphertext);
7216 tag_corruption(ciphertext, reference->ciphertext.len);
7218 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7222 TEST_ASSERT_EQUAL(ut_params->op->status,
7223 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7224 "authentication not failed");
7226 ut_params->obuf = ut_params->op->sym->m_src;
7227 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7233 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7234 const struct gcm_test_data *tdata,
7235 void *digest_mem, uint64_t digest_phys)
7237 struct crypto_testsuite_params *ts_params = &testsuite_params;
7238 struct crypto_unittest_params *ut_params = &unittest_params;
7240 const unsigned int auth_tag_len = tdata->auth_tag.len;
7241 const unsigned int iv_len = tdata->iv.len;
7242 const unsigned int aad_len = tdata->aad.len;
7244 /* Generate Crypto op data structure */
7245 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7246 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7247 TEST_ASSERT_NOT_NULL(ut_params->op,
7248 "Failed to allocate symmetric crypto operation struct");
7250 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7252 sym_op->auth.digest.data = digest_mem;
7254 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7255 "no room to append digest");
7257 sym_op->auth.digest.phys_addr = digest_phys;
7258 sym_op->auth.digest.length = auth_tag_len;
7260 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7261 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7263 TEST_HEXDUMP(stdout, "digest:",
7264 sym_op->auth.digest.data,
7265 sym_op->auth.digest.length);
7268 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7269 uint8_t *, IV_OFFSET);
7270 sym_op->cipher.iv.offset = IV_OFFSET;
7271 sym_op->cipher.iv.length = iv_len;
7273 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7275 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7276 ut_params->ibuf, aad_len);
7277 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7278 "no room to prepend aad");
7279 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7281 sym_op->auth.aad.length = aad_len;
7283 memset(sym_op->auth.aad.data, 0, aad_len);
7284 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7286 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7287 TEST_HEXDUMP(stdout, "aad:",
7288 sym_op->auth.aad.data, aad_len);
7290 sym_op->cipher.data.length = tdata->plaintext.len;
7291 sym_op->cipher.data.offset = aad_len;
7293 sym_op->auth.data.offset = aad_len;
7294 sym_op->auth.data.length = tdata->plaintext.len;
7299 #define SGL_MAX_NO 16
7302 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7303 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7305 struct crypto_testsuite_params *ts_params = &testsuite_params;
7306 struct crypto_unittest_params *ut_params = &unittest_params;
7307 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7310 int to_trn_tbl[SGL_MAX_NO];
7312 unsigned int trn_data = 0;
7313 uint8_t *plaintext, *ciphertext, *auth_tag;
7315 if (fragsz > tdata->plaintext.len)
7316 fragsz = tdata->plaintext.len;
7318 uint16_t plaintext_len = fragsz;
7319 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7321 if (fragsz_oop > tdata->plaintext.len)
7322 frag_size_oop = tdata->plaintext.len;
7325 void *digest_mem = NULL;
7327 uint32_t prepend_len = tdata->aad.len;
7329 if (tdata->plaintext.len % fragsz != 0) {
7330 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7333 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7338 * For out-op-place we need to alloc another mbuf
7341 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7342 rte_pktmbuf_append(ut_params->obuf,
7343 frag_size_oop + prepend_len);
7344 buf_oop = ut_params->obuf;
7347 /* Create GCM session */
7348 retval = create_gcm_session(ts_params->valid_devs[0],
7349 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7350 tdata->key.data, tdata->key.len,
7351 tdata->aad.len, tdata->auth_tag.len,
7352 RTE_CRYPTO_AUTH_OP_GENERATE);
7356 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7358 /* clear mbuf payload */
7359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7360 rte_pktmbuf_tailroom(ut_params->ibuf));
7362 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7365 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7367 trn_data += plaintext_len;
7369 buf = ut_params->ibuf;
7372 * Loop until no more fragments
7375 while (trn_data < tdata->plaintext.len) {
7377 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7378 (tdata->plaintext.len - trn_data) : fragsz;
7380 to_trn_tbl[ecx++] = to_trn;
7382 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7386 rte_pktmbuf_tailroom(buf));
7389 if (oop && !fragsz_oop) {
7390 buf_last_oop = buf_oop->next =
7391 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7392 buf_oop = buf_oop->next;
7393 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7394 0, rte_pktmbuf_tailroom(buf_oop));
7395 rte_pktmbuf_append(buf_oop, to_trn);
7398 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7401 memcpy(plaintext, tdata->plaintext.data + trn_data,
7404 if (trn_data == tdata->plaintext.len) {
7407 digest_mem = rte_pktmbuf_append(buf_oop,
7408 tdata->auth_tag.len);
7410 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7411 tdata->auth_tag.len);
7415 uint64_t digest_phys = 0;
7417 ut_params->ibuf->nb_segs = segs;
7420 if (fragsz_oop && oop) {
7424 if (frag_size_oop == tdata->plaintext.len) {
7425 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7426 tdata->auth_tag.len);
7428 digest_phys = rte_pktmbuf_mtophys_offset(
7430 tdata->plaintext.len + prepend_len);
7433 trn_data = frag_size_oop;
7434 while (trn_data < tdata->plaintext.len) {
7437 (tdata->plaintext.len - trn_data <
7439 (tdata->plaintext.len - trn_data) :
7442 to_trn_tbl[ecx++] = to_trn;
7444 buf_last_oop = buf_oop->next =
7445 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7446 buf_oop = buf_oop->next;
7447 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7448 0, rte_pktmbuf_tailroom(buf_oop));
7449 rte_pktmbuf_append(buf_oop, to_trn);
7453 if (trn_data == tdata->plaintext.len) {
7454 digest_mem = rte_pktmbuf_append(buf_oop,
7455 tdata->auth_tag.len);
7459 ut_params->obuf->nb_segs = segs;
7463 * Place digest at the end of the last buffer
7466 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7467 if (oop && buf_last_oop)
7468 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7470 if (!digest_mem && !oop) {
7471 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7472 + tdata->auth_tag.len);
7473 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7474 tdata->plaintext.len);
7477 /* Create GCM opertaion */
7478 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7479 tdata, digest_mem, digest_phys);
7484 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7486 ut_params->op->sym->m_src = ut_params->ibuf;
7488 ut_params->op->sym->m_dst = ut_params->obuf;
7490 /* Process crypto operation */
7491 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7492 ut_params->op), "failed to process sym crypto op");
7494 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7495 "crypto op processing failed");
7498 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7499 uint8_t *, prepend_len);
7501 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7502 uint8_t *, prepend_len);
7506 fragsz = fragsz_oop;
7508 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7510 tdata->ciphertext.data,
7512 "GCM Ciphertext data not as expected");
7514 buf = ut_params->op->sym->m_src->next;
7516 buf = ut_params->op->sym->m_dst->next;
7518 unsigned int off = fragsz;
7522 ciphertext = rte_pktmbuf_mtod(buf,
7525 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7527 tdata->ciphertext.data + off,
7529 "GCM Ciphertext data not as expected");
7531 off += to_trn_tbl[ecx++];
7535 auth_tag = digest_mem;
7536 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7538 tdata->auth_tag.data,
7539 tdata->auth_tag.len,
7540 "GCM Generated auth tag not as expected");
7546 #define OUT_OF_PLACE 1
7549 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7551 return test_AES_GCM_authenticated_encryption_SGL(
7552 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7556 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7558 return test_AES_GCM_authenticated_encryption_SGL(
7559 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7563 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7565 return test_AES_GCM_authenticated_encryption_SGL(
7566 &gcm_test_case_8, OUT_OF_PLACE, 400,
7567 gcm_test_case_8.plaintext.len);
7571 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7574 return test_AES_GCM_authenticated_encryption_SGL(
7575 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7579 test_authentication_verify_fail_when_data_corrupted(
7580 struct crypto_testsuite_params *ts_params,
7581 struct crypto_unittest_params *ut_params,
7582 const struct test_crypto_vector *reference)
7584 return test_authentication_verify_fail_when_data_corruption(
7585 ts_params, ut_params, reference, 1);
7589 test_authentication_verify_fail_when_tag_corrupted(
7590 struct crypto_testsuite_params *ts_params,
7591 struct crypto_unittest_params *ut_params,
7592 const struct test_crypto_vector *reference)
7594 return test_authentication_verify_fail_when_data_corruption(
7595 ts_params, ut_params, reference, 0);
7599 test_authentication_verify_GMAC_fail_when_data_corrupted(
7600 struct crypto_testsuite_params *ts_params,
7601 struct crypto_unittest_params *ut_params,
7602 const struct test_crypto_vector *reference)
7604 return test_authentication_verify_GMAC_fail_when_corruption(
7605 ts_params, ut_params, reference, 1);
7609 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7610 struct crypto_testsuite_params *ts_params,
7611 struct crypto_unittest_params *ut_params,
7612 const struct test_crypto_vector *reference)
7614 return test_authentication_verify_GMAC_fail_when_corruption(
7615 ts_params, ut_params, reference, 0);
7619 test_authenticated_decryption_fail_when_data_corrupted(
7620 struct crypto_testsuite_params *ts_params,
7621 struct crypto_unittest_params *ut_params,
7622 const struct test_crypto_vector *reference)
7624 return test_authenticated_decryption_fail_when_corruption(
7625 ts_params, ut_params, reference, 1);
7629 test_authenticated_decryption_fail_when_tag_corrupted(
7630 struct crypto_testsuite_params *ts_params,
7631 struct crypto_unittest_params *ut_params,
7632 const struct test_crypto_vector *reference)
7634 return test_authenticated_decryption_fail_when_corruption(
7635 ts_params, ut_params, reference, 0);
7639 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7641 return test_authentication_verify_fail_when_data_corrupted(
7642 &testsuite_params, &unittest_params,
7643 &hmac_sha1_test_crypto_vector);
7647 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7649 return test_authentication_verify_fail_when_tag_corrupted(
7650 &testsuite_params, &unittest_params,
7651 &hmac_sha1_test_crypto_vector);
7655 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7657 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7658 &testsuite_params, &unittest_params,
7659 &aes128_gmac_test_vector);
7663 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7665 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7666 &testsuite_params, &unittest_params,
7667 &aes128_gmac_test_vector);
7671 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7673 return test_authenticated_decryption_fail_when_data_corrupted(
7676 &aes128cbc_hmac_sha1_test_vector);
7680 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7682 return test_authenticated_decryption_fail_when_tag_corrupted(
7685 &aes128cbc_hmac_sha1_test_vector);
7688 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7690 /* global AESNI slave IDs for the scheduler test */
7691 uint8_t aesni_ids[2];
7694 test_scheduler_attach_slave_op(void)
7696 struct crypto_testsuite_params *ts_params = &testsuite_params;
7697 uint8_t sched_id = ts_params->valid_devs[0];
7698 uint32_t nb_devs, i, nb_devs_attached = 0;
7702 /* create 2 AESNI_MB if necessary */
7703 nb_devs = rte_cryptodev_count_devtype(
7704 RTE_CRYPTODEV_AESNI_MB_PMD);
7706 for (i = nb_devs; i < 2; i++) {
7707 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7708 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7710 ret = rte_vdev_init(vdev_name, NULL);
7712 TEST_ASSERT(ret == 0,
7713 "Failed to create instance %u of"
7715 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7719 /* attach 2 AESNI_MB cdevs */
7720 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7722 struct rte_cryptodev_info info;
7724 rte_cryptodev_info_get(i, &info);
7725 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7728 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7731 TEST_ASSERT(ret == 0,
7732 "Failed to attach device %u of pmd : %s", i,
7733 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7735 aesni_ids[nb_devs_attached] = (uint8_t)i;
7744 test_scheduler_detach_slave_op(void)
7746 struct crypto_testsuite_params *ts_params = &testsuite_params;
7747 uint8_t sched_id = ts_params->valid_devs[0];
7751 for (i = 0; i < 2; i++) {
7752 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7754 TEST_ASSERT(ret == 0,
7755 "Failed to detach device %u", aesni_ids[i]);
7762 test_scheduler_mode_op(void)
7764 struct crypto_testsuite_params *ts_params = &testsuite_params;
7765 uint8_t sched_id = ts_params->valid_devs[0];
7766 struct rte_cryptodev_scheduler_ops op = {0};
7767 struct rte_cryptodev_scheduler dummy_scheduler = {
7768 .description = "dummy scheduler to test mode",
7769 .name = "dummy scheduler",
7770 .mode = CDEV_SCHED_MODE_USERDEFINED,
7775 /* set user defined mode */
7776 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7778 TEST_ASSERT(ret == 0,
7779 "Failed to set cdev %u to user defined mode", sched_id);
7781 /* set round robin mode */
7782 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7783 CDEV_SCHED_MODE_ROUNDROBIN);
7784 TEST_ASSERT(ret == 0,
7785 "Failed to set cdev %u to round-robin mode", sched_id);
7786 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7787 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7793 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7794 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7795 .setup = testsuite_setup,
7796 .teardown = testsuite_teardown,
7797 .unit_test_cases = {
7798 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7799 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_AES_chain_scheduler_all),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_AES_cipheronly_scheduler_all),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_authonly_scheduler_all),
7806 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7807 TEST_CASES_END() /**< NULL terminate unit test array */
7811 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7813 static struct unit_test_suite cryptodev_qat_testsuite = {
7814 .suite_name = "Crypto QAT Unit Test Suite",
7815 .setup = testsuite_setup,
7816 .teardown = testsuite_teardown,
7817 .unit_test_cases = {
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_device_configure_invalid_dev_id),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_device_configure_invalid_queue_pair_ids),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_queue_pair_descriptor_setup),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_multi_session),
7827 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7828 TEST_CASE_ST(ut_setup, ut_teardown,
7829 test_AES_cipheronly_qat_all),
7830 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_3DES_cipheronly_qat_all),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_DES_cipheronly_qat_all),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_AES_docsis_qat_all),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_DES_docsis_qat_all),
7839 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7841 /** AES GCM Authenticated Encryption */
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7850 TEST_CASE_ST(ut_setup, ut_teardown,
7851 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7860 TEST_CASE_ST(ut_setup, ut_teardown,
7861 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7863 /** AES GCM Authenticated Decryption */
7864 TEST_CASE_ST(ut_setup, ut_teardown,
7865 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7868 TEST_CASE_ST(ut_setup, ut_teardown,
7869 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7870 TEST_CASE_ST(ut_setup, ut_teardown,
7871 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7876 TEST_CASE_ST(ut_setup, ut_teardown,
7877 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7879 /** AES GMAC Authentication */
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_AES_GMAC_authentication_test_case_1),
7882 TEST_CASE_ST(ut_setup, ut_teardown,
7883 test_AES_GMAC_authentication_verify_test_case_1),
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_AES_GMAC_authentication_test_case_2),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_AES_GMAC_authentication_verify_test_case_2),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_AES_GMAC_authentication_test_case_3),
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_AES_GMAC_authentication_verify_test_case_3),
7893 /** SNOW 3G encrypt only (UEA2) */
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_snow3g_encryption_test_case_1),
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 test_snow3g_encryption_test_case_2),
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 test_snow3g_encryption_test_case_3),
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_snow3g_encryption_test_case_4),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_snow3g_encryption_test_case_5),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_snow3g_encryption_test_case_1_oop),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 test_snow3g_decryption_test_case_1_oop),
7910 /** SNOW 3G decrypt only (UEA2) */
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_snow3g_decryption_test_case_1),
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 test_snow3g_decryption_test_case_2),
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_snow3g_decryption_test_case_3),
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_snow3g_decryption_test_case_4),
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_snow3g_decryption_test_case_5),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_snow3g_hash_generate_test_case_1),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_snow3g_hash_generate_test_case_2),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_snow3g_hash_generate_test_case_3),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_snow3g_hash_verify_test_case_1),
7929 TEST_CASE_ST(ut_setup, ut_teardown,
7930 test_snow3g_hash_verify_test_case_2),
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_snow3g_hash_verify_test_case_3),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_snow3g_cipher_auth_test_case_1),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_snow3g_auth_cipher_test_case_1),
7938 /** ZUC encrypt only (EEA3) */
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_zuc_encryption_test_case_1),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_zuc_encryption_test_case_2),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_zuc_encryption_test_case_3),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_zuc_encryption_test_case_4),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_zuc_encryption_test_case_5),
7950 /** ZUC authenticate (EIA3) */
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_zuc_hash_generate_test_case_6),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_zuc_hash_generate_test_case_7),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_zuc_hash_generate_test_case_8),
7958 /** ZUC alg-chain (EEA3/EIA3) */
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_zuc_cipher_auth_test_case_1),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_zuc_cipher_auth_test_case_2),
7964 /** HMAC_MD5 Authentication */
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_MD5_HMAC_generate_case_1),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_MD5_HMAC_verify_case_1),
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_MD5_HMAC_generate_case_2),
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_MD5_HMAC_verify_case_2),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_null_auth_only_operation),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_null_cipher_only_operation),
7979 TEST_CASE_ST(ut_setup, ut_teardown,
7980 test_null_cipher_auth_operation),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_null_auth_cipher_operation),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 test_kasumi_hash_generate_test_case_6),
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 test_kasumi_encryption_test_case_1),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_kasumi_encryption_test_case_3),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_kasumi_auth_cipher_test_case_1),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_kasumi_cipher_auth_test_case_1),
7997 /** Negative tests */
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 authentication_verify_AES128_GMAC_fail_data_corrupt),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8011 TEST_CASES_END() /**< NULL terminate unit test array */
8015 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8016 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8017 .setup = testsuite_setup,
8018 .teardown = testsuite_teardown,
8019 .unit_test_cases = {
8020 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8021 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8022 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8023 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8025 TEST_CASES_END() /**< NULL terminate unit test array */
8029 static struct unit_test_suite cryptodev_openssl_testsuite = {
8030 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8031 .setup = testsuite_setup,
8032 .teardown = testsuite_teardown,
8033 .unit_test_cases = {
8034 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8035 TEST_CASE_ST(ut_setup, ut_teardown,
8036 test_multi_session_random_usage),
8037 TEST_CASE_ST(ut_setup, ut_teardown,
8038 test_AES_chain_openssl_all),
8039 TEST_CASE_ST(ut_setup, ut_teardown,
8040 test_AES_cipheronly_openssl_all),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_3DES_chain_openssl_all),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_3DES_cipheronly_openssl_all),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_DES_docsis_openssl_all),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_authonly_openssl_all),
8050 /** AES GCM Authenticated Encryption */
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8066 /** AES GCM Authenticated Decryption */
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8082 /** AES GMAC Authentication */
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_AES_GMAC_authentication_test_case_1),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 test_AES_GMAC_authentication_verify_test_case_1),
8087 TEST_CASE_ST(ut_setup, ut_teardown,
8088 test_AES_GMAC_authentication_test_case_2),
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_AES_GMAC_authentication_verify_test_case_2),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_AES_GMAC_authentication_test_case_3),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_AES_GMAC_authentication_verify_test_case_3),
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_AES_GMAC_authentication_test_case_4),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_AES_GMAC_authentication_verify_test_case_4),
8100 /** Scatter-Gather */
8101 TEST_CASE_ST(ut_setup, ut_teardown,
8102 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8104 /** Negative tests */
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8107 TEST_CASE_ST(ut_setup, ut_teardown,
8108 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 authentication_verify_AES128_GMAC_fail_data_corrupt),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8115 TEST_CASE_ST(ut_setup, ut_teardown,
8116 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8118 TEST_CASES_END() /**< NULL terminate unit test array */
8122 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8123 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8124 .setup = testsuite_setup,
8125 .teardown = testsuite_teardown,
8126 .unit_test_cases = {
8127 /** AES GCM Authenticated Encryption */
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8143 /** AES GCM Authenticated Decryption */
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8159 /** AES GCM Authenticated Encryption 256 bits key */
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8175 /** AES GCM Authenticated Decryption 256 bits key */
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8191 /** AES GCM Authenticated Encryption big aad size */
8192 TEST_CASE_ST(ut_setup, ut_teardown,
8193 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8194 TEST_CASE_ST(ut_setup, ut_teardown,
8195 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8197 /** AES GCM Authenticated Decryption big aad size */
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8203 /** AES GMAC Authentication */
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 test_AES_GMAC_authentication_test_case_1),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 test_AES_GMAC_authentication_verify_test_case_1),
8208 TEST_CASE_ST(ut_setup, ut_teardown,
8209 test_AES_GMAC_authentication_test_case_3),
8210 TEST_CASE_ST(ut_setup, ut_teardown,
8211 test_AES_GMAC_authentication_verify_test_case_3),
8212 TEST_CASE_ST(ut_setup, ut_teardown,
8213 test_AES_GMAC_authentication_test_case_4),
8214 TEST_CASE_ST(ut_setup, ut_teardown,
8215 test_AES_GMAC_authentication_verify_test_case_4),
8217 /** Negative tests */
8218 TEST_CASE_ST(ut_setup, ut_teardown,
8219 authentication_verify_AES128_GMAC_fail_data_corrupt),
8220 TEST_CASE_ST(ut_setup, ut_teardown,
8221 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8223 /** Out of place tests */
8224 TEST_CASE_ST(ut_setup, ut_teardown,
8225 test_mb_AES_GCM_authenticated_encryption_oop),
8226 TEST_CASE_ST(ut_setup, ut_teardown,
8227 test_mb_AES_GCM_authenticated_decryption_oop),
8229 /** Session-less tests */
8230 TEST_CASE_ST(ut_setup, ut_teardown,
8231 test_mb_AES_GCM_authenticated_encryption_sessionless),
8232 TEST_CASE_ST(ut_setup, ut_teardown,
8233 test_mb_AES_GCM_authenticated_decryption_sessionless),
8235 /** Scatter-Gather */
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8239 TEST_CASES_END() /**< NULL terminate unit test array */
8243 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8244 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8245 .setup = testsuite_setup,
8246 .teardown = testsuite_teardown,
8247 .unit_test_cases = {
8248 /** KASUMI encrypt only (UEA1) */
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_kasumi_encryption_test_case_1),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_kasumi_encryption_test_case_1_sgl),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_kasumi_encryption_test_case_2),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_kasumi_encryption_test_case_3),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_kasumi_encryption_test_case_4),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_kasumi_encryption_test_case_5),
8261 /** KASUMI decrypt only (UEA1) */
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_kasumi_decryption_test_case_1),
8264 TEST_CASE_ST(ut_setup, ut_teardown,
8265 test_kasumi_decryption_test_case_2),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_kasumi_decryption_test_case_3),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_kasumi_decryption_test_case_4),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_kasumi_decryption_test_case_5),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_kasumi_encryption_test_case_1_oop),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_kasumi_encryption_test_case_1_oop_sgl),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_kasumi_decryption_test_case_1_oop),
8282 /** KASUMI hash only (UIA1) */
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_kasumi_hash_generate_test_case_1),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_kasumi_hash_generate_test_case_2),
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 test_kasumi_hash_generate_test_case_3),
8289 TEST_CASE_ST(ut_setup, ut_teardown,
8290 test_kasumi_hash_generate_test_case_4),
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_kasumi_hash_generate_test_case_5),
8293 TEST_CASE_ST(ut_setup, ut_teardown,
8294 test_kasumi_hash_generate_test_case_6),
8295 TEST_CASE_ST(ut_setup, ut_teardown,
8296 test_kasumi_hash_verify_test_case_1),
8297 TEST_CASE_ST(ut_setup, ut_teardown,
8298 test_kasumi_hash_verify_test_case_2),
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_kasumi_hash_verify_test_case_3),
8301 TEST_CASE_ST(ut_setup, ut_teardown,
8302 test_kasumi_hash_verify_test_case_4),
8303 TEST_CASE_ST(ut_setup, ut_teardown,
8304 test_kasumi_hash_verify_test_case_5),
8305 TEST_CASE_ST(ut_setup, ut_teardown,
8306 test_kasumi_auth_cipher_test_case_1),
8307 TEST_CASE_ST(ut_setup, ut_teardown,
8308 test_kasumi_cipher_auth_test_case_1),
8309 TEST_CASES_END() /**< NULL terminate unit test array */
8312 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8313 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8314 .setup = testsuite_setup,
8315 .teardown = testsuite_teardown,
8316 .unit_test_cases = {
8317 /** SNOW 3G encrypt only (UEA2) */
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_snow3g_encryption_test_case_1),
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_snow3g_encryption_test_case_2),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_snow3g_encryption_test_case_3),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_snow3g_encryption_test_case_4),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_snow3g_encryption_test_case_5),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_snow3g_encryption_test_case_1_oop),
8331 TEST_CASE_ST(ut_setup, ut_teardown,
8332 test_snow3g_encryption_test_case_1_oop_sgl),
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 test_snow3g_decryption_test_case_1_oop),
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_snow3g_encryption_test_case_1_offset_oop),
8339 /** SNOW 3G decrypt only (UEA2) */
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_snow3g_decryption_test_case_1),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_snow3g_decryption_test_case_2),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_snow3g_decryption_test_case_3),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_snow3g_decryption_test_case_4),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_snow3g_decryption_test_case_5),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_snow3g_hash_generate_test_case_1),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_snow3g_hash_generate_test_case_2),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_snow3g_hash_generate_test_case_3),
8356 /* Tests with buffers which length is not byte-aligned */
8357 TEST_CASE_ST(ut_setup, ut_teardown,
8358 test_snow3g_hash_generate_test_case_4),
8359 TEST_CASE_ST(ut_setup, ut_teardown,
8360 test_snow3g_hash_generate_test_case_5),
8361 TEST_CASE_ST(ut_setup, ut_teardown,
8362 test_snow3g_hash_generate_test_case_6),
8363 TEST_CASE_ST(ut_setup, ut_teardown,
8364 test_snow3g_hash_verify_test_case_1),
8365 TEST_CASE_ST(ut_setup, ut_teardown,
8366 test_snow3g_hash_verify_test_case_2),
8367 TEST_CASE_ST(ut_setup, ut_teardown,
8368 test_snow3g_hash_verify_test_case_3),
8369 /* Tests with buffers which length is not byte-aligned */
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_snow3g_hash_verify_test_case_4),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_snow3g_hash_verify_test_case_5),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 test_snow3g_hash_verify_test_case_6),
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 test_snow3g_cipher_auth_test_case_1),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_snow3g_auth_cipher_test_case_1),
8381 TEST_CASES_END() /**< NULL terminate unit test array */
8385 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8386 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8387 .setup = testsuite_setup,
8388 .teardown = testsuite_teardown,
8389 .unit_test_cases = {
8390 /** ZUC encrypt only (EEA3) */
8391 TEST_CASE_ST(ut_setup, ut_teardown,
8392 test_zuc_encryption_test_case_1),
8393 TEST_CASE_ST(ut_setup, ut_teardown,
8394 test_zuc_encryption_test_case_2),
8395 TEST_CASE_ST(ut_setup, ut_teardown,
8396 test_zuc_encryption_test_case_3),
8397 TEST_CASE_ST(ut_setup, ut_teardown,
8398 test_zuc_encryption_test_case_4),
8399 TEST_CASE_ST(ut_setup, ut_teardown,
8400 test_zuc_encryption_test_case_5),
8401 TEST_CASE_ST(ut_setup, ut_teardown,
8402 test_zuc_hash_generate_test_case_1),
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_zuc_hash_generate_test_case_2),
8405 TEST_CASE_ST(ut_setup, ut_teardown,
8406 test_zuc_hash_generate_test_case_3),
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_zuc_hash_generate_test_case_4),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_zuc_hash_generate_test_case_5),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_zuc_encryption_test_case_6_sgl),
8413 TEST_CASES_END() /**< NULL terminate unit test array */
8417 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8418 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8419 .setup = testsuite_setup,
8420 .teardown = testsuite_teardown,
8421 .unit_test_cases = {
8422 TEST_CASE_ST(ut_setup, ut_teardown,
8423 test_device_configure_invalid_dev_id),
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_multi_session),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_AES_chain_dpaa2_sec_all),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_3DES_chain_dpaa2_sec_all),
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_AES_cipheronly_dpaa2_sec_all),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_3DES_cipheronly_dpaa2_sec_all),
8436 /** HMAC_MD5 Authentication */
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_MD5_HMAC_generate_case_1),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_MD5_HMAC_verify_case_1),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_MD5_HMAC_generate_case_2),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_MD5_HMAC_verify_case_2),
8446 TEST_CASES_END() /**< NULL terminate unit test array */
8450 static struct unit_test_suite cryptodev_null_testsuite = {
8451 .suite_name = "Crypto Device NULL Unit Test Suite",
8452 .setup = testsuite_setup,
8453 .teardown = testsuite_teardown,
8454 .unit_test_cases = {
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_null_auth_only_operation),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_null_cipher_only_operation),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_null_cipher_auth_operation),
8461 TEST_CASE_ST(ut_setup, ut_teardown,
8462 test_null_auth_cipher_operation),
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_null_invalid_operation),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_null_burst_operation),
8468 TEST_CASES_END() /**< NULL terminate unit test array */
8472 static struct unit_test_suite cryptodev_armv8_testsuite = {
8473 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8474 .setup = testsuite_setup,
8475 .teardown = testsuite_teardown,
8476 .unit_test_cases = {
8477 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8479 /** Negative tests */
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8485 TEST_CASES_END() /**< NULL terminate unit test array */
8490 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8492 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8493 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8497 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8499 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8501 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8505 test_cryptodev_openssl(void)
8507 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8509 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8513 test_cryptodev_aesni_gcm(void)
8515 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8517 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8521 test_cryptodev_null(void)
8523 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8525 return unit_test_suite_runner(&cryptodev_null_testsuite);
8529 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8531 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8533 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8537 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8539 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8541 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8545 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8547 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8549 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8553 test_cryptodev_armv8(void)
8555 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8557 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8560 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8563 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8565 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8566 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8569 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8574 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8576 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8577 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8580 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8581 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8582 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8583 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8584 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8585 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8586 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8587 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8588 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8589 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);