4 * Copyright(c) 2015-2016 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>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
44 #include "test_cryptodev.h"
46 #include "test_cryptodev_aes.h"
47 #include "test_cryptodev_kasumi_test_vectors.h"
48 #include "test_cryptodev_kasumi_hash_test_vectors.h"
49 #include "test_cryptodev_snow3g_test_vectors.h"
50 #include "test_cryptodev_snow3g_hash_test_vectors.h"
51 #include "test_cryptodev_gcm_test_vectors.h"
52 #include "test_cryptodev_hmac_test_vectors.h"
54 static enum rte_cryptodev_type gbl_cryptodev_type;
56 struct crypto_testsuite_params {
57 struct rte_mempool *mbuf_pool;
58 struct rte_mempool *op_mpool;
59 struct rte_cryptodev_config conf;
60 struct rte_cryptodev_qp_conf qp_conf;
62 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
63 uint8_t valid_dev_count;
66 struct crypto_unittest_params {
67 struct rte_crypto_sym_xform cipher_xform;
68 struct rte_crypto_sym_xform auth_xform;
70 struct rte_cryptodev_sym_session *sess;
72 struct rte_crypto_op *op;
74 struct rte_mbuf *obuf, *ibuf;
79 #define ALIGN_POW2_ROUNDUP(num, align) \
80 (((num) + (align) - 1) & ~((align) - 1))
83 * Forward declarations.
86 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
87 struct crypto_unittest_params *ut_params);
90 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
91 struct crypto_unittest_params *ut_params,
92 struct crypto_testsuite_params *ts_param);
94 static struct rte_mbuf *
95 setup_test_string(struct rte_mempool *mpool,
96 const char *string, size_t len, uint8_t blocksize)
98 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
99 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
101 memset(m->buf_addr, 0, m->buf_len);
103 char *dst = rte_pktmbuf_append(m, t_len);
110 rte_memcpy(dst, string, t_len);
112 memset(dst, 0, t_len);
118 /* Get number of bytes in X bits (rounding up) */
120 ceil_byte_length(uint32_t num_bits)
123 return ((num_bits >> 3) + 1);
125 return (num_bits >> 3);
128 static struct rte_crypto_op *
129 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
131 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
132 printf("Error sending packet for encryption");
138 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
144 static struct crypto_testsuite_params testsuite_params = { NULL };
145 static struct crypto_unittest_params unittest_params;
148 testsuite_setup(void)
150 struct crypto_testsuite_params *ts_params = &testsuite_params;
151 struct rte_cryptodev_info info;
152 unsigned i, nb_devs, dev_id;
156 memset(ts_params, 0, sizeof(*ts_params));
158 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
159 if (ts_params->mbuf_pool == NULL) {
160 /* Not already created so create */
161 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
163 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
165 if (ts_params->mbuf_pool == NULL) {
166 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
171 ts_params->op_mpool = rte_crypto_op_pool_create(
172 "MBUF_CRYPTO_SYM_OP_POOL",
173 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
174 NUM_MBUFS, MBUF_CACHE_SIZE,
176 sizeof(struct rte_crypto_sym_xform),
178 if (ts_params->op_mpool == NULL) {
179 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
183 /* Create 2 AESNI MB devices if required */
184 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
185 #ifndef RTE_LIBRTE_PMD_AESNI_MB
186 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
187 " enabled in config file to run this testsuite.\n");
190 nb_devs = rte_cryptodev_count_devtype(
191 RTE_CRYPTODEV_AESNI_MB_PMD);
193 for (i = nb_devs; i < 2; i++) {
194 ret = rte_eal_vdev_init(
195 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
197 TEST_ASSERT(ret == 0,
198 "Failed to create instance %u of"
200 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
205 /* Create 2 AESNI GCM devices if required */
206 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
207 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
208 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
209 " enabled in config file to run this testsuite.\n");
212 nb_devs = rte_cryptodev_count_devtype(
213 RTE_CRYPTODEV_AESNI_GCM_PMD);
215 for (i = nb_devs; i < 2; i++) {
216 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
217 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
218 "Failed to create instance %u of"
220 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
225 /* Create 2 SNOW 3G devices if required */
226 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
227 #ifndef RTE_LIBRTE_PMD_SNOW3G
228 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
229 " enabled in config file to run this testsuite.\n");
232 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
234 for (i = nb_devs; i < 2; i++) {
235 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
236 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
237 "Failed to create instance %u of"
239 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
244 /* Create 2 KASUMI devices if required */
245 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
246 #ifndef RTE_LIBRTE_PMD_KASUMI
247 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
248 " enabled in config file to run this testsuite.\n");
251 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
253 for (i = nb_devs; i < 2; i++) {
254 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
255 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
256 "Failed to create instance %u of"
258 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
263 /* Create 2 NULL devices if required */
264 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
265 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
266 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
267 " enabled in config file to run this testsuite.\n");
270 nb_devs = rte_cryptodev_count_devtype(
271 RTE_CRYPTODEV_NULL_PMD);
273 for (i = nb_devs; i < 2; i++) {
274 int dev_id = rte_eal_vdev_init(
275 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
277 TEST_ASSERT(dev_id >= 0,
278 "Failed to create instance %u of"
280 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
285 #ifndef RTE_LIBRTE_PMD_QAT
286 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
287 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
288 "in config file to run this testsuite.\n");
293 nb_devs = rte_cryptodev_count();
295 RTE_LOG(ERR, USER1, "No crypto devices found?");
299 /* Create list of valid crypto devs */
300 for (i = 0; i < nb_devs; i++) {
301 rte_cryptodev_info_get(i, &info);
302 if (info.dev_type == gbl_cryptodev_type)
303 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
306 if (ts_params->valid_dev_count < 1)
309 /* Set up all the qps on the first of the valid devices found */
310 for (i = 0; i < 1; i++) {
311 dev_id = ts_params->valid_devs[i];
313 rte_cryptodev_info_get(dev_id, &info);
316 * Since we can't free and re-allocate queue memory always set
317 * the queues on this device up to max size first so enough
318 * memory is allocated for any later re-configures needed by
322 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
323 ts_params->conf.socket_id = SOCKET_ID_ANY;
324 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
326 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
328 "Failed to configure cryptodev %u with %u qps",
329 dev_id, ts_params->conf.nb_queue_pairs);
331 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
333 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
334 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
335 dev_id, qp_id, &ts_params->qp_conf,
336 rte_cryptodev_socket_id(dev_id)),
337 "Failed to setup queue pair %u on "
347 testsuite_teardown(void)
349 struct crypto_testsuite_params *ts_params = &testsuite_params;
351 if (ts_params->mbuf_pool != NULL) {
352 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
353 rte_mempool_avail_count(ts_params->mbuf_pool));
356 if (ts_params->op_mpool != NULL) {
357 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
358 rte_mempool_avail_count(ts_params->op_mpool));
366 struct crypto_testsuite_params *ts_params = &testsuite_params;
367 struct crypto_unittest_params *ut_params = &unittest_params;
371 /* Clear unit test parameters before running test */
372 memset(ut_params, 0, sizeof(*ut_params));
374 /* Reconfigure device to default parameters */
375 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
376 ts_params->conf.socket_id = SOCKET_ID_ANY;
377 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
379 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
381 "Failed to configure cryptodev %u",
382 ts_params->valid_devs[0]);
385 * Now reconfigure queues to size we actually want to use in this
388 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
390 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
391 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
392 ts_params->valid_devs[0], qp_id,
394 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
395 "Failed to setup queue pair %u on cryptodev %u",
396 qp_id, ts_params->valid_devs[0]);
400 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
402 /* Start the device */
403 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
404 "Failed to start cryptodev %u",
405 ts_params->valid_devs[0]);
413 struct crypto_testsuite_params *ts_params = &testsuite_params;
414 struct crypto_unittest_params *ut_params = &unittest_params;
415 struct rte_cryptodev_stats stats;
417 /* free crypto session structure */
418 if (ut_params->sess) {
419 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
421 ut_params->sess = NULL;
424 /* free crypto operation structure */
426 rte_crypto_op_free(ut_params->op);
429 * free mbuf - both obuf and ibuf are usually the same,
430 * so check if they point at the same address is necessary,
431 * to avoid freeing the mbuf twice.
433 if (ut_params->obuf) {
434 rte_pktmbuf_free(ut_params->obuf);
435 if (ut_params->ibuf == ut_params->obuf)
439 if (ut_params->ibuf) {
440 rte_pktmbuf_free(ut_params->ibuf);
444 if (ts_params->mbuf_pool != NULL)
445 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
446 rte_mempool_avail_count(ts_params->mbuf_pool));
448 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
450 /* Stop the device */
451 rte_cryptodev_stop(ts_params->valid_devs[0]);
455 test_device_configure_invalid_dev_id(void)
457 struct crypto_testsuite_params *ts_params = &testsuite_params;
458 uint16_t dev_id, num_devs = 0;
460 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
461 "Need at least %d devices for test", 1);
463 /* valid dev_id values */
464 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
466 /* Stop the device in case it's started so it can be configured */
467 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
469 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
470 "Failed test for rte_cryptodev_configure: "
471 "invalid dev_num %u", dev_id);
473 /* invalid dev_id values */
476 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
477 "Failed test for rte_cryptodev_configure: "
478 "invalid dev_num %u", dev_id);
482 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
483 "Failed test for rte_cryptodev_configure:"
484 "invalid dev_num %u", dev_id);
490 test_device_configure_invalid_queue_pair_ids(void)
492 struct crypto_testsuite_params *ts_params = &testsuite_params;
494 /* Stop the device in case it's started so it can be configured */
495 rte_cryptodev_stop(ts_params->valid_devs[0]);
497 /* valid - one queue pairs */
498 ts_params->conf.nb_queue_pairs = 1;
500 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
502 "Failed to configure cryptodev: dev_id %u, qp_id %u",
503 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
506 /* valid - max value queue pairs */
507 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
509 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
511 "Failed to configure cryptodev: dev_id %u, qp_id %u",
512 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
515 /* invalid - zero queue pairs */
516 ts_params->conf.nb_queue_pairs = 0;
518 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
520 "Failed test for rte_cryptodev_configure, dev_id %u,"
522 ts_params->valid_devs[0],
523 ts_params->conf.nb_queue_pairs);
526 /* invalid - max value supported by field queue pairs */
527 ts_params->conf.nb_queue_pairs = UINT16_MAX;
529 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
531 "Failed test for rte_cryptodev_configure, dev_id %u,"
533 ts_params->valid_devs[0],
534 ts_params->conf.nb_queue_pairs);
537 /* invalid - max value + 1 queue pairs */
538 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
540 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
542 "Failed test for rte_cryptodev_configure, dev_id %u,"
544 ts_params->valid_devs[0],
545 ts_params->conf.nb_queue_pairs);
551 test_queue_pair_descriptor_setup(void)
553 struct crypto_testsuite_params *ts_params = &testsuite_params;
554 struct rte_cryptodev_info dev_info;
555 struct rte_cryptodev_qp_conf qp_conf = {
556 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
561 /* Stop the device in case it's started so it can be configured */
562 rte_cryptodev_stop(ts_params->valid_devs[0]);
565 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
567 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
569 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
570 &ts_params->conf), "Failed to configure cryptodev %u",
571 ts_params->valid_devs[0]);
575 * Test various ring sizes on this device. memzones can't be
576 * freed so are re-used if ring is released and re-created.
578 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
580 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
581 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
582 ts_params->valid_devs[0], qp_id, &qp_conf,
583 rte_cryptodev_socket_id(
584 ts_params->valid_devs[0])),
586 "rte_cryptodev_queue_pair_setup: num_inflights "
587 "%u on qp %u on cryptodev %u",
588 qp_conf.nb_descriptors, qp_id,
589 ts_params->valid_devs[0]);
592 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
594 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
595 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
596 ts_params->valid_devs[0], qp_id, &qp_conf,
597 rte_cryptodev_socket_id(
598 ts_params->valid_devs[0])),
600 " rte_cryptodev_queue_pair_setup: num_inflights"
601 " %u on qp %u on cryptodev %u",
602 qp_conf.nb_descriptors, qp_id,
603 ts_params->valid_devs[0]);
606 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
608 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
609 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
610 ts_params->valid_devs[0], qp_id, &qp_conf,
611 rte_cryptodev_socket_id(
612 ts_params->valid_devs[0])),
614 "rte_cryptodev_queue_pair_setup: num_inflights"
615 " %u on qp %u on cryptodev %u",
616 qp_conf.nb_descriptors, qp_id,
617 ts_params->valid_devs[0]);
620 /* invalid number of descriptors - max supported + 2 */
621 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
623 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
624 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
625 ts_params->valid_devs[0], qp_id, &qp_conf,
626 rte_cryptodev_socket_id(
627 ts_params->valid_devs[0])),
628 "Unexpectedly passed test for "
629 "rte_cryptodev_queue_pair_setup:"
630 "num_inflights %u on qp %u on cryptodev %u",
631 qp_conf.nb_descriptors, qp_id,
632 ts_params->valid_devs[0]);
635 /* invalid number of descriptors - max value of parameter */
636 qp_conf.nb_descriptors = UINT32_MAX-1;
638 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
639 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
640 ts_params->valid_devs[0], qp_id, &qp_conf,
641 rte_cryptodev_socket_id(
642 ts_params->valid_devs[0])),
643 "Unexpectedly passed test for "
644 "rte_cryptodev_queue_pair_setup:"
645 "num_inflights %u on qp %u on cryptodev %u",
646 qp_conf.nb_descriptors, qp_id,
647 ts_params->valid_devs[0]);
650 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
652 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
653 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
654 ts_params->valid_devs[0], qp_id, &qp_conf,
655 rte_cryptodev_socket_id(
656 ts_params->valid_devs[0])),
658 " rte_cryptodev_queue_pair_setup:"
659 "num_inflights %u on qp %u on cryptodev %u",
660 qp_conf.nb_descriptors, qp_id,
661 ts_params->valid_devs[0]);
664 /* invalid number of descriptors - max supported + 1 */
665 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
667 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
668 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
669 ts_params->valid_devs[0], qp_id, &qp_conf,
670 rte_cryptodev_socket_id(
671 ts_params->valid_devs[0])),
672 "Unexpectedly passed test for "
673 "rte_cryptodev_queue_pair_setup:"
674 "num_inflights %u on qp %u on cryptodev %u",
675 qp_conf.nb_descriptors, qp_id,
676 ts_params->valid_devs[0]);
679 /* test invalid queue pair id */
680 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
682 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
684 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
685 ts_params->valid_devs[0],
687 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
688 "Failed test for rte_cryptodev_queue_pair_setup:"
689 "invalid qp %u on cryptodev %u",
690 qp_id, ts_params->valid_devs[0]);
692 qp_id = 0xffff; /*invalid*/
694 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
695 ts_params->valid_devs[0],
697 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
698 "Failed test for rte_cryptodev_queue_pair_setup:"
699 "invalid qp %u on cryptodev %u",
700 qp_id, ts_params->valid_devs[0]);
705 /* ***** Plaintext data for tests ***** */
707 const char catch_22_quote_1[] =
708 "There was only one catch and that was Catch-22, which "
709 "specified that a concern for one's safety in the face of "
710 "dangers that were real and immediate was the process of a "
711 "rational mind. Orr was crazy and could be grounded. All he "
712 "had to do was ask; and as soon as he did, he would no longer "
713 "be crazy and would have to fly more missions. Orr would be "
714 "crazy to fly more missions and sane if he didn't, but if he "
715 "was sane he had to fly them. If he flew them he was crazy "
716 "and didn't have to; but if he didn't want to he was sane and "
717 "had to. Yossarian was moved very deeply by the absolute "
718 "simplicity of this clause of Catch-22 and let out a "
719 "respectful whistle. \"That's some catch, that Catch-22\", he "
720 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
722 const char catch_22_quote[] =
723 "What a lousy earth! He wondered how many people were "
724 "destitute that same night even in his own prosperous country, "
725 "how many homes were shanties, how many husbands were drunk "
726 "and wives socked, and how many children were bullied, abused, "
727 "or abandoned. How many families hungered for food they could "
728 "not afford to buy? How many hearts were broken? How many "
729 "suicides would take place that same night, how many people "
730 "would go insane? How many cockroaches and landlords would "
731 "triumph? How many winners were losers, successes failures, "
732 "and rich men poor men? How many wise guys were stupid? How "
733 "many happy endings were unhappy endings? How many honest men "
734 "were liars, brave men cowards, loyal men traitors, how many "
735 "sainted men were corrupt, how many people in positions of "
736 "trust had sold their souls to bodyguards, how many had never "
737 "had souls? How many straight-and-narrow paths were crooked "
738 "paths? How many best families were worst families and how "
739 "many good people were bad people? When you added them all up "
740 "and then subtracted, you might be left with only the children, "
741 "and perhaps with Albert Einstein and an old violinist or "
742 "sculptor somewhere.";
744 #define QUOTE_480_BYTES (480)
745 #define QUOTE_512_BYTES (512)
746 #define QUOTE_768_BYTES (768)
747 #define QUOTE_1024_BYTES (1024)
751 /* ***** SHA1 Hash Tests ***** */
753 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
755 static uint8_t hmac_sha1_key[] = {
756 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
757 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
758 0xDE, 0xF4, 0xDE, 0xAD };
760 /* ***** SHA224 Hash Tests ***** */
762 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
765 /* ***** AES-CBC Cipher Tests ***** */
767 #define CIPHER_KEY_LENGTH_AES_CBC (16)
768 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
770 static uint8_t aes_cbc_key[] = {
771 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
772 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
774 static uint8_t aes_cbc_iv[] = {
775 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
776 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
779 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
781 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
782 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
783 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
784 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
785 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
786 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
787 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
788 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
789 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
790 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
791 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
792 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
793 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
794 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
795 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
796 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
797 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
798 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
799 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
800 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
801 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
802 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
803 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
804 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
805 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
806 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
807 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
808 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
809 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
810 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
811 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
812 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
813 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
814 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
815 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
816 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
817 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
818 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
819 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
820 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
821 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
822 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
823 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
824 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
825 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
826 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
827 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
828 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
829 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
830 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
831 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
832 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
833 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
834 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
835 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
836 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
837 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
838 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
839 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
840 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
841 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
842 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
843 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
844 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
845 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
848 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
849 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
850 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
851 0x18, 0x8c, 0x1d, 0x32
856 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
858 struct crypto_testsuite_params *ts_params = &testsuite_params;
859 struct crypto_unittest_params *ut_params = &unittest_params;
861 /* Generate test mbuf data and space for digest */
862 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
863 catch_22_quote, QUOTE_512_BYTES, 0);
865 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
866 DIGEST_BYTE_LENGTH_SHA1);
867 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
869 /* Setup Cipher Parameters */
870 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
871 ut_params->cipher_xform.next = &ut_params->auth_xform;
873 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
874 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
875 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
876 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
878 /* Setup HMAC Parameters */
879 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
881 ut_params->auth_xform.next = NULL;
883 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
884 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
885 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
886 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
887 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
889 /* Create crypto session*/
890 ut_params->sess = rte_cryptodev_sym_session_create(
891 ts_params->valid_devs[0],
892 &ut_params->cipher_xform);
893 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
895 /* Generate crypto op data structure */
896 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
897 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
898 TEST_ASSERT_NOT_NULL(ut_params->op,
899 "Failed to allocate symmetric crypto operation struct");
901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
903 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
905 /* set crypto operation source mbuf */
906 sym_op->m_src = ut_params->ibuf;
908 /* Set crypto operation authentication parameters */
909 sym_op->auth.digest.data = ut_params->digest;
910 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
911 ut_params->ibuf, QUOTE_512_BYTES);
912 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
914 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
915 sym_op->auth.data.length = QUOTE_512_BYTES;
917 /* Set crypto operation cipher parameters */
918 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
919 CIPHER_IV_LENGTH_AES_CBC);
920 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
921 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
923 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
924 CIPHER_IV_LENGTH_AES_CBC);
926 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
927 sym_op->cipher.data.length = QUOTE_512_BYTES;
929 /* Process crypto operation */
930 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
931 ut_params->op), "failed to process sym crypto op");
933 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
934 "crypto op processing failed");
937 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
938 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
940 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
941 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
943 "ciphertext data not as expected");
945 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
947 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
948 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
949 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
950 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
951 DIGEST_BYTE_LENGTH_SHA1,
952 "Generated digest data not as expected");
957 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
959 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
961 static uint8_t hmac_sha512_key[] = {
962 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
963 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
964 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
965 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
966 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
967 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
968 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
969 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
971 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
972 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
973 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
974 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
975 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
976 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
977 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
978 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
979 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
984 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
985 struct crypto_unittest_params *ut_params);
988 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
989 struct crypto_unittest_params *ut_params,
990 struct crypto_testsuite_params *ts_params);
994 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
995 struct crypto_unittest_params *ut_params)
998 /* Setup Cipher Parameters */
999 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1000 ut_params->cipher_xform.next = NULL;
1002 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1003 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1004 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1005 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1007 /* Setup HMAC Parameters */
1008 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1009 ut_params->auth_xform.next = &ut_params->cipher_xform;
1011 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1012 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1013 ut_params->auth_xform.auth.key.data = hmac_sha512_key;
1014 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1015 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1017 return TEST_SUCCESS;
1022 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1023 struct crypto_unittest_params *ut_params,
1024 struct crypto_testsuite_params *ts_params)
1026 /* Generate test mbuf data and digest */
1027 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1029 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1030 QUOTE_512_BYTES, 0);
1032 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1033 DIGEST_BYTE_LENGTH_SHA512);
1034 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1036 rte_memcpy(ut_params->digest,
1037 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1038 DIGEST_BYTE_LENGTH_SHA512);
1040 /* Generate Crypto op data structure */
1041 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1042 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1043 TEST_ASSERT_NOT_NULL(ut_params->op,
1044 "Failed to allocate symmetric crypto operation struct");
1046 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1048 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1050 /* set crypto operation source mbuf */
1051 sym_op->m_src = ut_params->ibuf;
1053 sym_op->auth.digest.data = ut_params->digest;
1054 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1055 ut_params->ibuf, QUOTE_512_BYTES);
1056 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1058 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1059 sym_op->auth.data.length = QUOTE_512_BYTES;
1061 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1062 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1063 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1064 ut_params->ibuf, 0);
1065 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1067 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1068 CIPHER_IV_LENGTH_AES_CBC);
1070 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1071 sym_op->cipher.data.length = QUOTE_512_BYTES;
1073 /* Process crypto operation */
1074 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1075 ut_params->op), "failed to process sym crypto op");
1077 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1078 "crypto op processing failed");
1080 ut_params->obuf = ut_params->op->sym->m_src;
1083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1084 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1085 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1087 "Plaintext data not as expected");
1090 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1091 "Digest verification failed");
1093 return TEST_SUCCESS;
1097 test_AES_mb_all(void)
1099 struct crypto_testsuite_params *ts_params = &testsuite_params;
1102 status = test_AES_all_tests(ts_params->mbuf_pool,
1103 ts_params->op_mpool, ts_params->valid_devs[0],
1104 RTE_CRYPTODEV_AESNI_MB_PMD);
1106 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1108 return TEST_SUCCESS;
1112 test_AES_qat_all(void)
1114 struct crypto_testsuite_params *ts_params = &testsuite_params;
1117 status = test_AES_all_tests(ts_params->mbuf_pool,
1118 ts_params->op_mpool, ts_params->valid_devs[0],
1119 RTE_CRYPTODEV_QAT_SYM_PMD);
1121 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1123 return TEST_SUCCESS;
1126 /* ***** SNOW 3G Tests ***** */
1128 create_wireless_algo_hash_session(uint8_t dev_id,
1129 const uint8_t *key, const uint8_t key_len,
1130 const uint8_t aad_len, const uint8_t auth_len,
1131 enum rte_crypto_auth_operation op,
1132 enum rte_crypto_auth_algorithm algo)
1134 uint8_t hash_key[key_len];
1136 struct crypto_unittest_params *ut_params = &unittest_params;
1138 memcpy(hash_key, key, key_len);
1140 TEST_HEXDUMP(stdout, "key:", key, key_len);
1142 /* Setup Authentication Parameters */
1143 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1144 ut_params->auth_xform.next = NULL;
1146 ut_params->auth_xform.auth.op = op;
1147 ut_params->auth_xform.auth.algo = algo;
1148 ut_params->auth_xform.auth.key.length = key_len;
1149 ut_params->auth_xform.auth.key.data = hash_key;
1150 ut_params->auth_xform.auth.digest_length = auth_len;
1151 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1152 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1153 &ut_params->auth_xform);
1154 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1159 create_wireless_algo_cipher_session(uint8_t dev_id,
1160 enum rte_crypto_cipher_operation op,
1161 enum rte_crypto_cipher_algorithm algo,
1162 const uint8_t *key, const uint8_t key_len)
1164 uint8_t cipher_key[key_len];
1166 struct crypto_unittest_params *ut_params = &unittest_params;
1168 memcpy(cipher_key, key, key_len);
1170 /* Setup Cipher Parameters */
1171 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1172 ut_params->cipher_xform.next = NULL;
1174 ut_params->cipher_xform.cipher.algo = algo;
1175 ut_params->cipher_xform.cipher.op = op;
1176 ut_params->cipher_xform.cipher.key.data = cipher_key;
1177 ut_params->cipher_xform.cipher.key.length = key_len;
1179 TEST_HEXDUMP(stdout, "key:", key, key_len);
1181 /* Create Crypto session */
1182 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1185 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1190 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1191 const unsigned cipher_len,
1192 const unsigned cipher_offset,
1193 enum rte_crypto_cipher_algorithm algo)
1195 struct crypto_testsuite_params *ts_params = &testsuite_params;
1196 struct crypto_unittest_params *ut_params = &unittest_params;
1197 unsigned iv_pad_len = 0;
1199 /* Generate Crypto op data structure */
1200 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1201 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1202 TEST_ASSERT_NOT_NULL(ut_params->op,
1203 "Failed to allocate pktmbuf offload");
1205 /* Set crypto operation data parameters */
1206 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1208 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1210 /* set crypto operation source mbuf */
1211 sym_op->m_src = ut_params->ibuf;
1214 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1215 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1217 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1219 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1222 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1224 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1225 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1226 sym_op->cipher.iv.length = iv_pad_len;
1228 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1229 sym_op->cipher.data.length = cipher_len;
1230 sym_op->cipher.data.offset = cipher_offset;
1235 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1236 const unsigned cipher_len,
1237 const unsigned cipher_offset,
1238 enum rte_crypto_cipher_algorithm algo)
1240 struct crypto_testsuite_params *ts_params = &testsuite_params;
1241 struct crypto_unittest_params *ut_params = &unittest_params;
1242 unsigned iv_pad_len = 0;
1244 /* Generate Crypto op data structure */
1245 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1246 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1247 TEST_ASSERT_NOT_NULL(ut_params->op,
1248 "Failed to allocate pktmbuf offload");
1250 /* Set crypto operation data parameters */
1251 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1253 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1255 /* set crypto operation source mbuf */
1256 sym_op->m_src = ut_params->ibuf;
1257 sym_op->m_dst = ut_params->obuf;
1260 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1261 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1263 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1264 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1267 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1269 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1270 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1271 sym_op->cipher.iv.length = iv_pad_len;
1273 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1274 sym_op->cipher.data.length = cipher_len;
1275 sym_op->cipher.data.offset = cipher_offset;
1280 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1281 enum rte_crypto_cipher_operation cipher_op,
1282 enum rte_crypto_auth_operation auth_op,
1283 enum rte_crypto_auth_algorithm auth_algo,
1284 enum rte_crypto_cipher_algorithm cipher_algo,
1285 const uint8_t *key, const uint8_t key_len,
1286 const uint8_t aad_len, const uint8_t auth_len)
1289 uint8_t cipher_auth_key[key_len];
1291 struct crypto_unittest_params *ut_params = &unittest_params;
1293 memcpy(cipher_auth_key, key, key_len);
1295 /* Setup Authentication Parameters */
1296 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1297 ut_params->auth_xform.next = NULL;
1299 ut_params->auth_xform.auth.op = auth_op;
1300 ut_params->auth_xform.auth.algo = auth_algo;
1301 ut_params->auth_xform.auth.key.length = key_len;
1302 /* Hash key = cipher key */
1303 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1304 ut_params->auth_xform.auth.digest_length = auth_len;
1305 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1307 /* Setup Cipher Parameters */
1308 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1309 ut_params->cipher_xform.next = &ut_params->auth_xform;
1311 ut_params->cipher_xform.cipher.algo = cipher_algo;
1312 ut_params->cipher_xform.cipher.op = cipher_op;
1313 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1314 ut_params->cipher_xform.cipher.key.length = key_len;
1316 TEST_HEXDUMP(stdout, "key:", key, key_len);
1318 /* Create Crypto session*/
1319 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1320 &ut_params->cipher_xform);
1322 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1327 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1328 enum rte_crypto_cipher_operation cipher_op,
1329 enum rte_crypto_auth_operation auth_op,
1330 enum rte_crypto_auth_algorithm auth_algo,
1331 enum rte_crypto_cipher_algorithm cipher_algo,
1332 const uint8_t *key, const uint8_t key_len,
1333 const uint8_t aad_len, const uint8_t auth_len)
1335 uint8_t auth_cipher_key[key_len];
1337 struct crypto_unittest_params *ut_params = &unittest_params;
1339 memcpy(auth_cipher_key, key, key_len);
1341 /* Setup Authentication Parameters */
1342 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1343 ut_params->auth_xform.auth.op = auth_op;
1344 ut_params->auth_xform.next = &ut_params->cipher_xform;
1345 ut_params->auth_xform.auth.algo = auth_algo;
1346 ut_params->auth_xform.auth.key.length = key_len;
1347 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1348 ut_params->auth_xform.auth.digest_length = auth_len;
1349 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1351 /* Setup Cipher Parameters */
1352 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1353 ut_params->cipher_xform.next = NULL;
1354 ut_params->cipher_xform.cipher.algo = cipher_algo;
1355 ut_params->cipher_xform.cipher.op = cipher_op;
1356 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1357 ut_params->cipher_xform.cipher.key.length = key_len;
1359 TEST_HEXDUMP(stdout, "key:", key, key_len);
1361 /* Create Crypto session*/
1362 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1363 &ut_params->auth_xform);
1365 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1371 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1372 const unsigned auth_tag_len,
1373 const uint8_t *aad, const unsigned aad_len,
1374 unsigned data_pad_len,
1375 enum rte_crypto_auth_operation op,
1376 enum rte_crypto_auth_algorithm algo,
1377 const unsigned auth_len, const unsigned auth_offset)
1379 struct crypto_testsuite_params *ts_params = &testsuite_params;
1381 struct crypto_unittest_params *ut_params = &unittest_params;
1383 unsigned aad_buffer_len;
1385 /* Generate Crypto op data structure */
1386 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1387 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1388 TEST_ASSERT_NOT_NULL(ut_params->op,
1389 "Failed to allocate pktmbuf offload");
1391 /* Set crypto operation data parameters */
1392 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1394 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1396 /* set crypto operation source mbuf */
1397 sym_op->m_src = ut_params->ibuf;
1401 * Always allocate the aad up to the block size.
1402 * The cryptodev API calls out -
1403 * - the array must be big enough to hold the AAD, plus any
1404 * space to round this up to the nearest multiple of the
1405 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1407 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1408 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1410 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1411 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1412 ut_params->ibuf, aad_buffer_len);
1413 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1414 "no room to prepend aad");
1415 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1417 sym_op->auth.aad.length = aad_len;
1419 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1420 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1422 TEST_HEXDUMP(stdout, "aad:",
1423 sym_op->auth.aad.data, aad_len);
1426 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1427 ut_params->ibuf, auth_tag_len);
1429 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1430 "no room to append auth tag");
1431 ut_params->digest = sym_op->auth.digest.data;
1432 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1433 ut_params->ibuf, data_pad_len + aad_len);
1434 sym_op->auth.digest.length = auth_tag_len;
1435 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1436 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1438 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1440 TEST_HEXDUMP(stdout, "digest:",
1441 sym_op->auth.digest.data,
1442 sym_op->auth.digest.length);
1444 sym_op->auth.data.length = auth_len;
1445 sym_op->auth.data.offset = auth_offset;
1451 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1452 const unsigned auth_tag_len,
1453 const uint8_t *aad, const uint8_t aad_len,
1454 unsigned data_pad_len,
1455 enum rte_crypto_auth_operation op,
1456 enum rte_crypto_auth_algorithm auth_algo,
1457 enum rte_crypto_cipher_algorithm cipher_algo,
1458 const uint8_t *iv, const uint8_t iv_len,
1459 const unsigned cipher_len, const unsigned cipher_offset,
1460 const unsigned auth_len, const unsigned auth_offset)
1462 struct crypto_testsuite_params *ts_params = &testsuite_params;
1463 struct crypto_unittest_params *ut_params = &unittest_params;
1465 unsigned iv_pad_len = 0;
1466 unsigned aad_buffer_len;
1468 /* Generate Crypto op data structure */
1469 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1470 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1471 TEST_ASSERT_NOT_NULL(ut_params->op,
1472 "Failed to allocate pktmbuf offload");
1473 /* Set crypto operation data parameters */
1474 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1476 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1478 /* set crypto operation source mbuf */
1479 sym_op->m_src = ut_params->ibuf;
1482 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1483 ut_params->ibuf, auth_tag_len);
1485 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1486 "no room to append auth tag");
1487 ut_params->digest = sym_op->auth.digest.data;
1488 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1489 ut_params->ibuf, data_pad_len);
1490 sym_op->auth.digest.length = auth_tag_len;
1491 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1492 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1494 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1496 TEST_HEXDUMP(stdout, "digest:",
1497 sym_op->auth.digest.data,
1498 sym_op->auth.digest.length);
1502 * Always allocate the aad up to the block size.
1503 * The cryptodev API calls out -
1504 * - the array must be big enough to hold the AAD, plus any
1505 * space to round this up to the nearest multiple of the
1506 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1508 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1509 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1511 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1512 sym_op->auth.aad.data =
1513 (uint8_t *)rte_pktmbuf_prepend(
1514 ut_params->ibuf, aad_buffer_len);
1515 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1516 "no room to prepend aad");
1517 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1519 sym_op->auth.aad.length = aad_len;
1520 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1521 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1522 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1525 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1526 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1528 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1529 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1530 ut_params->ibuf, iv_pad_len);
1532 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1533 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1534 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1535 sym_op->cipher.iv.length = iv_pad_len;
1536 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1537 sym_op->cipher.data.length = cipher_len;
1538 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1539 sym_op->auth.data.length = auth_len;
1540 sym_op->auth.data.offset = auth_offset + cipher_offset;
1546 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1547 const uint8_t *iv, const uint8_t iv_len,
1548 const uint8_t *aad, const uint8_t aad_len,
1549 unsigned data_pad_len,
1550 const unsigned cipher_len, const unsigned cipher_offset,
1551 const unsigned auth_len, const unsigned auth_offset,
1552 enum rte_crypto_auth_algorithm auth_algo,
1553 enum rte_crypto_cipher_algorithm cipher_algo)
1555 struct crypto_testsuite_params *ts_params = &testsuite_params;
1556 struct crypto_unittest_params *ut_params = &unittest_params;
1558 unsigned iv_pad_len = 0;
1559 unsigned aad_buffer_len = 0;
1561 /* Generate Crypto op data structure */
1562 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1563 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1564 TEST_ASSERT_NOT_NULL(ut_params->op,
1565 "Failed to allocate pktmbuf offload");
1567 /* Set crypto operation data parameters */
1568 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1570 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1572 /* set crypto operation source mbuf */
1573 sym_op->m_src = ut_params->ibuf;
1576 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1577 ut_params->ibuf, auth_tag_len);
1579 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1580 "no room to append auth tag");
1582 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1583 ut_params->ibuf, data_pad_len);
1584 sym_op->auth.digest.length = auth_tag_len;
1586 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1588 TEST_HEXDUMP(stdout, "digest:",
1589 sym_op->auth.digest.data,
1590 sym_op->auth.digest.length);
1594 * Always allocate the aad up to the block size.
1595 * The cryptodev API calls out -
1596 * - the array must be big enough to hold the AAD, plus any
1597 * space to round this up to the nearest multiple of the
1598 * block size (8 bytes for KASUMI 16 bytes).
1600 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1601 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1603 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1604 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1605 ut_params->ibuf, aad_buffer_len);
1606 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1607 "no room to prepend aad");
1608 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1610 sym_op->auth.aad.length = aad_len;
1611 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1612 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1613 TEST_HEXDUMP(stdout, "aad:",
1614 sym_op->auth.aad.data, aad_len);
1617 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1618 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1620 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1622 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1623 ut_params->ibuf, iv_pad_len);
1624 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1626 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1627 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1628 sym_op->cipher.iv.length = iv_pad_len;
1630 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1632 sym_op->cipher.data.length = cipher_len;
1633 sym_op->cipher.data.offset = auth_offset + cipher_offset;
1635 sym_op->auth.data.length = auth_len;
1636 sym_op->auth.data.offset = auth_offset + cipher_offset;
1642 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
1644 struct crypto_testsuite_params *ts_params = &testsuite_params;
1645 struct crypto_unittest_params *ut_params = &unittest_params;
1648 unsigned plaintext_pad_len;
1649 unsigned plaintext_len;
1652 /* Create SNOW 3G session */
1653 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
1654 tdata->key.data, tdata->key.len,
1655 tdata->aad.len, tdata->digest.len,
1656 RTE_CRYPTO_AUTH_OP_GENERATE,
1657 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
1661 /* alloc mbuf and set payload */
1662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1664 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1665 rte_pktmbuf_tailroom(ut_params->ibuf));
1667 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1668 /* Append data which is padded to a multiple of */
1669 /* the algorithms block size */
1670 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
1671 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1673 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1675 /* Create SNOW 3G operation */
1676 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
1677 tdata->aad.data, tdata->aad.len,
1678 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1679 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1680 tdata->validAuthLenInBits.len,
1681 tdata->validAuthOffsetLenInBits.len);
1685 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1687 ut_params->obuf = ut_params->op->sym->m_src;
1688 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1689 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1690 + plaintext_pad_len + tdata->aad.len;
1693 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1696 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
1697 "SNOW 3G Generated auth tag not as expected");
1703 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
1705 struct crypto_testsuite_params *ts_params = &testsuite_params;
1706 struct crypto_unittest_params *ut_params = &unittest_params;
1709 unsigned plaintext_pad_len;
1710 unsigned plaintext_len;
1713 /* Create SNOW 3G session */
1714 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
1715 tdata->key.data, tdata->key.len,
1716 tdata->aad.len, tdata->digest.len,
1717 RTE_CRYPTO_AUTH_OP_VERIFY,
1718 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
1721 /* alloc mbuf and set payload */
1722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1724 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1725 rte_pktmbuf_tailroom(ut_params->ibuf));
1727 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1728 /* Append data which is padded to a multiple of */
1729 /* the algorithms block size */
1730 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
1731 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1733 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1735 /* Create SNOW 3G operation */
1736 retval = create_wireless_algo_hash_operation(tdata->digest.data,
1738 tdata->aad.data, tdata->aad.len,
1740 RTE_CRYPTO_AUTH_OP_VERIFY,
1741 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1742 tdata->validAuthLenInBits.len,
1743 tdata->validAuthOffsetLenInBits.len);
1747 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1749 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1750 ut_params->obuf = ut_params->op->sym->m_src;
1751 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1752 + plaintext_pad_len + tdata->aad.len;
1755 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
1764 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
1766 struct crypto_testsuite_params *ts_params = &testsuite_params;
1767 struct crypto_unittest_params *ut_params = &unittest_params;
1770 unsigned plaintext_pad_len;
1771 unsigned plaintext_len;
1774 /* Create KASUMI session */
1775 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
1776 tdata->key.data, tdata->key.len,
1777 tdata->aad.len, tdata->digest.len,
1778 RTE_CRYPTO_AUTH_OP_GENERATE,
1779 RTE_CRYPTO_AUTH_KASUMI_F9);
1783 /* alloc mbuf and set payload */
1784 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1786 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1787 rte_pktmbuf_tailroom(ut_params->ibuf));
1789 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1790 /* Append data which is padded to a multiple of */
1791 /* the algorithms block size */
1792 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1793 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1795 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1797 /* Create KASUMI operation */
1798 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
1799 tdata->aad.data, tdata->aad.len,
1800 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1801 RTE_CRYPTO_AUTH_KASUMI_F9,
1802 tdata->validAuthLenInBits.len,
1803 tdata->validAuthOffsetLenInBits.len);
1807 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1809 ut_params->obuf = ut_params->op->sym->m_src;
1810 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1811 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1812 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
1815 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1818 DIGEST_BYTE_LENGTH_KASUMI_F9,
1819 "KASUMI Generated auth tag not as expected");
1825 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
1827 struct crypto_testsuite_params *ts_params = &testsuite_params;
1828 struct crypto_unittest_params *ut_params = &unittest_params;
1831 unsigned plaintext_pad_len;
1832 unsigned plaintext_len;
1835 /* Create KASUMI session */
1836 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
1837 tdata->key.data, tdata->key.len,
1838 tdata->aad.len, tdata->digest.len,
1839 RTE_CRYPTO_AUTH_OP_VERIFY,
1840 RTE_CRYPTO_AUTH_KASUMI_F9);
1843 /* alloc mbuf and set payload */
1844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1846 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1847 rte_pktmbuf_tailroom(ut_params->ibuf));
1849 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1850 /* Append data which is padded to a multiple */
1851 /* of the algorithms block size */
1852 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1853 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1855 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1857 /* Create KASUMI operation */
1858 retval = create_wireless_algo_hash_operation(tdata->digest.data,
1860 tdata->aad.data, tdata->aad.len,
1862 RTE_CRYPTO_AUTH_OP_VERIFY,
1863 RTE_CRYPTO_AUTH_KASUMI_F9,
1864 tdata->validAuthLenInBits.len,
1865 tdata->validAuthOffsetLenInBits.len);
1869 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1871 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1872 ut_params->obuf = ut_params->op->sym->m_src;
1873 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1874 + plaintext_pad_len + tdata->aad.len;
1877 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
1886 test_snow3g_hash_generate_test_case_1(void)
1888 return test_snow3g_authentication(&snow3g_hash_test_case_1);
1892 test_snow3g_hash_generate_test_case_2(void)
1894 return test_snow3g_authentication(&snow3g_hash_test_case_2);
1898 test_snow3g_hash_generate_test_case_3(void)
1900 return test_snow3g_authentication(&snow3g_hash_test_case_3);
1904 test_snow3g_hash_generate_test_case_4(void)
1906 return test_snow3g_authentication(&snow3g_hash_test_case_4);
1910 test_snow3g_hash_generate_test_case_5(void)
1912 return test_snow3g_authentication(&snow3g_hash_test_case_5);
1916 test_snow3g_hash_generate_test_case_6(void)
1918 return test_snow3g_authentication(&snow3g_hash_test_case_6);
1922 test_snow3g_hash_verify_test_case_1(void)
1924 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
1929 test_snow3g_hash_verify_test_case_2(void)
1931 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
1935 test_snow3g_hash_verify_test_case_3(void)
1937 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
1941 test_snow3g_hash_verify_test_case_4(void)
1943 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
1947 test_snow3g_hash_verify_test_case_5(void)
1949 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
1953 test_snow3g_hash_verify_test_case_6(void)
1955 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
1959 test_kasumi_hash_generate_test_case_1(void)
1961 return test_kasumi_authentication(&kasumi_hash_test_case_1);
1965 test_kasumi_hash_generate_test_case_2(void)
1967 return test_kasumi_authentication(&kasumi_hash_test_case_2);
1971 test_kasumi_hash_generate_test_case_3(void)
1973 return test_kasumi_authentication(&kasumi_hash_test_case_3);
1977 test_kasumi_hash_generate_test_case_4(void)
1979 return test_kasumi_authentication(&kasumi_hash_test_case_4);
1983 test_kasumi_hash_generate_test_case_5(void)
1985 return test_kasumi_authentication(&kasumi_hash_test_case_5);
1989 test_kasumi_hash_generate_test_case_6(void)
1991 return test_kasumi_authentication(&kasumi_hash_test_case_6);
1995 test_kasumi_hash_verify_test_case_1(void)
1997 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2001 test_kasumi_hash_verify_test_case_2(void)
2003 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2007 test_kasumi_hash_verify_test_case_3(void)
2009 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2013 test_kasumi_hash_verify_test_case_4(void)
2015 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2019 test_kasumi_hash_verify_test_case_5(void)
2021 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2025 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2027 struct crypto_testsuite_params *ts_params = &testsuite_params;
2028 struct crypto_unittest_params *ut_params = &unittest_params;
2031 uint8_t *plaintext, *ciphertext;
2032 unsigned plaintext_pad_len;
2033 unsigned plaintext_len;
2035 /* Create KASUMI session */
2036 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2037 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2038 RTE_CRYPTO_CIPHER_KASUMI_F8,
2039 tdata->key.data, tdata->key.len);
2043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2045 /* Clear mbuf payload */
2046 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2047 rte_pktmbuf_tailroom(ut_params->ibuf));
2049 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2050 /* Append data which is padded to a multiple */
2051 /* of the algorithms block size */
2052 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2055 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2057 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2059 /* Create KASUMI operation */
2060 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2061 tdata->plaintext.len,
2062 tdata->validCipherOffsetLenInBits.len,
2063 RTE_CRYPTO_CIPHER_KASUMI_F8);
2067 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2069 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2071 ut_params->obuf = ut_params->op->sym->m_dst;
2072 if (ut_params->obuf)
2073 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2076 ciphertext = plaintext;
2078 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2083 tdata->ciphertext.data,
2084 tdata->validCipherLenInBits.len,
2085 "KASUMI Ciphertext data not as expected");
2090 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2092 struct crypto_testsuite_params *ts_params = &testsuite_params;
2093 struct crypto_unittest_params *ut_params = &unittest_params;
2096 uint8_t *plaintext, *ciphertext;
2097 unsigned plaintext_pad_len;
2098 unsigned plaintext_len;
2100 /* Create KASUMI session */
2101 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2102 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2103 RTE_CRYPTO_CIPHER_KASUMI_F8,
2104 tdata->key.data, tdata->key.len);
2108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2109 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2111 /* Clear mbuf payload */
2112 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2113 rte_pktmbuf_tailroom(ut_params->ibuf));
2115 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2116 /* Append data which is padded to a multiple */
2117 /* of the algorithms block size */
2118 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2119 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2121 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2122 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2124 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2126 /* Create KASUMI operation */
2127 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2129 tdata->plaintext.len,
2130 tdata->validCipherOffsetLenInBits.len,
2131 RTE_CRYPTO_CIPHER_KASUMI_F8);
2135 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2137 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2139 ut_params->obuf = ut_params->op->sym->m_dst;
2140 if (ut_params->obuf)
2141 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2144 ciphertext = plaintext;
2146 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2149 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2151 tdata->ciphertext.data,
2152 tdata->validCipherLenInBits.len,
2153 "KASUMI Ciphertext data not as expected");
2158 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2160 struct crypto_testsuite_params *ts_params = &testsuite_params;
2161 struct crypto_unittest_params *ut_params = &unittest_params;
2164 uint8_t *ciphertext, *plaintext;
2165 unsigned ciphertext_pad_len;
2166 unsigned ciphertext_len;
2168 /* Create KASUMI session */
2169 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2170 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2171 RTE_CRYPTO_CIPHER_KASUMI_F8,
2172 tdata->key.data, tdata->key.len);
2176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2177 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2179 /* Clear mbuf payload */
2180 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2181 rte_pktmbuf_tailroom(ut_params->ibuf));
2183 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2184 /* Append data which is padded to a multiple */
2185 /* of the algorithms block size */
2186 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2187 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2188 ciphertext_pad_len);
2189 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2190 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2192 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2194 /* Create KASUMI operation */
2195 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2197 tdata->ciphertext.len,
2198 tdata->validCipherOffsetLenInBits.len,
2199 RTE_CRYPTO_CIPHER_KASUMI_F8);
2203 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2207 ut_params->obuf = ut_params->op->sym->m_dst;
2208 if (ut_params->obuf)
2209 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2212 plaintext = ciphertext;
2214 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2217 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2219 tdata->plaintext.data,
2220 tdata->validCipherLenInBits.len,
2221 "KASUMI Plaintext data not as expected");
2226 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2228 struct crypto_testsuite_params *ts_params = &testsuite_params;
2229 struct crypto_unittest_params *ut_params = &unittest_params;
2232 uint8_t *ciphertext, *plaintext;
2233 unsigned ciphertext_pad_len;
2234 unsigned ciphertext_len;
2236 /* Create KASUMI session */
2237 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2238 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2239 RTE_CRYPTO_CIPHER_KASUMI_F8,
2240 tdata->key.data, tdata->key.len);
2244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2246 /* Clear mbuf payload */
2247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2248 rte_pktmbuf_tailroom(ut_params->ibuf));
2250 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2251 /* Append data which is padded to a multiple */
2252 /* of the algorithms block size */
2253 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2254 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2255 ciphertext_pad_len);
2256 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2258 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2260 /* Create KASUMI operation */
2261 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2263 tdata->ciphertext.len,
2264 tdata->validCipherOffsetLenInBits.len,
2265 RTE_CRYPTO_CIPHER_KASUMI_F8);
2269 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2271 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2273 ut_params->obuf = ut_params->op->sym->m_dst;
2274 if (ut_params->obuf)
2275 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2278 plaintext = ciphertext;
2280 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2285 tdata->plaintext.data,
2286 tdata->validCipherLenInBits.len,
2287 "KASUMI Plaintext data not as expected");
2292 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2294 struct crypto_testsuite_params *ts_params = &testsuite_params;
2295 struct crypto_unittest_params *ut_params = &unittest_params;
2298 uint8_t *plaintext, *ciphertext;
2299 unsigned plaintext_pad_len;
2300 unsigned plaintext_len;
2302 /* Create SNOW 3G session */
2303 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2304 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2305 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2306 tdata->key.data, tdata->key.len);
2310 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2312 /* Clear mbuf payload */
2313 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2314 rte_pktmbuf_tailroom(ut_params->ibuf));
2316 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2317 /* Append data which is padded to a multiple of */
2318 /* the algorithms block size */
2319 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2320 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2322 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2324 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2326 /* Create SNOW 3G operation */
2327 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2328 tdata->validCipherLenInBits.len,
2329 tdata->validCipherOffsetLenInBits.len,
2330 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2334 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2336 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2338 ut_params->obuf = ut_params->op->sym->m_dst;
2339 if (ut_params->obuf)
2340 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2343 ciphertext = plaintext;
2345 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2348 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2350 tdata->ciphertext.data,
2351 tdata->validDataLenInBits.len,
2352 "SNOW 3G Ciphertext data not as expected");
2358 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2360 struct crypto_testsuite_params *ts_params = &testsuite_params;
2361 struct crypto_unittest_params *ut_params = &unittest_params;
2362 uint8_t *plaintext, *ciphertext;
2365 unsigned plaintext_pad_len;
2366 unsigned plaintext_len;
2368 /* Create SNOW 3G session */
2369 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2370 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2371 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2372 tdata->key.data, tdata->key.len);
2376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2377 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2379 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2380 "Failed to allocate input buffer in mempool");
2381 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2382 "Failed to allocate output buffer in mempool");
2384 /* Clear mbuf payload */
2385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2386 rte_pktmbuf_tailroom(ut_params->ibuf));
2388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2389 /* Append data which is padded to a multiple of */
2390 /* the algorithms block size */
2391 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2392 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2394 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2395 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2397 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2399 /* Create SNOW 3G operation */
2400 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2402 tdata->validCipherLenInBits.len,
2403 tdata->validCipherOffsetLenInBits.len,
2404 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2408 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2410 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2412 ut_params->obuf = ut_params->op->sym->m_dst;
2413 if (ut_params->obuf)
2414 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2417 ciphertext = plaintext;
2419 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2424 tdata->ciphertext.data,
2425 tdata->validDataLenInBits.len,
2426 "SNOW 3G Ciphertext data not as expected");
2430 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2432 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2434 uint8_t curr_byte, prev_byte;
2435 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2436 uint8_t lower_byte_mask = (1 << offset) - 1;
2439 prev_byte = buffer[0];
2440 buffer[0] >>= offset;
2442 for (i = 1; i < length_in_bytes; i++) {
2443 curr_byte = buffer[i];
2444 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2445 (curr_byte >> offset);
2446 prev_byte = curr_byte;
2451 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2453 struct crypto_testsuite_params *ts_params = &testsuite_params;
2454 struct crypto_unittest_params *ut_params = &unittest_params;
2455 uint8_t *plaintext, *ciphertext;
2457 uint32_t plaintext_len;
2458 uint32_t plaintext_pad_len;
2459 uint8_t extra_offset = 4;
2460 uint8_t *expected_ciphertext_shifted;
2462 /* Create SNOW 3G session */
2463 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2464 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2465 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2466 tdata->key.data, tdata->key.len);
2470 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2471 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2473 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2474 "Failed to allocate input buffer in mempool");
2475 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2476 "Failed to allocate output buffer in mempool");
2478 /* Clear mbuf payload */
2479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2480 rte_pktmbuf_tailroom(ut_params->ibuf));
2482 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2484 * Append data which is padded to a
2485 * multiple of the algorithms block size
2487 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2489 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2492 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2494 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2495 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2497 #ifdef RTE_APP_TEST_DEBUG
2498 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2500 /* Create SNOW 3G operation */
2501 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2503 tdata->validCipherLenInBits.len,
2504 tdata->validCipherOffsetLenInBits.len +
2506 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2510 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2512 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2514 ut_params->obuf = ut_params->op->sym->m_dst;
2515 if (ut_params->obuf)
2516 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2519 ciphertext = plaintext;
2521 #ifdef RTE_APP_TEST_DEBUG
2522 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2525 expected_ciphertext_shifted = rte_malloc(NULL,
2526 ceil_byte_length(plaintext_len + extra_offset), 0);
2528 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2529 "failed to reserve memory for ciphertext shifted\n");
2531 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2532 ceil_byte_length(tdata->ciphertext.len));
2533 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2538 expected_ciphertext_shifted,
2539 tdata->validDataLenInBits.len,
2541 "SNOW 3G Ciphertext data not as expected");
2545 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2547 struct crypto_testsuite_params *ts_params = &testsuite_params;
2548 struct crypto_unittest_params *ut_params = &unittest_params;
2552 uint8_t *plaintext, *ciphertext;
2553 unsigned ciphertext_pad_len;
2554 unsigned ciphertext_len;
2556 /* Create SNOW 3G session */
2557 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2558 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2559 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2560 tdata->key.data, tdata->key.len);
2564 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2566 /* Clear mbuf payload */
2567 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2568 rte_pktmbuf_tailroom(ut_params->ibuf));
2570 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2571 /* Append data which is padded to a multiple of */
2572 /* the algorithms block size */
2573 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2574 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2575 ciphertext_pad_len);
2576 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2578 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2580 /* Create SNOW 3G operation */
2581 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2582 tdata->validCipherLenInBits.len,
2583 tdata->validCipherOffsetLenInBits.len,
2584 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2588 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2590 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2591 ut_params->obuf = ut_params->op->sym->m_dst;
2592 if (ut_params->obuf)
2593 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2596 plaintext = ciphertext;
2598 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2601 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
2602 tdata->plaintext.data,
2603 tdata->validDataLenInBits.len,
2604 "SNOW 3G Plaintext data not as expected");
2608 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
2610 struct crypto_testsuite_params *ts_params = &testsuite_params;
2611 struct crypto_unittest_params *ut_params = &unittest_params;
2615 uint8_t *plaintext, *ciphertext;
2616 unsigned ciphertext_pad_len;
2617 unsigned ciphertext_len;
2619 /* Create SNOW 3G session */
2620 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2621 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2622 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2623 tdata->key.data, tdata->key.len);
2627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2628 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2630 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2631 "Failed to allocate input buffer");
2632 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2633 "Failed to allocate output buffer");
2635 /* Clear mbuf payload */
2636 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2637 rte_pktmbuf_tailroom(ut_params->ibuf));
2639 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
2640 rte_pktmbuf_tailroom(ut_params->obuf));
2642 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2643 /* Append data which is padded to a multiple of */
2644 /* the algorithms block size */
2645 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2646 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2647 ciphertext_pad_len);
2648 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2649 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2651 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2653 /* Create SNOW 3G operation */
2654 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2656 tdata->validCipherLenInBits.len,
2657 tdata->validCipherOffsetLenInBits.len,
2658 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2662 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2665 ut_params->obuf = ut_params->op->sym->m_dst;
2666 if (ut_params->obuf)
2667 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2670 plaintext = ciphertext;
2672 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
2676 tdata->plaintext.data,
2677 tdata->validDataLenInBits.len,
2678 "SNOW 3G Plaintext data not as expected");
2683 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
2685 struct crypto_testsuite_params *ts_params = &testsuite_params;
2686 struct crypto_unittest_params *ut_params = &unittest_params;
2690 uint8_t *plaintext, *ciphertext;
2691 unsigned plaintext_pad_len;
2692 unsigned plaintext_len;
2694 /* Create SNOW 3G session */
2695 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
2696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2697 RTE_CRYPTO_AUTH_OP_GENERATE,
2698 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2699 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2700 tdata->key.data, tdata->key.len,
2701 tdata->aad.len, tdata->digest.len);
2704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2706 /* clear mbuf payload */
2707 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2708 rte_pktmbuf_tailroom(ut_params->ibuf));
2710 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2711 /* Append data which is padded to a multiple of */
2712 /* the algorithms block size */
2713 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2714 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2716 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2718 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2720 /* Create SNOW 3G operation */
2721 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
2722 tdata->digest.len, tdata->aad.data,
2723 tdata->aad.len, /*tdata->plaintext.len,*/
2724 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2725 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2726 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2727 tdata->iv.data, tdata->iv.len,
2728 tdata->validCipherLenInBits.len,
2729 tdata->validCipherOffsetLenInBits.len,
2730 tdata->validAuthLenInBits.len,
2731 tdata->validAuthOffsetLenInBits.len
2736 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2738 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2739 ut_params->obuf = ut_params->op->sym->m_src;
2740 if (ut_params->obuf)
2741 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2742 + tdata->iv.len + tdata->aad.len;
2744 ciphertext = plaintext;
2746 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2748 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2750 tdata->ciphertext.data,
2751 tdata->validDataLenInBits.len,
2752 "SNOW 3G Ciphertext data not as expected");
2754 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2755 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
2758 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2761 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2762 "SNOW 3G Generated auth tag not as expected");
2766 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
2768 struct crypto_testsuite_params *ts_params = &testsuite_params;
2769 struct crypto_unittest_params *ut_params = &unittest_params;
2773 uint8_t *plaintext, *ciphertext;
2774 unsigned plaintext_pad_len;
2775 unsigned plaintext_len;
2777 /* Create SNOW 3G session */
2778 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
2779 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2780 RTE_CRYPTO_AUTH_OP_GENERATE,
2781 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2782 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2783 tdata->key.data, tdata->key.len,
2784 tdata->aad.len, tdata->digest.len);
2788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2790 /* clear mbuf payload */
2791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2792 rte_pktmbuf_tailroom(ut_params->ibuf));
2794 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2795 /* Append data which is padded to a multiple of */
2796 /* the algorithms block size */
2797 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2798 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2800 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2802 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2804 /* Create SNOW 3G operation */
2805 retval = create_wireless_algo_auth_cipher_operation(
2807 tdata->iv.data, tdata->iv.len,
2808 tdata->aad.data, tdata->aad.len,
2810 tdata->validCipherLenInBits.len,
2811 tdata->validCipherOffsetLenInBits.len,
2812 tdata->validAuthLenInBits.len,
2813 tdata->validAuthOffsetLenInBits.len,
2814 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2815 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->obuf = ut_params->op->sym->m_src;
2825 if (ut_params->obuf)
2826 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2827 + tdata->aad.len + tdata->iv.len;
2829 ciphertext = plaintext;
2831 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2832 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
2833 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2836 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2838 tdata->ciphertext.data,
2839 tdata->validDataLenInBits.len,
2840 "SNOW 3G Ciphertext data not as expected");
2843 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2846 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2847 "SNOW 3G Generated auth tag not as expected");
2852 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
2854 struct crypto_testsuite_params *ts_params = &testsuite_params;
2855 struct crypto_unittest_params *ut_params = &unittest_params;
2859 uint8_t *plaintext, *ciphertext;
2860 unsigned plaintext_pad_len;
2861 unsigned plaintext_len;
2863 /* Create KASUMI session */
2864 retval = create_wireless_algo_auth_cipher_session(
2865 ts_params->valid_devs[0],
2866 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2867 RTE_CRYPTO_AUTH_OP_GENERATE,
2868 RTE_CRYPTO_AUTH_KASUMI_F9,
2869 RTE_CRYPTO_CIPHER_KASUMI_F8,
2870 tdata->key.data, tdata->key.len,
2871 tdata->aad.len, tdata->digest.len);
2874 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2876 /* clear mbuf payload */
2877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2878 rte_pktmbuf_tailroom(ut_params->ibuf));
2880 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2881 /* Append data which is padded to a multiple of */
2882 /* the algorithms block size */
2883 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2884 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2886 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2888 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2890 /* Create KASUMI operation */
2891 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
2892 tdata->iv.data, tdata->iv.len,
2893 tdata->aad.data, tdata->aad.len,
2895 tdata->validCipherLenInBits.len,
2896 tdata->validCipherOffsetLenInBits.len,
2897 tdata->validAuthLenInBits.len,
2898 tdata->validAuthOffsetLenInBits.len,
2899 RTE_CRYPTO_AUTH_KASUMI_F9,
2900 RTE_CRYPTO_CIPHER_KASUMI_F8
2906 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2908 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2909 ut_params->obuf = ut_params->op->sym->m_src;
2910 if (ut_params->obuf)
2911 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2912 + tdata->iv.len + tdata->aad.len;
2914 ciphertext = plaintext;
2917 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2919 tdata->ciphertext.data,
2920 tdata->validCipherLenInBits.len,
2921 "KASUMI Ciphertext data not as expected");
2922 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2923 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
2926 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2929 DIGEST_BYTE_LENGTH_KASUMI_F9,
2930 "KASUMI Generated auth tag not as expected");
2935 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
2937 struct crypto_testsuite_params *ts_params = &testsuite_params;
2938 struct crypto_unittest_params *ut_params = &unittest_params;
2942 uint8_t *plaintext, *ciphertext;
2943 unsigned plaintext_pad_len;
2944 unsigned plaintext_len;
2946 /* Create KASUMI session */
2947 retval = create_wireless_algo_cipher_auth_session(
2948 ts_params->valid_devs[0],
2949 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2950 RTE_CRYPTO_AUTH_OP_GENERATE,
2951 RTE_CRYPTO_AUTH_KASUMI_F9,
2952 RTE_CRYPTO_CIPHER_KASUMI_F8,
2953 tdata->key.data, tdata->key.len,
2954 tdata->aad.len, tdata->digest.len);
2958 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2960 /* clear mbuf payload */
2961 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2962 rte_pktmbuf_tailroom(ut_params->ibuf));
2964 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2965 /* Append data which is padded to a multiple of */
2966 /* the algorithms block size */
2967 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2968 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2970 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2972 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2974 /* Create KASUMI operation */
2975 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
2976 tdata->digest.len, tdata->aad.data,
2978 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2979 RTE_CRYPTO_AUTH_KASUMI_F9,
2980 RTE_CRYPTO_CIPHER_KASUMI_F8,
2981 tdata->iv.data, tdata->iv.len,
2982 tdata->validCipherLenInBits.len,
2983 tdata->validCipherOffsetLenInBits.len,
2984 tdata->validAuthLenInBits.len,
2985 tdata->validAuthOffsetLenInBits.len
2990 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2992 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2993 ut_params->obuf = ut_params->op->sym->m_src;
2994 if (ut_params->obuf)
2995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2996 + tdata->aad.len + tdata->iv.len;
2998 ciphertext = plaintext;
3000 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3001 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3006 tdata->ciphertext.data,
3007 tdata->validCipherLenInBits.len,
3008 "KASUMI Ciphertext data not as expected");
3011 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3014 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3015 "KASUMI Generated auth tag not as expected");
3020 test_kasumi_encryption_test_case_1(void)
3022 return test_kasumi_encryption(&kasumi_test_case_1);
3026 test_kasumi_encryption_test_case_1_oop(void)
3028 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3032 test_kasumi_encryption_test_case_2(void)
3034 return test_kasumi_encryption(&kasumi_test_case_2);
3038 test_kasumi_encryption_test_case_3(void)
3040 return test_kasumi_encryption(&kasumi_test_case_3);
3044 test_kasumi_encryption_test_case_4(void)
3046 return test_kasumi_encryption(&kasumi_test_case_4);
3050 test_kasumi_encryption_test_case_5(void)
3052 return test_kasumi_encryption(&kasumi_test_case_5);
3056 test_kasumi_decryption_test_case_1(void)
3058 return test_kasumi_decryption(&kasumi_test_case_1);
3062 test_kasumi_decryption_test_case_1_oop(void)
3064 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3068 test_kasumi_decryption_test_case_2(void)
3070 return test_kasumi_decryption(&kasumi_test_case_2);
3074 test_kasumi_decryption_test_case_3(void)
3076 return test_kasumi_decryption(&kasumi_test_case_3);
3080 test_kasumi_decryption_test_case_4(void)
3082 return test_kasumi_decryption(&kasumi_test_case_4);
3086 test_kasumi_decryption_test_case_5(void)
3088 return test_kasumi_decryption(&kasumi_test_case_5);
3091 test_snow3g_encryption_test_case_1(void)
3093 return test_snow3g_encryption(&snow3g_test_case_1);
3097 test_snow3g_encryption_test_case_1_oop(void)
3099 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3103 test_snow3g_encryption_test_case_1_offset_oop(void)
3105 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3109 test_snow3g_encryption_test_case_2(void)
3111 return test_snow3g_encryption(&snow3g_test_case_2);
3115 test_snow3g_encryption_test_case_3(void)
3117 return test_snow3g_encryption(&snow3g_test_case_3);
3121 test_snow3g_encryption_test_case_4(void)
3123 return test_snow3g_encryption(&snow3g_test_case_4);
3127 test_snow3g_encryption_test_case_5(void)
3129 return test_snow3g_encryption(&snow3g_test_case_5);
3133 test_snow3g_decryption_test_case_1(void)
3135 return test_snow3g_decryption(&snow3g_test_case_1);
3139 test_snow3g_decryption_test_case_1_oop(void)
3141 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3145 test_snow3g_decryption_test_case_2(void)
3147 return test_snow3g_decryption(&snow3g_test_case_2);
3151 test_snow3g_decryption_test_case_3(void)
3153 return test_snow3g_decryption(&snow3g_test_case_3);
3157 test_snow3g_decryption_test_case_4(void)
3159 return test_snow3g_decryption(&snow3g_test_case_4);
3163 test_snow3g_decryption_test_case_5(void)
3165 return test_snow3g_decryption(&snow3g_test_case_5);
3168 test_snow3g_cipher_auth_test_case_1(void)
3170 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3174 test_snow3g_auth_cipher_test_case_1(void)
3176 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3180 test_kasumi_auth_cipher_test_case_1(void)
3182 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3186 test_kasumi_cipher_auth_test_case_1(void)
3188 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3192 /* ***** AES-GCM Tests ***** */
3195 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3196 const uint8_t *key, const uint8_t key_len,
3197 const uint8_t aad_len, const uint8_t auth_len,
3198 enum rte_crypto_auth_operation auth_op)
3200 uint8_t cipher_key[key_len];
3202 struct crypto_unittest_params *ut_params = &unittest_params;
3204 memcpy(cipher_key, key, key_len);
3206 /* Setup Cipher Parameters */
3207 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3208 ut_params->cipher_xform.next = NULL;
3210 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3211 ut_params->auth_xform.auth.op = auth_op;
3212 ut_params->cipher_xform.cipher.op = op;
3213 ut_params->cipher_xform.cipher.key.data = cipher_key;
3214 ut_params->cipher_xform.cipher.key.length = key_len;
3216 TEST_HEXDUMP(stdout, "key:", key, key_len);
3218 /* Setup Authentication Parameters */
3219 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3220 ut_params->auth_xform.next = NULL;
3222 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3224 ut_params->auth_xform.auth.digest_length = auth_len;
3225 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3226 ut_params->auth_xform.auth.key.length = 0;
3227 ut_params->auth_xform.auth.key.data = NULL;
3229 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3230 ut_params->cipher_xform.next = &ut_params->auth_xform;
3232 /* Create Crypto session*/
3233 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3234 &ut_params->cipher_xform);
3235 } else {/* Create Crypto session*/
3236 ut_params->auth_xform.next = &ut_params->cipher_xform;
3237 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3238 &ut_params->auth_xform);
3241 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3247 create_gcm_operation(enum rte_crypto_cipher_operation op,
3248 const uint8_t *auth_tag, const unsigned auth_tag_len,
3249 const uint8_t *iv, const unsigned iv_len,
3250 const uint8_t *aad, const unsigned aad_len,
3251 const unsigned data_len, unsigned data_pad_len)
3253 struct crypto_testsuite_params *ts_params = &testsuite_params;
3254 struct crypto_unittest_params *ut_params = &unittest_params;
3256 unsigned iv_pad_len = 0, aad_buffer_len;
3258 /* Generate Crypto op data structure */
3259 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3260 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3261 TEST_ASSERT_NOT_NULL(ut_params->op,
3262 "Failed to allocate symmetric crypto operation struct");
3264 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3266 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3267 ut_params->ibuf, auth_tag_len);
3268 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3269 "no room to append digest");
3270 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3271 ut_params->ibuf, data_pad_len);
3272 sym_op->auth.digest.length = auth_tag_len;
3274 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3275 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3276 TEST_HEXDUMP(stdout, "digest:",
3277 sym_op->auth.digest.data,
3278 sym_op->auth.digest.length);
3282 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3284 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3285 ut_params->ibuf, iv_pad_len);
3286 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3288 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3289 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3290 sym_op->cipher.iv.length = iv_len;
3292 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3295 * Always allocate the aad up to the block size.
3296 * The cryptodev API calls out -
3297 * - the array must be big enough to hold the AAD, plus any
3298 * space to round this up to the nearest multiple of the
3299 * block size (16 bytes).
3301 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3303 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3304 ut_params->ibuf, aad_buffer_len);
3305 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3306 "no room to prepend aad");
3307 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3309 sym_op->auth.aad.length = aad_len;
3311 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3312 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3314 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3315 TEST_HEXDUMP(stdout, "aad:",
3316 sym_op->auth.aad.data, aad_len);
3318 sym_op->cipher.data.length = data_len;
3319 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3321 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3322 sym_op->auth.data.length = data_len;
3328 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3330 struct crypto_testsuite_params *ts_params = &testsuite_params;
3331 struct crypto_unittest_params *ut_params = &unittest_params;
3335 uint8_t *plaintext, *ciphertext, *auth_tag;
3336 uint16_t plaintext_pad_len;
3338 /* Create GCM session */
3339 retval = create_gcm_session(ts_params->valid_devs[0],
3340 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3341 tdata->key.data, tdata->key.len,
3342 tdata->aad.len, tdata->auth_tag.len,
3343 RTE_CRYPTO_AUTH_OP_GENERATE);
3348 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3350 /* clear mbuf payload */
3351 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3352 rte_pktmbuf_tailroom(ut_params->ibuf));
3355 * Append data which is padded to a multiple
3356 * of the algorithms block size
3358 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
3360 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3362 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
3364 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3366 /* Create GCM opertaion */
3367 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3368 tdata->auth_tag.data, tdata->auth_tag.len,
3369 tdata->iv.data, tdata->iv.len,
3370 tdata->aad.data, tdata->aad.len,
3371 tdata->plaintext.len, plaintext_pad_len);
3375 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3377 ut_params->op->sym->m_src = ut_params->ibuf;
3379 /* Process crypto operation */
3380 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3381 ut_params->op), "failed to process sym crypto op");
3383 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3384 "crypto op processing failed");
3386 if (ut_params->op->sym->m_dst) {
3387 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3389 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
3390 uint8_t *, plaintext_pad_len);
3392 ciphertext = plaintext;
3393 auth_tag = plaintext + plaintext_pad_len;
3396 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3397 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
3400 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3402 tdata->ciphertext.data,
3403 tdata->ciphertext.len,
3404 "GCM Ciphertext data not as expected");
3406 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3408 tdata->auth_tag.data,
3409 tdata->auth_tag.len,
3410 "GCM Generated auth tag not as expected");
3417 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
3419 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
3423 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
3425 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
3429 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
3431 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
3435 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
3437 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
3441 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
3443 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
3447 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
3449 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
3453 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
3455 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
3459 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
3461 struct crypto_testsuite_params *ts_params = &testsuite_params;
3462 struct crypto_unittest_params *ut_params = &unittest_params;
3466 uint8_t *plaintext, *ciphertext;
3467 uint16_t ciphertext_pad_len;
3469 /* Create GCM session */
3470 retval = create_gcm_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3472 tdata->key.data, tdata->key.len,
3473 tdata->aad.len, tdata->auth_tag.len,
3474 RTE_CRYPTO_AUTH_OP_VERIFY);
3479 /* alloc mbuf and set payload */
3480 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3482 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3483 rte_pktmbuf_tailroom(ut_params->ibuf));
3485 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
3487 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3488 ciphertext_pad_len);
3489 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
3491 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3493 /* Create GCM opertaion */
3494 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
3495 tdata->auth_tag.data, tdata->auth_tag.len,
3496 tdata->iv.data, tdata->iv.len,
3497 tdata->aad.data, tdata->aad.len,
3498 tdata->ciphertext.len, ciphertext_pad_len);
3503 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3505 ut_params->op->sym->m_src = ut_params->ibuf;
3507 /* Process crypto operation */
3508 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3509 ut_params->op), "failed to process sym crypto op");
3511 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3512 "crypto op processing failed");
3514 if (ut_params->op->sym->m_dst)
3515 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3518 plaintext = ciphertext;
3520 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
3523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3525 tdata->plaintext.data,
3526 tdata->plaintext.len,
3527 "GCM plaintext data not as expected");
3529 TEST_ASSERT_EQUAL(ut_params->op->status,
3530 RTE_CRYPTO_OP_STATUS_SUCCESS,
3531 "GCM authentication failed");
3536 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
3538 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
3542 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
3544 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
3548 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
3550 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
3554 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
3556 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
3560 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
3562 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
3566 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
3568 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
3572 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
3574 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
3580 struct crypto_testsuite_params *ts_params = &testsuite_params;
3581 struct rte_cryptodev_stats stats;
3582 struct rte_cryptodev *dev;
3583 cryptodev_stats_get_t temp_pfn;
3585 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3586 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
3587 &stats) == -ENODEV),
3588 "rte_cryptodev_stats_get invalid dev failed");
3589 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
3590 "rte_cryptodev_stats_get invalid Param failed");
3591 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
3592 temp_pfn = dev->dev_ops->stats_get;
3593 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
3594 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
3596 "rte_cryptodev_stats_get invalid Param failed");
3597 dev->dev_ops->stats_get = temp_pfn;
3599 /* Test expected values */
3601 test_AES_CBC_HMAC_SHA1_encrypt_digest();
3603 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3605 "rte_cryptodev_stats_get failed");
3606 TEST_ASSERT((stats.enqueued_count == 1),
3607 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3608 TEST_ASSERT((stats.dequeued_count == 1),
3609 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3610 TEST_ASSERT((stats.enqueue_err_count == 0),
3611 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3612 TEST_ASSERT((stats.dequeue_err_count == 0),
3613 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3615 /* invalid device but should ignore and not reset device stats*/
3616 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
3617 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3619 "rte_cryptodev_stats_get failed");
3620 TEST_ASSERT((stats.enqueued_count == 1),
3621 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3623 /* check that a valid reset clears stats */
3624 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3625 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3627 "rte_cryptodev_stats_get failed");
3628 TEST_ASSERT((stats.enqueued_count == 0),
3629 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3630 TEST_ASSERT((stats.dequeued_count == 0),
3631 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3633 return TEST_SUCCESS;
3636 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
3637 struct crypto_unittest_params *ut_params,
3638 enum rte_crypto_auth_operation op,
3639 const struct HMAC_MD5_vector *test_case)
3643 memcpy(key, test_case->key.data, test_case->key.len);
3645 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3646 ut_params->auth_xform.next = NULL;
3647 ut_params->auth_xform.auth.op = op;
3649 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
3651 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
3652 ut_params->auth_xform.auth.add_auth_data_length = 0;
3653 ut_params->auth_xform.auth.key.length = test_case->key.len;
3654 ut_params->auth_xform.auth.key.data = key;
3656 ut_params->sess = rte_cryptodev_sym_session_create(
3657 ts_params->valid_devs[0], &ut_params->auth_xform);
3659 if (ut_params->sess == NULL)
3662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3664 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3665 rte_pktmbuf_tailroom(ut_params->ibuf));
3670 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
3671 const struct HMAC_MD5_vector *test_case,
3672 uint8_t **plaintext)
3674 uint16_t plaintext_pad_len;
3676 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3678 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
3681 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3683 memcpy(*plaintext, test_case->plaintext.data,
3684 test_case->plaintext.len);
3686 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3687 ut_params->ibuf, MD5_DIGEST_LEN);
3688 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3689 "no room to append digest");
3690 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3691 ut_params->ibuf, plaintext_pad_len);
3692 sym_op->auth.digest.length = MD5_DIGEST_LEN;
3694 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
3695 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
3696 test_case->auth_tag.len);
3699 sym_op->auth.data.offset = 0;
3700 sym_op->auth.data.length = test_case->plaintext.len;
3702 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3703 ut_params->op->sym->m_src = ut_params->ibuf;
3709 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
3711 uint16_t plaintext_pad_len;
3712 uint8_t *plaintext, *auth_tag;
3714 struct crypto_testsuite_params *ts_params = &testsuite_params;
3715 struct crypto_unittest_params *ut_params = &unittest_params;
3717 if (MD5_HMAC_create_session(ts_params, ut_params,
3718 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
3721 /* Generate Crypto op data structure */
3722 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3723 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3724 TEST_ASSERT_NOT_NULL(ut_params->op,
3725 "Failed to allocate symmetric crypto operation struct");
3727 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
3730 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
3733 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3734 ut_params->op), "failed to process sym crypto op");
3736 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3737 "crypto op processing failed");
3739 if (ut_params->op->sym->m_dst) {
3740 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
3741 uint8_t *, plaintext_pad_len);
3743 auth_tag = plaintext + plaintext_pad_len;
3746 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3748 test_case->auth_tag.data,
3749 test_case->auth_tag.len,
3750 "HMAC_MD5 generated tag not as expected");
3752 return TEST_SUCCESS;
3756 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
3760 struct crypto_testsuite_params *ts_params = &testsuite_params;
3761 struct crypto_unittest_params *ut_params = &unittest_params;
3763 if (MD5_HMAC_create_session(ts_params, ut_params,
3764 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
3768 /* Generate Crypto op data structure */
3769 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3770 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3771 TEST_ASSERT_NOT_NULL(ut_params->op,
3772 "Failed to allocate symmetric crypto operation struct");
3774 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
3777 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3778 ut_params->op), "failed to process sym crypto op");
3780 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3781 "HMAC_MD5 crypto op processing failed");
3783 return TEST_SUCCESS;
3787 test_MD5_HMAC_generate_case_1(void)
3789 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
3793 test_MD5_HMAC_verify_case_1(void)
3795 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
3799 test_MD5_HMAC_generate_case_2(void)
3801 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
3805 test_MD5_HMAC_verify_case_2(void)
3807 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
3811 test_multi_session(void)
3813 struct crypto_testsuite_params *ts_params = &testsuite_params;
3814 struct crypto_unittest_params *ut_params = &unittest_params;
3816 struct rte_cryptodev_info dev_info;
3817 struct rte_cryptodev_sym_session **sessions;
3821 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params);
3824 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3826 sessions = rte_malloc(NULL,
3827 (sizeof(struct rte_cryptodev_sym_session *) *
3828 dev_info.sym.max_nb_sessions) + 1, 0);
3830 /* Create multiple crypto sessions*/
3831 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
3832 sessions[i] = rte_cryptodev_sym_session_create(
3833 ts_params->valid_devs[0],
3834 &ut_params->auth_xform);
3835 TEST_ASSERT_NOT_NULL(sessions[i],
3836 "Session creation failed at session number %u",
3839 /* Attempt to send a request on each session */
3840 TEST_ASSERT_SUCCESS(test_AES_CBC_HMAC_SHA512_decrypt_perform(
3841 sessions[i], ut_params, ts_params),
3842 "Failed to perform decrypt on request "
3844 /* free crypto operation structure */
3846 rte_crypto_op_free(ut_params->op);
3849 * free mbuf - both obuf and ibuf are usually the same,
3850 * so check if they point at the same address is necessary,
3851 * to avoid freeing the mbuf twice.
3853 if (ut_params->obuf) {
3854 rte_pktmbuf_free(ut_params->obuf);
3855 if (ut_params->ibuf == ut_params->obuf)
3856 ut_params->ibuf = 0;
3857 ut_params->obuf = 0;
3859 if (ut_params->ibuf) {
3860 rte_pktmbuf_free(ut_params->ibuf);
3861 ut_params->ibuf = 0;
3865 /* Next session create should fail */
3866 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
3867 &ut_params->auth_xform);
3868 TEST_ASSERT_NULL(sessions[i],
3869 "Session creation succeeded unexpectedly!");
3871 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
3872 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
3877 return TEST_SUCCESS;
3881 test_null_cipher_only_operation(void)
3883 struct crypto_testsuite_params *ts_params = &testsuite_params;
3884 struct crypto_unittest_params *ut_params = &unittest_params;
3886 /* Generate test mbuf data and space for digest */
3887 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3888 catch_22_quote, QUOTE_512_BYTES, 0);
3890 /* Setup Cipher Parameters */
3891 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3892 ut_params->cipher_xform.next = NULL;
3894 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3895 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3897 /* Create Crypto session*/
3898 ut_params->sess = rte_cryptodev_sym_session_create(
3899 ts_params->valid_devs[0], &ut_params->cipher_xform);
3900 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3902 /* Generate Crypto op data structure */
3903 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3904 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3905 TEST_ASSERT_NOT_NULL(ut_params->op,
3906 "Failed to allocate symmetric crypto operation struct");
3908 /* Set crypto operation data parameters */
3909 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3911 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3913 /* set crypto operation source mbuf */
3914 sym_op->m_src = ut_params->ibuf;
3916 sym_op->cipher.data.offset = 0;
3917 sym_op->cipher.data.length = QUOTE_512_BYTES;
3919 /* Process crypto operation */
3920 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3922 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3924 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3925 "crypto operation processing failed");
3928 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3929 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3932 "Ciphertext data not as expected");
3934 return TEST_SUCCESS;
3938 test_null_auth_only_operation(void)
3940 struct crypto_testsuite_params *ts_params = &testsuite_params;
3941 struct crypto_unittest_params *ut_params = &unittest_params;
3943 /* Generate test mbuf data and space for digest */
3944 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3945 catch_22_quote, QUOTE_512_BYTES, 0);
3947 /* Setup HMAC Parameters */
3948 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3949 ut_params->auth_xform.next = NULL;
3951 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3952 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3954 /* Create Crypto session*/
3955 ut_params->sess = rte_cryptodev_sym_session_create(
3956 ts_params->valid_devs[0], &ut_params->auth_xform);
3957 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3959 /* Generate Crypto op data structure */
3960 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3961 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3962 TEST_ASSERT_NOT_NULL(ut_params->op,
3963 "Failed to allocate symmetric crypto operation struct");
3965 /* Set crypto operation data parameters */
3966 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3968 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3970 sym_op->m_src = ut_params->ibuf;
3972 sym_op->auth.data.offset = 0;
3973 sym_op->auth.data.length = QUOTE_512_BYTES;
3975 /* Process crypto operation */
3976 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3978 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3980 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3981 "crypto operation processing failed");
3983 return TEST_SUCCESS;
3987 test_null_cipher_auth_operation(void)
3989 struct crypto_testsuite_params *ts_params = &testsuite_params;
3990 struct crypto_unittest_params *ut_params = &unittest_params;
3992 /* Generate test mbuf data and space for digest */
3993 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3994 catch_22_quote, QUOTE_512_BYTES, 0);
3996 /* Setup Cipher Parameters */
3997 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3998 ut_params->cipher_xform.next = &ut_params->auth_xform;
4000 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4001 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4003 /* Setup HMAC Parameters */
4004 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4005 ut_params->auth_xform.next = NULL;
4007 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4008 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4010 /* Create Crypto session*/
4011 ut_params->sess = rte_cryptodev_sym_session_create(
4012 ts_params->valid_devs[0], &ut_params->cipher_xform);
4013 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4015 /* Generate Crypto op data structure */
4016 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4017 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4018 TEST_ASSERT_NOT_NULL(ut_params->op,
4019 "Failed to allocate symmetric crypto operation struct");
4021 /* Set crypto operation data parameters */
4022 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4024 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4026 sym_op->m_src = ut_params->ibuf;
4028 sym_op->cipher.data.offset = 0;
4029 sym_op->cipher.data.length = QUOTE_512_BYTES;
4031 sym_op->auth.data.offset = 0;
4032 sym_op->auth.data.length = QUOTE_512_BYTES;
4034 /* Process crypto operation */
4035 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4037 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4039 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4040 "crypto operation processing failed");
4043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4044 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4047 "Ciphertext data not as expected");
4049 return TEST_SUCCESS;
4053 test_null_auth_cipher_operation(void)
4055 struct crypto_testsuite_params *ts_params = &testsuite_params;
4056 struct crypto_unittest_params *ut_params = &unittest_params;
4058 /* Generate test mbuf data and space for digest */
4059 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4060 catch_22_quote, QUOTE_512_BYTES, 0);
4062 /* Setup Cipher Parameters */
4063 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4064 ut_params->cipher_xform.next = NULL;
4066 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4067 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4069 /* Setup HMAC Parameters */
4070 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4071 ut_params->auth_xform.next = &ut_params->cipher_xform;
4073 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4074 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4076 /* Create Crypto session*/
4077 ut_params->sess = rte_cryptodev_sym_session_create(
4078 ts_params->valid_devs[0], &ut_params->cipher_xform);
4079 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4081 /* Generate Crypto op data structure */
4082 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4083 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4084 TEST_ASSERT_NOT_NULL(ut_params->op,
4085 "Failed to allocate symmetric crypto operation struct");
4087 /* Set crypto operation data parameters */
4088 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4090 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4092 sym_op->m_src = ut_params->ibuf;
4094 sym_op->cipher.data.offset = 0;
4095 sym_op->cipher.data.length = QUOTE_512_BYTES;
4097 sym_op->auth.data.offset = 0;
4098 sym_op->auth.data.length = QUOTE_512_BYTES;
4100 /* Process crypto operation */
4101 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4103 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4105 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4106 "crypto operation processing failed");
4109 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4110 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4113 "Ciphertext data not as expected");
4115 return TEST_SUCCESS;
4120 test_null_invalid_operation(void)
4122 struct crypto_testsuite_params *ts_params = &testsuite_params;
4123 struct crypto_unittest_params *ut_params = &unittest_params;
4125 /* Setup Cipher Parameters */
4126 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4127 ut_params->cipher_xform.next = NULL;
4129 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4130 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4132 /* Create Crypto session*/
4133 ut_params->sess = rte_cryptodev_sym_session_create(
4134 ts_params->valid_devs[0], &ut_params->cipher_xform);
4135 TEST_ASSERT_NULL(ut_params->sess,
4136 "Session creation succeeded unexpectedly");
4139 /* Setup HMAC Parameters */
4140 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4141 ut_params->auth_xform.next = NULL;
4143 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4144 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4146 /* Create Crypto session*/
4147 ut_params->sess = rte_cryptodev_sym_session_create(
4148 ts_params->valid_devs[0], &ut_params->auth_xform);
4149 TEST_ASSERT_NULL(ut_params->sess,
4150 "Session creation succeeded unexpectedly");
4152 return TEST_SUCCESS;
4156 #define NULL_BURST_LENGTH (32)
4159 test_null_burst_operation(void)
4161 struct crypto_testsuite_params *ts_params = &testsuite_params;
4162 struct crypto_unittest_params *ut_params = &unittest_params;
4164 unsigned i, burst_len = NULL_BURST_LENGTH;
4166 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4167 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4169 /* Setup Cipher Parameters */
4170 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4171 ut_params->cipher_xform.next = &ut_params->auth_xform;
4173 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4174 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4176 /* Setup HMAC Parameters */
4177 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4178 ut_params->auth_xform.next = NULL;
4180 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4181 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4183 /* Create Crypto session*/
4184 ut_params->sess = rte_cryptodev_sym_session_create(
4185 ts_params->valid_devs[0], &ut_params->cipher_xform);
4186 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4188 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4189 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4190 burst_len, "failed to generate burst of crypto ops");
4192 /* Generate an operation for each mbuf in burst */
4193 for (i = 0; i < burst_len; i++) {
4194 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4196 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
4198 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
4202 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
4204 burst[i]->sym->m_src = m;
4207 /* Process crypto operation */
4208 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
4209 0, burst, burst_len),
4211 "Error enqueuing burst");
4213 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
4214 0, burst_dequeued, burst_len),
4216 "Error dequeuing burst");
4219 for (i = 0; i < burst_len; i++) {
4221 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
4222 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
4224 "data not as expected");
4226 rte_pktmbuf_free(burst[i]->sym->m_src);
4227 rte_crypto_op_free(burst[i]);
4230 return TEST_SUCCESS;
4234 create_gmac_operation(enum rte_crypto_auth_operation op,
4235 const struct gmac_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4239 struct rte_crypto_sym_op *sym_op;
4241 unsigned iv_pad_len;
4242 unsigned aad_pad_len;
4244 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4245 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4247 /* Generate Crypto op data structure */
4248 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4249 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4250 TEST_ASSERT_NOT_NULL(ut_params->op,
4251 "Failed to allocate symmetric crypto operation struct");
4253 sym_op = ut_params->op->sym;
4254 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4256 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4257 "no room to append aad");
4259 sym_op->auth.aad.length = tdata->aad.len;
4260 sym_op->auth.aad.phys_addr =
4261 rte_pktmbuf_mtophys(ut_params->ibuf);
4262 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4264 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4265 ut_params->ibuf, tdata->gmac_tag.len);
4266 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4267 "no room to append digest");
4269 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4270 ut_params->ibuf, aad_pad_len);
4271 sym_op->auth.digest.length = tdata->gmac_tag.len;
4273 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4274 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
4275 tdata->gmac_tag.len);
4276 TEST_HEXDUMP(stdout, "digest:",
4277 sym_op->auth.digest.data,
4278 sym_op->auth.digest.length);
4281 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4282 ut_params->ibuf, iv_pad_len);
4283 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4285 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4286 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4287 sym_op->cipher.iv.length = tdata->iv.len;
4289 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4291 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
4293 sym_op->cipher.data.length = 0;
4294 sym_op->cipher.data.offset = 0;
4296 sym_op->auth.data.offset = 0;
4297 sym_op->auth.data.length = 0;
4302 static int create_gmac_session(uint8_t dev_id,
4303 enum rte_crypto_cipher_operation op,
4304 const struct gmac_test_data *tdata,
4305 enum rte_crypto_auth_operation auth_op)
4307 uint8_t cipher_key[tdata->key.len];
4309 struct crypto_unittest_params *ut_params = &unittest_params;
4311 memcpy(cipher_key, tdata->key.data, tdata->key.len);
4313 /* For GMAC we setup cipher parameters */
4314 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4315 ut_params->cipher_xform.next = NULL;
4316 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4317 ut_params->cipher_xform.cipher.op = op;
4318 ut_params->cipher_xform.cipher.key.data = cipher_key;
4319 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
4321 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4322 ut_params->auth_xform.next = NULL;
4324 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
4325 ut_params->auth_xform.auth.op = auth_op;
4326 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
4327 ut_params->auth_xform.auth.add_auth_data_length = 0;
4328 ut_params->auth_xform.auth.key.length = 0;
4329 ut_params->auth_xform.auth.key.data = NULL;
4331 ut_params->cipher_xform.next = &ut_params->auth_xform;
4333 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4334 &ut_params->cipher_xform);
4336 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4342 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
4344 struct crypto_testsuite_params *ts_params = &testsuite_params;
4345 struct crypto_unittest_params *ut_params = &unittest_params;
4349 uint8_t *auth_tag, *p;
4350 uint16_t aad_pad_len;
4352 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
4353 "No GMAC length in the source data");
4355 retval = create_gmac_session(ts_params->valid_devs[0],
4356 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4357 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
4362 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4364 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4365 rte_pktmbuf_tailroom(ut_params->ibuf));
4367 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4369 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
4371 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
4377 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4379 ut_params->op->sym->m_src = ut_params->ibuf;
4381 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4382 ut_params->op), "failed to process sym crypto op");
4384 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4385 "crypto op processing failed");
4387 if (ut_params->op->sym->m_dst) {
4388 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4389 uint8_t *, aad_pad_len);
4391 auth_tag = p + aad_pad_len;
4394 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
4396 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4398 tdata->gmac_tag.data,
4399 tdata->gmac_tag.len,
4400 "GMAC Generated auth tag not as expected");
4406 test_AES_GMAC_authentication_test_case_1(void)
4408 return test_AES_GMAC_authentication(&gmac_test_case_1);
4412 test_AES_GMAC_authentication_test_case_2(void)
4414 return test_AES_GMAC_authentication(&gmac_test_case_2);
4418 test_AES_GMAC_authentication_test_case_3(void)
4420 return test_AES_GMAC_authentication(&gmac_test_case_3);
4424 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
4426 struct crypto_testsuite_params *ts_params = &testsuite_params;
4427 struct crypto_unittest_params *ut_params = &unittest_params;
4430 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
4431 "No GMAC length in the source data");
4433 retval = create_gmac_session(ts_params->valid_devs[0],
4434 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4435 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
4440 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4442 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4443 rte_pktmbuf_tailroom(ut_params->ibuf));
4445 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
4451 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4453 ut_params->op->sym->m_src = ut_params->ibuf;
4455 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4456 ut_params->op), "failed to process sym crypto op");
4458 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4459 "crypto op processing failed");
4466 test_AES_GMAC_authentication_verify_test_case_1(void)
4468 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
4472 test_AES_GMAC_authentication_verify_test_case_2(void)
4474 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
4478 test_AES_GMAC_authentication_verify_test_case_3(void)
4480 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
4483 static struct unit_test_suite cryptodev_qat_testsuite = {
4484 .suite_name = "Crypto QAT Unit Test Suite",
4485 .setup = testsuite_setup,
4486 .teardown = testsuite_teardown,
4487 .unit_test_cases = {
4488 TEST_CASE_ST(ut_setup, ut_teardown,
4489 test_device_configure_invalid_dev_id),
4490 TEST_CASE_ST(ut_setup, ut_teardown,
4491 test_device_configure_invalid_queue_pair_ids),
4492 TEST_CASE_ST(ut_setup, ut_teardown,
4493 test_queue_pair_descriptor_setup),
4494 TEST_CASE_ST(ut_setup, ut_teardown,
4495 test_multi_session),
4497 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_qat_all),
4498 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
4500 /** AES GCM Authenticated Encryption */
4501 TEST_CASE_ST(ut_setup, ut_teardown,
4502 test_mb_AES_GCM_authenticated_encryption_test_case_1),
4503 TEST_CASE_ST(ut_setup, ut_teardown,
4504 test_mb_AES_GCM_authenticated_encryption_test_case_2),
4505 TEST_CASE_ST(ut_setup, ut_teardown,
4506 test_mb_AES_GCM_authenticated_encryption_test_case_3),
4507 TEST_CASE_ST(ut_setup, ut_teardown,
4508 test_mb_AES_GCM_authenticated_encryption_test_case_4),
4509 TEST_CASE_ST(ut_setup, ut_teardown,
4510 test_mb_AES_GCM_authenticated_encryption_test_case_5),
4511 TEST_CASE_ST(ut_setup, ut_teardown,
4512 test_mb_AES_GCM_authenticated_encryption_test_case_6),
4513 TEST_CASE_ST(ut_setup, ut_teardown,
4514 test_mb_AES_GCM_authenticated_encryption_test_case_7),
4516 /** AES GCM Authenticated Decryption */
4517 TEST_CASE_ST(ut_setup, ut_teardown,
4518 test_mb_AES_GCM_authenticated_decryption_test_case_1),
4519 TEST_CASE_ST(ut_setup, ut_teardown,
4520 test_mb_AES_GCM_authenticated_decryption_test_case_2),
4521 TEST_CASE_ST(ut_setup, ut_teardown,
4522 test_mb_AES_GCM_authenticated_decryption_test_case_3),
4523 TEST_CASE_ST(ut_setup, ut_teardown,
4524 test_mb_AES_GCM_authenticated_decryption_test_case_4),
4525 TEST_CASE_ST(ut_setup, ut_teardown,
4526 test_mb_AES_GCM_authenticated_decryption_test_case_5),
4527 TEST_CASE_ST(ut_setup, ut_teardown,
4528 test_mb_AES_GCM_authenticated_decryption_test_case_6),
4529 TEST_CASE_ST(ut_setup, ut_teardown,
4530 test_mb_AES_GCM_authenticated_decryption_test_case_7),
4532 /** AES GMAC Authentication */
4533 TEST_CASE_ST(ut_setup, ut_teardown,
4534 test_AES_GMAC_authentication_test_case_1),
4535 TEST_CASE_ST(ut_setup, ut_teardown,
4536 test_AES_GMAC_authentication_verify_test_case_1),
4537 TEST_CASE_ST(ut_setup, ut_teardown,
4538 test_AES_GMAC_authentication_test_case_2),
4539 TEST_CASE_ST(ut_setup, ut_teardown,
4540 test_AES_GMAC_authentication_verify_test_case_2),
4541 TEST_CASE_ST(ut_setup, ut_teardown,
4542 test_AES_GMAC_authentication_test_case_3),
4543 TEST_CASE_ST(ut_setup, ut_teardown,
4544 test_AES_GMAC_authentication_verify_test_case_3),
4546 /** SNOW 3G encrypt only (UEA2) */
4547 TEST_CASE_ST(ut_setup, ut_teardown,
4548 test_snow3g_encryption_test_case_1),
4549 TEST_CASE_ST(ut_setup, ut_teardown,
4550 test_snow3g_encryption_test_case_2),
4551 TEST_CASE_ST(ut_setup, ut_teardown,
4552 test_snow3g_encryption_test_case_3),
4553 TEST_CASE_ST(ut_setup, ut_teardown,
4554 test_snow3g_encryption_test_case_4),
4555 TEST_CASE_ST(ut_setup, ut_teardown,
4556 test_snow3g_encryption_test_case_5),
4558 TEST_CASE_ST(ut_setup, ut_teardown,
4559 test_snow3g_encryption_test_case_1_oop),
4560 TEST_CASE_ST(ut_setup, ut_teardown,
4561 test_snow3g_decryption_test_case_1_oop),
4563 /** SNOW 3G decrypt only (UEA2) */
4564 TEST_CASE_ST(ut_setup, ut_teardown,
4565 test_snow3g_decryption_test_case_1),
4566 TEST_CASE_ST(ut_setup, ut_teardown,
4567 test_snow3g_decryption_test_case_2),
4568 TEST_CASE_ST(ut_setup, ut_teardown,
4569 test_snow3g_decryption_test_case_3),
4570 TEST_CASE_ST(ut_setup, ut_teardown,
4571 test_snow3g_decryption_test_case_4),
4572 TEST_CASE_ST(ut_setup, ut_teardown,
4573 test_snow3g_decryption_test_case_5),
4574 TEST_CASE_ST(ut_setup, ut_teardown,
4575 test_snow3g_hash_generate_test_case_1),
4576 TEST_CASE_ST(ut_setup, ut_teardown,
4577 test_snow3g_hash_generate_test_case_2),
4578 TEST_CASE_ST(ut_setup, ut_teardown,
4579 test_snow3g_hash_generate_test_case_3),
4580 TEST_CASE_ST(ut_setup, ut_teardown,
4581 test_snow3g_hash_verify_test_case_1),
4582 TEST_CASE_ST(ut_setup, ut_teardown,
4583 test_snow3g_hash_verify_test_case_2),
4584 TEST_CASE_ST(ut_setup, ut_teardown,
4585 test_snow3g_hash_verify_test_case_3),
4586 TEST_CASE_ST(ut_setup, ut_teardown,
4587 test_snow3g_cipher_auth_test_case_1),
4588 TEST_CASE_ST(ut_setup, ut_teardown,
4589 test_snow3g_auth_cipher_test_case_1),
4591 /** HMAC_MD5 Authentication */
4592 TEST_CASE_ST(ut_setup, ut_teardown,
4593 test_MD5_HMAC_generate_case_1),
4594 TEST_CASE_ST(ut_setup, ut_teardown,
4595 test_MD5_HMAC_verify_case_1),
4596 TEST_CASE_ST(ut_setup, ut_teardown,
4597 test_MD5_HMAC_generate_case_2),
4598 TEST_CASE_ST(ut_setup, ut_teardown,
4599 test_MD5_HMAC_verify_case_2),
4602 TEST_CASE_ST(ut_setup, ut_teardown,
4603 test_null_auth_only_operation),
4604 TEST_CASE_ST(ut_setup, ut_teardown,
4605 test_null_cipher_only_operation),
4606 TEST_CASE_ST(ut_setup, ut_teardown,
4607 test_null_cipher_auth_operation),
4608 TEST_CASE_ST(ut_setup, ut_teardown,
4609 test_null_auth_cipher_operation),
4611 TEST_CASE_ST(ut_setup, ut_teardown,
4612 test_kasumi_hash_generate_test_case_6),
4615 TEST_CASE_ST(ut_setup, ut_teardown,
4616 test_kasumi_encryption_test_case_1),
4617 TEST_CASE_ST(ut_setup, ut_teardown,
4618 test_kasumi_encryption_test_case_3),
4619 TEST_CASE_ST(ut_setup, ut_teardown,
4620 test_kasumi_auth_cipher_test_case_1),
4621 TEST_CASE_ST(ut_setup, ut_teardown,
4622 test_kasumi_cipher_auth_test_case_1),
4624 TEST_CASES_END() /**< NULL terminate unit test array */
4628 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
4629 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
4630 .setup = testsuite_setup,
4631 .teardown = testsuite_teardown,
4632 .unit_test_cases = {
4633 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_mb_all),
4635 TEST_CASES_END() /**< NULL terminate unit test array */
4639 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
4640 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
4641 .setup = testsuite_setup,
4642 .teardown = testsuite_teardown,
4643 .unit_test_cases = {
4644 /** AES GCM Authenticated Encryption */
4645 TEST_CASE_ST(ut_setup, ut_teardown,
4646 test_mb_AES_GCM_authenticated_encryption_test_case_1),
4647 TEST_CASE_ST(ut_setup, ut_teardown,
4648 test_mb_AES_GCM_authenticated_encryption_test_case_2),
4649 TEST_CASE_ST(ut_setup, ut_teardown,
4650 test_mb_AES_GCM_authenticated_encryption_test_case_3),
4651 TEST_CASE_ST(ut_setup, ut_teardown,
4652 test_mb_AES_GCM_authenticated_encryption_test_case_4),
4653 TEST_CASE_ST(ut_setup, ut_teardown,
4654 test_mb_AES_GCM_authenticated_encryption_test_case_5),
4655 TEST_CASE_ST(ut_setup, ut_teardown,
4656 test_mb_AES_GCM_authenticated_encryption_test_case_6),
4657 TEST_CASE_ST(ut_setup, ut_teardown,
4658 test_mb_AES_GCM_authenticated_encryption_test_case_7),
4660 /** AES GCM Authenticated Decryption */
4661 TEST_CASE_ST(ut_setup, ut_teardown,
4662 test_mb_AES_GCM_authenticated_decryption_test_case_1),
4663 TEST_CASE_ST(ut_setup, ut_teardown,
4664 test_mb_AES_GCM_authenticated_decryption_test_case_2),
4665 TEST_CASE_ST(ut_setup, ut_teardown,
4666 test_mb_AES_GCM_authenticated_decryption_test_case_3),
4667 TEST_CASE_ST(ut_setup, ut_teardown,
4668 test_mb_AES_GCM_authenticated_decryption_test_case_4),
4669 TEST_CASE_ST(ut_setup, ut_teardown,
4670 test_mb_AES_GCM_authenticated_decryption_test_case_5),
4671 TEST_CASE_ST(ut_setup, ut_teardown,
4672 test_mb_AES_GCM_authenticated_decryption_test_case_6),
4673 TEST_CASE_ST(ut_setup, ut_teardown,
4674 test_mb_AES_GCM_authenticated_decryption_test_case_7),
4676 TEST_CASES_END() /**< NULL terminate unit test array */
4680 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
4681 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
4682 .setup = testsuite_setup,
4683 .teardown = testsuite_teardown,
4684 .unit_test_cases = {
4685 /** KASUMI encrypt only (UEA1) */
4686 TEST_CASE_ST(ut_setup, ut_teardown,
4687 test_kasumi_encryption_test_case_1),
4688 TEST_CASE_ST(ut_setup, ut_teardown,
4689 test_kasumi_encryption_test_case_2),
4690 TEST_CASE_ST(ut_setup, ut_teardown,
4691 test_kasumi_encryption_test_case_3),
4692 TEST_CASE_ST(ut_setup, ut_teardown,
4693 test_kasumi_encryption_test_case_4),
4694 TEST_CASE_ST(ut_setup, ut_teardown,
4695 test_kasumi_encryption_test_case_5),
4696 /** KASUMI decrypt only (UEA1) */
4697 TEST_CASE_ST(ut_setup, ut_teardown,
4698 test_kasumi_decryption_test_case_1),
4699 TEST_CASE_ST(ut_setup, ut_teardown,
4700 test_kasumi_decryption_test_case_2),
4701 TEST_CASE_ST(ut_setup, ut_teardown,
4702 test_kasumi_decryption_test_case_3),
4703 TEST_CASE_ST(ut_setup, ut_teardown,
4704 test_kasumi_decryption_test_case_4),
4705 TEST_CASE_ST(ut_setup, ut_teardown,
4706 test_kasumi_decryption_test_case_5),
4708 TEST_CASE_ST(ut_setup, ut_teardown,
4709 test_kasumi_encryption_test_case_1_oop),
4710 TEST_CASE_ST(ut_setup, ut_teardown,
4711 test_kasumi_decryption_test_case_1_oop),
4713 /** KASUMI hash only (UIA1) */
4714 TEST_CASE_ST(ut_setup, ut_teardown,
4715 test_kasumi_hash_generate_test_case_1),
4716 TEST_CASE_ST(ut_setup, ut_teardown,
4717 test_kasumi_hash_generate_test_case_2),
4718 TEST_CASE_ST(ut_setup, ut_teardown,
4719 test_kasumi_hash_generate_test_case_3),
4720 TEST_CASE_ST(ut_setup, ut_teardown,
4721 test_kasumi_hash_generate_test_case_4),
4722 TEST_CASE_ST(ut_setup, ut_teardown,
4723 test_kasumi_hash_generate_test_case_5),
4724 TEST_CASE_ST(ut_setup, ut_teardown,
4725 test_kasumi_hash_generate_test_case_6),
4726 TEST_CASE_ST(ut_setup, ut_teardown,
4727 test_kasumi_hash_verify_test_case_1),
4728 TEST_CASE_ST(ut_setup, ut_teardown,
4729 test_kasumi_hash_verify_test_case_2),
4730 TEST_CASE_ST(ut_setup, ut_teardown,
4731 test_kasumi_hash_verify_test_case_3),
4732 TEST_CASE_ST(ut_setup, ut_teardown,
4733 test_kasumi_hash_verify_test_case_4),
4734 TEST_CASE_ST(ut_setup, ut_teardown,
4735 test_kasumi_hash_verify_test_case_5),
4736 TEST_CASE_ST(ut_setup, ut_teardown,
4737 test_kasumi_auth_cipher_test_case_1),
4738 TEST_CASE_ST(ut_setup, ut_teardown,
4739 test_kasumi_cipher_auth_test_case_1),
4740 TEST_CASES_END() /**< NULL terminate unit test array */
4743 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
4744 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
4745 .setup = testsuite_setup,
4746 .teardown = testsuite_teardown,
4747 .unit_test_cases = {
4748 /** SNOW 3G encrypt only (UEA2) */
4749 TEST_CASE_ST(ut_setup, ut_teardown,
4750 test_snow3g_encryption_test_case_1),
4751 TEST_CASE_ST(ut_setup, ut_teardown,
4752 test_snow3g_encryption_test_case_2),
4753 TEST_CASE_ST(ut_setup, ut_teardown,
4754 test_snow3g_encryption_test_case_3),
4755 TEST_CASE_ST(ut_setup, ut_teardown,
4756 test_snow3g_encryption_test_case_4),
4757 TEST_CASE_ST(ut_setup, ut_teardown,
4758 test_snow3g_encryption_test_case_5),
4760 TEST_CASE_ST(ut_setup, ut_teardown,
4761 test_snow3g_encryption_test_case_1_oop),
4762 TEST_CASE_ST(ut_setup, ut_teardown,
4763 test_snow3g_decryption_test_case_1_oop),
4765 TEST_CASE_ST(ut_setup, ut_teardown,
4766 test_snow3g_encryption_test_case_1_offset_oop),
4768 /** SNOW 3G decrypt only (UEA2) */
4769 TEST_CASE_ST(ut_setup, ut_teardown,
4770 test_snow3g_decryption_test_case_1),
4771 TEST_CASE_ST(ut_setup, ut_teardown,
4772 test_snow3g_decryption_test_case_2),
4773 TEST_CASE_ST(ut_setup, ut_teardown,
4774 test_snow3g_decryption_test_case_3),
4775 TEST_CASE_ST(ut_setup, ut_teardown,
4776 test_snow3g_decryption_test_case_4),
4777 TEST_CASE_ST(ut_setup, ut_teardown,
4778 test_snow3g_decryption_test_case_5),
4779 TEST_CASE_ST(ut_setup, ut_teardown,
4780 test_snow3g_hash_generate_test_case_1),
4781 TEST_CASE_ST(ut_setup, ut_teardown,
4782 test_snow3g_hash_generate_test_case_2),
4783 TEST_CASE_ST(ut_setup, ut_teardown,
4784 test_snow3g_hash_generate_test_case_3),
4785 /* Tests with buffers which length is not byte-aligned */
4786 TEST_CASE_ST(ut_setup, ut_teardown,
4787 test_snow3g_hash_generate_test_case_4),
4788 TEST_CASE_ST(ut_setup, ut_teardown,
4789 test_snow3g_hash_generate_test_case_5),
4790 TEST_CASE_ST(ut_setup, ut_teardown,
4791 test_snow3g_hash_generate_test_case_6),
4792 TEST_CASE_ST(ut_setup, ut_teardown,
4793 test_snow3g_hash_verify_test_case_1),
4794 TEST_CASE_ST(ut_setup, ut_teardown,
4795 test_snow3g_hash_verify_test_case_2),
4796 TEST_CASE_ST(ut_setup, ut_teardown,
4797 test_snow3g_hash_verify_test_case_3),
4798 /* Tests with buffers which length is not byte-aligned */
4799 TEST_CASE_ST(ut_setup, ut_teardown,
4800 test_snow3g_hash_verify_test_case_4),
4801 TEST_CASE_ST(ut_setup, ut_teardown,
4802 test_snow3g_hash_verify_test_case_5),
4803 TEST_CASE_ST(ut_setup, ut_teardown,
4804 test_snow3g_hash_verify_test_case_6),
4805 TEST_CASE_ST(ut_setup, ut_teardown,
4806 test_snow3g_cipher_auth_test_case_1),
4807 TEST_CASE_ST(ut_setup, ut_teardown,
4808 test_snow3g_auth_cipher_test_case_1),
4810 TEST_CASES_END() /**< NULL terminate unit test array */
4814 static struct unit_test_suite cryptodev_null_testsuite = {
4815 .suite_name = "Crypto Device NULL Unit Test Suite",
4816 .setup = testsuite_setup,
4817 .teardown = testsuite_teardown,
4818 .unit_test_cases = {
4819 TEST_CASE_ST(ut_setup, ut_teardown,
4820 test_null_auth_only_operation),
4821 TEST_CASE_ST(ut_setup, ut_teardown,
4822 test_null_cipher_only_operation),
4823 TEST_CASE_ST(ut_setup, ut_teardown,
4824 test_null_cipher_auth_operation),
4825 TEST_CASE_ST(ut_setup, ut_teardown,
4826 test_null_auth_cipher_operation),
4827 TEST_CASE_ST(ut_setup, ut_teardown,
4828 test_null_invalid_operation),
4829 TEST_CASE_ST(ut_setup, ut_teardown,
4830 test_null_burst_operation),
4832 TEST_CASES_END() /**< NULL terminate unit test array */
4837 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
4839 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
4840 return unit_test_suite_runner(&cryptodev_qat_testsuite);
4844 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
4846 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
4848 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
4852 test_cryptodev_aesni_gcm(void)
4854 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
4856 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
4860 test_cryptodev_null(void)
4862 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
4864 return unit_test_suite_runner(&cryptodev_null_testsuite);
4868 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
4870 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
4872 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
4876 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
4878 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
4880 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
4883 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
4884 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
4885 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
4886 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
4887 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
4888 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);