4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
81 struct rte_cryptodev_sym_session *sess;
83 struct rte_crypto_op *op;
85 struct rte_mbuf *obuf, *ibuf;
90 #define ALIGN_POW2_ROUNDUP(num, align) \
91 (((num) + (align) - 1) & ~((align) - 1))
94 * Forward declarations.
97 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
98 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
102 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
103 struct crypto_unittest_params *ut_params,
104 struct crypto_testsuite_params *ts_param,
105 const uint8_t *cipher,
106 const uint8_t *digest,
109 static struct rte_mbuf *
110 setup_test_string(struct rte_mempool *mpool,
111 const char *string, size_t len, uint8_t blocksize)
113 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
114 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
116 memset(m->buf_addr, 0, m->buf_len);
118 char *dst = rte_pktmbuf_append(m, t_len);
125 rte_memcpy(dst, string, t_len);
127 memset(dst, 0, t_len);
133 /* Get number of bytes in X bits (rounding up) */
135 ceil_byte_length(uint32_t num_bits)
138 return ((num_bits >> 3) + 1);
140 return (num_bits >> 3);
143 static struct rte_crypto_op *
144 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
146 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
147 printf("Error sending packet for encryption");
153 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
159 static struct crypto_testsuite_params testsuite_params = { NULL };
160 static struct crypto_unittest_params unittest_params;
163 testsuite_setup(void)
165 struct crypto_testsuite_params *ts_params = &testsuite_params;
166 struct rte_cryptodev_info info;
167 uint32_t i = 0, nb_devs, dev_id;
171 memset(ts_params, 0, sizeof(*ts_params));
173 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
174 if (ts_params->mbuf_pool == NULL) {
175 /* Not already created so create */
176 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
178 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
180 if (ts_params->mbuf_pool == NULL) {
181 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 ts_params->large_mbuf_pool = rte_mempool_lookup(
187 "CRYPTO_LARGE_MBUFPOOL");
188 if (ts_params->large_mbuf_pool == NULL) {
189 /* Not already created so create */
190 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
191 "CRYPTO_LARGE_MBUFPOOL",
194 if (ts_params->large_mbuf_pool == NULL) {
196 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 ts_params->op_mpool = rte_crypto_op_pool_create(
202 "MBUF_CRYPTO_SYM_OP_POOL",
203 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
204 NUM_MBUFS, MBUF_CACHE_SIZE,
206 sizeof(struct rte_crypto_sym_xform) +
209 if (ts_params->op_mpool == NULL) {
210 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
214 /* Create an AESNI MB device if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_MB
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_MB_PMD);
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
236 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(
242 RTE_CRYPTODEV_AESNI_GCM_PMD);
244 TEST_ASSERT_SUCCESS(rte_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
246 "Failed to create instance of"
248 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
252 /* Create a SNOW 3G device if required */
253 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
254 #ifndef RTE_LIBRTE_PMD_SNOW3G
255 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
256 " enabled in config file to run this testsuite.\n");
259 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
261 TEST_ASSERT_SUCCESS(rte_vdev_init(
262 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
263 "Failed to create instance of"
265 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create a KASUMI device if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 TEST_ASSERT_SUCCESS(rte_vdev_init(
279 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
280 "Failed to create instance of"
282 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
286 /* Create a ZUC device if required */
287 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
288 #ifndef RTE_LIBRTE_PMD_ZUC
289 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
290 " enabled in config file to run this testsuite.\n");
293 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
295 TEST_ASSERT_SUCCESS(rte_vdev_init(
296 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
297 "Failed to create instance of"
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
303 /* Create a NULL device if required */
304 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
305 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
306 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
307 " enabled in config file to run this testsuite.\n");
310 nb_devs = rte_cryptodev_count_devtype(
311 RTE_CRYPTODEV_NULL_PMD);
314 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
316 TEST_ASSERT(ret == 0,
317 "Failed to create instance of"
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
323 /* Create an OPENSSL device if required */
324 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
325 #ifndef RTE_LIBRTE_PMD_OPENSSL
326 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
327 " enabled in config file to run this testsuite.\n");
330 nb_devs = rte_cryptodev_count_devtype(
331 RTE_CRYPTODEV_OPENSSL_PMD);
334 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
343 /* Create a ARMv8 device if required */
344 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
345 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
346 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
347 " enabled in config file to run this testsuite.\n");
350 nb_devs = rte_cryptodev_count_devtype(
351 RTE_CRYPTODEV_ARMV8_PMD);
354 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
363 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
364 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
366 #ifndef RTE_LIBRTE_PMD_AESNI_MB
367 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
368 " enabled in config file to run this testsuite.\n");
371 nb_devs = rte_cryptodev_count_devtype(
372 RTE_CRYPTODEV_SCHEDULER_PMD);
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
378 TEST_ASSERT(ret == 0,
379 "Failed to create instance %u of"
381 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
384 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
386 #ifndef RTE_LIBRTE_PMD_QAT
387 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
388 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
389 "in config file to run this testsuite.\n");
394 nb_devs = rte_cryptodev_count();
396 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
400 /* Create list of valid crypto devs */
401 for (i = 0; i < nb_devs; i++) {
402 rte_cryptodev_info_get(i, &info);
403 if (info.dev_type == gbl_cryptodev_type)
404 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
407 if (ts_params->valid_dev_count < 1)
410 /* Set up all the qps on the first of the valid devices found */
412 dev_id = ts_params->valid_devs[0];
414 rte_cryptodev_info_get(dev_id, &info);
416 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
417 ts_params->conf.socket_id = SOCKET_ID_ANY;
418 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
422 "Failed to configure cryptodev %u with %u qps",
423 dev_id, ts_params->conf.nb_queue_pairs);
425 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
427 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
428 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
429 dev_id, qp_id, &ts_params->qp_conf,
430 rte_cryptodev_socket_id(dev_id)),
431 "Failed to setup queue pair %u on cryptodev %u",
439 testsuite_teardown(void)
441 struct crypto_testsuite_params *ts_params = &testsuite_params;
443 if (ts_params->mbuf_pool != NULL) {
444 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
445 rte_mempool_avail_count(ts_params->mbuf_pool));
448 if (ts_params->op_mpool != NULL) {
449 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
450 rte_mempool_avail_count(ts_params->op_mpool));
458 struct crypto_testsuite_params *ts_params = &testsuite_params;
459 struct crypto_unittest_params *ut_params = &unittest_params;
463 /* Clear unit test parameters before running test */
464 memset(ut_params, 0, sizeof(*ut_params));
466 /* Reconfigure device to default parameters */
467 ts_params->conf.socket_id = SOCKET_ID_ANY;
468 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
470 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
475 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 ts_params->valid_devs[0], qp_id,
479 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
480 "Failed to setup queue pair %u on cryptodev %u",
481 qp_id, ts_params->valid_devs[0]);
485 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
487 /* Start the device */
488 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
489 "Failed to start cryptodev %u",
490 ts_params->valid_devs[0]);
498 struct crypto_testsuite_params *ts_params = &testsuite_params;
499 struct crypto_unittest_params *ut_params = &unittest_params;
500 struct rte_cryptodev_stats stats;
502 /* free crypto session structure */
503 if (ut_params->sess) {
504 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
506 ut_params->sess = NULL;
509 /* free crypto operation structure */
511 rte_crypto_op_free(ut_params->op);
514 * free mbuf - both obuf and ibuf are usually the same,
515 * so check if they point at the same address is necessary,
516 * to avoid freeing the mbuf twice.
518 if (ut_params->obuf) {
519 rte_pktmbuf_free(ut_params->obuf);
520 if (ut_params->ibuf == ut_params->obuf)
524 if (ut_params->ibuf) {
525 rte_pktmbuf_free(ut_params->ibuf);
529 if (ts_params->mbuf_pool != NULL)
530 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
531 rte_mempool_avail_count(ts_params->mbuf_pool));
533 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
535 /* Stop the device */
536 rte_cryptodev_stop(ts_params->valid_devs[0]);
540 test_device_configure_invalid_dev_id(void)
542 struct crypto_testsuite_params *ts_params = &testsuite_params;
543 uint16_t dev_id, num_devs = 0;
545 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
546 "Need at least %d devices for test", 1);
548 /* valid dev_id values */
549 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
551 /* Stop the device in case it's started so it can be configured */
552 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
554 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
558 /* invalid dev_id values */
561 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
562 "Failed test for rte_cryptodev_configure: "
563 "invalid dev_num %u", dev_id);
567 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
568 "Failed test for rte_cryptodev_configure:"
569 "invalid dev_num %u", dev_id);
575 test_device_configure_invalid_queue_pair_ids(void)
577 struct crypto_testsuite_params *ts_params = &testsuite_params;
578 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
580 /* Stop the device in case it's started so it can be configured */
581 rte_cryptodev_stop(ts_params->valid_devs[0]);
583 /* valid - one queue pairs */
584 ts_params->conf.nb_queue_pairs = 1;
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
588 "Failed to configure cryptodev: dev_id %u, qp_id %u",
589 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
592 /* valid - max value queue pairs */
593 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
595 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed to configure cryptodev: dev_id %u, qp_id %u",
598 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
601 /* invalid - zero queue pairs */
602 ts_params->conf.nb_queue_pairs = 0;
604 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed test for rte_cryptodev_configure, dev_id %u,"
608 ts_params->valid_devs[0],
609 ts_params->conf.nb_queue_pairs);
612 /* invalid - max value supported by field queue pairs */
613 ts_params->conf.nb_queue_pairs = UINT16_MAX;
615 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
617 "Failed test for rte_cryptodev_configure, dev_id %u,"
619 ts_params->valid_devs[0],
620 ts_params->conf.nb_queue_pairs);
623 /* invalid - max value + 1 queue pairs */
624 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
626 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
628 "Failed test for rte_cryptodev_configure, dev_id %u,"
630 ts_params->valid_devs[0],
631 ts_params->conf.nb_queue_pairs);
633 /* revert to original testsuite value */
634 ts_params->conf.nb_queue_pairs = orig_nb_qps;
640 test_queue_pair_descriptor_setup(void)
642 struct crypto_testsuite_params *ts_params = &testsuite_params;
643 struct rte_cryptodev_info dev_info;
644 struct rte_cryptodev_qp_conf qp_conf = {
645 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
650 /* Stop the device in case it's started so it can be configured */
651 rte_cryptodev_stop(ts_params->valid_devs[0]);
654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
656 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
658 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
659 &ts_params->conf), "Failed to configure cryptodev %u",
660 ts_params->valid_devs[0]);
664 * Test various ring sizes on this device. memzones can't be
665 * freed so are re-used if ring is released and re-created.
667 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
669 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
670 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
671 ts_params->valid_devs[0], qp_id, &qp_conf,
672 rte_cryptodev_socket_id(
673 ts_params->valid_devs[0])),
675 "rte_cryptodev_queue_pair_setup: num_inflights "
676 "%u on qp %u on cryptodev %u",
677 qp_conf.nb_descriptors, qp_id,
678 ts_params->valid_devs[0]);
681 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
683 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
684 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0], qp_id, &qp_conf,
686 rte_cryptodev_socket_id(
687 ts_params->valid_devs[0])),
689 " rte_cryptodev_queue_pair_setup: num_inflights"
690 " %u on qp %u on cryptodev %u",
691 qp_conf.nb_descriptors, qp_id,
692 ts_params->valid_devs[0]);
695 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
697 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
698 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
699 ts_params->valid_devs[0], qp_id, &qp_conf,
700 rte_cryptodev_socket_id(
701 ts_params->valid_devs[0])),
703 "rte_cryptodev_queue_pair_setup: num_inflights"
704 " %u on qp %u on cryptodev %u",
705 qp_conf.nb_descriptors, qp_id,
706 ts_params->valid_devs[0]);
709 /* invalid number of descriptors - max supported + 2 */
710 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0])),
717 "Unexpectedly passed test for "
718 "rte_cryptodev_queue_pair_setup:"
719 "num_inflights %u on qp %u on cryptodev %u",
720 qp_conf.nb_descriptors, qp_id,
721 ts_params->valid_devs[0]);
724 /* invalid number of descriptors - max value of parameter */
725 qp_conf.nb_descriptors = UINT32_MAX-1;
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0])),
732 "Unexpectedly passed test for "
733 "rte_cryptodev_queue_pair_setup:"
734 "num_inflights %u on qp %u on cryptodev %u",
735 qp_conf.nb_descriptors, qp_id,
736 ts_params->valid_devs[0]);
739 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
741 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
742 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0], qp_id, &qp_conf,
744 rte_cryptodev_socket_id(
745 ts_params->valid_devs[0])),
747 " rte_cryptodev_queue_pair_setup:"
748 "num_inflights %u on qp %u on cryptodev %u",
749 qp_conf.nb_descriptors, qp_id,
750 ts_params->valid_devs[0]);
753 /* invalid number of descriptors - max supported + 1 */
754 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
756 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
757 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
758 ts_params->valid_devs[0], qp_id, &qp_conf,
759 rte_cryptodev_socket_id(
760 ts_params->valid_devs[0])),
761 "Unexpectedly passed test for "
762 "rte_cryptodev_queue_pair_setup:"
763 "num_inflights %u on qp %u on cryptodev %u",
764 qp_conf.nb_descriptors, qp_id,
765 ts_params->valid_devs[0]);
768 /* test invalid queue pair id */
769 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
771 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
773 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
774 ts_params->valid_devs[0],
776 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
777 "Failed test for rte_cryptodev_queue_pair_setup:"
778 "invalid qp %u on cryptodev %u",
779 qp_id, ts_params->valid_devs[0]);
781 qp_id = 0xffff; /*invalid*/
783 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0],
786 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
787 "Failed test for rte_cryptodev_queue_pair_setup:"
788 "invalid qp %u on cryptodev %u",
789 qp_id, ts_params->valid_devs[0]);
794 /* ***** Plaintext data for tests ***** */
796 const char catch_22_quote_1[] =
797 "There was only one catch and that was Catch-22, which "
798 "specified that a concern for one's safety in the face of "
799 "dangers that were real and immediate was the process of a "
800 "rational mind. Orr was crazy and could be grounded. All he "
801 "had to do was ask; and as soon as he did, he would no longer "
802 "be crazy and would have to fly more missions. Orr would be "
803 "crazy to fly more missions and sane if he didn't, but if he "
804 "was sane he had to fly them. If he flew them he was crazy "
805 "and didn't have to; but if he didn't want to he was sane and "
806 "had to. Yossarian was moved very deeply by the absolute "
807 "simplicity of this clause of Catch-22 and let out a "
808 "respectful whistle. \"That's some catch, that Catch-22\", he "
809 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
811 const char catch_22_quote[] =
812 "What a lousy earth! He wondered how many people were "
813 "destitute that same night even in his own prosperous country, "
814 "how many homes were shanties, how many husbands were drunk "
815 "and wives socked, and how many children were bullied, abused, "
816 "or abandoned. How many families hungered for food they could "
817 "not afford to buy? How many hearts were broken? How many "
818 "suicides would take place that same night, how many people "
819 "would go insane? How many cockroaches and landlords would "
820 "triumph? How many winners were losers, successes failures, "
821 "and rich men poor men? How many wise guys were stupid? How "
822 "many happy endings were unhappy endings? How many honest men "
823 "were liars, brave men cowards, loyal men traitors, how many "
824 "sainted men were corrupt, how many people in positions of "
825 "trust had sold their souls to bodyguards, how many had never "
826 "had souls? How many straight-and-narrow paths were crooked "
827 "paths? How many best families were worst families and how "
828 "many good people were bad people? When you added them all up "
829 "and then subtracted, you might be left with only the children, "
830 "and perhaps with Albert Einstein and an old violinist or "
831 "sculptor somewhere.";
833 #define QUOTE_480_BYTES (480)
834 #define QUOTE_512_BYTES (512)
835 #define QUOTE_768_BYTES (768)
836 #define QUOTE_1024_BYTES (1024)
840 /* ***** SHA1 Hash Tests ***** */
842 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
844 static uint8_t hmac_sha1_key[] = {
845 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
846 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
847 0xDE, 0xF4, 0xDE, 0xAD };
849 /* ***** SHA224 Hash Tests ***** */
851 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
854 /* ***** AES-CBC Cipher Tests ***** */
856 #define CIPHER_KEY_LENGTH_AES_CBC (16)
857 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
859 static uint8_t aes_cbc_key[] = {
860 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
861 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
863 static uint8_t aes_cbc_iv[] = {
864 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
865 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
868 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
870 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
871 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
872 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
873 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
874 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
875 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
876 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
877 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
878 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
879 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
880 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
881 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
882 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
883 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
884 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
885 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
886 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
887 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
888 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
889 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
890 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
891 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
892 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
893 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
894 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
895 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
896 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
897 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
898 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
899 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
900 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
901 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
902 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
903 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
904 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
905 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
906 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
907 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
908 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
909 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
910 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
911 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
912 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
913 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
914 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
915 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
916 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
917 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
918 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
919 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
920 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
921 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
922 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
923 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
924 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
925 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
926 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
927 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
928 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
929 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
930 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
931 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
932 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
933 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
934 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
937 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
938 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
939 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
940 0x18, 0x8c, 0x1d, 0x32
944 /* Multisession Vector context Test */
946 static uint8_t ms_aes_cbc_key0[] = {
947 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
951 static uint8_t ms_aes_cbc_iv0[] = {
952 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
953 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
956 static const uint8_t ms_aes_cbc_cipher0[] = {
957 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
958 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
959 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
960 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
961 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
962 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
963 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
964 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
965 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
966 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
967 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
968 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
969 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
970 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
971 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
972 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
973 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
974 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
975 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
976 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
977 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
978 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
979 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
980 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
981 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
982 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
983 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
984 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
985 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
986 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
987 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
988 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
989 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
990 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
991 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
992 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
993 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
994 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
995 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
996 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
997 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
998 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
999 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1000 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1001 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1002 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1003 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1004 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1005 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1006 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1007 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1008 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1009 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1010 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1011 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1012 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1013 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1014 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1015 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1016 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1017 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1018 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1019 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1020 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1024 static uint8_t ms_hmac_key0[] = {
1025 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1026 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1027 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1028 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1029 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1030 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1031 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1032 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1035 static const uint8_t ms_hmac_digest0[] = {
1036 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1037 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1038 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1039 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1040 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1041 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1042 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1043 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1047 /* Begin session 1 */
1049 static uint8_t ms_aes_cbc_key1[] = {
1050 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static uint8_t ms_aes_cbc_iv1[] = {
1055 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1056 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1059 static const uint8_t ms_aes_cbc_cipher1[] = {
1060 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1061 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1062 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1063 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1064 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1065 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1066 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1067 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1068 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1069 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1070 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1071 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1072 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1073 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1074 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1075 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1076 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1077 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1078 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1079 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1080 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1081 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1082 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1083 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1084 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1085 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1086 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1087 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1088 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1089 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1090 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1091 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1092 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1093 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1094 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1095 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1096 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1097 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1098 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1099 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1100 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1101 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1102 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1103 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1104 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1105 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1106 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1107 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1108 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1109 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1110 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1111 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1112 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1113 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1114 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1115 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1116 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1117 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1118 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1119 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1120 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1121 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1122 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1123 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1127 static uint8_t ms_hmac_key1[] = {
1128 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1129 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1130 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1131 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1132 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1133 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1134 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1135 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1138 static const uint8_t ms_hmac_digest1[] = {
1139 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1140 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1141 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1142 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1143 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1144 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1145 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1146 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1149 /* Begin Session 2 */
1150 static uint8_t ms_aes_cbc_key2[] = {
1151 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1152 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 static uint8_t ms_aes_cbc_iv2[] = {
1156 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1157 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1160 static const uint8_t ms_aes_cbc_cipher2[] = {
1161 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1162 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1163 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1164 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1165 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1166 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1167 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1168 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1169 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1170 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1171 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1172 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1173 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1174 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1175 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1176 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1177 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1178 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1179 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1180 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1181 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1182 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1183 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1184 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1185 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1186 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1187 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1188 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1189 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1190 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1191 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1192 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1193 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1194 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1195 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1196 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1197 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1198 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1199 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1200 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1201 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1202 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1203 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1204 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1205 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1206 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1207 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1208 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1209 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1210 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1211 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1212 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1213 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1214 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1215 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1216 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1217 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1218 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1219 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1220 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1221 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1222 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1223 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1224 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1227 static uint8_t ms_hmac_key2[] = {
1228 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest2[] = {
1239 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1240 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1241 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1242 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1243 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1244 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1245 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1246 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1253 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1255 struct crypto_testsuite_params *ts_params = &testsuite_params;
1256 struct crypto_unittest_params *ut_params = &unittest_params;
1258 /* Generate test mbuf data and space for digest */
1259 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1260 catch_22_quote, QUOTE_512_BYTES, 0);
1262 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1263 DIGEST_BYTE_LENGTH_SHA1);
1264 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1266 /* Setup Cipher Parameters */
1267 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1268 ut_params->cipher_xform.next = &ut_params->auth_xform;
1270 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1271 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1272 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1273 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1274 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1275 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1277 /* Setup HMAC Parameters */
1278 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1280 ut_params->auth_xform.next = NULL;
1282 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1283 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1284 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1285 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1286 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1288 /* Create crypto session*/
1289 ut_params->sess = rte_cryptodev_sym_session_create(
1290 ts_params->valid_devs[0],
1291 &ut_params->cipher_xform);
1292 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1294 /* Generate crypto op data structure */
1295 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1296 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1297 TEST_ASSERT_NOT_NULL(ut_params->op,
1298 "Failed to allocate symmetric crypto operation struct");
1300 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1302 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1304 /* set crypto operation source mbuf */
1305 sym_op->m_src = ut_params->ibuf;
1307 /* Set crypto operation authentication parameters */
1308 sym_op->auth.digest.data = ut_params->digest;
1309 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1310 ut_params->ibuf, QUOTE_512_BYTES);
1311 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1345 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1346 DIGEST_BYTE_LENGTH_SHA1,
1347 "Generated digest data not as expected");
1349 return TEST_SUCCESS;
1352 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1354 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1356 static uint8_t hmac_sha512_key[] = {
1357 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1358 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1359 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1360 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1361 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1362 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1363 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1364 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1366 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1367 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1368 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1369 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1370 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1371 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1372 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1373 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1374 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1379 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1380 struct crypto_unittest_params *ut_params,
1381 uint8_t *cipher_key,
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1395 struct crypto_unittest_params *ut_params,
1396 uint8_t *cipher_key,
1400 /* Setup Cipher Parameters */
1401 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1402 ut_params->cipher_xform.next = NULL;
1404 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1405 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1406 ut_params->cipher_xform.cipher.key.data = cipher_key;
1407 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1409 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1411 /* Setup HMAC Parameters */
1412 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1413 ut_params->auth_xform.next = &ut_params->cipher_xform;
1415 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1417 ut_params->auth_xform.auth.key.data = hmac_key;
1418 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1419 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1421 return TEST_SUCCESS;
1426 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1427 struct crypto_unittest_params *ut_params,
1428 struct crypto_testsuite_params *ts_params,
1429 const uint8_t *cipher,
1430 const uint8_t *digest,
1433 /* Generate test mbuf data and digest */
1434 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA512);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 rte_memcpy(ut_params->digest,
1445 DIGEST_BYTE_LENGTH_SHA512);
1447 /* Generate Crypto op data structure */
1448 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1449 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1450 TEST_ASSERT_NOT_NULL(ut_params->op,
1451 "Failed to allocate symmetric crypto operation struct");
1453 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1455 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1457 /* set crypto operation source mbuf */
1458 sym_op->m_src = ut_params->ibuf;
1460 sym_op->auth.digest.data = ut_params->digest;
1461 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1462 ut_params->ibuf, QUOTE_512_BYTES);
1463 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1465 sym_op->auth.data.offset = 0;
1466 sym_op->auth.data.length = QUOTE_512_BYTES;
1468 /* Copy IV at the end of the crypto operation */
1469 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1470 iv, CIPHER_IV_LENGTH_AES_CBC);
1472 sym_op->cipher.data.offset = 0;
1473 sym_op->cipher.data.length = QUOTE_512_BYTES;
1475 /* Process crypto operation */
1476 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1477 ut_params->op), "failed to process sym crypto op");
1479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1480 "crypto op processing failed");
1482 ut_params->obuf = ut_params->op->sym->m_src;
1485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1486 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1489 "Plaintext data not as expected");
1492 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1493 "Digest verification failed");
1495 return TEST_SUCCESS;
1499 test_AES_cipheronly_mb_all(void)
1501 struct crypto_testsuite_params *ts_params = &testsuite_params;
1504 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1505 ts_params->op_mpool, ts_params->valid_devs[0],
1506 RTE_CRYPTODEV_AESNI_MB_PMD,
1507 BLKCIPHER_AES_CIPHERONLY_TYPE);
1509 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1511 return TEST_SUCCESS;
1515 test_AES_docsis_mb_all(void)
1517 struct crypto_testsuite_params *ts_params = &testsuite_params;
1520 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1521 ts_params->op_mpool, ts_params->valid_devs[0],
1522 RTE_CRYPTODEV_AESNI_MB_PMD,
1523 BLKCIPHER_AES_DOCSIS_TYPE);
1525 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1527 return TEST_SUCCESS;
1531 test_AES_docsis_qat_all(void)
1533 struct crypto_testsuite_params *ts_params = &testsuite_params;
1536 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1537 ts_params->op_mpool, ts_params->valid_devs[0],
1538 RTE_CRYPTODEV_QAT_SYM_PMD,
1539 BLKCIPHER_AES_DOCSIS_TYPE);
1541 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1543 return TEST_SUCCESS;
1547 test_DES_docsis_qat_all(void)
1549 struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1553 ts_params->op_mpool, ts_params->valid_devs[0],
1554 RTE_CRYPTODEV_QAT_SYM_PMD,
1555 BLKCIPHER_DES_DOCSIS_TYPE);
1557 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1559 return TEST_SUCCESS;
1563 test_authonly_mb_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool, ts_params->valid_devs[0],
1570 RTE_CRYPTODEV_AESNI_MB_PMD,
1571 BLKCIPHER_AUTHONLY_TYPE);
1573 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1575 return TEST_SUCCESS;
1579 test_AES_chain_mb_all(void)
1581 struct crypto_testsuite_params *ts_params = &testsuite_params;
1584 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1585 ts_params->op_mpool, ts_params->valid_devs[0],
1586 RTE_CRYPTODEV_AESNI_MB_PMD,
1587 BLKCIPHER_AES_CHAIN_TYPE);
1589 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1591 return TEST_SUCCESS;
1594 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1597 test_AES_cipheronly_scheduler_all(void)
1599 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1603 ts_params->op_mpool, ts_params->valid_devs[0],
1604 RTE_CRYPTODEV_SCHEDULER_PMD,
1605 BLKCIPHER_AES_CIPHERONLY_TYPE);
1607 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1609 return TEST_SUCCESS;
1613 test_AES_chain_scheduler_all(void)
1615 struct crypto_testsuite_params *ts_params = &testsuite_params;
1618 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1619 ts_params->op_mpool, ts_params->valid_devs[0],
1620 RTE_CRYPTODEV_SCHEDULER_PMD,
1621 BLKCIPHER_AES_CHAIN_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1629 test_authonly_scheduler_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool, ts_params->valid_devs[0],
1636 RTE_CRYPTODEV_SCHEDULER_PMD,
1637 BLKCIPHER_AUTHONLY_TYPE);
1639 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1641 return TEST_SUCCESS;
1644 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1647 test_AES_chain_openssl_all(void)
1649 struct crypto_testsuite_params *ts_params = &testsuite_params;
1652 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1653 ts_params->op_mpool, ts_params->valid_devs[0],
1654 RTE_CRYPTODEV_OPENSSL_PMD,
1655 BLKCIPHER_AES_CHAIN_TYPE);
1657 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1659 return TEST_SUCCESS;
1663 test_AES_cipheronly_openssl_all(void)
1665 struct crypto_testsuite_params *ts_params = &testsuite_params;
1668 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1669 ts_params->op_mpool, ts_params->valid_devs[0],
1670 RTE_CRYPTODEV_OPENSSL_PMD,
1671 BLKCIPHER_AES_CIPHERONLY_TYPE);
1673 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1675 return TEST_SUCCESS;
1679 test_AES_chain_qat_all(void)
1681 struct crypto_testsuite_params *ts_params = &testsuite_params;
1684 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1685 ts_params->op_mpool, ts_params->valid_devs[0],
1686 RTE_CRYPTODEV_QAT_SYM_PMD,
1687 BLKCIPHER_AES_CHAIN_TYPE);
1689 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1691 return TEST_SUCCESS;
1695 test_AES_cipheronly_qat_all(void)
1697 struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1701 ts_params->op_mpool, ts_params->valid_devs[0],
1702 RTE_CRYPTODEV_QAT_SYM_PMD,
1703 BLKCIPHER_AES_CIPHERONLY_TYPE);
1705 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1707 return TEST_SUCCESS;
1711 test_AES_chain_dpaa2_sec_all(void)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1717 ts_params->op_mpool, ts_params->valid_devs[0],
1718 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1719 BLKCIPHER_AES_CHAIN_TYPE);
1721 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1723 return TEST_SUCCESS;
1727 test_AES_cipheronly_dpaa2_sec_all(void)
1729 struct crypto_testsuite_params *ts_params = &testsuite_params;
1732 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1733 ts_params->op_mpool, ts_params->valid_devs[0],
1734 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1735 BLKCIPHER_AES_CIPHERONLY_TYPE);
1737 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1739 return TEST_SUCCESS;
1743 test_authonly_openssl_all(void)
1745 struct crypto_testsuite_params *ts_params = &testsuite_params;
1748 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1749 ts_params->op_mpool, ts_params->valid_devs[0],
1750 RTE_CRYPTODEV_OPENSSL_PMD,
1751 BLKCIPHER_AUTHONLY_TYPE);
1753 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1755 return TEST_SUCCESS;
1759 test_AES_chain_armv8_all(void)
1761 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1765 ts_params->op_mpool, ts_params->valid_devs[0],
1766 RTE_CRYPTODEV_ARMV8_PMD,
1767 BLKCIPHER_AES_CHAIN_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1774 /* ***** SNOW 3G Tests ***** */
1776 create_wireless_algo_hash_session(uint8_t dev_id,
1777 const uint8_t *key, const uint8_t key_len,
1778 const uint8_t iv_len, const uint8_t auth_len,
1779 enum rte_crypto_auth_operation op,
1780 enum rte_crypto_auth_algorithm algo)
1782 uint8_t hash_key[key_len];
1784 struct crypto_unittest_params *ut_params = &unittest_params;
1786 memcpy(hash_key, key, key_len);
1788 TEST_HEXDUMP(stdout, "key:", key, key_len);
1790 /* Setup Authentication Parameters */
1791 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1792 ut_params->auth_xform.next = NULL;
1794 ut_params->auth_xform.auth.op = op;
1795 ut_params->auth_xform.auth.algo = algo;
1796 ut_params->auth_xform.auth.key.length = key_len;
1797 ut_params->auth_xform.auth.key.data = hash_key;
1798 ut_params->auth_xform.auth.digest_length = auth_len;
1799 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1800 ut_params->auth_xform.auth.iv.length = iv_len;
1801 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1802 &ut_params->auth_xform);
1803 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1808 create_wireless_algo_cipher_session(uint8_t dev_id,
1809 enum rte_crypto_cipher_operation op,
1810 enum rte_crypto_cipher_algorithm algo,
1811 const uint8_t *key, const uint8_t key_len,
1814 uint8_t cipher_key[key_len];
1816 struct crypto_unittest_params *ut_params = &unittest_params;
1818 memcpy(cipher_key, key, key_len);
1820 /* Setup Cipher Parameters */
1821 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1822 ut_params->cipher_xform.next = NULL;
1824 ut_params->cipher_xform.cipher.algo = algo;
1825 ut_params->cipher_xform.cipher.op = op;
1826 ut_params->cipher_xform.cipher.key.data = cipher_key;
1827 ut_params->cipher_xform.cipher.key.length = key_len;
1828 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1829 ut_params->cipher_xform.cipher.iv.length = iv_len;
1831 TEST_HEXDUMP(stdout, "key:", key, key_len);
1833 /* Create Crypto session */
1834 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1837 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1842 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1843 unsigned int cipher_len,
1844 unsigned int cipher_offset)
1846 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 struct crypto_unittest_params *ut_params = &unittest_params;
1849 /* Generate Crypto op data structure */
1850 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1851 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1852 TEST_ASSERT_NOT_NULL(ut_params->op,
1853 "Failed to allocate pktmbuf offload");
1855 /* Set crypto operation data parameters */
1856 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1858 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1860 /* set crypto operation source mbuf */
1861 sym_op->m_src = ut_params->ibuf;
1864 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1866 sym_op->cipher.data.length = cipher_len;
1867 sym_op->cipher.data.offset = cipher_offset;
1872 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1873 unsigned int cipher_len,
1874 unsigned int cipher_offset)
1876 struct crypto_testsuite_params *ts_params = &testsuite_params;
1877 struct crypto_unittest_params *ut_params = &unittest_params;
1879 /* Generate Crypto op data structure */
1880 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1881 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1882 TEST_ASSERT_NOT_NULL(ut_params->op,
1883 "Failed to allocate pktmbuf offload");
1885 /* Set crypto operation data parameters */
1886 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1888 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1890 /* set crypto operation source mbuf */
1891 sym_op->m_src = ut_params->ibuf;
1892 sym_op->m_dst = ut_params->obuf;
1895 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1897 sym_op->cipher.data.length = cipher_len;
1898 sym_op->cipher.data.offset = cipher_offset;
1903 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1904 enum rte_crypto_cipher_operation cipher_op,
1905 enum rte_crypto_auth_operation auth_op,
1906 enum rte_crypto_auth_algorithm auth_algo,
1907 enum rte_crypto_cipher_algorithm cipher_algo,
1908 const uint8_t *key, uint8_t key_len,
1909 uint8_t auth_iv_len, uint8_t auth_len,
1910 uint8_t cipher_iv_len)
1913 uint8_t cipher_auth_key[key_len];
1915 struct crypto_unittest_params *ut_params = &unittest_params;
1917 memcpy(cipher_auth_key, key, key_len);
1919 /* Setup Authentication Parameters */
1920 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1921 ut_params->auth_xform.next = NULL;
1923 ut_params->auth_xform.auth.op = auth_op;
1924 ut_params->auth_xform.auth.algo = auth_algo;
1925 ut_params->auth_xform.auth.key.length = key_len;
1926 /* Hash key = cipher key */
1927 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1928 ut_params->auth_xform.auth.digest_length = auth_len;
1929 /* Auth IV will be after cipher IV */
1930 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1931 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1933 /* Setup Cipher Parameters */
1934 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1935 ut_params->cipher_xform.next = &ut_params->auth_xform;
1937 ut_params->cipher_xform.cipher.algo = cipher_algo;
1938 ut_params->cipher_xform.cipher.op = cipher_op;
1939 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1940 ut_params->cipher_xform.cipher.key.length = key_len;
1941 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1942 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1944 TEST_HEXDUMP(stdout, "key:", key, key_len);
1946 /* Create Crypto session*/
1947 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1948 &ut_params->cipher_xform);
1950 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1955 create_wireless_cipher_auth_session(uint8_t dev_id,
1956 enum rte_crypto_cipher_operation cipher_op,
1957 enum rte_crypto_auth_operation auth_op,
1958 enum rte_crypto_auth_algorithm auth_algo,
1959 enum rte_crypto_cipher_algorithm cipher_algo,
1960 const struct wireless_test_data *tdata)
1962 const uint8_t key_len = tdata->key.len;
1963 uint8_t cipher_auth_key[key_len];
1965 struct crypto_unittest_params *ut_params = &unittest_params;
1966 const uint8_t *key = tdata->key.data;
1967 const uint8_t auth_len = tdata->digest.len;
1968 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1969 uint8_t auth_iv_len = tdata->auth_iv.len;
1971 memcpy(cipher_auth_key, key, key_len);
1973 /* Setup Authentication Parameters */
1974 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1975 ut_params->auth_xform.next = NULL;
1977 ut_params->auth_xform.auth.op = auth_op;
1978 ut_params->auth_xform.auth.algo = auth_algo;
1979 ut_params->auth_xform.auth.key.length = key_len;
1980 /* Hash key = cipher key */
1981 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1982 ut_params->auth_xform.auth.digest_length = auth_len;
1983 /* Auth IV will be after cipher IV */
1984 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1985 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1987 /* Setup Cipher Parameters */
1988 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1989 ut_params->cipher_xform.next = &ut_params->auth_xform;
1991 ut_params->cipher_xform.cipher.algo = cipher_algo;
1992 ut_params->cipher_xform.cipher.op = cipher_op;
1993 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1994 ut_params->cipher_xform.cipher.key.length = key_len;
1995 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1996 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1999 TEST_HEXDUMP(stdout, "key:", key, key_len);
2001 /* Create Crypto session*/
2002 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2003 &ut_params->cipher_xform);
2005 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2010 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2011 const struct wireless_test_data *tdata)
2013 return create_wireless_cipher_auth_session(dev_id,
2014 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2015 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2016 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2020 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2021 enum rte_crypto_cipher_operation cipher_op,
2022 enum rte_crypto_auth_operation auth_op,
2023 enum rte_crypto_auth_algorithm auth_algo,
2024 enum rte_crypto_cipher_algorithm cipher_algo,
2025 const uint8_t *key, const uint8_t key_len,
2026 uint8_t auth_iv_len, uint8_t auth_len,
2027 uint8_t cipher_iv_len)
2029 uint8_t auth_cipher_key[key_len];
2031 struct crypto_unittest_params *ut_params = &unittest_params;
2033 memcpy(auth_cipher_key, key, key_len);
2035 /* Setup Authentication Parameters */
2036 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2037 ut_params->auth_xform.auth.op = auth_op;
2038 ut_params->auth_xform.next = &ut_params->cipher_xform;
2039 ut_params->auth_xform.auth.algo = auth_algo;
2040 ut_params->auth_xform.auth.key.length = key_len;
2041 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2042 ut_params->auth_xform.auth.digest_length = auth_len;
2043 /* Auth IV will be after cipher IV */
2044 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2045 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2047 /* Setup Cipher Parameters */
2048 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2049 ut_params->cipher_xform.next = NULL;
2050 ut_params->cipher_xform.cipher.algo = cipher_algo;
2051 ut_params->cipher_xform.cipher.op = cipher_op;
2052 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2053 ut_params->cipher_xform.cipher.key.length = key_len;
2054 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2055 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2057 TEST_HEXDUMP(stdout, "key:", key, key_len);
2059 /* Create Crypto session*/
2060 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2061 &ut_params->auth_xform);
2063 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2069 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2070 unsigned int auth_tag_len,
2071 const uint8_t *iv, unsigned int iv_len,
2072 unsigned int data_pad_len,
2073 enum rte_crypto_auth_operation op,
2074 unsigned int auth_len, unsigned int auth_offset)
2076 struct crypto_testsuite_params *ts_params = &testsuite_params;
2078 struct crypto_unittest_params *ut_params = &unittest_params;
2080 /* Generate Crypto op data structure */
2081 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2082 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2083 TEST_ASSERT_NOT_NULL(ut_params->op,
2084 "Failed to allocate pktmbuf offload");
2086 /* Set crypto operation data parameters */
2087 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2089 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2091 /* set crypto operation source mbuf */
2092 sym_op->m_src = ut_params->ibuf;
2095 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2098 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2099 ut_params->ibuf, auth_tag_len);
2101 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2102 "no room to append auth tag");
2103 ut_params->digest = sym_op->auth.digest.data;
2104 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2105 ut_params->ibuf, data_pad_len);
2106 sym_op->auth.digest.length = auth_tag_len;
2107 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2108 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2110 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2112 TEST_HEXDUMP(stdout, "digest:",
2113 sym_op->auth.digest.data,
2114 sym_op->auth.digest.length);
2116 sym_op->auth.data.length = auth_len;
2117 sym_op->auth.data.offset = auth_offset;
2123 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2124 enum rte_crypto_auth_operation op)
2126 struct crypto_testsuite_params *ts_params = &testsuite_params;
2127 struct crypto_unittest_params *ut_params = &unittest_params;
2129 const uint8_t *auth_tag = tdata->digest.data;
2130 const unsigned int auth_tag_len = tdata->digest.len;
2131 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2132 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2134 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2135 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2136 const uint8_t *auth_iv = tdata->auth_iv.data;
2137 const uint8_t auth_iv_len = tdata->auth_iv.len;
2138 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2139 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2141 /* Generate Crypto op data structure */
2142 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2143 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2144 TEST_ASSERT_NOT_NULL(ut_params->op,
2145 "Failed to allocate pktmbuf offload");
2146 /* Set crypto operation data parameters */
2147 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2149 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2151 /* set crypto operation source mbuf */
2152 sym_op->m_src = ut_params->ibuf;
2155 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2156 ut_params->ibuf, auth_tag_len);
2158 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2159 "no room to append auth tag");
2160 ut_params->digest = sym_op->auth.digest.data;
2161 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2162 ut_params->ibuf, data_pad_len);
2163 sym_op->auth.digest.length = auth_tag_len;
2164 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2165 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2167 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2169 TEST_HEXDUMP(stdout, "digest:",
2170 sym_op->auth.digest.data,
2171 sym_op->auth.digest.length);
2173 /* Copy cipher and auth IVs at the end of the crypto operation */
2174 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2176 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2177 iv_ptr += cipher_iv_len;
2178 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2180 sym_op->cipher.data.length = cipher_len;
2181 sym_op->cipher.data.offset = 0;
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = 0;
2189 create_zuc_cipher_hash_generate_operation(
2190 const struct wireless_test_data *tdata)
2192 return create_wireless_cipher_hash_operation(tdata,
2193 RTE_CRYPTO_AUTH_OP_GENERATE);
2197 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2198 const unsigned auth_tag_len,
2199 const uint8_t *auth_iv, uint8_t auth_iv_len,
2200 unsigned data_pad_len,
2201 enum rte_crypto_auth_operation op,
2202 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2203 const unsigned cipher_len, const unsigned cipher_offset,
2204 const unsigned auth_len, const unsigned auth_offset)
2206 struct crypto_testsuite_params *ts_params = &testsuite_params;
2207 struct crypto_unittest_params *ut_params = &unittest_params;
2209 /* Generate Crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate pktmbuf offload");
2214 /* Set crypto operation data parameters */
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2223 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2224 ut_params->ibuf, auth_tag_len);
2226 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2227 "no room to append auth tag");
2228 ut_params->digest = sym_op->auth.digest.data;
2229 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2230 ut_params->ibuf, data_pad_len);
2231 sym_op->auth.digest.length = auth_tag_len;
2232 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2233 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2235 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2237 TEST_HEXDUMP(stdout, "digest:",
2238 sym_op->auth.digest.data,
2239 sym_op->auth.digest.length);
2241 /* Copy cipher and auth IVs at the end of the crypto operation */
2242 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2244 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2245 iv_ptr += cipher_iv_len;
2246 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2248 sym_op->cipher.data.length = cipher_len;
2249 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2250 sym_op->auth.data.length = auth_len;
2251 sym_op->auth.data.offset = auth_offset + cipher_offset;
2257 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2258 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2259 const uint8_t *auth_iv, uint8_t auth_iv_len,
2260 unsigned int data_pad_len,
2261 unsigned int cipher_len, unsigned int cipher_offset,
2262 unsigned int auth_len, unsigned int auth_offset)
2264 struct crypto_testsuite_params *ts_params = &testsuite_params;
2265 struct crypto_unittest_params *ut_params = &unittest_params;
2267 /* Generate Crypto op data structure */
2268 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2269 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2270 TEST_ASSERT_NOT_NULL(ut_params->op,
2271 "Failed to allocate pktmbuf offload");
2273 /* Set crypto operation data parameters */
2274 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2276 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2278 /* set crypto operation source mbuf */
2279 sym_op->m_src = ut_params->ibuf;
2282 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2283 ut_params->ibuf, auth_tag_len);
2285 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2286 "no room to append auth tag");
2288 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2289 ut_params->ibuf, data_pad_len);
2290 sym_op->auth.digest.length = auth_tag_len;
2292 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2294 TEST_HEXDUMP(stdout, "digest:",
2295 sym_op->auth.digest.data,
2296 sym_op->auth.digest.length);
2298 /* Copy cipher and auth IVs at the end of the crypto operation */
2299 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2301 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2302 iv_ptr += cipher_iv_len;
2303 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2305 sym_op->cipher.data.length = cipher_len;
2306 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2308 sym_op->auth.data.length = auth_len;
2309 sym_op->auth.data.offset = auth_offset + cipher_offset;
2315 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2317 struct crypto_testsuite_params *ts_params = &testsuite_params;
2318 struct crypto_unittest_params *ut_params = &unittest_params;
2321 unsigned plaintext_pad_len;
2322 unsigned plaintext_len;
2325 /* Create SNOW 3G session */
2326 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2327 tdata->key.data, tdata->key.len,
2328 tdata->auth_iv.len, tdata->digest.len,
2329 RTE_CRYPTO_AUTH_OP_GENERATE,
2330 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2334 /* alloc mbuf and set payload */
2335 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2338 rte_pktmbuf_tailroom(ut_params->ibuf));
2340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2341 /* Append data which is padded to a multiple of */
2342 /* the algorithms block size */
2343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2348 /* Create SNOW 3G operation */
2349 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2350 tdata->auth_iv.data, tdata->auth_iv.len,
2351 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2352 tdata->validAuthLenInBits.len,
2357 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2359 ut_params->obuf = ut_params->op->sym->m_src;
2360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2361 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2362 + plaintext_pad_len;
2365 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2368 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2369 "SNOW 3G Generated auth tag not as expected");
2375 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2377 struct crypto_testsuite_params *ts_params = &testsuite_params;
2378 struct crypto_unittest_params *ut_params = &unittest_params;
2381 unsigned plaintext_pad_len;
2382 unsigned plaintext_len;
2385 /* Create SNOW 3G session */
2386 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2387 tdata->key.data, tdata->key.len,
2388 tdata->auth_iv.len, tdata->digest.len,
2389 RTE_CRYPTO_AUTH_OP_VERIFY,
2390 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2393 /* alloc mbuf and set payload */
2394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2396 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2397 rte_pktmbuf_tailroom(ut_params->ibuf));
2399 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2400 /* Append data which is padded to a multiple of */
2401 /* the algorithms block size */
2402 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2403 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2405 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2407 /* Create SNOW 3G operation */
2408 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2410 tdata->auth_iv.data, tdata->auth_iv.len,
2412 RTE_CRYPTO_AUTH_OP_VERIFY,
2413 tdata->validAuthLenInBits.len,
2418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2421 ut_params->obuf = ut_params->op->sym->m_src;
2422 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2423 + plaintext_pad_len;
2426 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2435 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2437 struct crypto_testsuite_params *ts_params = &testsuite_params;
2438 struct crypto_unittest_params *ut_params = &unittest_params;
2441 unsigned plaintext_pad_len;
2442 unsigned plaintext_len;
2445 /* Create KASUMI session */
2446 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2447 tdata->key.data, tdata->key.len,
2448 tdata->auth_iv.len, tdata->digest.len,
2449 RTE_CRYPTO_AUTH_OP_GENERATE,
2450 RTE_CRYPTO_AUTH_KASUMI_F9);
2454 /* alloc mbuf and set payload */
2455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2458 rte_pktmbuf_tailroom(ut_params->ibuf));
2460 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2461 /* Append data which is padded to a multiple of */
2462 /* the algorithms block size */
2463 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2464 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2466 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2468 /* Create KASUMI operation */
2469 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2470 tdata->auth_iv.data, tdata->auth_iv.len,
2471 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2472 tdata->validAuthLenInBits.len,
2477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2479 ut_params->obuf = ut_params->op->sym->m_src;
2480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2481 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2482 + plaintext_pad_len;
2485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2488 DIGEST_BYTE_LENGTH_KASUMI_F9,
2489 "KASUMI Generated auth tag not as expected");
2495 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2497 struct crypto_testsuite_params *ts_params = &testsuite_params;
2498 struct crypto_unittest_params *ut_params = &unittest_params;
2501 unsigned plaintext_pad_len;
2502 unsigned plaintext_len;
2505 /* Create KASUMI session */
2506 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2507 tdata->key.data, tdata->key.len,
2508 tdata->auth_iv.len, tdata->digest.len,
2509 RTE_CRYPTO_AUTH_OP_VERIFY,
2510 RTE_CRYPTO_AUTH_KASUMI_F9);
2513 /* alloc mbuf and set payload */
2514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2517 rte_pktmbuf_tailroom(ut_params->ibuf));
2519 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2520 /* Append data which is padded to a multiple */
2521 /* of the algorithms block size */
2522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2523 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2527 /* Create KASUMI operation */
2528 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2530 tdata->auth_iv.data, tdata->auth_iv.len,
2532 RTE_CRYPTO_AUTH_OP_VERIFY,
2533 tdata->validAuthLenInBits.len,
2538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2541 ut_params->obuf = ut_params->op->sym->m_src;
2542 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2543 + plaintext_pad_len;
2546 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2555 test_snow3g_hash_generate_test_case_1(void)
2557 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2561 test_snow3g_hash_generate_test_case_2(void)
2563 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2567 test_snow3g_hash_generate_test_case_3(void)
2569 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2573 test_snow3g_hash_generate_test_case_4(void)
2575 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2579 test_snow3g_hash_generate_test_case_5(void)
2581 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2585 test_snow3g_hash_generate_test_case_6(void)
2587 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2591 test_snow3g_hash_verify_test_case_1(void)
2593 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2598 test_snow3g_hash_verify_test_case_2(void)
2600 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2604 test_snow3g_hash_verify_test_case_3(void)
2606 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2610 test_snow3g_hash_verify_test_case_4(void)
2612 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2616 test_snow3g_hash_verify_test_case_5(void)
2618 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2622 test_snow3g_hash_verify_test_case_6(void)
2624 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2628 test_kasumi_hash_generate_test_case_1(void)
2630 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2634 test_kasumi_hash_generate_test_case_2(void)
2636 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2640 test_kasumi_hash_generate_test_case_3(void)
2642 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2646 test_kasumi_hash_generate_test_case_4(void)
2648 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2652 test_kasumi_hash_generate_test_case_5(void)
2654 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2658 test_kasumi_hash_generate_test_case_6(void)
2660 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2664 test_kasumi_hash_verify_test_case_1(void)
2666 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2670 test_kasumi_hash_verify_test_case_2(void)
2672 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2676 test_kasumi_hash_verify_test_case_3(void)
2678 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2682 test_kasumi_hash_verify_test_case_4(void)
2684 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2688 test_kasumi_hash_verify_test_case_5(void)
2690 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2694 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2696 struct crypto_testsuite_params *ts_params = &testsuite_params;
2697 struct crypto_unittest_params *ut_params = &unittest_params;
2700 uint8_t *plaintext, *ciphertext;
2701 unsigned plaintext_pad_len;
2702 unsigned plaintext_len;
2704 /* Create KASUMI session */
2705 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2706 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2707 RTE_CRYPTO_CIPHER_KASUMI_F8,
2708 tdata->key.data, tdata->key.len,
2709 tdata->cipher_iv.len);
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 /* Clear mbuf payload */
2716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2717 rte_pktmbuf_tailroom(ut_params->ibuf));
2719 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2720 /* Append data which is padded to a multiple */
2721 /* of the algorithms block size */
2722 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2725 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2727 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2729 /* Create KASUMI operation */
2730 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2731 tdata->cipher_iv.len,
2732 tdata->plaintext.len,
2737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2741 ut_params->obuf = ut_params->op->sym->m_dst;
2742 if (ut_params->obuf)
2743 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2745 ciphertext = plaintext;
2747 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2750 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2752 tdata->ciphertext.data,
2753 tdata->validCipherLenInBits.len,
2754 "KASUMI Ciphertext data not as expected");
2759 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2761 struct crypto_testsuite_params *ts_params = &testsuite_params;
2762 struct crypto_unittest_params *ut_params = &unittest_params;
2766 unsigned int plaintext_pad_len;
2767 unsigned int plaintext_len;
2769 uint8_t buffer[10000];
2770 const uint8_t *ciphertext;
2772 struct rte_cryptodev_info dev_info;
2774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2775 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2776 printf("Device doesn't support scatter-gather. "
2781 /* Create KASUMI session */
2782 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 RTE_CRYPTO_CIPHER_KASUMI_F8,
2785 tdata->key.data, tdata->key.len,
2786 tdata->cipher_iv.len);
2790 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2793 /* Append data which is padded to a multiple */
2794 /* of the algorithms block size */
2795 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2797 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2798 plaintext_pad_len, 10, 0);
2800 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2802 /* Create KASUMI operation */
2803 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2804 tdata->cipher_iv.len,
2805 tdata->plaintext.len,
2810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2812 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2814 ut_params->obuf = ut_params->op->sym->m_dst;
2816 if (ut_params->obuf)
2817 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2818 plaintext_len, buffer);
2820 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2821 plaintext_len, buffer);
2824 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2827 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2829 tdata->ciphertext.data,
2830 tdata->validCipherLenInBits.len,
2831 "KASUMI Ciphertext data not as expected");
2836 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2838 struct crypto_testsuite_params *ts_params = &testsuite_params;
2839 struct crypto_unittest_params *ut_params = &unittest_params;
2842 uint8_t *plaintext, *ciphertext;
2843 unsigned plaintext_pad_len;
2844 unsigned plaintext_len;
2846 /* Create KASUMI session */
2847 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2848 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2849 RTE_CRYPTO_CIPHER_KASUMI_F8,
2850 tdata->key.data, tdata->key.len,
2851 tdata->cipher_iv.len);
2855 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2856 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2858 /* Clear mbuf payload */
2859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2860 rte_pktmbuf_tailroom(ut_params->ibuf));
2862 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2863 /* Append data which is padded to a multiple */
2864 /* of the algorithms block size */
2865 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2868 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2869 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2871 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2873 /* Create KASUMI operation */
2874 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2875 tdata->cipher_iv.len,
2876 tdata->plaintext.len,
2881 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2885 ut_params->obuf = ut_params->op->sym->m_dst;
2886 if (ut_params->obuf)
2887 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2889 ciphertext = plaintext;
2891 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2896 tdata->ciphertext.data,
2897 tdata->validCipherLenInBits.len,
2898 "KASUMI Ciphertext data not as expected");
2903 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2905 struct crypto_testsuite_params *ts_params = &testsuite_params;
2906 struct crypto_unittest_params *ut_params = &unittest_params;
2909 unsigned int plaintext_pad_len;
2910 unsigned int plaintext_len;
2912 const uint8_t *ciphertext;
2913 uint8_t buffer[2048];
2915 struct rte_cryptodev_info dev_info;
2917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2918 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2919 printf("Device doesn't support scatter-gather. "
2924 /* Create KASUMI session */
2925 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2926 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2927 RTE_CRYPTO_CIPHER_KASUMI_F8,
2928 tdata->key.data, tdata->key.len,
2929 tdata->cipher_iv.len);
2933 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2934 /* Append data which is padded to a multiple */
2935 /* of the algorithms block size */
2936 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2938 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2939 plaintext_pad_len, 10, 0);
2940 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2941 plaintext_pad_len, 3, 0);
2943 /* Append data which is padded to a multiple */
2944 /* of the algorithms block size */
2945 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2947 /* Create KASUMI operation */
2948 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2949 tdata->cipher_iv.len,
2950 tdata->plaintext.len,
2955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2957 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2959 ut_params->obuf = ut_params->op->sym->m_dst;
2960 if (ut_params->obuf)
2961 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2962 plaintext_pad_len, buffer);
2964 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2965 plaintext_pad_len, buffer);
2968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2970 tdata->ciphertext.data,
2971 tdata->validCipherLenInBits.len,
2972 "KASUMI Ciphertext data not as expected");
2978 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2980 struct crypto_testsuite_params *ts_params = &testsuite_params;
2981 struct crypto_unittest_params *ut_params = &unittest_params;
2984 uint8_t *ciphertext, *plaintext;
2985 unsigned ciphertext_pad_len;
2986 unsigned ciphertext_len;
2988 /* Create KASUMI session */
2989 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2990 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2991 RTE_CRYPTO_CIPHER_KASUMI_F8,
2992 tdata->key.data, tdata->key.len,
2993 tdata->cipher_iv.len);
2997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2998 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3000 /* Clear mbuf payload */
3001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3002 rte_pktmbuf_tailroom(ut_params->ibuf));
3004 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3005 /* Append data which is padded to a multiple */
3006 /* of the algorithms block size */
3007 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3008 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3009 ciphertext_pad_len);
3010 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3011 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3013 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3015 /* Create KASUMI operation */
3016 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3017 tdata->cipher_iv.len,
3018 tdata->ciphertext.len,
3023 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3025 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3027 ut_params->obuf = ut_params->op->sym->m_dst;
3028 if (ut_params->obuf)
3029 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3031 plaintext = ciphertext;
3033 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3036 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3038 tdata->plaintext.data,
3039 tdata->validCipherLenInBits.len,
3040 "KASUMI Plaintext data not as expected");
3045 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3047 struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 struct crypto_unittest_params *ut_params = &unittest_params;
3051 uint8_t *ciphertext, *plaintext;
3052 unsigned ciphertext_pad_len;
3053 unsigned ciphertext_len;
3055 /* Create KASUMI session */
3056 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3057 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3058 RTE_CRYPTO_CIPHER_KASUMI_F8,
3059 tdata->key.data, tdata->key.len,
3060 tdata->cipher_iv.len);
3064 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3066 /* Clear mbuf payload */
3067 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3068 rte_pktmbuf_tailroom(ut_params->ibuf));
3070 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3071 /* Append data which is padded to a multiple */
3072 /* of the algorithms block size */
3073 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3074 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3075 ciphertext_pad_len);
3076 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3078 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3080 /* Create KASUMI operation */
3081 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3082 tdata->cipher_iv.len,
3083 tdata->ciphertext.len,
3088 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3090 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3092 ut_params->obuf = ut_params->op->sym->m_dst;
3093 if (ut_params->obuf)
3094 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3096 plaintext = ciphertext;
3098 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3103 tdata->plaintext.data,
3104 tdata->validCipherLenInBits.len,
3105 "KASUMI Plaintext data not as expected");
3110 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3112 struct crypto_testsuite_params *ts_params = &testsuite_params;
3113 struct crypto_unittest_params *ut_params = &unittest_params;
3116 uint8_t *plaintext, *ciphertext;
3117 unsigned plaintext_pad_len;
3118 unsigned plaintext_len;
3120 /* Create SNOW 3G session */
3121 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3122 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3123 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3124 tdata->key.data, tdata->key.len,
3125 tdata->cipher_iv.len);
3129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3131 /* Clear mbuf payload */
3132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3133 rte_pktmbuf_tailroom(ut_params->ibuf));
3135 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3136 /* Append data which is padded to a multiple of */
3137 /* the algorithms block size */
3138 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3139 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3141 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3143 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3145 /* Create SNOW 3G operation */
3146 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3147 tdata->cipher_iv.len,
3148 tdata->validCipherLenInBits.len,
3153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3155 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3157 ut_params->obuf = ut_params->op->sym->m_dst;
3158 if (ut_params->obuf)
3159 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3161 ciphertext = plaintext;
3163 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3168 tdata->ciphertext.data,
3169 tdata->validDataLenInBits.len,
3170 "SNOW 3G Ciphertext data not as expected");
3176 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3178 struct crypto_testsuite_params *ts_params = &testsuite_params;
3179 struct crypto_unittest_params *ut_params = &unittest_params;
3180 uint8_t *plaintext, *ciphertext;
3183 unsigned plaintext_pad_len;
3184 unsigned plaintext_len;
3186 /* Create SNOW 3G session */
3187 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3188 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3189 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3190 tdata->key.data, tdata->key.len,
3191 tdata->cipher_iv.len);
3195 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3198 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3199 "Failed to allocate input buffer in mempool");
3200 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3201 "Failed to allocate output buffer in mempool");
3203 /* Clear mbuf payload */
3204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3205 rte_pktmbuf_tailroom(ut_params->ibuf));
3207 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3208 /* Append data which is padded to a multiple of */
3209 /* the algorithms block size */
3210 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3213 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3214 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3216 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3218 /* Create SNOW 3G operation */
3219 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3220 tdata->cipher_iv.len,
3221 tdata->validCipherLenInBits.len,
3226 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3230 ut_params->obuf = ut_params->op->sym->m_dst;
3231 if (ut_params->obuf)
3232 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3234 ciphertext = plaintext;
3236 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3239 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3241 tdata->ciphertext.data,
3242 tdata->validDataLenInBits.len,
3243 "SNOW 3G Ciphertext data not as expected");
3248 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3250 struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 struct crypto_unittest_params *ut_params = &unittest_params;
3254 unsigned int plaintext_pad_len;
3255 unsigned int plaintext_len;
3256 uint8_t buffer[10000];
3257 const uint8_t *ciphertext;
3259 struct rte_cryptodev_info dev_info;
3261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3262 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3263 printf("Device doesn't support scatter-gather. "
3268 /* Create SNOW 3G session */
3269 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3270 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3271 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3272 tdata->key.data, tdata->key.len,
3273 tdata->cipher_iv.len);
3277 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3278 /* Append data which is padded to a multiple of */
3279 /* the algorithms block size */
3280 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3282 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3283 plaintext_pad_len, 10, 0);
3284 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3285 plaintext_pad_len, 3, 0);
3287 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3288 "Failed to allocate input buffer in mempool");
3289 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3290 "Failed to allocate output buffer in mempool");
3292 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3294 /* Create SNOW 3G operation */
3295 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3296 tdata->cipher_iv.len,
3297 tdata->validCipherLenInBits.len,
3302 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3304 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3306 ut_params->obuf = ut_params->op->sym->m_dst;
3307 if (ut_params->obuf)
3308 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3309 plaintext_len, buffer);
3311 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3312 plaintext_len, buffer);
3314 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3317 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3319 tdata->ciphertext.data,
3320 tdata->validDataLenInBits.len,
3321 "SNOW 3G Ciphertext data not as expected");
3326 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3328 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3330 uint8_t curr_byte, prev_byte;
3331 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3332 uint8_t lower_byte_mask = (1 << offset) - 1;
3335 prev_byte = buffer[0];
3336 buffer[0] >>= offset;
3338 for (i = 1; i < length_in_bytes; i++) {
3339 curr_byte = buffer[i];
3340 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3341 (curr_byte >> offset);
3342 prev_byte = curr_byte;
3347 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3349 struct crypto_testsuite_params *ts_params = &testsuite_params;
3350 struct crypto_unittest_params *ut_params = &unittest_params;
3351 uint8_t *plaintext, *ciphertext;
3353 uint32_t plaintext_len;
3354 uint32_t plaintext_pad_len;
3355 uint8_t extra_offset = 4;
3356 uint8_t *expected_ciphertext_shifted;
3358 /* Create SNOW 3G session */
3359 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3360 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3361 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3362 tdata->key.data, tdata->key.len,
3363 tdata->cipher_iv.len);
3367 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3368 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3370 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3371 "Failed to allocate input buffer in mempool");
3372 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3373 "Failed to allocate output buffer in mempool");
3375 /* Clear mbuf payload */
3376 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3377 rte_pktmbuf_tailroom(ut_params->ibuf));
3379 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3381 * Append data which is padded to a
3382 * multiple of the algorithms block size
3384 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3386 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3389 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3391 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3392 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3394 #ifdef RTE_APP_TEST_DEBUG
3395 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3397 /* Create SNOW 3G operation */
3398 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3399 tdata->cipher_iv.len,
3400 tdata->validCipherLenInBits.len,
3405 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3407 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3409 ut_params->obuf = ut_params->op->sym->m_dst;
3410 if (ut_params->obuf)
3411 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3413 ciphertext = plaintext;
3415 #ifdef RTE_APP_TEST_DEBUG
3416 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3419 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3421 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3422 "failed to reserve memory for ciphertext shifted\n");
3424 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3425 ceil_byte_length(tdata->ciphertext.len));
3426 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3429 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3431 expected_ciphertext_shifted,
3432 tdata->validDataLenInBits.len,
3434 "SNOW 3G Ciphertext data not as expected");
3438 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3440 struct crypto_testsuite_params *ts_params = &testsuite_params;
3441 struct crypto_unittest_params *ut_params = &unittest_params;
3445 uint8_t *plaintext, *ciphertext;
3446 unsigned ciphertext_pad_len;
3447 unsigned ciphertext_len;
3449 /* Create SNOW 3G session */
3450 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3451 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3452 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3453 tdata->key.data, tdata->key.len,
3454 tdata->cipher_iv.len);
3458 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3460 /* Clear mbuf payload */
3461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3462 rte_pktmbuf_tailroom(ut_params->ibuf));
3464 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3465 /* Append data which is padded to a multiple of */
3466 /* the algorithms block size */
3467 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3468 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3469 ciphertext_pad_len);
3470 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3472 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3474 /* Create SNOW 3G operation */
3475 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3476 tdata->cipher_iv.len,
3477 tdata->validCipherLenInBits.len,
3482 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3485 ut_params->obuf = ut_params->op->sym->m_dst;
3486 if (ut_params->obuf)
3487 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3489 plaintext = ciphertext;
3491 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3495 tdata->plaintext.data,
3496 tdata->validDataLenInBits.len,
3497 "SNOW 3G Plaintext data not as expected");
3501 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3503 struct crypto_testsuite_params *ts_params = &testsuite_params;
3504 struct crypto_unittest_params *ut_params = &unittest_params;
3508 uint8_t *plaintext, *ciphertext;
3509 unsigned ciphertext_pad_len;
3510 unsigned ciphertext_len;
3512 /* Create SNOW 3G session */
3513 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3514 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3515 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3516 tdata->key.data, tdata->key.len,
3517 tdata->cipher_iv.len);
3521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3522 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3524 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3525 "Failed to allocate input buffer");
3526 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3527 "Failed to allocate output buffer");
3529 /* Clear mbuf payload */
3530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3531 rte_pktmbuf_tailroom(ut_params->ibuf));
3533 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3534 rte_pktmbuf_tailroom(ut_params->obuf));
3536 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3537 /* Append data which is padded to a multiple of */
3538 /* the algorithms block size */
3539 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3540 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3541 ciphertext_pad_len);
3542 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3543 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3545 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3547 /* Create SNOW 3G operation */
3548 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3549 tdata->cipher_iv.len,
3550 tdata->validCipherLenInBits.len,
3555 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3557 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3558 ut_params->obuf = ut_params->op->sym->m_dst;
3559 if (ut_params->obuf)
3560 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3562 plaintext = ciphertext;
3564 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3567 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3568 tdata->plaintext.data,
3569 tdata->validDataLenInBits.len,
3570 "SNOW 3G Plaintext data not as expected");
3575 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3577 struct crypto_testsuite_params *ts_params = &testsuite_params;
3578 struct crypto_unittest_params *ut_params = &unittest_params;
3582 uint8_t *plaintext, *ciphertext;
3583 unsigned int plaintext_pad_len;
3584 unsigned int plaintext_len;
3586 struct rte_cryptodev_sym_capability_idx cap_idx;
3588 /* Check if device supports ZUC EEA3 */
3589 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3590 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3592 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3596 /* Check if device supports ZUC EIA3 */
3597 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3598 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3600 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3604 /* Create ZUC session */
3605 retval = create_zuc_cipher_auth_encrypt_generate_session(
3606 ts_params->valid_devs[0],
3610 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3612 /* clear mbuf payload */
3613 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3614 rte_pktmbuf_tailroom(ut_params->ibuf));
3616 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3617 /* Append data which is padded to a multiple of */
3618 /* the algorithms block size */
3619 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3620 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3622 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3624 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3626 /* Create ZUC operation */
3627 retval = create_zuc_cipher_hash_generate_operation(tdata);
3631 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3633 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3634 ut_params->obuf = ut_params->op->sym->m_src;
3635 if (ut_params->obuf)
3636 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3638 ciphertext = plaintext;
3640 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3642 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3644 tdata->ciphertext.data,
3645 tdata->validDataLenInBits.len,
3646 "ZUC Ciphertext data not as expected");
3648 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3649 + plaintext_pad_len;
3652 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3656 "ZUC Generated auth tag not as expected");
3661 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3663 struct crypto_testsuite_params *ts_params = &testsuite_params;
3664 struct crypto_unittest_params *ut_params = &unittest_params;
3668 uint8_t *plaintext, *ciphertext;
3669 unsigned plaintext_pad_len;
3670 unsigned plaintext_len;
3672 /* Create SNOW 3G session */
3673 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3674 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3675 RTE_CRYPTO_AUTH_OP_GENERATE,
3676 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3677 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3678 tdata->key.data, tdata->key.len,
3679 tdata->auth_iv.len, tdata->digest.len,
3680 tdata->cipher_iv.len);
3683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3685 /* clear mbuf payload */
3686 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3687 rte_pktmbuf_tailroom(ut_params->ibuf));
3689 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3690 /* Append data which is padded to a multiple of */
3691 /* the algorithms block size */
3692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3693 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3695 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3697 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3699 /* Create SNOW 3G operation */
3700 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3701 tdata->digest.len, tdata->auth_iv.data,
3703 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3704 tdata->cipher_iv.data, tdata->cipher_iv.len,
3705 tdata->validCipherLenInBits.len,
3707 tdata->validAuthLenInBits.len,
3713 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3715 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3716 ut_params->obuf = ut_params->op->sym->m_src;
3717 if (ut_params->obuf)
3718 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3720 ciphertext = plaintext;
3722 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3726 tdata->ciphertext.data,
3727 tdata->validDataLenInBits.len,
3728 "SNOW 3G Ciphertext data not as expected");
3730 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3731 + plaintext_pad_len;
3734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3737 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3738 "SNOW 3G Generated auth tag not as expected");
3742 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3744 struct crypto_testsuite_params *ts_params = &testsuite_params;
3745 struct crypto_unittest_params *ut_params = &unittest_params;
3749 uint8_t *plaintext, *ciphertext;
3750 unsigned plaintext_pad_len;
3751 unsigned plaintext_len;
3753 /* Create SNOW 3G session */
3754 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3755 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3756 RTE_CRYPTO_AUTH_OP_GENERATE,
3757 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3758 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3759 tdata->key.data, tdata->key.len,
3760 tdata->auth_iv.len, tdata->digest.len,
3761 tdata->cipher_iv.len);
3765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3767 /* clear mbuf payload */
3768 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3769 rte_pktmbuf_tailroom(ut_params->ibuf));
3771 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3772 /* Append data which is padded to a multiple of */
3773 /* the algorithms block size */
3774 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3775 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3777 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3779 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3781 /* Create SNOW 3G operation */
3782 retval = create_wireless_algo_auth_cipher_operation(
3784 tdata->cipher_iv.data, tdata->cipher_iv.len,
3785 tdata->auth_iv.data, tdata->auth_iv.len,
3787 tdata->validCipherLenInBits.len,
3789 tdata->validAuthLenInBits.len,
3795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3798 ut_params->obuf = ut_params->op->sym->m_src;
3799 if (ut_params->obuf)
3800 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3802 ciphertext = plaintext;
3804 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3805 + plaintext_pad_len;
3806 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3809 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3811 tdata->ciphertext.data,
3812 tdata->validDataLenInBits.len,
3813 "SNOW 3G Ciphertext data not as expected");
3816 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3819 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3820 "SNOW 3G Generated auth tag not as expected");
3825 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3827 struct crypto_testsuite_params *ts_params = &testsuite_params;
3828 struct crypto_unittest_params *ut_params = &unittest_params;
3832 uint8_t *plaintext, *ciphertext;
3833 unsigned plaintext_pad_len;
3834 unsigned plaintext_len;
3836 /* Create KASUMI session */
3837 retval = create_wireless_algo_auth_cipher_session(
3838 ts_params->valid_devs[0],
3839 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3840 RTE_CRYPTO_AUTH_OP_GENERATE,
3841 RTE_CRYPTO_AUTH_KASUMI_F9,
3842 RTE_CRYPTO_CIPHER_KASUMI_F8,
3843 tdata->key.data, tdata->key.len,
3844 tdata->auth_iv.len, tdata->digest.len,
3845 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3850 /* clear mbuf payload */
3851 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3852 rte_pktmbuf_tailroom(ut_params->ibuf));
3854 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3855 /* Append data which is padded to a multiple of */
3856 /* the algorithms block size */
3857 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3858 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3860 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3862 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3864 /* Create KASUMI operation */
3865 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3866 tdata->cipher_iv.data, tdata->cipher_iv.len,
3867 tdata->auth_iv.data, tdata->auth_iv.len,
3869 tdata->validCipherLenInBits.len,
3871 tdata->validAuthLenInBits.len,
3878 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3880 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3881 ut_params->obuf = ut_params->op->sym->m_src;
3882 if (ut_params->obuf)
3883 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3885 ciphertext = plaintext;
3888 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3890 tdata->ciphertext.data,
3891 tdata->validCipherLenInBits.len,
3892 "KASUMI Ciphertext data not as expected");
3893 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3894 + plaintext_pad_len;
3897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3900 DIGEST_BYTE_LENGTH_KASUMI_F9,
3901 "KASUMI Generated auth tag not as expected");
3906 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3908 struct crypto_testsuite_params *ts_params = &testsuite_params;
3909 struct crypto_unittest_params *ut_params = &unittest_params;
3913 uint8_t *plaintext, *ciphertext;
3914 unsigned plaintext_pad_len;
3915 unsigned plaintext_len;
3917 /* Create KASUMI session */
3918 retval = create_wireless_algo_cipher_auth_session(
3919 ts_params->valid_devs[0],
3920 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3921 RTE_CRYPTO_AUTH_OP_GENERATE,
3922 RTE_CRYPTO_AUTH_KASUMI_F9,
3923 RTE_CRYPTO_CIPHER_KASUMI_F8,
3924 tdata->key.data, tdata->key.len,
3925 tdata->auth_iv.len, tdata->digest.len,
3926 tdata->cipher_iv.len);
3930 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3932 /* clear mbuf payload */
3933 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3934 rte_pktmbuf_tailroom(ut_params->ibuf));
3936 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3937 /* Append data which is padded to a multiple of */
3938 /* the algorithms block size */
3939 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3940 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3942 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3944 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3946 /* Create KASUMI operation */
3947 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3948 tdata->digest.len, tdata->auth_iv.data,
3950 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3951 tdata->cipher_iv.data, tdata->cipher_iv.len,
3952 tdata->validCipherLenInBits.len,
3954 tdata->validAuthLenInBits.len,
3960 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3962 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3963 ut_params->obuf = ut_params->op->sym->m_src;
3964 if (ut_params->obuf)
3965 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3967 ciphertext = plaintext;
3969 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3970 + plaintext_pad_len;
3973 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3975 tdata->ciphertext.data,
3976 tdata->validCipherLenInBits.len,
3977 "KASUMI Ciphertext data not as expected");
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3983 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3984 "KASUMI Generated auth tag not as expected");
3989 test_zuc_encryption(const struct wireless_test_data *tdata)
3991 struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 struct crypto_unittest_params *ut_params = &unittest_params;
3995 uint8_t *plaintext, *ciphertext;
3996 unsigned plaintext_pad_len;
3997 unsigned plaintext_len;
3999 struct rte_cryptodev_sym_capability_idx cap_idx;
4001 /* Check if device supports ZUC EEA3 */
4002 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4003 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4005 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4009 /* Create ZUC session */
4010 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4011 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4012 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4013 tdata->key.data, tdata->key.len,
4014 tdata->cipher_iv.len);
4018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4020 /* Clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4025 /* Append data which is padded to a multiple */
4026 /* of the algorithms block size */
4027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4028 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4030 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4032 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4034 /* Create ZUC operation */
4035 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4036 tdata->cipher_iv.len,
4037 tdata->plaintext.len,
4042 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4044 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4046 ut_params->obuf = ut_params->op->sym->m_dst;
4047 if (ut_params->obuf)
4048 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4050 ciphertext = plaintext;
4052 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4055 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4057 tdata->ciphertext.data,
4058 tdata->validCipherLenInBits.len,
4059 "ZUC Ciphertext data not as expected");
4064 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4066 struct crypto_testsuite_params *ts_params = &testsuite_params;
4067 struct crypto_unittest_params *ut_params = &unittest_params;
4071 unsigned int plaintext_pad_len;
4072 unsigned int plaintext_len;
4073 const uint8_t *ciphertext;
4074 uint8_t ciphertext_buffer[2048];
4075 struct rte_cryptodev_info dev_info;
4077 struct rte_cryptodev_sym_capability_idx cap_idx;
4079 /* Check if device supports ZUC EEA3 */
4080 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4081 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4083 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4088 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4089 printf("Device doesn't support scatter-gather. "
4094 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4096 /* Append data which is padded to a multiple */
4097 /* of the algorithms block size */
4098 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4100 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4101 plaintext_pad_len, 10, 0);
4103 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4104 tdata->plaintext.data);
4106 /* Create ZUC session */
4107 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4108 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4109 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4110 tdata->key.data, tdata->key.len,
4111 tdata->cipher_iv.len);
4115 /* Clear mbuf payload */
4117 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4119 /* Create ZUC operation */
4120 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121 tdata->cipher_iv.len, tdata->plaintext.len,
4126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4130 ut_params->obuf = ut_params->op->sym->m_dst;
4131 if (ut_params->obuf)
4132 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4133 0, plaintext_len, ciphertext_buffer);
4135 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4136 0, plaintext_len, ciphertext_buffer);
4139 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4142 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4144 tdata->ciphertext.data,
4145 tdata->validCipherLenInBits.len,
4146 "ZUC Ciphertext data not as expected");
4152 test_zuc_authentication(const struct wireless_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4158 unsigned plaintext_pad_len;
4159 unsigned plaintext_len;
4162 struct rte_cryptodev_sym_capability_idx cap_idx;
4164 /* Check if device supports ZUC EIA3 */
4165 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4166 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4168 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4172 /* Create ZUC session */
4173 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4174 tdata->key.data, tdata->key.len,
4175 tdata->auth_iv.len, tdata->digest.len,
4176 RTE_CRYPTO_AUTH_OP_GENERATE,
4177 RTE_CRYPTO_AUTH_ZUC_EIA3);
4181 /* alloc mbuf and set payload */
4182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4185 rte_pktmbuf_tailroom(ut_params->ibuf));
4187 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4188 /* Append data which is padded to a multiple of */
4189 /* the algorithms block size */
4190 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4191 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4193 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4195 /* Create ZUC operation */
4196 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4197 tdata->auth_iv.data, tdata->auth_iv.len,
4198 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4199 tdata->validAuthLenInBits.len,
4204 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4206 ut_params->obuf = ut_params->op->sym->m_src;
4207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4208 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4209 + plaintext_pad_len;
4212 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4215 DIGEST_BYTE_LENGTH_KASUMI_F9,
4216 "ZUC Generated auth tag not as expected");
4222 test_kasumi_encryption_test_case_1(void)
4224 return test_kasumi_encryption(&kasumi_test_case_1);
4228 test_kasumi_encryption_test_case_1_sgl(void)
4230 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4234 test_kasumi_encryption_test_case_1_oop(void)
4236 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4240 test_kasumi_encryption_test_case_1_oop_sgl(void)
4242 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4246 test_kasumi_encryption_test_case_2(void)
4248 return test_kasumi_encryption(&kasumi_test_case_2);
4252 test_kasumi_encryption_test_case_3(void)
4254 return test_kasumi_encryption(&kasumi_test_case_3);
4258 test_kasumi_encryption_test_case_4(void)
4260 return test_kasumi_encryption(&kasumi_test_case_4);
4264 test_kasumi_encryption_test_case_5(void)
4266 return test_kasumi_encryption(&kasumi_test_case_5);
4270 test_kasumi_decryption_test_case_1(void)
4272 return test_kasumi_decryption(&kasumi_test_case_1);
4276 test_kasumi_decryption_test_case_1_oop(void)
4278 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4282 test_kasumi_decryption_test_case_2(void)
4284 return test_kasumi_decryption(&kasumi_test_case_2);
4288 test_kasumi_decryption_test_case_3(void)
4290 return test_kasumi_decryption(&kasumi_test_case_3);
4294 test_kasumi_decryption_test_case_4(void)
4296 return test_kasumi_decryption(&kasumi_test_case_4);
4300 test_kasumi_decryption_test_case_5(void)
4302 return test_kasumi_decryption(&kasumi_test_case_5);
4305 test_snow3g_encryption_test_case_1(void)
4307 return test_snow3g_encryption(&snow3g_test_case_1);
4311 test_snow3g_encryption_test_case_1_oop(void)
4313 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4317 test_snow3g_encryption_test_case_1_oop_sgl(void)
4319 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4324 test_snow3g_encryption_test_case_1_offset_oop(void)
4326 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4330 test_snow3g_encryption_test_case_2(void)
4332 return test_snow3g_encryption(&snow3g_test_case_2);
4336 test_snow3g_encryption_test_case_3(void)
4338 return test_snow3g_encryption(&snow3g_test_case_3);
4342 test_snow3g_encryption_test_case_4(void)
4344 return test_snow3g_encryption(&snow3g_test_case_4);
4348 test_snow3g_encryption_test_case_5(void)
4350 return test_snow3g_encryption(&snow3g_test_case_5);
4354 test_snow3g_decryption_test_case_1(void)
4356 return test_snow3g_decryption(&snow3g_test_case_1);
4360 test_snow3g_decryption_test_case_1_oop(void)
4362 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4366 test_snow3g_decryption_test_case_2(void)
4368 return test_snow3g_decryption(&snow3g_test_case_2);
4372 test_snow3g_decryption_test_case_3(void)
4374 return test_snow3g_decryption(&snow3g_test_case_3);
4378 test_snow3g_decryption_test_case_4(void)
4380 return test_snow3g_decryption(&snow3g_test_case_4);
4384 test_snow3g_decryption_test_case_5(void)
4386 return test_snow3g_decryption(&snow3g_test_case_5);
4389 test_snow3g_cipher_auth_test_case_1(void)
4391 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4395 test_snow3g_auth_cipher_test_case_1(void)
4397 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4401 test_kasumi_auth_cipher_test_case_1(void)
4403 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4407 test_kasumi_cipher_auth_test_case_1(void)
4409 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4413 test_zuc_encryption_test_case_1(void)
4415 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4419 test_zuc_encryption_test_case_2(void)
4421 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4425 test_zuc_encryption_test_case_3(void)
4427 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4431 test_zuc_encryption_test_case_4(void)
4433 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4437 test_zuc_encryption_test_case_5(void)
4439 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4443 test_zuc_encryption_test_case_6_sgl(void)
4445 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4449 test_zuc_hash_generate_test_case_1(void)
4451 return test_zuc_authentication(&zuc_test_case_auth_1b);
4455 test_zuc_hash_generate_test_case_2(void)
4457 return test_zuc_authentication(&zuc_test_case_auth_90b);
4461 test_zuc_hash_generate_test_case_3(void)
4463 return test_zuc_authentication(&zuc_test_case_auth_577b);
4467 test_zuc_hash_generate_test_case_4(void)
4469 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4473 test_zuc_hash_generate_test_case_5(void)
4475 return test_zuc_authentication(&zuc_test_auth_5670b);
4479 test_zuc_hash_generate_test_case_6(void)
4481 return test_zuc_authentication(&zuc_test_case_auth_128b);
4485 test_zuc_hash_generate_test_case_7(void)
4487 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4491 test_zuc_hash_generate_test_case_8(void)
4493 return test_zuc_authentication(&zuc_test_case_auth_584b);
4497 test_zuc_cipher_auth_test_case_1(void)
4499 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4503 test_zuc_cipher_auth_test_case_2(void)
4505 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4509 test_3DES_chain_qat_all(void)
4511 struct crypto_testsuite_params *ts_params = &testsuite_params;
4514 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4515 ts_params->op_mpool, ts_params->valid_devs[0],
4516 RTE_CRYPTODEV_QAT_SYM_PMD,
4517 BLKCIPHER_3DES_CHAIN_TYPE);
4519 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4521 return TEST_SUCCESS;
4525 test_DES_cipheronly_qat_all(void)
4527 struct crypto_testsuite_params *ts_params = &testsuite_params;
4530 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4531 ts_params->op_mpool, ts_params->valid_devs[0],
4532 RTE_CRYPTODEV_QAT_SYM_PMD,
4533 BLKCIPHER_DES_CIPHERONLY_TYPE);
4535 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4537 return TEST_SUCCESS;
4541 test_DES_docsis_openssl_all(void)
4543 struct crypto_testsuite_params *ts_params = &testsuite_params;
4546 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4547 ts_params->op_mpool, ts_params->valid_devs[0],
4548 RTE_CRYPTODEV_OPENSSL_PMD,
4549 BLKCIPHER_DES_DOCSIS_TYPE);
4551 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4553 return TEST_SUCCESS;
4557 test_3DES_chain_dpaa2_sec_all(void)
4559 struct crypto_testsuite_params *ts_params = &testsuite_params;
4562 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4563 ts_params->op_mpool, ts_params->valid_devs[0],
4564 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4565 BLKCIPHER_3DES_CHAIN_TYPE);
4567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4569 return TEST_SUCCESS;
4573 test_3DES_cipheronly_dpaa2_sec_all(void)
4575 struct crypto_testsuite_params *ts_params = &testsuite_params;
4578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4579 ts_params->op_mpool, ts_params->valid_devs[0],
4580 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4581 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4583 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4585 return TEST_SUCCESS;
4589 test_3DES_cipheronly_qat_all(void)
4591 struct crypto_testsuite_params *ts_params = &testsuite_params;
4594 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4595 ts_params->op_mpool, ts_params->valid_devs[0],
4596 RTE_CRYPTODEV_QAT_SYM_PMD,
4597 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4599 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4601 return TEST_SUCCESS;
4605 test_3DES_chain_openssl_all(void)
4607 struct crypto_testsuite_params *ts_params = &testsuite_params;
4610 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4611 ts_params->op_mpool, ts_params->valid_devs[0],
4612 RTE_CRYPTODEV_OPENSSL_PMD,
4613 BLKCIPHER_3DES_CHAIN_TYPE);
4615 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4617 return TEST_SUCCESS;
4621 test_3DES_cipheronly_openssl_all(void)
4623 struct crypto_testsuite_params *ts_params = &testsuite_params;
4626 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4627 ts_params->op_mpool, ts_params->valid_devs[0],
4628 RTE_CRYPTODEV_OPENSSL_PMD,
4629 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4631 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4633 return TEST_SUCCESS;
4636 /* ***** AES-GCM Tests ***** */
4639 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4640 const uint8_t *key, const uint8_t key_len,
4641 const uint16_t aad_len, const uint8_t auth_len,
4643 enum rte_crypto_auth_operation auth_op)
4645 uint8_t cipher_key[key_len];
4647 struct crypto_unittest_params *ut_params = &unittest_params;
4649 memcpy(cipher_key, key, key_len);
4651 /* Setup Cipher Parameters */
4652 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4653 ut_params->cipher_xform.next = NULL;
4655 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4656 ut_params->auth_xform.auth.op = auth_op;
4657 ut_params->cipher_xform.cipher.op = op;
4658 ut_params->cipher_xform.cipher.key.data = cipher_key;
4659 ut_params->cipher_xform.cipher.key.length = key_len;
4660 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
4661 ut_params->cipher_xform.cipher.iv.length = iv_len;
4663 TEST_HEXDUMP(stdout, "key:", key, key_len);
4665 /* Setup Authentication Parameters */
4666 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4667 ut_params->auth_xform.next = NULL;
4669 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4671 ut_params->auth_xform.auth.digest_length = auth_len;
4672 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4673 ut_params->auth_xform.auth.key.length = 0;
4674 ut_params->auth_xform.auth.key.data = NULL;
4676 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4677 ut_params->cipher_xform.next = &ut_params->auth_xform;
4679 /* Create Crypto session*/
4680 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4681 &ut_params->cipher_xform);
4682 } else {/* Create Crypto session*/
4683 ut_params->auth_xform.next = &ut_params->cipher_xform;
4684 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4685 &ut_params->auth_xform);
4688 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4694 create_gcm_xforms(struct rte_crypto_op *op,
4695 enum rte_crypto_cipher_operation cipher_op,
4696 uint8_t *key, const uint8_t key_len,
4697 const uint8_t aad_len, const uint8_t auth_len,
4699 enum rte_crypto_auth_operation auth_op)
4701 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4702 "failed to allocate space for crypto transforms");
4704 struct rte_crypto_sym_op *sym_op = op->sym;
4706 /* Setup Cipher Parameters */
4707 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4708 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4709 sym_op->xform->cipher.op = cipher_op;
4710 sym_op->xform->cipher.key.data = key;
4711 sym_op->xform->cipher.key.length = key_len;
4712 sym_op->xform->cipher.iv.offset = IV_OFFSET;
4713 sym_op->xform->cipher.iv.length = iv_len;
4715 TEST_HEXDUMP(stdout, "key:", key, key_len);
4717 /* Setup Authentication Parameters */
4718 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4719 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4720 sym_op->xform->next->auth.op = auth_op;
4721 sym_op->xform->next->auth.digest_length = auth_len;
4722 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4723 sym_op->xform->next->auth.key.length = 0;
4724 sym_op->xform->next->auth.key.data = NULL;
4725 sym_op->xform->next->next = NULL;
4731 create_gcm_operation(enum rte_crypto_cipher_operation op,
4732 const struct gcm_test_data *tdata)
4734 struct crypto_testsuite_params *ts_params = &testsuite_params;
4735 struct crypto_unittest_params *ut_params = &unittest_params;
4737 uint8_t *plaintext, *ciphertext;
4738 unsigned int aad_pad_len, plaintext_pad_len;
4740 /* Generate Crypto op data structure */
4741 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4742 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4743 TEST_ASSERT_NOT_NULL(ut_params->op,
4744 "Failed to allocate symmetric crypto operation struct");
4746 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4748 /* Append aad data */
4749 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4750 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4752 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4753 "no room to append aad");
4755 sym_op->auth.aad.phys_addr =
4756 rte_pktmbuf_mtophys(ut_params->ibuf);
4757 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4758 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4761 /* Append IV at the end of the crypto operation*/
4762 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4763 uint8_t *, IV_OFFSET);
4765 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4766 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4769 /* Append plaintext/ciphertext */
4770 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4771 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4772 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4774 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4776 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4777 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4778 tdata->plaintext.len);
4780 if (ut_params->obuf) {
4781 ciphertext = (uint8_t *)rte_pktmbuf_append(
4783 plaintext_pad_len + aad_pad_len);
4784 TEST_ASSERT_NOT_NULL(ciphertext,
4785 "no room to append ciphertext");
4787 memset(ciphertext + aad_pad_len, 0,
4788 tdata->ciphertext.len);
4791 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4792 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4794 TEST_ASSERT_NOT_NULL(ciphertext,
4795 "no room to append ciphertext");
4797 memcpy(ciphertext, tdata->ciphertext.data,
4798 tdata->ciphertext.len);
4799 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4800 tdata->ciphertext.len);
4802 if (ut_params->obuf) {
4803 plaintext = (uint8_t *)rte_pktmbuf_append(
4805 plaintext_pad_len + aad_pad_len);
4806 TEST_ASSERT_NOT_NULL(plaintext,
4807 "no room to append plaintext");
4809 memset(plaintext + aad_pad_len, 0,
4810 tdata->plaintext.len);
4814 /* Append digest data */
4815 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4816 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4817 ut_params->obuf ? ut_params->obuf :
4819 tdata->auth_tag.len);
4820 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4821 "no room to append digest");
4822 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4823 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4824 ut_params->obuf ? ut_params->obuf :
4828 sym_op->auth.digest.length = tdata->auth_tag.len;
4830 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4831 ut_params->ibuf, tdata->auth_tag.len);
4832 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4833 "no room to append digest");
4834 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4836 plaintext_pad_len + aad_pad_len);
4837 sym_op->auth.digest.length = tdata->auth_tag.len;
4839 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4840 tdata->auth_tag.len);
4841 TEST_HEXDUMP(stdout, "digest:",
4842 sym_op->auth.digest.data,
4843 sym_op->auth.digest.length);
4846 sym_op->cipher.data.length = tdata->plaintext.len;
4847 sym_op->cipher.data.offset = aad_pad_len;
4849 sym_op->auth.data.length = tdata->plaintext.len;
4850 sym_op->auth.data.offset = aad_pad_len;
4856 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4858 struct crypto_testsuite_params *ts_params = &testsuite_params;
4859 struct crypto_unittest_params *ut_params = &unittest_params;
4862 uint8_t *ciphertext, *auth_tag;
4863 uint16_t plaintext_pad_len;
4866 /* Create GCM session */
4867 retval = create_gcm_session(ts_params->valid_devs[0],
4868 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4869 tdata->key.data, tdata->key.len,
4870 tdata->aad.len, tdata->auth_tag.len,
4872 RTE_CRYPTO_AUTH_OP_GENERATE);
4876 if (tdata->aad.len > MBUF_SIZE) {
4877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4878 /* Populate full size of add data */
4879 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4880 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4882 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4884 /* clear mbuf payload */
4885 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4886 rte_pktmbuf_tailroom(ut_params->ibuf));
4888 /* Create GCM operation */
4889 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4895 ut_params->op->sym->m_src = ut_params->ibuf;
4897 /* Process crypto operation */
4898 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4899 ut_params->op), "failed to process sym crypto op");
4901 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4902 "crypto op processing failed");
4904 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4906 if (ut_params->op->sym->m_dst) {
4907 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4909 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4910 uint8_t *, plaintext_pad_len);
4912 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4914 ut_params->op->sym->cipher.data.offset);
4915 auth_tag = ciphertext + plaintext_pad_len;
4918 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4919 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4922 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4924 tdata->ciphertext.data,
4925 tdata->ciphertext.len,
4926 "GCM Ciphertext data not as expected");
4928 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4930 tdata->auth_tag.data,
4931 tdata->auth_tag.len,
4932 "GCM Generated auth tag not as expected");
4939 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4941 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4945 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4947 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4951 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4953 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4957 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4959 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4963 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4965 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4969 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4971 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4975 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4977 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4981 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4983 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4987 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4989 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4993 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4995 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4999 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
5001 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5005 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
5007 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5011 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5013 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5017 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5019 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5023 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5025 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5029 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5031 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5035 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5037 struct crypto_testsuite_params *ts_params = &testsuite_params;
5038 struct crypto_unittest_params *ut_params = &unittest_params;
5044 /* Create GCM session */
5045 retval = create_gcm_session(ts_params->valid_devs[0],
5046 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5047 tdata->key.data, tdata->key.len,
5048 tdata->aad.len, tdata->auth_tag.len,
5050 RTE_CRYPTO_AUTH_OP_VERIFY);
5054 /* alloc mbuf and set payload */
5055 if (tdata->aad.len > MBUF_SIZE) {
5056 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5057 /* Populate full size of add data */
5058 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5059 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5061 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5063 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5064 rte_pktmbuf_tailroom(ut_params->ibuf));
5066 /* Create GCM operation */
5067 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5073 ut_params->op->sym->m_src = ut_params->ibuf;
5075 /* Process crypto operation */
5076 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5077 ut_params->op), "failed to process sym crypto op");
5079 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5080 "crypto op processing failed");
5082 if (ut_params->op->sym->m_dst)
5083 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5086 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5088 ut_params->op->sym->cipher.data.offset);
5090 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5093 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5095 tdata->plaintext.data,
5096 tdata->plaintext.len,
5097 "GCM plaintext data not as expected");
5099 TEST_ASSERT_EQUAL(ut_params->op->status,
5100 RTE_CRYPTO_OP_STATUS_SUCCESS,
5101 "GCM authentication failed");
5106 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5108 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5112 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5114 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5118 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5120 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5124 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5126 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5130 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5132 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5136 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5138 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5142 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5144 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5148 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5150 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5154 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5156 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5160 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5162 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5166 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5168 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5172 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5174 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5178 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5180 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5184 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5186 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5190 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5192 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5196 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5198 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5202 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5204 struct crypto_testsuite_params *ts_params = &testsuite_params;
5205 struct crypto_unittest_params *ut_params = &unittest_params;
5208 uint8_t *ciphertext, *auth_tag;
5209 uint16_t plaintext_pad_len;
5211 /* Create GCM session */
5212 retval = create_gcm_session(ts_params->valid_devs[0],
5213 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5214 tdata->key.data, tdata->key.len,
5215 tdata->aad.len, tdata->auth_tag.len,
5217 RTE_CRYPTO_AUTH_OP_GENERATE);
5221 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5222 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5224 /* clear mbuf payload */
5225 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5226 rte_pktmbuf_tailroom(ut_params->ibuf));
5227 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5228 rte_pktmbuf_tailroom(ut_params->obuf));
5230 /* Create GCM operation */
5231 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5235 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5237 ut_params->op->sym->m_src = ut_params->ibuf;
5238 ut_params->op->sym->m_dst = ut_params->obuf;
5240 /* Process crypto operation */
5241 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5242 ut_params->op), "failed to process sym crypto op");
5244 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5245 "crypto op processing failed");
5247 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5249 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5250 ut_params->op->sym->cipher.data.offset);
5251 auth_tag = ciphertext + plaintext_pad_len;
5253 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5254 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5259 tdata->ciphertext.data,
5260 tdata->ciphertext.len,
5261 "GCM Ciphertext data not as expected");
5263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5265 tdata->auth_tag.data,
5266 tdata->auth_tag.len,
5267 "GCM Generated auth tag not as expected");
5274 test_mb_AES_GCM_authenticated_encryption_oop(void)
5276 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5280 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5282 struct crypto_testsuite_params *ts_params = &testsuite_params;
5283 struct crypto_unittest_params *ut_params = &unittest_params;
5288 /* Create GCM session */
5289 retval = create_gcm_session(ts_params->valid_devs[0],
5290 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5291 tdata->key.data, tdata->key.len,
5292 tdata->aad.len, tdata->auth_tag.len,
5294 RTE_CRYPTO_AUTH_OP_VERIFY);
5298 /* alloc mbuf and set payload */
5299 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5300 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5302 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5303 rte_pktmbuf_tailroom(ut_params->ibuf));
5304 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5305 rte_pktmbuf_tailroom(ut_params->obuf));
5307 /* Create GCM operation */
5308 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5312 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5314 ut_params->op->sym->m_src = ut_params->ibuf;
5315 ut_params->op->sym->m_dst = ut_params->obuf;
5317 /* Process crypto operation */
5318 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5319 ut_params->op), "failed to process sym crypto op");
5321 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5322 "crypto op processing failed");
5324 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5325 ut_params->op->sym->cipher.data.offset);
5327 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5332 tdata->plaintext.data,
5333 tdata->plaintext.len,
5334 "GCM plaintext data not as expected");
5336 TEST_ASSERT_EQUAL(ut_params->op->status,
5337 RTE_CRYPTO_OP_STATUS_SUCCESS,
5338 "GCM authentication failed");
5343 test_mb_AES_GCM_authenticated_decryption_oop(void)
5345 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5349 test_AES_GCM_authenticated_encryption_sessionless(
5350 const struct gcm_test_data *tdata)
5352 struct crypto_testsuite_params *ts_params = &testsuite_params;
5353 struct crypto_unittest_params *ut_params = &unittest_params;
5356 uint8_t *ciphertext, *auth_tag;
5357 uint16_t plaintext_pad_len;
5358 uint8_t key[tdata->key.len + 1];
5360 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5362 /* clear mbuf payload */
5363 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5364 rte_pktmbuf_tailroom(ut_params->ibuf));
5366 /* Create GCM operation */
5367 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5371 /* Create GCM xforms */
5372 memcpy(key, tdata->key.data, tdata->key.len);
5373 retval = create_gcm_xforms(ut_params->op,
5374 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5375 key, tdata->key.len,
5376 tdata->aad.len, tdata->auth_tag.len,
5378 RTE_CRYPTO_AUTH_OP_GENERATE);
5382 ut_params->op->sym->m_src = ut_params->ibuf;
5384 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5385 RTE_CRYPTO_OP_SESSIONLESS,
5386 "crypto op session type not sessionless");
5388 /* Process crypto operation */
5389 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5390 ut_params->op), "failed to process sym crypto op");
5392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5394 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5395 "crypto op status not success");
5397 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5399 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5400 ut_params->op->sym->cipher.data.offset);
5401 auth_tag = ciphertext + plaintext_pad_len;
5403 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5404 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5407 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5409 tdata->ciphertext.data,
5410 tdata->ciphertext.len,
5411 "GCM Ciphertext data not as expected");
5413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5415 tdata->auth_tag.data,
5416 tdata->auth_tag.len,
5417 "GCM Generated auth tag not as expected");
5424 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5426 return test_AES_GCM_authenticated_encryption_sessionless(
5431 test_AES_GCM_authenticated_decryption_sessionless(
5432 const struct gcm_test_data *tdata)
5434 struct crypto_testsuite_params *ts_params = &testsuite_params;
5435 struct crypto_unittest_params *ut_params = &unittest_params;
5439 uint8_t key[tdata->key.len + 1];
5441 /* alloc mbuf and set payload */
5442 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5444 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5445 rte_pktmbuf_tailroom(ut_params->ibuf));
5447 /* Create GCM operation */
5448 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5452 /* Create GCM xforms */
5453 memcpy(key, tdata->key.data, tdata->key.len);
5454 retval = create_gcm_xforms(ut_params->op,
5455 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5456 key, tdata->key.len,
5457 tdata->aad.len, tdata->auth_tag.len,
5459 RTE_CRYPTO_AUTH_OP_VERIFY);
5463 ut_params->op->sym->m_src = ut_params->ibuf;
5465 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5466 RTE_CRYPTO_OP_SESSIONLESS,
5467 "crypto op session type not sessionless");
5469 /* Process crypto operation */
5470 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5471 ut_params->op), "failed to process sym crypto op");
5473 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5475 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5476 "crypto op status not success");
5478 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5479 ut_params->op->sym->cipher.data.offset);
5481 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5484 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5486 tdata->plaintext.data,
5487 tdata->plaintext.len,
5488 "GCM plaintext data not as expected");
5490 TEST_ASSERT_EQUAL(ut_params->op->status,
5491 RTE_CRYPTO_OP_STATUS_SUCCESS,
5492 "GCM authentication failed");
5497 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5499 return test_AES_GCM_authenticated_decryption_sessionless(
5506 struct crypto_testsuite_params *ts_params = &testsuite_params;
5507 struct rte_cryptodev_stats stats;
5508 struct rte_cryptodev *dev;
5509 cryptodev_stats_get_t temp_pfn;
5511 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5512 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5513 &stats) == -ENODEV),
5514 "rte_cryptodev_stats_get invalid dev failed");
5515 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5516 "rte_cryptodev_stats_get invalid Param failed");
5517 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5518 temp_pfn = dev->dev_ops->stats_get;
5519 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5520 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5522 "rte_cryptodev_stats_get invalid Param failed");
5523 dev->dev_ops->stats_get = temp_pfn;
5525 /* Test expected values */
5527 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5529 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5531 "rte_cryptodev_stats_get failed");
5532 TEST_ASSERT((stats.enqueued_count == 1),
5533 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5534 TEST_ASSERT((stats.dequeued_count == 1),
5535 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5536 TEST_ASSERT((stats.enqueue_err_count == 0),
5537 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5538 TEST_ASSERT((stats.dequeue_err_count == 0),
5539 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5541 /* invalid device but should ignore and not reset device stats*/
5542 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5543 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5545 "rte_cryptodev_stats_get failed");
5546 TEST_ASSERT((stats.enqueued_count == 1),
5547 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5549 /* check that a valid reset clears stats */
5550 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5551 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5553 "rte_cryptodev_stats_get failed");
5554 TEST_ASSERT((stats.enqueued_count == 0),
5555 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5556 TEST_ASSERT((stats.dequeued_count == 0),
5557 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5559 return TEST_SUCCESS;
5562 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5563 struct crypto_unittest_params *ut_params,
5564 enum rte_crypto_auth_operation op,
5565 const struct HMAC_MD5_vector *test_case)
5569 memcpy(key, test_case->key.data, test_case->key.len);
5571 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5572 ut_params->auth_xform.next = NULL;
5573 ut_params->auth_xform.auth.op = op;
5575 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5577 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5578 ut_params->auth_xform.auth.add_auth_data_length = 0;
5579 ut_params->auth_xform.auth.key.length = test_case->key.len;
5580 ut_params->auth_xform.auth.key.data = key;
5582 ut_params->sess = rte_cryptodev_sym_session_create(
5583 ts_params->valid_devs[0], &ut_params->auth_xform);
5585 if (ut_params->sess == NULL)
5588 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5590 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5591 rte_pktmbuf_tailroom(ut_params->ibuf));
5596 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5597 const struct HMAC_MD5_vector *test_case,
5598 uint8_t **plaintext)
5600 uint16_t plaintext_pad_len;
5602 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5604 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5607 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5609 memcpy(*plaintext, test_case->plaintext.data,
5610 test_case->plaintext.len);
5612 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5613 ut_params->ibuf, MD5_DIGEST_LEN);
5614 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5615 "no room to append digest");
5616 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5617 ut_params->ibuf, plaintext_pad_len);
5618 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5620 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5621 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5622 test_case->auth_tag.len);
5625 sym_op->auth.data.offset = 0;
5626 sym_op->auth.data.length = test_case->plaintext.len;
5628 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5629 ut_params->op->sym->m_src = ut_params->ibuf;
5635 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5637 uint16_t plaintext_pad_len;
5638 uint8_t *plaintext, *auth_tag;
5640 struct crypto_testsuite_params *ts_params = &testsuite_params;
5641 struct crypto_unittest_params *ut_params = &unittest_params;
5643 if (MD5_HMAC_create_session(ts_params, ut_params,
5644 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5647 /* Generate Crypto op data structure */
5648 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5649 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5650 TEST_ASSERT_NOT_NULL(ut_params->op,
5651 "Failed to allocate symmetric crypto operation struct");
5653 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5656 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5659 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5660 ut_params->op), "failed to process sym crypto op");
5662 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5663 "crypto op processing failed");
5665 if (ut_params->op->sym->m_dst) {
5666 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5667 uint8_t *, plaintext_pad_len);
5669 auth_tag = plaintext + plaintext_pad_len;
5672 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5674 test_case->auth_tag.data,
5675 test_case->auth_tag.len,
5676 "HMAC_MD5 generated tag not as expected");
5678 return TEST_SUCCESS;
5682 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5686 struct crypto_testsuite_params *ts_params = &testsuite_params;
5687 struct crypto_unittest_params *ut_params = &unittest_params;
5689 if (MD5_HMAC_create_session(ts_params, ut_params,
5690 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5694 /* Generate Crypto op data structure */
5695 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5696 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5697 TEST_ASSERT_NOT_NULL(ut_params->op,
5698 "Failed to allocate symmetric crypto operation struct");
5700 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5703 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5704 ut_params->op), "failed to process sym crypto op");
5706 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5707 "HMAC_MD5 crypto op processing failed");
5709 return TEST_SUCCESS;
5713 test_MD5_HMAC_generate_case_1(void)
5715 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5719 test_MD5_HMAC_verify_case_1(void)
5721 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5725 test_MD5_HMAC_generate_case_2(void)
5727 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5731 test_MD5_HMAC_verify_case_2(void)
5733 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5737 test_multi_session(void)
5739 struct crypto_testsuite_params *ts_params = &testsuite_params;
5740 struct crypto_unittest_params *ut_params = &unittest_params;
5742 struct rte_cryptodev_info dev_info;
5743 struct rte_cryptodev_sym_session **sessions;
5747 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5748 aes_cbc_key, hmac_sha512_key);
5751 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5753 sessions = rte_malloc(NULL,
5754 (sizeof(struct rte_cryptodev_sym_session *) *
5755 dev_info.sym.max_nb_sessions) + 1, 0);
5757 /* Create multiple crypto sessions*/
5758 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5759 sessions[i] = rte_cryptodev_sym_session_create(
5760 ts_params->valid_devs[0],
5761 &ut_params->auth_xform);
5762 TEST_ASSERT_NOT_NULL(sessions[i],
5763 "Session creation failed at session number %u",
5766 /* Attempt to send a request on each session */
5767 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5771 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5772 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5774 "Failed to perform decrypt on request number %u.", i);
5775 /* free crypto operation structure */
5777 rte_crypto_op_free(ut_params->op);
5780 * free mbuf - both obuf and ibuf are usually the same,
5781 * so check if they point at the same address is necessary,
5782 * to avoid freeing the mbuf twice.
5784 if (ut_params->obuf) {
5785 rte_pktmbuf_free(ut_params->obuf);
5786 if (ut_params->ibuf == ut_params->obuf)
5787 ut_params->ibuf = 0;
5788 ut_params->obuf = 0;
5790 if (ut_params->ibuf) {
5791 rte_pktmbuf_free(ut_params->ibuf);
5792 ut_params->ibuf = 0;
5796 /* Next session create should fail */
5797 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5798 &ut_params->auth_xform);
5799 TEST_ASSERT_NULL(sessions[i],
5800 "Session creation succeeded unexpectedly!");
5802 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5803 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5808 return TEST_SUCCESS;
5811 struct multi_session_params {
5812 struct crypto_unittest_params ut_params;
5813 uint8_t *cipher_key;
5815 const uint8_t *cipher;
5816 const uint8_t *digest;
5820 #define MB_SESSION_NUMBER 3
5823 test_multi_session_random_usage(void)
5825 struct crypto_testsuite_params *ts_params = &testsuite_params;
5826 struct rte_cryptodev_info dev_info;
5827 struct rte_cryptodev_sym_session **sessions;
5829 struct multi_session_params ut_paramz[] = {
5832 .cipher_key = ms_aes_cbc_key0,
5833 .hmac_key = ms_hmac_key0,
5834 .cipher = ms_aes_cbc_cipher0,
5835 .digest = ms_hmac_digest0,
5836 .iv = ms_aes_cbc_iv0
5839 .cipher_key = ms_aes_cbc_key1,
5840 .hmac_key = ms_hmac_key1,
5841 .cipher = ms_aes_cbc_cipher1,
5842 .digest = ms_hmac_digest1,
5843 .iv = ms_aes_cbc_iv1
5846 .cipher_key = ms_aes_cbc_key2,
5847 .hmac_key = ms_hmac_key2,
5848 .cipher = ms_aes_cbc_cipher2,
5849 .digest = ms_hmac_digest2,
5850 .iv = ms_aes_cbc_iv2
5855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5857 sessions = rte_malloc(NULL,
5858 (sizeof(struct rte_cryptodev_sym_session *)
5859 * dev_info.sym.max_nb_sessions) + 1, 0);
5861 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5862 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5863 sizeof(struct crypto_unittest_params));
5865 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5866 &ut_paramz[i].ut_params,
5867 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5869 /* Create multiple crypto sessions*/
5870 sessions[i] = rte_cryptodev_sym_session_create(
5871 ts_params->valid_devs[0],
5872 &ut_paramz[i].ut_params.auth_xform);
5874 TEST_ASSERT_NOT_NULL(sessions[i],
5875 "Session creation failed at session number %u",
5881 for (i = 0; i < 40000; i++) {
5883 j = rand() % MB_SESSION_NUMBER;
5885 TEST_ASSERT_SUCCESS(
5886 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5888 &ut_paramz[j].ut_params,
5889 ts_params, ut_paramz[j].cipher,
5890 ut_paramz[j].digest,
5892 "Failed to perform decrypt on request number %u.", i);
5894 if (ut_paramz[j].ut_params.op)
5895 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5898 * free mbuf - both obuf and ibuf are usually the same,
5899 * so check if they point at the same address is necessary,
5900 * to avoid freeing the mbuf twice.
5902 if (ut_paramz[j].ut_params.obuf) {
5903 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5904 if (ut_paramz[j].ut_params.ibuf
5905 == ut_paramz[j].ut_params.obuf)
5906 ut_paramz[j].ut_params.ibuf = 0;
5907 ut_paramz[j].ut_params.obuf = 0;
5909 if (ut_paramz[j].ut_params.ibuf) {
5910 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5911 ut_paramz[j].ut_params.ibuf = 0;
5915 for (i = 0; i < MB_SESSION_NUMBER; i++)
5916 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5921 return TEST_SUCCESS;
5925 test_null_cipher_only_operation(void)
5927 struct crypto_testsuite_params *ts_params = &testsuite_params;
5928 struct crypto_unittest_params *ut_params = &unittest_params;
5930 /* Generate test mbuf data and space for digest */
5931 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5932 catch_22_quote, QUOTE_512_BYTES, 0);
5934 /* Setup Cipher Parameters */
5935 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5936 ut_params->cipher_xform.next = NULL;
5938 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5939 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5941 /* Create Crypto session*/
5942 ut_params->sess = rte_cryptodev_sym_session_create(
5943 ts_params->valid_devs[0], &ut_params->cipher_xform);
5944 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5946 /* Generate Crypto op data structure */
5947 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5948 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5949 TEST_ASSERT_NOT_NULL(ut_params->op,
5950 "Failed to allocate symmetric crypto operation struct");
5952 /* Set crypto operation data parameters */
5953 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5955 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5957 /* set crypto operation source mbuf */
5958 sym_op->m_src = ut_params->ibuf;
5960 sym_op->cipher.data.offset = 0;
5961 sym_op->cipher.data.length = QUOTE_512_BYTES;
5963 /* Process crypto operation */
5964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5966 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5968 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5969 "crypto operation processing failed");
5972 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5973 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5976 "Ciphertext data not as expected");
5978 return TEST_SUCCESS;
5982 test_null_auth_only_operation(void)
5984 struct crypto_testsuite_params *ts_params = &testsuite_params;
5985 struct crypto_unittest_params *ut_params = &unittest_params;
5987 /* Generate test mbuf data and space for digest */
5988 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5989 catch_22_quote, QUOTE_512_BYTES, 0);
5991 /* Setup HMAC Parameters */
5992 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5993 ut_params->auth_xform.next = NULL;
5995 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5996 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5998 /* Create Crypto session*/
5999 ut_params->sess = rte_cryptodev_sym_session_create(
6000 ts_params->valid_devs[0], &ut_params->auth_xform);
6001 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6003 /* Generate Crypto op data structure */
6004 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6005 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6006 TEST_ASSERT_NOT_NULL(ut_params->op,
6007 "Failed to allocate symmetric crypto operation struct");
6009 /* Set crypto operation data parameters */
6010 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6012 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6014 sym_op->m_src = ut_params->ibuf;
6016 sym_op->auth.data.offset = 0;
6017 sym_op->auth.data.length = QUOTE_512_BYTES;
6019 /* Process crypto operation */
6020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6022 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6024 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6025 "crypto operation processing failed");
6027 return TEST_SUCCESS;
6031 test_null_cipher_auth_operation(void)
6033 struct crypto_testsuite_params *ts_params = &testsuite_params;
6034 struct crypto_unittest_params *ut_params = &unittest_params;
6036 /* Generate test mbuf data and space for digest */
6037 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6038 catch_22_quote, QUOTE_512_BYTES, 0);
6040 /* Setup Cipher Parameters */
6041 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6042 ut_params->cipher_xform.next = &ut_params->auth_xform;
6044 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6045 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6047 /* Setup HMAC Parameters */
6048 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6049 ut_params->auth_xform.next = NULL;
6051 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6052 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6054 /* Create Crypto session*/
6055 ut_params->sess = rte_cryptodev_sym_session_create(
6056 ts_params->valid_devs[0], &ut_params->cipher_xform);
6057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6059 /* Generate Crypto op data structure */
6060 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6061 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6062 TEST_ASSERT_NOT_NULL(ut_params->op,
6063 "Failed to allocate symmetric crypto operation struct");
6065 /* Set crypto operation data parameters */
6066 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6068 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6070 sym_op->m_src = ut_params->ibuf;
6072 sym_op->cipher.data.offset = 0;
6073 sym_op->cipher.data.length = QUOTE_512_BYTES;
6075 sym_op->auth.data.offset = 0;
6076 sym_op->auth.data.length = QUOTE_512_BYTES;
6078 /* Process crypto operation */
6079 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6081 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6083 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6084 "crypto operation processing failed");
6087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6088 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6091 "Ciphertext data not as expected");
6093 return TEST_SUCCESS;
6097 test_null_auth_cipher_operation(void)
6099 struct crypto_testsuite_params *ts_params = &testsuite_params;
6100 struct crypto_unittest_params *ut_params = &unittest_params;
6102 /* Generate test mbuf data and space for digest */
6103 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6104 catch_22_quote, QUOTE_512_BYTES, 0);
6106 /* Setup Cipher Parameters */
6107 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6108 ut_params->cipher_xform.next = NULL;
6110 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6111 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6113 /* Setup HMAC Parameters */
6114 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6115 ut_params->auth_xform.next = &ut_params->cipher_xform;
6117 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6118 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6120 /* Create Crypto session*/
6121 ut_params->sess = rte_cryptodev_sym_session_create(
6122 ts_params->valid_devs[0], &ut_params->cipher_xform);
6123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6125 /* Generate Crypto op data structure */
6126 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6127 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6128 TEST_ASSERT_NOT_NULL(ut_params->op,
6129 "Failed to allocate symmetric crypto operation struct");
6131 /* Set crypto operation data parameters */
6132 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6134 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6136 sym_op->m_src = ut_params->ibuf;
6138 sym_op->cipher.data.offset = 0;
6139 sym_op->cipher.data.length = QUOTE_512_BYTES;
6141 sym_op->auth.data.offset = 0;
6142 sym_op->auth.data.length = QUOTE_512_BYTES;
6144 /* Process crypto operation */
6145 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6147 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6149 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6150 "crypto operation processing failed");
6153 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6154 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6157 "Ciphertext data not as expected");
6159 return TEST_SUCCESS;
6164 test_null_invalid_operation(void)
6166 struct crypto_testsuite_params *ts_params = &testsuite_params;
6167 struct crypto_unittest_params *ut_params = &unittest_params;
6169 /* Setup Cipher Parameters */
6170 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6171 ut_params->cipher_xform.next = NULL;
6173 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6174 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6176 /* Create Crypto session*/
6177 ut_params->sess = rte_cryptodev_sym_session_create(
6178 ts_params->valid_devs[0], &ut_params->cipher_xform);
6179 TEST_ASSERT_NULL(ut_params->sess,
6180 "Session creation succeeded unexpectedly");
6183 /* Setup HMAC Parameters */
6184 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6185 ut_params->auth_xform.next = NULL;
6187 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6188 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6190 /* Create Crypto session*/
6191 ut_params->sess = rte_cryptodev_sym_session_create(
6192 ts_params->valid_devs[0], &ut_params->auth_xform);
6193 TEST_ASSERT_NULL(ut_params->sess,
6194 "Session creation succeeded unexpectedly");
6196 return TEST_SUCCESS;
6200 #define NULL_BURST_LENGTH (32)
6203 test_null_burst_operation(void)
6205 struct crypto_testsuite_params *ts_params = &testsuite_params;
6206 struct crypto_unittest_params *ut_params = &unittest_params;
6208 unsigned i, burst_len = NULL_BURST_LENGTH;
6210 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6211 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6213 /* Setup Cipher Parameters */
6214 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6215 ut_params->cipher_xform.next = &ut_params->auth_xform;
6217 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6218 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6220 /* Setup HMAC Parameters */
6221 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6222 ut_params->auth_xform.next = NULL;
6224 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6225 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6227 /* Create Crypto session*/
6228 ut_params->sess = rte_cryptodev_sym_session_create(
6229 ts_params->valid_devs[0], &ut_params->cipher_xform);
6230 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6232 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6233 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6234 burst_len, "failed to generate burst of crypto ops");
6236 /* Generate an operation for each mbuf in burst */
6237 for (i = 0; i < burst_len; i++) {
6238 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6240 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6242 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6246 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6248 burst[i]->sym->m_src = m;
6251 /* Process crypto operation */
6252 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6253 0, burst, burst_len),
6255 "Error enqueuing burst");
6257 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6258 0, burst_dequeued, burst_len),
6260 "Error dequeuing burst");
6263 for (i = 0; i < burst_len; i++) {
6265 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6266 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6268 "data not as expected");
6270 rte_pktmbuf_free(burst[i]->sym->m_src);
6271 rte_crypto_op_free(burst[i]);
6274 return TEST_SUCCESS;
6278 generate_gmac_large_plaintext(uint8_t *data)
6282 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6283 memcpy(&data[i], &data[0], 32);
6287 create_gmac_operation(enum rte_crypto_auth_operation op,
6288 const struct gmac_test_data *tdata)
6290 struct crypto_testsuite_params *ts_params = &testsuite_params;
6291 struct crypto_unittest_params *ut_params = &unittest_params;
6292 struct rte_crypto_sym_op *sym_op;
6294 unsigned aad_pad_len;
6296 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6299 * Runtime generate the large plain text instead of use hard code
6300 * plain text vector. It is done to avoid create huge source file
6301 * with the test vector.
6303 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6304 generate_gmac_large_plaintext(tdata->aad.data);
6306 /* Generate Crypto op data structure */
6307 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6308 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6309 TEST_ASSERT_NOT_NULL(ut_params->op,
6310 "Failed to allocate symmetric crypto operation struct");
6312 sym_op = ut_params->op->sym;
6313 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6315 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6316 "no room to append aad");
6318 sym_op->auth.aad.phys_addr =
6319 rte_pktmbuf_mtophys(ut_params->ibuf);
6320 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6322 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6323 ut_params->ibuf, tdata->gmac_tag.len);
6324 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6325 "no room to append digest");
6327 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6328 ut_params->ibuf, aad_pad_len);
6329 sym_op->auth.digest.length = tdata->gmac_tag.len;
6331 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6332 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6333 tdata->gmac_tag.len);
6334 TEST_HEXDUMP(stdout, "digest:",
6335 sym_op->auth.digest.data,
6336 sym_op->auth.digest.length);
6339 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6340 uint8_t *, IV_OFFSET);
6342 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6344 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6346 sym_op->cipher.data.length = 0;
6347 sym_op->cipher.data.offset = 0;
6349 sym_op->auth.data.offset = 0;
6350 sym_op->auth.data.length = 0;
6355 static int create_gmac_session(uint8_t dev_id,
6356 enum rte_crypto_cipher_operation op,
6357 const struct gmac_test_data *tdata,
6358 enum rte_crypto_auth_operation auth_op)
6360 uint8_t cipher_key[tdata->key.len];
6362 struct crypto_unittest_params *ut_params = &unittest_params;
6364 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6366 /* For GMAC we setup cipher parameters */
6367 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6368 ut_params->cipher_xform.next = NULL;
6369 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6370 ut_params->cipher_xform.cipher.op = op;
6371 ut_params->cipher_xform.cipher.key.data = cipher_key;
6372 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6373 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6374 ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
6376 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6377 ut_params->auth_xform.next = NULL;
6379 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6380 ut_params->auth_xform.auth.op = auth_op;
6381 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6382 ut_params->auth_xform.auth.add_auth_data_length = tdata->aad.len;
6383 ut_params->auth_xform.auth.key.length = 0;
6384 ut_params->auth_xform.auth.key.data = NULL;
6386 ut_params->cipher_xform.next = &ut_params->auth_xform;
6388 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6389 &ut_params->cipher_xform);
6391 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6397 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6399 struct crypto_testsuite_params *ts_params = &testsuite_params;
6400 struct crypto_unittest_params *ut_params = &unittest_params;
6404 uint8_t *auth_tag, *p;
6405 uint16_t aad_pad_len;
6407 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6408 "No GMAC length in the source data");
6410 retval = create_gmac_session(ts_params->valid_devs[0],
6411 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6412 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6417 if (tdata->aad.len > MBUF_SIZE)
6418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6421 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6422 "Failed to allocate input buffer in mempool");
6424 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6425 rte_pktmbuf_tailroom(ut_params->ibuf));
6427 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6429 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6431 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6437 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6439 ut_params->op->sym->m_src = ut_params->ibuf;
6441 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6442 ut_params->op), "failed to process sym crypto op");
6444 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6445 "crypto op processing failed");
6447 if (ut_params->op->sym->m_dst) {
6448 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6449 uint8_t *, aad_pad_len);
6451 auth_tag = p + aad_pad_len;
6454 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6456 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6458 tdata->gmac_tag.data,
6459 tdata->gmac_tag.len,
6460 "GMAC Generated auth tag not as expected");
6466 test_AES_GMAC_authentication_test_case_1(void)
6468 return test_AES_GMAC_authentication(&gmac_test_case_1);
6472 test_AES_GMAC_authentication_test_case_2(void)
6474 return test_AES_GMAC_authentication(&gmac_test_case_2);
6478 test_AES_GMAC_authentication_test_case_3(void)
6480 return test_AES_GMAC_authentication(&gmac_test_case_3);
6484 test_AES_GMAC_authentication_test_case_4(void)
6486 return test_AES_GMAC_authentication(&gmac_test_case_4);
6490 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6492 struct crypto_testsuite_params *ts_params = &testsuite_params;
6493 struct crypto_unittest_params *ut_params = &unittest_params;
6496 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6497 "No GMAC length in the source data");
6499 retval = create_gmac_session(ts_params->valid_devs[0],
6500 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6501 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6506 if (tdata->aad.len > MBUF_SIZE)
6507 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6509 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6510 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6511 "Failed to allocate input buffer in mempool");
6513 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6514 rte_pktmbuf_tailroom(ut_params->ibuf));
6516 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6522 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6524 ut_params->op->sym->m_src = ut_params->ibuf;
6526 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6527 ut_params->op), "failed to process sym crypto op");
6529 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6530 "crypto op processing failed");
6537 test_AES_GMAC_authentication_verify_test_case_1(void)
6539 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6543 test_AES_GMAC_authentication_verify_test_case_2(void)
6545 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6549 test_AES_GMAC_authentication_verify_test_case_3(void)
6551 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6555 test_AES_GMAC_authentication_verify_test_case_4(void)
6557 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6560 struct test_crypto_vector {
6561 enum rte_crypto_cipher_algorithm crypto_algo;
6574 const uint8_t *data;
6579 const uint8_t *data;
6583 enum rte_crypto_auth_algorithm auth_algo;
6591 const uint8_t *data;
6601 static const struct test_crypto_vector
6602 hmac_sha1_test_crypto_vector = {
6603 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6605 .data = plaintext_hash,
6610 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6611 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6612 0xDE, 0xF4, 0xDE, 0xAD
6618 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6619 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6620 0x3F, 0x91, 0x64, 0x59
6626 static const struct test_crypto_vector
6627 aes128_gmac_test_vector = {
6628 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6629 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6631 .data = plaintext_hash,
6636 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6637 0x08, 0x09, 0x0A, 0x0B
6643 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6644 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6650 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6651 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6657 static const struct test_crypto_vector
6658 aes128cbc_hmac_sha1_test_vector = {
6659 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6662 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6663 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6669 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6670 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6675 .data = plaintext_hash,
6679 .data = ciphertext512_aes128cbc,
6682 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6685 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6686 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6687 0xDE, 0xF4, 0xDE, 0xAD
6693 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6694 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6695 0x18, 0x8C, 0x1D, 0x32
6702 data_corruption(uint8_t *data)
6708 tag_corruption(uint8_t *data, unsigned int tag_offset)
6710 data[tag_offset] += 1;
6714 create_auth_session(struct crypto_unittest_params *ut_params,
6716 const struct test_crypto_vector *reference,
6717 enum rte_crypto_auth_operation auth_op)
6719 uint8_t auth_key[reference->auth_key.len + 1];
6721 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6723 /* Setup Authentication Parameters */
6724 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6725 ut_params->auth_xform.auth.op = auth_op;
6726 ut_params->auth_xform.next = NULL;
6727 ut_params->auth_xform.auth.algo = reference->auth_algo;
6728 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6729 ut_params->auth_xform.auth.key.data = auth_key;
6730 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6731 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6733 /* Create Crypto session*/
6734 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6735 &ut_params->auth_xform);
6737 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6743 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6745 const struct test_crypto_vector *reference,
6746 enum rte_crypto_auth_operation auth_op,
6747 enum rte_crypto_cipher_operation cipher_op)
6749 uint8_t cipher_key[reference->cipher_key.len + 1];
6750 uint8_t auth_key[reference->auth_key.len + 1];
6752 memcpy(cipher_key, reference->cipher_key.data,
6753 reference->cipher_key.len);
6754 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6756 /* Setup Authentication Parameters */
6757 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6758 ut_params->auth_xform.auth.op = auth_op;
6759 ut_params->auth_xform.next = &ut_params->cipher_xform;
6760 ut_params->auth_xform.auth.algo = reference->auth_algo;
6761 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6762 ut_params->auth_xform.auth.key.data = auth_key;
6763 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6764 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6766 /* Setup Cipher Parameters */
6767 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6768 ut_params->cipher_xform.next = NULL;
6769 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6770 ut_params->cipher_xform.cipher.op = cipher_op;
6771 ut_params->cipher_xform.cipher.key.data = cipher_key;
6772 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6773 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6774 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6776 /* Create Crypto session*/
6777 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6778 &ut_params->auth_xform);
6780 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6786 create_auth_operation(struct crypto_testsuite_params *ts_params,
6787 struct crypto_unittest_params *ut_params,
6788 const struct test_crypto_vector *reference,
6789 unsigned int auth_generate)
6791 /* Generate Crypto op data structure */
6792 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6793 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6794 TEST_ASSERT_NOT_NULL(ut_params->op,
6795 "Failed to allocate pktmbuf offload");
6797 /* Set crypto operation data parameters */
6798 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6800 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6802 /* set crypto operation source mbuf */
6803 sym_op->m_src = ut_params->ibuf;
6806 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6807 ut_params->ibuf, reference->digest.len);
6809 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6810 "no room to append auth tag");
6812 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6813 ut_params->ibuf, reference->plaintext.len);
6814 sym_op->auth.digest.length = reference->digest.len;
6817 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6819 memcpy(sym_op->auth.digest.data,
6820 reference->digest.data,
6821 reference->digest.len);
6823 TEST_HEXDUMP(stdout, "digest:",
6824 sym_op->auth.digest.data,
6825 sym_op->auth.digest.length);
6827 sym_op->auth.data.length = reference->plaintext.len;
6828 sym_op->auth.data.offset = 0;
6834 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6835 struct crypto_unittest_params *ut_params,
6836 const struct test_crypto_vector *reference,
6837 unsigned int auth_generate)
6839 /* Generate Crypto op data structure */
6840 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6841 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6842 TEST_ASSERT_NOT_NULL(ut_params->op,
6843 "Failed to allocate pktmbuf offload");
6845 /* Set crypto operation data parameters */
6846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6848 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6850 /* set crypto operation source mbuf */
6851 sym_op->m_src = ut_params->ibuf;
6854 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6855 reference->aad.len);
6856 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6857 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6859 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6861 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6864 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6865 ut_params->ibuf, reference->digest.len);
6867 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6868 "no room to append auth tag");
6870 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6871 ut_params->ibuf, reference->ciphertext.len);
6872 sym_op->auth.digest.length = reference->digest.len;
6875 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6877 memcpy(sym_op->auth.digest.data,
6878 reference->digest.data,
6879 reference->digest.len);
6881 TEST_HEXDUMP(stdout, "digest:",
6882 sym_op->auth.digest.data,
6883 sym_op->auth.digest.length);
6885 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6886 reference->iv.data, reference->iv.len);
6888 sym_op->cipher.data.length = 0;
6889 sym_op->cipher.data.offset = 0;
6891 sym_op->auth.data.length = 0;
6892 sym_op->auth.data.offset = 0;
6898 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6899 struct crypto_unittest_params *ut_params,
6900 const struct test_crypto_vector *reference,
6901 unsigned int auth_generate)
6903 /* Generate Crypto op data structure */
6904 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6905 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6906 TEST_ASSERT_NOT_NULL(ut_params->op,
6907 "Failed to allocate pktmbuf offload");
6909 /* Set crypto operation data parameters */
6910 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6912 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6914 /* set crypto operation source mbuf */
6915 sym_op->m_src = ut_params->ibuf;
6918 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6919 ut_params->ibuf, reference->digest.len);
6921 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6922 "no room to append auth tag");
6924 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6925 ut_params->ibuf, reference->ciphertext.len);
6926 sym_op->auth.digest.length = reference->digest.len;
6929 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6931 memcpy(sym_op->auth.digest.data,
6932 reference->digest.data,
6933 reference->digest.len);
6935 TEST_HEXDUMP(stdout, "digest:",
6936 sym_op->auth.digest.data,
6937 sym_op->auth.digest.length);
6939 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6940 reference->iv.data, reference->iv.len);
6942 sym_op->cipher.data.length = reference->ciphertext.len;
6943 sym_op->cipher.data.offset = 0;
6945 sym_op->auth.data.length = reference->ciphertext.len;
6946 sym_op->auth.data.offset = 0;
6952 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6953 struct crypto_unittest_params *ut_params,
6954 const struct test_crypto_vector *reference)
6956 return create_auth_operation(ts_params, ut_params, reference, 0);
6960 create_auth_verify_GMAC_operation(
6961 struct crypto_testsuite_params *ts_params,
6962 struct crypto_unittest_params *ut_params,
6963 const struct test_crypto_vector *reference)
6965 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6969 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6970 struct crypto_unittest_params *ut_params,
6971 const struct test_crypto_vector *reference)
6973 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6977 test_authentication_verify_fail_when_data_corruption(
6978 struct crypto_testsuite_params *ts_params,
6979 struct crypto_unittest_params *ut_params,
6980 const struct test_crypto_vector *reference,
6981 unsigned int data_corrupted)
6987 /* Create session */
6988 retval = create_auth_session(ut_params,
6989 ts_params->valid_devs[0],
6991 RTE_CRYPTO_AUTH_OP_VERIFY);
6995 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6996 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6997 "Failed to allocate input buffer in mempool");
6999 /* clear mbuf payload */
7000 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7001 rte_pktmbuf_tailroom(ut_params->ibuf));
7003 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7004 reference->plaintext.len);
7005 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7006 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7008 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7010 /* Create operation */
7011 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7017 data_corruption(plaintext);
7019 tag_corruption(plaintext, reference->plaintext.len);
7021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7024 TEST_ASSERT_EQUAL(ut_params->op->status,
7025 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7026 "authentication not failed");
7028 ut_params->obuf = ut_params->op->sym->m_src;
7029 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7035 test_authentication_verify_GMAC_fail_when_corruption(
7036 struct crypto_testsuite_params *ts_params,
7037 struct crypto_unittest_params *ut_params,
7038 const struct test_crypto_vector *reference,
7039 unsigned int data_corrupted)
7043 /* Create session */
7044 retval = create_auth_cipher_session(ut_params,
7045 ts_params->valid_devs[0],
7047 RTE_CRYPTO_AUTH_OP_VERIFY,
7048 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7052 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7053 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7054 "Failed to allocate input buffer in mempool");
7056 /* clear mbuf payload */
7057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7058 rte_pktmbuf_tailroom(ut_params->ibuf));
7060 /* Create operation */
7061 retval = create_auth_verify_GMAC_operation(ts_params,
7069 data_corruption(ut_params->op->sym->auth.aad.data);
7071 tag_corruption(ut_params->op->sym->auth.aad.data,
7072 reference->aad.len);
7074 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7076 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7077 TEST_ASSERT_EQUAL(ut_params->op->status,
7078 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7079 "authentication not failed");
7081 ut_params->obuf = ut_params->op->sym->m_src;
7082 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7088 test_authenticated_decryption_fail_when_corruption(
7089 struct crypto_testsuite_params *ts_params,
7090 struct crypto_unittest_params *ut_params,
7091 const struct test_crypto_vector *reference,
7092 unsigned int data_corrupted)
7096 uint8_t *ciphertext;
7098 /* Create session */
7099 retval = create_auth_cipher_session(ut_params,
7100 ts_params->valid_devs[0],
7102 RTE_CRYPTO_AUTH_OP_VERIFY,
7103 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7107 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7108 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7109 "Failed to allocate input buffer in mempool");
7111 /* clear mbuf payload */
7112 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7113 rte_pktmbuf_tailroom(ut_params->ibuf));
7115 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7116 reference->ciphertext.len);
7117 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7118 memcpy(ciphertext, reference->ciphertext.data,
7119 reference->ciphertext.len);
7121 /* Create operation */
7122 retval = create_cipher_auth_verify_operation(ts_params,
7130 data_corruption(ciphertext);
7132 tag_corruption(ciphertext, reference->ciphertext.len);
7134 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7137 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7138 TEST_ASSERT_EQUAL(ut_params->op->status,
7139 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7140 "authentication not failed");
7142 ut_params->obuf = ut_params->op->sym->m_src;
7143 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7149 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7150 const struct gcm_test_data *tdata,
7151 void *digest_mem, uint64_t digest_phys)
7153 struct crypto_testsuite_params *ts_params = &testsuite_params;
7154 struct crypto_unittest_params *ut_params = &unittest_params;
7156 const unsigned int auth_tag_len = tdata->auth_tag.len;
7157 const unsigned int iv_len = tdata->iv.len;
7158 const unsigned int aad_len = tdata->aad.len;
7160 /* Generate Crypto op data structure */
7161 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7162 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7163 TEST_ASSERT_NOT_NULL(ut_params->op,
7164 "Failed to allocate symmetric crypto operation struct");
7166 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7168 sym_op->auth.digest.data = digest_mem;
7170 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7171 "no room to append digest");
7173 sym_op->auth.digest.phys_addr = digest_phys;
7174 sym_op->auth.digest.length = auth_tag_len;
7176 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7177 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7179 TEST_HEXDUMP(stdout, "digest:",
7180 sym_op->auth.digest.data,
7181 sym_op->auth.digest.length);
7184 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7185 uint8_t *, IV_OFFSET);
7187 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7189 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7190 ut_params->ibuf, aad_len);
7191 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7192 "no room to prepend aad");
7193 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7196 memset(sym_op->auth.aad.data, 0, aad_len);
7197 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7199 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7200 TEST_HEXDUMP(stdout, "aad:",
7201 sym_op->auth.aad.data, aad_len);
7203 sym_op->cipher.data.length = tdata->plaintext.len;
7204 sym_op->cipher.data.offset = aad_len;
7206 sym_op->auth.data.offset = aad_len;
7207 sym_op->auth.data.length = tdata->plaintext.len;
7212 #define SGL_MAX_NO 16
7215 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7216 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7218 struct crypto_testsuite_params *ts_params = &testsuite_params;
7219 struct crypto_unittest_params *ut_params = &unittest_params;
7220 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7223 int to_trn_tbl[SGL_MAX_NO];
7225 unsigned int trn_data = 0;
7226 uint8_t *plaintext, *ciphertext, *auth_tag;
7228 if (fragsz > tdata->plaintext.len)
7229 fragsz = tdata->plaintext.len;
7231 uint16_t plaintext_len = fragsz;
7232 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7234 if (fragsz_oop > tdata->plaintext.len)
7235 frag_size_oop = tdata->plaintext.len;
7238 void *digest_mem = NULL;
7240 uint32_t prepend_len = tdata->aad.len;
7242 if (tdata->plaintext.len % fragsz != 0) {
7243 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7246 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7251 * For out-op-place we need to alloc another mbuf
7254 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7255 rte_pktmbuf_append(ut_params->obuf,
7256 frag_size_oop + prepend_len);
7257 buf_oop = ut_params->obuf;
7260 /* Create GCM session */
7261 retval = create_gcm_session(ts_params->valid_devs[0],
7262 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7263 tdata->key.data, tdata->key.len,
7264 tdata->aad.len, tdata->auth_tag.len,
7266 RTE_CRYPTO_AUTH_OP_GENERATE);
7270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7272 /* clear mbuf payload */
7273 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7274 rte_pktmbuf_tailroom(ut_params->ibuf));
7276 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7279 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7281 trn_data += plaintext_len;
7283 buf = ut_params->ibuf;
7286 * Loop until no more fragments
7289 while (trn_data < tdata->plaintext.len) {
7291 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7292 (tdata->plaintext.len - trn_data) : fragsz;
7294 to_trn_tbl[ecx++] = to_trn;
7296 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7299 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7300 rte_pktmbuf_tailroom(buf));
7303 if (oop && !fragsz_oop) {
7304 buf_last_oop = buf_oop->next =
7305 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7306 buf_oop = buf_oop->next;
7307 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7308 0, rte_pktmbuf_tailroom(buf_oop));
7309 rte_pktmbuf_append(buf_oop, to_trn);
7312 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7315 memcpy(plaintext, tdata->plaintext.data + trn_data,
7318 if (trn_data == tdata->plaintext.len) {
7321 digest_mem = rte_pktmbuf_append(buf_oop,
7322 tdata->auth_tag.len);
7324 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7325 tdata->auth_tag.len);
7329 uint64_t digest_phys = 0;
7331 ut_params->ibuf->nb_segs = segs;
7334 if (fragsz_oop && oop) {
7338 if (frag_size_oop == tdata->plaintext.len) {
7339 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7340 tdata->auth_tag.len);
7342 digest_phys = rte_pktmbuf_mtophys_offset(
7344 tdata->plaintext.len + prepend_len);
7347 trn_data = frag_size_oop;
7348 while (trn_data < tdata->plaintext.len) {
7351 (tdata->plaintext.len - trn_data <
7353 (tdata->plaintext.len - trn_data) :
7356 to_trn_tbl[ecx++] = to_trn;
7358 buf_last_oop = buf_oop->next =
7359 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7360 buf_oop = buf_oop->next;
7361 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7362 0, rte_pktmbuf_tailroom(buf_oop));
7363 rte_pktmbuf_append(buf_oop, to_trn);
7367 if (trn_data == tdata->plaintext.len) {
7368 digest_mem = rte_pktmbuf_append(buf_oop,
7369 tdata->auth_tag.len);
7373 ut_params->obuf->nb_segs = segs;
7377 * Place digest at the end of the last buffer
7380 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7381 if (oop && buf_last_oop)
7382 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7384 if (!digest_mem && !oop) {
7385 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7386 + tdata->auth_tag.len);
7387 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7388 tdata->plaintext.len);
7391 /* Create GCM opertaion */
7392 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7393 tdata, digest_mem, digest_phys);
7398 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7400 ut_params->op->sym->m_src = ut_params->ibuf;
7402 ut_params->op->sym->m_dst = ut_params->obuf;
7404 /* Process crypto operation */
7405 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7406 ut_params->op), "failed to process sym crypto op");
7408 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7409 "crypto op processing failed");
7412 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7413 uint8_t *, prepend_len);
7415 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7416 uint8_t *, prepend_len);
7420 fragsz = fragsz_oop;
7422 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7424 tdata->ciphertext.data,
7426 "GCM Ciphertext data not as expected");
7428 buf = ut_params->op->sym->m_src->next;
7430 buf = ut_params->op->sym->m_dst->next;
7432 unsigned int off = fragsz;
7436 ciphertext = rte_pktmbuf_mtod(buf,
7439 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7441 tdata->ciphertext.data + off,
7443 "GCM Ciphertext data not as expected");
7445 off += to_trn_tbl[ecx++];
7449 auth_tag = digest_mem;
7450 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7452 tdata->auth_tag.data,
7453 tdata->auth_tag.len,
7454 "GCM Generated auth tag not as expected");
7460 #define OUT_OF_PLACE 1
7463 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7465 return test_AES_GCM_authenticated_encryption_SGL(
7466 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7470 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7472 return test_AES_GCM_authenticated_encryption_SGL(
7473 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7477 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7479 return test_AES_GCM_authenticated_encryption_SGL(
7480 &gcm_test_case_8, OUT_OF_PLACE, 400,
7481 gcm_test_case_8.plaintext.len);
7485 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7488 return test_AES_GCM_authenticated_encryption_SGL(
7489 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7493 test_authentication_verify_fail_when_data_corrupted(
7494 struct crypto_testsuite_params *ts_params,
7495 struct crypto_unittest_params *ut_params,
7496 const struct test_crypto_vector *reference)
7498 return test_authentication_verify_fail_when_data_corruption(
7499 ts_params, ut_params, reference, 1);
7503 test_authentication_verify_fail_when_tag_corrupted(
7504 struct crypto_testsuite_params *ts_params,
7505 struct crypto_unittest_params *ut_params,
7506 const struct test_crypto_vector *reference)
7508 return test_authentication_verify_fail_when_data_corruption(
7509 ts_params, ut_params, reference, 0);
7513 test_authentication_verify_GMAC_fail_when_data_corrupted(
7514 struct crypto_testsuite_params *ts_params,
7515 struct crypto_unittest_params *ut_params,
7516 const struct test_crypto_vector *reference)
7518 return test_authentication_verify_GMAC_fail_when_corruption(
7519 ts_params, ut_params, reference, 1);
7523 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7524 struct crypto_testsuite_params *ts_params,
7525 struct crypto_unittest_params *ut_params,
7526 const struct test_crypto_vector *reference)
7528 return test_authentication_verify_GMAC_fail_when_corruption(
7529 ts_params, ut_params, reference, 0);
7533 test_authenticated_decryption_fail_when_data_corrupted(
7534 struct crypto_testsuite_params *ts_params,
7535 struct crypto_unittest_params *ut_params,
7536 const struct test_crypto_vector *reference)
7538 return test_authenticated_decryption_fail_when_corruption(
7539 ts_params, ut_params, reference, 1);
7543 test_authenticated_decryption_fail_when_tag_corrupted(
7544 struct crypto_testsuite_params *ts_params,
7545 struct crypto_unittest_params *ut_params,
7546 const struct test_crypto_vector *reference)
7548 return test_authenticated_decryption_fail_when_corruption(
7549 ts_params, ut_params, reference, 0);
7553 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7555 return test_authentication_verify_fail_when_data_corrupted(
7556 &testsuite_params, &unittest_params,
7557 &hmac_sha1_test_crypto_vector);
7561 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7563 return test_authentication_verify_fail_when_tag_corrupted(
7564 &testsuite_params, &unittest_params,
7565 &hmac_sha1_test_crypto_vector);
7569 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7571 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7572 &testsuite_params, &unittest_params,
7573 &aes128_gmac_test_vector);
7577 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7579 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7580 &testsuite_params, &unittest_params,
7581 &aes128_gmac_test_vector);
7585 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7587 return test_authenticated_decryption_fail_when_data_corrupted(
7590 &aes128cbc_hmac_sha1_test_vector);
7594 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7596 return test_authenticated_decryption_fail_when_tag_corrupted(
7599 &aes128cbc_hmac_sha1_test_vector);
7602 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7604 /* global AESNI slave IDs for the scheduler test */
7605 uint8_t aesni_ids[2];
7608 test_scheduler_attach_slave_op(void)
7610 struct crypto_testsuite_params *ts_params = &testsuite_params;
7611 uint8_t sched_id = ts_params->valid_devs[0];
7612 uint32_t nb_devs, i, nb_devs_attached = 0;
7616 /* create 2 AESNI_MB if necessary */
7617 nb_devs = rte_cryptodev_count_devtype(
7618 RTE_CRYPTODEV_AESNI_MB_PMD);
7620 for (i = nb_devs; i < 2; i++) {
7621 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7622 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7624 ret = rte_vdev_init(vdev_name, NULL);
7626 TEST_ASSERT(ret == 0,
7627 "Failed to create instance %u of"
7629 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7633 /* attach 2 AESNI_MB cdevs */
7634 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7636 struct rte_cryptodev_info info;
7638 rte_cryptodev_info_get(i, &info);
7639 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7642 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7645 TEST_ASSERT(ret == 0,
7646 "Failed to attach device %u of pmd : %s", i,
7647 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7649 aesni_ids[nb_devs_attached] = (uint8_t)i;
7658 test_scheduler_detach_slave_op(void)
7660 struct crypto_testsuite_params *ts_params = &testsuite_params;
7661 uint8_t sched_id = ts_params->valid_devs[0];
7665 for (i = 0; i < 2; i++) {
7666 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7668 TEST_ASSERT(ret == 0,
7669 "Failed to detach device %u", aesni_ids[i]);
7676 test_scheduler_mode_op(void)
7678 struct crypto_testsuite_params *ts_params = &testsuite_params;
7679 uint8_t sched_id = ts_params->valid_devs[0];
7680 struct rte_cryptodev_scheduler_ops op = {0};
7681 struct rte_cryptodev_scheduler dummy_scheduler = {
7682 .description = "dummy scheduler to test mode",
7683 .name = "dummy scheduler",
7684 .mode = CDEV_SCHED_MODE_USERDEFINED,
7689 /* set user defined mode */
7690 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7692 TEST_ASSERT(ret == 0,
7693 "Failed to set cdev %u to user defined mode", sched_id);
7695 /* set round robin mode */
7696 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7697 CDEV_SCHED_MODE_ROUNDROBIN);
7698 TEST_ASSERT(ret == 0,
7699 "Failed to set cdev %u to round-robin mode", sched_id);
7700 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7701 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7707 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7708 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7709 .setup = testsuite_setup,
7710 .teardown = testsuite_teardown,
7711 .unit_test_cases = {
7712 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7713 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7714 TEST_CASE_ST(ut_setup, ut_teardown,
7715 test_AES_chain_scheduler_all),
7716 TEST_CASE_ST(ut_setup, ut_teardown,
7717 test_AES_cipheronly_scheduler_all),
7718 TEST_CASE_ST(ut_setup, ut_teardown,
7719 test_authonly_scheduler_all),
7720 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7721 TEST_CASES_END() /**< NULL terminate unit test array */
7725 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7727 static struct unit_test_suite cryptodev_qat_testsuite = {
7728 .suite_name = "Crypto QAT Unit Test Suite",
7729 .setup = testsuite_setup,
7730 .teardown = testsuite_teardown,
7731 .unit_test_cases = {
7732 TEST_CASE_ST(ut_setup, ut_teardown,
7733 test_device_configure_invalid_dev_id),
7734 TEST_CASE_ST(ut_setup, ut_teardown,
7735 test_device_configure_invalid_queue_pair_ids),
7736 TEST_CASE_ST(ut_setup, ut_teardown,
7737 test_queue_pair_descriptor_setup),
7738 TEST_CASE_ST(ut_setup, ut_teardown,
7739 test_multi_session),
7741 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_AES_cipheronly_qat_all),
7744 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7745 TEST_CASE_ST(ut_setup, ut_teardown,
7746 test_3DES_cipheronly_qat_all),
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_DES_cipheronly_qat_all),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_AES_docsis_qat_all),
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_DES_docsis_qat_all),
7753 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7755 /** AES GCM Authenticated Encryption */
7756 TEST_CASE_ST(ut_setup, ut_teardown,
7757 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7758 TEST_CASE_ST(ut_setup, ut_teardown,
7759 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7762 TEST_CASE_ST(ut_setup, ut_teardown,
7763 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7764 TEST_CASE_ST(ut_setup, ut_teardown,
7765 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7766 TEST_CASE_ST(ut_setup, ut_teardown,
7767 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7777 /** AES GCM Authenticated Decryption */
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7793 /** AES GMAC Authentication */
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_AES_GMAC_authentication_test_case_1),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_AES_GMAC_authentication_verify_test_case_1),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_AES_GMAC_authentication_test_case_2),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_AES_GMAC_authentication_verify_test_case_2),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_AES_GMAC_authentication_test_case_3),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_AES_GMAC_authentication_verify_test_case_3),
7807 /** SNOW 3G encrypt only (UEA2) */
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_snow3g_encryption_test_case_1),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_snow3g_encryption_test_case_2),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_snow3g_encryption_test_case_3),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_snow3g_encryption_test_case_4),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_snow3g_encryption_test_case_5),
7819 TEST_CASE_ST(ut_setup, ut_teardown,
7820 test_snow3g_encryption_test_case_1_oop),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_snow3g_decryption_test_case_1_oop),
7824 /** SNOW 3G decrypt only (UEA2) */
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_snow3g_decryption_test_case_1),
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_snow3g_decryption_test_case_2),
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_snow3g_decryption_test_case_3),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_snow3g_decryption_test_case_4),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_snow3g_decryption_test_case_5),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_snow3g_hash_generate_test_case_1),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_snow3g_hash_generate_test_case_2),
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_snow3g_hash_generate_test_case_3),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_snow3g_hash_verify_test_case_1),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_snow3g_hash_verify_test_case_2),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_snow3g_hash_verify_test_case_3),
7847 TEST_CASE_ST(ut_setup, ut_teardown,
7848 test_snow3g_cipher_auth_test_case_1),
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_snow3g_auth_cipher_test_case_1),
7852 /** ZUC encrypt only (EEA3) */
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_zuc_encryption_test_case_1),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_zuc_encryption_test_case_2),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_zuc_encryption_test_case_3),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_zuc_encryption_test_case_4),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_zuc_encryption_test_case_5),
7864 /** ZUC authenticate (EIA3) */
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_zuc_hash_generate_test_case_6),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_zuc_hash_generate_test_case_7),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_zuc_hash_generate_test_case_8),
7872 /** ZUC alg-chain (EEA3/EIA3) */
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_zuc_cipher_auth_test_case_1),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_zuc_cipher_auth_test_case_2),
7878 /** HMAC_MD5 Authentication */
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_MD5_HMAC_generate_case_1),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_MD5_HMAC_verify_case_1),
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 test_MD5_HMAC_generate_case_2),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_MD5_HMAC_verify_case_2),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_null_auth_only_operation),
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 test_null_cipher_only_operation),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_null_cipher_auth_operation),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_null_auth_cipher_operation),
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 test_kasumi_hash_generate_test_case_6),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_kasumi_encryption_test_case_1),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_kasumi_encryption_test_case_3),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_kasumi_auth_cipher_test_case_1),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_kasumi_cipher_auth_test_case_1),
7911 /** Negative tests */
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7914 TEST_CASE_ST(ut_setup, ut_teardown,
7915 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 authentication_verify_AES128_GMAC_fail_data_corrupt),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7925 TEST_CASES_END() /**< NULL terminate unit test array */
7929 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7930 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7931 .setup = testsuite_setup,
7932 .teardown = testsuite_teardown,
7933 .unit_test_cases = {
7934 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7935 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7936 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7937 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7939 TEST_CASES_END() /**< NULL terminate unit test array */
7943 static struct unit_test_suite cryptodev_openssl_testsuite = {
7944 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7945 .setup = testsuite_setup,
7946 .teardown = testsuite_teardown,
7947 .unit_test_cases = {
7948 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_multi_session_random_usage),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_AES_chain_openssl_all),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_AES_cipheronly_openssl_all),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_3DES_chain_openssl_all),
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_3DES_cipheronly_openssl_all),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_DES_docsis_openssl_all),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_authonly_openssl_all),
7964 /** AES GCM Authenticated Encryption */
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7980 /** AES GCM Authenticated Decryption */
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7996 /** AES GMAC Authentication */
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_AES_GMAC_authentication_test_case_1),
7999 TEST_CASE_ST(ut_setup, ut_teardown,
8000 test_AES_GMAC_authentication_verify_test_case_1),
8001 TEST_CASE_ST(ut_setup, ut_teardown,
8002 test_AES_GMAC_authentication_test_case_2),
8003 TEST_CASE_ST(ut_setup, ut_teardown,
8004 test_AES_GMAC_authentication_verify_test_case_2),
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 test_AES_GMAC_authentication_test_case_3),
8007 TEST_CASE_ST(ut_setup, ut_teardown,
8008 test_AES_GMAC_authentication_verify_test_case_3),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_AES_GMAC_authentication_test_case_4),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 test_AES_GMAC_authentication_verify_test_case_4),
8014 /** Scatter-Gather */
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8018 /** Negative tests */
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8021 TEST_CASE_ST(ut_setup, ut_teardown,
8022 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8023 TEST_CASE_ST(ut_setup, ut_teardown,
8024 authentication_verify_AES128_GMAC_fail_data_corrupt),
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8029 TEST_CASE_ST(ut_setup, ut_teardown,
8030 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8032 TEST_CASES_END() /**< NULL terminate unit test array */
8036 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8037 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8038 .setup = testsuite_setup,
8039 .teardown = testsuite_teardown,
8040 .unit_test_cases = {
8041 /** AES GCM Authenticated Encryption */
8042 TEST_CASE_ST(ut_setup, ut_teardown,
8043 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8044 TEST_CASE_ST(ut_setup, ut_teardown,
8045 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8057 /** AES GCM Authenticated Decryption */
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8060 TEST_CASE_ST(ut_setup, ut_teardown,
8061 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8073 /** AES GCM Authenticated Encryption 256 bits key */
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8089 /** AES GCM Authenticated Decryption 256 bits key */
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8105 /** AES GCM Authenticated Encryption big aad size */
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8111 /** AES GCM Authenticated Decryption big aad size */
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8117 /** AES GMAC Authentication */
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_AES_GMAC_authentication_test_case_1),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_AES_GMAC_authentication_verify_test_case_1),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_AES_GMAC_authentication_test_case_3),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_AES_GMAC_authentication_verify_test_case_3),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_AES_GMAC_authentication_test_case_4),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_AES_GMAC_authentication_verify_test_case_4),
8131 /** Negative tests */
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 authentication_verify_AES128_GMAC_fail_data_corrupt),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8137 /** Out of place tests */
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_mb_AES_GCM_authenticated_encryption_oop),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_mb_AES_GCM_authenticated_decryption_oop),
8143 /** Session-less tests */
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_mb_AES_GCM_authenticated_encryption_sessionless),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_mb_AES_GCM_authenticated_decryption_sessionless),
8149 /** Scatter-Gather */
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8153 TEST_CASES_END() /**< NULL terminate unit test array */
8157 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8158 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8159 .setup = testsuite_setup,
8160 .teardown = testsuite_teardown,
8161 .unit_test_cases = {
8162 /** KASUMI encrypt only (UEA1) */
8163 TEST_CASE_ST(ut_setup, ut_teardown,
8164 test_kasumi_encryption_test_case_1),
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_kasumi_encryption_test_case_1_sgl),
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_kasumi_encryption_test_case_2),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_kasumi_encryption_test_case_3),
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_kasumi_encryption_test_case_4),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_kasumi_encryption_test_case_5),
8175 /** KASUMI decrypt only (UEA1) */
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 test_kasumi_decryption_test_case_1),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 test_kasumi_decryption_test_case_2),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_kasumi_decryption_test_case_3),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_kasumi_decryption_test_case_4),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_kasumi_decryption_test_case_5),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_kasumi_encryption_test_case_1_oop),
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_kasumi_encryption_test_case_1_oop_sgl),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_kasumi_decryption_test_case_1_oop),
8196 /** KASUMI hash only (UIA1) */
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_kasumi_hash_generate_test_case_1),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_kasumi_hash_generate_test_case_2),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_kasumi_hash_generate_test_case_3),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_kasumi_hash_generate_test_case_4),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_kasumi_hash_generate_test_case_5),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_kasumi_hash_generate_test_case_6),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_kasumi_hash_verify_test_case_1),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_kasumi_hash_verify_test_case_2),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_kasumi_hash_verify_test_case_3),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_kasumi_hash_verify_test_case_4),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_kasumi_hash_verify_test_case_5),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_kasumi_auth_cipher_test_case_1),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_kasumi_cipher_auth_test_case_1),
8223 TEST_CASES_END() /**< NULL terminate unit test array */
8226 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8227 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8228 .setup = testsuite_setup,
8229 .teardown = testsuite_teardown,
8230 .unit_test_cases = {
8231 /** SNOW 3G encrypt only (UEA2) */
8232 TEST_CASE_ST(ut_setup, ut_teardown,
8233 test_snow3g_encryption_test_case_1),
8234 TEST_CASE_ST(ut_setup, ut_teardown,
8235 test_snow3g_encryption_test_case_2),
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_snow3g_encryption_test_case_3),
8238 TEST_CASE_ST(ut_setup, ut_teardown,
8239 test_snow3g_encryption_test_case_4),
8240 TEST_CASE_ST(ut_setup, ut_teardown,
8241 test_snow3g_encryption_test_case_5),
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_snow3g_encryption_test_case_1_oop),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_snow3g_encryption_test_case_1_oop_sgl),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_snow3g_decryption_test_case_1_oop),
8250 TEST_CASE_ST(ut_setup, ut_teardown,
8251 test_snow3g_encryption_test_case_1_offset_oop),
8253 /** SNOW 3G decrypt only (UEA2) */
8254 TEST_CASE_ST(ut_setup, ut_teardown,
8255 test_snow3g_decryption_test_case_1),
8256 TEST_CASE_ST(ut_setup, ut_teardown,
8257 test_snow3g_decryption_test_case_2),
8258 TEST_CASE_ST(ut_setup, ut_teardown,
8259 test_snow3g_decryption_test_case_3),
8260 TEST_CASE_ST(ut_setup, ut_teardown,
8261 test_snow3g_decryption_test_case_4),
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_snow3g_decryption_test_case_5),
8264 TEST_CASE_ST(ut_setup, ut_teardown,
8265 test_snow3g_hash_generate_test_case_1),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_snow3g_hash_generate_test_case_2),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_snow3g_hash_generate_test_case_3),
8270 /* Tests with buffers which length is not byte-aligned */
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_snow3g_hash_generate_test_case_4),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_snow3g_hash_generate_test_case_5),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_snow3g_hash_generate_test_case_6),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_snow3g_hash_verify_test_case_1),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_snow3g_hash_verify_test_case_2),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_snow3g_hash_verify_test_case_3),
8283 /* Tests with buffers which length is not byte-aligned */
8284 TEST_CASE_ST(ut_setup, ut_teardown,
8285 test_snow3g_hash_verify_test_case_4),
8286 TEST_CASE_ST(ut_setup, ut_teardown,
8287 test_snow3g_hash_verify_test_case_5),
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_snow3g_hash_verify_test_case_6),
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_snow3g_cipher_auth_test_case_1),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_snow3g_auth_cipher_test_case_1),
8295 TEST_CASES_END() /**< NULL terminate unit test array */
8299 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8300 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8301 .setup = testsuite_setup,
8302 .teardown = testsuite_teardown,
8303 .unit_test_cases = {
8304 /** ZUC encrypt only (EEA3) */
8305 TEST_CASE_ST(ut_setup, ut_teardown,
8306 test_zuc_encryption_test_case_1),
8307 TEST_CASE_ST(ut_setup, ut_teardown,
8308 test_zuc_encryption_test_case_2),
8309 TEST_CASE_ST(ut_setup, ut_teardown,
8310 test_zuc_encryption_test_case_3),
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_zuc_encryption_test_case_4),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_zuc_encryption_test_case_5),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_zuc_hash_generate_test_case_1),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_zuc_hash_generate_test_case_2),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_zuc_hash_generate_test_case_3),
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 test_zuc_hash_generate_test_case_4),
8323 TEST_CASE_ST(ut_setup, ut_teardown,
8324 test_zuc_hash_generate_test_case_5),
8325 TEST_CASE_ST(ut_setup, ut_teardown,
8326 test_zuc_encryption_test_case_6_sgl),
8327 TEST_CASES_END() /**< NULL terminate unit test array */
8331 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8332 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8333 .setup = testsuite_setup,
8334 .teardown = testsuite_teardown,
8335 .unit_test_cases = {
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_device_configure_invalid_dev_id),
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_multi_session),
8341 TEST_CASE_ST(ut_setup, ut_teardown,
8342 test_AES_chain_dpaa2_sec_all),
8343 TEST_CASE_ST(ut_setup, ut_teardown,
8344 test_3DES_chain_dpaa2_sec_all),
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 test_AES_cipheronly_dpaa2_sec_all),
8347 TEST_CASE_ST(ut_setup, ut_teardown,
8348 test_3DES_cipheronly_dpaa2_sec_all),
8350 /** HMAC_MD5 Authentication */
8351 TEST_CASE_ST(ut_setup, ut_teardown,
8352 test_MD5_HMAC_generate_case_1),
8353 TEST_CASE_ST(ut_setup, ut_teardown,
8354 test_MD5_HMAC_verify_case_1),
8355 TEST_CASE_ST(ut_setup, ut_teardown,
8356 test_MD5_HMAC_generate_case_2),
8357 TEST_CASE_ST(ut_setup, ut_teardown,
8358 test_MD5_HMAC_verify_case_2),
8360 TEST_CASES_END() /**< NULL terminate unit test array */
8364 static struct unit_test_suite cryptodev_null_testsuite = {
8365 .suite_name = "Crypto Device NULL Unit Test Suite",
8366 .setup = testsuite_setup,
8367 .teardown = testsuite_teardown,
8368 .unit_test_cases = {
8369 TEST_CASE_ST(ut_setup, ut_teardown,
8370 test_null_auth_only_operation),
8371 TEST_CASE_ST(ut_setup, ut_teardown,
8372 test_null_cipher_only_operation),
8373 TEST_CASE_ST(ut_setup, ut_teardown,
8374 test_null_cipher_auth_operation),
8375 TEST_CASE_ST(ut_setup, ut_teardown,
8376 test_null_auth_cipher_operation),
8377 TEST_CASE_ST(ut_setup, ut_teardown,
8378 test_null_invalid_operation),
8379 TEST_CASE_ST(ut_setup, ut_teardown,
8380 test_null_burst_operation),
8382 TEST_CASES_END() /**< NULL terminate unit test array */
8386 static struct unit_test_suite cryptodev_armv8_testsuite = {
8387 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8388 .setup = testsuite_setup,
8389 .teardown = testsuite_teardown,
8390 .unit_test_cases = {
8391 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8393 /** Negative tests */
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8399 TEST_CASES_END() /**< NULL terminate unit test array */
8404 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8406 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8407 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8411 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8413 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8415 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8419 test_cryptodev_openssl(void)
8421 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8423 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8427 test_cryptodev_aesni_gcm(void)
8429 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8431 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8435 test_cryptodev_null(void)
8437 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8439 return unit_test_suite_runner(&cryptodev_null_testsuite);
8443 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8445 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8447 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8451 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8453 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8455 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8459 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8461 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8463 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8467 test_cryptodev_armv8(void)
8469 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8471 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8474 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8477 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8479 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8480 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8483 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8488 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8490 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8491 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8494 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8495 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8496 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8497 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8498 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8499 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8500 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8501 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8502 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8503 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);