4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
81 struct rte_cryptodev_sym_session *sess;
83 struct rte_crypto_op *op;
85 struct rte_mbuf *obuf, *ibuf;
90 #define ALIGN_POW2_ROUNDUP(num, align) \
91 (((num) + (align) - 1) & ~((align) - 1))
94 * Forward declarations.
97 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
98 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
102 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
103 struct crypto_unittest_params *ut_params,
104 struct crypto_testsuite_params *ts_param,
105 const uint8_t *cipher,
106 const uint8_t *digest,
109 static struct rte_mbuf *
110 setup_test_string(struct rte_mempool *mpool,
111 const char *string, size_t len, uint8_t blocksize)
113 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
114 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
116 memset(m->buf_addr, 0, m->buf_len);
118 char *dst = rte_pktmbuf_append(m, t_len);
125 rte_memcpy(dst, string, t_len);
127 memset(dst, 0, t_len);
133 /* Get number of bytes in X bits (rounding up) */
135 ceil_byte_length(uint32_t num_bits)
138 return ((num_bits >> 3) + 1);
140 return (num_bits >> 3);
143 static struct rte_crypto_op *
144 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
146 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
147 printf("Error sending packet for encryption");
153 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
159 static struct crypto_testsuite_params testsuite_params = { NULL };
160 static struct crypto_unittest_params unittest_params;
163 testsuite_setup(void)
165 struct crypto_testsuite_params *ts_params = &testsuite_params;
166 struct rte_cryptodev_info info;
167 uint32_t i = 0, nb_devs, dev_id;
171 memset(ts_params, 0, sizeof(*ts_params));
173 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
174 if (ts_params->mbuf_pool == NULL) {
175 /* Not already created so create */
176 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
178 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
180 if (ts_params->mbuf_pool == NULL) {
181 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 ts_params->large_mbuf_pool = rte_mempool_lookup(
187 "CRYPTO_LARGE_MBUFPOOL");
188 if (ts_params->large_mbuf_pool == NULL) {
189 /* Not already created so create */
190 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
191 "CRYPTO_LARGE_MBUFPOOL",
194 if (ts_params->large_mbuf_pool == NULL) {
196 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 ts_params->op_mpool = rte_crypto_op_pool_create(
202 "MBUF_CRYPTO_SYM_OP_POOL",
203 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
204 NUM_MBUFS, MBUF_CACHE_SIZE,
206 sizeof(struct rte_crypto_sym_xform) +
209 if (ts_params->op_mpool == NULL) {
210 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
214 /* Create an AESNI MB device if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_MB
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_MB_PMD);
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
236 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(
242 RTE_CRYPTODEV_AESNI_GCM_PMD);
244 TEST_ASSERT_SUCCESS(rte_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
246 "Failed to create instance of"
248 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
252 /* Create a SNOW 3G device if required */
253 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
254 #ifndef RTE_LIBRTE_PMD_SNOW3G
255 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
256 " enabled in config file to run this testsuite.\n");
259 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
261 TEST_ASSERT_SUCCESS(rte_vdev_init(
262 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
263 "Failed to create instance of"
265 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create a KASUMI device if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 TEST_ASSERT_SUCCESS(rte_vdev_init(
279 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
280 "Failed to create instance of"
282 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
286 /* Create a ZUC device if required */
287 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
288 #ifndef RTE_LIBRTE_PMD_ZUC
289 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
290 " enabled in config file to run this testsuite.\n");
293 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
295 TEST_ASSERT_SUCCESS(rte_vdev_init(
296 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
297 "Failed to create instance of"
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
303 /* Create a NULL device if required */
304 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
305 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
306 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
307 " enabled in config file to run this testsuite.\n");
310 nb_devs = rte_cryptodev_count_devtype(
311 RTE_CRYPTODEV_NULL_PMD);
314 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
316 TEST_ASSERT(ret == 0,
317 "Failed to create instance of"
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
323 /* Create an OPENSSL device if required */
324 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
325 #ifndef RTE_LIBRTE_PMD_OPENSSL
326 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
327 " enabled in config file to run this testsuite.\n");
330 nb_devs = rte_cryptodev_count_devtype(
331 RTE_CRYPTODEV_OPENSSL_PMD);
334 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
343 /* Create a ARMv8 device if required */
344 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
345 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
346 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
347 " enabled in config file to run this testsuite.\n");
350 nb_devs = rte_cryptodev_count_devtype(
351 RTE_CRYPTODEV_ARMV8_PMD);
354 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
366 #ifndef RTE_LIBRTE_PMD_AESNI_MB
367 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
368 " enabled in config file to run this testsuite.\n");
371 nb_devs = rte_cryptodev_count_devtype(
372 RTE_CRYPTODEV_SCHEDULER_PMD);
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
378 TEST_ASSERT(ret == 0,
379 "Failed to create instance %u of"
381 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
384 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
386 #ifndef RTE_LIBRTE_PMD_QAT
387 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
388 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
389 "in config file to run this testsuite.\n");
394 nb_devs = rte_cryptodev_count();
396 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
400 /* Create list of valid crypto devs */
401 for (i = 0; i < nb_devs; i++) {
402 rte_cryptodev_info_get(i, &info);
403 if (info.dev_type == gbl_cryptodev_type)
404 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
407 if (ts_params->valid_dev_count < 1)
410 /* Set up all the qps on the first of the valid devices found */
412 dev_id = ts_params->valid_devs[0];
414 rte_cryptodev_info_get(dev_id, &info);
416 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
417 ts_params->conf.socket_id = SOCKET_ID_ANY;
418 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
422 "Failed to configure cryptodev %u with %u qps",
423 dev_id, ts_params->conf.nb_queue_pairs);
425 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
427 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
428 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
429 dev_id, qp_id, &ts_params->qp_conf,
430 rte_cryptodev_socket_id(dev_id)),
431 "Failed to setup queue pair %u on cryptodev %u",
439 testsuite_teardown(void)
441 struct crypto_testsuite_params *ts_params = &testsuite_params;
443 if (ts_params->mbuf_pool != NULL) {
444 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
445 rte_mempool_avail_count(ts_params->mbuf_pool));
448 if (ts_params->op_mpool != NULL) {
449 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
450 rte_mempool_avail_count(ts_params->op_mpool));
458 struct crypto_testsuite_params *ts_params = &testsuite_params;
459 struct crypto_unittest_params *ut_params = &unittest_params;
463 /* Clear unit test parameters before running test */
464 memset(ut_params, 0, sizeof(*ut_params));
466 /* Reconfigure device to default parameters */
467 ts_params->conf.socket_id = SOCKET_ID_ANY;
468 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
470 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
475 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 ts_params->valid_devs[0], qp_id,
479 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
480 "Failed to setup queue pair %u on cryptodev %u",
481 qp_id, ts_params->valid_devs[0]);
485 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
487 /* Start the device */
488 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
489 "Failed to start cryptodev %u",
490 ts_params->valid_devs[0]);
498 struct crypto_testsuite_params *ts_params = &testsuite_params;
499 struct crypto_unittest_params *ut_params = &unittest_params;
500 struct rte_cryptodev_stats stats;
502 /* free crypto session structure */
503 if (ut_params->sess) {
504 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
506 ut_params->sess = NULL;
509 /* free crypto operation structure */
511 rte_crypto_op_free(ut_params->op);
514 * free mbuf - both obuf and ibuf are usually the same,
515 * so check if they point at the same address is necessary,
516 * to avoid freeing the mbuf twice.
518 if (ut_params->obuf) {
519 rte_pktmbuf_free(ut_params->obuf);
520 if (ut_params->ibuf == ut_params->obuf)
524 if (ut_params->ibuf) {
525 rte_pktmbuf_free(ut_params->ibuf);
529 if (ts_params->mbuf_pool != NULL)
530 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
531 rte_mempool_avail_count(ts_params->mbuf_pool));
533 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
535 /* Stop the device */
536 rte_cryptodev_stop(ts_params->valid_devs[0]);
540 test_device_configure_invalid_dev_id(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 uint16_t dev_id, num_devs = 0;
545 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
546 "Need at least %d devices for test", 1);
548 /* valid dev_id values */
549 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
551 /* Stop the device in case it's started so it can be configured */
552 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
554 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
558 /* invalid dev_id values */
561 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
562 "Failed test for rte_cryptodev_configure: "
563 "invalid dev_num %u", dev_id);
567 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
568 "Failed test for rte_cryptodev_configure:"
569 "invalid dev_num %u", dev_id);
575 test_device_configure_invalid_queue_pair_ids(void)
577 struct crypto_testsuite_params *ts_params = &testsuite_params;
578 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
580 /* Stop the device in case it's started so it can be configured */
581 rte_cryptodev_stop(ts_params->valid_devs[0]);
583 /* valid - one queue pairs */
584 ts_params->conf.nb_queue_pairs = 1;
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
588 "Failed to configure cryptodev: dev_id %u, qp_id %u",
589 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
592 /* valid - max value queue pairs */
593 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
595 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed to configure cryptodev: dev_id %u, qp_id %u",
598 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
601 /* invalid - zero queue pairs */
602 ts_params->conf.nb_queue_pairs = 0;
604 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed test for rte_cryptodev_configure, dev_id %u,"
608 ts_params->valid_devs[0],
609 ts_params->conf.nb_queue_pairs);
612 /* invalid - max value supported by field queue pairs */
613 ts_params->conf.nb_queue_pairs = UINT16_MAX;
615 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
617 "Failed test for rte_cryptodev_configure, dev_id %u,"
619 ts_params->valid_devs[0],
620 ts_params->conf.nb_queue_pairs);
623 /* invalid - max value + 1 queue pairs */
624 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
626 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
628 "Failed test for rte_cryptodev_configure, dev_id %u,"
630 ts_params->valid_devs[0],
631 ts_params->conf.nb_queue_pairs);
633 /* revert to original testsuite value */
634 ts_params->conf.nb_queue_pairs = orig_nb_qps;
640 test_queue_pair_descriptor_setup(void)
642 struct crypto_testsuite_params *ts_params = &testsuite_params;
643 struct rte_cryptodev_info dev_info;
644 struct rte_cryptodev_qp_conf qp_conf = {
645 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
650 /* Stop the device in case it's started so it can be configured */
651 rte_cryptodev_stop(ts_params->valid_devs[0]);
654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
656 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
658 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
659 &ts_params->conf), "Failed to configure cryptodev %u",
660 ts_params->valid_devs[0]);
664 * Test various ring sizes on this device. memzones can't be
665 * freed so are re-used if ring is released and re-created.
667 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
669 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
670 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
671 ts_params->valid_devs[0], qp_id, &qp_conf,
672 rte_cryptodev_socket_id(
673 ts_params->valid_devs[0])),
675 "rte_cryptodev_queue_pair_setup: num_inflights "
676 "%u on qp %u on cryptodev %u",
677 qp_conf.nb_descriptors, qp_id,
678 ts_params->valid_devs[0]);
681 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0])),
689 " rte_cryptodev_queue_pair_setup: num_inflights"
690 " %u on qp %u on cryptodev %u",
691 qp_conf.nb_descriptors, qp_id,
692 ts_params->valid_devs[0]);
695 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
697 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
698 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
699 ts_params->valid_devs[0], qp_id, &qp_conf,
700 rte_cryptodev_socket_id(
701 ts_params->valid_devs[0])),
703 "rte_cryptodev_queue_pair_setup: num_inflights"
704 " %u on qp %u on cryptodev %u",
705 qp_conf.nb_descriptors, qp_id,
706 ts_params->valid_devs[0]);
709 /* invalid number of descriptors - max supported + 2 */
710 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0])),
717 "Unexpectedly passed test for "
718 "rte_cryptodev_queue_pair_setup:"
719 "num_inflights %u on qp %u on cryptodev %u",
720 qp_conf.nb_descriptors, qp_id,
721 ts_params->valid_devs[0]);
724 /* invalid number of descriptors - max value of parameter */
725 qp_conf.nb_descriptors = UINT32_MAX-1;
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0])),
732 "Unexpectedly passed test for "
733 "rte_cryptodev_queue_pair_setup:"
734 "num_inflights %u on qp %u on cryptodev %u",
735 qp_conf.nb_descriptors, qp_id,
736 ts_params->valid_devs[0]);
739 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
741 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
742 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0], qp_id, &qp_conf,
744 rte_cryptodev_socket_id(
745 ts_params->valid_devs[0])),
747 " rte_cryptodev_queue_pair_setup:"
748 "num_inflights %u on qp %u on cryptodev %u",
749 qp_conf.nb_descriptors, qp_id,
750 ts_params->valid_devs[0]);
753 /* invalid number of descriptors - max supported + 1 */
754 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
756 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
757 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
758 ts_params->valid_devs[0], qp_id, &qp_conf,
759 rte_cryptodev_socket_id(
760 ts_params->valid_devs[0])),
761 "Unexpectedly passed test for "
762 "rte_cryptodev_queue_pair_setup:"
763 "num_inflights %u on qp %u on cryptodev %u",
764 qp_conf.nb_descriptors, qp_id,
765 ts_params->valid_devs[0]);
768 /* test invalid queue pair id */
769 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
771 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
773 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
774 ts_params->valid_devs[0],
776 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
777 "Failed test for rte_cryptodev_queue_pair_setup:"
778 "invalid qp %u on cryptodev %u",
779 qp_id, ts_params->valid_devs[0]);
781 qp_id = 0xffff; /*invalid*/
783 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0],
786 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
787 "Failed test for rte_cryptodev_queue_pair_setup:"
788 "invalid qp %u on cryptodev %u",
789 qp_id, ts_params->valid_devs[0]);
794 /* ***** Plaintext data for tests ***** */
796 const char catch_22_quote_1[] =
797 "There was only one catch and that was Catch-22, which "
798 "specified that a concern for one's safety in the face of "
799 "dangers that were real and immediate was the process of a "
800 "rational mind. Orr was crazy and could be grounded. All he "
801 "had to do was ask; and as soon as he did, he would no longer "
802 "be crazy and would have to fly more missions. Orr would be "
803 "crazy to fly more missions and sane if he didn't, but if he "
804 "was sane he had to fly them. If he flew them he was crazy "
805 "and didn't have to; but if he didn't want to he was sane and "
806 "had to. Yossarian was moved very deeply by the absolute "
807 "simplicity of this clause of Catch-22 and let out a "
808 "respectful whistle. \"That's some catch, that Catch-22\", he "
809 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
811 const char catch_22_quote[] =
812 "What a lousy earth! He wondered how many people were "
813 "destitute that same night even in his own prosperous country, "
814 "how many homes were shanties, how many husbands were drunk "
815 "and wives socked, and how many children were bullied, abused, "
816 "or abandoned. How many families hungered for food they could "
817 "not afford to buy? How many hearts were broken? How many "
818 "suicides would take place that same night, how many people "
819 "would go insane? How many cockroaches and landlords would "
820 "triumph? How many winners were losers, successes failures, "
821 "and rich men poor men? How many wise guys were stupid? How "
822 "many happy endings were unhappy endings? How many honest men "
823 "were liars, brave men cowards, loyal men traitors, how many "
824 "sainted men were corrupt, how many people in positions of "
825 "trust had sold their souls to bodyguards, how many had never "
826 "had souls? How many straight-and-narrow paths were crooked "
827 "paths? How many best families were worst families and how "
828 "many good people were bad people? When you added them all up "
829 "and then subtracted, you might be left with only the children, "
830 "and perhaps with Albert Einstein and an old violinist or "
831 "sculptor somewhere.";
833 #define QUOTE_480_BYTES (480)
834 #define QUOTE_512_BYTES (512)
835 #define QUOTE_768_BYTES (768)
836 #define QUOTE_1024_BYTES (1024)
840 /* ***** SHA1 Hash Tests ***** */
842 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
844 static uint8_t hmac_sha1_key[] = {
845 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
846 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
847 0xDE, 0xF4, 0xDE, 0xAD };
849 /* ***** SHA224 Hash Tests ***** */
851 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
854 /* ***** AES-CBC Cipher Tests ***** */
856 #define CIPHER_KEY_LENGTH_AES_CBC (16)
857 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
859 static uint8_t aes_cbc_key[] = {
860 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
861 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
863 static uint8_t aes_cbc_iv[] = {
864 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
865 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
868 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
870 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
871 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
872 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
873 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
874 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
875 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
876 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
877 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
878 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
879 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
880 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
881 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
882 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
883 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
884 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
885 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
886 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
887 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
888 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
889 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
890 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
891 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
892 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
893 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
894 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
895 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
896 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
897 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
898 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
899 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
900 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
901 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
902 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
903 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
904 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
905 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
906 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
907 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
908 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
909 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
910 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
911 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
912 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
913 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
914 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
915 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
916 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
917 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
918 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
919 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
920 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
921 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
922 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
923 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
924 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
925 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
926 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
927 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
928 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
929 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
930 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
931 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
932 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
933 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
934 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
937 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
938 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
939 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
940 0x18, 0x8c, 0x1d, 0x32
944 /* Multisession Vector context Test */
946 static uint8_t ms_aes_cbc_key0[] = {
947 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
951 static uint8_t ms_aes_cbc_iv0[] = {
952 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
953 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
956 static const uint8_t ms_aes_cbc_cipher0[] = {
957 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
958 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
959 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
960 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
961 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
962 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
963 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
964 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
965 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
966 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
967 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
968 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
969 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
970 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
971 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
972 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
973 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
974 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
975 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
976 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
977 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
978 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
979 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
980 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
981 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
982 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
983 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
984 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
985 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
986 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
987 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
988 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
989 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
990 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
991 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
992 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
993 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
994 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
995 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
996 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
997 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
998 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
999 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1000 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1001 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1002 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1003 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1004 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1005 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1006 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1007 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1008 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1009 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1010 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1011 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1012 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1013 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1014 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1015 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1016 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1017 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1018 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1019 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1020 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1024 static uint8_t ms_hmac_key0[] = {
1025 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1026 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1027 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1028 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1029 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1030 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1031 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1032 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1035 static const uint8_t ms_hmac_digest0[] = {
1036 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1037 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1038 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1039 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1040 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1041 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1042 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1043 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1047 /* Begin session 1 */
1049 static uint8_t ms_aes_cbc_key1[] = {
1050 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static uint8_t ms_aes_cbc_iv1[] = {
1055 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1056 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1059 static const uint8_t ms_aes_cbc_cipher1[] = {
1060 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1061 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1062 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1063 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1064 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1065 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1066 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1067 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1068 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1069 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1070 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1071 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1072 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1073 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1074 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1075 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1076 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1077 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1078 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1079 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1080 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1081 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1082 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1083 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1084 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1085 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1086 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1087 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1088 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1089 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1090 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1091 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1092 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1093 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1094 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1095 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1096 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1097 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1098 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1099 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1100 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1101 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1102 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1103 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1104 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1105 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1106 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1107 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1108 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1109 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1110 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1111 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1112 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1113 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1114 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1115 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1116 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1117 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1118 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1119 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1120 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1121 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1122 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1123 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1127 static uint8_t ms_hmac_key1[] = {
1128 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1129 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1130 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1131 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1132 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1133 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1134 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1135 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1138 static const uint8_t ms_hmac_digest1[] = {
1139 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1140 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1141 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1142 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1143 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1144 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1145 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1146 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1149 /* Begin Session 2 */
1150 static uint8_t ms_aes_cbc_key2[] = {
1151 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1152 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 static uint8_t ms_aes_cbc_iv2[] = {
1156 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1157 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1160 static const uint8_t ms_aes_cbc_cipher2[] = {
1161 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1162 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1163 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1164 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1165 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1166 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1167 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1168 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1169 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1170 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1171 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1172 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1173 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1174 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1175 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1176 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1177 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1178 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1179 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1180 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1181 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1182 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1183 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1184 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1185 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1186 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1187 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1188 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1189 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1190 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1191 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1192 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1193 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1194 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1195 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1196 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1197 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1198 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1199 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1200 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1201 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1202 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1203 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1204 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1205 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1206 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1207 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1208 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1209 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1210 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1211 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1212 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1213 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1214 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1215 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1216 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1217 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1218 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1219 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1220 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1221 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1222 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1223 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1224 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1227 static uint8_t ms_hmac_key2[] = {
1228 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest2[] = {
1239 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1240 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1241 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1242 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1243 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1244 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1245 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1246 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1253 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1255 struct crypto_testsuite_params *ts_params = &testsuite_params;
1256 struct crypto_unittest_params *ut_params = &unittest_params;
1258 /* Generate test mbuf data and space for digest */
1259 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1260 catch_22_quote, QUOTE_512_BYTES, 0);
1262 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1263 DIGEST_BYTE_LENGTH_SHA1);
1264 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1266 /* Setup Cipher Parameters */
1267 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1268 ut_params->cipher_xform.next = &ut_params->auth_xform;
1270 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1271 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1272 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1273 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1274 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1275 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1277 /* Setup HMAC Parameters */
1278 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1280 ut_params->auth_xform.next = NULL;
1282 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1283 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1284 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1285 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1286 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1288 /* Create crypto session*/
1289 ut_params->sess = rte_cryptodev_sym_session_create(
1290 ts_params->valid_devs[0],
1291 &ut_params->cipher_xform);
1292 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1294 /* Generate crypto op data structure */
1295 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1296 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1297 TEST_ASSERT_NOT_NULL(ut_params->op,
1298 "Failed to allocate symmetric crypto operation struct");
1300 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1302 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1304 /* set crypto operation source mbuf */
1305 sym_op->m_src = ut_params->ibuf;
1307 /* Set crypto operation authentication parameters */
1308 sym_op->auth.digest.data = ut_params->digest;
1309 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1310 ut_params->ibuf, QUOTE_512_BYTES);
1311 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1345 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1346 DIGEST_BYTE_LENGTH_SHA1,
1347 "Generated digest data not as expected");
1349 return TEST_SUCCESS;
1352 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1354 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1356 static uint8_t hmac_sha512_key[] = {
1357 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1358 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1359 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1360 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1361 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1362 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1363 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1364 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1366 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1367 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1368 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1369 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1370 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1371 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1372 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1373 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1374 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1379 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1380 struct crypto_unittest_params *ut_params,
1381 uint8_t *cipher_key,
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1395 struct crypto_unittest_params *ut_params,
1396 uint8_t *cipher_key,
1400 /* Setup Cipher Parameters */
1401 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1402 ut_params->cipher_xform.next = NULL;
1404 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1405 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1406 ut_params->cipher_xform.cipher.key.data = cipher_key;
1407 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1409 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1411 /* Setup HMAC Parameters */
1412 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1413 ut_params->auth_xform.next = &ut_params->cipher_xform;
1415 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1417 ut_params->auth_xform.auth.key.data = hmac_key;
1418 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1419 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1421 return TEST_SUCCESS;
1426 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1427 struct crypto_unittest_params *ut_params,
1428 struct crypto_testsuite_params *ts_params,
1429 const uint8_t *cipher,
1430 const uint8_t *digest,
1433 /* Generate test mbuf data and digest */
1434 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA512);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 rte_memcpy(ut_params->digest,
1445 DIGEST_BYTE_LENGTH_SHA512);
1447 /* Generate Crypto op data structure */
1448 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1449 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1450 TEST_ASSERT_NOT_NULL(ut_params->op,
1451 "Failed to allocate symmetric crypto operation struct");
1453 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1455 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1457 /* set crypto operation source mbuf */
1458 sym_op->m_src = ut_params->ibuf;
1460 sym_op->auth.digest.data = ut_params->digest;
1461 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1462 ut_params->ibuf, QUOTE_512_BYTES);
1463 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1465 sym_op->auth.data.offset = 0;
1466 sym_op->auth.data.length = QUOTE_512_BYTES;
1468 /* Copy IV at the end of the crypto operation */
1469 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1470 iv, CIPHER_IV_LENGTH_AES_CBC);
1472 sym_op->cipher.data.offset = 0;
1473 sym_op->cipher.data.length = QUOTE_512_BYTES;
1475 /* Process crypto operation */
1476 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1477 ut_params->op), "failed to process sym crypto op");
1479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1480 "crypto op processing failed");
1482 ut_params->obuf = ut_params->op->sym->m_src;
1485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1486 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1489 "Plaintext data not as expected");
1492 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1493 "Digest verification failed");
1495 return TEST_SUCCESS;
1499 test_AES_cipheronly_mb_all(void)
1501 struct crypto_testsuite_params *ts_params = &testsuite_params;
1504 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1505 ts_params->op_mpool, ts_params->valid_devs[0],
1506 RTE_CRYPTODEV_AESNI_MB_PMD,
1507 BLKCIPHER_AES_CIPHERONLY_TYPE);
1509 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1511 return TEST_SUCCESS;
1515 test_AES_docsis_mb_all(void)
1517 struct crypto_testsuite_params *ts_params = &testsuite_params;
1520 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1521 ts_params->op_mpool, ts_params->valid_devs[0],
1522 RTE_CRYPTODEV_AESNI_MB_PMD,
1523 BLKCIPHER_AES_DOCSIS_TYPE);
1525 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1527 return TEST_SUCCESS;
1531 test_AES_docsis_qat_all(void)
1533 struct crypto_testsuite_params *ts_params = &testsuite_params;
1536 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1537 ts_params->op_mpool, ts_params->valid_devs[0],
1538 RTE_CRYPTODEV_QAT_SYM_PMD,
1539 BLKCIPHER_AES_DOCSIS_TYPE);
1541 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1543 return TEST_SUCCESS;
1547 test_DES_docsis_qat_all(void)
1549 struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1553 ts_params->op_mpool, ts_params->valid_devs[0],
1554 RTE_CRYPTODEV_QAT_SYM_PMD,
1555 BLKCIPHER_DES_DOCSIS_TYPE);
1557 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1559 return TEST_SUCCESS;
1563 test_authonly_mb_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool, ts_params->valid_devs[0],
1570 RTE_CRYPTODEV_AESNI_MB_PMD,
1571 BLKCIPHER_AUTHONLY_TYPE);
1573 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1575 return TEST_SUCCESS;
1579 test_AES_chain_mb_all(void)
1581 struct crypto_testsuite_params *ts_params = &testsuite_params;
1584 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1585 ts_params->op_mpool, ts_params->valid_devs[0],
1586 RTE_CRYPTODEV_AESNI_MB_PMD,
1587 BLKCIPHER_AES_CHAIN_TYPE);
1589 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1591 return TEST_SUCCESS;
1594 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1597 test_AES_cipheronly_scheduler_all(void)
1599 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1603 ts_params->op_mpool, ts_params->valid_devs[0],
1604 RTE_CRYPTODEV_SCHEDULER_PMD,
1605 BLKCIPHER_AES_CIPHERONLY_TYPE);
1607 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1609 return TEST_SUCCESS;
1613 test_AES_chain_scheduler_all(void)
1615 struct crypto_testsuite_params *ts_params = &testsuite_params;
1618 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1619 ts_params->op_mpool, ts_params->valid_devs[0],
1620 RTE_CRYPTODEV_SCHEDULER_PMD,
1621 BLKCIPHER_AES_CHAIN_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1629 test_authonly_scheduler_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool, ts_params->valid_devs[0],
1636 RTE_CRYPTODEV_SCHEDULER_PMD,
1637 BLKCIPHER_AUTHONLY_TYPE);
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1644 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1647 test_AES_chain_openssl_all(void)
1649 struct crypto_testsuite_params *ts_params = &testsuite_params;
1652 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1653 ts_params->op_mpool, ts_params->valid_devs[0],
1654 RTE_CRYPTODEV_OPENSSL_PMD,
1655 BLKCIPHER_AES_CHAIN_TYPE);
1657 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1659 return TEST_SUCCESS;
1663 test_AES_cipheronly_openssl_all(void)
1665 struct crypto_testsuite_params *ts_params = &testsuite_params;
1668 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1669 ts_params->op_mpool, ts_params->valid_devs[0],
1670 RTE_CRYPTODEV_OPENSSL_PMD,
1671 BLKCIPHER_AES_CIPHERONLY_TYPE);
1673 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1675 return TEST_SUCCESS;
1679 test_AES_chain_qat_all(void)
1681 struct crypto_testsuite_params *ts_params = &testsuite_params;
1684 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1685 ts_params->op_mpool, ts_params->valid_devs[0],
1686 RTE_CRYPTODEV_QAT_SYM_PMD,
1687 BLKCIPHER_AES_CHAIN_TYPE);
1689 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1691 return TEST_SUCCESS;
1695 test_AES_cipheronly_qat_all(void)
1697 struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1701 ts_params->op_mpool, ts_params->valid_devs[0],
1702 RTE_CRYPTODEV_QAT_SYM_PMD,
1703 BLKCIPHER_AES_CIPHERONLY_TYPE);
1705 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1707 return TEST_SUCCESS;
1711 test_AES_chain_dpaa2_sec_all(void)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1717 ts_params->op_mpool, ts_params->valid_devs[0],
1718 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1719 BLKCIPHER_AES_CHAIN_TYPE);
1721 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1723 return TEST_SUCCESS;
1727 test_AES_cipheronly_dpaa2_sec_all(void)
1729 struct crypto_testsuite_params *ts_params = &testsuite_params;
1732 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1733 ts_params->op_mpool, ts_params->valid_devs[0],
1734 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1735 BLKCIPHER_AES_CIPHERONLY_TYPE);
1737 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1739 return TEST_SUCCESS;
1743 test_authonly_openssl_all(void)
1745 struct crypto_testsuite_params *ts_params = &testsuite_params;
1748 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1749 ts_params->op_mpool, ts_params->valid_devs[0],
1750 RTE_CRYPTODEV_OPENSSL_PMD,
1751 BLKCIPHER_AUTHONLY_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1759 test_AES_chain_armv8_all(void)
1761 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1765 ts_params->op_mpool, ts_params->valid_devs[0],
1766 RTE_CRYPTODEV_ARMV8_PMD,
1767 BLKCIPHER_AES_CHAIN_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1774 /* ***** SNOW 3G Tests ***** */
1776 create_wireless_algo_hash_session(uint8_t dev_id,
1777 const uint8_t *key, const uint8_t key_len,
1778 const uint8_t 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,
1813 uint8_t cipher_key[key_len];
1815 struct crypto_unittest_params *ut_params = &unittest_params;
1817 memcpy(cipher_key, key, key_len);
1819 /* Setup Cipher Parameters */
1820 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1821 ut_params->cipher_xform.next = NULL;
1823 ut_params->cipher_xform.cipher.algo = algo;
1824 ut_params->cipher_xform.cipher.op = op;
1825 ut_params->cipher_xform.cipher.key.data = cipher_key;
1826 ut_params->cipher_xform.cipher.key.length = key_len;
1827 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1828 ut_params->cipher_xform.cipher.iv.length = iv_len;
1830 TEST_HEXDUMP(stdout, "key:", key, key_len);
1832 /* Create Crypto session */
1833 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1841 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1842 unsigned int cipher_len,
1843 unsigned int cipher_offset)
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 /* Generate Crypto op data structure */
1849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1851 TEST_ASSERT_NOT_NULL(ut_params->op,
1852 "Failed to allocate pktmbuf offload");
1854 /* Set crypto operation data parameters */
1855 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1857 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1859 /* set crypto operation source mbuf */
1860 sym_op->m_src = ut_params->ibuf;
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 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1896 sym_op->cipher.data.length = cipher_len;
1897 sym_op->cipher.data.offset = cipher_offset;
1902 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1903 enum rte_crypto_cipher_operation cipher_op,
1904 enum rte_crypto_auth_operation auth_op,
1905 enum rte_crypto_auth_algorithm auth_algo,
1906 enum rte_crypto_cipher_algorithm cipher_algo,
1907 const uint8_t *key, const uint8_t key_len,
1908 const uint8_t aad_len, const uint8_t auth_len,
1912 uint8_t cipher_auth_key[key_len];
1914 struct crypto_unittest_params *ut_params = &unittest_params;
1916 memcpy(cipher_auth_key, key, key_len);
1918 /* Setup Authentication Parameters */
1919 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1920 ut_params->auth_xform.next = NULL;
1922 ut_params->auth_xform.auth.op = auth_op;
1923 ut_params->auth_xform.auth.algo = auth_algo;
1924 ut_params->auth_xform.auth.key.length = key_len;
1925 /* Hash key = cipher key */
1926 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1927 ut_params->auth_xform.auth.digest_length = auth_len;
1928 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1930 /* Setup Cipher Parameters */
1931 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1932 ut_params->cipher_xform.next = &ut_params->auth_xform;
1934 ut_params->cipher_xform.cipher.algo = cipher_algo;
1935 ut_params->cipher_xform.cipher.op = cipher_op;
1936 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1937 ut_params->cipher_xform.cipher.key.length = key_len;
1938 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1939 ut_params->cipher_xform.cipher.iv.length = iv_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;
1966 uint8_t iv_len = tdata->iv.len;
1968 memcpy(cipher_auth_key, key, key_len);
1970 /* Setup Authentication Parameters */
1971 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1972 ut_params->auth_xform.next = NULL;
1974 ut_params->auth_xform.auth.op = auth_op;
1975 ut_params->auth_xform.auth.algo = auth_algo;
1976 ut_params->auth_xform.auth.key.length = key_len;
1977 /* Hash key = cipher key */
1978 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1979 ut_params->auth_xform.auth.digest_length = auth_len;
1980 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1982 /* Setup Cipher Parameters */
1983 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1984 ut_params->cipher_xform.next = &ut_params->auth_xform;
1986 ut_params->cipher_xform.cipher.algo = cipher_algo;
1987 ut_params->cipher_xform.cipher.op = cipher_op;
1988 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1989 ut_params->cipher_xform.cipher.key.length = key_len;
1990 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1991 ut_params->cipher_xform.cipher.iv.length = iv_len;
1994 TEST_HEXDUMP(stdout, "key:", key, key_len);
1996 /* Create Crypto session*/
1997 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1998 &ut_params->cipher_xform);
2000 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2005 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2006 const struct wireless_test_data *tdata)
2008 return create_wireless_cipher_auth_session(dev_id,
2009 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2010 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2011 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2015 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2016 enum rte_crypto_cipher_operation cipher_op,
2017 enum rte_crypto_auth_operation auth_op,
2018 enum rte_crypto_auth_algorithm auth_algo,
2019 enum rte_crypto_cipher_algorithm cipher_algo,
2020 const uint8_t *key, const uint8_t key_len,
2021 const uint8_t aad_len, const uint8_t auth_len,
2024 uint8_t auth_cipher_key[key_len];
2026 struct crypto_unittest_params *ut_params = &unittest_params;
2028 memcpy(auth_cipher_key, key, key_len);
2030 /* Setup Authentication Parameters */
2031 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2032 ut_params->auth_xform.auth.op = auth_op;
2033 ut_params->auth_xform.next = &ut_params->cipher_xform;
2034 ut_params->auth_xform.auth.algo = auth_algo;
2035 ut_params->auth_xform.auth.key.length = key_len;
2036 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2037 ut_params->auth_xform.auth.digest_length = auth_len;
2038 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
2040 /* Setup Cipher Parameters */
2041 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2042 ut_params->cipher_xform.next = NULL;
2043 ut_params->cipher_xform.cipher.algo = cipher_algo;
2044 ut_params->cipher_xform.cipher.op = cipher_op;
2045 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2046 ut_params->cipher_xform.cipher.key.length = key_len;
2047 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2048 ut_params->cipher_xform.cipher.iv.length = iv_len;
2050 TEST_HEXDUMP(stdout, "key:", key, key_len);
2052 /* Create Crypto session*/
2053 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2054 &ut_params->auth_xform);
2056 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2062 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2063 const unsigned auth_tag_len,
2064 const uint8_t *aad, const unsigned aad_len,
2065 unsigned data_pad_len,
2066 enum rte_crypto_auth_operation op,
2067 enum rte_crypto_auth_algorithm algo,
2068 const unsigned auth_len, const unsigned auth_offset)
2070 struct crypto_testsuite_params *ts_params = &testsuite_params;
2072 struct crypto_unittest_params *ut_params = &unittest_params;
2074 unsigned aad_buffer_len;
2076 /* Generate Crypto op data structure */
2077 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2078 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2079 TEST_ASSERT_NOT_NULL(ut_params->op,
2080 "Failed to allocate pktmbuf offload");
2082 /* Set crypto operation data parameters */
2083 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2085 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2087 /* set crypto operation source mbuf */
2088 sym_op->m_src = ut_params->ibuf;
2092 * Always allocate the aad up to the block size.
2093 * The cryptodev API calls out -
2094 * - the array must be big enough to hold the AAD, plus any
2095 * space to round this up to the nearest multiple of the
2096 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2098 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2099 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2101 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2102 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2103 ut_params->ibuf, aad_buffer_len);
2104 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2105 "no room to prepend aad");
2106 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2108 sym_op->auth.aad.length = aad_len;
2110 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2111 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2113 TEST_HEXDUMP(stdout, "aad:",
2114 sym_op->auth.aad.data, aad_len);
2117 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2118 ut_params->ibuf, auth_tag_len);
2120 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2121 "no room to append auth tag");
2122 ut_params->digest = sym_op->auth.digest.data;
2123 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2124 ut_params->ibuf, data_pad_len + aad_len);
2125 sym_op->auth.digest.length = auth_tag_len;
2126 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2127 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2129 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2131 TEST_HEXDUMP(stdout, "digest:",
2132 sym_op->auth.digest.data,
2133 sym_op->auth.digest.length);
2135 sym_op->auth.data.length = auth_len;
2136 sym_op->auth.data.offset = auth_offset;
2142 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2143 enum rte_crypto_auth_operation op,
2144 enum rte_crypto_auth_algorithm auth_algo)
2146 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 struct crypto_unittest_params *ut_params = &unittest_params;
2149 const uint8_t *auth_tag = tdata->digest.data;
2150 const unsigned int auth_tag_len = tdata->digest.len;
2151 const uint8_t *aad = tdata->aad.data;
2152 const uint8_t aad_len = tdata->aad.len;
2153 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2154 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2156 const uint8_t *iv = tdata->iv.data;
2157 const uint8_t iv_len = tdata->iv.len;
2158 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2159 const unsigned int cipher_offset = 0;
2160 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2161 const unsigned int auth_offset = tdata->aad.len << 3;
2163 unsigned int aad_buffer_len;
2165 /* Generate Crypto op data structure */
2166 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2167 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2168 TEST_ASSERT_NOT_NULL(ut_params->op,
2169 "Failed to allocate pktmbuf offload");
2170 /* Set crypto operation data parameters */
2171 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2173 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2175 /* set crypto operation source mbuf */
2176 sym_op->m_src = ut_params->ibuf;
2179 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2180 ut_params->ibuf, auth_tag_len);
2182 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2183 "no room to append auth tag");
2184 ut_params->digest = sym_op->auth.digest.data;
2185 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2186 ut_params->ibuf, data_pad_len);
2187 sym_op->auth.digest.length = auth_tag_len;
2188 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2189 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2191 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2193 TEST_HEXDUMP(stdout, "digest:",
2194 sym_op->auth.digest.data,
2195 sym_op->auth.digest.length);
2199 * Always allocate the aad up to the block size.
2200 * The cryptodev API calls out -
2201 * - the array must be big enough to hold the AAD, plus any
2202 * space to round this up to the nearest multiple of the
2203 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2205 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2206 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2208 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2209 sym_op->auth.aad.data =
2210 (uint8_t *)rte_pktmbuf_prepend(
2211 ut_params->ibuf, aad_buffer_len);
2212 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2213 "no room to prepend aad");
2214 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2216 sym_op->auth.aad.length = aad_len;
2217 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2218 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2219 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2222 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2224 sym_op->cipher.data.length = cipher_len;
2225 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2226 sym_op->auth.data.length = auth_len;
2227 sym_op->auth.data.offset = auth_offset + cipher_offset;
2233 create_zuc_cipher_hash_generate_operation(
2234 const struct wireless_test_data *tdata)
2236 return create_wireless_cipher_hash_operation(tdata,
2237 RTE_CRYPTO_AUTH_OP_GENERATE,
2238 RTE_CRYPTO_AUTH_ZUC_EIA3);
2242 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2243 const unsigned auth_tag_len,
2244 const uint8_t *aad, const uint8_t aad_len,
2245 unsigned data_pad_len,
2246 enum rte_crypto_auth_operation op,
2247 enum rte_crypto_auth_algorithm auth_algo,
2248 const uint8_t *iv, const uint8_t iv_len,
2249 const unsigned cipher_len, const unsigned cipher_offset,
2250 const unsigned auth_len, const unsigned auth_offset)
2252 struct crypto_testsuite_params *ts_params = &testsuite_params;
2253 struct crypto_unittest_params *ut_params = &unittest_params;
2255 unsigned aad_buffer_len;
2257 /* Generate Crypto op data structure */
2258 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2259 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2260 TEST_ASSERT_NOT_NULL(ut_params->op,
2261 "Failed to allocate pktmbuf offload");
2262 /* Set crypto operation data parameters */
2263 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2265 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2267 /* set crypto operation source mbuf */
2268 sym_op->m_src = ut_params->ibuf;
2271 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2272 ut_params->ibuf, auth_tag_len);
2274 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2275 "no room to append auth tag");
2276 ut_params->digest = sym_op->auth.digest.data;
2277 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2278 ut_params->ibuf, data_pad_len);
2279 sym_op->auth.digest.length = auth_tag_len;
2280 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2281 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2283 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2285 TEST_HEXDUMP(stdout, "digest:",
2286 sym_op->auth.digest.data,
2287 sym_op->auth.digest.length);
2291 * Always allocate the aad up to the block size.
2292 * The cryptodev API calls out -
2293 * - the array must be big enough to hold the AAD, plus any
2294 * space to round this up to the nearest multiple of the
2295 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2297 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2298 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2300 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2301 sym_op->auth.aad.data =
2302 (uint8_t *)rte_pktmbuf_prepend(
2303 ut_params->ibuf, aad_buffer_len);
2304 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2305 "no room to prepend aad");
2306 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2308 sym_op->auth.aad.length = aad_len;
2309 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2310 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2311 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2314 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2316 sym_op->cipher.data.length = cipher_len;
2317 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2318 sym_op->auth.data.length = auth_len;
2319 sym_op->auth.data.offset = auth_offset + cipher_offset;
2325 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2326 const uint8_t *iv, const uint8_t iv_len,
2327 const uint8_t *aad, const uint8_t aad_len,
2328 unsigned data_pad_len,
2329 const unsigned cipher_len, const unsigned cipher_offset,
2330 const unsigned auth_len, const unsigned auth_offset,
2331 enum rte_crypto_auth_algorithm auth_algo)
2333 struct crypto_testsuite_params *ts_params = &testsuite_params;
2334 struct crypto_unittest_params *ut_params = &unittest_params;
2336 unsigned aad_buffer_len = 0;
2338 /* Generate Crypto op data structure */
2339 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2340 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2341 TEST_ASSERT_NOT_NULL(ut_params->op,
2342 "Failed to allocate pktmbuf offload");
2344 /* Set crypto operation data parameters */
2345 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2347 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2349 /* set crypto operation source mbuf */
2350 sym_op->m_src = ut_params->ibuf;
2353 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2354 ut_params->ibuf, auth_tag_len);
2356 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2357 "no room to append auth tag");
2359 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2360 ut_params->ibuf, data_pad_len);
2361 sym_op->auth.digest.length = auth_tag_len;
2363 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2365 TEST_HEXDUMP(stdout, "digest:",
2366 sym_op->auth.digest.data,
2367 sym_op->auth.digest.length);
2371 * Always allocate the aad up to the block size.
2372 * The cryptodev API calls out -
2373 * - the array must be big enough to hold the AAD, plus any
2374 * space to round this up to the nearest multiple of the
2375 * block size (8 bytes for KASUMI 16 bytes).
2377 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2378 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2380 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2381 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2382 ut_params->ibuf, aad_buffer_len);
2383 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2384 "no room to prepend aad");
2385 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2387 sym_op->auth.aad.length = aad_len;
2388 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2389 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2390 TEST_HEXDUMP(stdout, "aad:",
2391 sym_op->auth.aad.data, aad_len);
2394 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2396 sym_op->cipher.data.length = cipher_len;
2397 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2399 sym_op->auth.data.length = auth_len;
2400 sym_op->auth.data.offset = auth_offset + cipher_offset;
2406 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2408 struct crypto_testsuite_params *ts_params = &testsuite_params;
2409 struct crypto_unittest_params *ut_params = &unittest_params;
2412 unsigned plaintext_pad_len;
2413 unsigned plaintext_len;
2416 /* Create SNOW 3G session */
2417 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2418 tdata->key.data, tdata->key.len,
2419 tdata->aad.len, tdata->digest.len,
2420 RTE_CRYPTO_AUTH_OP_GENERATE,
2421 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2425 /* alloc mbuf and set payload */
2426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2428 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2429 rte_pktmbuf_tailroom(ut_params->ibuf));
2431 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2432 /* Append data which is padded to a multiple of */
2433 /* the algorithms block size */
2434 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2435 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2437 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2439 /* Create SNOW 3G operation */
2440 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2441 tdata->aad.data, tdata->aad.len,
2442 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2443 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2444 tdata->validAuthLenInBits.len,
2445 (tdata->aad.len << 3));
2449 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2451 ut_params->obuf = ut_params->op->sym->m_src;
2452 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2453 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2454 + plaintext_pad_len + tdata->aad.len;
2457 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2460 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2461 "SNOW 3G Generated auth tag not as expected");
2467 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2469 struct crypto_testsuite_params *ts_params = &testsuite_params;
2470 struct crypto_unittest_params *ut_params = &unittest_params;
2473 unsigned plaintext_pad_len;
2474 unsigned plaintext_len;
2477 /* Create SNOW 3G session */
2478 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2479 tdata->key.data, tdata->key.len,
2480 tdata->aad.len, tdata->digest.len,
2481 RTE_CRYPTO_AUTH_OP_VERIFY,
2482 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2485 /* alloc mbuf and set payload */
2486 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2489 rte_pktmbuf_tailroom(ut_params->ibuf));
2491 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2492 /* Append data which is padded to a multiple of */
2493 /* the algorithms block size */
2494 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2495 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2497 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2499 /* Create SNOW 3G operation */
2500 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2502 tdata->aad.data, tdata->aad.len,
2504 RTE_CRYPTO_AUTH_OP_VERIFY,
2505 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2506 tdata->validAuthLenInBits.len,
2507 (tdata->aad.len << 3));
2511 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2513 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2514 ut_params->obuf = ut_params->op->sym->m_src;
2515 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2516 + plaintext_pad_len + tdata->aad.len;
2519 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2528 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2530 struct crypto_testsuite_params *ts_params = &testsuite_params;
2531 struct crypto_unittest_params *ut_params = &unittest_params;
2534 unsigned plaintext_pad_len;
2535 unsigned plaintext_len;
2538 /* Create KASUMI session */
2539 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2540 tdata->key.data, tdata->key.len,
2541 tdata->aad.len, tdata->digest.len,
2542 RTE_CRYPTO_AUTH_OP_GENERATE,
2543 RTE_CRYPTO_AUTH_KASUMI_F9);
2547 /* alloc mbuf and set payload */
2548 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2550 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2551 rte_pktmbuf_tailroom(ut_params->ibuf));
2553 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2554 /* Append data which is padded to a multiple of */
2555 /* the algorithms block size */
2556 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2557 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2559 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2561 /* Create KASUMI operation */
2562 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2563 tdata->aad.data, tdata->aad.len,
2564 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2565 RTE_CRYPTO_AUTH_KASUMI_F9,
2566 tdata->validAuthLenInBits.len,
2567 (tdata->aad.len << 3));
2571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2573 ut_params->obuf = ut_params->op->sym->m_src;
2574 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2575 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2576 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2579 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2582 DIGEST_BYTE_LENGTH_KASUMI_F9,
2583 "KASUMI Generated auth tag not as expected");
2589 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2591 struct crypto_testsuite_params *ts_params = &testsuite_params;
2592 struct crypto_unittest_params *ut_params = &unittest_params;
2595 unsigned plaintext_pad_len;
2596 unsigned plaintext_len;
2599 /* Create KASUMI session */
2600 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2601 tdata->key.data, tdata->key.len,
2602 tdata->aad.len, tdata->digest.len,
2603 RTE_CRYPTO_AUTH_OP_VERIFY,
2604 RTE_CRYPTO_AUTH_KASUMI_F9);
2607 /* alloc mbuf and set payload */
2608 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2611 rte_pktmbuf_tailroom(ut_params->ibuf));
2613 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2614 /* Append data which is padded to a multiple */
2615 /* of the algorithms block size */
2616 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2617 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2619 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2621 /* Create KASUMI operation */
2622 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2624 tdata->aad.data, tdata->aad.len,
2626 RTE_CRYPTO_AUTH_OP_VERIFY,
2627 RTE_CRYPTO_AUTH_KASUMI_F9,
2628 tdata->validAuthLenInBits.len,
2629 (tdata->aad.len << 3));
2633 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2635 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2636 ut_params->obuf = ut_params->op->sym->m_src;
2637 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2638 + plaintext_pad_len + tdata->aad.len;
2641 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2650 test_snow3g_hash_generate_test_case_1(void)
2652 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2656 test_snow3g_hash_generate_test_case_2(void)
2658 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2662 test_snow3g_hash_generate_test_case_3(void)
2664 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2668 test_snow3g_hash_generate_test_case_4(void)
2670 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2674 test_snow3g_hash_generate_test_case_5(void)
2676 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2680 test_snow3g_hash_generate_test_case_6(void)
2682 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2686 test_snow3g_hash_verify_test_case_1(void)
2688 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2693 test_snow3g_hash_verify_test_case_2(void)
2695 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2699 test_snow3g_hash_verify_test_case_3(void)
2701 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2705 test_snow3g_hash_verify_test_case_4(void)
2707 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2711 test_snow3g_hash_verify_test_case_5(void)
2713 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2717 test_snow3g_hash_verify_test_case_6(void)
2719 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2723 test_kasumi_hash_generate_test_case_1(void)
2725 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2729 test_kasumi_hash_generate_test_case_2(void)
2731 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2735 test_kasumi_hash_generate_test_case_3(void)
2737 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2741 test_kasumi_hash_generate_test_case_4(void)
2743 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2747 test_kasumi_hash_generate_test_case_5(void)
2749 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2753 test_kasumi_hash_generate_test_case_6(void)
2755 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2759 test_kasumi_hash_verify_test_case_1(void)
2761 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2765 test_kasumi_hash_verify_test_case_2(void)
2767 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2771 test_kasumi_hash_verify_test_case_3(void)
2773 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2777 test_kasumi_hash_verify_test_case_4(void)
2779 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2783 test_kasumi_hash_verify_test_case_5(void)
2785 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2789 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2791 struct crypto_testsuite_params *ts_params = &testsuite_params;
2792 struct crypto_unittest_params *ut_params = &unittest_params;
2795 uint8_t *plaintext, *ciphertext;
2796 unsigned plaintext_pad_len;
2797 unsigned plaintext_len;
2799 /* Create KASUMI session */
2800 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2801 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2802 RTE_CRYPTO_CIPHER_KASUMI_F8,
2803 tdata->key.data, tdata->key.len,
2808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2810 /* Clear mbuf payload */
2811 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2812 rte_pktmbuf_tailroom(ut_params->ibuf));
2814 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2815 /* Append data which is padded to a multiple */
2816 /* of the algorithms block size */
2817 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2818 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2820 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2822 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2824 /* Create KASUMI operation */
2825 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2826 tdata->plaintext.len,
2831 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2833 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2835 ut_params->obuf = ut_params->op->sym->m_dst;
2836 if (ut_params->obuf)
2837 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2839 ciphertext = plaintext;
2841 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2844 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2846 tdata->ciphertext.data,
2847 tdata->validCipherLenInBits.len,
2848 "KASUMI Ciphertext data not as expected");
2853 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2855 struct crypto_testsuite_params *ts_params = &testsuite_params;
2856 struct crypto_unittest_params *ut_params = &unittest_params;
2860 unsigned int plaintext_pad_len;
2861 unsigned int plaintext_len;
2863 uint8_t buffer[10000];
2864 const uint8_t *ciphertext;
2866 struct rte_cryptodev_info dev_info;
2868 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2869 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2870 printf("Device doesn't support scatter-gather. "
2875 /* Create KASUMI session */
2876 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2877 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2878 RTE_CRYPTO_CIPHER_KASUMI_F8,
2879 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,
2949 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2950 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2952 /* Clear mbuf payload */
2953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2954 rte_pktmbuf_tailroom(ut_params->ibuf));
2956 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2957 /* Append data which is padded to a multiple */
2958 /* of the algorithms block size */
2959 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2960 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2962 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2963 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2965 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2967 /* Create KASUMI operation */
2968 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2970 tdata->plaintext.len,
2975 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2977 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2979 ut_params->obuf = ut_params->op->sym->m_dst;
2980 if (ut_params->obuf)
2981 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2983 ciphertext = plaintext;
2985 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2988 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2990 tdata->ciphertext.data,
2991 tdata->validCipherLenInBits.len,
2992 "KASUMI Ciphertext data not as expected");
2997 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2999 struct crypto_testsuite_params *ts_params = &testsuite_params;
3000 struct crypto_unittest_params *ut_params = &unittest_params;
3003 unsigned int plaintext_pad_len;
3004 unsigned int plaintext_len;
3006 const uint8_t *ciphertext;
3007 uint8_t buffer[2048];
3009 struct rte_cryptodev_info dev_info;
3011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3012 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3013 printf("Device doesn't support scatter-gather. "
3018 /* Create KASUMI session */
3019 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3020 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3021 RTE_CRYPTO_CIPHER_KASUMI_F8,
3022 tdata->key.data, tdata->key.len,
3027 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3028 /* Append data which is padded to a multiple */
3029 /* of the algorithms block size */
3030 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3032 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3033 plaintext_pad_len, 10, 0);
3034 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3035 plaintext_pad_len, 3, 0);
3037 /* Append data which is padded to a multiple */
3038 /* of the algorithms block size */
3039 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3041 /* Create KASUMI operation */
3042 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3044 tdata->plaintext.len,
3049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3051 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3053 ut_params->obuf = ut_params->op->sym->m_dst;
3054 if (ut_params->obuf)
3055 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3056 plaintext_pad_len, buffer);
3058 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3059 plaintext_pad_len, buffer);
3062 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3064 tdata->ciphertext.data,
3065 tdata->validCipherLenInBits.len,
3066 "KASUMI Ciphertext data not as expected");
3072 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3074 struct crypto_testsuite_params *ts_params = &testsuite_params;
3075 struct crypto_unittest_params *ut_params = &unittest_params;
3078 uint8_t *ciphertext, *plaintext;
3079 unsigned ciphertext_pad_len;
3080 unsigned ciphertext_len;
3082 /* Create KASUMI session */
3083 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3084 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3085 RTE_CRYPTO_CIPHER_KASUMI_F8,
3086 tdata->key.data, tdata->key.len,
3091 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3092 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3094 /* Clear mbuf payload */
3095 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3096 rte_pktmbuf_tailroom(ut_params->ibuf));
3098 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3099 /* Append data which is padded to a multiple */
3100 /* of the algorithms block size */
3101 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3102 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3103 ciphertext_pad_len);
3104 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3105 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3107 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3109 /* Create KASUMI operation */
3110 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3112 tdata->ciphertext.len,
3117 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3119 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3121 ut_params->obuf = ut_params->op->sym->m_dst;
3122 if (ut_params->obuf)
3123 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3125 plaintext = ciphertext;
3127 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3130 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3132 tdata->plaintext.data,
3133 tdata->validCipherLenInBits.len,
3134 "KASUMI Plaintext data not as expected");
3139 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3141 struct crypto_testsuite_params *ts_params = &testsuite_params;
3142 struct crypto_unittest_params *ut_params = &unittest_params;
3145 uint8_t *ciphertext, *plaintext;
3146 unsigned ciphertext_pad_len;
3147 unsigned ciphertext_len;
3149 /* Create KASUMI session */
3150 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3151 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3152 RTE_CRYPTO_CIPHER_KASUMI_F8,
3153 tdata->key.data, tdata->key.len,
3158 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3160 /* Clear mbuf payload */
3161 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3162 rte_pktmbuf_tailroom(ut_params->ibuf));
3164 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3165 /* Append data which is padded to a multiple */
3166 /* of the algorithms block size */
3167 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3168 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3169 ciphertext_pad_len);
3170 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3172 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3174 /* Create KASUMI operation */
3175 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3177 tdata->ciphertext.len,
3182 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3184 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3186 ut_params->obuf = ut_params->op->sym->m_dst;
3187 if (ut_params->obuf)
3188 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3190 plaintext = ciphertext;
3192 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3195 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3197 tdata->plaintext.data,
3198 tdata->validCipherLenInBits.len,
3199 "KASUMI Plaintext data not as expected");
3204 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3206 struct crypto_testsuite_params *ts_params = &testsuite_params;
3207 struct crypto_unittest_params *ut_params = &unittest_params;
3210 uint8_t *plaintext, *ciphertext;
3211 unsigned plaintext_pad_len;
3212 unsigned plaintext_len;
3214 /* Create SNOW 3G session */
3215 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3216 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3217 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3218 tdata->key.data, tdata->key.len,
3223 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3225 /* Clear mbuf payload */
3226 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3227 rte_pktmbuf_tailroom(ut_params->ibuf));
3229 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3230 /* Append data which is padded to a multiple of */
3231 /* the algorithms block size */
3232 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3233 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3235 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3237 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3239 /* Create SNOW 3G operation */
3240 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3241 tdata->validCipherLenInBits.len,
3246 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3248 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3250 ut_params->obuf = ut_params->op->sym->m_dst;
3251 if (ut_params->obuf)
3252 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3254 ciphertext = plaintext;
3256 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3259 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3261 tdata->ciphertext.data,
3262 tdata->validDataLenInBits.len,
3263 "SNOW 3G Ciphertext data not as expected");
3269 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3271 struct crypto_testsuite_params *ts_params = &testsuite_params;
3272 struct crypto_unittest_params *ut_params = &unittest_params;
3273 uint8_t *plaintext, *ciphertext;
3276 unsigned plaintext_pad_len;
3277 unsigned plaintext_len;
3279 /* Create SNOW 3G session */
3280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3282 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3283 tdata->key.data, tdata->key.len,
3288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3289 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3291 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3292 "Failed to allocate input buffer in mempool");
3293 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3294 "Failed to allocate output buffer in mempool");
3296 /* Clear mbuf payload */
3297 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3298 rte_pktmbuf_tailroom(ut_params->ibuf));
3300 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3301 /* Append data which is padded to a multiple of */
3302 /* the algorithms block size */
3303 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3304 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3306 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3307 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3309 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3311 /* Create SNOW 3G operation */
3312 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3314 tdata->validCipherLenInBits.len,
3319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3321 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3323 ut_params->obuf = ut_params->op->sym->m_dst;
3324 if (ut_params->obuf)
3325 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3327 ciphertext = plaintext;
3329 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3332 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3334 tdata->ciphertext.data,
3335 tdata->validDataLenInBits.len,
3336 "SNOW 3G Ciphertext data not as expected");
3341 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3343 struct crypto_testsuite_params *ts_params = &testsuite_params;
3344 struct crypto_unittest_params *ut_params = &unittest_params;
3347 unsigned int plaintext_pad_len;
3348 unsigned int plaintext_len;
3349 uint8_t buffer[10000];
3350 const uint8_t *ciphertext;
3352 struct rte_cryptodev_info dev_info;
3354 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3355 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3356 printf("Device doesn't support scatter-gather. "
3361 /* Create SNOW 3G session */
3362 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3363 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3364 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3365 tdata->key.data, tdata->key.len,
3370 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3371 /* Append data which is padded to a multiple of */
3372 /* the algorithms block size */
3373 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3375 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3376 plaintext_pad_len, 10, 0);
3377 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3378 plaintext_pad_len, 3, 0);
3380 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3381 "Failed to allocate input buffer in mempool");
3382 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3383 "Failed to allocate output buffer in mempool");
3385 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3387 /* Create SNOW 3G operation */
3388 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3390 tdata->validCipherLenInBits.len,
3395 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3397 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3399 ut_params->obuf = ut_params->op->sym->m_dst;
3400 if (ut_params->obuf)
3401 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3402 plaintext_len, buffer);
3404 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3405 plaintext_len, buffer);
3407 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3410 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3412 tdata->ciphertext.data,
3413 tdata->validDataLenInBits.len,
3414 "SNOW 3G Ciphertext data not as expected");
3419 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3421 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3423 uint8_t curr_byte, prev_byte;
3424 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3425 uint8_t lower_byte_mask = (1 << offset) - 1;
3428 prev_byte = buffer[0];
3429 buffer[0] >>= offset;
3431 for (i = 1; i < length_in_bytes; i++) {
3432 curr_byte = buffer[i];
3433 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3434 (curr_byte >> offset);
3435 prev_byte = curr_byte;
3440 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3442 struct crypto_testsuite_params *ts_params = &testsuite_params;
3443 struct crypto_unittest_params *ut_params = &unittest_params;
3444 uint8_t *plaintext, *ciphertext;
3446 uint32_t plaintext_len;
3447 uint32_t plaintext_pad_len;
3448 uint8_t extra_offset = 4;
3449 uint8_t *expected_ciphertext_shifted;
3451 /* Create SNOW 3G session */
3452 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3453 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3454 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3455 tdata->key.data, tdata->key.len,
3460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3461 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3464 "Failed to allocate input buffer in mempool");
3465 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3466 "Failed to allocate output buffer in mempool");
3468 /* Clear mbuf payload */
3469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3470 rte_pktmbuf_tailroom(ut_params->ibuf));
3472 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3474 * Append data which is padded to a
3475 * multiple of the algorithms block size
3477 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3479 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3482 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3484 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3485 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3487 #ifdef RTE_APP_TEST_DEBUG
3488 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3490 /* Create SNOW 3G operation */
3491 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3493 tdata->validCipherLenInBits.len,
3498 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3500 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3502 ut_params->obuf = ut_params->op->sym->m_dst;
3503 if (ut_params->obuf)
3504 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3506 ciphertext = plaintext;
3508 #ifdef RTE_APP_TEST_DEBUG
3509 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3512 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3514 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3515 "failed to reserve memory for ciphertext shifted\n");
3517 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3518 ceil_byte_length(tdata->ciphertext.len));
3519 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3524 expected_ciphertext_shifted,
3525 tdata->validDataLenInBits.len,
3527 "SNOW 3G Ciphertext data not as expected");
3531 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3533 struct crypto_testsuite_params *ts_params = &testsuite_params;
3534 struct crypto_unittest_params *ut_params = &unittest_params;
3538 uint8_t *plaintext, *ciphertext;
3539 unsigned ciphertext_pad_len;
3540 unsigned ciphertext_len;
3542 /* Create SNOW 3G session */
3543 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3544 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3545 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3546 tdata->key.data, tdata->key.len,
3551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3553 /* Clear mbuf payload */
3554 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3555 rte_pktmbuf_tailroom(ut_params->ibuf));
3557 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3558 /* Append data which is padded to a multiple of */
3559 /* the algorithms block size */
3560 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3561 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3562 ciphertext_pad_len);
3563 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3565 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3567 /* Create SNOW 3G operation */
3568 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3569 tdata->validCipherLenInBits.len,
3574 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3577 ut_params->obuf = ut_params->op->sym->m_dst;
3578 if (ut_params->obuf)
3579 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3581 plaintext = ciphertext;
3583 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3586 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3587 tdata->plaintext.data,
3588 tdata->validDataLenInBits.len,
3589 "SNOW 3G Plaintext data not as expected");
3593 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3595 struct crypto_testsuite_params *ts_params = &testsuite_params;
3596 struct crypto_unittest_params *ut_params = &unittest_params;
3600 uint8_t *plaintext, *ciphertext;
3601 unsigned ciphertext_pad_len;
3602 unsigned ciphertext_len;
3604 /* Create SNOW 3G session */
3605 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3606 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3607 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3608 tdata->key.data, tdata->key.len,
3613 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3614 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3616 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3617 "Failed to allocate input buffer");
3618 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3619 "Failed to allocate output buffer");
3621 /* Clear mbuf payload */
3622 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3623 rte_pktmbuf_tailroom(ut_params->ibuf));
3625 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3626 rte_pktmbuf_tailroom(ut_params->obuf));
3628 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3629 /* Append data which is padded to a multiple of */
3630 /* the algorithms block size */
3631 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3632 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3633 ciphertext_pad_len);
3634 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3635 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3637 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3639 /* Create SNOW 3G operation */
3640 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3642 tdata->validCipherLenInBits.len,
3647 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3649 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3650 ut_params->obuf = ut_params->op->sym->m_dst;
3651 if (ut_params->obuf)
3652 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3654 plaintext = ciphertext;
3656 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3659 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3660 tdata->plaintext.data,
3661 tdata->validDataLenInBits.len,
3662 "SNOW 3G Plaintext data not as expected");
3667 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3669 struct crypto_testsuite_params *ts_params = &testsuite_params;
3670 struct crypto_unittest_params *ut_params = &unittest_params;
3674 uint8_t *plaintext, *ciphertext;
3675 unsigned int plaintext_pad_len;
3676 unsigned int plaintext_len;
3678 struct rte_cryptodev_sym_capability_idx cap_idx;
3680 /* Check if device supports ZUC EEA3 */
3681 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3682 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3684 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3688 /* Check if device supports ZUC EIA3 */
3689 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3690 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3696 /* Create ZUC session */
3697 retval = create_zuc_cipher_auth_encrypt_generate_session(
3698 ts_params->valid_devs[0],
3702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3704 /* clear mbuf payload */
3705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3706 rte_pktmbuf_tailroom(ut_params->ibuf));
3708 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3709 /* Append data which is padded to a multiple of */
3710 /* the algorithms block size */
3711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3712 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3714 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3716 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3718 /* Create ZUC operation */
3719 retval = create_zuc_cipher_hash_generate_operation(tdata);
3723 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3725 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3726 ut_params->obuf = ut_params->op->sym->m_src;
3727 if (ut_params->obuf)
3728 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3731 ciphertext = plaintext;
3733 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3737 tdata->ciphertext.data,
3738 tdata->validDataLenInBits.len,
3739 "ZUC Ciphertext data not as expected");
3741 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3742 + plaintext_pad_len + tdata->aad.len;
3745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3749 "ZUC Generated auth tag not as expected");
3754 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3756 struct crypto_testsuite_params *ts_params = &testsuite_params;
3757 struct crypto_unittest_params *ut_params = &unittest_params;
3761 uint8_t *plaintext, *ciphertext;
3762 unsigned plaintext_pad_len;
3763 unsigned plaintext_len;
3765 /* Create SNOW 3G session */
3766 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3767 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3768 RTE_CRYPTO_AUTH_OP_GENERATE,
3769 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3770 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3771 tdata->key.data, tdata->key.len,
3772 tdata->aad.len, tdata->digest.len,
3776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 /* clear mbuf payload */
3779 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3780 rte_pktmbuf_tailroom(ut_params->ibuf));
3782 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3783 /* Append data which is padded to a multiple of */
3784 /* the algorithms block size */
3785 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3786 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3790 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3792 /* Create SNOW 3G operation */
3793 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3794 tdata->digest.len, tdata->aad.data,
3795 tdata->aad.len, /*tdata->plaintext.len,*/
3796 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3797 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3798 tdata->iv.data, tdata->iv.len,
3799 tdata->validCipherLenInBits.len,
3801 tdata->validAuthLenInBits.len,
3802 (tdata->aad.len << 3)
3807 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3809 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3810 ut_params->obuf = ut_params->op->sym->m_src;
3811 if (ut_params->obuf)
3812 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3815 ciphertext = plaintext;
3817 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3821 tdata->ciphertext.data,
3822 tdata->validDataLenInBits.len,
3823 "SNOW 3G Ciphertext data not as expected");
3825 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3826 + plaintext_pad_len + tdata->aad.len;
3829 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3832 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3833 "SNOW 3G Generated auth tag not as expected");
3837 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3839 struct crypto_testsuite_params *ts_params = &testsuite_params;
3840 struct crypto_unittest_params *ut_params = &unittest_params;
3844 uint8_t *plaintext, *ciphertext;
3845 unsigned plaintext_pad_len;
3846 unsigned plaintext_len;
3848 /* Create SNOW 3G session */
3849 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3850 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3851 RTE_CRYPTO_AUTH_OP_GENERATE,
3852 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3853 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3854 tdata->key.data, tdata->key.len,
3855 tdata->aad.len, tdata->digest.len,
3860 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3862 /* clear mbuf payload */
3863 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3864 rte_pktmbuf_tailroom(ut_params->ibuf));
3866 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3867 /* Append data which is padded to a multiple of */
3868 /* the algorithms block size */
3869 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3870 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3872 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3874 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3876 /* Create SNOW 3G operation */
3877 retval = create_wireless_algo_auth_cipher_operation(
3879 tdata->iv.data, tdata->iv.len,
3880 tdata->aad.data, tdata->aad.len,
3882 tdata->validCipherLenInBits.len,
3884 tdata->validAuthLenInBits.len,
3885 (tdata->aad.len << 3),
3886 RTE_CRYPTO_AUTH_SNOW3G_UIA2
3892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3895 ut_params->obuf = ut_params->op->sym->m_src;
3896 if (ut_params->obuf)
3897 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3900 ciphertext = plaintext;
3902 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3903 + plaintext_pad_len + tdata->aad.len;
3904 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3907 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3909 tdata->ciphertext.data,
3910 tdata->validDataLenInBits.len,
3911 "SNOW 3G Ciphertext data not as expected");
3914 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3917 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3918 "SNOW 3G Generated auth tag not as expected");
3923 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3925 struct crypto_testsuite_params *ts_params = &testsuite_params;
3926 struct crypto_unittest_params *ut_params = &unittest_params;
3930 uint8_t *plaintext, *ciphertext;
3931 unsigned plaintext_pad_len;
3932 unsigned plaintext_len;
3934 /* Create KASUMI session */
3935 retval = create_wireless_algo_auth_cipher_session(
3936 ts_params->valid_devs[0],
3937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3938 RTE_CRYPTO_AUTH_OP_GENERATE,
3939 RTE_CRYPTO_AUTH_KASUMI_F9,
3940 RTE_CRYPTO_CIPHER_KASUMI_F8,
3941 tdata->key.data, tdata->key.len,
3942 tdata->aad.len, tdata->digest.len,
3946 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3948 /* clear mbuf payload */
3949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3950 rte_pktmbuf_tailroom(ut_params->ibuf));
3952 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3953 /* Append data which is padded to a multiple of */
3954 /* the algorithms block size */
3955 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3956 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3958 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3960 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3962 /* Create KASUMI operation */
3963 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3964 tdata->iv.data, tdata->iv.len,
3965 tdata->aad.data, tdata->aad.len,
3967 tdata->validCipherLenInBits.len,
3969 tdata->validAuthLenInBits.len,
3970 (tdata->aad.len << 3),
3971 RTE_CRYPTO_AUTH_KASUMI_F9
3977 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3979 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3980 ut_params->obuf = ut_params->op->sym->m_src;
3981 if (ut_params->obuf)
3982 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3985 ciphertext = plaintext;
3988 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3990 tdata->ciphertext.data,
3991 tdata->validCipherLenInBits.len,
3992 "KASUMI Ciphertext data not as expected");
3993 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3994 + plaintext_pad_len + tdata->aad.len;
3997 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4000 DIGEST_BYTE_LENGTH_KASUMI_F9,
4001 "KASUMI Generated auth tag not as expected");
4006 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4008 struct crypto_testsuite_params *ts_params = &testsuite_params;
4009 struct crypto_unittest_params *ut_params = &unittest_params;
4013 uint8_t *plaintext, *ciphertext;
4014 unsigned plaintext_pad_len;
4015 unsigned plaintext_len;
4017 /* Create KASUMI session */
4018 retval = create_wireless_algo_cipher_auth_session(
4019 ts_params->valid_devs[0],
4020 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4021 RTE_CRYPTO_AUTH_OP_GENERATE,
4022 RTE_CRYPTO_AUTH_KASUMI_F9,
4023 RTE_CRYPTO_CIPHER_KASUMI_F8,
4024 tdata->key.data, tdata->key.len,
4025 tdata->aad.len, tdata->digest.len,
4030 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4032 /* clear mbuf payload */
4033 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4034 rte_pktmbuf_tailroom(ut_params->ibuf));
4036 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4037 /* Append data which is padded to a multiple of */
4038 /* the algorithms block size */
4039 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4040 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4042 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4044 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4046 /* Create KASUMI operation */
4047 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4048 tdata->digest.len, tdata->aad.data,
4050 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4051 RTE_CRYPTO_AUTH_KASUMI_F9,
4052 tdata->iv.data, tdata->iv.len,
4053 tdata->validCipherLenInBits.len,
4055 tdata->validAuthLenInBits.len,
4056 (tdata->aad.len << 3)
4061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4063 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4064 ut_params->obuf = ut_params->op->sym->m_src;
4065 if (ut_params->obuf)
4066 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4069 ciphertext = plaintext;
4071 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4072 + plaintext_pad_len + tdata->aad.len;
4075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4077 tdata->ciphertext.data,
4078 tdata->validCipherLenInBits.len,
4079 "KASUMI Ciphertext data not as expected");
4082 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4085 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4086 "KASUMI Generated auth tag not as expected");
4091 test_zuc_encryption(const struct wireless_test_data *tdata)
4093 struct crypto_testsuite_params *ts_params = &testsuite_params;
4094 struct crypto_unittest_params *ut_params = &unittest_params;
4097 uint8_t *plaintext, *ciphertext;
4098 unsigned plaintext_pad_len;
4099 unsigned plaintext_len;
4101 struct rte_cryptodev_sym_capability_idx cap_idx;
4103 /* Check if device supports ZUC EEA3 */
4104 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4105 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4111 /* Create ZUC session */
4112 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4113 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4114 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4115 tdata->key.data, tdata->key.len,
4120 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4122 /* Clear mbuf payload */
4123 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4124 rte_pktmbuf_tailroom(ut_params->ibuf));
4126 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4127 /* Append data which is padded to a multiple */
4128 /* of the algorithms block size */
4129 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4130 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4132 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4134 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4136 /* Create ZUC operation */
4137 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
4138 tdata->plaintext.len,
4143 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4145 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4147 ut_params->obuf = ut_params->op->sym->m_dst;
4148 if (ut_params->obuf)
4149 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4151 ciphertext = plaintext;
4153 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4156 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4158 tdata->ciphertext.data,
4159 tdata->validCipherLenInBits.len,
4160 "ZUC Ciphertext data not as expected");
4165 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4167 struct crypto_testsuite_params *ts_params = &testsuite_params;
4168 struct crypto_unittest_params *ut_params = &unittest_params;
4172 unsigned int plaintext_pad_len;
4173 unsigned int plaintext_len;
4174 const uint8_t *ciphertext;
4175 uint8_t ciphertext_buffer[2048];
4176 struct rte_cryptodev_info dev_info;
4178 struct rte_cryptodev_sym_capability_idx cap_idx;
4180 /* Check if device supports ZUC EEA3 */
4181 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4182 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4184 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4188 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4189 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4190 printf("Device doesn't support scatter-gather. "
4195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4197 /* Append data which is padded to a multiple */
4198 /* of the algorithms block size */
4199 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4201 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4202 plaintext_pad_len, 10, 0);
4204 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4205 tdata->plaintext.data);
4207 /* Create ZUC session */
4208 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4209 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4210 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4211 tdata->key.data, tdata->key.len,
4216 /* Clear mbuf payload */
4218 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4220 /* Create ZUC operation */
4221 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
4222 tdata->iv.len, tdata->plaintext.len,
4227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4229 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4231 ut_params->obuf = ut_params->op->sym->m_dst;
4232 if (ut_params->obuf)
4233 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4234 0, plaintext_len, ciphertext_buffer);
4236 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4237 0, plaintext_len, ciphertext_buffer);
4240 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4243 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4245 tdata->ciphertext.data,
4246 tdata->validCipherLenInBits.len,
4247 "ZUC Ciphertext data not as expected");
4253 test_zuc_authentication(const struct wireless_test_data *tdata)
4255 struct crypto_testsuite_params *ts_params = &testsuite_params;
4256 struct crypto_unittest_params *ut_params = &unittest_params;
4259 unsigned plaintext_pad_len;
4260 unsigned plaintext_len;
4263 struct rte_cryptodev_sym_capability_idx cap_idx;
4265 /* Check if device supports ZUC EIA3 */
4266 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4267 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4269 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4273 /* Create ZUC session */
4274 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4275 tdata->key.data, tdata->key.len,
4276 tdata->aad.len, tdata->digest.len,
4277 RTE_CRYPTO_AUTH_OP_GENERATE,
4278 RTE_CRYPTO_AUTH_ZUC_EIA3);
4282 /* alloc mbuf and set payload */
4283 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4285 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4286 rte_pktmbuf_tailroom(ut_params->ibuf));
4288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4289 /* Append data which is padded to a multiple of */
4290 /* the algorithms block size */
4291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4292 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4294 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4296 /* Create ZUC operation */
4297 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4298 tdata->aad.data, tdata->aad.len,
4299 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4300 RTE_CRYPTO_AUTH_ZUC_EIA3,
4301 tdata->validAuthLenInBits.len,
4302 (tdata->aad.len << 3));
4306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4308 ut_params->obuf = ut_params->op->sym->m_src;
4309 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4310 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4311 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
4314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4317 DIGEST_BYTE_LENGTH_KASUMI_F9,
4318 "ZUC Generated auth tag not as expected");
4324 test_kasumi_encryption_test_case_1(void)
4326 return test_kasumi_encryption(&kasumi_test_case_1);
4330 test_kasumi_encryption_test_case_1_sgl(void)
4332 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4336 test_kasumi_encryption_test_case_1_oop(void)
4338 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4342 test_kasumi_encryption_test_case_1_oop_sgl(void)
4344 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4348 test_kasumi_encryption_test_case_2(void)
4350 return test_kasumi_encryption(&kasumi_test_case_2);
4354 test_kasumi_encryption_test_case_3(void)
4356 return test_kasumi_encryption(&kasumi_test_case_3);
4360 test_kasumi_encryption_test_case_4(void)
4362 return test_kasumi_encryption(&kasumi_test_case_4);
4366 test_kasumi_encryption_test_case_5(void)
4368 return test_kasumi_encryption(&kasumi_test_case_5);
4372 test_kasumi_decryption_test_case_1(void)
4374 return test_kasumi_decryption(&kasumi_test_case_1);
4378 test_kasumi_decryption_test_case_1_oop(void)
4380 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4384 test_kasumi_decryption_test_case_2(void)
4386 return test_kasumi_decryption(&kasumi_test_case_2);
4390 test_kasumi_decryption_test_case_3(void)
4392 return test_kasumi_decryption(&kasumi_test_case_3);
4396 test_kasumi_decryption_test_case_4(void)
4398 return test_kasumi_decryption(&kasumi_test_case_4);
4402 test_kasumi_decryption_test_case_5(void)
4404 return test_kasumi_decryption(&kasumi_test_case_5);
4407 test_snow3g_encryption_test_case_1(void)
4409 return test_snow3g_encryption(&snow3g_test_case_1);
4413 test_snow3g_encryption_test_case_1_oop(void)
4415 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4419 test_snow3g_encryption_test_case_1_oop_sgl(void)
4421 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4426 test_snow3g_encryption_test_case_1_offset_oop(void)
4428 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4432 test_snow3g_encryption_test_case_2(void)
4434 return test_snow3g_encryption(&snow3g_test_case_2);
4438 test_snow3g_encryption_test_case_3(void)
4440 return test_snow3g_encryption(&snow3g_test_case_3);
4444 test_snow3g_encryption_test_case_4(void)
4446 return test_snow3g_encryption(&snow3g_test_case_4);
4450 test_snow3g_encryption_test_case_5(void)
4452 return test_snow3g_encryption(&snow3g_test_case_5);
4456 test_snow3g_decryption_test_case_1(void)
4458 return test_snow3g_decryption(&snow3g_test_case_1);
4462 test_snow3g_decryption_test_case_1_oop(void)
4464 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4468 test_snow3g_decryption_test_case_2(void)
4470 return test_snow3g_decryption(&snow3g_test_case_2);
4474 test_snow3g_decryption_test_case_3(void)
4476 return test_snow3g_decryption(&snow3g_test_case_3);
4480 test_snow3g_decryption_test_case_4(void)
4482 return test_snow3g_decryption(&snow3g_test_case_4);
4486 test_snow3g_decryption_test_case_5(void)
4488 return test_snow3g_decryption(&snow3g_test_case_5);
4491 test_snow3g_cipher_auth_test_case_1(void)
4493 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4497 test_snow3g_auth_cipher_test_case_1(void)
4499 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4503 test_kasumi_auth_cipher_test_case_1(void)
4505 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4509 test_kasumi_cipher_auth_test_case_1(void)
4511 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4515 test_zuc_encryption_test_case_1(void)
4517 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4521 test_zuc_encryption_test_case_2(void)
4523 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4527 test_zuc_encryption_test_case_3(void)
4529 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4533 test_zuc_encryption_test_case_4(void)
4535 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4539 test_zuc_encryption_test_case_5(void)
4541 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4545 test_zuc_encryption_test_case_6_sgl(void)
4547 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4551 test_zuc_hash_generate_test_case_1(void)
4553 return test_zuc_authentication(&zuc_test_case_auth_1b);
4557 test_zuc_hash_generate_test_case_2(void)
4559 return test_zuc_authentication(&zuc_test_case_auth_90b);
4563 test_zuc_hash_generate_test_case_3(void)
4565 return test_zuc_authentication(&zuc_test_case_auth_577b);
4569 test_zuc_hash_generate_test_case_4(void)
4571 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4575 test_zuc_hash_generate_test_case_5(void)
4577 return test_zuc_authentication(&zuc_test_auth_5670b);
4581 test_zuc_hash_generate_test_case_6(void)
4583 return test_zuc_authentication(&zuc_test_case_auth_128b);
4587 test_zuc_hash_generate_test_case_7(void)
4589 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4593 test_zuc_hash_generate_test_case_8(void)
4595 return test_zuc_authentication(&zuc_test_case_auth_584b);
4599 test_zuc_cipher_auth_test_case_1(void)
4601 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4605 test_zuc_cipher_auth_test_case_2(void)
4607 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4611 test_3DES_chain_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_3DES_CHAIN_TYPE);
4621 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4623 return TEST_SUCCESS;
4627 test_DES_cipheronly_qat_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_QAT_SYM_PMD,
4635 BLKCIPHER_DES_CIPHERONLY_TYPE);
4637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4639 return TEST_SUCCESS;
4643 test_DES_docsis_openssl_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_OPENSSL_PMD,
4651 BLKCIPHER_DES_DOCSIS_TYPE);
4653 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4655 return TEST_SUCCESS;
4659 test_3DES_chain_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_CHAIN_TYPE);
4669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4671 return TEST_SUCCESS;
4675 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD,
4683 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4685 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4687 return TEST_SUCCESS;
4691 test_3DES_cipheronly_qat_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_QAT_SYM_PMD,
4699 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4701 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4703 return TEST_SUCCESS;
4707 test_3DES_chain_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_CHAIN_TYPE);
4717 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4719 return TEST_SUCCESS;
4723 test_3DES_cipheronly_openssl_all(void)
4725 struct crypto_testsuite_params *ts_params = &testsuite_params;
4728 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4729 ts_params->op_mpool, ts_params->valid_devs[0],
4730 RTE_CRYPTODEV_OPENSSL_PMD,
4731 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4733 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4735 return TEST_SUCCESS;
4738 /* ***** AES-GCM Tests ***** */
4741 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4742 const uint8_t *key, const uint8_t key_len,
4743 const uint8_t aad_len, const uint8_t auth_len,
4745 enum rte_crypto_auth_operation auth_op)
4747 uint8_t cipher_key[key_len];
4749 struct crypto_unittest_params *ut_params = &unittest_params;
4751 memcpy(cipher_key, key, key_len);
4753 /* Setup Cipher Parameters */
4754 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4755 ut_params->cipher_xform.next = NULL;
4757 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4758 ut_params->auth_xform.auth.op = auth_op;
4759 ut_params->cipher_xform.cipher.op = op;
4760 ut_params->cipher_xform.cipher.key.data = cipher_key;
4761 ut_params->cipher_xform.cipher.key.length = key_len;
4762 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
4763 ut_params->cipher_xform.cipher.iv.length = iv_len;
4765 TEST_HEXDUMP(stdout, "key:", key, key_len);
4767 /* Setup Authentication Parameters */
4768 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4769 ut_params->auth_xform.next = NULL;
4771 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4773 ut_params->auth_xform.auth.digest_length = auth_len;
4774 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4775 ut_params->auth_xform.auth.key.length = 0;
4776 ut_params->auth_xform.auth.key.data = NULL;
4778 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4779 ut_params->cipher_xform.next = &ut_params->auth_xform;
4781 /* Create Crypto session*/
4782 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4783 &ut_params->cipher_xform);
4784 } else {/* Create Crypto session*/
4785 ut_params->auth_xform.next = &ut_params->cipher_xform;
4786 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4787 &ut_params->auth_xform);
4790 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4796 create_gcm_xforms(struct rte_crypto_op *op,
4797 enum rte_crypto_cipher_operation cipher_op,
4798 uint8_t *key, const uint8_t key_len,
4799 const uint8_t aad_len, const uint8_t auth_len,
4801 enum rte_crypto_auth_operation auth_op)
4803 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4804 "failed to allocate space for crypto transforms");
4806 struct rte_crypto_sym_op *sym_op = op->sym;
4808 /* Setup Cipher Parameters */
4809 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4810 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4811 sym_op->xform->cipher.op = cipher_op;
4812 sym_op->xform->cipher.key.data = key;
4813 sym_op->xform->cipher.key.length = key_len;
4814 sym_op->xform->cipher.iv.offset = IV_OFFSET;
4815 sym_op->xform->cipher.iv.length = iv_len;
4817 TEST_HEXDUMP(stdout, "key:", key, key_len);
4819 /* Setup Authentication Parameters */
4820 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4821 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4822 sym_op->xform->next->auth.op = auth_op;
4823 sym_op->xform->next->auth.digest_length = auth_len;
4824 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4825 sym_op->xform->next->auth.key.length = 0;
4826 sym_op->xform->next->auth.key.data = NULL;
4827 sym_op->xform->next->next = NULL;
4833 create_gcm_operation(enum rte_crypto_cipher_operation op,
4834 const struct gcm_test_data *tdata)
4836 struct crypto_testsuite_params *ts_params = &testsuite_params;
4837 struct crypto_unittest_params *ut_params = &unittest_params;
4839 uint8_t *plaintext, *ciphertext;
4840 unsigned int aad_pad_len, plaintext_pad_len;
4842 /* Generate Crypto op data structure */
4843 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4844 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4845 TEST_ASSERT_NOT_NULL(ut_params->op,
4846 "Failed to allocate symmetric crypto operation struct");
4848 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4850 /* Append aad data */
4851 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4852 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4854 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4855 "no room to append aad");
4857 sym_op->auth.aad.length = tdata->aad.len;
4858 sym_op->auth.aad.phys_addr =
4859 rte_pktmbuf_mtophys(ut_params->ibuf);
4860 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4861 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4862 sym_op->auth.aad.length);
4864 /* Append IV at the end of the crypto operation*/
4865 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4866 uint8_t *, IV_OFFSET);
4868 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4869 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4872 /* Append plaintext/ciphertext */
4873 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4874 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4875 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4877 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4879 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4880 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4881 tdata->plaintext.len);
4883 if (ut_params->obuf) {
4884 ciphertext = (uint8_t *)rte_pktmbuf_append(
4886 plaintext_pad_len + aad_pad_len);
4887 TEST_ASSERT_NOT_NULL(ciphertext,
4888 "no room to append ciphertext");
4890 memset(ciphertext + aad_pad_len, 0,
4891 tdata->ciphertext.len);
4894 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4895 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4897 TEST_ASSERT_NOT_NULL(ciphertext,
4898 "no room to append ciphertext");
4900 memcpy(ciphertext, tdata->ciphertext.data,
4901 tdata->ciphertext.len);
4902 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4903 tdata->ciphertext.len);
4905 if (ut_params->obuf) {
4906 plaintext = (uint8_t *)rte_pktmbuf_append(
4908 plaintext_pad_len + aad_pad_len);
4909 TEST_ASSERT_NOT_NULL(plaintext,
4910 "no room to append plaintext");
4912 memset(plaintext + aad_pad_len, 0,
4913 tdata->plaintext.len);
4917 /* Append digest data */
4918 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4919 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4920 ut_params->obuf ? ut_params->obuf :
4922 tdata->auth_tag.len);
4923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4924 "no room to append digest");
4925 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4926 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4927 ut_params->obuf ? ut_params->obuf :
4931 sym_op->auth.digest.length = tdata->auth_tag.len;
4933 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4934 ut_params->ibuf, tdata->auth_tag.len);
4935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4936 "no room to append digest");
4937 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4939 plaintext_pad_len + aad_pad_len);
4940 sym_op->auth.digest.length = tdata->auth_tag.len;
4942 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4943 tdata->auth_tag.len);
4944 TEST_HEXDUMP(stdout, "digest:",
4945 sym_op->auth.digest.data,
4946 sym_op->auth.digest.length);
4949 sym_op->cipher.data.length = tdata->plaintext.len;
4950 sym_op->cipher.data.offset = aad_pad_len;
4952 sym_op->auth.data.length = tdata->plaintext.len;
4953 sym_op->auth.data.offset = aad_pad_len;
4959 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4961 struct crypto_testsuite_params *ts_params = &testsuite_params;
4962 struct crypto_unittest_params *ut_params = &unittest_params;
4965 uint8_t *ciphertext, *auth_tag;
4966 uint16_t plaintext_pad_len;
4969 /* Create GCM session */
4970 retval = create_gcm_session(ts_params->valid_devs[0],
4971 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4972 tdata->key.data, tdata->key.len,
4973 tdata->aad.len, tdata->auth_tag.len,
4975 RTE_CRYPTO_AUTH_OP_GENERATE);
4979 if (tdata->aad.len > MBUF_SIZE) {
4980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4981 /* Populate full size of add data */
4982 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4983 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4985 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4987 /* clear mbuf payload */
4988 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4989 rte_pktmbuf_tailroom(ut_params->ibuf));
4991 /* Create GCM operation */
4992 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4996 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4998 ut_params->op->sym->m_src = ut_params->ibuf;
5000 /* Process crypto operation */
5001 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5002 ut_params->op), "failed to process sym crypto op");
5004 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5005 "crypto op processing failed");
5007 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5009 if (ut_params->op->sym->m_dst) {
5010 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5012 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5013 uint8_t *, plaintext_pad_len);
5015 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5017 ut_params->op->sym->cipher.data.offset);
5018 auth_tag = ciphertext + plaintext_pad_len;
5021 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5022 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5025 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5027 tdata->ciphertext.data,
5028 tdata->ciphertext.len,
5029 "GCM Ciphertext data not as expected");
5031 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5033 tdata->auth_tag.data,
5034 tdata->auth_tag.len,
5035 "GCM Generated auth tag not as expected");
5042 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
5044 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5048 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
5050 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5054 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
5056 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5060 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
5062 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5066 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
5068 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5072 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
5074 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5078 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
5080 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5084 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
5086 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5090 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
5092 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5096 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
5098 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5102 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5104 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5108 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5110 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5114 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5116 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5120 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5122 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5126 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5128 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5132 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5134 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5138 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5140 struct crypto_testsuite_params *ts_params = &testsuite_params;
5141 struct crypto_unittest_params *ut_params = &unittest_params;
5147 /* Create GCM session */
5148 retval = create_gcm_session(ts_params->valid_devs[0],
5149 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5150 tdata->key.data, tdata->key.len,
5151 tdata->aad.len, tdata->auth_tag.len,
5153 RTE_CRYPTO_AUTH_OP_VERIFY);
5157 /* alloc mbuf and set payload */
5158 if (tdata->aad.len > MBUF_SIZE) {
5159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5160 /* Populate full size of add data */
5161 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5162 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5164 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5167 rte_pktmbuf_tailroom(ut_params->ibuf));
5169 /* Create GCM operation */
5170 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5174 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5176 ut_params->op->sym->m_src = ut_params->ibuf;
5178 /* Process crypto operation */
5179 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5180 ut_params->op), "failed to process sym crypto op");
5182 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5183 "crypto op processing failed");
5185 if (ut_params->op->sym->m_dst)
5186 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5189 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5191 ut_params->op->sym->cipher.data.offset);
5193 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5196 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5198 tdata->plaintext.data,
5199 tdata->plaintext.len,
5200 "GCM plaintext data not as expected");
5202 TEST_ASSERT_EQUAL(ut_params->op->status,
5203 RTE_CRYPTO_OP_STATUS_SUCCESS,
5204 "GCM authentication failed");
5209 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5211 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5215 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5217 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5221 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5223 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5227 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5229 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5233 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5235 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5239 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5241 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5245 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5247 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5251 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5253 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5257 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5259 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5263 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5265 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5269 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5271 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5275 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5277 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5281 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5283 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5287 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5289 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5293 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5295 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5299 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5301 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5305 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5307 struct crypto_testsuite_params *ts_params = &testsuite_params;
5308 struct crypto_unittest_params *ut_params = &unittest_params;
5311 uint8_t *ciphertext, *auth_tag;
5312 uint16_t plaintext_pad_len;
5314 /* Create GCM session */
5315 retval = create_gcm_session(ts_params->valid_devs[0],
5316 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5317 tdata->key.data, tdata->key.len,
5318 tdata->aad.len, tdata->auth_tag.len,
5320 RTE_CRYPTO_AUTH_OP_GENERATE);
5324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5325 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5327 /* clear mbuf payload */
5328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5329 rte_pktmbuf_tailroom(ut_params->ibuf));
5330 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5331 rte_pktmbuf_tailroom(ut_params->obuf));
5333 /* Create GCM operation */
5334 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5338 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5340 ut_params->op->sym->m_src = ut_params->ibuf;
5341 ut_params->op->sym->m_dst = ut_params->obuf;
5343 /* Process crypto operation */
5344 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5345 ut_params->op), "failed to process sym crypto op");
5347 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5348 "crypto op processing failed");
5350 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5352 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5353 ut_params->op->sym->cipher.data.offset);
5354 auth_tag = ciphertext + plaintext_pad_len;
5356 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5357 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5362 tdata->ciphertext.data,
5363 tdata->ciphertext.len,
5364 "GCM Ciphertext data not as expected");
5366 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5368 tdata->auth_tag.data,
5369 tdata->auth_tag.len,
5370 "GCM Generated auth tag not as expected");
5377 test_mb_AES_GCM_authenticated_encryption_oop(void)
5379 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5383 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5385 struct crypto_testsuite_params *ts_params = &testsuite_params;
5386 struct crypto_unittest_params *ut_params = &unittest_params;
5391 /* Create GCM session */
5392 retval = create_gcm_session(ts_params->valid_devs[0],
5393 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5394 tdata->key.data, tdata->key.len,
5395 tdata->aad.len, tdata->auth_tag.len,
5397 RTE_CRYPTO_AUTH_OP_VERIFY);
5401 /* alloc mbuf and set payload */
5402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5403 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5405 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5406 rte_pktmbuf_tailroom(ut_params->ibuf));
5407 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5408 rte_pktmbuf_tailroom(ut_params->obuf));
5410 /* Create GCM operation */
5411 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5415 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5417 ut_params->op->sym->m_src = ut_params->ibuf;
5418 ut_params->op->sym->m_dst = ut_params->obuf;
5420 /* Process crypto operation */
5421 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5422 ut_params->op), "failed to process sym crypto op");
5424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5425 "crypto op processing failed");
5427 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5428 ut_params->op->sym->cipher.data.offset);
5430 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5435 tdata->plaintext.data,
5436 tdata->plaintext.len,
5437 "GCM plaintext data not as expected");
5439 TEST_ASSERT_EQUAL(ut_params->op->status,
5440 RTE_CRYPTO_OP_STATUS_SUCCESS,
5441 "GCM authentication failed");
5446 test_mb_AES_GCM_authenticated_decryption_oop(void)
5448 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5452 test_AES_GCM_authenticated_encryption_sessionless(
5453 const struct gcm_test_data *tdata)
5455 struct crypto_testsuite_params *ts_params = &testsuite_params;
5456 struct crypto_unittest_params *ut_params = &unittest_params;
5459 uint8_t *ciphertext, *auth_tag;
5460 uint16_t plaintext_pad_len;
5461 uint8_t key[tdata->key.len + 1];
5463 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5465 /* clear mbuf payload */
5466 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5467 rte_pktmbuf_tailroom(ut_params->ibuf));
5469 /* Create GCM operation */
5470 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5474 /* Create GCM xforms */
5475 memcpy(key, tdata->key.data, tdata->key.len);
5476 retval = create_gcm_xforms(ut_params->op,
5477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5478 key, tdata->key.len,
5479 tdata->aad.len, tdata->auth_tag.len,
5481 RTE_CRYPTO_AUTH_OP_GENERATE);
5485 ut_params->op->sym->m_src = ut_params->ibuf;
5487 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5488 RTE_CRYPTO_OP_SESSIONLESS,
5489 "crypto op session type not sessionless");
5491 /* Process crypto operation */
5492 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5493 ut_params->op), "failed to process sym crypto op");
5495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5497 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5498 "crypto op status not success");
5500 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5502 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5503 ut_params->op->sym->cipher.data.offset);
5504 auth_tag = ciphertext + plaintext_pad_len;
5506 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5507 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5510 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5512 tdata->ciphertext.data,
5513 tdata->ciphertext.len,
5514 "GCM Ciphertext data not as expected");
5516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5518 tdata->auth_tag.data,
5519 tdata->auth_tag.len,
5520 "GCM Generated auth tag not as expected");
5527 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5529 return test_AES_GCM_authenticated_encryption_sessionless(
5534 test_AES_GCM_authenticated_decryption_sessionless(
5535 const struct gcm_test_data *tdata)
5537 struct crypto_testsuite_params *ts_params = &testsuite_params;
5538 struct crypto_unittest_params *ut_params = &unittest_params;
5542 uint8_t key[tdata->key.len + 1];
5544 /* alloc mbuf and set payload */
5545 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5547 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5548 rte_pktmbuf_tailroom(ut_params->ibuf));
5550 /* Create GCM operation */
5551 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5555 /* Create GCM xforms */
5556 memcpy(key, tdata->key.data, tdata->key.len);
5557 retval = create_gcm_xforms(ut_params->op,
5558 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5559 key, tdata->key.len,
5560 tdata->aad.len, tdata->auth_tag.len,
5562 RTE_CRYPTO_AUTH_OP_VERIFY);
5566 ut_params->op->sym->m_src = ut_params->ibuf;
5568 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5569 RTE_CRYPTO_OP_SESSIONLESS,
5570 "crypto op session type not sessionless");
5572 /* Process crypto operation */
5573 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5574 ut_params->op), "failed to process sym crypto op");
5576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5578 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5579 "crypto op status not success");
5581 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5582 ut_params->op->sym->cipher.data.offset);
5584 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5587 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5589 tdata->plaintext.data,
5590 tdata->plaintext.len,
5591 "GCM plaintext data not as expected");
5593 TEST_ASSERT_EQUAL(ut_params->op->status,
5594 RTE_CRYPTO_OP_STATUS_SUCCESS,
5595 "GCM authentication failed");
5600 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5602 return test_AES_GCM_authenticated_decryption_sessionless(
5609 struct crypto_testsuite_params *ts_params = &testsuite_params;
5610 struct rte_cryptodev_stats stats;
5611 struct rte_cryptodev *dev;
5612 cryptodev_stats_get_t temp_pfn;
5614 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5615 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5616 &stats) == -ENODEV),
5617 "rte_cryptodev_stats_get invalid dev failed");
5618 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5619 "rte_cryptodev_stats_get invalid Param failed");
5620 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5621 temp_pfn = dev->dev_ops->stats_get;
5622 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5623 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5625 "rte_cryptodev_stats_get invalid Param failed");
5626 dev->dev_ops->stats_get = temp_pfn;
5628 /* Test expected values */
5630 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5632 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5634 "rte_cryptodev_stats_get failed");
5635 TEST_ASSERT((stats.enqueued_count == 1),
5636 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5637 TEST_ASSERT((stats.dequeued_count == 1),
5638 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5639 TEST_ASSERT((stats.enqueue_err_count == 0),
5640 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5641 TEST_ASSERT((stats.dequeue_err_count == 0),
5642 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5644 /* invalid device but should ignore and not reset device stats*/
5645 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5646 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5648 "rte_cryptodev_stats_get failed");
5649 TEST_ASSERT((stats.enqueued_count == 1),
5650 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5652 /* check that a valid reset clears stats */
5653 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5654 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5656 "rte_cryptodev_stats_get failed");
5657 TEST_ASSERT((stats.enqueued_count == 0),
5658 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5659 TEST_ASSERT((stats.dequeued_count == 0),
5660 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5662 return TEST_SUCCESS;
5665 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5666 struct crypto_unittest_params *ut_params,
5667 enum rte_crypto_auth_operation op,
5668 const struct HMAC_MD5_vector *test_case)
5672 memcpy(key, test_case->key.data, test_case->key.len);
5674 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5675 ut_params->auth_xform.next = NULL;
5676 ut_params->auth_xform.auth.op = op;
5678 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5680 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5681 ut_params->auth_xform.auth.add_auth_data_length = 0;
5682 ut_params->auth_xform.auth.key.length = test_case->key.len;
5683 ut_params->auth_xform.auth.key.data = key;
5685 ut_params->sess = rte_cryptodev_sym_session_create(
5686 ts_params->valid_devs[0], &ut_params->auth_xform);
5688 if (ut_params->sess == NULL)
5691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5693 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5694 rte_pktmbuf_tailroom(ut_params->ibuf));
5699 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5700 const struct HMAC_MD5_vector *test_case,
5701 uint8_t **plaintext)
5703 uint16_t plaintext_pad_len;
5705 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5707 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5710 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5712 memcpy(*plaintext, test_case->plaintext.data,
5713 test_case->plaintext.len);
5715 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5716 ut_params->ibuf, MD5_DIGEST_LEN);
5717 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5718 "no room to append digest");
5719 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5720 ut_params->ibuf, plaintext_pad_len);
5721 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5723 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5724 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5725 test_case->auth_tag.len);
5728 sym_op->auth.data.offset = 0;
5729 sym_op->auth.data.length = test_case->plaintext.len;
5731 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5732 ut_params->op->sym->m_src = ut_params->ibuf;
5738 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5740 uint16_t plaintext_pad_len;
5741 uint8_t *plaintext, *auth_tag;
5743 struct crypto_testsuite_params *ts_params = &testsuite_params;
5744 struct crypto_unittest_params *ut_params = &unittest_params;
5746 if (MD5_HMAC_create_session(ts_params, ut_params,
5747 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5750 /* Generate Crypto op data structure */
5751 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5752 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5753 TEST_ASSERT_NOT_NULL(ut_params->op,
5754 "Failed to allocate symmetric crypto operation struct");
5756 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5759 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5762 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5763 ut_params->op), "failed to process sym crypto op");
5765 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5766 "crypto op processing failed");
5768 if (ut_params->op->sym->m_dst) {
5769 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5770 uint8_t *, plaintext_pad_len);
5772 auth_tag = plaintext + plaintext_pad_len;
5775 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5777 test_case->auth_tag.data,
5778 test_case->auth_tag.len,
5779 "HMAC_MD5 generated tag not as expected");
5781 return TEST_SUCCESS;
5785 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5789 struct crypto_testsuite_params *ts_params = &testsuite_params;
5790 struct crypto_unittest_params *ut_params = &unittest_params;
5792 if (MD5_HMAC_create_session(ts_params, ut_params,
5793 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5797 /* Generate Crypto op data structure */
5798 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5799 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5800 TEST_ASSERT_NOT_NULL(ut_params->op,
5801 "Failed to allocate symmetric crypto operation struct");
5803 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5806 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5807 ut_params->op), "failed to process sym crypto op");
5809 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5810 "HMAC_MD5 crypto op processing failed");
5812 return TEST_SUCCESS;
5816 test_MD5_HMAC_generate_case_1(void)
5818 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5822 test_MD5_HMAC_verify_case_1(void)
5824 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5828 test_MD5_HMAC_generate_case_2(void)
5830 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5834 test_MD5_HMAC_verify_case_2(void)
5836 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5840 test_multi_session(void)
5842 struct crypto_testsuite_params *ts_params = &testsuite_params;
5843 struct crypto_unittest_params *ut_params = &unittest_params;
5845 struct rte_cryptodev_info dev_info;
5846 struct rte_cryptodev_sym_session **sessions;
5850 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5851 aes_cbc_key, hmac_sha512_key);
5854 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5856 sessions = rte_malloc(NULL,
5857 (sizeof(struct rte_cryptodev_sym_session *) *
5858 dev_info.sym.max_nb_sessions) + 1, 0);
5860 /* Create multiple crypto sessions*/
5861 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5862 sessions[i] = rte_cryptodev_sym_session_create(
5863 ts_params->valid_devs[0],
5864 &ut_params->auth_xform);
5865 TEST_ASSERT_NOT_NULL(sessions[i],
5866 "Session creation failed at session number %u",
5869 /* Attempt to send a request on each session */
5870 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5874 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5875 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5877 "Failed to perform decrypt on request number %u.", i);
5878 /* free crypto operation structure */
5880 rte_crypto_op_free(ut_params->op);
5883 * free mbuf - both obuf and ibuf are usually the same,
5884 * so check if they point at the same address is necessary,
5885 * to avoid freeing the mbuf twice.
5887 if (ut_params->obuf) {
5888 rte_pktmbuf_free(ut_params->obuf);
5889 if (ut_params->ibuf == ut_params->obuf)
5890 ut_params->ibuf = 0;
5891 ut_params->obuf = 0;
5893 if (ut_params->ibuf) {
5894 rte_pktmbuf_free(ut_params->ibuf);
5895 ut_params->ibuf = 0;
5899 /* Next session create should fail */
5900 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5901 &ut_params->auth_xform);
5902 TEST_ASSERT_NULL(sessions[i],
5903 "Session creation succeeded unexpectedly!");
5905 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5906 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5911 return TEST_SUCCESS;
5914 struct multi_session_params {
5915 struct crypto_unittest_params ut_params;
5916 uint8_t *cipher_key;
5918 const uint8_t *cipher;
5919 const uint8_t *digest;
5923 #define MB_SESSION_NUMBER 3
5926 test_multi_session_random_usage(void)
5928 struct crypto_testsuite_params *ts_params = &testsuite_params;
5929 struct rte_cryptodev_info dev_info;
5930 struct rte_cryptodev_sym_session **sessions;
5932 struct multi_session_params ut_paramz[] = {
5935 .cipher_key = ms_aes_cbc_key0,
5936 .hmac_key = ms_hmac_key0,
5937 .cipher = ms_aes_cbc_cipher0,
5938 .digest = ms_hmac_digest0,
5939 .iv = ms_aes_cbc_iv0
5942 .cipher_key = ms_aes_cbc_key1,
5943 .hmac_key = ms_hmac_key1,
5944 .cipher = ms_aes_cbc_cipher1,
5945 .digest = ms_hmac_digest1,
5946 .iv = ms_aes_cbc_iv1
5949 .cipher_key = ms_aes_cbc_key2,
5950 .hmac_key = ms_hmac_key2,
5951 .cipher = ms_aes_cbc_cipher2,
5952 .digest = ms_hmac_digest2,
5953 .iv = ms_aes_cbc_iv2
5958 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5960 sessions = rte_malloc(NULL,
5961 (sizeof(struct rte_cryptodev_sym_session *)
5962 * dev_info.sym.max_nb_sessions) + 1, 0);
5964 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5965 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5966 sizeof(struct crypto_unittest_params));
5968 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5969 &ut_paramz[i].ut_params,
5970 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5972 /* Create multiple crypto sessions*/
5973 sessions[i] = rte_cryptodev_sym_session_create(
5974 ts_params->valid_devs[0],
5975 &ut_paramz[i].ut_params.auth_xform);
5977 TEST_ASSERT_NOT_NULL(sessions[i],
5978 "Session creation failed at session number %u",
5984 for (i = 0; i < 40000; i++) {
5986 j = rand() % MB_SESSION_NUMBER;
5988 TEST_ASSERT_SUCCESS(
5989 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5991 &ut_paramz[j].ut_params,
5992 ts_params, ut_paramz[j].cipher,
5993 ut_paramz[j].digest,
5995 "Failed to perform decrypt on request number %u.", i);
5997 if (ut_paramz[j].ut_params.op)
5998 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6001 * free mbuf - both obuf and ibuf are usually the same,
6002 * so check if they point at the same address is necessary,
6003 * to avoid freeing the mbuf twice.
6005 if (ut_paramz[j].ut_params.obuf) {
6006 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6007 if (ut_paramz[j].ut_params.ibuf
6008 == ut_paramz[j].ut_params.obuf)
6009 ut_paramz[j].ut_params.ibuf = 0;
6010 ut_paramz[j].ut_params.obuf = 0;
6012 if (ut_paramz[j].ut_params.ibuf) {
6013 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6014 ut_paramz[j].ut_params.ibuf = 0;
6018 for (i = 0; i < MB_SESSION_NUMBER; i++)
6019 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
6024 return TEST_SUCCESS;
6028 test_null_cipher_only_operation(void)
6030 struct crypto_testsuite_params *ts_params = &testsuite_params;
6031 struct crypto_unittest_params *ut_params = &unittest_params;
6033 /* Generate test mbuf data and space for digest */
6034 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6035 catch_22_quote, QUOTE_512_BYTES, 0);
6037 /* Setup Cipher Parameters */
6038 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6039 ut_params->cipher_xform.next = NULL;
6041 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6042 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6044 /* Create Crypto session*/
6045 ut_params->sess = rte_cryptodev_sym_session_create(
6046 ts_params->valid_devs[0], &ut_params->cipher_xform);
6047 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6049 /* Generate Crypto op data structure */
6050 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6051 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6052 TEST_ASSERT_NOT_NULL(ut_params->op,
6053 "Failed to allocate symmetric crypto operation struct");
6055 /* Set crypto operation data parameters */
6056 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6058 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6060 /* set crypto operation source mbuf */
6061 sym_op->m_src = ut_params->ibuf;
6063 sym_op->cipher.data.offset = 0;
6064 sym_op->cipher.data.length = QUOTE_512_BYTES;
6066 /* Process crypto operation */
6067 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6069 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6071 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6072 "crypto operation processing failed");
6075 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6076 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6079 "Ciphertext data not as expected");
6081 return TEST_SUCCESS;
6085 test_null_auth_only_operation(void)
6087 struct crypto_testsuite_params *ts_params = &testsuite_params;
6088 struct crypto_unittest_params *ut_params = &unittest_params;
6090 /* Generate test mbuf data and space for digest */
6091 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6092 catch_22_quote, QUOTE_512_BYTES, 0);
6094 /* Setup HMAC Parameters */
6095 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6096 ut_params->auth_xform.next = NULL;
6098 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6099 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6101 /* Create Crypto session*/
6102 ut_params->sess = rte_cryptodev_sym_session_create(
6103 ts_params->valid_devs[0], &ut_params->auth_xform);
6104 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6106 /* Generate Crypto op data structure */
6107 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6108 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6109 TEST_ASSERT_NOT_NULL(ut_params->op,
6110 "Failed to allocate symmetric crypto operation struct");
6112 /* Set crypto operation data parameters */
6113 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6115 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6117 sym_op->m_src = ut_params->ibuf;
6119 sym_op->auth.data.offset = 0;
6120 sym_op->auth.data.length = QUOTE_512_BYTES;
6122 /* Process crypto operation */
6123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6125 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6127 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6128 "crypto operation processing failed");
6130 return TEST_SUCCESS;
6134 test_null_cipher_auth_operation(void)
6136 struct crypto_testsuite_params *ts_params = &testsuite_params;
6137 struct crypto_unittest_params *ut_params = &unittest_params;
6139 /* Generate test mbuf data and space for digest */
6140 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6141 catch_22_quote, QUOTE_512_BYTES, 0);
6143 /* Setup Cipher Parameters */
6144 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6145 ut_params->cipher_xform.next = &ut_params->auth_xform;
6147 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6148 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6150 /* Setup HMAC Parameters */
6151 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6152 ut_params->auth_xform.next = NULL;
6154 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6155 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6157 /* Create Crypto session*/
6158 ut_params->sess = rte_cryptodev_sym_session_create(
6159 ts_params->valid_devs[0], &ut_params->cipher_xform);
6160 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6162 /* Generate Crypto op data structure */
6163 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6164 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6165 TEST_ASSERT_NOT_NULL(ut_params->op,
6166 "Failed to allocate symmetric crypto operation struct");
6168 /* Set crypto operation data parameters */
6169 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6171 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6173 sym_op->m_src = ut_params->ibuf;
6175 sym_op->cipher.data.offset = 0;
6176 sym_op->cipher.data.length = QUOTE_512_BYTES;
6178 sym_op->auth.data.offset = 0;
6179 sym_op->auth.data.length = QUOTE_512_BYTES;
6181 /* Process crypto operation */
6182 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6184 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6186 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6187 "crypto operation processing failed");
6190 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6191 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6194 "Ciphertext data not as expected");
6196 return TEST_SUCCESS;
6200 test_null_auth_cipher_operation(void)
6202 struct crypto_testsuite_params *ts_params = &testsuite_params;
6203 struct crypto_unittest_params *ut_params = &unittest_params;
6205 /* Generate test mbuf data and space for digest */
6206 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6207 catch_22_quote, QUOTE_512_BYTES, 0);
6209 /* Setup Cipher Parameters */
6210 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6211 ut_params->cipher_xform.next = NULL;
6213 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6214 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6216 /* Setup HMAC Parameters */
6217 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6218 ut_params->auth_xform.next = &ut_params->cipher_xform;
6220 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6221 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6223 /* Create Crypto session*/
6224 ut_params->sess = rte_cryptodev_sym_session_create(
6225 ts_params->valid_devs[0], &ut_params->cipher_xform);
6226 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6228 /* Generate Crypto op data structure */
6229 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6230 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6231 TEST_ASSERT_NOT_NULL(ut_params->op,
6232 "Failed to allocate symmetric crypto operation struct");
6234 /* Set crypto operation data parameters */
6235 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6237 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6239 sym_op->m_src = ut_params->ibuf;
6241 sym_op->cipher.data.offset = 0;
6242 sym_op->cipher.data.length = QUOTE_512_BYTES;
6244 sym_op->auth.data.offset = 0;
6245 sym_op->auth.data.length = QUOTE_512_BYTES;
6247 /* Process crypto operation */
6248 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6250 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6252 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6253 "crypto operation processing failed");
6256 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6257 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6260 "Ciphertext data not as expected");
6262 return TEST_SUCCESS;
6267 test_null_invalid_operation(void)
6269 struct crypto_testsuite_params *ts_params = &testsuite_params;
6270 struct crypto_unittest_params *ut_params = &unittest_params;
6272 /* Setup Cipher Parameters */
6273 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6274 ut_params->cipher_xform.next = NULL;
6276 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6277 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6279 /* Create Crypto session*/
6280 ut_params->sess = rte_cryptodev_sym_session_create(
6281 ts_params->valid_devs[0], &ut_params->cipher_xform);
6282 TEST_ASSERT_NULL(ut_params->sess,
6283 "Session creation succeeded unexpectedly");
6286 /* Setup HMAC Parameters */
6287 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6288 ut_params->auth_xform.next = NULL;
6290 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6291 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6293 /* Create Crypto session*/
6294 ut_params->sess = rte_cryptodev_sym_session_create(
6295 ts_params->valid_devs[0], &ut_params->auth_xform);
6296 TEST_ASSERT_NULL(ut_params->sess,
6297 "Session creation succeeded unexpectedly");
6299 return TEST_SUCCESS;
6303 #define NULL_BURST_LENGTH (32)
6306 test_null_burst_operation(void)
6308 struct crypto_testsuite_params *ts_params = &testsuite_params;
6309 struct crypto_unittest_params *ut_params = &unittest_params;
6311 unsigned i, burst_len = NULL_BURST_LENGTH;
6313 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6314 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6316 /* Setup Cipher Parameters */
6317 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6318 ut_params->cipher_xform.next = &ut_params->auth_xform;
6320 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6321 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6323 /* Setup HMAC Parameters */
6324 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6325 ut_params->auth_xform.next = NULL;
6327 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6328 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6330 /* Create Crypto session*/
6331 ut_params->sess = rte_cryptodev_sym_session_create(
6332 ts_params->valid_devs[0], &ut_params->cipher_xform);
6333 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6335 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6336 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6337 burst_len, "failed to generate burst of crypto ops");
6339 /* Generate an operation for each mbuf in burst */
6340 for (i = 0; i < burst_len; i++) {
6341 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6343 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6345 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6349 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6351 burst[i]->sym->m_src = m;
6354 /* Process crypto operation */
6355 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6356 0, burst, burst_len),
6358 "Error enqueuing burst");
6360 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6361 0, burst_dequeued, burst_len),
6363 "Error dequeuing burst");
6366 for (i = 0; i < burst_len; i++) {
6368 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6369 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6371 "data not as expected");
6373 rte_pktmbuf_free(burst[i]->sym->m_src);
6374 rte_crypto_op_free(burst[i]);
6377 return TEST_SUCCESS;
6381 generate_gmac_large_plaintext(uint8_t *data)
6385 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6386 memcpy(&data[i], &data[0], 32);
6390 create_gmac_operation(enum rte_crypto_auth_operation op,
6391 const struct gmac_test_data *tdata)
6393 struct crypto_testsuite_params *ts_params = &testsuite_params;
6394 struct crypto_unittest_params *ut_params = &unittest_params;
6395 struct rte_crypto_sym_op *sym_op;
6397 unsigned aad_pad_len;
6399 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6402 * Runtime generate the large plain text instead of use hard code
6403 * plain text vector. It is done to avoid create huge source file
6404 * with the test vector.
6406 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6407 generate_gmac_large_plaintext(tdata->aad.data);
6409 /* Generate Crypto op data structure */
6410 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6411 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6412 TEST_ASSERT_NOT_NULL(ut_params->op,
6413 "Failed to allocate symmetric crypto operation struct");
6415 sym_op = ut_params->op->sym;
6416 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6418 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6419 "no room to append aad");
6421 sym_op->auth.aad.length = tdata->aad.len;
6422 sym_op->auth.aad.phys_addr =
6423 rte_pktmbuf_mtophys(ut_params->ibuf);
6424 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6426 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6427 ut_params->ibuf, tdata->gmac_tag.len);
6428 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6429 "no room to append digest");
6431 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6432 ut_params->ibuf, aad_pad_len);
6433 sym_op->auth.digest.length = tdata->gmac_tag.len;
6435 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6436 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6437 tdata->gmac_tag.len);
6438 TEST_HEXDUMP(stdout, "digest:",
6439 sym_op->auth.digest.data,
6440 sym_op->auth.digest.length);
6443 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6444 uint8_t *, IV_OFFSET);
6446 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6448 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6450 sym_op->cipher.data.length = 0;
6451 sym_op->cipher.data.offset = 0;
6453 sym_op->auth.data.offset = 0;
6454 sym_op->auth.data.length = 0;
6459 static int create_gmac_session(uint8_t dev_id,
6460 enum rte_crypto_cipher_operation op,
6461 const struct gmac_test_data *tdata,
6462 enum rte_crypto_auth_operation auth_op)
6464 uint8_t cipher_key[tdata->key.len];
6466 struct crypto_unittest_params *ut_params = &unittest_params;
6468 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6470 /* For GMAC we setup cipher parameters */
6471 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6472 ut_params->cipher_xform.next = NULL;
6473 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6474 ut_params->cipher_xform.cipher.op = op;
6475 ut_params->cipher_xform.cipher.key.data = cipher_key;
6476 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6477 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6478 ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
6480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6481 ut_params->auth_xform.next = NULL;
6483 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6484 ut_params->auth_xform.auth.op = auth_op;
6485 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6486 ut_params->auth_xform.auth.add_auth_data_length = 0;
6487 ut_params->auth_xform.auth.key.length = 0;
6488 ut_params->auth_xform.auth.key.data = NULL;
6490 ut_params->cipher_xform.next = &ut_params->auth_xform;
6492 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6493 &ut_params->cipher_xform);
6495 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6501 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6503 struct crypto_testsuite_params *ts_params = &testsuite_params;
6504 struct crypto_unittest_params *ut_params = &unittest_params;
6508 uint8_t *auth_tag, *p;
6509 uint16_t aad_pad_len;
6511 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6512 "No GMAC length in the source data");
6514 retval = create_gmac_session(ts_params->valid_devs[0],
6515 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6516 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6521 if (tdata->aad.len > MBUF_SIZE)
6522 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6524 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6525 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6526 "Failed to allocate input buffer in mempool");
6528 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6529 rte_pktmbuf_tailroom(ut_params->ibuf));
6531 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6533 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6535 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6541 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6543 ut_params->op->sym->m_src = ut_params->ibuf;
6545 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6546 ut_params->op), "failed to process sym crypto op");
6548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6549 "crypto op processing failed");
6551 if (ut_params->op->sym->m_dst) {
6552 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6553 uint8_t *, aad_pad_len);
6555 auth_tag = p + aad_pad_len;
6558 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6560 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6562 tdata->gmac_tag.data,
6563 tdata->gmac_tag.len,
6564 "GMAC Generated auth tag not as expected");
6570 test_AES_GMAC_authentication_test_case_1(void)
6572 return test_AES_GMAC_authentication(&gmac_test_case_1);
6576 test_AES_GMAC_authentication_test_case_2(void)
6578 return test_AES_GMAC_authentication(&gmac_test_case_2);
6582 test_AES_GMAC_authentication_test_case_3(void)
6584 return test_AES_GMAC_authentication(&gmac_test_case_3);
6588 test_AES_GMAC_authentication_test_case_4(void)
6590 return test_AES_GMAC_authentication(&gmac_test_case_4);
6594 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6596 struct crypto_testsuite_params *ts_params = &testsuite_params;
6597 struct crypto_unittest_params *ut_params = &unittest_params;
6600 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6601 "No GMAC length in the source data");
6603 retval = create_gmac_session(ts_params->valid_devs[0],
6604 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6605 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6610 if (tdata->aad.len > MBUF_SIZE)
6611 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6613 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6614 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6615 "Failed to allocate input buffer in mempool");
6617 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6618 rte_pktmbuf_tailroom(ut_params->ibuf));
6620 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6626 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6628 ut_params->op->sym->m_src = ut_params->ibuf;
6630 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6631 ut_params->op), "failed to process sym crypto op");
6633 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6634 "crypto op processing failed");
6641 test_AES_GMAC_authentication_verify_test_case_1(void)
6643 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6647 test_AES_GMAC_authentication_verify_test_case_2(void)
6649 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6653 test_AES_GMAC_authentication_verify_test_case_3(void)
6655 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6659 test_AES_GMAC_authentication_verify_test_case_4(void)
6661 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6664 struct test_crypto_vector {
6665 enum rte_crypto_cipher_algorithm crypto_algo;
6678 const uint8_t *data;
6683 const uint8_t *data;
6687 enum rte_crypto_auth_algorithm auth_algo;
6695 const uint8_t *data;
6705 static const struct test_crypto_vector
6706 hmac_sha1_test_crypto_vector = {
6707 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6709 .data = plaintext_hash,
6714 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6715 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6716 0xDE, 0xF4, 0xDE, 0xAD
6722 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6723 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6724 0x3F, 0x91, 0x64, 0x59
6730 static const struct test_crypto_vector
6731 aes128_gmac_test_vector = {
6732 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6733 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6735 .data = plaintext_hash,
6740 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6741 0x08, 0x09, 0x0A, 0x0B
6747 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6748 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6754 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6755 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6761 static const struct test_crypto_vector
6762 aes128cbc_hmac_sha1_test_vector = {
6763 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6766 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6767 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6773 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6774 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6779 .data = plaintext_hash,
6783 .data = ciphertext512_aes128cbc,
6786 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6789 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6790 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6791 0xDE, 0xF4, 0xDE, 0xAD
6797 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6798 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6799 0x18, 0x8C, 0x1D, 0x32
6806 data_corruption(uint8_t *data)
6812 tag_corruption(uint8_t *data, unsigned int tag_offset)
6814 data[tag_offset] += 1;
6818 create_auth_session(struct crypto_unittest_params *ut_params,
6820 const struct test_crypto_vector *reference,
6821 enum rte_crypto_auth_operation auth_op)
6823 uint8_t auth_key[reference->auth_key.len + 1];
6825 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6827 /* Setup Authentication Parameters */
6828 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6829 ut_params->auth_xform.auth.op = auth_op;
6830 ut_params->auth_xform.next = NULL;
6831 ut_params->auth_xform.auth.algo = reference->auth_algo;
6832 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6833 ut_params->auth_xform.auth.key.data = auth_key;
6834 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6835 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6837 /* Create Crypto session*/
6838 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6839 &ut_params->auth_xform);
6841 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6847 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6849 const struct test_crypto_vector *reference,
6850 enum rte_crypto_auth_operation auth_op,
6851 enum rte_crypto_cipher_operation cipher_op)
6853 uint8_t cipher_key[reference->cipher_key.len + 1];
6854 uint8_t auth_key[reference->auth_key.len + 1];
6856 memcpy(cipher_key, reference->cipher_key.data,
6857 reference->cipher_key.len);
6858 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6860 /* Setup Authentication Parameters */
6861 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6862 ut_params->auth_xform.auth.op = auth_op;
6863 ut_params->auth_xform.next = &ut_params->cipher_xform;
6864 ut_params->auth_xform.auth.algo = reference->auth_algo;
6865 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6866 ut_params->auth_xform.auth.key.data = auth_key;
6867 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6868 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6870 /* Setup Cipher Parameters */
6871 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6872 ut_params->cipher_xform.next = NULL;
6873 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6874 ut_params->cipher_xform.cipher.op = cipher_op;
6875 ut_params->cipher_xform.cipher.key.data = cipher_key;
6876 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6877 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6878 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6880 /* Create Crypto session*/
6881 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6882 &ut_params->auth_xform);
6884 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6890 create_auth_operation(struct crypto_testsuite_params *ts_params,
6891 struct crypto_unittest_params *ut_params,
6892 const struct test_crypto_vector *reference,
6893 unsigned int auth_generate)
6895 /* Generate Crypto op data structure */
6896 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6897 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6898 TEST_ASSERT_NOT_NULL(ut_params->op,
6899 "Failed to allocate pktmbuf offload");
6901 /* Set crypto operation data parameters */
6902 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6904 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6906 /* set crypto operation source mbuf */
6907 sym_op->m_src = ut_params->ibuf;
6910 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6911 ut_params->ibuf, reference->digest.len);
6913 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6914 "no room to append auth tag");
6916 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6917 ut_params->ibuf, reference->plaintext.len);
6918 sym_op->auth.digest.length = reference->digest.len;
6921 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6923 memcpy(sym_op->auth.digest.data,
6924 reference->digest.data,
6925 reference->digest.len);
6927 TEST_HEXDUMP(stdout, "digest:",
6928 sym_op->auth.digest.data,
6929 sym_op->auth.digest.length);
6931 sym_op->auth.data.length = reference->plaintext.len;
6932 sym_op->auth.data.offset = 0;
6938 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6939 struct crypto_unittest_params *ut_params,
6940 const struct test_crypto_vector *reference,
6941 unsigned int auth_generate)
6943 /* Generate Crypto op data structure */
6944 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6945 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6946 TEST_ASSERT_NOT_NULL(ut_params->op,
6947 "Failed to allocate pktmbuf offload");
6949 /* Set crypto operation data parameters */
6950 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6952 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6954 /* set crypto operation source mbuf */
6955 sym_op->m_src = ut_params->ibuf;
6958 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6959 reference->aad.len);
6960 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6961 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6963 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6965 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6966 sym_op->auth.aad.length = reference->aad.len;
6969 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6970 ut_params->ibuf, reference->digest.len);
6972 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6973 "no room to append auth tag");
6975 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6976 ut_params->ibuf, reference->ciphertext.len);
6977 sym_op->auth.digest.length = reference->digest.len;
6980 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6982 memcpy(sym_op->auth.digest.data,
6983 reference->digest.data,
6984 reference->digest.len);
6986 TEST_HEXDUMP(stdout, "digest:",
6987 sym_op->auth.digest.data,
6988 sym_op->auth.digest.length);
6990 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6991 reference->iv.data, reference->iv.len);
6993 sym_op->cipher.data.length = 0;
6994 sym_op->cipher.data.offset = 0;
6996 sym_op->auth.data.length = 0;
6997 sym_op->auth.data.offset = 0;
7003 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7004 struct crypto_unittest_params *ut_params,
7005 const struct test_crypto_vector *reference,
7006 unsigned int auth_generate)
7008 /* Generate Crypto op data structure */
7009 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7010 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7011 TEST_ASSERT_NOT_NULL(ut_params->op,
7012 "Failed to allocate pktmbuf offload");
7014 /* Set crypto operation data parameters */
7015 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7017 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7019 /* set crypto operation source mbuf */
7020 sym_op->m_src = ut_params->ibuf;
7023 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7024 ut_params->ibuf, reference->digest.len);
7026 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7027 "no room to append auth tag");
7029 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7030 ut_params->ibuf, reference->ciphertext.len);
7031 sym_op->auth.digest.length = reference->digest.len;
7034 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7036 memcpy(sym_op->auth.digest.data,
7037 reference->digest.data,
7038 reference->digest.len);
7040 TEST_HEXDUMP(stdout, "digest:",
7041 sym_op->auth.digest.data,
7042 sym_op->auth.digest.length);
7044 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7045 reference->iv.data, reference->iv.len);
7047 sym_op->cipher.data.length = reference->ciphertext.len;
7048 sym_op->cipher.data.offset = 0;
7050 sym_op->auth.data.length = reference->ciphertext.len;
7051 sym_op->auth.data.offset = 0;
7057 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7058 struct crypto_unittest_params *ut_params,
7059 const struct test_crypto_vector *reference)
7061 return create_auth_operation(ts_params, ut_params, reference, 0);
7065 create_auth_verify_GMAC_operation(
7066 struct crypto_testsuite_params *ts_params,
7067 struct crypto_unittest_params *ut_params,
7068 const struct test_crypto_vector *reference)
7070 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7074 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7075 struct crypto_unittest_params *ut_params,
7076 const struct test_crypto_vector *reference)
7078 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7082 test_authentication_verify_fail_when_data_corruption(
7083 struct crypto_testsuite_params *ts_params,
7084 struct crypto_unittest_params *ut_params,
7085 const struct test_crypto_vector *reference,
7086 unsigned int data_corrupted)
7092 /* Create session */
7093 retval = create_auth_session(ut_params,
7094 ts_params->valid_devs[0],
7096 RTE_CRYPTO_AUTH_OP_VERIFY);
7100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7101 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7102 "Failed to allocate input buffer in mempool");
7104 /* clear mbuf payload */
7105 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7106 rte_pktmbuf_tailroom(ut_params->ibuf));
7108 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7109 reference->plaintext.len);
7110 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7111 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7113 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7115 /* Create operation */
7116 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7122 data_corruption(plaintext);
7124 tag_corruption(plaintext, reference->plaintext.len);
7126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7129 TEST_ASSERT_EQUAL(ut_params->op->status,
7130 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7131 "authentication not failed");
7133 ut_params->obuf = ut_params->op->sym->m_src;
7134 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7140 test_authentication_verify_GMAC_fail_when_corruption(
7141 struct crypto_testsuite_params *ts_params,
7142 struct crypto_unittest_params *ut_params,
7143 const struct test_crypto_vector *reference,
7144 unsigned int data_corrupted)
7148 /* Create session */
7149 retval = create_auth_cipher_session(ut_params,
7150 ts_params->valid_devs[0],
7152 RTE_CRYPTO_AUTH_OP_VERIFY,
7153 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7157 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7158 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7159 "Failed to allocate input buffer in mempool");
7161 /* clear mbuf payload */
7162 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7163 rte_pktmbuf_tailroom(ut_params->ibuf));
7165 /* Create operation */
7166 retval = create_auth_verify_GMAC_operation(ts_params,
7174 data_corruption(ut_params->op->sym->auth.aad.data);
7176 tag_corruption(ut_params->op->sym->auth.aad.data,
7177 reference->aad.len);
7179 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7181 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7182 TEST_ASSERT_EQUAL(ut_params->op->status,
7183 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7184 "authentication not failed");
7186 ut_params->obuf = ut_params->op->sym->m_src;
7187 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7193 test_authenticated_decryption_fail_when_corruption(
7194 struct crypto_testsuite_params *ts_params,
7195 struct crypto_unittest_params *ut_params,
7196 const struct test_crypto_vector *reference,
7197 unsigned int data_corrupted)
7201 uint8_t *ciphertext;
7203 /* Create session */
7204 retval = create_auth_cipher_session(ut_params,
7205 ts_params->valid_devs[0],
7207 RTE_CRYPTO_AUTH_OP_VERIFY,
7208 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7212 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7213 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7214 "Failed to allocate input buffer in mempool");
7216 /* clear mbuf payload */
7217 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7218 rte_pktmbuf_tailroom(ut_params->ibuf));
7220 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7221 reference->ciphertext.len);
7222 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7223 memcpy(ciphertext, reference->ciphertext.data,
7224 reference->ciphertext.len);
7226 /* Create operation */
7227 retval = create_cipher_auth_verify_operation(ts_params,
7235 data_corruption(ciphertext);
7237 tag_corruption(ciphertext, reference->ciphertext.len);
7239 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7242 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7243 TEST_ASSERT_EQUAL(ut_params->op->status,
7244 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7245 "authentication not failed");
7247 ut_params->obuf = ut_params->op->sym->m_src;
7248 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7254 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7255 const struct gcm_test_data *tdata,
7256 void *digest_mem, uint64_t digest_phys)
7258 struct crypto_testsuite_params *ts_params = &testsuite_params;
7259 struct crypto_unittest_params *ut_params = &unittest_params;
7261 const unsigned int auth_tag_len = tdata->auth_tag.len;
7262 const unsigned int iv_len = tdata->iv.len;
7263 const unsigned int aad_len = tdata->aad.len;
7265 /* Generate Crypto op data structure */
7266 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7267 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7268 TEST_ASSERT_NOT_NULL(ut_params->op,
7269 "Failed to allocate symmetric crypto operation struct");
7271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7273 sym_op->auth.digest.data = digest_mem;
7275 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7276 "no room to append digest");
7278 sym_op->auth.digest.phys_addr = digest_phys;
7279 sym_op->auth.digest.length = auth_tag_len;
7281 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7282 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7284 TEST_HEXDUMP(stdout, "digest:",
7285 sym_op->auth.digest.data,
7286 sym_op->auth.digest.length);
7289 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7290 uint8_t *, IV_OFFSET);
7292 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7294 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7295 ut_params->ibuf, aad_len);
7296 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7297 "no room to prepend aad");
7298 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7300 sym_op->auth.aad.length = aad_len;
7302 memset(sym_op->auth.aad.data, 0, aad_len);
7303 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7305 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7306 TEST_HEXDUMP(stdout, "aad:",
7307 sym_op->auth.aad.data, aad_len);
7309 sym_op->cipher.data.length = tdata->plaintext.len;
7310 sym_op->cipher.data.offset = aad_len;
7312 sym_op->auth.data.offset = aad_len;
7313 sym_op->auth.data.length = tdata->plaintext.len;
7318 #define SGL_MAX_NO 16
7321 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7322 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7324 struct crypto_testsuite_params *ts_params = &testsuite_params;
7325 struct crypto_unittest_params *ut_params = &unittest_params;
7326 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7329 int to_trn_tbl[SGL_MAX_NO];
7331 unsigned int trn_data = 0;
7332 uint8_t *plaintext, *ciphertext, *auth_tag;
7334 if (fragsz > tdata->plaintext.len)
7335 fragsz = tdata->plaintext.len;
7337 uint16_t plaintext_len = fragsz;
7338 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7340 if (fragsz_oop > tdata->plaintext.len)
7341 frag_size_oop = tdata->plaintext.len;
7344 void *digest_mem = NULL;
7346 uint32_t prepend_len = tdata->aad.len;
7348 if (tdata->plaintext.len % fragsz != 0) {
7349 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7352 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7357 * For out-op-place we need to alloc another mbuf
7360 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7361 rte_pktmbuf_append(ut_params->obuf,
7362 frag_size_oop + prepend_len);
7363 buf_oop = ut_params->obuf;
7366 /* Create GCM session */
7367 retval = create_gcm_session(ts_params->valid_devs[0],
7368 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7369 tdata->key.data, tdata->key.len,
7370 tdata->aad.len, tdata->auth_tag.len,
7372 RTE_CRYPTO_AUTH_OP_GENERATE);
7376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7378 /* clear mbuf payload */
7379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7380 rte_pktmbuf_tailroom(ut_params->ibuf));
7382 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7385 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7387 trn_data += plaintext_len;
7389 buf = ut_params->ibuf;
7392 * Loop until no more fragments
7395 while (trn_data < tdata->plaintext.len) {
7397 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7398 (tdata->plaintext.len - trn_data) : fragsz;
7400 to_trn_tbl[ecx++] = to_trn;
7402 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7405 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7406 rte_pktmbuf_tailroom(buf));
7409 if (oop && !fragsz_oop) {
7410 buf_last_oop = buf_oop->next =
7411 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7412 buf_oop = buf_oop->next;
7413 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7414 0, rte_pktmbuf_tailroom(buf_oop));
7415 rte_pktmbuf_append(buf_oop, to_trn);
7418 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7421 memcpy(plaintext, tdata->plaintext.data + trn_data,
7424 if (trn_data == tdata->plaintext.len) {
7427 digest_mem = rte_pktmbuf_append(buf_oop,
7428 tdata->auth_tag.len);
7430 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7431 tdata->auth_tag.len);
7435 uint64_t digest_phys = 0;
7437 ut_params->ibuf->nb_segs = segs;
7440 if (fragsz_oop && oop) {
7444 if (frag_size_oop == tdata->plaintext.len) {
7445 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7446 tdata->auth_tag.len);
7448 digest_phys = rte_pktmbuf_mtophys_offset(
7450 tdata->plaintext.len + prepend_len);
7453 trn_data = frag_size_oop;
7454 while (trn_data < tdata->plaintext.len) {
7457 (tdata->plaintext.len - trn_data <
7459 (tdata->plaintext.len - trn_data) :
7462 to_trn_tbl[ecx++] = to_trn;
7464 buf_last_oop = buf_oop->next =
7465 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7466 buf_oop = buf_oop->next;
7467 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7468 0, rte_pktmbuf_tailroom(buf_oop));
7469 rte_pktmbuf_append(buf_oop, to_trn);
7473 if (trn_data == tdata->plaintext.len) {
7474 digest_mem = rte_pktmbuf_append(buf_oop,
7475 tdata->auth_tag.len);
7479 ut_params->obuf->nb_segs = segs;
7483 * Place digest at the end of the last buffer
7486 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7487 if (oop && buf_last_oop)
7488 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7490 if (!digest_mem && !oop) {
7491 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7492 + tdata->auth_tag.len);
7493 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7494 tdata->plaintext.len);
7497 /* Create GCM opertaion */
7498 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7499 tdata, digest_mem, digest_phys);
7504 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7506 ut_params->op->sym->m_src = ut_params->ibuf;
7508 ut_params->op->sym->m_dst = ut_params->obuf;
7510 /* Process crypto operation */
7511 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7512 ut_params->op), "failed to process sym crypto op");
7514 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7515 "crypto op processing failed");
7518 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7519 uint8_t *, prepend_len);
7521 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7522 uint8_t *, prepend_len);
7526 fragsz = fragsz_oop;
7528 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7530 tdata->ciphertext.data,
7532 "GCM Ciphertext data not as expected");
7534 buf = ut_params->op->sym->m_src->next;
7536 buf = ut_params->op->sym->m_dst->next;
7538 unsigned int off = fragsz;
7542 ciphertext = rte_pktmbuf_mtod(buf,
7545 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7547 tdata->ciphertext.data + off,
7549 "GCM Ciphertext data not as expected");
7551 off += to_trn_tbl[ecx++];
7555 auth_tag = digest_mem;
7556 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7558 tdata->auth_tag.data,
7559 tdata->auth_tag.len,
7560 "GCM Generated auth tag not as expected");
7566 #define OUT_OF_PLACE 1
7569 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7571 return test_AES_GCM_authenticated_encryption_SGL(
7572 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7576 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7578 return test_AES_GCM_authenticated_encryption_SGL(
7579 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7583 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7585 return test_AES_GCM_authenticated_encryption_SGL(
7586 &gcm_test_case_8, OUT_OF_PLACE, 400,
7587 gcm_test_case_8.plaintext.len);
7591 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7594 return test_AES_GCM_authenticated_encryption_SGL(
7595 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7599 test_authentication_verify_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_fail_when_data_corruption(
7605 ts_params, ut_params, reference, 1);
7609 test_authentication_verify_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_fail_when_data_corruption(
7615 ts_params, ut_params, reference, 0);
7619 test_authentication_verify_GMAC_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_authentication_verify_GMAC_fail_when_corruption(
7625 ts_params, ut_params, reference, 1);
7629 test_authentication_verify_GMAC_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_authentication_verify_GMAC_fail_when_corruption(
7635 ts_params, ut_params, reference, 0);
7639 test_authenticated_decryption_fail_when_data_corrupted(
7640 struct crypto_testsuite_params *ts_params,
7641 struct crypto_unittest_params *ut_params,
7642 const struct test_crypto_vector *reference)
7644 return test_authenticated_decryption_fail_when_corruption(
7645 ts_params, ut_params, reference, 1);
7649 test_authenticated_decryption_fail_when_tag_corrupted(
7650 struct crypto_testsuite_params *ts_params,
7651 struct crypto_unittest_params *ut_params,
7652 const struct test_crypto_vector *reference)
7654 return test_authenticated_decryption_fail_when_corruption(
7655 ts_params, ut_params, reference, 0);
7659 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7661 return test_authentication_verify_fail_when_data_corrupted(
7662 &testsuite_params, &unittest_params,
7663 &hmac_sha1_test_crypto_vector);
7667 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7669 return test_authentication_verify_fail_when_tag_corrupted(
7670 &testsuite_params, &unittest_params,
7671 &hmac_sha1_test_crypto_vector);
7675 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7677 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7678 &testsuite_params, &unittest_params,
7679 &aes128_gmac_test_vector);
7683 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7685 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7686 &testsuite_params, &unittest_params,
7687 &aes128_gmac_test_vector);
7691 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7693 return test_authenticated_decryption_fail_when_data_corrupted(
7696 &aes128cbc_hmac_sha1_test_vector);
7700 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7702 return test_authenticated_decryption_fail_when_tag_corrupted(
7705 &aes128cbc_hmac_sha1_test_vector);
7708 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7710 /* global AESNI slave IDs for the scheduler test */
7711 uint8_t aesni_ids[2];
7714 test_scheduler_attach_slave_op(void)
7716 struct crypto_testsuite_params *ts_params = &testsuite_params;
7717 uint8_t sched_id = ts_params->valid_devs[0];
7718 uint32_t nb_devs, i, nb_devs_attached = 0;
7722 /* create 2 AESNI_MB if necessary */
7723 nb_devs = rte_cryptodev_count_devtype(
7724 RTE_CRYPTODEV_AESNI_MB_PMD);
7726 for (i = nb_devs; i < 2; i++) {
7727 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7728 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7730 ret = rte_vdev_init(vdev_name, NULL);
7732 TEST_ASSERT(ret == 0,
7733 "Failed to create instance %u of"
7735 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7739 /* attach 2 AESNI_MB cdevs */
7740 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7742 struct rte_cryptodev_info info;
7744 rte_cryptodev_info_get(i, &info);
7745 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7748 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7751 TEST_ASSERT(ret == 0,
7752 "Failed to attach device %u of pmd : %s", i,
7753 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7755 aesni_ids[nb_devs_attached] = (uint8_t)i;
7764 test_scheduler_detach_slave_op(void)
7766 struct crypto_testsuite_params *ts_params = &testsuite_params;
7767 uint8_t sched_id = ts_params->valid_devs[0];
7771 for (i = 0; i < 2; i++) {
7772 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7774 TEST_ASSERT(ret == 0,
7775 "Failed to detach device %u", aesni_ids[i]);
7782 test_scheduler_mode_op(void)
7784 struct crypto_testsuite_params *ts_params = &testsuite_params;
7785 uint8_t sched_id = ts_params->valid_devs[0];
7786 struct rte_cryptodev_scheduler_ops op = {0};
7787 struct rte_cryptodev_scheduler dummy_scheduler = {
7788 .description = "dummy scheduler to test mode",
7789 .name = "dummy scheduler",
7790 .mode = CDEV_SCHED_MODE_USERDEFINED,
7795 /* set user defined mode */
7796 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7798 TEST_ASSERT(ret == 0,
7799 "Failed to set cdev %u to user defined mode", sched_id);
7801 /* set round robin mode */
7802 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7803 CDEV_SCHED_MODE_ROUNDROBIN);
7804 TEST_ASSERT(ret == 0,
7805 "Failed to set cdev %u to round-robin mode", sched_id);
7806 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7807 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7813 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7814 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7815 .setup = testsuite_setup,
7816 .teardown = testsuite_teardown,
7817 .unit_test_cases = {
7818 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7819 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_AES_chain_scheduler_all),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_AES_cipheronly_scheduler_all),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_authonly_scheduler_all),
7826 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7827 TEST_CASES_END() /**< NULL terminate unit test array */
7831 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7833 static struct unit_test_suite cryptodev_qat_testsuite = {
7834 .suite_name = "Crypto QAT Unit Test Suite",
7835 .setup = testsuite_setup,
7836 .teardown = testsuite_teardown,
7837 .unit_test_cases = {
7838 TEST_CASE_ST(ut_setup, ut_teardown,
7839 test_device_configure_invalid_dev_id),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_device_configure_invalid_queue_pair_ids),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_queue_pair_descriptor_setup),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_multi_session),
7847 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_AES_cipheronly_qat_all),
7850 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_3DES_cipheronly_qat_all),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_DES_cipheronly_qat_all),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_AES_docsis_qat_all),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_DES_docsis_qat_all),
7859 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7861 /** AES GCM Authenticated Encryption */
7862 TEST_CASE_ST(ut_setup, ut_teardown,
7863 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7864 TEST_CASE_ST(ut_setup, ut_teardown,
7865 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7868 TEST_CASE_ST(ut_setup, ut_teardown,
7869 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7870 TEST_CASE_ST(ut_setup, ut_teardown,
7871 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7876 TEST_CASE_ST(ut_setup, ut_teardown,
7877 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7878 TEST_CASE_ST(ut_setup, ut_teardown,
7879 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7883 /** AES GCM Authenticated Decryption */
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7892 TEST_CASE_ST(ut_setup, ut_teardown,
7893 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7899 /** AES GMAC Authentication */
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_AES_GMAC_authentication_test_case_1),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_AES_GMAC_authentication_verify_test_case_1),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_AES_GMAC_authentication_test_case_2),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_AES_GMAC_authentication_verify_test_case_2),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_AES_GMAC_authentication_test_case_3),
7910 TEST_CASE_ST(ut_setup, ut_teardown,
7911 test_AES_GMAC_authentication_verify_test_case_3),
7913 /** SNOW 3G encrypt only (UEA2) */
7914 TEST_CASE_ST(ut_setup, ut_teardown,
7915 test_snow3g_encryption_test_case_1),
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 test_snow3g_encryption_test_case_2),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 test_snow3g_encryption_test_case_3),
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 test_snow3g_encryption_test_case_4),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_snow3g_encryption_test_case_5),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_snow3g_encryption_test_case_1_oop),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_snow3g_decryption_test_case_1_oop),
7930 /** SNOW 3G decrypt only (UEA2) */
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_snow3g_decryption_test_case_1),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_snow3g_decryption_test_case_2),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_snow3g_decryption_test_case_3),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_snow3g_decryption_test_case_4),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_snow3g_decryption_test_case_5),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_snow3g_hash_generate_test_case_1),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_snow3g_hash_generate_test_case_2),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_snow3g_hash_generate_test_case_3),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_snow3g_hash_verify_test_case_1),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_snow3g_hash_verify_test_case_2),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_snow3g_hash_verify_test_case_3),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_snow3g_cipher_auth_test_case_1),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_snow3g_auth_cipher_test_case_1),
7958 /** ZUC encrypt only (EEA3) */
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_zuc_encryption_test_case_1),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_zuc_encryption_test_case_2),
7963 TEST_CASE_ST(ut_setup, ut_teardown,
7964 test_zuc_encryption_test_case_3),
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_zuc_encryption_test_case_4),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_zuc_encryption_test_case_5),
7970 /** ZUC authenticate (EIA3) */
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_zuc_hash_generate_test_case_6),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_zuc_hash_generate_test_case_7),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_zuc_hash_generate_test_case_8),
7978 /** ZUC alg-chain (EEA3/EIA3) */
7979 TEST_CASE_ST(ut_setup, ut_teardown,
7980 test_zuc_cipher_auth_test_case_1),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_zuc_cipher_auth_test_case_2),
7984 /** HMAC_MD5 Authentication */
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_MD5_HMAC_generate_case_1),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_MD5_HMAC_verify_case_1),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_MD5_HMAC_generate_case_2),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_MD5_HMAC_verify_case_2),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_null_auth_only_operation),
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_null_cipher_only_operation),
7999 TEST_CASE_ST(ut_setup, ut_teardown,
8000 test_null_cipher_auth_operation),
8001 TEST_CASE_ST(ut_setup, ut_teardown,
8002 test_null_auth_cipher_operation),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_kasumi_hash_generate_test_case_6),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_kasumi_encryption_test_case_1),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_kasumi_encryption_test_case_3),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_kasumi_auth_cipher_test_case_1),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_kasumi_cipher_auth_test_case_1),
8017 /** Negative tests */
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 authentication_verify_AES128_GMAC_fail_data_corrupt),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8031 TEST_CASES_END() /**< NULL terminate unit test array */
8035 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8036 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8037 .setup = testsuite_setup,
8038 .teardown = testsuite_teardown,
8039 .unit_test_cases = {
8040 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8041 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8042 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8043 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8045 TEST_CASES_END() /**< NULL terminate unit test array */
8049 static struct unit_test_suite cryptodev_openssl_testsuite = {
8050 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8051 .setup = testsuite_setup,
8052 .teardown = testsuite_teardown,
8053 .unit_test_cases = {
8054 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_multi_session_random_usage),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_AES_chain_openssl_all),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_AES_cipheronly_openssl_all),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_3DES_chain_openssl_all),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_3DES_cipheronly_openssl_all),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_DES_docsis_openssl_all),
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 test_authonly_openssl_all),
8070 /** AES GCM Authenticated Encryption */
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8081 TEST_CASE_ST(ut_setup, ut_teardown,
8082 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8086 /** AES GCM Authenticated Decryption */
8087 TEST_CASE_ST(ut_setup, ut_teardown,
8088 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8099 TEST_CASE_ST(ut_setup, ut_teardown,
8100 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8102 /** AES GMAC Authentication */
8103 TEST_CASE_ST(ut_setup, ut_teardown,
8104 test_AES_GMAC_authentication_test_case_1),
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 test_AES_GMAC_authentication_verify_test_case_1),
8107 TEST_CASE_ST(ut_setup, ut_teardown,
8108 test_AES_GMAC_authentication_test_case_2),
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 test_AES_GMAC_authentication_verify_test_case_2),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 test_AES_GMAC_authentication_test_case_3),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_AES_GMAC_authentication_verify_test_case_3),
8115 TEST_CASE_ST(ut_setup, ut_teardown,
8116 test_AES_GMAC_authentication_test_case_4),
8117 TEST_CASE_ST(ut_setup, ut_teardown,
8118 test_AES_GMAC_authentication_verify_test_case_4),
8120 /** Scatter-Gather */
8121 TEST_CASE_ST(ut_setup, ut_teardown,
8122 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8124 /** Negative tests */
8125 TEST_CASE_ST(ut_setup, ut_teardown,
8126 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8127 TEST_CASE_ST(ut_setup, ut_teardown,
8128 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 authentication_verify_AES128_GMAC_fail_data_corrupt),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8135 TEST_CASE_ST(ut_setup, ut_teardown,
8136 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8138 TEST_CASES_END() /**< NULL terminate unit test array */
8142 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8143 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8144 .setup = testsuite_setup,
8145 .teardown = testsuite_teardown,
8146 .unit_test_cases = {
8147 /** AES GCM Authenticated Encryption */
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8163 /** AES GCM Authenticated Decryption */
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8174 TEST_CASE_ST(ut_setup, ut_teardown,
8175 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8179 /** AES GCM Authenticated Encryption 256 bits key */
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8190 TEST_CASE_ST(ut_setup, ut_teardown,
8191 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8192 TEST_CASE_ST(ut_setup, ut_teardown,
8193 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8195 /** AES GCM Authenticated Decryption 256 bits key */
8196 TEST_CASE_ST(ut_setup, ut_teardown,
8197 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8202 TEST_CASE_ST(ut_setup, ut_teardown,
8203 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8208 TEST_CASE_ST(ut_setup, ut_teardown,
8209 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8211 /** AES GCM Authenticated Encryption big aad size */
8212 TEST_CASE_ST(ut_setup, ut_teardown,
8213 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8214 TEST_CASE_ST(ut_setup, ut_teardown,
8215 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8217 /** AES GCM Authenticated Decryption big aad size */
8218 TEST_CASE_ST(ut_setup, ut_teardown,
8219 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8220 TEST_CASE_ST(ut_setup, ut_teardown,
8221 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8223 /** AES GMAC Authentication */
8224 TEST_CASE_ST(ut_setup, ut_teardown,
8225 test_AES_GMAC_authentication_test_case_1),
8226 TEST_CASE_ST(ut_setup, ut_teardown,
8227 test_AES_GMAC_authentication_verify_test_case_1),
8228 TEST_CASE_ST(ut_setup, ut_teardown,
8229 test_AES_GMAC_authentication_test_case_3),
8230 TEST_CASE_ST(ut_setup, ut_teardown,
8231 test_AES_GMAC_authentication_verify_test_case_3),
8232 TEST_CASE_ST(ut_setup, ut_teardown,
8233 test_AES_GMAC_authentication_test_case_4),
8234 TEST_CASE_ST(ut_setup, ut_teardown,
8235 test_AES_GMAC_authentication_verify_test_case_4),
8237 /** Negative tests */
8238 TEST_CASE_ST(ut_setup, ut_teardown,
8239 authentication_verify_AES128_GMAC_fail_data_corrupt),
8240 TEST_CASE_ST(ut_setup, ut_teardown,
8241 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8243 /** Out of place tests */
8244 TEST_CASE_ST(ut_setup, ut_teardown,
8245 test_mb_AES_GCM_authenticated_encryption_oop),
8246 TEST_CASE_ST(ut_setup, ut_teardown,
8247 test_mb_AES_GCM_authenticated_decryption_oop),
8249 /** Session-less tests */
8250 TEST_CASE_ST(ut_setup, ut_teardown,
8251 test_mb_AES_GCM_authenticated_encryption_sessionless),
8252 TEST_CASE_ST(ut_setup, ut_teardown,
8253 test_mb_AES_GCM_authenticated_decryption_sessionless),
8255 /** Scatter-Gather */
8256 TEST_CASE_ST(ut_setup, ut_teardown,
8257 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8259 TEST_CASES_END() /**< NULL terminate unit test array */
8263 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8264 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8265 .setup = testsuite_setup,
8266 .teardown = testsuite_teardown,
8267 .unit_test_cases = {
8268 /** KASUMI encrypt only (UEA1) */
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 test_kasumi_encryption_test_case_1),
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_kasumi_encryption_test_case_1_sgl),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_kasumi_encryption_test_case_2),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_kasumi_encryption_test_case_3),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_kasumi_encryption_test_case_4),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_kasumi_encryption_test_case_5),
8281 /** KASUMI decrypt only (UEA1) */
8282 TEST_CASE_ST(ut_setup, ut_teardown,
8283 test_kasumi_decryption_test_case_1),
8284 TEST_CASE_ST(ut_setup, ut_teardown,
8285 test_kasumi_decryption_test_case_2),
8286 TEST_CASE_ST(ut_setup, ut_teardown,
8287 test_kasumi_decryption_test_case_3),
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_kasumi_decryption_test_case_4),
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_kasumi_decryption_test_case_5),
8293 TEST_CASE_ST(ut_setup, ut_teardown,
8294 test_kasumi_encryption_test_case_1_oop),
8295 TEST_CASE_ST(ut_setup, ut_teardown,
8296 test_kasumi_encryption_test_case_1_oop_sgl),
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_kasumi_decryption_test_case_1_oop),
8302 /** KASUMI hash only (UIA1) */
8303 TEST_CASE_ST(ut_setup, ut_teardown,
8304 test_kasumi_hash_generate_test_case_1),
8305 TEST_CASE_ST(ut_setup, ut_teardown,
8306 test_kasumi_hash_generate_test_case_2),
8307 TEST_CASE_ST(ut_setup, ut_teardown,
8308 test_kasumi_hash_generate_test_case_3),
8309 TEST_CASE_ST(ut_setup, ut_teardown,
8310 test_kasumi_hash_generate_test_case_4),
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_kasumi_hash_generate_test_case_5),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_kasumi_hash_generate_test_case_6),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_kasumi_hash_verify_test_case_1),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_kasumi_hash_verify_test_case_2),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_kasumi_hash_verify_test_case_3),
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 test_kasumi_hash_verify_test_case_4),
8323 TEST_CASE_ST(ut_setup, ut_teardown,
8324 test_kasumi_hash_verify_test_case_5),
8325 TEST_CASE_ST(ut_setup, ut_teardown,
8326 test_kasumi_auth_cipher_test_case_1),
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 test_kasumi_cipher_auth_test_case_1),
8329 TEST_CASES_END() /**< NULL terminate unit test array */
8332 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8333 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8334 .setup = testsuite_setup,
8335 .teardown = testsuite_teardown,
8336 .unit_test_cases = {
8337 /** SNOW 3G encrypt only (UEA2) */
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_snow3g_encryption_test_case_1),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_snow3g_encryption_test_case_2),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_snow3g_encryption_test_case_3),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_snow3g_encryption_test_case_4),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_snow3g_encryption_test_case_5),
8349 TEST_CASE_ST(ut_setup, ut_teardown,
8350 test_snow3g_encryption_test_case_1_oop),
8351 TEST_CASE_ST(ut_setup, ut_teardown,
8352 test_snow3g_encryption_test_case_1_oop_sgl),
8353 TEST_CASE_ST(ut_setup, ut_teardown,
8354 test_snow3g_decryption_test_case_1_oop),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_snow3g_encryption_test_case_1_offset_oop),
8359 /** SNOW 3G decrypt only (UEA2) */
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_snow3g_decryption_test_case_1),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_snow3g_decryption_test_case_2),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_snow3g_decryption_test_case_3),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_snow3g_decryption_test_case_4),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_snow3g_decryption_test_case_5),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_snow3g_hash_generate_test_case_1),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_snow3g_hash_generate_test_case_2),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 test_snow3g_hash_generate_test_case_3),
8376 /* Tests with buffers which length is not byte-aligned */
8377 TEST_CASE_ST(ut_setup, ut_teardown,
8378 test_snow3g_hash_generate_test_case_4),
8379 TEST_CASE_ST(ut_setup, ut_teardown,
8380 test_snow3g_hash_generate_test_case_5),
8381 TEST_CASE_ST(ut_setup, ut_teardown,
8382 test_snow3g_hash_generate_test_case_6),
8383 TEST_CASE_ST(ut_setup, ut_teardown,
8384 test_snow3g_hash_verify_test_case_1),
8385 TEST_CASE_ST(ut_setup, ut_teardown,
8386 test_snow3g_hash_verify_test_case_2),
8387 TEST_CASE_ST(ut_setup, ut_teardown,
8388 test_snow3g_hash_verify_test_case_3),
8389 /* Tests with buffers which length is not byte-aligned */
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_snow3g_hash_verify_test_case_4),
8392 TEST_CASE_ST(ut_setup, ut_teardown,
8393 test_snow3g_hash_verify_test_case_5),
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 test_snow3g_hash_verify_test_case_6),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 test_snow3g_cipher_auth_test_case_1),
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_snow3g_auth_cipher_test_case_1),
8401 TEST_CASES_END() /**< NULL terminate unit test array */
8405 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8406 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8407 .setup = testsuite_setup,
8408 .teardown = testsuite_teardown,
8409 .unit_test_cases = {
8410 /** ZUC encrypt only (EEA3) */
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_zuc_encryption_test_case_1),
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 test_zuc_encryption_test_case_2),
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_zuc_encryption_test_case_3),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_zuc_encryption_test_case_4),
8419 TEST_CASE_ST(ut_setup, ut_teardown,
8420 test_zuc_encryption_test_case_5),
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_zuc_hash_generate_test_case_1),
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_zuc_hash_generate_test_case_2),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_zuc_hash_generate_test_case_3),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_zuc_hash_generate_test_case_4),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_zuc_hash_generate_test_case_5),
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_zuc_encryption_test_case_6_sgl),
8433 TEST_CASES_END() /**< NULL terminate unit test array */
8437 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8438 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8439 .setup = testsuite_setup,
8440 .teardown = testsuite_teardown,
8441 .unit_test_cases = {
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_device_configure_invalid_dev_id),
8444 TEST_CASE_ST(ut_setup, ut_teardown,
8445 test_multi_session),
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_AES_chain_dpaa2_sec_all),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_3DES_chain_dpaa2_sec_all),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_AES_cipheronly_dpaa2_sec_all),
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_3DES_cipheronly_dpaa2_sec_all),
8456 /** HMAC_MD5 Authentication */
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_MD5_HMAC_generate_case_1),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_MD5_HMAC_verify_case_1),
8461 TEST_CASE_ST(ut_setup, ut_teardown,
8462 test_MD5_HMAC_generate_case_2),
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_MD5_HMAC_verify_case_2),
8466 TEST_CASES_END() /**< NULL terminate unit test array */
8470 static struct unit_test_suite cryptodev_null_testsuite = {
8471 .suite_name = "Crypto Device NULL Unit Test Suite",
8472 .setup = testsuite_setup,
8473 .teardown = testsuite_teardown,
8474 .unit_test_cases = {
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_null_auth_only_operation),
8477 TEST_CASE_ST(ut_setup, ut_teardown,
8478 test_null_cipher_only_operation),
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_null_cipher_auth_operation),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_null_auth_cipher_operation),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_null_invalid_operation),
8485 TEST_CASE_ST(ut_setup, ut_teardown,
8486 test_null_burst_operation),
8488 TEST_CASES_END() /**< NULL terminate unit test array */
8492 static struct unit_test_suite cryptodev_armv8_testsuite = {
8493 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8494 .setup = testsuite_setup,
8495 .teardown = testsuite_teardown,
8496 .unit_test_cases = {
8497 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8499 /** Negative tests */
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8505 TEST_CASES_END() /**< NULL terminate unit test array */
8510 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8512 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8513 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8517 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8519 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8521 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8525 test_cryptodev_openssl(void)
8527 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8529 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8533 test_cryptodev_aesni_gcm(void)
8535 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8537 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8541 test_cryptodev_null(void)
8543 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8545 return unit_test_suite_runner(&cryptodev_null_testsuite);
8549 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8551 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8553 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8557 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8559 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8561 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8565 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8567 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8569 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8573 test_cryptodev_armv8(void)
8575 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8577 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8580 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8583 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8585 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8586 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8589 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8594 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8596 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8597 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8600 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8601 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8602 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8603 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8604 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8605 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8606 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8607 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8608 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8609 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);