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 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6287 /* Generate Crypto op data structure */
6288 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6289 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6290 TEST_ASSERT_NOT_NULL(ut_params->op,
6291 "Failed to allocate symmetric crypto operation struct");
6293 sym_op = ut_params->op->sym;
6295 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6296 ut_params->ibuf, tdata->gmac_tag.len);
6297 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6298 "no room to append digest");
6300 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6301 ut_params->ibuf, plaintext_pad_len);
6303 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6304 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6305 tdata->gmac_tag.len);
6306 TEST_HEXDUMP(stdout, "digest:",
6307 sym_op->auth.digest.data,
6308 tdata->gmac_tag.len);
6311 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6312 uint8_t *, IV_OFFSET);
6314 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6316 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6318 sym_op->cipher.data.length = 0;
6319 sym_op->cipher.data.offset = 0;
6321 sym_op->auth.data.offset = 0;
6322 sym_op->auth.data.length = tdata->plaintext.len;
6327 static int create_gmac_session(uint8_t dev_id,
6328 const struct gmac_test_data *tdata,
6329 enum rte_crypto_auth_operation auth_op)
6331 uint8_t auth_key[tdata->key.len];
6333 struct crypto_unittest_params *ut_params = &unittest_params;
6335 memcpy(auth_key, tdata->key.data, tdata->key.len);
6337 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6338 ut_params->auth_xform.next = NULL;
6340 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6341 ut_params->auth_xform.auth.op = auth_op;
6342 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6343 ut_params->auth_xform.auth.add_auth_data_length = 0;
6344 ut_params->auth_xform.auth.key.length = tdata->key.len;
6345 ut_params->auth_xform.auth.key.data = auth_key;
6346 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6347 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6350 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6351 &ut_params->auth_xform);
6353 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6359 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6361 struct crypto_testsuite_params *ts_params = &testsuite_params;
6362 struct crypto_unittest_params *ut_params = &unittest_params;
6366 uint8_t *auth_tag, *plaintext;
6367 uint16_t plaintext_pad_len;
6369 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6370 "No GMAC length in the source data");
6372 retval = create_gmac_session(ts_params->valid_devs[0],
6373 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6378 if (tdata->plaintext.len > MBUF_SIZE)
6379 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6382 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6383 "Failed to allocate input buffer in mempool");
6385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6386 rte_pktmbuf_tailroom(ut_params->ibuf));
6388 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6390 * Runtime generate the large plain text instead of use hard code
6391 * plain text vector. It is done to avoid create huge source file
6392 * with the test vector.
6394 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6395 generate_gmac_large_plaintext(tdata->plaintext.data);
6397 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6399 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6401 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6402 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6403 tdata->plaintext.len);
6405 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6411 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6413 ut_params->op->sym->m_src = ut_params->ibuf;
6415 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6416 ut_params->op), "failed to process sym crypto op");
6418 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6419 "crypto op processing failed");
6421 if (ut_params->op->sym->m_dst) {
6422 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6423 uint8_t *, plaintext_pad_len);
6425 auth_tag = plaintext + plaintext_pad_len;
6428 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6430 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6432 tdata->gmac_tag.data,
6433 tdata->gmac_tag.len,
6434 "GMAC Generated auth tag not as expected");
6440 test_AES_GMAC_authentication_test_case_1(void)
6442 return test_AES_GMAC_authentication(&gmac_test_case_1);
6446 test_AES_GMAC_authentication_test_case_2(void)
6448 return test_AES_GMAC_authentication(&gmac_test_case_2);
6452 test_AES_GMAC_authentication_test_case_3(void)
6454 return test_AES_GMAC_authentication(&gmac_test_case_3);
6458 test_AES_GMAC_authentication_test_case_4(void)
6460 return test_AES_GMAC_authentication(&gmac_test_case_4);
6464 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6466 struct crypto_testsuite_params *ts_params = &testsuite_params;
6467 struct crypto_unittest_params *ut_params = &unittest_params;
6469 uint32_t plaintext_pad_len;
6472 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6473 "No GMAC length in the source data");
6475 retval = create_gmac_session(ts_params->valid_devs[0],
6476 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6481 if (tdata->plaintext.len > MBUF_SIZE)
6482 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6484 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6485 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6486 "Failed to allocate input buffer in mempool");
6488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6489 rte_pktmbuf_tailroom(ut_params->ibuf));
6491 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6494 * Runtime generate the large plain text instead of use hard code
6495 * plain text vector. It is done to avoid create huge source file
6496 * with the test vector.
6498 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6499 generate_gmac_large_plaintext(tdata->plaintext.data);
6501 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6503 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6505 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6506 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6507 tdata->plaintext.len);
6509 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6515 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6517 ut_params->op->sym->m_src = ut_params->ibuf;
6519 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6520 ut_params->op), "failed to process sym crypto op");
6522 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6523 "crypto op processing failed");
6530 test_AES_GMAC_authentication_verify_test_case_1(void)
6532 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6536 test_AES_GMAC_authentication_verify_test_case_2(void)
6538 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6542 test_AES_GMAC_authentication_verify_test_case_3(void)
6544 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6548 test_AES_GMAC_authentication_verify_test_case_4(void)
6550 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6553 struct test_crypto_vector {
6554 enum rte_crypto_cipher_algorithm crypto_algo;
6567 const uint8_t *data;
6572 const uint8_t *data;
6576 enum rte_crypto_auth_algorithm auth_algo;
6584 const uint8_t *data;
6594 static const struct test_crypto_vector
6595 hmac_sha1_test_crypto_vector = {
6596 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6598 .data = plaintext_hash,
6603 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6604 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6605 0xDE, 0xF4, 0xDE, 0xAD
6611 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6612 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6613 0x3F, 0x91, 0x64, 0x59
6619 static const struct test_crypto_vector
6620 aes128_gmac_test_vector = {
6621 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6623 .data = plaintext_hash,
6628 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6629 0x08, 0x09, 0x0A, 0x0B
6635 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6636 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6642 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6643 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6649 static const struct test_crypto_vector
6650 aes128cbc_hmac_sha1_test_vector = {
6651 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6654 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6655 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6661 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6662 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6667 .data = plaintext_hash,
6671 .data = ciphertext512_aes128cbc,
6674 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6677 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6678 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6679 0xDE, 0xF4, 0xDE, 0xAD
6685 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6686 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6687 0x18, 0x8C, 0x1D, 0x32
6694 data_corruption(uint8_t *data)
6700 tag_corruption(uint8_t *data, unsigned int tag_offset)
6702 data[tag_offset] += 1;
6706 create_auth_session(struct crypto_unittest_params *ut_params,
6708 const struct test_crypto_vector *reference,
6709 enum rte_crypto_auth_operation auth_op)
6711 uint8_t auth_key[reference->auth_key.len + 1];
6713 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6715 /* Setup Authentication Parameters */
6716 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6717 ut_params->auth_xform.auth.op = auth_op;
6718 ut_params->auth_xform.next = NULL;
6719 ut_params->auth_xform.auth.algo = reference->auth_algo;
6720 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6721 ut_params->auth_xform.auth.key.data = auth_key;
6722 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6723 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6725 /* Create Crypto session*/
6726 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6727 &ut_params->auth_xform);
6729 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6735 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6737 const struct test_crypto_vector *reference,
6738 enum rte_crypto_auth_operation auth_op,
6739 enum rte_crypto_cipher_operation cipher_op)
6741 uint8_t cipher_key[reference->cipher_key.len + 1];
6742 uint8_t auth_key[reference->auth_key.len + 1];
6744 memcpy(cipher_key, reference->cipher_key.data,
6745 reference->cipher_key.len);
6746 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6748 /* Setup Authentication Parameters */
6749 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6750 ut_params->auth_xform.auth.op = auth_op;
6751 ut_params->auth_xform.auth.algo = reference->auth_algo;
6752 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6753 ut_params->auth_xform.auth.key.data = auth_key;
6754 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6756 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6757 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6758 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6760 ut_params->auth_xform.next = &ut_params->cipher_xform;
6761 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6763 /* Setup Cipher Parameters */
6764 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6765 ut_params->cipher_xform.next = NULL;
6766 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6767 ut_params->cipher_xform.cipher.op = cipher_op;
6768 ut_params->cipher_xform.cipher.key.data = cipher_key;
6769 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6770 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6771 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6774 /* Create Crypto session*/
6775 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6776 &ut_params->auth_xform);
6778 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6784 create_auth_operation(struct crypto_testsuite_params *ts_params,
6785 struct crypto_unittest_params *ut_params,
6786 const struct test_crypto_vector *reference,
6787 unsigned int auth_generate)
6789 /* Generate Crypto op data structure */
6790 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6791 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6792 TEST_ASSERT_NOT_NULL(ut_params->op,
6793 "Failed to allocate pktmbuf offload");
6795 /* Set crypto operation data parameters */
6796 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6798 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6800 /* set crypto operation source mbuf */
6801 sym_op->m_src = ut_params->ibuf;
6804 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6805 ut_params->ibuf, reference->digest.len);
6807 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6808 "no room to append auth tag");
6810 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6811 ut_params->ibuf, reference->plaintext.len);
6814 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6816 memcpy(sym_op->auth.digest.data,
6817 reference->digest.data,
6818 reference->digest.len);
6820 TEST_HEXDUMP(stdout, "digest:",
6821 sym_op->auth.digest.data,
6822 reference->digest.len);
6824 sym_op->auth.data.length = reference->plaintext.len;
6825 sym_op->auth.data.offset = 0;
6831 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6832 struct crypto_unittest_params *ut_params,
6833 const struct test_crypto_vector *reference,
6834 unsigned int auth_generate)
6836 /* Generate Crypto op data structure */
6837 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6838 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6839 TEST_ASSERT_NOT_NULL(ut_params->op,
6840 "Failed to allocate pktmbuf offload");
6842 /* Set crypto operation data parameters */
6843 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6845 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6847 /* set crypto operation source mbuf */
6848 sym_op->m_src = ut_params->ibuf;
6851 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6852 ut_params->ibuf, reference->digest.len);
6854 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6855 "no room to append auth tag");
6857 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6858 ut_params->ibuf, reference->ciphertext.len);
6861 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6863 memcpy(sym_op->auth.digest.data,
6864 reference->digest.data,
6865 reference->digest.len);
6867 TEST_HEXDUMP(stdout, "digest:",
6868 sym_op->auth.digest.data,
6869 reference->digest.len);
6871 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6872 reference->iv.data, reference->iv.len);
6874 sym_op->cipher.data.length = 0;
6875 sym_op->cipher.data.offset = 0;
6877 sym_op->auth.data.length = reference->plaintext.len;
6878 sym_op->auth.data.offset = 0;
6884 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6885 struct crypto_unittest_params *ut_params,
6886 const struct test_crypto_vector *reference,
6887 unsigned int auth_generate)
6889 /* Generate Crypto op data structure */
6890 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6891 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6892 TEST_ASSERT_NOT_NULL(ut_params->op,
6893 "Failed to allocate pktmbuf offload");
6895 /* Set crypto operation data parameters */
6896 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6898 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6900 /* set crypto operation source mbuf */
6901 sym_op->m_src = ut_params->ibuf;
6904 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6905 ut_params->ibuf, reference->digest.len);
6907 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6908 "no room to append auth tag");
6910 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6911 ut_params->ibuf, reference->ciphertext.len);
6914 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6916 memcpy(sym_op->auth.digest.data,
6917 reference->digest.data,
6918 reference->digest.len);
6920 TEST_HEXDUMP(stdout, "digest:",
6921 sym_op->auth.digest.data,
6922 reference->digest.len);
6924 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6925 reference->iv.data, reference->iv.len);
6927 sym_op->cipher.data.length = reference->ciphertext.len;
6928 sym_op->cipher.data.offset = 0;
6930 sym_op->auth.data.length = reference->ciphertext.len;
6931 sym_op->auth.data.offset = 0;
6937 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6938 struct crypto_unittest_params *ut_params,
6939 const struct test_crypto_vector *reference)
6941 return create_auth_operation(ts_params, ut_params, reference, 0);
6945 create_auth_verify_GMAC_operation(
6946 struct crypto_testsuite_params *ts_params,
6947 struct crypto_unittest_params *ut_params,
6948 const struct test_crypto_vector *reference)
6950 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6954 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6955 struct crypto_unittest_params *ut_params,
6956 const struct test_crypto_vector *reference)
6958 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6962 test_authentication_verify_fail_when_data_corruption(
6963 struct crypto_testsuite_params *ts_params,
6964 struct crypto_unittest_params *ut_params,
6965 const struct test_crypto_vector *reference,
6966 unsigned int data_corrupted)
6972 /* Create session */
6973 retval = create_auth_session(ut_params,
6974 ts_params->valid_devs[0],
6976 RTE_CRYPTO_AUTH_OP_VERIFY);
6980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6981 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6982 "Failed to allocate input buffer in mempool");
6984 /* clear mbuf payload */
6985 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6986 rte_pktmbuf_tailroom(ut_params->ibuf));
6988 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6989 reference->plaintext.len);
6990 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6991 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6993 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6995 /* Create operation */
6996 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7002 data_corruption(plaintext);
7004 tag_corruption(plaintext, reference->plaintext.len);
7006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7008 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7009 TEST_ASSERT_EQUAL(ut_params->op->status,
7010 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7011 "authentication not failed");
7013 ut_params->obuf = ut_params->op->sym->m_src;
7014 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7020 test_authentication_verify_GMAC_fail_when_corruption(
7021 struct crypto_testsuite_params *ts_params,
7022 struct crypto_unittest_params *ut_params,
7023 const struct test_crypto_vector *reference,
7024 unsigned int data_corrupted)
7029 /* Create session */
7030 retval = create_auth_cipher_session(ut_params,
7031 ts_params->valid_devs[0],
7033 RTE_CRYPTO_AUTH_OP_VERIFY,
7034 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7038 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7039 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7040 "Failed to allocate input buffer in mempool");
7042 /* clear mbuf payload */
7043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7044 rte_pktmbuf_tailroom(ut_params->ibuf));
7046 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7047 reference->plaintext.len);
7048 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7049 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7051 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7053 /* Create operation */
7054 retval = create_auth_verify_GMAC_operation(ts_params,
7062 data_corruption(plaintext);
7064 tag_corruption(plaintext, reference->aad.len);
7066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7069 TEST_ASSERT_EQUAL(ut_params->op->status,
7070 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7071 "authentication not failed");
7073 ut_params->obuf = ut_params->op->sym->m_src;
7074 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7080 test_authenticated_decryption_fail_when_corruption(
7081 struct crypto_testsuite_params *ts_params,
7082 struct crypto_unittest_params *ut_params,
7083 const struct test_crypto_vector *reference,
7084 unsigned int data_corrupted)
7088 uint8_t *ciphertext;
7090 /* Create session */
7091 retval = create_auth_cipher_session(ut_params,
7092 ts_params->valid_devs[0],
7094 RTE_CRYPTO_AUTH_OP_VERIFY,
7095 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7099 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7100 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7101 "Failed to allocate input buffer in mempool");
7103 /* clear mbuf payload */
7104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7105 rte_pktmbuf_tailroom(ut_params->ibuf));
7107 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7108 reference->ciphertext.len);
7109 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7110 memcpy(ciphertext, reference->ciphertext.data,
7111 reference->ciphertext.len);
7113 /* Create operation */
7114 retval = create_cipher_auth_verify_operation(ts_params,
7122 data_corruption(ciphertext);
7124 tag_corruption(ciphertext, reference->ciphertext.len);
7126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7129 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7130 TEST_ASSERT_EQUAL(ut_params->op->status,
7131 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7132 "authentication not failed");
7134 ut_params->obuf = ut_params->op->sym->m_src;
7135 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7141 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
7142 const struct gcm_test_data *tdata,
7143 void *digest_mem, uint64_t digest_phys)
7145 struct crypto_testsuite_params *ts_params = &testsuite_params;
7146 struct crypto_unittest_params *ut_params = &unittest_params;
7148 const unsigned int auth_tag_len = tdata->auth_tag.len;
7149 const unsigned int iv_len = tdata->iv.len;
7150 const unsigned int aad_len = tdata->aad.len;
7152 /* Generate Crypto op data structure */
7153 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7154 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7155 TEST_ASSERT_NOT_NULL(ut_params->op,
7156 "Failed to allocate symmetric crypto operation struct");
7158 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7160 sym_op->auth.digest.data = digest_mem;
7162 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7163 "no room to append digest");
7165 sym_op->auth.digest.phys_addr = digest_phys;
7167 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
7168 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
7170 TEST_HEXDUMP(stdout, "digest:",
7171 sym_op->auth.digest.data,
7175 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7176 uint8_t *, IV_OFFSET);
7178 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7180 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7181 ut_params->ibuf, aad_len);
7182 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
7183 "no room to prepend aad");
7184 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
7187 memset(sym_op->auth.aad.data, 0, aad_len);
7188 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
7190 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7191 TEST_HEXDUMP(stdout, "aad:",
7192 sym_op->auth.aad.data, aad_len);
7194 sym_op->cipher.data.length = tdata->plaintext.len;
7195 sym_op->cipher.data.offset = aad_len;
7197 sym_op->auth.data.offset = aad_len;
7198 sym_op->auth.data.length = tdata->plaintext.len;
7203 #define SGL_MAX_NO 16
7206 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7207 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7209 struct crypto_testsuite_params *ts_params = &testsuite_params;
7210 struct crypto_unittest_params *ut_params = &unittest_params;
7211 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7214 int to_trn_tbl[SGL_MAX_NO];
7216 unsigned int trn_data = 0;
7217 uint8_t *plaintext, *ciphertext, *auth_tag;
7219 if (fragsz > tdata->plaintext.len)
7220 fragsz = tdata->plaintext.len;
7222 uint16_t plaintext_len = fragsz;
7223 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7225 if (fragsz_oop > tdata->plaintext.len)
7226 frag_size_oop = tdata->plaintext.len;
7229 void *digest_mem = NULL;
7231 uint32_t prepend_len = tdata->aad.len;
7233 if (tdata->plaintext.len % fragsz != 0) {
7234 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7237 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7242 * For out-op-place we need to alloc another mbuf
7245 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7246 rte_pktmbuf_append(ut_params->obuf,
7247 frag_size_oop + prepend_len);
7248 buf_oop = ut_params->obuf;
7251 /* Create GCM session */
7252 retval = create_gcm_session(ts_params->valid_devs[0],
7253 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7254 tdata->key.data, tdata->key.len,
7255 tdata->aad.len, tdata->auth_tag.len,
7257 RTE_CRYPTO_AUTH_OP_GENERATE);
7261 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7263 /* clear mbuf payload */
7264 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7265 rte_pktmbuf_tailroom(ut_params->ibuf));
7267 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7270 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7272 trn_data += plaintext_len;
7274 buf = ut_params->ibuf;
7277 * Loop until no more fragments
7280 while (trn_data < tdata->plaintext.len) {
7282 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7283 (tdata->plaintext.len - trn_data) : fragsz;
7285 to_trn_tbl[ecx++] = to_trn;
7287 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7290 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7291 rte_pktmbuf_tailroom(buf));
7294 if (oop && !fragsz_oop) {
7295 buf_last_oop = buf_oop->next =
7296 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7297 buf_oop = buf_oop->next;
7298 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7299 0, rte_pktmbuf_tailroom(buf_oop));
7300 rte_pktmbuf_append(buf_oop, to_trn);
7303 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7306 memcpy(plaintext, tdata->plaintext.data + trn_data,
7309 if (trn_data == tdata->plaintext.len) {
7312 digest_mem = rte_pktmbuf_append(buf_oop,
7313 tdata->auth_tag.len);
7315 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7316 tdata->auth_tag.len);
7320 uint64_t digest_phys = 0;
7322 ut_params->ibuf->nb_segs = segs;
7325 if (fragsz_oop && oop) {
7329 if (frag_size_oop == tdata->plaintext.len) {
7330 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7331 tdata->auth_tag.len);
7333 digest_phys = rte_pktmbuf_mtophys_offset(
7335 tdata->plaintext.len + prepend_len);
7338 trn_data = frag_size_oop;
7339 while (trn_data < tdata->plaintext.len) {
7342 (tdata->plaintext.len - trn_data <
7344 (tdata->plaintext.len - trn_data) :
7347 to_trn_tbl[ecx++] = to_trn;
7349 buf_last_oop = buf_oop->next =
7350 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7351 buf_oop = buf_oop->next;
7352 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7353 0, rte_pktmbuf_tailroom(buf_oop));
7354 rte_pktmbuf_append(buf_oop, to_trn);
7358 if (trn_data == tdata->plaintext.len) {
7359 digest_mem = rte_pktmbuf_append(buf_oop,
7360 tdata->auth_tag.len);
7364 ut_params->obuf->nb_segs = segs;
7368 * Place digest at the end of the last buffer
7371 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7372 if (oop && buf_last_oop)
7373 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7375 if (!digest_mem && !oop) {
7376 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7377 + tdata->auth_tag.len);
7378 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7379 tdata->plaintext.len);
7382 /* Create GCM opertaion */
7383 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7384 tdata, digest_mem, digest_phys);
7389 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7391 ut_params->op->sym->m_src = ut_params->ibuf;
7393 ut_params->op->sym->m_dst = ut_params->obuf;
7395 /* Process crypto operation */
7396 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7397 ut_params->op), "failed to process sym crypto op");
7399 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7400 "crypto op processing failed");
7403 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7404 uint8_t *, prepend_len);
7406 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7407 uint8_t *, prepend_len);
7411 fragsz = fragsz_oop;
7413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7415 tdata->ciphertext.data,
7417 "GCM Ciphertext data not as expected");
7419 buf = ut_params->op->sym->m_src->next;
7421 buf = ut_params->op->sym->m_dst->next;
7423 unsigned int off = fragsz;
7427 ciphertext = rte_pktmbuf_mtod(buf,
7430 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7432 tdata->ciphertext.data + off,
7434 "GCM Ciphertext data not as expected");
7436 off += to_trn_tbl[ecx++];
7440 auth_tag = digest_mem;
7441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7443 tdata->auth_tag.data,
7444 tdata->auth_tag.len,
7445 "GCM Generated auth tag not as expected");
7451 #define OUT_OF_PLACE 1
7454 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7456 return test_AES_GCM_authenticated_encryption_SGL(
7457 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7461 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7463 return test_AES_GCM_authenticated_encryption_SGL(
7464 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7468 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7470 return test_AES_GCM_authenticated_encryption_SGL(
7471 &gcm_test_case_8, OUT_OF_PLACE, 400,
7472 gcm_test_case_8.plaintext.len);
7476 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7479 return test_AES_GCM_authenticated_encryption_SGL(
7480 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7484 test_authentication_verify_fail_when_data_corrupted(
7485 struct crypto_testsuite_params *ts_params,
7486 struct crypto_unittest_params *ut_params,
7487 const struct test_crypto_vector *reference)
7489 return test_authentication_verify_fail_when_data_corruption(
7490 ts_params, ut_params, reference, 1);
7494 test_authentication_verify_fail_when_tag_corrupted(
7495 struct crypto_testsuite_params *ts_params,
7496 struct crypto_unittest_params *ut_params,
7497 const struct test_crypto_vector *reference)
7499 return test_authentication_verify_fail_when_data_corruption(
7500 ts_params, ut_params, reference, 0);
7504 test_authentication_verify_GMAC_fail_when_data_corrupted(
7505 struct crypto_testsuite_params *ts_params,
7506 struct crypto_unittest_params *ut_params,
7507 const struct test_crypto_vector *reference)
7509 return test_authentication_verify_GMAC_fail_when_corruption(
7510 ts_params, ut_params, reference, 1);
7514 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7515 struct crypto_testsuite_params *ts_params,
7516 struct crypto_unittest_params *ut_params,
7517 const struct test_crypto_vector *reference)
7519 return test_authentication_verify_GMAC_fail_when_corruption(
7520 ts_params, ut_params, reference, 0);
7524 test_authenticated_decryption_fail_when_data_corrupted(
7525 struct crypto_testsuite_params *ts_params,
7526 struct crypto_unittest_params *ut_params,
7527 const struct test_crypto_vector *reference)
7529 return test_authenticated_decryption_fail_when_corruption(
7530 ts_params, ut_params, reference, 1);
7534 test_authenticated_decryption_fail_when_tag_corrupted(
7535 struct crypto_testsuite_params *ts_params,
7536 struct crypto_unittest_params *ut_params,
7537 const struct test_crypto_vector *reference)
7539 return test_authenticated_decryption_fail_when_corruption(
7540 ts_params, ut_params, reference, 0);
7544 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7546 return test_authentication_verify_fail_when_data_corrupted(
7547 &testsuite_params, &unittest_params,
7548 &hmac_sha1_test_crypto_vector);
7552 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7554 return test_authentication_verify_fail_when_tag_corrupted(
7555 &testsuite_params, &unittest_params,
7556 &hmac_sha1_test_crypto_vector);
7560 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7562 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7563 &testsuite_params, &unittest_params,
7564 &aes128_gmac_test_vector);
7568 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7570 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7571 &testsuite_params, &unittest_params,
7572 &aes128_gmac_test_vector);
7576 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7578 return test_authenticated_decryption_fail_when_data_corrupted(
7581 &aes128cbc_hmac_sha1_test_vector);
7585 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7587 return test_authenticated_decryption_fail_when_tag_corrupted(
7590 &aes128cbc_hmac_sha1_test_vector);
7593 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7595 /* global AESNI slave IDs for the scheduler test */
7596 uint8_t aesni_ids[2];
7599 test_scheduler_attach_slave_op(void)
7601 struct crypto_testsuite_params *ts_params = &testsuite_params;
7602 uint8_t sched_id = ts_params->valid_devs[0];
7603 uint32_t nb_devs, i, nb_devs_attached = 0;
7607 /* create 2 AESNI_MB if necessary */
7608 nb_devs = rte_cryptodev_count_devtype(
7609 RTE_CRYPTODEV_AESNI_MB_PMD);
7611 for (i = nb_devs; i < 2; i++) {
7612 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7613 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7615 ret = rte_vdev_init(vdev_name, NULL);
7617 TEST_ASSERT(ret == 0,
7618 "Failed to create instance %u of"
7620 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7624 /* attach 2 AESNI_MB cdevs */
7625 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7627 struct rte_cryptodev_info info;
7629 rte_cryptodev_info_get(i, &info);
7630 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7633 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7636 TEST_ASSERT(ret == 0,
7637 "Failed to attach device %u of pmd : %s", i,
7638 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7640 aesni_ids[nb_devs_attached] = (uint8_t)i;
7649 test_scheduler_detach_slave_op(void)
7651 struct crypto_testsuite_params *ts_params = &testsuite_params;
7652 uint8_t sched_id = ts_params->valid_devs[0];
7656 for (i = 0; i < 2; i++) {
7657 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7659 TEST_ASSERT(ret == 0,
7660 "Failed to detach device %u", aesni_ids[i]);
7667 test_scheduler_mode_op(void)
7669 struct crypto_testsuite_params *ts_params = &testsuite_params;
7670 uint8_t sched_id = ts_params->valid_devs[0];
7671 struct rte_cryptodev_scheduler_ops op = {0};
7672 struct rte_cryptodev_scheduler dummy_scheduler = {
7673 .description = "dummy scheduler to test mode",
7674 .name = "dummy scheduler",
7675 .mode = CDEV_SCHED_MODE_USERDEFINED,
7680 /* set user defined mode */
7681 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7683 TEST_ASSERT(ret == 0,
7684 "Failed to set cdev %u to user defined mode", sched_id);
7686 /* set round robin mode */
7687 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7688 CDEV_SCHED_MODE_ROUNDROBIN);
7689 TEST_ASSERT(ret == 0,
7690 "Failed to set cdev %u to round-robin mode", sched_id);
7691 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7692 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7698 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7699 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7700 .setup = testsuite_setup,
7701 .teardown = testsuite_teardown,
7702 .unit_test_cases = {
7703 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7704 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7705 TEST_CASE_ST(ut_setup, ut_teardown,
7706 test_AES_chain_scheduler_all),
7707 TEST_CASE_ST(ut_setup, ut_teardown,
7708 test_AES_cipheronly_scheduler_all),
7709 TEST_CASE_ST(ut_setup, ut_teardown,
7710 test_authonly_scheduler_all),
7711 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7712 TEST_CASES_END() /**< NULL terminate unit test array */
7716 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7718 static struct unit_test_suite cryptodev_qat_testsuite = {
7719 .suite_name = "Crypto QAT Unit Test Suite",
7720 .setup = testsuite_setup,
7721 .teardown = testsuite_teardown,
7722 .unit_test_cases = {
7723 TEST_CASE_ST(ut_setup, ut_teardown,
7724 test_device_configure_invalid_dev_id),
7725 TEST_CASE_ST(ut_setup, ut_teardown,
7726 test_device_configure_invalid_queue_pair_ids),
7727 TEST_CASE_ST(ut_setup, ut_teardown,
7728 test_queue_pair_descriptor_setup),
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 test_multi_session),
7732 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_AES_cipheronly_qat_all),
7735 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7736 TEST_CASE_ST(ut_setup, ut_teardown,
7737 test_3DES_cipheronly_qat_all),
7738 TEST_CASE_ST(ut_setup, ut_teardown,
7739 test_DES_cipheronly_qat_all),
7740 TEST_CASE_ST(ut_setup, ut_teardown,
7741 test_AES_docsis_qat_all),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_DES_docsis_qat_all),
7744 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7746 /** AES GCM Authenticated Encryption */
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7755 TEST_CASE_ST(ut_setup, ut_teardown,
7756 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7757 TEST_CASE_ST(ut_setup, ut_teardown,
7758 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7759 TEST_CASE_ST(ut_setup, ut_teardown,
7760 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7768 /** AES GCM Authenticated Decryption */
7769 TEST_CASE_ST(ut_setup, ut_teardown,
7770 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7771 TEST_CASE_ST(ut_setup, ut_teardown,
7772 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7773 TEST_CASE_ST(ut_setup, ut_teardown,
7774 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7775 TEST_CASE_ST(ut_setup, ut_teardown,
7776 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7777 TEST_CASE_ST(ut_setup, ut_teardown,
7778 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7779 TEST_CASE_ST(ut_setup, ut_teardown,
7780 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7781 TEST_CASE_ST(ut_setup, ut_teardown,
7782 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7784 /** AES GMAC Authentication */
7785 TEST_CASE_ST(ut_setup, ut_teardown,
7786 test_AES_GMAC_authentication_test_case_1),
7787 TEST_CASE_ST(ut_setup, ut_teardown,
7788 test_AES_GMAC_authentication_verify_test_case_1),
7789 TEST_CASE_ST(ut_setup, ut_teardown,
7790 test_AES_GMAC_authentication_test_case_2),
7791 TEST_CASE_ST(ut_setup, ut_teardown,
7792 test_AES_GMAC_authentication_verify_test_case_2),
7793 TEST_CASE_ST(ut_setup, ut_teardown,
7794 test_AES_GMAC_authentication_test_case_3),
7795 TEST_CASE_ST(ut_setup, ut_teardown,
7796 test_AES_GMAC_authentication_verify_test_case_3),
7798 /** SNOW 3G encrypt only (UEA2) */
7799 TEST_CASE_ST(ut_setup, ut_teardown,
7800 test_snow3g_encryption_test_case_1),
7801 TEST_CASE_ST(ut_setup, ut_teardown,
7802 test_snow3g_encryption_test_case_2),
7803 TEST_CASE_ST(ut_setup, ut_teardown,
7804 test_snow3g_encryption_test_case_3),
7805 TEST_CASE_ST(ut_setup, ut_teardown,
7806 test_snow3g_encryption_test_case_4),
7807 TEST_CASE_ST(ut_setup, ut_teardown,
7808 test_snow3g_encryption_test_case_5),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_snow3g_encryption_test_case_1_oop),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_snow3g_decryption_test_case_1_oop),
7815 /** SNOW 3G decrypt only (UEA2) */
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_snow3g_decryption_test_case_1),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_snow3g_decryption_test_case_2),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_snow3g_decryption_test_case_3),
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_snow3g_decryption_test_case_4),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_snow3g_decryption_test_case_5),
7826 TEST_CASE_ST(ut_setup, ut_teardown,
7827 test_snow3g_hash_generate_test_case_1),
7828 TEST_CASE_ST(ut_setup, ut_teardown,
7829 test_snow3g_hash_generate_test_case_2),
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 test_snow3g_hash_generate_test_case_3),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 test_snow3g_hash_verify_test_case_1),
7834 TEST_CASE_ST(ut_setup, ut_teardown,
7835 test_snow3g_hash_verify_test_case_2),
7836 TEST_CASE_ST(ut_setup, ut_teardown,
7837 test_snow3g_hash_verify_test_case_3),
7838 TEST_CASE_ST(ut_setup, ut_teardown,
7839 test_snow3g_cipher_auth_test_case_1),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_snow3g_auth_cipher_test_case_1),
7843 /** ZUC encrypt only (EEA3) */
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_zuc_encryption_test_case_1),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_zuc_encryption_test_case_2),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_zuc_encryption_test_case_3),
7850 TEST_CASE_ST(ut_setup, ut_teardown,
7851 test_zuc_encryption_test_case_4),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_zuc_encryption_test_case_5),
7855 /** ZUC authenticate (EIA3) */
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_zuc_hash_generate_test_case_6),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_zuc_hash_generate_test_case_7),
7860 TEST_CASE_ST(ut_setup, ut_teardown,
7861 test_zuc_hash_generate_test_case_8),
7863 /** ZUC alg-chain (EEA3/EIA3) */
7864 TEST_CASE_ST(ut_setup, ut_teardown,
7865 test_zuc_cipher_auth_test_case_1),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_zuc_cipher_auth_test_case_2),
7869 /** HMAC_MD5 Authentication */
7870 TEST_CASE_ST(ut_setup, ut_teardown,
7871 test_MD5_HMAC_generate_case_1),
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_MD5_HMAC_verify_case_1),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_MD5_HMAC_generate_case_2),
7876 TEST_CASE_ST(ut_setup, ut_teardown,
7877 test_MD5_HMAC_verify_case_2),
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_null_auth_only_operation),
7882 TEST_CASE_ST(ut_setup, ut_teardown,
7883 test_null_cipher_only_operation),
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_null_cipher_auth_operation),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_null_auth_cipher_operation),
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_kasumi_hash_generate_test_case_6),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_kasumi_encryption_test_case_1),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_kasumi_encryption_test_case_3),
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_kasumi_auth_cipher_test_case_1),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_kasumi_cipher_auth_test_case_1),
7902 /** Negative tests */
7903 TEST_CASE_ST(ut_setup, ut_teardown,
7904 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 authentication_verify_AES128_GMAC_fail_data_corrupt),
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7916 TEST_CASES_END() /**< NULL terminate unit test array */
7920 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7921 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7922 .setup = testsuite_setup,
7923 .teardown = testsuite_teardown,
7924 .unit_test_cases = {
7925 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7926 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7927 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7928 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7930 TEST_CASES_END() /**< NULL terminate unit test array */
7934 static struct unit_test_suite cryptodev_openssl_testsuite = {
7935 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7936 .setup = testsuite_setup,
7937 .teardown = testsuite_teardown,
7938 .unit_test_cases = {
7939 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7940 TEST_CASE_ST(ut_setup, ut_teardown,
7941 test_multi_session_random_usage),
7942 TEST_CASE_ST(ut_setup, ut_teardown,
7943 test_AES_chain_openssl_all),
7944 TEST_CASE_ST(ut_setup, ut_teardown,
7945 test_AES_cipheronly_openssl_all),
7946 TEST_CASE_ST(ut_setup, ut_teardown,
7947 test_3DES_chain_openssl_all),
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_3DES_cipheronly_openssl_all),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_DES_docsis_openssl_all),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_authonly_openssl_all),
7955 /** AES GCM Authenticated Encryption */
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7958 TEST_CASE_ST(ut_setup, ut_teardown,
7959 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7971 /** AES GCM Authenticated Decryption */
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7987 /** AES GMAC Authentication */
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 test_AES_GMAC_authentication_test_case_1),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_AES_GMAC_authentication_verify_test_case_1),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_AES_GMAC_authentication_test_case_2),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_AES_GMAC_authentication_verify_test_case_2),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_AES_GMAC_authentication_test_case_3),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_AES_GMAC_authentication_verify_test_case_3),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_AES_GMAC_authentication_test_case_4),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_AES_GMAC_authentication_verify_test_case_4),
8005 /** Scatter-Gather */
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8009 /** Negative tests */
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 authentication_verify_AES128_GMAC_fail_data_corrupt),
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8023 TEST_CASES_END() /**< NULL terminate unit test array */
8027 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8028 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8029 .setup = testsuite_setup,
8030 .teardown = testsuite_teardown,
8031 .unit_test_cases = {
8032 /** AES GCM Authenticated Encryption */
8033 TEST_CASE_ST(ut_setup, ut_teardown,
8034 test_mb_AES_GCM_authenticated_encryption_test_case_1),
8035 TEST_CASE_ST(ut_setup, ut_teardown,
8036 test_mb_AES_GCM_authenticated_encryption_test_case_2),
8037 TEST_CASE_ST(ut_setup, ut_teardown,
8038 test_mb_AES_GCM_authenticated_encryption_test_case_3),
8039 TEST_CASE_ST(ut_setup, ut_teardown,
8040 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8048 /** AES GCM Authenticated Decryption */
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8064 /** AES GCM Authenticated Encryption 256 bits key */
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8080 /** AES GCM Authenticated Decryption 256 bits key */
8081 TEST_CASE_ST(ut_setup, ut_teardown,
8082 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8087 TEST_CASE_ST(ut_setup, ut_teardown,
8088 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8096 /** AES GCM Authenticated Encryption big aad size */
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8099 TEST_CASE_ST(ut_setup, ut_teardown,
8100 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8102 /** AES GCM Authenticated Decryption big aad size */
8103 TEST_CASE_ST(ut_setup, ut_teardown,
8104 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8108 /** AES GMAC Authentication */
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 test_AES_GMAC_authentication_test_case_1),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 test_AES_GMAC_authentication_verify_test_case_1),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_AES_GMAC_authentication_test_case_3),
8115 TEST_CASE_ST(ut_setup, ut_teardown,
8116 test_AES_GMAC_authentication_verify_test_case_3),
8117 TEST_CASE_ST(ut_setup, ut_teardown,
8118 test_AES_GMAC_authentication_test_case_4),
8119 TEST_CASE_ST(ut_setup, ut_teardown,
8120 test_AES_GMAC_authentication_verify_test_case_4),
8122 /** Negative tests */
8123 TEST_CASE_ST(ut_setup, ut_teardown,
8124 authentication_verify_AES128_GMAC_fail_data_corrupt),
8125 TEST_CASE_ST(ut_setup, ut_teardown,
8126 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8128 /** Out of place tests */
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 test_mb_AES_GCM_authenticated_encryption_oop),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 test_mb_AES_GCM_authenticated_decryption_oop),
8134 /** Session-less tests */
8135 TEST_CASE_ST(ut_setup, ut_teardown,
8136 test_mb_AES_GCM_authenticated_encryption_sessionless),
8137 TEST_CASE_ST(ut_setup, ut_teardown,
8138 test_mb_AES_GCM_authenticated_decryption_sessionless),
8140 /** Scatter-Gather */
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8144 TEST_CASES_END() /**< NULL terminate unit test array */
8148 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8149 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8150 .setup = testsuite_setup,
8151 .teardown = testsuite_teardown,
8152 .unit_test_cases = {
8153 /** KASUMI encrypt only (UEA1) */
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_kasumi_encryption_test_case_1),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_kasumi_encryption_test_case_1_sgl),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_kasumi_encryption_test_case_2),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_kasumi_encryption_test_case_3),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_kasumi_encryption_test_case_4),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_kasumi_encryption_test_case_5),
8166 /** KASUMI decrypt only (UEA1) */
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_kasumi_decryption_test_case_1),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_kasumi_decryption_test_case_2),
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_kasumi_decryption_test_case_3),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_kasumi_decryption_test_case_4),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_kasumi_decryption_test_case_5),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 test_kasumi_encryption_test_case_1_oop),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_kasumi_encryption_test_case_1_oop_sgl),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_kasumi_decryption_test_case_1_oop),
8187 /** KASUMI hash only (UIA1) */
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_kasumi_hash_generate_test_case_1),
8190 TEST_CASE_ST(ut_setup, ut_teardown,
8191 test_kasumi_hash_generate_test_case_2),
8192 TEST_CASE_ST(ut_setup, ut_teardown,
8193 test_kasumi_hash_generate_test_case_3),
8194 TEST_CASE_ST(ut_setup, ut_teardown,
8195 test_kasumi_hash_generate_test_case_4),
8196 TEST_CASE_ST(ut_setup, ut_teardown,
8197 test_kasumi_hash_generate_test_case_5),
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_kasumi_hash_generate_test_case_6),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 test_kasumi_hash_verify_test_case_1),
8202 TEST_CASE_ST(ut_setup, ut_teardown,
8203 test_kasumi_hash_verify_test_case_2),
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 test_kasumi_hash_verify_test_case_3),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 test_kasumi_hash_verify_test_case_4),
8208 TEST_CASE_ST(ut_setup, ut_teardown,
8209 test_kasumi_hash_verify_test_case_5),
8210 TEST_CASE_ST(ut_setup, ut_teardown,
8211 test_kasumi_auth_cipher_test_case_1),
8212 TEST_CASE_ST(ut_setup, ut_teardown,
8213 test_kasumi_cipher_auth_test_case_1),
8214 TEST_CASES_END() /**< NULL terminate unit test array */
8217 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8218 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8219 .setup = testsuite_setup,
8220 .teardown = testsuite_teardown,
8221 .unit_test_cases = {
8222 /** SNOW 3G encrypt only (UEA2) */
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_snow3g_encryption_test_case_1),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_snow3g_encryption_test_case_2),
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_snow3g_encryption_test_case_3),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_snow3g_encryption_test_case_4),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_snow3g_encryption_test_case_5),
8234 TEST_CASE_ST(ut_setup, ut_teardown,
8235 test_snow3g_encryption_test_case_1_oop),
8236 TEST_CASE_ST(ut_setup, ut_teardown,
8237 test_snow3g_encryption_test_case_1_oop_sgl),
8238 TEST_CASE_ST(ut_setup, ut_teardown,
8239 test_snow3g_decryption_test_case_1_oop),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 test_snow3g_encryption_test_case_1_offset_oop),
8244 /** SNOW 3G decrypt only (UEA2) */
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_snow3g_decryption_test_case_1),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_snow3g_decryption_test_case_2),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_snow3g_decryption_test_case_3),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_snow3g_decryption_test_case_4),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_snow3g_decryption_test_case_5),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_snow3g_hash_generate_test_case_1),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_snow3g_hash_generate_test_case_2),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_snow3g_hash_generate_test_case_3),
8261 /* Tests with buffers which length is not byte-aligned */
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_snow3g_hash_generate_test_case_4),
8264 TEST_CASE_ST(ut_setup, ut_teardown,
8265 test_snow3g_hash_generate_test_case_5),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_snow3g_hash_generate_test_case_6),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_snow3g_hash_verify_test_case_1),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_snow3g_hash_verify_test_case_2),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_snow3g_hash_verify_test_case_3),
8274 /* Tests with buffers which length is not byte-aligned */
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_snow3g_hash_verify_test_case_4),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_snow3g_hash_verify_test_case_5),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_snow3g_hash_verify_test_case_6),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_snow3g_cipher_auth_test_case_1),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_snow3g_auth_cipher_test_case_1),
8286 TEST_CASES_END() /**< NULL terminate unit test array */
8290 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8291 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8292 .setup = testsuite_setup,
8293 .teardown = testsuite_teardown,
8294 .unit_test_cases = {
8295 /** ZUC encrypt only (EEA3) */
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_zuc_encryption_test_case_1),
8298 TEST_CASE_ST(ut_setup, ut_teardown,
8299 test_zuc_encryption_test_case_2),
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_zuc_encryption_test_case_3),
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_zuc_encryption_test_case_4),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_zuc_encryption_test_case_5),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_zuc_hash_generate_test_case_1),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_zuc_hash_generate_test_case_2),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_zuc_hash_generate_test_case_3),
8312 TEST_CASE_ST(ut_setup, ut_teardown,
8313 test_zuc_hash_generate_test_case_4),
8314 TEST_CASE_ST(ut_setup, ut_teardown,
8315 test_zuc_hash_generate_test_case_5),
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_zuc_encryption_test_case_6_sgl),
8318 TEST_CASES_END() /**< NULL terminate unit test array */
8322 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8323 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8324 .setup = testsuite_setup,
8325 .teardown = testsuite_teardown,
8326 .unit_test_cases = {
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 test_device_configure_invalid_dev_id),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_multi_session),
8332 TEST_CASE_ST(ut_setup, ut_teardown,
8333 test_AES_chain_dpaa2_sec_all),
8334 TEST_CASE_ST(ut_setup, ut_teardown,
8335 test_3DES_chain_dpaa2_sec_all),
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_AES_cipheronly_dpaa2_sec_all),
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_3DES_cipheronly_dpaa2_sec_all),
8341 /** HMAC_MD5 Authentication */
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_MD5_HMAC_generate_case_1),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_MD5_HMAC_verify_case_1),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_MD5_HMAC_generate_case_2),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_MD5_HMAC_verify_case_2),
8351 TEST_CASES_END() /**< NULL terminate unit test array */
8355 static struct unit_test_suite cryptodev_null_testsuite = {
8356 .suite_name = "Crypto Device NULL Unit Test Suite",
8357 .setup = testsuite_setup,
8358 .teardown = testsuite_teardown,
8359 .unit_test_cases = {
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_null_auth_only_operation),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_null_cipher_only_operation),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_null_cipher_auth_operation),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_null_auth_cipher_operation),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_null_invalid_operation),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_null_burst_operation),
8373 TEST_CASES_END() /**< NULL terminate unit test array */
8377 static struct unit_test_suite cryptodev_armv8_testsuite = {
8378 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8379 .setup = testsuite_setup,
8380 .teardown = testsuite_teardown,
8381 .unit_test_cases = {
8382 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8384 /** Negative tests */
8385 TEST_CASE_ST(ut_setup, ut_teardown,
8386 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8387 TEST_CASE_ST(ut_setup, ut_teardown,
8388 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8390 TEST_CASES_END() /**< NULL terminate unit test array */
8395 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8397 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8398 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8402 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8404 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8406 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8410 test_cryptodev_openssl(void)
8412 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8414 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8418 test_cryptodev_aesni_gcm(void)
8420 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8422 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8426 test_cryptodev_null(void)
8428 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8430 return unit_test_suite_runner(&cryptodev_null_testsuite);
8434 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8436 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8438 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8442 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8444 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8446 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8450 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8452 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8454 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8458 test_cryptodev_armv8(void)
8460 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8462 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8465 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8468 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8470 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8471 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8474 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8479 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8481 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8482 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8485 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8486 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8487 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8488 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8489 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8490 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8491 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8492 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8493 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8494 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);