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);
1312 sym_op->auth.data.offset = 0;
1313 sym_op->auth.data.length = QUOTE_512_BYTES;
1315 /* Copy IV at the end of the crypto operation */
1316 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1317 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1319 /* Set crypto operation cipher parameters */
1320 sym_op->cipher.data.offset = 0;
1321 sym_op->cipher.data.length = QUOTE_512_BYTES;
1323 /* Process crypto operation */
1324 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1325 ut_params->op), "failed to process sym crypto op");
1327 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1328 "crypto op processing failed");
1331 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1334 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1335 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1337 "ciphertext data not as expected");
1339 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1341 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1342 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1343 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1344 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1345 DIGEST_BYTE_LENGTH_SHA1,
1346 "Generated digest data not as expected");
1348 return TEST_SUCCESS;
1351 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1353 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1355 static uint8_t hmac_sha512_key[] = {
1356 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1357 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1358 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1359 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1360 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1361 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1362 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1363 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1365 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1366 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1367 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1368 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1369 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1370 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1371 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1372 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1373 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1378 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1379 struct crypto_unittest_params *ut_params,
1380 uint8_t *cipher_key,
1384 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1385 struct crypto_unittest_params *ut_params,
1386 struct crypto_testsuite_params *ts_params,
1387 const uint8_t *cipher,
1388 const uint8_t *digest,
1393 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1394 struct crypto_unittest_params *ut_params,
1395 uint8_t *cipher_key,
1399 /* Setup Cipher Parameters */
1400 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1401 ut_params->cipher_xform.next = NULL;
1403 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1404 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1405 ut_params->cipher_xform.cipher.key.data = cipher_key;
1406 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1407 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1408 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1410 /* Setup HMAC Parameters */
1411 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1412 ut_params->auth_xform.next = &ut_params->cipher_xform;
1414 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1415 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1416 ut_params->auth_xform.auth.key.data = hmac_key;
1417 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1418 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1420 return TEST_SUCCESS;
1425 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1426 struct crypto_unittest_params *ut_params,
1427 struct crypto_testsuite_params *ts_params,
1428 const uint8_t *cipher,
1429 const uint8_t *digest,
1432 /* Generate test mbuf data and digest */
1433 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1436 QUOTE_512_BYTES, 0);
1438 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1439 DIGEST_BYTE_LENGTH_SHA512);
1440 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1442 rte_memcpy(ut_params->digest,
1444 DIGEST_BYTE_LENGTH_SHA512);
1446 /* Generate Crypto op data structure */
1447 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1448 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1449 TEST_ASSERT_NOT_NULL(ut_params->op,
1450 "Failed to allocate symmetric crypto operation struct");
1452 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1454 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1456 /* set crypto operation source mbuf */
1457 sym_op->m_src = ut_params->ibuf;
1459 sym_op->auth.digest.data = ut_params->digest;
1460 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1461 ut_params->ibuf, QUOTE_512_BYTES);
1463 sym_op->auth.data.offset = 0;
1464 sym_op->auth.data.length = QUOTE_512_BYTES;
1466 /* Copy IV at the end of the crypto operation */
1467 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1468 iv, CIPHER_IV_LENGTH_AES_CBC);
1470 sym_op->cipher.data.offset = 0;
1471 sym_op->cipher.data.length = QUOTE_512_BYTES;
1473 /* Process crypto operation */
1474 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1475 ut_params->op), "failed to process sym crypto op");
1477 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1478 "crypto op processing failed");
1480 ut_params->obuf = ut_params->op->sym->m_src;
1483 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1484 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1487 "Plaintext data not as expected");
1490 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1491 "Digest verification failed");
1493 return TEST_SUCCESS;
1497 test_AES_cipheronly_mb_all(void)
1499 struct crypto_testsuite_params *ts_params = &testsuite_params;
1502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1503 ts_params->op_mpool, ts_params->valid_devs[0],
1504 RTE_CRYPTODEV_AESNI_MB_PMD,
1505 BLKCIPHER_AES_CIPHERONLY_TYPE);
1507 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1509 return TEST_SUCCESS;
1513 test_AES_docsis_mb_all(void)
1515 struct crypto_testsuite_params *ts_params = &testsuite_params;
1518 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1519 ts_params->op_mpool, ts_params->valid_devs[0],
1520 RTE_CRYPTODEV_AESNI_MB_PMD,
1521 BLKCIPHER_AES_DOCSIS_TYPE);
1523 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1525 return TEST_SUCCESS;
1529 test_AES_docsis_qat_all(void)
1531 struct crypto_testsuite_params *ts_params = &testsuite_params;
1534 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1535 ts_params->op_mpool, ts_params->valid_devs[0],
1536 RTE_CRYPTODEV_QAT_SYM_PMD,
1537 BLKCIPHER_AES_DOCSIS_TYPE);
1539 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1541 return TEST_SUCCESS;
1545 test_DES_docsis_qat_all(void)
1547 struct crypto_testsuite_params *ts_params = &testsuite_params;
1550 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1551 ts_params->op_mpool, ts_params->valid_devs[0],
1552 RTE_CRYPTODEV_QAT_SYM_PMD,
1553 BLKCIPHER_DES_DOCSIS_TYPE);
1555 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1557 return TEST_SUCCESS;
1561 test_authonly_mb_all(void)
1563 struct crypto_testsuite_params *ts_params = &testsuite_params;
1566 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1567 ts_params->op_mpool, ts_params->valid_devs[0],
1568 RTE_CRYPTODEV_AESNI_MB_PMD,
1569 BLKCIPHER_AUTHONLY_TYPE);
1571 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1573 return TEST_SUCCESS;
1577 test_AES_chain_mb_all(void)
1579 struct crypto_testsuite_params *ts_params = &testsuite_params;
1582 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1583 ts_params->op_mpool, ts_params->valid_devs[0],
1584 RTE_CRYPTODEV_AESNI_MB_PMD,
1585 BLKCIPHER_AES_CHAIN_TYPE);
1587 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1589 return TEST_SUCCESS;
1592 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1595 test_AES_cipheronly_scheduler_all(void)
1597 struct crypto_testsuite_params *ts_params = &testsuite_params;
1600 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1601 ts_params->op_mpool, ts_params->valid_devs[0],
1602 RTE_CRYPTODEV_SCHEDULER_PMD,
1603 BLKCIPHER_AES_CIPHERONLY_TYPE);
1605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1607 return TEST_SUCCESS;
1611 test_AES_chain_scheduler_all(void)
1613 struct crypto_testsuite_params *ts_params = &testsuite_params;
1616 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1617 ts_params->op_mpool, ts_params->valid_devs[0],
1618 RTE_CRYPTODEV_SCHEDULER_PMD,
1619 BLKCIPHER_AES_CHAIN_TYPE);
1621 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1623 return TEST_SUCCESS;
1627 test_authonly_scheduler_all(void)
1629 struct crypto_testsuite_params *ts_params = &testsuite_params;
1632 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1633 ts_params->op_mpool, ts_params->valid_devs[0],
1634 RTE_CRYPTODEV_SCHEDULER_PMD,
1635 BLKCIPHER_AUTHONLY_TYPE);
1637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1639 return TEST_SUCCESS;
1642 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1645 test_AES_chain_openssl_all(void)
1647 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1651 ts_params->op_mpool, ts_params->valid_devs[0],
1652 RTE_CRYPTODEV_OPENSSL_PMD,
1653 BLKCIPHER_AES_CHAIN_TYPE);
1655 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1657 return TEST_SUCCESS;
1661 test_AES_cipheronly_openssl_all(void)
1663 struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1667 ts_params->op_mpool, ts_params->valid_devs[0],
1668 RTE_CRYPTODEV_OPENSSL_PMD,
1669 BLKCIPHER_AES_CIPHERONLY_TYPE);
1671 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1673 return TEST_SUCCESS;
1677 test_AES_chain_qat_all(void)
1679 struct crypto_testsuite_params *ts_params = &testsuite_params;
1682 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1683 ts_params->op_mpool, ts_params->valid_devs[0],
1684 RTE_CRYPTODEV_QAT_SYM_PMD,
1685 BLKCIPHER_AES_CHAIN_TYPE);
1687 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1689 return TEST_SUCCESS;
1693 test_AES_cipheronly_qat_all(void)
1695 struct crypto_testsuite_params *ts_params = &testsuite_params;
1698 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1699 ts_params->op_mpool, ts_params->valid_devs[0],
1700 RTE_CRYPTODEV_QAT_SYM_PMD,
1701 BLKCIPHER_AES_CIPHERONLY_TYPE);
1703 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1705 return TEST_SUCCESS;
1709 test_AES_chain_dpaa2_sec_all(void)
1711 struct crypto_testsuite_params *ts_params = &testsuite_params;
1714 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1715 ts_params->op_mpool, ts_params->valid_devs[0],
1716 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1717 BLKCIPHER_AES_CHAIN_TYPE);
1719 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1721 return TEST_SUCCESS;
1725 test_AES_cipheronly_dpaa2_sec_all(void)
1727 struct crypto_testsuite_params *ts_params = &testsuite_params;
1730 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1731 ts_params->op_mpool, ts_params->valid_devs[0],
1732 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1733 BLKCIPHER_AES_CIPHERONLY_TYPE);
1735 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1737 return TEST_SUCCESS;
1741 test_authonly_openssl_all(void)
1743 struct crypto_testsuite_params *ts_params = &testsuite_params;
1746 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1747 ts_params->op_mpool, ts_params->valid_devs[0],
1748 RTE_CRYPTODEV_OPENSSL_PMD,
1749 BLKCIPHER_AUTHONLY_TYPE);
1751 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1753 return TEST_SUCCESS;
1757 test_AES_chain_armv8_all(void)
1759 struct crypto_testsuite_params *ts_params = &testsuite_params;
1762 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1763 ts_params->op_mpool, ts_params->valid_devs[0],
1764 RTE_CRYPTODEV_ARMV8_PMD,
1765 BLKCIPHER_AES_CHAIN_TYPE);
1767 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1769 return TEST_SUCCESS;
1772 /* ***** SNOW 3G Tests ***** */
1774 create_wireless_algo_hash_session(uint8_t dev_id,
1775 const uint8_t *key, const uint8_t key_len,
1776 const uint8_t iv_len, const uint8_t auth_len,
1777 enum rte_crypto_auth_operation op,
1778 enum rte_crypto_auth_algorithm algo)
1780 uint8_t hash_key[key_len];
1782 struct crypto_unittest_params *ut_params = &unittest_params;
1784 memcpy(hash_key, key, key_len);
1786 TEST_HEXDUMP(stdout, "key:", key, key_len);
1788 /* Setup Authentication Parameters */
1789 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1790 ut_params->auth_xform.next = NULL;
1792 ut_params->auth_xform.auth.op = op;
1793 ut_params->auth_xform.auth.algo = algo;
1794 ut_params->auth_xform.auth.key.length = key_len;
1795 ut_params->auth_xform.auth.key.data = hash_key;
1796 ut_params->auth_xform.auth.digest_length = auth_len;
1797 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1798 ut_params->auth_xform.auth.iv.length = iv_len;
1799 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1800 &ut_params->auth_xform);
1801 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1806 create_wireless_algo_cipher_session(uint8_t dev_id,
1807 enum rte_crypto_cipher_operation op,
1808 enum rte_crypto_cipher_algorithm algo,
1809 const uint8_t *key, const uint8_t key_len,
1812 uint8_t cipher_key[key_len];
1814 struct crypto_unittest_params *ut_params = &unittest_params;
1816 memcpy(cipher_key, key, key_len);
1818 /* Setup Cipher Parameters */
1819 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1820 ut_params->cipher_xform.next = NULL;
1822 ut_params->cipher_xform.cipher.algo = algo;
1823 ut_params->cipher_xform.cipher.op = op;
1824 ut_params->cipher_xform.cipher.key.data = cipher_key;
1825 ut_params->cipher_xform.cipher.key.length = key_len;
1826 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1827 ut_params->cipher_xform.cipher.iv.length = iv_len;
1829 TEST_HEXDUMP(stdout, "key:", key, key_len);
1831 /* Create Crypto session */
1832 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1835 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1840 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1841 unsigned int cipher_len,
1842 unsigned int cipher_offset)
1844 struct crypto_testsuite_params *ts_params = &testsuite_params;
1845 struct crypto_unittest_params *ut_params = &unittest_params;
1847 /* Generate Crypto op data structure */
1848 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1849 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1850 TEST_ASSERT_NOT_NULL(ut_params->op,
1851 "Failed to allocate pktmbuf offload");
1853 /* Set crypto operation data parameters */
1854 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1856 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1858 /* set crypto operation source mbuf */
1859 sym_op->m_src = ut_params->ibuf;
1862 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1864 sym_op->cipher.data.length = cipher_len;
1865 sym_op->cipher.data.offset = cipher_offset;
1870 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1871 unsigned int cipher_len,
1872 unsigned int cipher_offset)
1874 struct crypto_testsuite_params *ts_params = &testsuite_params;
1875 struct crypto_unittest_params *ut_params = &unittest_params;
1877 /* Generate Crypto op data structure */
1878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1880 TEST_ASSERT_NOT_NULL(ut_params->op,
1881 "Failed to allocate pktmbuf offload");
1883 /* Set crypto operation data parameters */
1884 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1886 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1888 /* set crypto operation source mbuf */
1889 sym_op->m_src = ut_params->ibuf;
1890 sym_op->m_dst = ut_params->obuf;
1893 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1895 sym_op->cipher.data.length = cipher_len;
1896 sym_op->cipher.data.offset = cipher_offset;
1901 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1902 enum rte_crypto_cipher_operation cipher_op,
1903 enum rte_crypto_auth_operation auth_op,
1904 enum rte_crypto_auth_algorithm auth_algo,
1905 enum rte_crypto_cipher_algorithm cipher_algo,
1906 const uint8_t *key, uint8_t key_len,
1907 uint8_t auth_iv_len, uint8_t auth_len,
1908 uint8_t cipher_iv_len)
1911 uint8_t cipher_auth_key[key_len];
1913 struct crypto_unittest_params *ut_params = &unittest_params;
1915 memcpy(cipher_auth_key, key, key_len);
1917 /* Setup Authentication Parameters */
1918 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1919 ut_params->auth_xform.next = NULL;
1921 ut_params->auth_xform.auth.op = auth_op;
1922 ut_params->auth_xform.auth.algo = auth_algo;
1923 ut_params->auth_xform.auth.key.length = key_len;
1924 /* Hash key = cipher key */
1925 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1926 ut_params->auth_xform.auth.digest_length = auth_len;
1927 /* Auth IV will be after cipher IV */
1928 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1929 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1931 /* Setup Cipher Parameters */
1932 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1933 ut_params->cipher_xform.next = &ut_params->auth_xform;
1935 ut_params->cipher_xform.cipher.algo = cipher_algo;
1936 ut_params->cipher_xform.cipher.op = cipher_op;
1937 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1938 ut_params->cipher_xform.cipher.key.length = key_len;
1939 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1940 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1942 TEST_HEXDUMP(stdout, "key:", key, key_len);
1944 /* Create Crypto session*/
1945 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1946 &ut_params->cipher_xform);
1948 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1953 create_wireless_cipher_auth_session(uint8_t dev_id,
1954 enum rte_crypto_cipher_operation cipher_op,
1955 enum rte_crypto_auth_operation auth_op,
1956 enum rte_crypto_auth_algorithm auth_algo,
1957 enum rte_crypto_cipher_algorithm cipher_algo,
1958 const struct wireless_test_data *tdata)
1960 const uint8_t key_len = tdata->key.len;
1961 uint8_t cipher_auth_key[key_len];
1963 struct crypto_unittest_params *ut_params = &unittest_params;
1964 const uint8_t *key = tdata->key.data;
1965 const uint8_t auth_len = tdata->digest.len;
1966 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1967 uint8_t auth_iv_len = tdata->auth_iv.len;
1969 memcpy(cipher_auth_key, key, key_len);
1971 /* Setup Authentication Parameters */
1972 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1973 ut_params->auth_xform.next = NULL;
1975 ut_params->auth_xform.auth.op = auth_op;
1976 ut_params->auth_xform.auth.algo = auth_algo;
1977 ut_params->auth_xform.auth.key.length = key_len;
1978 /* Hash key = cipher key */
1979 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1980 ut_params->auth_xform.auth.digest_length = auth_len;
1981 /* Auth IV will be after cipher IV */
1982 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1983 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1985 /* Setup Cipher Parameters */
1986 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1987 ut_params->cipher_xform.next = &ut_params->auth_xform;
1989 ut_params->cipher_xform.cipher.algo = cipher_algo;
1990 ut_params->cipher_xform.cipher.op = cipher_op;
1991 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1992 ut_params->cipher_xform.cipher.key.length = key_len;
1993 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1994 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1997 TEST_HEXDUMP(stdout, "key:", key, key_len);
1999 /* Create Crypto session*/
2000 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2001 &ut_params->cipher_xform);
2003 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2008 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2009 const struct wireless_test_data *tdata)
2011 return create_wireless_cipher_auth_session(dev_id,
2012 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2013 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2014 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2018 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2019 enum rte_crypto_cipher_operation cipher_op,
2020 enum rte_crypto_auth_operation auth_op,
2021 enum rte_crypto_auth_algorithm auth_algo,
2022 enum rte_crypto_cipher_algorithm cipher_algo,
2023 const uint8_t *key, const uint8_t key_len,
2024 uint8_t auth_iv_len, uint8_t auth_len,
2025 uint8_t cipher_iv_len)
2027 uint8_t auth_cipher_key[key_len];
2029 struct crypto_unittest_params *ut_params = &unittest_params;
2031 memcpy(auth_cipher_key, key, key_len);
2033 /* Setup Authentication Parameters */
2034 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2035 ut_params->auth_xform.auth.op = auth_op;
2036 ut_params->auth_xform.next = &ut_params->cipher_xform;
2037 ut_params->auth_xform.auth.algo = auth_algo;
2038 ut_params->auth_xform.auth.key.length = key_len;
2039 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2040 ut_params->auth_xform.auth.digest_length = auth_len;
2041 /* Auth IV will be after cipher IV */
2042 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2043 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2045 /* Setup Cipher Parameters */
2046 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2047 ut_params->cipher_xform.next = NULL;
2048 ut_params->cipher_xform.cipher.algo = cipher_algo;
2049 ut_params->cipher_xform.cipher.op = cipher_op;
2050 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2051 ut_params->cipher_xform.cipher.key.length = key_len;
2052 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2053 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2055 TEST_HEXDUMP(stdout, "key:", key, key_len);
2057 /* Create Crypto session*/
2058 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2059 &ut_params->auth_xform);
2061 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2067 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2068 unsigned int auth_tag_len,
2069 const uint8_t *iv, unsigned int iv_len,
2070 unsigned int data_pad_len,
2071 enum rte_crypto_auth_operation op,
2072 unsigned int auth_len, unsigned int auth_offset)
2074 struct crypto_testsuite_params *ts_params = &testsuite_params;
2076 struct crypto_unittest_params *ut_params = &unittest_params;
2078 /* Generate Crypto op data structure */
2079 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2080 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2081 TEST_ASSERT_NOT_NULL(ut_params->op,
2082 "Failed to allocate pktmbuf offload");
2084 /* Set crypto operation data parameters */
2085 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2087 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2089 /* set crypto operation source mbuf */
2090 sym_op->m_src = ut_params->ibuf;
2093 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2096 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2097 ut_params->ibuf, auth_tag_len);
2099 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2100 "no room to append auth tag");
2101 ut_params->digest = sym_op->auth.digest.data;
2102 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2103 ut_params->ibuf, data_pad_len);
2104 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2105 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2107 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2109 TEST_HEXDUMP(stdout, "digest:",
2110 sym_op->auth.digest.data,
2113 sym_op->auth.data.length = auth_len;
2114 sym_op->auth.data.offset = auth_offset;
2120 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2121 enum rte_crypto_auth_operation op)
2123 struct crypto_testsuite_params *ts_params = &testsuite_params;
2124 struct crypto_unittest_params *ut_params = &unittest_params;
2126 const uint8_t *auth_tag = tdata->digest.data;
2127 const unsigned int auth_tag_len = tdata->digest.len;
2128 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2129 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2131 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2132 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2133 const uint8_t *auth_iv = tdata->auth_iv.data;
2134 const uint8_t auth_iv_len = tdata->auth_iv.len;
2135 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2136 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2138 /* Generate Crypto op data structure */
2139 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2140 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2141 TEST_ASSERT_NOT_NULL(ut_params->op,
2142 "Failed to allocate pktmbuf offload");
2143 /* Set crypto operation data parameters */
2144 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2146 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2148 /* set crypto operation source mbuf */
2149 sym_op->m_src = ut_params->ibuf;
2152 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2153 ut_params->ibuf, auth_tag_len);
2155 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2156 "no room to append auth tag");
2157 ut_params->digest = sym_op->auth.digest.data;
2158 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2159 ut_params->ibuf, data_pad_len);
2160 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2161 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2163 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2165 TEST_HEXDUMP(stdout, "digest:",
2166 sym_op->auth.digest.data,
2169 /* Copy cipher and auth IVs at the end of the crypto operation */
2170 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2172 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2173 iv_ptr += cipher_iv_len;
2174 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2176 sym_op->cipher.data.length = cipher_len;
2177 sym_op->cipher.data.offset = 0;
2178 sym_op->auth.data.length = auth_len;
2179 sym_op->auth.data.offset = 0;
2185 create_zuc_cipher_hash_generate_operation(
2186 const struct wireless_test_data *tdata)
2188 return create_wireless_cipher_hash_operation(tdata,
2189 RTE_CRYPTO_AUTH_OP_GENERATE);
2193 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2194 const unsigned auth_tag_len,
2195 const uint8_t *auth_iv, uint8_t auth_iv_len,
2196 unsigned data_pad_len,
2197 enum rte_crypto_auth_operation op,
2198 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2199 const unsigned cipher_len, const unsigned cipher_offset,
2200 const unsigned auth_len, const unsigned auth_offset)
2202 struct crypto_testsuite_params *ts_params = &testsuite_params;
2203 struct crypto_unittest_params *ut_params = &unittest_params;
2205 /* Generate Crypto op data structure */
2206 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2207 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2208 TEST_ASSERT_NOT_NULL(ut_params->op,
2209 "Failed to allocate pktmbuf offload");
2210 /* Set crypto operation data parameters */
2211 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2213 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2215 /* set crypto operation source mbuf */
2216 sym_op->m_src = ut_params->ibuf;
2219 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2220 ut_params->ibuf, auth_tag_len);
2222 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2223 "no room to append auth tag");
2224 ut_params->digest = sym_op->auth.digest.data;
2225 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2226 ut_params->ibuf, data_pad_len);
2227 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2228 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2230 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2232 TEST_HEXDUMP(stdout, "digest:",
2233 sym_op->auth.digest.data,
2236 /* Copy cipher and auth IVs at the end of the crypto operation */
2237 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2239 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2240 iv_ptr += cipher_iv_len;
2241 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2243 sym_op->cipher.data.length = cipher_len;
2244 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2245 sym_op->auth.data.length = auth_len;
2246 sym_op->auth.data.offset = auth_offset + cipher_offset;
2252 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2253 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2254 const uint8_t *auth_iv, uint8_t auth_iv_len,
2255 unsigned int data_pad_len,
2256 unsigned int cipher_len, unsigned int cipher_offset,
2257 unsigned int auth_len, unsigned int auth_offset)
2259 struct crypto_testsuite_params *ts_params = &testsuite_params;
2260 struct crypto_unittest_params *ut_params = &unittest_params;
2262 /* Generate Crypto op data structure */
2263 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2264 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2265 TEST_ASSERT_NOT_NULL(ut_params->op,
2266 "Failed to allocate pktmbuf offload");
2268 /* Set crypto operation data parameters */
2269 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2273 /* set crypto operation source mbuf */
2274 sym_op->m_src = ut_params->ibuf;
2277 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2278 ut_params->ibuf, auth_tag_len);
2280 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2281 "no room to append auth tag");
2283 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2284 ut_params->ibuf, data_pad_len);
2286 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2288 TEST_HEXDUMP(stdout, "digest:",
2289 sym_op->auth.digest.data,
2292 /* Copy cipher and auth IVs at the end of the crypto operation */
2293 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2295 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2296 iv_ptr += cipher_iv_len;
2297 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2299 sym_op->cipher.data.length = cipher_len;
2300 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2302 sym_op->auth.data.length = auth_len;
2303 sym_op->auth.data.offset = auth_offset + cipher_offset;
2309 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2311 struct crypto_testsuite_params *ts_params = &testsuite_params;
2312 struct crypto_unittest_params *ut_params = &unittest_params;
2315 unsigned plaintext_pad_len;
2316 unsigned plaintext_len;
2319 /* Create SNOW 3G session */
2320 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2321 tdata->key.data, tdata->key.len,
2322 tdata->auth_iv.len, tdata->digest.len,
2323 RTE_CRYPTO_AUTH_OP_GENERATE,
2324 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2328 /* alloc mbuf and set payload */
2329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2331 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2332 rte_pktmbuf_tailroom(ut_params->ibuf));
2334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2335 /* Append data which is padded to a multiple of */
2336 /* the algorithms block size */
2337 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2338 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2340 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2342 /* Create SNOW 3G operation */
2343 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2344 tdata->auth_iv.data, tdata->auth_iv.len,
2345 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2346 tdata->validAuthLenInBits.len,
2351 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2353 ut_params->obuf = ut_params->op->sym->m_src;
2354 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2355 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2356 + plaintext_pad_len;
2359 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2362 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2363 "SNOW 3G Generated auth tag not as expected");
2369 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2371 struct crypto_testsuite_params *ts_params = &testsuite_params;
2372 struct crypto_unittest_params *ut_params = &unittest_params;
2375 unsigned plaintext_pad_len;
2376 unsigned plaintext_len;
2379 /* Create SNOW 3G session */
2380 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2381 tdata->key.data, tdata->key.len,
2382 tdata->auth_iv.len, tdata->digest.len,
2383 RTE_CRYPTO_AUTH_OP_VERIFY,
2384 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2387 /* alloc mbuf and set payload */
2388 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2391 rte_pktmbuf_tailroom(ut_params->ibuf));
2393 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2394 /* Append data which is padded to a multiple of */
2395 /* the algorithms block size */
2396 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2397 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2399 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2401 /* Create SNOW 3G operation */
2402 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2404 tdata->auth_iv.data, tdata->auth_iv.len,
2406 RTE_CRYPTO_AUTH_OP_VERIFY,
2407 tdata->validAuthLenInBits.len,
2412 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2414 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2415 ut_params->obuf = ut_params->op->sym->m_src;
2416 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2417 + plaintext_pad_len;
2420 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2429 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2431 struct crypto_testsuite_params *ts_params = &testsuite_params;
2432 struct crypto_unittest_params *ut_params = &unittest_params;
2435 unsigned plaintext_pad_len;
2436 unsigned plaintext_len;
2439 /* Create KASUMI session */
2440 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2441 tdata->key.data, tdata->key.len,
2442 tdata->auth_iv.len, tdata->digest.len,
2443 RTE_CRYPTO_AUTH_OP_GENERATE,
2444 RTE_CRYPTO_AUTH_KASUMI_F9);
2448 /* alloc mbuf and set payload */
2449 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2451 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2452 rte_pktmbuf_tailroom(ut_params->ibuf));
2454 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2455 /* Append data which is padded to a multiple of */
2456 /* the algorithms block size */
2457 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2458 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2460 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2462 /* Create KASUMI operation */
2463 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2464 tdata->auth_iv.data, tdata->auth_iv.len,
2465 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2466 tdata->validAuthLenInBits.len,
2471 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2473 ut_params->obuf = ut_params->op->sym->m_src;
2474 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2475 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2476 + plaintext_pad_len;
2479 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2482 DIGEST_BYTE_LENGTH_KASUMI_F9,
2483 "KASUMI Generated auth tag not as expected");
2489 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2491 struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 struct crypto_unittest_params *ut_params = &unittest_params;
2495 unsigned plaintext_pad_len;
2496 unsigned plaintext_len;
2499 /* Create KASUMI session */
2500 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2501 tdata->key.data, tdata->key.len,
2502 tdata->auth_iv.len, tdata->digest.len,
2503 RTE_CRYPTO_AUTH_OP_VERIFY,
2504 RTE_CRYPTO_AUTH_KASUMI_F9);
2507 /* alloc mbuf and set payload */
2508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2511 rte_pktmbuf_tailroom(ut_params->ibuf));
2513 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2514 /* Append data which is padded to a multiple */
2515 /* of the algorithms block size */
2516 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2517 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2519 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2521 /* Create KASUMI operation */
2522 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2524 tdata->auth_iv.data, tdata->auth_iv.len,
2526 RTE_CRYPTO_AUTH_OP_VERIFY,
2527 tdata->validAuthLenInBits.len,
2532 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2535 ut_params->obuf = ut_params->op->sym->m_src;
2536 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2537 + plaintext_pad_len;
2540 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2549 test_snow3g_hash_generate_test_case_1(void)
2551 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2555 test_snow3g_hash_generate_test_case_2(void)
2557 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2561 test_snow3g_hash_generate_test_case_3(void)
2563 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2567 test_snow3g_hash_generate_test_case_4(void)
2569 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2573 test_snow3g_hash_generate_test_case_5(void)
2575 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2579 test_snow3g_hash_generate_test_case_6(void)
2581 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2585 test_snow3g_hash_verify_test_case_1(void)
2587 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2592 test_snow3g_hash_verify_test_case_2(void)
2594 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2598 test_snow3g_hash_verify_test_case_3(void)
2600 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2604 test_snow3g_hash_verify_test_case_4(void)
2606 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2610 test_snow3g_hash_verify_test_case_5(void)
2612 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2616 test_snow3g_hash_verify_test_case_6(void)
2618 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2622 test_kasumi_hash_generate_test_case_1(void)
2624 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2628 test_kasumi_hash_generate_test_case_2(void)
2630 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2634 test_kasumi_hash_generate_test_case_3(void)
2636 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2640 test_kasumi_hash_generate_test_case_4(void)
2642 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2646 test_kasumi_hash_generate_test_case_5(void)
2648 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2652 test_kasumi_hash_generate_test_case_6(void)
2654 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2658 test_kasumi_hash_verify_test_case_1(void)
2660 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2664 test_kasumi_hash_verify_test_case_2(void)
2666 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2670 test_kasumi_hash_verify_test_case_3(void)
2672 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2676 test_kasumi_hash_verify_test_case_4(void)
2678 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2682 test_kasumi_hash_verify_test_case_5(void)
2684 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2688 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2690 struct crypto_testsuite_params *ts_params = &testsuite_params;
2691 struct crypto_unittest_params *ut_params = &unittest_params;
2694 uint8_t *plaintext, *ciphertext;
2695 unsigned plaintext_pad_len;
2696 unsigned plaintext_len;
2698 /* Create KASUMI session */
2699 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2700 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2701 RTE_CRYPTO_CIPHER_KASUMI_F8,
2702 tdata->key.data, tdata->key.len,
2703 tdata->cipher_iv.len);
2707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2709 /* Clear mbuf payload */
2710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2711 rte_pktmbuf_tailroom(ut_params->ibuf));
2713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2714 /* Append data which is padded to a multiple */
2715 /* of the algorithms block size */
2716 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2717 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2719 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2721 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2723 /* Create KASUMI operation */
2724 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2725 tdata->cipher_iv.len,
2726 tdata->plaintext.len,
2731 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2733 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2735 ut_params->obuf = ut_params->op->sym->m_dst;
2736 if (ut_params->obuf)
2737 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2739 ciphertext = plaintext;
2741 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2744 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2746 tdata->ciphertext.data,
2747 tdata->validCipherLenInBits.len,
2748 "KASUMI Ciphertext data not as expected");
2753 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2755 struct crypto_testsuite_params *ts_params = &testsuite_params;
2756 struct crypto_unittest_params *ut_params = &unittest_params;
2760 unsigned int plaintext_pad_len;
2761 unsigned int plaintext_len;
2763 uint8_t buffer[10000];
2764 const uint8_t *ciphertext;
2766 struct rte_cryptodev_info dev_info;
2768 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2769 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2770 printf("Device doesn't support scatter-gather. "
2775 /* Create KASUMI session */
2776 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2777 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2778 RTE_CRYPTO_CIPHER_KASUMI_F8,
2779 tdata->key.data, tdata->key.len,
2780 tdata->cipher_iv.len);
2784 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2787 /* Append data which is padded to a multiple */
2788 /* of the algorithms block size */
2789 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2791 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2792 plaintext_pad_len, 10, 0);
2794 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2796 /* Create KASUMI operation */
2797 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2798 tdata->cipher_iv.len,
2799 tdata->plaintext.len,
2804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2808 ut_params->obuf = ut_params->op->sym->m_dst;
2810 if (ut_params->obuf)
2811 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2812 plaintext_len, buffer);
2814 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2815 plaintext_len, buffer);
2818 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2821 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2823 tdata->ciphertext.data,
2824 tdata->validCipherLenInBits.len,
2825 "KASUMI Ciphertext data not as expected");
2830 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2832 struct crypto_testsuite_params *ts_params = &testsuite_params;
2833 struct crypto_unittest_params *ut_params = &unittest_params;
2836 uint8_t *plaintext, *ciphertext;
2837 unsigned plaintext_pad_len;
2838 unsigned plaintext_len;
2840 /* Create KASUMI session */
2841 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2842 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2843 RTE_CRYPTO_CIPHER_KASUMI_F8,
2844 tdata->key.data, tdata->key.len,
2845 tdata->cipher_iv.len);
2849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2850 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2852 /* Clear mbuf payload */
2853 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2854 rte_pktmbuf_tailroom(ut_params->ibuf));
2856 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2857 /* Append data which is padded to a multiple */
2858 /* of the algorithms block size */
2859 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2860 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2862 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2863 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2865 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2867 /* Create KASUMI operation */
2868 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2869 tdata->cipher_iv.len,
2870 tdata->plaintext.len,
2875 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2877 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2879 ut_params->obuf = ut_params->op->sym->m_dst;
2880 if (ut_params->obuf)
2881 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2883 ciphertext = plaintext;
2885 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2888 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2890 tdata->ciphertext.data,
2891 tdata->validCipherLenInBits.len,
2892 "KASUMI Ciphertext data not as expected");
2897 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2899 struct crypto_testsuite_params *ts_params = &testsuite_params;
2900 struct crypto_unittest_params *ut_params = &unittest_params;
2903 unsigned int plaintext_pad_len;
2904 unsigned int plaintext_len;
2906 const uint8_t *ciphertext;
2907 uint8_t buffer[2048];
2909 struct rte_cryptodev_info dev_info;
2911 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2912 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2913 printf("Device doesn't support scatter-gather. "
2918 /* Create KASUMI session */
2919 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2920 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2921 RTE_CRYPTO_CIPHER_KASUMI_F8,
2922 tdata->key.data, tdata->key.len,
2923 tdata->cipher_iv.len);
2927 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2928 /* Append data which is padded to a multiple */
2929 /* of the algorithms block size */
2930 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2932 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2933 plaintext_pad_len, 10, 0);
2934 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2935 plaintext_pad_len, 3, 0);
2937 /* Append data which is padded to a multiple */
2938 /* of the algorithms block size */
2939 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2941 /* Create KASUMI operation */
2942 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2943 tdata->cipher_iv.len,
2944 tdata->plaintext.len,
2949 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2951 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2953 ut_params->obuf = ut_params->op->sym->m_dst;
2954 if (ut_params->obuf)
2955 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2956 plaintext_pad_len, buffer);
2958 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2959 plaintext_pad_len, buffer);
2962 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2964 tdata->ciphertext.data,
2965 tdata->validCipherLenInBits.len,
2966 "KASUMI Ciphertext data not as expected");
2972 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2974 struct crypto_testsuite_params *ts_params = &testsuite_params;
2975 struct crypto_unittest_params *ut_params = &unittest_params;
2978 uint8_t *ciphertext, *plaintext;
2979 unsigned ciphertext_pad_len;
2980 unsigned ciphertext_len;
2982 /* Create KASUMI session */
2983 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2984 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2985 RTE_CRYPTO_CIPHER_KASUMI_F8,
2986 tdata->key.data, tdata->key.len,
2987 tdata->cipher_iv.len);
2991 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2992 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2994 /* Clear mbuf payload */
2995 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2996 rte_pktmbuf_tailroom(ut_params->ibuf));
2998 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2999 /* Append data which is padded to a multiple */
3000 /* of the algorithms block size */
3001 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3002 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3003 ciphertext_pad_len);
3004 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3005 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3007 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3009 /* Create KASUMI operation */
3010 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3011 tdata->cipher_iv.len,
3012 tdata->ciphertext.len,
3017 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3019 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3021 ut_params->obuf = ut_params->op->sym->m_dst;
3022 if (ut_params->obuf)
3023 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3025 plaintext = ciphertext;
3027 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3030 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3032 tdata->plaintext.data,
3033 tdata->validCipherLenInBits.len,
3034 "KASUMI Plaintext data not as expected");
3039 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3041 struct crypto_testsuite_params *ts_params = &testsuite_params;
3042 struct crypto_unittest_params *ut_params = &unittest_params;
3045 uint8_t *ciphertext, *plaintext;
3046 unsigned ciphertext_pad_len;
3047 unsigned ciphertext_len;
3049 /* Create KASUMI session */
3050 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3051 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3052 RTE_CRYPTO_CIPHER_KASUMI_F8,
3053 tdata->key.data, tdata->key.len,
3054 tdata->cipher_iv.len);
3058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3060 /* Clear mbuf payload */
3061 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3062 rte_pktmbuf_tailroom(ut_params->ibuf));
3064 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3065 /* Append data which is padded to a multiple */
3066 /* of the algorithms block size */
3067 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3068 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3069 ciphertext_pad_len);
3070 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3072 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3074 /* Create KASUMI operation */
3075 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3076 tdata->cipher_iv.len,
3077 tdata->ciphertext.len,
3082 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3084 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3086 ut_params->obuf = ut_params->op->sym->m_dst;
3087 if (ut_params->obuf)
3088 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3090 plaintext = ciphertext;
3092 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3095 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3097 tdata->plaintext.data,
3098 tdata->validCipherLenInBits.len,
3099 "KASUMI Plaintext data not as expected");
3104 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3106 struct crypto_testsuite_params *ts_params = &testsuite_params;
3107 struct crypto_unittest_params *ut_params = &unittest_params;
3110 uint8_t *plaintext, *ciphertext;
3111 unsigned plaintext_pad_len;
3112 unsigned plaintext_len;
3114 /* Create SNOW 3G session */
3115 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3116 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3117 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3118 tdata->key.data, tdata->key.len,
3119 tdata->cipher_iv.len);
3123 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3125 /* Clear mbuf payload */
3126 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3127 rte_pktmbuf_tailroom(ut_params->ibuf));
3129 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3130 /* Append data which is padded to a multiple of */
3131 /* the algorithms block size */
3132 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3135 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3137 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3139 /* Create SNOW 3G operation */
3140 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3141 tdata->cipher_iv.len,
3142 tdata->validCipherLenInBits.len,
3147 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3149 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3151 ut_params->obuf = ut_params->op->sym->m_dst;
3152 if (ut_params->obuf)
3153 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3155 ciphertext = plaintext;
3157 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3160 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3162 tdata->ciphertext.data,
3163 tdata->validDataLenInBits.len,
3164 "SNOW 3G Ciphertext data not as expected");
3170 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3172 struct crypto_testsuite_params *ts_params = &testsuite_params;
3173 struct crypto_unittest_params *ut_params = &unittest_params;
3174 uint8_t *plaintext, *ciphertext;
3177 unsigned plaintext_pad_len;
3178 unsigned plaintext_len;
3180 /* Create SNOW 3G session */
3181 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3182 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3183 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3184 tdata->key.data, tdata->key.len,
3185 tdata->cipher_iv.len);
3189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3190 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3192 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3193 "Failed to allocate input buffer in mempool");
3194 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3195 "Failed to allocate output buffer in mempool");
3197 /* Clear mbuf payload */
3198 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3199 rte_pktmbuf_tailroom(ut_params->ibuf));
3201 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3202 /* Append data which is padded to a multiple of */
3203 /* the algorithms block size */
3204 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3205 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3207 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3208 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3210 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3212 /* Create SNOW 3G operation */
3213 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3214 tdata->cipher_iv.len,
3215 tdata->validCipherLenInBits.len,
3220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3224 ut_params->obuf = ut_params->op->sym->m_dst;
3225 if (ut_params->obuf)
3226 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3228 ciphertext = plaintext;
3230 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3235 tdata->ciphertext.data,
3236 tdata->validDataLenInBits.len,
3237 "SNOW 3G Ciphertext data not as expected");
3242 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3244 struct crypto_testsuite_params *ts_params = &testsuite_params;
3245 struct crypto_unittest_params *ut_params = &unittest_params;
3248 unsigned int plaintext_pad_len;
3249 unsigned int plaintext_len;
3250 uint8_t buffer[10000];
3251 const uint8_t *ciphertext;
3253 struct rte_cryptodev_info dev_info;
3255 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3256 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3257 printf("Device doesn't support scatter-gather. "
3262 /* Create SNOW 3G session */
3263 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3264 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3265 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3266 tdata->key.data, tdata->key.len,
3267 tdata->cipher_iv.len);
3271 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3272 /* Append data which is padded to a multiple of */
3273 /* the algorithms block size */
3274 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3276 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3277 plaintext_pad_len, 10, 0);
3278 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3279 plaintext_pad_len, 3, 0);
3281 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3282 "Failed to allocate input buffer in mempool");
3283 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3284 "Failed to allocate output buffer in mempool");
3286 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3288 /* Create SNOW 3G operation */
3289 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3290 tdata->cipher_iv.len,
3291 tdata->validCipherLenInBits.len,
3296 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3298 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3300 ut_params->obuf = ut_params->op->sym->m_dst;
3301 if (ut_params->obuf)
3302 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3303 plaintext_len, buffer);
3305 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3306 plaintext_len, buffer);
3308 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3311 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3313 tdata->ciphertext.data,
3314 tdata->validDataLenInBits.len,
3315 "SNOW 3G Ciphertext data not as expected");
3320 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3322 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3324 uint8_t curr_byte, prev_byte;
3325 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3326 uint8_t lower_byte_mask = (1 << offset) - 1;
3329 prev_byte = buffer[0];
3330 buffer[0] >>= offset;
3332 for (i = 1; i < length_in_bytes; i++) {
3333 curr_byte = buffer[i];
3334 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3335 (curr_byte >> offset);
3336 prev_byte = curr_byte;
3341 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3343 struct crypto_testsuite_params *ts_params = &testsuite_params;
3344 struct crypto_unittest_params *ut_params = &unittest_params;
3345 uint8_t *plaintext, *ciphertext;
3347 uint32_t plaintext_len;
3348 uint32_t plaintext_pad_len;
3349 uint8_t extra_offset = 4;
3350 uint8_t *expected_ciphertext_shifted;
3352 /* Create SNOW 3G session */
3353 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3354 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3355 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3356 tdata->key.data, tdata->key.len,
3357 tdata->cipher_iv.len);
3361 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3362 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3364 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3365 "Failed to allocate input buffer in mempool");
3366 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3367 "Failed to allocate output buffer in mempool");
3369 /* Clear mbuf payload */
3370 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3371 rte_pktmbuf_tailroom(ut_params->ibuf));
3373 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3375 * Append data which is padded to a
3376 * multiple of the algorithms block size
3378 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3380 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3383 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3385 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3386 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3388 #ifdef RTE_APP_TEST_DEBUG
3389 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3391 /* Create SNOW 3G operation */
3392 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3393 tdata->cipher_iv.len,
3394 tdata->validCipherLenInBits.len,
3399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3401 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3403 ut_params->obuf = ut_params->op->sym->m_dst;
3404 if (ut_params->obuf)
3405 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3407 ciphertext = plaintext;
3409 #ifdef RTE_APP_TEST_DEBUG
3410 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3413 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3415 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3416 "failed to reserve memory for ciphertext shifted\n");
3418 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3419 ceil_byte_length(tdata->ciphertext.len));
3420 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3423 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3425 expected_ciphertext_shifted,
3426 tdata->validDataLenInBits.len,
3428 "SNOW 3G Ciphertext data not as expected");
3432 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3434 struct crypto_testsuite_params *ts_params = &testsuite_params;
3435 struct crypto_unittest_params *ut_params = &unittest_params;
3439 uint8_t *plaintext, *ciphertext;
3440 unsigned ciphertext_pad_len;
3441 unsigned ciphertext_len;
3443 /* Create SNOW 3G session */
3444 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3445 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3446 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3447 tdata->key.data, tdata->key.len,
3448 tdata->cipher_iv.len);
3452 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3454 /* Clear mbuf payload */
3455 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3456 rte_pktmbuf_tailroom(ut_params->ibuf));
3458 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3459 /* Append data which is padded to a multiple of */
3460 /* the algorithms block size */
3461 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3462 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3463 ciphertext_pad_len);
3464 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3466 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3468 /* Create SNOW 3G operation */
3469 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3470 tdata->cipher_iv.len,
3471 tdata->validCipherLenInBits.len,
3476 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3478 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3479 ut_params->obuf = ut_params->op->sym->m_dst;
3480 if (ut_params->obuf)
3481 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3483 plaintext = ciphertext;
3485 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3488 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3489 tdata->plaintext.data,
3490 tdata->validDataLenInBits.len,
3491 "SNOW 3G Plaintext data not as expected");
3495 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3497 struct crypto_testsuite_params *ts_params = &testsuite_params;
3498 struct crypto_unittest_params *ut_params = &unittest_params;
3502 uint8_t *plaintext, *ciphertext;
3503 unsigned ciphertext_pad_len;
3504 unsigned ciphertext_len;
3506 /* Create SNOW 3G session */
3507 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3508 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3509 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3510 tdata->key.data, tdata->key.len,
3511 tdata->cipher_iv.len);
3515 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3516 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3518 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3519 "Failed to allocate input buffer");
3520 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3521 "Failed to allocate output buffer");
3523 /* Clear mbuf payload */
3524 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3525 rte_pktmbuf_tailroom(ut_params->ibuf));
3527 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3528 rte_pktmbuf_tailroom(ut_params->obuf));
3530 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3531 /* Append data which is padded to a multiple of */
3532 /* the algorithms block size */
3533 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3534 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3535 ciphertext_pad_len);
3536 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3537 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3539 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3541 /* Create SNOW 3G operation */
3542 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3543 tdata->cipher_iv.len,
3544 tdata->validCipherLenInBits.len,
3549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3551 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3552 ut_params->obuf = ut_params->op->sym->m_dst;
3553 if (ut_params->obuf)
3554 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3556 plaintext = ciphertext;
3558 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3561 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3562 tdata->plaintext.data,
3563 tdata->validDataLenInBits.len,
3564 "SNOW 3G Plaintext data not as expected");
3569 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3571 struct crypto_testsuite_params *ts_params = &testsuite_params;
3572 struct crypto_unittest_params *ut_params = &unittest_params;
3576 uint8_t *plaintext, *ciphertext;
3577 unsigned int plaintext_pad_len;
3578 unsigned int plaintext_len;
3580 struct rte_cryptodev_sym_capability_idx cap_idx;
3582 /* Check if device supports ZUC EEA3 */
3583 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3584 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3586 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3590 /* Check if device supports ZUC EIA3 */
3591 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3592 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3594 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3598 /* Create ZUC session */
3599 retval = create_zuc_cipher_auth_encrypt_generate_session(
3600 ts_params->valid_devs[0],
3604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3606 /* clear mbuf payload */
3607 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3608 rte_pktmbuf_tailroom(ut_params->ibuf));
3610 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3611 /* Append data which is padded to a multiple of */
3612 /* the algorithms block size */
3613 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3614 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3616 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3618 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3620 /* Create ZUC operation */
3621 retval = create_zuc_cipher_hash_generate_operation(tdata);
3625 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3627 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3628 ut_params->obuf = ut_params->op->sym->m_src;
3629 if (ut_params->obuf)
3630 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3632 ciphertext = plaintext;
3634 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3636 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3638 tdata->ciphertext.data,
3639 tdata->validDataLenInBits.len,
3640 "ZUC Ciphertext data not as expected");
3642 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3643 + plaintext_pad_len;
3646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3650 "ZUC Generated auth tag not as expected");
3655 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3657 struct crypto_testsuite_params *ts_params = &testsuite_params;
3658 struct crypto_unittest_params *ut_params = &unittest_params;
3662 uint8_t *plaintext, *ciphertext;
3663 unsigned plaintext_pad_len;
3664 unsigned plaintext_len;
3666 /* Create SNOW 3G session */
3667 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3668 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3669 RTE_CRYPTO_AUTH_OP_GENERATE,
3670 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3671 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3672 tdata->key.data, tdata->key.len,
3673 tdata->auth_iv.len, tdata->digest.len,
3674 tdata->cipher_iv.len);
3677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 /* clear mbuf payload */
3680 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3681 rte_pktmbuf_tailroom(ut_params->ibuf));
3683 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3684 /* Append data which is padded to a multiple of */
3685 /* the algorithms block size */
3686 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3687 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3689 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3691 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3693 /* Create SNOW 3G operation */
3694 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3695 tdata->digest.len, tdata->auth_iv.data,
3697 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3698 tdata->cipher_iv.data, tdata->cipher_iv.len,
3699 tdata->validCipherLenInBits.len,
3701 tdata->validAuthLenInBits.len,
3707 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3709 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3710 ut_params->obuf = ut_params->op->sym->m_src;
3711 if (ut_params->obuf)
3712 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3714 ciphertext = plaintext;
3716 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3718 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3720 tdata->ciphertext.data,
3721 tdata->validDataLenInBits.len,
3722 "SNOW 3G Ciphertext data not as expected");
3724 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3725 + plaintext_pad_len;
3728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3731 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3732 "SNOW 3G Generated auth tag not as expected");
3736 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3738 struct crypto_testsuite_params *ts_params = &testsuite_params;
3739 struct crypto_unittest_params *ut_params = &unittest_params;
3743 uint8_t *plaintext, *ciphertext;
3744 unsigned plaintext_pad_len;
3745 unsigned plaintext_len;
3747 /* Create SNOW 3G session */
3748 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3749 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3750 RTE_CRYPTO_AUTH_OP_GENERATE,
3751 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3752 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3753 tdata->key.data, tdata->key.len,
3754 tdata->auth_iv.len, tdata->digest.len,
3755 tdata->cipher_iv.len);
3759 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3761 /* clear mbuf payload */
3762 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3763 rte_pktmbuf_tailroom(ut_params->ibuf));
3765 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3766 /* Append data which is padded to a multiple of */
3767 /* the algorithms block size */
3768 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3769 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3771 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3773 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3775 /* Create SNOW 3G operation */
3776 retval = create_wireless_algo_auth_cipher_operation(
3778 tdata->cipher_iv.data, tdata->cipher_iv.len,
3779 tdata->auth_iv.data, tdata->auth_iv.len,
3781 tdata->validCipherLenInBits.len,
3783 tdata->validAuthLenInBits.len,
3789 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3791 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3792 ut_params->obuf = ut_params->op->sym->m_src;
3793 if (ut_params->obuf)
3794 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3796 ciphertext = plaintext;
3798 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3799 + plaintext_pad_len;
3800 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3803 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3805 tdata->ciphertext.data,
3806 tdata->validDataLenInBits.len,
3807 "SNOW 3G Ciphertext data not as expected");
3810 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3813 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3814 "SNOW 3G Generated auth tag not as expected");
3819 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3821 struct crypto_testsuite_params *ts_params = &testsuite_params;
3822 struct crypto_unittest_params *ut_params = &unittest_params;
3826 uint8_t *plaintext, *ciphertext;
3827 unsigned plaintext_pad_len;
3828 unsigned plaintext_len;
3830 /* Create KASUMI session */
3831 retval = create_wireless_algo_auth_cipher_session(
3832 ts_params->valid_devs[0],
3833 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3834 RTE_CRYPTO_AUTH_OP_GENERATE,
3835 RTE_CRYPTO_AUTH_KASUMI_F9,
3836 RTE_CRYPTO_CIPHER_KASUMI_F8,
3837 tdata->key.data, tdata->key.len,
3838 tdata->auth_iv.len, tdata->digest.len,
3839 tdata->cipher_iv.len);
3842 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3844 /* clear mbuf payload */
3845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846 rte_pktmbuf_tailroom(ut_params->ibuf));
3848 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3849 /* Append data which is padded to a multiple of */
3850 /* the algorithms block size */
3851 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3854 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3856 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3858 /* Create KASUMI operation */
3859 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3860 tdata->cipher_iv.data, tdata->cipher_iv.len,
3861 tdata->auth_iv.data, tdata->auth_iv.len,
3863 tdata->validCipherLenInBits.len,
3865 tdata->validAuthLenInBits.len,
3872 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3874 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3875 ut_params->obuf = ut_params->op->sym->m_src;
3876 if (ut_params->obuf)
3877 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3879 ciphertext = plaintext;
3882 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3884 tdata->ciphertext.data,
3885 tdata->validCipherLenInBits.len,
3886 "KASUMI Ciphertext data not as expected");
3887 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3888 + plaintext_pad_len;
3891 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3894 DIGEST_BYTE_LENGTH_KASUMI_F9,
3895 "KASUMI Generated auth tag not as expected");
3900 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3902 struct crypto_testsuite_params *ts_params = &testsuite_params;
3903 struct crypto_unittest_params *ut_params = &unittest_params;
3907 uint8_t *plaintext, *ciphertext;
3908 unsigned plaintext_pad_len;
3909 unsigned plaintext_len;
3911 /* Create KASUMI session */
3912 retval = create_wireless_algo_cipher_auth_session(
3913 ts_params->valid_devs[0],
3914 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3915 RTE_CRYPTO_AUTH_OP_GENERATE,
3916 RTE_CRYPTO_AUTH_KASUMI_F9,
3917 RTE_CRYPTO_CIPHER_KASUMI_F8,
3918 tdata->key.data, tdata->key.len,
3919 tdata->auth_iv.len, tdata->digest.len,
3920 tdata->cipher_iv.len);
3924 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3926 /* clear mbuf payload */
3927 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3928 rte_pktmbuf_tailroom(ut_params->ibuf));
3930 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3931 /* Append data which is padded to a multiple of */
3932 /* the algorithms block size */
3933 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3934 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3936 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3938 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3940 /* Create KASUMI operation */
3941 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3942 tdata->digest.len, tdata->auth_iv.data,
3944 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3945 tdata->cipher_iv.data, tdata->cipher_iv.len,
3946 tdata->validCipherLenInBits.len,
3948 tdata->validAuthLenInBits.len,
3954 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3956 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3957 ut_params->obuf = ut_params->op->sym->m_src;
3958 if (ut_params->obuf)
3959 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3961 ciphertext = plaintext;
3963 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3964 + plaintext_pad_len;
3967 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3969 tdata->ciphertext.data,
3970 tdata->validCipherLenInBits.len,
3971 "KASUMI Ciphertext data not as expected");
3974 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3977 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3978 "KASUMI Generated auth tag not as expected");
3983 test_zuc_encryption(const struct wireless_test_data *tdata)
3985 struct crypto_testsuite_params *ts_params = &testsuite_params;
3986 struct crypto_unittest_params *ut_params = &unittest_params;
3989 uint8_t *plaintext, *ciphertext;
3990 unsigned plaintext_pad_len;
3991 unsigned plaintext_len;
3993 struct rte_cryptodev_sym_capability_idx cap_idx;
3995 /* Check if device supports ZUC EEA3 */
3996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3997 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3999 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4003 /* Create ZUC session */
4004 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4006 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4007 tdata->key.data, tdata->key.len,
4008 tdata->cipher_iv.len);
4012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4014 /* Clear mbuf payload */
4015 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4016 rte_pktmbuf_tailroom(ut_params->ibuf));
4018 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4019 /* Append data which is padded to a multiple */
4020 /* of the algorithms block size */
4021 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4022 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4024 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4026 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4028 /* Create ZUC operation */
4029 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4030 tdata->cipher_iv.len,
4031 tdata->plaintext.len,
4036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4040 ut_params->obuf = ut_params->op->sym->m_dst;
4041 if (ut_params->obuf)
4042 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4044 ciphertext = plaintext;
4046 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4049 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4051 tdata->ciphertext.data,
4052 tdata->validCipherLenInBits.len,
4053 "ZUC Ciphertext data not as expected");
4058 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4060 struct crypto_testsuite_params *ts_params = &testsuite_params;
4061 struct crypto_unittest_params *ut_params = &unittest_params;
4065 unsigned int plaintext_pad_len;
4066 unsigned int plaintext_len;
4067 const uint8_t *ciphertext;
4068 uint8_t ciphertext_buffer[2048];
4069 struct rte_cryptodev_info dev_info;
4071 struct rte_cryptodev_sym_capability_idx cap_idx;
4073 /* Check if device supports ZUC EEA3 */
4074 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4075 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4081 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4082 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4083 printf("Device doesn't support scatter-gather. "
4088 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4090 /* Append data which is padded to a multiple */
4091 /* of the algorithms block size */
4092 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4094 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4095 plaintext_pad_len, 10, 0);
4097 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4098 tdata->plaintext.data);
4100 /* Create ZUC session */
4101 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4102 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4103 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4104 tdata->key.data, tdata->key.len,
4105 tdata->cipher_iv.len);
4109 /* Clear mbuf payload */
4111 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4113 /* Create ZUC operation */
4114 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4115 tdata->cipher_iv.len, tdata->plaintext.len,
4120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4122 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4124 ut_params->obuf = ut_params->op->sym->m_dst;
4125 if (ut_params->obuf)
4126 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4127 0, plaintext_len, ciphertext_buffer);
4129 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4130 0, plaintext_len, ciphertext_buffer);
4133 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4136 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4138 tdata->ciphertext.data,
4139 tdata->validCipherLenInBits.len,
4140 "ZUC Ciphertext data not as expected");
4146 test_zuc_authentication(const struct wireless_test_data *tdata)
4148 struct crypto_testsuite_params *ts_params = &testsuite_params;
4149 struct crypto_unittest_params *ut_params = &unittest_params;
4152 unsigned plaintext_pad_len;
4153 unsigned plaintext_len;
4156 struct rte_cryptodev_sym_capability_idx cap_idx;
4158 /* Check if device supports ZUC EIA3 */
4159 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4160 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4162 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4166 /* Create ZUC session */
4167 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4168 tdata->key.data, tdata->key.len,
4169 tdata->auth_iv.len, tdata->digest.len,
4170 RTE_CRYPTO_AUTH_OP_GENERATE,
4171 RTE_CRYPTO_AUTH_ZUC_EIA3);
4175 /* alloc mbuf and set payload */
4176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4179 rte_pktmbuf_tailroom(ut_params->ibuf));
4181 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 /* Append data which is padded to a multiple of */
4183 /* the algorithms block size */
4184 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4187 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4189 /* Create ZUC operation */
4190 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4191 tdata->auth_iv.data, tdata->auth_iv.len,
4192 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4193 tdata->validAuthLenInBits.len,
4198 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4200 ut_params->obuf = ut_params->op->sym->m_src;
4201 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4202 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4203 + plaintext_pad_len;
4206 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4209 DIGEST_BYTE_LENGTH_KASUMI_F9,
4210 "ZUC Generated auth tag not as expected");
4216 test_kasumi_encryption_test_case_1(void)
4218 return test_kasumi_encryption(&kasumi_test_case_1);
4222 test_kasumi_encryption_test_case_1_sgl(void)
4224 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4228 test_kasumi_encryption_test_case_1_oop(void)
4230 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4234 test_kasumi_encryption_test_case_1_oop_sgl(void)
4236 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4240 test_kasumi_encryption_test_case_2(void)
4242 return test_kasumi_encryption(&kasumi_test_case_2);
4246 test_kasumi_encryption_test_case_3(void)
4248 return test_kasumi_encryption(&kasumi_test_case_3);
4252 test_kasumi_encryption_test_case_4(void)
4254 return test_kasumi_encryption(&kasumi_test_case_4);
4258 test_kasumi_encryption_test_case_5(void)
4260 return test_kasumi_encryption(&kasumi_test_case_5);
4264 test_kasumi_decryption_test_case_1(void)
4266 return test_kasumi_decryption(&kasumi_test_case_1);
4270 test_kasumi_decryption_test_case_1_oop(void)
4272 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4276 test_kasumi_decryption_test_case_2(void)
4278 return test_kasumi_decryption(&kasumi_test_case_2);
4282 test_kasumi_decryption_test_case_3(void)
4284 return test_kasumi_decryption(&kasumi_test_case_3);
4288 test_kasumi_decryption_test_case_4(void)
4290 return test_kasumi_decryption(&kasumi_test_case_4);
4294 test_kasumi_decryption_test_case_5(void)
4296 return test_kasumi_decryption(&kasumi_test_case_5);
4299 test_snow3g_encryption_test_case_1(void)
4301 return test_snow3g_encryption(&snow3g_test_case_1);
4305 test_snow3g_encryption_test_case_1_oop(void)
4307 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4311 test_snow3g_encryption_test_case_1_oop_sgl(void)
4313 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4318 test_snow3g_encryption_test_case_1_offset_oop(void)
4320 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4324 test_snow3g_encryption_test_case_2(void)
4326 return test_snow3g_encryption(&snow3g_test_case_2);
4330 test_snow3g_encryption_test_case_3(void)
4332 return test_snow3g_encryption(&snow3g_test_case_3);
4336 test_snow3g_encryption_test_case_4(void)
4338 return test_snow3g_encryption(&snow3g_test_case_4);
4342 test_snow3g_encryption_test_case_5(void)
4344 return test_snow3g_encryption(&snow3g_test_case_5);
4348 test_snow3g_decryption_test_case_1(void)
4350 return test_snow3g_decryption(&snow3g_test_case_1);
4354 test_snow3g_decryption_test_case_1_oop(void)
4356 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4360 test_snow3g_decryption_test_case_2(void)
4362 return test_snow3g_decryption(&snow3g_test_case_2);
4366 test_snow3g_decryption_test_case_3(void)
4368 return test_snow3g_decryption(&snow3g_test_case_3);
4372 test_snow3g_decryption_test_case_4(void)
4374 return test_snow3g_decryption(&snow3g_test_case_4);
4378 test_snow3g_decryption_test_case_5(void)
4380 return test_snow3g_decryption(&snow3g_test_case_5);
4383 test_snow3g_cipher_auth_test_case_1(void)
4385 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4389 test_snow3g_auth_cipher_test_case_1(void)
4391 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4395 test_kasumi_auth_cipher_test_case_1(void)
4397 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4401 test_kasumi_cipher_auth_test_case_1(void)
4403 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4407 test_zuc_encryption_test_case_1(void)
4409 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4413 test_zuc_encryption_test_case_2(void)
4415 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4419 test_zuc_encryption_test_case_3(void)
4421 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4425 test_zuc_encryption_test_case_4(void)
4427 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4431 test_zuc_encryption_test_case_5(void)
4433 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4437 test_zuc_encryption_test_case_6_sgl(void)
4439 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4443 test_zuc_hash_generate_test_case_1(void)
4445 return test_zuc_authentication(&zuc_test_case_auth_1b);
4449 test_zuc_hash_generate_test_case_2(void)
4451 return test_zuc_authentication(&zuc_test_case_auth_90b);
4455 test_zuc_hash_generate_test_case_3(void)
4457 return test_zuc_authentication(&zuc_test_case_auth_577b);
4461 test_zuc_hash_generate_test_case_4(void)
4463 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4467 test_zuc_hash_generate_test_case_5(void)
4469 return test_zuc_authentication(&zuc_test_auth_5670b);
4473 test_zuc_hash_generate_test_case_6(void)
4475 return test_zuc_authentication(&zuc_test_case_auth_128b);
4479 test_zuc_hash_generate_test_case_7(void)
4481 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4485 test_zuc_hash_generate_test_case_8(void)
4487 return test_zuc_authentication(&zuc_test_case_auth_584b);
4491 test_zuc_cipher_auth_test_case_1(void)
4493 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4497 test_zuc_cipher_auth_test_case_2(void)
4499 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4503 test_3DES_chain_qat_all(void)
4505 struct crypto_testsuite_params *ts_params = &testsuite_params;
4508 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4509 ts_params->op_mpool, ts_params->valid_devs[0],
4510 RTE_CRYPTODEV_QAT_SYM_PMD,
4511 BLKCIPHER_3DES_CHAIN_TYPE);
4513 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4515 return TEST_SUCCESS;
4519 test_DES_cipheronly_qat_all(void)
4521 struct crypto_testsuite_params *ts_params = &testsuite_params;
4524 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4525 ts_params->op_mpool, ts_params->valid_devs[0],
4526 RTE_CRYPTODEV_QAT_SYM_PMD,
4527 BLKCIPHER_DES_CIPHERONLY_TYPE);
4529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4531 return TEST_SUCCESS;
4535 test_DES_docsis_openssl_all(void)
4537 struct crypto_testsuite_params *ts_params = &testsuite_params;
4540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4541 ts_params->op_mpool, ts_params->valid_devs[0],
4542 RTE_CRYPTODEV_OPENSSL_PMD,
4543 BLKCIPHER_DES_DOCSIS_TYPE);
4545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4547 return TEST_SUCCESS;
4551 test_3DES_chain_dpaa2_sec_all(void)
4553 struct crypto_testsuite_params *ts_params = &testsuite_params;
4556 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4557 ts_params->op_mpool, ts_params->valid_devs[0],
4558 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4559 BLKCIPHER_3DES_CHAIN_TYPE);
4561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4563 return TEST_SUCCESS;
4567 test_3DES_cipheronly_dpaa2_sec_all(void)
4569 struct crypto_testsuite_params *ts_params = &testsuite_params;
4572 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4573 ts_params->op_mpool, ts_params->valid_devs[0],
4574 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4575 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4577 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4579 return TEST_SUCCESS;
4583 test_3DES_cipheronly_qat_all(void)
4585 struct crypto_testsuite_params *ts_params = &testsuite_params;
4588 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4589 ts_params->op_mpool, ts_params->valid_devs[0],
4590 RTE_CRYPTODEV_QAT_SYM_PMD,
4591 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4593 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4595 return TEST_SUCCESS;
4599 test_3DES_chain_openssl_all(void)
4601 struct crypto_testsuite_params *ts_params = &testsuite_params;
4604 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4605 ts_params->op_mpool, ts_params->valid_devs[0],
4606 RTE_CRYPTODEV_OPENSSL_PMD,
4607 BLKCIPHER_3DES_CHAIN_TYPE);
4609 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4611 return TEST_SUCCESS;
4615 test_3DES_cipheronly_openssl_all(void)
4617 struct crypto_testsuite_params *ts_params = &testsuite_params;
4620 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4621 ts_params->op_mpool, ts_params->valid_devs[0],
4622 RTE_CRYPTODEV_OPENSSL_PMD,
4623 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4625 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4627 return TEST_SUCCESS;
4630 /* ***** AES-GCM Tests ***** */
4633 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4634 const uint8_t *key, const uint8_t key_len,
4635 const uint16_t aad_len, const uint8_t auth_len,
4637 enum rte_crypto_auth_operation auth_op)
4639 uint8_t cipher_key[key_len];
4641 struct crypto_unittest_params *ut_params = &unittest_params;
4643 memcpy(cipher_key, key, key_len);
4645 /* Setup Cipher Parameters */
4646 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4647 ut_params->cipher_xform.next = NULL;
4649 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4650 ut_params->auth_xform.auth.op = auth_op;
4651 ut_params->cipher_xform.cipher.op = op;
4652 ut_params->cipher_xform.cipher.key.data = cipher_key;
4653 ut_params->cipher_xform.cipher.key.length = key_len;
4654 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
4655 ut_params->cipher_xform.cipher.iv.length = iv_len;
4657 TEST_HEXDUMP(stdout, "key:", key, key_len);
4659 /* Setup Authentication Parameters */
4660 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4661 ut_params->auth_xform.next = NULL;
4663 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4665 ut_params->auth_xform.auth.digest_length = auth_len;
4666 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4667 ut_params->auth_xform.auth.key.length = 0;
4668 ut_params->auth_xform.auth.key.data = NULL;
4670 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4671 ut_params->cipher_xform.next = &ut_params->auth_xform;
4673 /* Create Crypto session*/
4674 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4675 &ut_params->cipher_xform);
4676 } else {/* Create Crypto session*/
4677 ut_params->auth_xform.next = &ut_params->cipher_xform;
4678 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4679 &ut_params->auth_xform);
4682 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4688 create_gcm_xforms(struct rte_crypto_op *op,
4689 enum rte_crypto_cipher_operation cipher_op,
4690 uint8_t *key, const uint8_t key_len,
4691 const uint8_t aad_len, const uint8_t auth_len,
4693 enum rte_crypto_auth_operation auth_op)
4695 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4696 "failed to allocate space for crypto transforms");
4698 struct rte_crypto_sym_op *sym_op = op->sym;
4700 /* Setup Cipher Parameters */
4701 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4702 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4703 sym_op->xform->cipher.op = cipher_op;
4704 sym_op->xform->cipher.key.data = key;
4705 sym_op->xform->cipher.key.length = key_len;
4706 sym_op->xform->cipher.iv.offset = IV_OFFSET;
4707 sym_op->xform->cipher.iv.length = iv_len;
4709 TEST_HEXDUMP(stdout, "key:", key, key_len);
4711 /* Setup Authentication Parameters */
4712 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4713 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4714 sym_op->xform->next->auth.op = auth_op;
4715 sym_op->xform->next->auth.digest_length = auth_len;
4716 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4717 sym_op->xform->next->auth.key.length = 0;
4718 sym_op->xform->next->auth.key.data = NULL;
4719 sym_op->xform->next->next = NULL;
4725 create_gcm_operation(enum rte_crypto_cipher_operation op,
4726 const struct gcm_test_data *tdata)
4728 struct crypto_testsuite_params *ts_params = &testsuite_params;
4729 struct crypto_unittest_params *ut_params = &unittest_params;
4731 uint8_t *plaintext, *ciphertext;
4732 unsigned int aad_pad_len, plaintext_pad_len;
4734 /* Generate Crypto op data structure */
4735 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4736 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4737 TEST_ASSERT_NOT_NULL(ut_params->op,
4738 "Failed to allocate symmetric crypto operation struct");
4740 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4742 /* Append aad data */
4743 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4744 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4746 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4747 "no room to append aad");
4749 sym_op->auth.aad.phys_addr =
4750 rte_pktmbuf_mtophys(ut_params->ibuf);
4751 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4752 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4755 /* Append IV at the end of the crypto operation*/
4756 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4757 uint8_t *, IV_OFFSET);
4759 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4760 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4763 /* Append plaintext/ciphertext */
4764 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4765 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4766 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4768 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4770 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4771 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4772 tdata->plaintext.len);
4774 if (ut_params->obuf) {
4775 ciphertext = (uint8_t *)rte_pktmbuf_append(
4777 plaintext_pad_len + aad_pad_len);
4778 TEST_ASSERT_NOT_NULL(ciphertext,
4779 "no room to append ciphertext");
4781 memset(ciphertext + aad_pad_len, 0,
4782 tdata->ciphertext.len);
4785 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4786 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4788 TEST_ASSERT_NOT_NULL(ciphertext,
4789 "no room to append ciphertext");
4791 memcpy(ciphertext, tdata->ciphertext.data,
4792 tdata->ciphertext.len);
4793 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4794 tdata->ciphertext.len);
4796 if (ut_params->obuf) {
4797 plaintext = (uint8_t *)rte_pktmbuf_append(
4799 plaintext_pad_len + aad_pad_len);
4800 TEST_ASSERT_NOT_NULL(plaintext,
4801 "no room to append plaintext");
4803 memset(plaintext + aad_pad_len, 0,
4804 tdata->plaintext.len);
4808 /* Append digest data */
4809 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4810 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4811 ut_params->obuf ? ut_params->obuf :
4813 tdata->auth_tag.len);
4814 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4815 "no room to append digest");
4816 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4817 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4818 ut_params->obuf ? ut_params->obuf :
4823 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4824 ut_params->ibuf, tdata->auth_tag.len);
4825 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4826 "no room to append digest");
4827 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4829 plaintext_pad_len + aad_pad_len);
4831 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4832 tdata->auth_tag.len);
4833 TEST_HEXDUMP(stdout, "digest:",
4834 sym_op->auth.digest.data,
4835 tdata->auth_tag.len);
4838 sym_op->cipher.data.length = tdata->plaintext.len;
4839 sym_op->cipher.data.offset = aad_pad_len;
4841 sym_op->auth.data.length = tdata->plaintext.len;
4842 sym_op->auth.data.offset = aad_pad_len;
4848 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4850 struct crypto_testsuite_params *ts_params = &testsuite_params;
4851 struct crypto_unittest_params *ut_params = &unittest_params;
4854 uint8_t *ciphertext, *auth_tag;
4855 uint16_t plaintext_pad_len;
4858 /* Create GCM session */
4859 retval = create_gcm_session(ts_params->valid_devs[0],
4860 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4861 tdata->key.data, tdata->key.len,
4862 tdata->aad.len, tdata->auth_tag.len,
4864 RTE_CRYPTO_AUTH_OP_GENERATE);
4868 if (tdata->aad.len > MBUF_SIZE) {
4869 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4870 /* Populate full size of add data */
4871 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4872 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4874 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4876 /* clear mbuf payload */
4877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4878 rte_pktmbuf_tailroom(ut_params->ibuf));
4880 /* Create GCM operation */
4881 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4885 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4887 ut_params->op->sym->m_src = ut_params->ibuf;
4889 /* Process crypto operation */
4890 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4891 ut_params->op), "failed to process sym crypto op");
4893 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4894 "crypto op processing failed");
4896 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4898 if (ut_params->op->sym->m_dst) {
4899 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4901 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4902 uint8_t *, plaintext_pad_len);
4904 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4906 ut_params->op->sym->cipher.data.offset);
4907 auth_tag = ciphertext + plaintext_pad_len;
4910 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4911 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4914 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4916 tdata->ciphertext.data,
4917 tdata->ciphertext.len,
4918 "GCM Ciphertext data not as expected");
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4922 tdata->auth_tag.data,
4923 tdata->auth_tag.len,
4924 "GCM Generated auth tag not as expected");
4931 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4933 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4937 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4939 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4943 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4945 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4949 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4951 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4955 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4957 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4961 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4963 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4967 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4969 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4973 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4975 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4979 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4981 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4985 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4987 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4991 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4993 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4997 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4999 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5003 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
5005 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5009 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
5011 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5015 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
5017 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5021 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
5023 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5027 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5029 struct crypto_testsuite_params *ts_params = &testsuite_params;
5030 struct crypto_unittest_params *ut_params = &unittest_params;
5036 /* Create GCM session */
5037 retval = create_gcm_session(ts_params->valid_devs[0],
5038 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5039 tdata->key.data, tdata->key.len,
5040 tdata->aad.len, tdata->auth_tag.len,
5042 RTE_CRYPTO_AUTH_OP_VERIFY);
5046 /* alloc mbuf and set payload */
5047 if (tdata->aad.len > MBUF_SIZE) {
5048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5049 /* Populate full size of add data */
5050 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5051 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5053 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5055 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5056 rte_pktmbuf_tailroom(ut_params->ibuf));
5058 /* Create GCM operation */
5059 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5063 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5065 ut_params->op->sym->m_src = ut_params->ibuf;
5067 /* Process crypto operation */
5068 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5069 ut_params->op), "failed to process sym crypto op");
5071 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5072 "crypto op processing failed");
5074 if (ut_params->op->sym->m_dst)
5075 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5078 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5080 ut_params->op->sym->cipher.data.offset);
5082 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5087 tdata->plaintext.data,
5088 tdata->plaintext.len,
5089 "GCM plaintext data not as expected");
5091 TEST_ASSERT_EQUAL(ut_params->op->status,
5092 RTE_CRYPTO_OP_STATUS_SUCCESS,
5093 "GCM authentication failed");
5098 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5100 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5104 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5106 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5110 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5112 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5116 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5118 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5122 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5124 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5128 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5130 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5134 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5136 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5140 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5142 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5146 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5148 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5152 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5154 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5158 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5160 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5164 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5166 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5170 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5172 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5176 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5178 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5182 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5184 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5188 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5190 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5194 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5196 struct crypto_testsuite_params *ts_params = &testsuite_params;
5197 struct crypto_unittest_params *ut_params = &unittest_params;
5200 uint8_t *ciphertext, *auth_tag;
5201 uint16_t plaintext_pad_len;
5203 /* Create GCM session */
5204 retval = create_gcm_session(ts_params->valid_devs[0],
5205 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5206 tdata->key.data, tdata->key.len,
5207 tdata->aad.len, tdata->auth_tag.len,
5209 RTE_CRYPTO_AUTH_OP_GENERATE);
5213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5214 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5216 /* clear mbuf payload */
5217 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5218 rte_pktmbuf_tailroom(ut_params->ibuf));
5219 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5220 rte_pktmbuf_tailroom(ut_params->obuf));
5222 /* Create GCM operation */
5223 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5227 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5229 ut_params->op->sym->m_src = ut_params->ibuf;
5230 ut_params->op->sym->m_dst = ut_params->obuf;
5232 /* Process crypto operation */
5233 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5234 ut_params->op), "failed to process sym crypto op");
5236 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5237 "crypto op processing failed");
5239 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5241 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5242 ut_params->op->sym->cipher.data.offset);
5243 auth_tag = ciphertext + plaintext_pad_len;
5245 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5246 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5249 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5251 tdata->ciphertext.data,
5252 tdata->ciphertext.len,
5253 "GCM Ciphertext data not as expected");
5255 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5257 tdata->auth_tag.data,
5258 tdata->auth_tag.len,
5259 "GCM Generated auth tag not as expected");
5266 test_mb_AES_GCM_authenticated_encryption_oop(void)
5268 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5272 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5274 struct crypto_testsuite_params *ts_params = &testsuite_params;
5275 struct crypto_unittest_params *ut_params = &unittest_params;
5280 /* Create GCM session */
5281 retval = create_gcm_session(ts_params->valid_devs[0],
5282 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5283 tdata->key.data, tdata->key.len,
5284 tdata->aad.len, tdata->auth_tag.len,
5286 RTE_CRYPTO_AUTH_OP_VERIFY);
5290 /* alloc mbuf and set payload */
5291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5292 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5295 rte_pktmbuf_tailroom(ut_params->ibuf));
5296 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5297 rte_pktmbuf_tailroom(ut_params->obuf));
5299 /* Create GCM operation */
5300 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5304 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5306 ut_params->op->sym->m_src = ut_params->ibuf;
5307 ut_params->op->sym->m_dst = ut_params->obuf;
5309 /* Process crypto operation */
5310 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5311 ut_params->op), "failed to process sym crypto op");
5313 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5314 "crypto op processing failed");
5316 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5317 ut_params->op->sym->cipher.data.offset);
5319 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5322 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5324 tdata->plaintext.data,
5325 tdata->plaintext.len,
5326 "GCM plaintext data not as expected");
5328 TEST_ASSERT_EQUAL(ut_params->op->status,
5329 RTE_CRYPTO_OP_STATUS_SUCCESS,
5330 "GCM authentication failed");
5335 test_mb_AES_GCM_authenticated_decryption_oop(void)
5337 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5341 test_AES_GCM_authenticated_encryption_sessionless(
5342 const struct gcm_test_data *tdata)
5344 struct crypto_testsuite_params *ts_params = &testsuite_params;
5345 struct crypto_unittest_params *ut_params = &unittest_params;
5348 uint8_t *ciphertext, *auth_tag;
5349 uint16_t plaintext_pad_len;
5350 uint8_t key[tdata->key.len + 1];
5352 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5354 /* clear mbuf payload */
5355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5356 rte_pktmbuf_tailroom(ut_params->ibuf));
5358 /* Create GCM operation */
5359 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5363 /* Create GCM xforms */
5364 memcpy(key, tdata->key.data, tdata->key.len);
5365 retval = create_gcm_xforms(ut_params->op,
5366 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5367 key, tdata->key.len,
5368 tdata->aad.len, tdata->auth_tag.len,
5370 RTE_CRYPTO_AUTH_OP_GENERATE);
5374 ut_params->op->sym->m_src = ut_params->ibuf;
5376 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5377 RTE_CRYPTO_OP_SESSIONLESS,
5378 "crypto op session type not sessionless");
5380 /* Process crypto operation */
5381 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5382 ut_params->op), "failed to process sym crypto op");
5384 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5386 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5387 "crypto op status not success");
5389 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5391 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5392 ut_params->op->sym->cipher.data.offset);
5393 auth_tag = ciphertext + plaintext_pad_len;
5395 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5396 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5399 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5401 tdata->ciphertext.data,
5402 tdata->ciphertext.len,
5403 "GCM Ciphertext data not as expected");
5405 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5407 tdata->auth_tag.data,
5408 tdata->auth_tag.len,
5409 "GCM Generated auth tag not as expected");
5416 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5418 return test_AES_GCM_authenticated_encryption_sessionless(
5423 test_AES_GCM_authenticated_decryption_sessionless(
5424 const struct gcm_test_data *tdata)
5426 struct crypto_testsuite_params *ts_params = &testsuite_params;
5427 struct crypto_unittest_params *ut_params = &unittest_params;
5431 uint8_t key[tdata->key.len + 1];
5433 /* alloc mbuf and set payload */
5434 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5436 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5437 rte_pktmbuf_tailroom(ut_params->ibuf));
5439 /* Create GCM operation */
5440 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5444 /* Create GCM xforms */
5445 memcpy(key, tdata->key.data, tdata->key.len);
5446 retval = create_gcm_xforms(ut_params->op,
5447 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5448 key, tdata->key.len,
5449 tdata->aad.len, tdata->auth_tag.len,
5451 RTE_CRYPTO_AUTH_OP_VERIFY);
5455 ut_params->op->sym->m_src = ut_params->ibuf;
5457 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5458 RTE_CRYPTO_OP_SESSIONLESS,
5459 "crypto op session type not sessionless");
5461 /* Process crypto operation */
5462 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5463 ut_params->op), "failed to process sym crypto op");
5465 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5467 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5468 "crypto op status not success");
5470 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5471 ut_params->op->sym->cipher.data.offset);
5473 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5476 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5478 tdata->plaintext.data,
5479 tdata->plaintext.len,
5480 "GCM plaintext data not as expected");
5482 TEST_ASSERT_EQUAL(ut_params->op->status,
5483 RTE_CRYPTO_OP_STATUS_SUCCESS,
5484 "GCM authentication failed");
5489 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5491 return test_AES_GCM_authenticated_decryption_sessionless(
5498 struct crypto_testsuite_params *ts_params = &testsuite_params;
5499 struct rte_cryptodev_stats stats;
5500 struct rte_cryptodev *dev;
5501 cryptodev_stats_get_t temp_pfn;
5503 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5504 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5505 &stats) == -ENODEV),
5506 "rte_cryptodev_stats_get invalid dev failed");
5507 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5508 "rte_cryptodev_stats_get invalid Param failed");
5509 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5510 temp_pfn = dev->dev_ops->stats_get;
5511 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5512 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5514 "rte_cryptodev_stats_get invalid Param failed");
5515 dev->dev_ops->stats_get = temp_pfn;
5517 /* Test expected values */
5519 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5521 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5523 "rte_cryptodev_stats_get failed");
5524 TEST_ASSERT((stats.enqueued_count == 1),
5525 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5526 TEST_ASSERT((stats.dequeued_count == 1),
5527 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5528 TEST_ASSERT((stats.enqueue_err_count == 0),
5529 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5530 TEST_ASSERT((stats.dequeue_err_count == 0),
5531 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5533 /* invalid device but should ignore and not reset device stats*/
5534 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5535 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5537 "rte_cryptodev_stats_get failed");
5538 TEST_ASSERT((stats.enqueued_count == 1),
5539 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5541 /* check that a valid reset clears stats */
5542 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
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 == 0),
5547 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5548 TEST_ASSERT((stats.dequeued_count == 0),
5549 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5551 return TEST_SUCCESS;
5554 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5555 struct crypto_unittest_params *ut_params,
5556 enum rte_crypto_auth_operation op,
5557 const struct HMAC_MD5_vector *test_case)
5561 memcpy(key, test_case->key.data, test_case->key.len);
5563 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5564 ut_params->auth_xform.next = NULL;
5565 ut_params->auth_xform.auth.op = op;
5567 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5569 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5570 ut_params->auth_xform.auth.add_auth_data_length = 0;
5571 ut_params->auth_xform.auth.key.length = test_case->key.len;
5572 ut_params->auth_xform.auth.key.data = key;
5574 ut_params->sess = rte_cryptodev_sym_session_create(
5575 ts_params->valid_devs[0], &ut_params->auth_xform);
5577 if (ut_params->sess == NULL)
5580 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5583 rte_pktmbuf_tailroom(ut_params->ibuf));
5588 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5589 const struct HMAC_MD5_vector *test_case,
5590 uint8_t **plaintext)
5592 uint16_t plaintext_pad_len;
5594 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5596 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5599 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5601 memcpy(*plaintext, test_case->plaintext.data,
5602 test_case->plaintext.len);
5604 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5605 ut_params->ibuf, MD5_DIGEST_LEN);
5606 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5607 "no room to append digest");
5608 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5609 ut_params->ibuf, plaintext_pad_len);
5611 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5612 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5613 test_case->auth_tag.len);
5616 sym_op->auth.data.offset = 0;
5617 sym_op->auth.data.length = test_case->plaintext.len;
5619 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5620 ut_params->op->sym->m_src = ut_params->ibuf;
5626 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5628 uint16_t plaintext_pad_len;
5629 uint8_t *plaintext, *auth_tag;
5631 struct crypto_testsuite_params *ts_params = &testsuite_params;
5632 struct crypto_unittest_params *ut_params = &unittest_params;
5634 if (MD5_HMAC_create_session(ts_params, ut_params,
5635 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5638 /* Generate Crypto op data structure */
5639 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5640 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5641 TEST_ASSERT_NOT_NULL(ut_params->op,
5642 "Failed to allocate symmetric crypto operation struct");
5644 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5647 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5650 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5651 ut_params->op), "failed to process sym crypto op");
5653 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5654 "crypto op processing failed");
5656 if (ut_params->op->sym->m_dst) {
5657 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5658 uint8_t *, plaintext_pad_len);
5660 auth_tag = plaintext + plaintext_pad_len;
5663 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5665 test_case->auth_tag.data,
5666 test_case->auth_tag.len,
5667 "HMAC_MD5 generated tag not as expected");
5669 return TEST_SUCCESS;
5673 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5677 struct crypto_testsuite_params *ts_params = &testsuite_params;
5678 struct crypto_unittest_params *ut_params = &unittest_params;
5680 if (MD5_HMAC_create_session(ts_params, ut_params,
5681 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5685 /* Generate Crypto op data structure */
5686 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5687 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5688 TEST_ASSERT_NOT_NULL(ut_params->op,
5689 "Failed to allocate symmetric crypto operation struct");
5691 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5694 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5695 ut_params->op), "failed to process sym crypto op");
5697 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5698 "HMAC_MD5 crypto op processing failed");
5700 return TEST_SUCCESS;
5704 test_MD5_HMAC_generate_case_1(void)
5706 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5710 test_MD5_HMAC_verify_case_1(void)
5712 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5716 test_MD5_HMAC_generate_case_2(void)
5718 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5722 test_MD5_HMAC_verify_case_2(void)
5724 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5728 test_multi_session(void)
5730 struct crypto_testsuite_params *ts_params = &testsuite_params;
5731 struct crypto_unittest_params *ut_params = &unittest_params;
5733 struct rte_cryptodev_info dev_info;
5734 struct rte_cryptodev_sym_session **sessions;
5738 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5739 aes_cbc_key, hmac_sha512_key);
5742 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5744 sessions = rte_malloc(NULL,
5745 (sizeof(struct rte_cryptodev_sym_session *) *
5746 dev_info.sym.max_nb_sessions) + 1, 0);
5748 /* Create multiple crypto sessions*/
5749 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5750 sessions[i] = rte_cryptodev_sym_session_create(
5751 ts_params->valid_devs[0],
5752 &ut_params->auth_xform);
5753 TEST_ASSERT_NOT_NULL(sessions[i],
5754 "Session creation failed at session number %u",
5757 /* Attempt to send a request on each session */
5758 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5762 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5763 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5765 "Failed to perform decrypt on request number %u.", i);
5766 /* free crypto operation structure */
5768 rte_crypto_op_free(ut_params->op);
5771 * free mbuf - both obuf and ibuf are usually the same,
5772 * so check if they point at the same address is necessary,
5773 * to avoid freeing the mbuf twice.
5775 if (ut_params->obuf) {
5776 rte_pktmbuf_free(ut_params->obuf);
5777 if (ut_params->ibuf == ut_params->obuf)
5778 ut_params->ibuf = 0;
5779 ut_params->obuf = 0;
5781 if (ut_params->ibuf) {
5782 rte_pktmbuf_free(ut_params->ibuf);
5783 ut_params->ibuf = 0;
5787 /* Next session create should fail */
5788 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5789 &ut_params->auth_xform);
5790 TEST_ASSERT_NULL(sessions[i],
5791 "Session creation succeeded unexpectedly!");
5793 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5794 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5799 return TEST_SUCCESS;
5802 struct multi_session_params {
5803 struct crypto_unittest_params ut_params;
5804 uint8_t *cipher_key;
5806 const uint8_t *cipher;
5807 const uint8_t *digest;
5811 #define MB_SESSION_NUMBER 3
5814 test_multi_session_random_usage(void)
5816 struct crypto_testsuite_params *ts_params = &testsuite_params;
5817 struct rte_cryptodev_info dev_info;
5818 struct rte_cryptodev_sym_session **sessions;
5820 struct multi_session_params ut_paramz[] = {
5823 .cipher_key = ms_aes_cbc_key0,
5824 .hmac_key = ms_hmac_key0,
5825 .cipher = ms_aes_cbc_cipher0,
5826 .digest = ms_hmac_digest0,
5827 .iv = ms_aes_cbc_iv0
5830 .cipher_key = ms_aes_cbc_key1,
5831 .hmac_key = ms_hmac_key1,
5832 .cipher = ms_aes_cbc_cipher1,
5833 .digest = ms_hmac_digest1,
5834 .iv = ms_aes_cbc_iv1
5837 .cipher_key = ms_aes_cbc_key2,
5838 .hmac_key = ms_hmac_key2,
5839 .cipher = ms_aes_cbc_cipher2,
5840 .digest = ms_hmac_digest2,
5841 .iv = ms_aes_cbc_iv2
5846 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5848 sessions = rte_malloc(NULL,
5849 (sizeof(struct rte_cryptodev_sym_session *)
5850 * dev_info.sym.max_nb_sessions) + 1, 0);
5852 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5853 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5854 sizeof(struct crypto_unittest_params));
5856 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5857 &ut_paramz[i].ut_params,
5858 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5860 /* Create multiple crypto sessions*/
5861 sessions[i] = rte_cryptodev_sym_session_create(
5862 ts_params->valid_devs[0],
5863 &ut_paramz[i].ut_params.auth_xform);
5865 TEST_ASSERT_NOT_NULL(sessions[i],
5866 "Session creation failed at session number %u",
5872 for (i = 0; i < 40000; i++) {
5874 j = rand() % MB_SESSION_NUMBER;
5876 TEST_ASSERT_SUCCESS(
5877 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5879 &ut_paramz[j].ut_params,
5880 ts_params, ut_paramz[j].cipher,
5881 ut_paramz[j].digest,
5883 "Failed to perform decrypt on request number %u.", i);
5885 if (ut_paramz[j].ut_params.op)
5886 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5889 * free mbuf - both obuf and ibuf are usually the same,
5890 * so check if they point at the same address is necessary,
5891 * to avoid freeing the mbuf twice.
5893 if (ut_paramz[j].ut_params.obuf) {
5894 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5895 if (ut_paramz[j].ut_params.ibuf
5896 == ut_paramz[j].ut_params.obuf)
5897 ut_paramz[j].ut_params.ibuf = 0;
5898 ut_paramz[j].ut_params.obuf = 0;
5900 if (ut_paramz[j].ut_params.ibuf) {
5901 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5902 ut_paramz[j].ut_params.ibuf = 0;
5906 for (i = 0; i < MB_SESSION_NUMBER; i++)
5907 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5912 return TEST_SUCCESS;
5916 test_null_cipher_only_operation(void)
5918 struct crypto_testsuite_params *ts_params = &testsuite_params;
5919 struct crypto_unittest_params *ut_params = &unittest_params;
5921 /* Generate test mbuf data and space for digest */
5922 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5923 catch_22_quote, QUOTE_512_BYTES, 0);
5925 /* Setup Cipher Parameters */
5926 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5927 ut_params->cipher_xform.next = NULL;
5929 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5930 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5932 /* Create Crypto session*/
5933 ut_params->sess = rte_cryptodev_sym_session_create(
5934 ts_params->valid_devs[0], &ut_params->cipher_xform);
5935 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5937 /* Generate Crypto op data structure */
5938 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5939 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5940 TEST_ASSERT_NOT_NULL(ut_params->op,
5941 "Failed to allocate symmetric crypto operation struct");
5943 /* Set crypto operation data parameters */
5944 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5946 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5948 /* set crypto operation source mbuf */
5949 sym_op->m_src = ut_params->ibuf;
5951 sym_op->cipher.data.offset = 0;
5952 sym_op->cipher.data.length = QUOTE_512_BYTES;
5954 /* Process crypto operation */
5955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5957 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5959 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5960 "crypto operation processing failed");
5963 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5964 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5967 "Ciphertext data not as expected");
5969 return TEST_SUCCESS;
5973 test_null_auth_only_operation(void)
5975 struct crypto_testsuite_params *ts_params = &testsuite_params;
5976 struct crypto_unittest_params *ut_params = &unittest_params;
5978 /* Generate test mbuf data and space for digest */
5979 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5980 catch_22_quote, QUOTE_512_BYTES, 0);
5982 /* Setup HMAC Parameters */
5983 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5984 ut_params->auth_xform.next = NULL;
5986 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5987 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5989 /* Create Crypto session*/
5990 ut_params->sess = rte_cryptodev_sym_session_create(
5991 ts_params->valid_devs[0], &ut_params->auth_xform);
5992 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5994 /* Generate Crypto op data structure */
5995 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5996 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5997 TEST_ASSERT_NOT_NULL(ut_params->op,
5998 "Failed to allocate symmetric crypto operation struct");
6000 /* Set crypto operation data parameters */
6001 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6003 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6005 sym_op->m_src = ut_params->ibuf;
6007 sym_op->auth.data.offset = 0;
6008 sym_op->auth.data.length = QUOTE_512_BYTES;
6010 /* Process crypto operation */
6011 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6013 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6015 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6016 "crypto operation processing failed");
6018 return TEST_SUCCESS;
6022 test_null_cipher_auth_operation(void)
6024 struct crypto_testsuite_params *ts_params = &testsuite_params;
6025 struct crypto_unittest_params *ut_params = &unittest_params;
6027 /* Generate test mbuf data and space for digest */
6028 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6029 catch_22_quote, QUOTE_512_BYTES, 0);
6031 /* Setup Cipher Parameters */
6032 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6033 ut_params->cipher_xform.next = &ut_params->auth_xform;
6035 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6036 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6038 /* Setup HMAC Parameters */
6039 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6040 ut_params->auth_xform.next = NULL;
6042 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6043 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6045 /* Create Crypto session*/
6046 ut_params->sess = rte_cryptodev_sym_session_create(
6047 ts_params->valid_devs[0], &ut_params->cipher_xform);
6048 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6050 /* Generate Crypto op data structure */
6051 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6052 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6053 TEST_ASSERT_NOT_NULL(ut_params->op,
6054 "Failed to allocate symmetric crypto operation struct");
6056 /* Set crypto operation data parameters */
6057 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6059 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6061 sym_op->m_src = ut_params->ibuf;
6063 sym_op->cipher.data.offset = 0;
6064 sym_op->cipher.data.length = QUOTE_512_BYTES;
6066 sym_op->auth.data.offset = 0;
6067 sym_op->auth.data.length = QUOTE_512_BYTES;
6069 /* Process crypto operation */
6070 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6072 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6074 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6075 "crypto operation processing failed");
6078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6079 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6082 "Ciphertext data not as expected");
6084 return TEST_SUCCESS;
6088 test_null_auth_cipher_operation(void)
6090 struct crypto_testsuite_params *ts_params = &testsuite_params;
6091 struct crypto_unittest_params *ut_params = &unittest_params;
6093 /* Generate test mbuf data and space for digest */
6094 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6095 catch_22_quote, QUOTE_512_BYTES, 0);
6097 /* Setup Cipher Parameters */
6098 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6099 ut_params->cipher_xform.next = NULL;
6101 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6102 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6104 /* Setup HMAC Parameters */
6105 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6106 ut_params->auth_xform.next = &ut_params->cipher_xform;
6108 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6109 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6111 /* Create Crypto session*/
6112 ut_params->sess = rte_cryptodev_sym_session_create(
6113 ts_params->valid_devs[0], &ut_params->cipher_xform);
6114 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6116 /* Generate Crypto op data structure */
6117 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6118 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6119 TEST_ASSERT_NOT_NULL(ut_params->op,
6120 "Failed to allocate symmetric crypto operation struct");
6122 /* Set crypto operation data parameters */
6123 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6125 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6127 sym_op->m_src = ut_params->ibuf;
6129 sym_op->cipher.data.offset = 0;
6130 sym_op->cipher.data.length = QUOTE_512_BYTES;
6132 sym_op->auth.data.offset = 0;
6133 sym_op->auth.data.length = QUOTE_512_BYTES;
6135 /* Process crypto operation */
6136 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6138 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6140 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6141 "crypto operation processing failed");
6144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6145 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6148 "Ciphertext data not as expected");
6150 return TEST_SUCCESS;
6155 test_null_invalid_operation(void)
6157 struct crypto_testsuite_params *ts_params = &testsuite_params;
6158 struct crypto_unittest_params *ut_params = &unittest_params;
6160 /* Setup Cipher Parameters */
6161 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6162 ut_params->cipher_xform.next = NULL;
6164 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6165 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6167 /* Create Crypto session*/
6168 ut_params->sess = rte_cryptodev_sym_session_create(
6169 ts_params->valid_devs[0], &ut_params->cipher_xform);
6170 TEST_ASSERT_NULL(ut_params->sess,
6171 "Session creation succeeded unexpectedly");
6174 /* Setup HMAC Parameters */
6175 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6176 ut_params->auth_xform.next = NULL;
6178 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6179 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6181 /* Create Crypto session*/
6182 ut_params->sess = rte_cryptodev_sym_session_create(
6183 ts_params->valid_devs[0], &ut_params->auth_xform);
6184 TEST_ASSERT_NULL(ut_params->sess,
6185 "Session creation succeeded unexpectedly");
6187 return TEST_SUCCESS;
6191 #define NULL_BURST_LENGTH (32)
6194 test_null_burst_operation(void)
6196 struct crypto_testsuite_params *ts_params = &testsuite_params;
6197 struct crypto_unittest_params *ut_params = &unittest_params;
6199 unsigned i, burst_len = NULL_BURST_LENGTH;
6201 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6202 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6204 /* Setup Cipher Parameters */
6205 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6206 ut_params->cipher_xform.next = &ut_params->auth_xform;
6208 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6209 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6211 /* Setup HMAC Parameters */
6212 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6213 ut_params->auth_xform.next = NULL;
6215 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6216 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6218 /* Create Crypto session*/
6219 ut_params->sess = rte_cryptodev_sym_session_create(
6220 ts_params->valid_devs[0], &ut_params->cipher_xform);
6221 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6223 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6224 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6225 burst_len, "failed to generate burst of crypto ops");
6227 /* Generate an operation for each mbuf in burst */
6228 for (i = 0; i < burst_len; i++) {
6229 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6231 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6233 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6237 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6239 burst[i]->sym->m_src = m;
6242 /* Process crypto operation */
6243 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6244 0, burst, burst_len),
6246 "Error enqueuing burst");
6248 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6249 0, burst_dequeued, burst_len),
6251 "Error dequeuing burst");
6254 for (i = 0; i < burst_len; i++) {
6256 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6257 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6259 "data not as expected");
6261 rte_pktmbuf_free(burst[i]->sym->m_src);
6262 rte_crypto_op_free(burst[i]);
6265 return TEST_SUCCESS;
6269 generate_gmac_large_plaintext(uint8_t *data)
6273 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6274 memcpy(&data[i], &data[0], 32);
6278 create_gmac_operation(enum rte_crypto_auth_operation op,
6279 const struct gmac_test_data *tdata)
6281 struct crypto_testsuite_params *ts_params = &testsuite_params;
6282 struct crypto_unittest_params *ut_params = &unittest_params;
6283 struct rte_crypto_sym_op *sym_op;
6285 unsigned aad_pad_len;
6287 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6290 * Runtime generate the large plain text instead of use hard code
6291 * plain text vector. It is done to avoid create huge source file
6292 * with the test vector.
6294 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6295 generate_gmac_large_plaintext(tdata->aad.data);
6297 /* Generate Crypto op data structure */
6298 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6299 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6300 TEST_ASSERT_NOT_NULL(ut_params->op,
6301 "Failed to allocate symmetric crypto operation struct");
6303 sym_op = ut_params->op->sym;
6304 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6306 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6307 "no room to append aad");
6309 sym_op->auth.aad.phys_addr =
6310 rte_pktmbuf_mtophys(ut_params->ibuf);
6311 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
6313 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6314 ut_params->ibuf, tdata->gmac_tag.len);
6315 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6316 "no room to append digest");
6318 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6319 ut_params->ibuf, aad_pad_len);
6321 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6322 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6323 tdata->gmac_tag.len);
6324 TEST_HEXDUMP(stdout, "digest:",
6325 sym_op->auth.digest.data,
6326 tdata->gmac_tag.len);
6329 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6330 uint8_t *, IV_OFFSET);
6332 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6334 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6336 sym_op->cipher.data.length = 0;
6337 sym_op->cipher.data.offset = 0;
6339 sym_op->auth.data.offset = 0;
6340 sym_op->auth.data.length = 0;
6345 static int create_gmac_session(uint8_t dev_id,
6346 enum rte_crypto_cipher_operation op,
6347 const struct gmac_test_data *tdata,
6348 enum rte_crypto_auth_operation auth_op)
6350 uint8_t cipher_key[tdata->key.len];
6352 struct crypto_unittest_params *ut_params = &unittest_params;
6354 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6356 /* For GMAC we setup cipher parameters */
6357 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6358 ut_params->cipher_xform.next = NULL;
6359 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6360 ut_params->cipher_xform.cipher.op = op;
6361 ut_params->cipher_xform.cipher.key.data = cipher_key;
6362 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6363 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6364 ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
6366 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6367 ut_params->auth_xform.next = NULL;
6369 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6370 ut_params->auth_xform.auth.op = auth_op;
6371 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6372 ut_params->auth_xform.auth.add_auth_data_length = tdata->aad.len;
6373 ut_params->auth_xform.auth.key.length = 0;
6374 ut_params->auth_xform.auth.key.data = NULL;
6376 ut_params->cipher_xform.next = &ut_params->auth_xform;
6378 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6379 &ut_params->cipher_xform);
6381 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6387 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6389 struct crypto_testsuite_params *ts_params = &testsuite_params;
6390 struct crypto_unittest_params *ut_params = &unittest_params;
6394 uint8_t *auth_tag, *p;
6395 uint16_t aad_pad_len;
6397 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6398 "No GMAC length in the source data");
6400 retval = create_gmac_session(ts_params->valid_devs[0],
6401 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6402 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6407 if (tdata->aad.len > MBUF_SIZE)
6408 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6410 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6411 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6412 "Failed to allocate input buffer in mempool");
6414 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6415 rte_pktmbuf_tailroom(ut_params->ibuf));
6417 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6419 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6421 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6427 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6429 ut_params->op->sym->m_src = ut_params->ibuf;
6431 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6432 ut_params->op), "failed to process sym crypto op");
6434 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6435 "crypto op processing failed");
6437 if (ut_params->op->sym->m_dst) {
6438 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6439 uint8_t *, aad_pad_len);
6441 auth_tag = p + aad_pad_len;
6444 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6446 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6448 tdata->gmac_tag.data,
6449 tdata->gmac_tag.len,
6450 "GMAC Generated auth tag not as expected");
6456 test_AES_GMAC_authentication_test_case_1(void)
6458 return test_AES_GMAC_authentication(&gmac_test_case_1);
6462 test_AES_GMAC_authentication_test_case_2(void)
6464 return test_AES_GMAC_authentication(&gmac_test_case_2);
6468 test_AES_GMAC_authentication_test_case_3(void)
6470 return test_AES_GMAC_authentication(&gmac_test_case_3);
6474 test_AES_GMAC_authentication_test_case_4(void)
6476 return test_AES_GMAC_authentication(&gmac_test_case_4);
6480 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6482 struct crypto_testsuite_params *ts_params = &testsuite_params;
6483 struct crypto_unittest_params *ut_params = &unittest_params;
6486 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6487 "No GMAC length in the source data");
6489 retval = create_gmac_session(ts_params->valid_devs[0],
6490 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6491 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6496 if (tdata->aad.len > MBUF_SIZE)
6497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6499 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6500 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6501 "Failed to allocate input buffer in mempool");
6503 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6504 rte_pktmbuf_tailroom(ut_params->ibuf));
6506 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6512 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6514 ut_params->op->sym->m_src = ut_params->ibuf;
6516 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6517 ut_params->op), "failed to process sym crypto op");
6519 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6520 "crypto op processing failed");
6527 test_AES_GMAC_authentication_verify_test_case_1(void)
6529 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6533 test_AES_GMAC_authentication_verify_test_case_2(void)
6535 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6539 test_AES_GMAC_authentication_verify_test_case_3(void)
6541 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6545 test_AES_GMAC_authentication_verify_test_case_4(void)
6547 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6550 struct test_crypto_vector {
6551 enum rte_crypto_cipher_algorithm crypto_algo;
6564 const uint8_t *data;
6569 const uint8_t *data;
6573 enum rte_crypto_auth_algorithm auth_algo;
6581 const uint8_t *data;
6591 static const struct test_crypto_vector
6592 hmac_sha1_test_crypto_vector = {
6593 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6595 .data = plaintext_hash,
6600 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6601 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6602 0xDE, 0xF4, 0xDE, 0xAD
6608 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6609 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6610 0x3F, 0x91, 0x64, 0x59
6616 static const struct test_crypto_vector
6617 aes128_gmac_test_vector = {
6618 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6619 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6621 .data = plaintext_hash,
6626 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6627 0x08, 0x09, 0x0A, 0x0B
6633 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6634 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6640 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6641 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6647 static const struct test_crypto_vector
6648 aes128cbc_hmac_sha1_test_vector = {
6649 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6652 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6653 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6659 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6660 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6665 .data = plaintext_hash,
6669 .data = ciphertext512_aes128cbc,
6672 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6675 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6676 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6677 0xDE, 0xF4, 0xDE, 0xAD
6683 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6684 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6685 0x18, 0x8C, 0x1D, 0x32
6692 data_corruption(uint8_t *data)
6698 tag_corruption(uint8_t *data, unsigned int tag_offset)
6700 data[tag_offset] += 1;
6704 create_auth_session(struct crypto_unittest_params *ut_params,
6706 const struct test_crypto_vector *reference,
6707 enum rte_crypto_auth_operation auth_op)
6709 uint8_t auth_key[reference->auth_key.len + 1];
6711 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6713 /* Setup Authentication Parameters */
6714 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6715 ut_params->auth_xform.auth.op = auth_op;
6716 ut_params->auth_xform.next = NULL;
6717 ut_params->auth_xform.auth.algo = reference->auth_algo;
6718 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6719 ut_params->auth_xform.auth.key.data = auth_key;
6720 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6721 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6723 /* Create Crypto session*/
6724 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6725 &ut_params->auth_xform);
6727 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6733 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6735 const struct test_crypto_vector *reference,
6736 enum rte_crypto_auth_operation auth_op,
6737 enum rte_crypto_cipher_operation cipher_op)
6739 uint8_t cipher_key[reference->cipher_key.len + 1];
6740 uint8_t auth_key[reference->auth_key.len + 1];
6742 memcpy(cipher_key, reference->cipher_key.data,
6743 reference->cipher_key.len);
6744 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6746 /* Setup Authentication Parameters */
6747 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6748 ut_params->auth_xform.auth.op = auth_op;
6749 ut_params->auth_xform.next = &ut_params->cipher_xform;
6750 ut_params->auth_xform.auth.algo = reference->auth_algo;
6751 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6752 ut_params->auth_xform.auth.key.data = auth_key;
6753 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6754 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6756 /* Setup Cipher Parameters */
6757 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6758 ut_params->cipher_xform.next = NULL;
6759 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6760 ut_params->cipher_xform.cipher.op = cipher_op;
6761 ut_params->cipher_xform.cipher.key.data = cipher_key;
6762 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6763 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6764 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6766 /* Create Crypto session*/
6767 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6768 &ut_params->auth_xform);
6770 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6776 create_auth_operation(struct crypto_testsuite_params *ts_params,
6777 struct crypto_unittest_params *ut_params,
6778 const struct test_crypto_vector *reference,
6779 unsigned int auth_generate)
6781 /* Generate Crypto op data structure */
6782 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6783 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6784 TEST_ASSERT_NOT_NULL(ut_params->op,
6785 "Failed to allocate pktmbuf offload");
6787 /* Set crypto operation data parameters */
6788 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6790 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6792 /* set crypto operation source mbuf */
6793 sym_op->m_src = ut_params->ibuf;
6796 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6797 ut_params->ibuf, reference->digest.len);
6799 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6800 "no room to append auth tag");
6802 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6803 ut_params->ibuf, reference->plaintext.len);
6806 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6808 memcpy(sym_op->auth.digest.data,
6809 reference->digest.data,
6810 reference->digest.len);
6812 TEST_HEXDUMP(stdout, "digest:",
6813 sym_op->auth.digest.data,
6814 reference->digest.len);
6816 sym_op->auth.data.length = reference->plaintext.len;
6817 sym_op->auth.data.offset = 0;
6823 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6824 struct crypto_unittest_params *ut_params,
6825 const struct test_crypto_vector *reference,
6826 unsigned int auth_generate)
6828 /* Generate Crypto op data structure */
6829 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6830 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6831 TEST_ASSERT_NOT_NULL(ut_params->op,
6832 "Failed to allocate pktmbuf offload");
6834 /* Set crypto operation data parameters */
6835 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6837 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6839 /* set crypto operation source mbuf */
6840 sym_op->m_src = ut_params->ibuf;
6843 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6844 reference->aad.len);
6845 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6846 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6848 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6850 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6853 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6854 ut_params->ibuf, reference->digest.len);
6856 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6857 "no room to append auth tag");
6859 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6860 ut_params->ibuf, reference->ciphertext.len);
6863 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6865 memcpy(sym_op->auth.digest.data,
6866 reference->digest.data,
6867 reference->digest.len);
6869 TEST_HEXDUMP(stdout, "digest:",
6870 sym_op->auth.digest.data,
6871 reference->digest.len);
6873 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6874 reference->iv.data, reference->iv.len);
6876 sym_op->cipher.data.length = 0;
6877 sym_op->cipher.data.offset = 0;
6879 sym_op->auth.data.length = 0;
6880 sym_op->auth.data.offset = 0;
6886 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6887 struct crypto_unittest_params *ut_params,
6888 const struct test_crypto_vector *reference,
6889 unsigned int auth_generate)
6891 /* Generate Crypto op data structure */
6892 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6893 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6894 TEST_ASSERT_NOT_NULL(ut_params->op,
6895 "Failed to allocate pktmbuf offload");
6897 /* Set crypto operation data parameters */
6898 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6900 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6902 /* set crypto operation source mbuf */
6903 sym_op->m_src = ut_params->ibuf;
6906 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6907 ut_params->ibuf, reference->digest.len);
6909 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6910 "no room to append auth tag");
6912 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6913 ut_params->ibuf, reference->ciphertext.len);
6916 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6918 memcpy(sym_op->auth.digest.data,
6919 reference->digest.data,
6920 reference->digest.len);
6922 TEST_HEXDUMP(stdout, "digest:",
6923 sym_op->auth.digest.data,
6924 reference->digest.len);
6926 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6927 reference->iv.data, reference->iv.len);
6929 sym_op->cipher.data.length = reference->ciphertext.len;
6930 sym_op->cipher.data.offset = 0;
6932 sym_op->auth.data.length = reference->ciphertext.len;
6933 sym_op->auth.data.offset = 0;
6939 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6940 struct crypto_unittest_params *ut_params,
6941 const struct test_crypto_vector *reference)
6943 return create_auth_operation(ts_params, ut_params, reference, 0);
6947 create_auth_verify_GMAC_operation(
6948 struct crypto_testsuite_params *ts_params,
6949 struct crypto_unittest_params *ut_params,
6950 const struct test_crypto_vector *reference)
6952 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6956 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6957 struct crypto_unittest_params *ut_params,
6958 const struct test_crypto_vector *reference)
6960 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6964 test_authentication_verify_fail_when_data_corruption(
6965 struct crypto_testsuite_params *ts_params,
6966 struct crypto_unittest_params *ut_params,
6967 const struct test_crypto_vector *reference,
6968 unsigned int data_corrupted)
6974 /* Create session */
6975 retval = create_auth_session(ut_params,
6976 ts_params->valid_devs[0],
6978 RTE_CRYPTO_AUTH_OP_VERIFY);
6982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6983 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6984 "Failed to allocate input buffer in mempool");
6986 /* clear mbuf payload */
6987 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6988 rte_pktmbuf_tailroom(ut_params->ibuf));
6990 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6991 reference->plaintext.len);
6992 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6993 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6995 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6997 /* Create operation */
6998 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7004 data_corruption(plaintext);
7006 tag_corruption(plaintext, reference->plaintext.len);
7008 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7010 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7011 TEST_ASSERT_EQUAL(ut_params->op->status,
7012 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7013 "authentication not failed");
7015 ut_params->obuf = ut_params->op->sym->m_src;
7016 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7022 test_authentication_verify_GMAC_fail_when_corruption(
7023 struct crypto_testsuite_params *ts_params,
7024 struct crypto_unittest_params *ut_params,
7025 const struct test_crypto_vector *reference,
7026 unsigned int data_corrupted)
7030 /* Create session */
7031 retval = create_auth_cipher_session(ut_params,
7032 ts_params->valid_devs[0],
7034 RTE_CRYPTO_AUTH_OP_VERIFY,
7035 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7039 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7040 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7041 "Failed to allocate input buffer in mempool");
7043 /* clear mbuf payload */
7044 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7045 rte_pktmbuf_tailroom(ut_params->ibuf));
7047 /* Create operation */
7048 retval = create_auth_verify_GMAC_operation(ts_params,
7056 data_corruption(ut_params->op->sym->auth.aad.data);
7058 tag_corruption(ut_params->op->sym->auth.aad.data,
7059 reference->aad.len);
7061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7063 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7064 TEST_ASSERT_EQUAL(ut_params->op->status,
7065 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7066 "authentication not failed");
7068 ut_params->obuf = ut_params->op->sym->m_src;
7069 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7075 test_authenticated_decryption_fail_when_corruption(
7076 struct crypto_testsuite_params *ts_params,
7077 struct crypto_unittest_params *ut_params,
7078 const struct test_crypto_vector *reference,
7079 unsigned int data_corrupted)
7083 uint8_t *ciphertext;
7085 /* Create session */
7086 retval = create_auth_cipher_session(ut_params,
7087 ts_params->valid_devs[0],
7089 RTE_CRYPTO_AUTH_OP_VERIFY,
7090 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7094 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7095 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7096 "Failed to allocate input buffer in mempool");
7098 /* clear mbuf payload */
7099 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7100 rte_pktmbuf_tailroom(ut_params->ibuf));
7102 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7103 reference->ciphertext.len);
7104 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7105 memcpy(ciphertext, reference->ciphertext.data,
7106 reference->ciphertext.len);
7108 /* Create operation */
7109 retval = create_cipher_auth_verify_operation(ts_params,
7117 data_corruption(ciphertext);
7119 tag_corruption(ciphertext, reference->ciphertext.len);
7121 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7124 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7125 TEST_ASSERT_EQUAL(ut_params->op->status,
7126 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7127 "authentication not failed");
7129 ut_params->obuf = ut_params->op->sym->m_src;
7130 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7136 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7137 const struct gcm_test_data *tdata,
7138 void *digest_mem, uint64_t digest_phys)
7140 struct crypto_testsuite_params *ts_params = &testsuite_params;
7141 struct crypto_unittest_params *ut_params = &unittest_params;
7143 const unsigned int auth_tag_len = tdata->auth_tag.len;
7144 const unsigned int iv_len = tdata->iv.len;
7145 const unsigned int aad_len = tdata->aad.len;
7147 /* Generate Crypto op data structure */
7148 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7149 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7150 TEST_ASSERT_NOT_NULL(ut_params->op,
7151 "Failed to allocate symmetric crypto operation struct");
7153 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7155 sym_op->auth.digest.data = digest_mem;
7157 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7158 "no room to append digest");
7160 sym_op->auth.digest.phys_addr = digest_phys;
7162 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7163 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7165 TEST_HEXDUMP(stdout, "digest:",
7166 sym_op->auth.digest.data,
7170 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7171 uint8_t *, IV_OFFSET);
7173 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7175 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7176 ut_params->ibuf, aad_len);
7177 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7178 "no room to prepend aad");
7179 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7182 memset(sym_op->auth.aad.data, 0, aad_len);
7183 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7185 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7186 TEST_HEXDUMP(stdout, "aad:",
7187 sym_op->auth.aad.data, aad_len);
7189 sym_op->cipher.data.length = tdata->plaintext.len;
7190 sym_op->cipher.data.offset = aad_len;
7192 sym_op->auth.data.offset = aad_len;
7193 sym_op->auth.data.length = tdata->plaintext.len;
7198 #define SGL_MAX_NO 16
7201 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7202 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7204 struct crypto_testsuite_params *ts_params = &testsuite_params;
7205 struct crypto_unittest_params *ut_params = &unittest_params;
7206 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7209 int to_trn_tbl[SGL_MAX_NO];
7211 unsigned int trn_data = 0;
7212 uint8_t *plaintext, *ciphertext, *auth_tag;
7214 if (fragsz > tdata->plaintext.len)
7215 fragsz = tdata->plaintext.len;
7217 uint16_t plaintext_len = fragsz;
7218 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7220 if (fragsz_oop > tdata->plaintext.len)
7221 frag_size_oop = tdata->plaintext.len;
7224 void *digest_mem = NULL;
7226 uint32_t prepend_len = tdata->aad.len;
7228 if (tdata->plaintext.len % fragsz != 0) {
7229 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7232 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7237 * For out-op-place we need to alloc another mbuf
7240 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7241 rte_pktmbuf_append(ut_params->obuf,
7242 frag_size_oop + prepend_len);
7243 buf_oop = ut_params->obuf;
7246 /* Create GCM session */
7247 retval = create_gcm_session(ts_params->valid_devs[0],
7248 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7249 tdata->key.data, tdata->key.len,
7250 tdata->aad.len, tdata->auth_tag.len,
7252 RTE_CRYPTO_AUTH_OP_GENERATE);
7256 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7258 /* clear mbuf payload */
7259 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7260 rte_pktmbuf_tailroom(ut_params->ibuf));
7262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7265 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7267 trn_data += plaintext_len;
7269 buf = ut_params->ibuf;
7272 * Loop until no more fragments
7275 while (trn_data < tdata->plaintext.len) {
7277 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7278 (tdata->plaintext.len - trn_data) : fragsz;
7280 to_trn_tbl[ecx++] = to_trn;
7282 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7285 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7286 rte_pktmbuf_tailroom(buf));
7289 if (oop && !fragsz_oop) {
7290 buf_last_oop = buf_oop->next =
7291 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7292 buf_oop = buf_oop->next;
7293 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7294 0, rte_pktmbuf_tailroom(buf_oop));
7295 rte_pktmbuf_append(buf_oop, to_trn);
7298 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7301 memcpy(plaintext, tdata->plaintext.data + trn_data,
7304 if (trn_data == tdata->plaintext.len) {
7307 digest_mem = rte_pktmbuf_append(buf_oop,
7308 tdata->auth_tag.len);
7310 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7311 tdata->auth_tag.len);
7315 uint64_t digest_phys = 0;
7317 ut_params->ibuf->nb_segs = segs;
7320 if (fragsz_oop && oop) {
7324 if (frag_size_oop == tdata->plaintext.len) {
7325 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7326 tdata->auth_tag.len);
7328 digest_phys = rte_pktmbuf_mtophys_offset(
7330 tdata->plaintext.len + prepend_len);
7333 trn_data = frag_size_oop;
7334 while (trn_data < tdata->plaintext.len) {
7337 (tdata->plaintext.len - trn_data <
7339 (tdata->plaintext.len - trn_data) :
7342 to_trn_tbl[ecx++] = to_trn;
7344 buf_last_oop = buf_oop->next =
7345 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7346 buf_oop = buf_oop->next;
7347 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7348 0, rte_pktmbuf_tailroom(buf_oop));
7349 rte_pktmbuf_append(buf_oop, to_trn);
7353 if (trn_data == tdata->plaintext.len) {
7354 digest_mem = rte_pktmbuf_append(buf_oop,
7355 tdata->auth_tag.len);
7359 ut_params->obuf->nb_segs = segs;
7363 * Place digest at the end of the last buffer
7366 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7367 if (oop && buf_last_oop)
7368 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7370 if (!digest_mem && !oop) {
7371 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7372 + tdata->auth_tag.len);
7373 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7374 tdata->plaintext.len);
7377 /* Create GCM opertaion */
7378 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7379 tdata, digest_mem, digest_phys);
7384 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7386 ut_params->op->sym->m_src = ut_params->ibuf;
7388 ut_params->op->sym->m_dst = ut_params->obuf;
7390 /* Process crypto operation */
7391 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7392 ut_params->op), "failed to process sym crypto op");
7394 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7395 "crypto op processing failed");
7398 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7399 uint8_t *, prepend_len);
7401 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7402 uint8_t *, prepend_len);
7406 fragsz = fragsz_oop;
7408 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7410 tdata->ciphertext.data,
7412 "GCM Ciphertext data not as expected");
7414 buf = ut_params->op->sym->m_src->next;
7416 buf = ut_params->op->sym->m_dst->next;
7418 unsigned int off = fragsz;
7422 ciphertext = rte_pktmbuf_mtod(buf,
7425 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7427 tdata->ciphertext.data + off,
7429 "GCM Ciphertext data not as expected");
7431 off += to_trn_tbl[ecx++];
7435 auth_tag = digest_mem;
7436 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7438 tdata->auth_tag.data,
7439 tdata->auth_tag.len,
7440 "GCM Generated auth tag not as expected");
7446 #define OUT_OF_PLACE 1
7449 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7451 return test_AES_GCM_authenticated_encryption_SGL(
7452 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7456 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7458 return test_AES_GCM_authenticated_encryption_SGL(
7459 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7463 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7465 return test_AES_GCM_authenticated_encryption_SGL(
7466 &gcm_test_case_8, OUT_OF_PLACE, 400,
7467 gcm_test_case_8.plaintext.len);
7471 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7474 return test_AES_GCM_authenticated_encryption_SGL(
7475 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7479 test_authentication_verify_fail_when_data_corrupted(
7480 struct crypto_testsuite_params *ts_params,
7481 struct crypto_unittest_params *ut_params,
7482 const struct test_crypto_vector *reference)
7484 return test_authentication_verify_fail_when_data_corruption(
7485 ts_params, ut_params, reference, 1);
7489 test_authentication_verify_fail_when_tag_corrupted(
7490 struct crypto_testsuite_params *ts_params,
7491 struct crypto_unittest_params *ut_params,
7492 const struct test_crypto_vector *reference)
7494 return test_authentication_verify_fail_when_data_corruption(
7495 ts_params, ut_params, reference, 0);
7499 test_authentication_verify_GMAC_fail_when_data_corrupted(
7500 struct crypto_testsuite_params *ts_params,
7501 struct crypto_unittest_params *ut_params,
7502 const struct test_crypto_vector *reference)
7504 return test_authentication_verify_GMAC_fail_when_corruption(
7505 ts_params, ut_params, reference, 1);
7509 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7510 struct crypto_testsuite_params *ts_params,
7511 struct crypto_unittest_params *ut_params,
7512 const struct test_crypto_vector *reference)
7514 return test_authentication_verify_GMAC_fail_when_corruption(
7515 ts_params, ut_params, reference, 0);
7519 test_authenticated_decryption_fail_when_data_corrupted(
7520 struct crypto_testsuite_params *ts_params,
7521 struct crypto_unittest_params *ut_params,
7522 const struct test_crypto_vector *reference)
7524 return test_authenticated_decryption_fail_when_corruption(
7525 ts_params, ut_params, reference, 1);
7529 test_authenticated_decryption_fail_when_tag_corrupted(
7530 struct crypto_testsuite_params *ts_params,
7531 struct crypto_unittest_params *ut_params,
7532 const struct test_crypto_vector *reference)
7534 return test_authenticated_decryption_fail_when_corruption(
7535 ts_params, ut_params, reference, 0);
7539 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7541 return test_authentication_verify_fail_when_data_corrupted(
7542 &testsuite_params, &unittest_params,
7543 &hmac_sha1_test_crypto_vector);
7547 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7549 return test_authentication_verify_fail_when_tag_corrupted(
7550 &testsuite_params, &unittest_params,
7551 &hmac_sha1_test_crypto_vector);
7555 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7557 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7558 &testsuite_params, &unittest_params,
7559 &aes128_gmac_test_vector);
7563 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7565 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7566 &testsuite_params, &unittest_params,
7567 &aes128_gmac_test_vector);
7571 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7573 return test_authenticated_decryption_fail_when_data_corrupted(
7576 &aes128cbc_hmac_sha1_test_vector);
7580 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7582 return test_authenticated_decryption_fail_when_tag_corrupted(
7585 &aes128cbc_hmac_sha1_test_vector);
7588 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7590 /* global AESNI slave IDs for the scheduler test */
7591 uint8_t aesni_ids[2];
7594 test_scheduler_attach_slave_op(void)
7596 struct crypto_testsuite_params *ts_params = &testsuite_params;
7597 uint8_t sched_id = ts_params->valid_devs[0];
7598 uint32_t nb_devs, i, nb_devs_attached = 0;
7602 /* create 2 AESNI_MB if necessary */
7603 nb_devs = rte_cryptodev_count_devtype(
7604 RTE_CRYPTODEV_AESNI_MB_PMD);
7606 for (i = nb_devs; i < 2; i++) {
7607 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7608 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7610 ret = rte_vdev_init(vdev_name, NULL);
7612 TEST_ASSERT(ret == 0,
7613 "Failed to create instance %u of"
7615 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7619 /* attach 2 AESNI_MB cdevs */
7620 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7622 struct rte_cryptodev_info info;
7624 rte_cryptodev_info_get(i, &info);
7625 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7628 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7631 TEST_ASSERT(ret == 0,
7632 "Failed to attach device %u of pmd : %s", i,
7633 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7635 aesni_ids[nb_devs_attached] = (uint8_t)i;
7644 test_scheduler_detach_slave_op(void)
7646 struct crypto_testsuite_params *ts_params = &testsuite_params;
7647 uint8_t sched_id = ts_params->valid_devs[0];
7651 for (i = 0; i < 2; i++) {
7652 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7654 TEST_ASSERT(ret == 0,
7655 "Failed to detach device %u", aesni_ids[i]);
7662 test_scheduler_mode_op(void)
7664 struct crypto_testsuite_params *ts_params = &testsuite_params;
7665 uint8_t sched_id = ts_params->valid_devs[0];
7666 struct rte_cryptodev_scheduler_ops op = {0};
7667 struct rte_cryptodev_scheduler dummy_scheduler = {
7668 .description = "dummy scheduler to test mode",
7669 .name = "dummy scheduler",
7670 .mode = CDEV_SCHED_MODE_USERDEFINED,
7675 /* set user defined mode */
7676 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7678 TEST_ASSERT(ret == 0,
7679 "Failed to set cdev %u to user defined mode", sched_id);
7681 /* set round robin mode */
7682 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7683 CDEV_SCHED_MODE_ROUNDROBIN);
7684 TEST_ASSERT(ret == 0,
7685 "Failed to set cdev %u to round-robin mode", sched_id);
7686 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7687 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7693 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7694 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7695 .setup = testsuite_setup,
7696 .teardown = testsuite_teardown,
7697 .unit_test_cases = {
7698 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7699 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7700 TEST_CASE_ST(ut_setup, ut_teardown,
7701 test_AES_chain_scheduler_all),
7702 TEST_CASE_ST(ut_setup, ut_teardown,
7703 test_AES_cipheronly_scheduler_all),
7704 TEST_CASE_ST(ut_setup, ut_teardown,
7705 test_authonly_scheduler_all),
7706 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7707 TEST_CASES_END() /**< NULL terminate unit test array */
7711 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7713 static struct unit_test_suite cryptodev_qat_testsuite = {
7714 .suite_name = "Crypto QAT Unit Test Suite",
7715 .setup = testsuite_setup,
7716 .teardown = testsuite_teardown,
7717 .unit_test_cases = {
7718 TEST_CASE_ST(ut_setup, ut_teardown,
7719 test_device_configure_invalid_dev_id),
7720 TEST_CASE_ST(ut_setup, ut_teardown,
7721 test_device_configure_invalid_queue_pair_ids),
7722 TEST_CASE_ST(ut_setup, ut_teardown,
7723 test_queue_pair_descriptor_setup),
7724 TEST_CASE_ST(ut_setup, ut_teardown,
7725 test_multi_session),
7727 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7728 TEST_CASE_ST(ut_setup, ut_teardown,
7729 test_AES_cipheronly_qat_all),
7730 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7731 TEST_CASE_ST(ut_setup, ut_teardown,
7732 test_3DES_cipheronly_qat_all),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_DES_cipheronly_qat_all),
7735 TEST_CASE_ST(ut_setup, ut_teardown,
7736 test_AES_docsis_qat_all),
7737 TEST_CASE_ST(ut_setup, ut_teardown,
7738 test_DES_docsis_qat_all),
7739 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7741 /** AES GCM Authenticated Encryption */
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7744 TEST_CASE_ST(ut_setup, ut_teardown,
7745 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7746 TEST_CASE_ST(ut_setup, ut_teardown,
7747 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7748 TEST_CASE_ST(ut_setup, ut_teardown,
7749 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7750 TEST_CASE_ST(ut_setup, ut_teardown,
7751 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7752 TEST_CASE_ST(ut_setup, ut_teardown,
7753 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7754 TEST_CASE_ST(ut_setup, ut_teardown,
7755 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7756 TEST_CASE_ST(ut_setup, ut_teardown,
7757 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7758 TEST_CASE_ST(ut_setup, ut_teardown,
7759 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7763 /** AES GCM Authenticated Decryption */
7764 TEST_CASE_ST(ut_setup, ut_teardown,
7765 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7766 TEST_CASE_ST(ut_setup, ut_teardown,
7767 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7768 TEST_CASE_ST(ut_setup, ut_teardown,
7769 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7774 TEST_CASE_ST(ut_setup, ut_teardown,
7775 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7779 /** AES GMAC Authentication */
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_AES_GMAC_authentication_test_case_1),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_AES_GMAC_authentication_verify_test_case_1),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_AES_GMAC_authentication_test_case_2),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 test_AES_GMAC_authentication_verify_test_case_2),
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_AES_GMAC_authentication_test_case_3),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_AES_GMAC_authentication_verify_test_case_3),
7793 /** SNOW 3G encrypt only (UEA2) */
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_snow3g_encryption_test_case_1),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_snow3g_encryption_test_case_2),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_snow3g_encryption_test_case_3),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_snow3g_encryption_test_case_4),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_snow3g_encryption_test_case_5),
7805 TEST_CASE_ST(ut_setup, ut_teardown,
7806 test_snow3g_encryption_test_case_1_oop),
7807 TEST_CASE_ST(ut_setup, ut_teardown,
7808 test_snow3g_decryption_test_case_1_oop),
7810 /** SNOW 3G decrypt only (UEA2) */
7811 TEST_CASE_ST(ut_setup, ut_teardown,
7812 test_snow3g_decryption_test_case_1),
7813 TEST_CASE_ST(ut_setup, ut_teardown,
7814 test_snow3g_decryption_test_case_2),
7815 TEST_CASE_ST(ut_setup, ut_teardown,
7816 test_snow3g_decryption_test_case_3),
7817 TEST_CASE_ST(ut_setup, ut_teardown,
7818 test_snow3g_decryption_test_case_4),
7819 TEST_CASE_ST(ut_setup, ut_teardown,
7820 test_snow3g_decryption_test_case_5),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_snow3g_hash_generate_test_case_1),
7823 TEST_CASE_ST(ut_setup, ut_teardown,
7824 test_snow3g_hash_generate_test_case_2),
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_snow3g_hash_generate_test_case_3),
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_snow3g_hash_verify_test_case_1),
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_snow3g_hash_verify_test_case_2),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_snow3g_hash_verify_test_case_3),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_snow3g_cipher_auth_test_case_1),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_snow3g_auth_cipher_test_case_1),
7838 /** ZUC encrypt only (EEA3) */
7839 TEST_CASE_ST(ut_setup, ut_teardown,
7840 test_zuc_encryption_test_case_1),
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_zuc_encryption_test_case_2),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_zuc_encryption_test_case_3),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_zuc_encryption_test_case_4),
7847 TEST_CASE_ST(ut_setup, ut_teardown,
7848 test_zuc_encryption_test_case_5),
7850 /** ZUC authenticate (EIA3) */
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_zuc_hash_generate_test_case_6),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_zuc_hash_generate_test_case_7),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_zuc_hash_generate_test_case_8),
7858 /** ZUC alg-chain (EEA3/EIA3) */
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_zuc_cipher_auth_test_case_1),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_zuc_cipher_auth_test_case_2),
7864 /** HMAC_MD5 Authentication */
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_MD5_HMAC_generate_case_1),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_MD5_HMAC_verify_case_1),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_MD5_HMAC_generate_case_2),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_MD5_HMAC_verify_case_2),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_null_auth_only_operation),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_null_cipher_only_operation),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_null_cipher_auth_operation),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_null_auth_cipher_operation),
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_kasumi_hash_generate_test_case_6),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_kasumi_encryption_test_case_1),
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_kasumi_encryption_test_case_3),
7892 TEST_CASE_ST(ut_setup, ut_teardown,
7893 test_kasumi_auth_cipher_test_case_1),
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_kasumi_cipher_auth_test_case_1),
7897 /** Negative tests */
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 authentication_verify_AES128_GMAC_fail_data_corrupt),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7911 TEST_CASES_END() /**< NULL terminate unit test array */
7915 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7916 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7917 .setup = testsuite_setup,
7918 .teardown = testsuite_teardown,
7919 .unit_test_cases = {
7920 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7921 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7922 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7923 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7925 TEST_CASES_END() /**< NULL terminate unit test array */
7929 static struct unit_test_suite cryptodev_openssl_testsuite = {
7930 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7931 .setup = testsuite_setup,
7932 .teardown = testsuite_teardown,
7933 .unit_test_cases = {
7934 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_multi_session_random_usage),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_AES_chain_openssl_all),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_AES_cipheronly_openssl_all),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_3DES_chain_openssl_all),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_3DES_cipheronly_openssl_all),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_DES_docsis_openssl_all),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_authonly_openssl_all),
7950 /** AES GCM Authenticated Encryption */
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7963 TEST_CASE_ST(ut_setup, ut_teardown,
7964 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7966 /** AES GCM Authenticated Decryption */
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7979 TEST_CASE_ST(ut_setup, ut_teardown,
7980 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7982 /** AES GMAC Authentication */
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_AES_GMAC_authentication_test_case_1),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_AES_GMAC_authentication_verify_test_case_1),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_AES_GMAC_authentication_test_case_2),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_AES_GMAC_authentication_verify_test_case_2),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_AES_GMAC_authentication_test_case_3),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_AES_GMAC_authentication_verify_test_case_3),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_AES_GMAC_authentication_test_case_4),
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_AES_GMAC_authentication_verify_test_case_4),
8000 /** Scatter-Gather */
8001 TEST_CASE_ST(ut_setup, ut_teardown,
8002 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8004 /** Negative tests */
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8007 TEST_CASE_ST(ut_setup, ut_teardown,
8008 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 authentication_verify_AES128_GMAC_fail_data_corrupt),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8018 TEST_CASES_END() /**< NULL terminate unit test array */
8022 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8023 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8024 .setup = testsuite_setup,
8025 .teardown = testsuite_teardown,
8026 .unit_test_cases = {
8027 /** AES GCM Authenticated Encryption */
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8043 /** AES GCM Authenticated Decryption */
8044 TEST_CASE_ST(ut_setup, ut_teardown,
8045 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8059 /** AES GCM Authenticated Encryption 256 bits key */
8060 TEST_CASE_ST(ut_setup, ut_teardown,
8061 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8075 /** AES GCM Authenticated Decryption 256 bits key */
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8091 /** AES GCM Authenticated Encryption big aad size */
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8097 /** AES GCM Authenticated Decryption big aad size */
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8103 /** AES GMAC Authentication */
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_AES_GMAC_authentication_test_case_1),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_AES_GMAC_authentication_verify_test_case_1),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_AES_GMAC_authentication_test_case_3),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_AES_GMAC_authentication_verify_test_case_3),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_AES_GMAC_authentication_test_case_4),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_AES_GMAC_authentication_verify_test_case_4),
8117 /** Negative tests */
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 authentication_verify_AES128_GMAC_fail_data_corrupt),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8123 /** Out of place tests */
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_mb_AES_GCM_authenticated_encryption_oop),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_mb_AES_GCM_authenticated_decryption_oop),
8129 /** Session-less tests */
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_mb_AES_GCM_authenticated_encryption_sessionless),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_mb_AES_GCM_authenticated_decryption_sessionless),
8135 /** Scatter-Gather */
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8139 TEST_CASES_END() /**< NULL terminate unit test array */
8143 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8144 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8145 .setup = testsuite_setup,
8146 .teardown = testsuite_teardown,
8147 .unit_test_cases = {
8148 /** KASUMI encrypt only (UEA1) */
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_kasumi_encryption_test_case_1),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_kasumi_encryption_test_case_1_sgl),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_kasumi_encryption_test_case_2),
8155 TEST_CASE_ST(ut_setup, ut_teardown,
8156 test_kasumi_encryption_test_case_3),
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_kasumi_encryption_test_case_4),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_kasumi_encryption_test_case_5),
8161 /** KASUMI decrypt only (UEA1) */
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_kasumi_decryption_test_case_1),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_kasumi_decryption_test_case_2),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_kasumi_decryption_test_case_3),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_kasumi_decryption_test_case_4),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_kasumi_decryption_test_case_5),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_kasumi_encryption_test_case_1_oop),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_kasumi_encryption_test_case_1_oop_sgl),
8179 TEST_CASE_ST(ut_setup, ut_teardown,
8180 test_kasumi_decryption_test_case_1_oop),
8182 /** KASUMI hash only (UIA1) */
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_kasumi_hash_generate_test_case_1),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_kasumi_hash_generate_test_case_2),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_kasumi_hash_generate_test_case_3),
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_kasumi_hash_generate_test_case_4),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_kasumi_hash_generate_test_case_5),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_kasumi_hash_generate_test_case_6),
8195 TEST_CASE_ST(ut_setup, ut_teardown,
8196 test_kasumi_hash_verify_test_case_1),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_kasumi_hash_verify_test_case_2),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_kasumi_hash_verify_test_case_3),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_kasumi_hash_verify_test_case_4),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_kasumi_hash_verify_test_case_5),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_kasumi_auth_cipher_test_case_1),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_kasumi_cipher_auth_test_case_1),
8209 TEST_CASES_END() /**< NULL terminate unit test array */
8212 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8213 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8214 .setup = testsuite_setup,
8215 .teardown = testsuite_teardown,
8216 .unit_test_cases = {
8217 /** SNOW 3G encrypt only (UEA2) */
8218 TEST_CASE_ST(ut_setup, ut_teardown,
8219 test_snow3g_encryption_test_case_1),
8220 TEST_CASE_ST(ut_setup, ut_teardown,
8221 test_snow3g_encryption_test_case_2),
8222 TEST_CASE_ST(ut_setup, ut_teardown,
8223 test_snow3g_encryption_test_case_3),
8224 TEST_CASE_ST(ut_setup, ut_teardown,
8225 test_snow3g_encryption_test_case_4),
8226 TEST_CASE_ST(ut_setup, ut_teardown,
8227 test_snow3g_encryption_test_case_5),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_snow3g_encryption_test_case_1_oop),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_snow3g_encryption_test_case_1_oop_sgl),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_snow3g_decryption_test_case_1_oop),
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_snow3g_encryption_test_case_1_offset_oop),
8239 /** SNOW 3G decrypt only (UEA2) */
8240 TEST_CASE_ST(ut_setup, ut_teardown,
8241 test_snow3g_decryption_test_case_1),
8242 TEST_CASE_ST(ut_setup, ut_teardown,
8243 test_snow3g_decryption_test_case_2),
8244 TEST_CASE_ST(ut_setup, ut_teardown,
8245 test_snow3g_decryption_test_case_3),
8246 TEST_CASE_ST(ut_setup, ut_teardown,
8247 test_snow3g_decryption_test_case_4),
8248 TEST_CASE_ST(ut_setup, ut_teardown,
8249 test_snow3g_decryption_test_case_5),
8250 TEST_CASE_ST(ut_setup, ut_teardown,
8251 test_snow3g_hash_generate_test_case_1),
8252 TEST_CASE_ST(ut_setup, ut_teardown,
8253 test_snow3g_hash_generate_test_case_2),
8254 TEST_CASE_ST(ut_setup, ut_teardown,
8255 test_snow3g_hash_generate_test_case_3),
8256 /* Tests with buffers which length is not byte-aligned */
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_snow3g_hash_generate_test_case_4),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_snow3g_hash_generate_test_case_5),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_snow3g_hash_generate_test_case_6),
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_snow3g_hash_verify_test_case_1),
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_snow3g_hash_verify_test_case_2),
8267 TEST_CASE_ST(ut_setup, ut_teardown,
8268 test_snow3g_hash_verify_test_case_3),
8269 /* Tests with buffers which length is not byte-aligned */
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_snow3g_hash_verify_test_case_4),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_snow3g_hash_verify_test_case_5),
8274 TEST_CASE_ST(ut_setup, ut_teardown,
8275 test_snow3g_hash_verify_test_case_6),
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_snow3g_cipher_auth_test_case_1),
8278 TEST_CASE_ST(ut_setup, ut_teardown,
8279 test_snow3g_auth_cipher_test_case_1),
8281 TEST_CASES_END() /**< NULL terminate unit test array */
8285 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8286 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8287 .setup = testsuite_setup,
8288 .teardown = testsuite_teardown,
8289 .unit_test_cases = {
8290 /** ZUC encrypt only (EEA3) */
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_zuc_encryption_test_case_1),
8293 TEST_CASE_ST(ut_setup, ut_teardown,
8294 test_zuc_encryption_test_case_2),
8295 TEST_CASE_ST(ut_setup, ut_teardown,
8296 test_zuc_encryption_test_case_3),
8297 TEST_CASE_ST(ut_setup, ut_teardown,
8298 test_zuc_encryption_test_case_4),
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_zuc_encryption_test_case_5),
8301 TEST_CASE_ST(ut_setup, ut_teardown,
8302 test_zuc_hash_generate_test_case_1),
8303 TEST_CASE_ST(ut_setup, ut_teardown,
8304 test_zuc_hash_generate_test_case_2),
8305 TEST_CASE_ST(ut_setup, ut_teardown,
8306 test_zuc_hash_generate_test_case_3),
8307 TEST_CASE_ST(ut_setup, ut_teardown,
8308 test_zuc_hash_generate_test_case_4),
8309 TEST_CASE_ST(ut_setup, ut_teardown,
8310 test_zuc_hash_generate_test_case_5),
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_zuc_encryption_test_case_6_sgl),
8313 TEST_CASES_END() /**< NULL terminate unit test array */
8317 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8318 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8319 .setup = testsuite_setup,
8320 .teardown = testsuite_teardown,
8321 .unit_test_cases = {
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_device_configure_invalid_dev_id),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_multi_session),
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 test_AES_chain_dpaa2_sec_all),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_3DES_chain_dpaa2_sec_all),
8331 TEST_CASE_ST(ut_setup, ut_teardown,
8332 test_AES_cipheronly_dpaa2_sec_all),
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 test_3DES_cipheronly_dpaa2_sec_all),
8336 /** HMAC_MD5 Authentication */
8337 TEST_CASE_ST(ut_setup, ut_teardown,
8338 test_MD5_HMAC_generate_case_1),
8339 TEST_CASE_ST(ut_setup, ut_teardown,
8340 test_MD5_HMAC_verify_case_1),
8341 TEST_CASE_ST(ut_setup, ut_teardown,
8342 test_MD5_HMAC_generate_case_2),
8343 TEST_CASE_ST(ut_setup, ut_teardown,
8344 test_MD5_HMAC_verify_case_2),
8346 TEST_CASES_END() /**< NULL terminate unit test array */
8350 static struct unit_test_suite cryptodev_null_testsuite = {
8351 .suite_name = "Crypto Device NULL Unit Test Suite",
8352 .setup = testsuite_setup,
8353 .teardown = testsuite_teardown,
8354 .unit_test_cases = {
8355 TEST_CASE_ST(ut_setup, ut_teardown,
8356 test_null_auth_only_operation),
8357 TEST_CASE_ST(ut_setup, ut_teardown,
8358 test_null_cipher_only_operation),
8359 TEST_CASE_ST(ut_setup, ut_teardown,
8360 test_null_cipher_auth_operation),
8361 TEST_CASE_ST(ut_setup, ut_teardown,
8362 test_null_auth_cipher_operation),
8363 TEST_CASE_ST(ut_setup, ut_teardown,
8364 test_null_invalid_operation),
8365 TEST_CASE_ST(ut_setup, ut_teardown,
8366 test_null_burst_operation),
8368 TEST_CASES_END() /**< NULL terminate unit test array */
8372 static struct unit_test_suite cryptodev_armv8_testsuite = {
8373 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8374 .setup = testsuite_setup,
8375 .teardown = testsuite_teardown,
8376 .unit_test_cases = {
8377 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8379 /** Negative tests */
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8385 TEST_CASES_END() /**< NULL terminate unit test array */
8390 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8392 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8393 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8397 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8399 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8401 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8405 test_cryptodev_openssl(void)
8407 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8409 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8413 test_cryptodev_aesni_gcm(void)
8415 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8417 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8421 test_cryptodev_null(void)
8423 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8425 return unit_test_suite_runner(&cryptodev_null_testsuite);
8429 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8431 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8433 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8437 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8439 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8441 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8445 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8447 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8449 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8453 test_cryptodev_armv8(void)
8455 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8457 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8460 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8463 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8465 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8466 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8469 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8474 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8476 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8477 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8480 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8481 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8482 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8483 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8484 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8485 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8486 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8487 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8488 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8489 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);