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"
53 static enum rte_cryptodev_type gbl_cryptodev_type;
55 struct crypto_testsuite_params {
56 struct rte_mempool *mbuf_pool;
57 struct rte_mempool *op_mpool;
58 struct rte_cryptodev_config conf;
59 struct rte_cryptodev_qp_conf qp_conf;
61 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
62 uint8_t valid_dev_count;
65 struct crypto_unittest_params {
66 struct rte_crypto_sym_xform cipher_xform;
67 struct rte_crypto_sym_xform auth_xform;
69 struct rte_cryptodev_sym_session *sess;
71 struct rte_crypto_op *op;
73 struct rte_mbuf *obuf, *ibuf;
78 #define ALIGN_POW2_ROUNDUP(num, align) \
79 (((num) + (align) - 1) & ~((align) - 1))
82 * Forward declarations.
85 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
86 struct crypto_unittest_params *ut_params);
89 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
90 struct crypto_unittest_params *ut_params,
91 struct crypto_testsuite_params *ts_param);
93 static struct rte_mbuf *
94 setup_test_string(struct rte_mempool *mpool,
95 const char *string, size_t len, uint8_t blocksize)
97 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
98 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
100 memset(m->buf_addr, 0, m->buf_len);
102 char *dst = rte_pktmbuf_append(m, t_len);
109 rte_memcpy(dst, string, t_len);
111 memset(dst, 0, t_len);
117 /* Get number of bytes in X bits (rounding up) */
119 ceil_byte_length(uint32_t num_bits)
122 return ((num_bits >> 3) + 1);
124 return (num_bits >> 3);
127 static struct rte_crypto_op *
128 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
130 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
131 printf("Error sending packet for encryption");
137 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
143 static struct crypto_testsuite_params testsuite_params = { NULL };
144 static struct crypto_unittest_params unittest_params;
147 testsuite_setup(void)
149 struct crypto_testsuite_params *ts_params = &testsuite_params;
150 struct rte_cryptodev_info info;
151 unsigned i, nb_devs, dev_id;
155 memset(ts_params, 0, sizeof(*ts_params));
157 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
158 if (ts_params->mbuf_pool == NULL) {
159 /* Not already created so create */
160 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
162 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
164 if (ts_params->mbuf_pool == NULL) {
165 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
170 ts_params->op_mpool = rte_crypto_op_pool_create(
171 "MBUF_CRYPTO_SYM_OP_POOL",
172 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
173 NUM_MBUFS, MBUF_CACHE_SIZE,
175 sizeof(struct rte_crypto_sym_xform),
177 if (ts_params->op_mpool == NULL) {
178 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
182 /* Create 2 AESNI MB devices if required */
183 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
184 nb_devs = rte_cryptodev_count_devtype(
185 RTE_CRYPTODEV_AESNI_MB_PMD);
187 for (i = nb_devs; i < 2; i++) {
188 ret = rte_eal_vdev_init(
189 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
191 TEST_ASSERT(ret == 0,
192 "Failed to create instance %u of"
194 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
199 /* Create 2 AESNI GCM devices if required */
200 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
201 nb_devs = rte_cryptodev_count_devtype(
202 RTE_CRYPTODEV_AESNI_GCM_PMD);
204 for (i = nb_devs; i < 2; i++) {
205 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
206 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
207 "Failed to create instance %u of"
209 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
214 /* Create 2 Snow3G devices if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
216 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
218 for (i = nb_devs; i < 2; i++) {
219 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
220 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
221 "Failed to create instance %u of"
223 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
228 /* Create 2 KASUMI devices if required */
229 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
230 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
232 for (i = nb_devs; i < 2; i++) {
233 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
234 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
235 "Failed to create instance %u of"
237 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
242 /* Create 2 NULL devices if required */
243 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
244 nb_devs = rte_cryptodev_count_devtype(
245 RTE_CRYPTODEV_NULL_PMD);
247 for (i = nb_devs; i < 2; i++) {
248 int dev_id = rte_eal_vdev_init(
249 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
251 TEST_ASSERT(dev_id >= 0,
252 "Failed to create instance %u of"
254 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
259 nb_devs = rte_cryptodev_count();
261 RTE_LOG(ERR, USER1, "No crypto devices found?");
265 /* Create list of valid crypto devs */
266 for (i = 0; i < nb_devs; i++) {
267 rte_cryptodev_info_get(i, &info);
268 if (info.dev_type == gbl_cryptodev_type)
269 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
272 if (ts_params->valid_dev_count < 1)
275 /* Set up all the qps on the first of the valid devices found */
276 for (i = 0; i < 1; i++) {
277 dev_id = ts_params->valid_devs[i];
279 rte_cryptodev_info_get(dev_id, &info);
282 * Since we can't free and re-allocate queue memory always set
283 * the queues on this device up to max size first so enough
284 * memory is allocated for any later re-configures needed by
288 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
289 ts_params->conf.socket_id = SOCKET_ID_ANY;
290 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
292 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
294 "Failed to configure cryptodev %u with %u qps",
295 dev_id, ts_params->conf.nb_queue_pairs);
297 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
299 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
300 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
301 dev_id, qp_id, &ts_params->qp_conf,
302 rte_cryptodev_socket_id(dev_id)),
303 "Failed to setup queue pair %u on "
313 testsuite_teardown(void)
315 struct crypto_testsuite_params *ts_params = &testsuite_params;
317 if (ts_params->mbuf_pool != NULL) {
318 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
319 rte_mempool_avail_count(ts_params->mbuf_pool));
322 if (ts_params->op_mpool != NULL) {
323 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
324 rte_mempool_avail_count(ts_params->op_mpool));
332 struct crypto_testsuite_params *ts_params = &testsuite_params;
333 struct crypto_unittest_params *ut_params = &unittest_params;
337 /* Clear unit test parameters before running test */
338 memset(ut_params, 0, sizeof(*ut_params));
340 /* Reconfigure device to default parameters */
341 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
342 ts_params->conf.socket_id = SOCKET_ID_ANY;
343 ts_params->conf.session_mp.nb_objs =
344 (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) ?
345 DEFAULT_NUM_OPS_INFLIGHT :
346 DEFAULT_NUM_OPS_INFLIGHT;
348 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
350 "Failed to configure cryptodev %u",
351 ts_params->valid_devs[0]);
354 * Now reconfigure queues to size we actually want to use in this
357 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
359 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
360 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
361 ts_params->valid_devs[0], qp_id,
363 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
364 "Failed to setup queue pair %u on cryptodev %u",
365 qp_id, ts_params->valid_devs[0]);
369 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
371 /* Start the device */
372 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
373 "Failed to start cryptodev %u",
374 ts_params->valid_devs[0]);
382 struct crypto_testsuite_params *ts_params = &testsuite_params;
383 struct crypto_unittest_params *ut_params = &unittest_params;
384 struct rte_cryptodev_stats stats;
386 /* free crypto session structure */
387 if (ut_params->sess) {
388 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
390 ut_params->sess = NULL;
393 /* free crypto operation structure */
395 rte_crypto_op_free(ut_params->op);
398 * free mbuf - both obuf and ibuf are usually the same,
399 * so check if they point at the same address is necessary,
400 * to avoid freeing the mbuf twice.
402 if (ut_params->obuf) {
403 rte_pktmbuf_free(ut_params->obuf);
404 if (ut_params->ibuf == ut_params->obuf)
408 if (ut_params->ibuf) {
409 rte_pktmbuf_free(ut_params->ibuf);
413 if (ts_params->mbuf_pool != NULL)
414 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
415 rte_mempool_avail_count(ts_params->mbuf_pool));
417 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
419 /* Stop the device */
420 rte_cryptodev_stop(ts_params->valid_devs[0]);
424 test_device_configure_invalid_dev_id(void)
426 struct crypto_testsuite_params *ts_params = &testsuite_params;
427 uint16_t dev_id, num_devs = 0;
429 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
430 "Need at least %d devices for test", 1);
432 /* valid dev_id values */
433 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
435 /* Stop the device in case it's started so it can be configured */
436 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
438 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
439 "Failed test for rte_cryptodev_configure: "
440 "invalid dev_num %u", dev_id);
442 /* invalid dev_id values */
445 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
446 "Failed test for rte_cryptodev_configure: "
447 "invalid dev_num %u", dev_id);
451 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
452 "Failed test for rte_cryptodev_configure:"
453 "invalid dev_num %u", dev_id);
459 test_device_configure_invalid_queue_pair_ids(void)
461 struct crypto_testsuite_params *ts_params = &testsuite_params;
463 /* Stop the device in case it's started so it can be configured */
464 rte_cryptodev_stop(ts_params->valid_devs[0]);
466 /* valid - one queue pairs */
467 ts_params->conf.nb_queue_pairs = 1;
469 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
471 "Failed to configure cryptodev: dev_id %u, qp_id %u",
472 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
475 /* valid - max value queue pairs */
476 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
478 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
480 "Failed to configure cryptodev: dev_id %u, qp_id %u",
481 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
484 /* invalid - zero queue pairs */
485 ts_params->conf.nb_queue_pairs = 0;
487 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
489 "Failed test for rte_cryptodev_configure, dev_id %u,"
491 ts_params->valid_devs[0],
492 ts_params->conf.nb_queue_pairs);
495 /* invalid - max value supported by field queue pairs */
496 ts_params->conf.nb_queue_pairs = UINT16_MAX;
498 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
500 "Failed test for rte_cryptodev_configure, dev_id %u,"
502 ts_params->valid_devs[0],
503 ts_params->conf.nb_queue_pairs);
506 /* invalid - max value + 1 queue pairs */
507 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
509 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
511 "Failed test for rte_cryptodev_configure, dev_id %u,"
513 ts_params->valid_devs[0],
514 ts_params->conf.nb_queue_pairs);
520 test_queue_pair_descriptor_setup(void)
522 struct crypto_testsuite_params *ts_params = &testsuite_params;
523 struct rte_cryptodev_info dev_info;
524 struct rte_cryptodev_qp_conf qp_conf = {
525 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
530 /* Stop the device in case it's started so it can be configured */
531 rte_cryptodev_stop(ts_params->valid_devs[0]);
534 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
536 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
538 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
539 &ts_params->conf), "Failed to configure cryptodev %u",
540 ts_params->valid_devs[0]);
544 * Test various ring sizes on this device. memzones can't be
545 * freed so are re-used if ring is released and re-created.
547 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
549 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
550 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
551 ts_params->valid_devs[0], qp_id, &qp_conf,
552 rte_cryptodev_socket_id(
553 ts_params->valid_devs[0])),
555 "rte_cryptodev_queue_pair_setup: num_inflights "
556 "%u on qp %u on cryptodev %u",
557 qp_conf.nb_descriptors, qp_id,
558 ts_params->valid_devs[0]);
561 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
563 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
564 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
565 ts_params->valid_devs[0], qp_id, &qp_conf,
566 rte_cryptodev_socket_id(
567 ts_params->valid_devs[0])),
569 " rte_cryptodev_queue_pair_setup: num_inflights"
570 " %u on qp %u on cryptodev %u",
571 qp_conf.nb_descriptors, qp_id,
572 ts_params->valid_devs[0]);
575 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
577 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
578 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
579 ts_params->valid_devs[0], qp_id, &qp_conf,
580 rte_cryptodev_socket_id(
581 ts_params->valid_devs[0])),
583 "rte_cryptodev_queue_pair_setup: num_inflights"
584 " %u on qp %u on cryptodev %u",
585 qp_conf.nb_descriptors, qp_id,
586 ts_params->valid_devs[0]);
589 /* invalid number of descriptors - max supported + 2 */
590 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
592 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
593 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
594 ts_params->valid_devs[0], qp_id, &qp_conf,
595 rte_cryptodev_socket_id(
596 ts_params->valid_devs[0])),
597 "Unexpectedly passed test for "
598 "rte_cryptodev_queue_pair_setup:"
599 "num_inflights %u on qp %u on cryptodev %u",
600 qp_conf.nb_descriptors, qp_id,
601 ts_params->valid_devs[0]);
604 /* invalid number of descriptors - max value of parameter */
605 qp_conf.nb_descriptors = UINT32_MAX-1;
607 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
608 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
609 ts_params->valid_devs[0], qp_id, &qp_conf,
610 rte_cryptodev_socket_id(
611 ts_params->valid_devs[0])),
612 "Unexpectedly passed test for "
613 "rte_cryptodev_queue_pair_setup:"
614 "num_inflights %u on qp %u on cryptodev %u",
615 qp_conf.nb_descriptors, qp_id,
616 ts_params->valid_devs[0]);
619 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
621 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
622 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
623 ts_params->valid_devs[0], qp_id, &qp_conf,
624 rte_cryptodev_socket_id(
625 ts_params->valid_devs[0])),
627 " rte_cryptodev_queue_pair_setup:"
628 "num_inflights %u on qp %u on cryptodev %u",
629 qp_conf.nb_descriptors, qp_id,
630 ts_params->valid_devs[0]);
633 /* invalid number of descriptors - max supported + 1 */
634 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
636 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
637 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
638 ts_params->valid_devs[0], qp_id, &qp_conf,
639 rte_cryptodev_socket_id(
640 ts_params->valid_devs[0])),
641 "Unexpectedly passed test for "
642 "rte_cryptodev_queue_pair_setup:"
643 "num_inflights %u on qp %u on cryptodev %u",
644 qp_conf.nb_descriptors, qp_id,
645 ts_params->valid_devs[0]);
648 /* test invalid queue pair id */
649 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
651 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
653 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
654 ts_params->valid_devs[0],
656 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
657 "Failed test for rte_cryptodev_queue_pair_setup:"
658 "invalid qp %u on cryptodev %u",
659 qp_id, ts_params->valid_devs[0]);
661 qp_id = 0xffff; /*invalid*/
663 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
664 ts_params->valid_devs[0],
666 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
667 "Failed test for rte_cryptodev_queue_pair_setup:"
668 "invalid qp %u on cryptodev %u",
669 qp_id, ts_params->valid_devs[0]);
674 /* ***** Plaintext data for tests ***** */
676 const char catch_22_quote_1[] =
677 "There was only one catch and that was Catch-22, which "
678 "specified that a concern for one's safety in the face of "
679 "dangers that were real and immediate was the process of a "
680 "rational mind. Orr was crazy and could be grounded. All he "
681 "had to do was ask; and as soon as he did, he would no longer "
682 "be crazy and would have to fly more missions. Orr would be "
683 "crazy to fly more missions and sane if he didn't, but if he "
684 "was sane he had to fly them. If he flew them he was crazy "
685 "and didn't have to; but if he didn't want to he was sane and "
686 "had to. Yossarian was moved very deeply by the absolute "
687 "simplicity of this clause of Catch-22 and let out a "
688 "respectful whistle. \"That's some catch, that Catch-22\", he "
689 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
691 const char catch_22_quote[] =
692 "What a lousy earth! He wondered how many people were "
693 "destitute that same night even in his own prosperous country, "
694 "how many homes were shanties, how many husbands were drunk "
695 "and wives socked, and how many children were bullied, abused, "
696 "or abandoned. How many families hungered for food they could "
697 "not afford to buy? How many hearts were broken? How many "
698 "suicides would take place that same night, how many people "
699 "would go insane? How many cockroaches and landlords would "
700 "triumph? How many winners were losers, successes failures, "
701 "and rich men poor men? How many wise guys were stupid? How "
702 "many happy endings were unhappy endings? How many honest men "
703 "were liars, brave men cowards, loyal men traitors, how many "
704 "sainted men were corrupt, how many people in positions of "
705 "trust had sold their souls to bodyguards, how many had never "
706 "had souls? How many straight-and-narrow paths were crooked "
707 "paths? How many best families were worst families and how "
708 "many good people were bad people? When you added them all up "
709 "and then subtracted, you might be left with only the children, "
710 "and perhaps with Albert Einstein and an old violinist or "
711 "sculptor somewhere.";
713 #define QUOTE_480_BYTES (480)
714 #define QUOTE_512_BYTES (512)
715 #define QUOTE_768_BYTES (768)
716 #define QUOTE_1024_BYTES (1024)
720 /* ***** SHA1 Hash Tests ***** */
722 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
724 static uint8_t hmac_sha1_key[] = {
725 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
726 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
727 0xDE, 0xF4, 0xDE, 0xAD };
729 /* ***** SHA224 Hash Tests ***** */
731 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
734 /* ***** AES-CBC Cipher Tests ***** */
736 #define CIPHER_KEY_LENGTH_AES_CBC (16)
737 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
739 static uint8_t aes_cbc_key[] = {
740 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
741 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
743 static uint8_t aes_cbc_iv[] = {
744 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
745 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
748 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
750 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
751 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
752 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
753 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
754 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
755 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
756 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
757 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
758 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
759 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
760 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
761 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
762 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
763 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
764 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
765 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
766 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
767 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
768 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
769 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
770 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
771 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
772 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
773 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
774 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
775 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
776 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
777 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
778 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
779 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
780 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
781 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
782 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
783 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
784 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
785 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
786 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
787 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
788 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
789 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
790 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
791 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
792 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
793 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
794 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
795 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
796 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
797 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
798 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
799 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
800 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
801 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
802 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
803 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
804 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
805 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
806 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
807 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
808 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
809 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
810 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
811 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
812 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
813 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
814 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
817 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
818 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
819 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
820 0x18, 0x8c, 0x1d, 0x32
825 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
827 struct crypto_testsuite_params *ts_params = &testsuite_params;
828 struct crypto_unittest_params *ut_params = &unittest_params;
830 /* Generate test mbuf data and space for digest */
831 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
832 catch_22_quote, QUOTE_512_BYTES, 0);
834 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
835 DIGEST_BYTE_LENGTH_SHA1);
836 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
838 /* Setup Cipher Parameters */
839 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
840 ut_params->cipher_xform.next = &ut_params->auth_xform;
842 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
843 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
844 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
845 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
847 /* Setup HMAC Parameters */
848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
850 ut_params->auth_xform.next = NULL;
852 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
853 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
854 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
855 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
856 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
858 /* Create crypto session*/
859 ut_params->sess = rte_cryptodev_sym_session_create(
860 ts_params->valid_devs[0],
861 &ut_params->cipher_xform);
862 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
864 /* Generate crypto op data structure */
865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
867 TEST_ASSERT_NOT_NULL(ut_params->op,
868 "Failed to allocate symmetric crypto operation struct");
870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
872 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
874 /* set crypto operation source mbuf */
875 sym_op->m_src = ut_params->ibuf;
877 /* Set crypto operation authentication parameters */
878 sym_op->auth.digest.data = ut_params->digest;
879 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
880 ut_params->ibuf, QUOTE_512_BYTES);
881 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
883 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
884 sym_op->auth.data.length = QUOTE_512_BYTES;
886 /* Set crypto operation cipher parameters */
887 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
888 CIPHER_IV_LENGTH_AES_CBC);
889 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
890 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
892 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
893 CIPHER_IV_LENGTH_AES_CBC);
895 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
896 sym_op->cipher.data.length = QUOTE_512_BYTES;
898 /* Process crypto operation */
899 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
900 ut_params->op), "failed to process sym crypto op");
902 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
903 "crypto op processing failed");
906 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
907 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
909 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
910 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
912 "ciphertext data not as expected");
914 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
916 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
917 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
918 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
919 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
920 DIGEST_BYTE_LENGTH_SHA1,
921 "Generated digest data not as expected");
926 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
928 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
930 static uint8_t hmac_sha512_key[] = {
931 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
932 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
933 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
934 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
935 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
936 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
937 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
938 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
940 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
941 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
942 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
943 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
944 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
945 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
946 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
947 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
948 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
953 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
954 struct crypto_unittest_params *ut_params);
957 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
958 struct crypto_unittest_params *ut_params,
959 struct crypto_testsuite_params *ts_params);
963 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
964 struct crypto_unittest_params *ut_params)
967 /* Setup Cipher Parameters */
968 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
969 ut_params->cipher_xform.next = NULL;
971 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
972 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
973 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
974 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
976 /* Setup HMAC Parameters */
977 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
978 ut_params->auth_xform.next = &ut_params->cipher_xform;
980 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
981 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
982 ut_params->auth_xform.auth.key.data = hmac_sha512_key;
983 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
984 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
991 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
992 struct crypto_unittest_params *ut_params,
993 struct crypto_testsuite_params *ts_params)
995 /* Generate test mbuf data and digest */
996 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
998 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1001 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1002 DIGEST_BYTE_LENGTH_SHA512);
1003 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1005 rte_memcpy(ut_params->digest,
1006 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1007 DIGEST_BYTE_LENGTH_SHA512);
1009 /* Generate Crypto op data structure */
1010 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1011 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1012 TEST_ASSERT_NOT_NULL(ut_params->op,
1013 "Failed to allocate symmetric crypto operation struct");
1015 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1017 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1019 /* set crypto operation source mbuf */
1020 sym_op->m_src = ut_params->ibuf;
1022 sym_op->auth.digest.data = ut_params->digest;
1023 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1024 ut_params->ibuf, QUOTE_512_BYTES);
1025 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1027 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1028 sym_op->auth.data.length = QUOTE_512_BYTES;
1030 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1031 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1032 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1033 ut_params->ibuf, 0);
1034 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1036 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1037 CIPHER_IV_LENGTH_AES_CBC);
1039 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1040 sym_op->cipher.data.length = QUOTE_512_BYTES;
1042 /* Process crypto operation */
1043 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1044 ut_params->op), "failed to process sym crypto op");
1046 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1047 "crypto op processing failed");
1049 ut_params->obuf = ut_params->op->sym->m_src;
1052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1053 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1054 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1056 "Plaintext data not as expected");
1059 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1060 "Digest verification failed");
1062 return TEST_SUCCESS;
1066 test_AES_mb_all(void)
1068 struct crypto_testsuite_params *ts_params = &testsuite_params;
1071 status = test_AES_all_tests(ts_params->mbuf_pool,
1072 ts_params->op_mpool, ts_params->valid_devs[0],
1073 RTE_CRYPTODEV_AESNI_MB_PMD);
1075 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1077 return TEST_SUCCESS;
1081 test_AES_qat_all(void)
1083 struct crypto_testsuite_params *ts_params = &testsuite_params;
1086 status = test_AES_all_tests(ts_params->mbuf_pool,
1087 ts_params->op_mpool, ts_params->valid_devs[0],
1088 RTE_CRYPTODEV_QAT_SYM_PMD);
1090 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1092 return TEST_SUCCESS;
1095 /* ***** Snow3G Tests ***** */
1097 create_snow3g_kasumi_hash_session(uint8_t dev_id,
1098 const uint8_t *key, const uint8_t key_len,
1099 const uint8_t aad_len, const uint8_t auth_len,
1100 enum rte_crypto_auth_operation op,
1101 enum rte_crypto_auth_algorithm algo)
1103 uint8_t hash_key[key_len];
1105 struct crypto_unittest_params *ut_params = &unittest_params;
1107 memcpy(hash_key, key, key_len);
1109 TEST_HEXDUMP(stdout, "key:", key, key_len);
1111 /* Setup Authentication Parameters */
1112 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1113 ut_params->auth_xform.next = NULL;
1115 ut_params->auth_xform.auth.op = op;
1116 ut_params->auth_xform.auth.algo = algo;
1117 ut_params->auth_xform.auth.key.length = key_len;
1118 ut_params->auth_xform.auth.key.data = hash_key;
1119 ut_params->auth_xform.auth.digest_length = auth_len;
1120 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1121 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1122 &ut_params->auth_xform);
1123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1128 create_snow3g_kasumi_cipher_session(uint8_t dev_id,
1129 enum rte_crypto_cipher_operation op,
1130 enum rte_crypto_cipher_algorithm algo,
1131 const uint8_t *key, const uint8_t key_len)
1133 uint8_t cipher_key[key_len];
1135 struct crypto_unittest_params *ut_params = &unittest_params;
1137 memcpy(cipher_key, key, key_len);
1139 /* Setup Cipher Parameters */
1140 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1141 ut_params->cipher_xform.next = NULL;
1143 ut_params->cipher_xform.cipher.algo = algo;
1144 ut_params->cipher_xform.cipher.op = op;
1145 ut_params->cipher_xform.cipher.key.data = cipher_key;
1146 ut_params->cipher_xform.cipher.key.length = key_len;
1148 TEST_HEXDUMP(stdout, "key:", key, key_len);
1150 /* Create Crypto session */
1151 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1154 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1159 create_snow3g_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1160 const unsigned cipher_len,
1161 const unsigned cipher_offset,
1162 enum rte_crypto_cipher_algorithm algo)
1164 struct crypto_testsuite_params *ts_params = &testsuite_params;
1165 struct crypto_unittest_params *ut_params = &unittest_params;
1166 unsigned iv_pad_len = 0;
1168 /* Generate Crypto op data structure */
1169 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1170 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1171 TEST_ASSERT_NOT_NULL(ut_params->op,
1172 "Failed to allocate pktmbuf offload");
1174 /* Set crypto operation data parameters */
1175 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1177 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1179 /* set crypto operation source mbuf */
1180 sym_op->m_src = ut_params->ibuf;
1183 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1184 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1186 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1188 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1191 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1193 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1194 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1195 sym_op->cipher.iv.length = iv_pad_len;
1197 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1198 sym_op->cipher.data.length = cipher_len;
1199 sym_op->cipher.data.offset = cipher_offset;
1204 create_snow3g_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1205 const unsigned cipher_len,
1206 const unsigned cipher_offset,
1207 enum rte_crypto_cipher_algorithm algo)
1209 struct crypto_testsuite_params *ts_params = &testsuite_params;
1210 struct crypto_unittest_params *ut_params = &unittest_params;
1211 unsigned iv_pad_len = 0;
1213 /* Generate Crypto op data structure */
1214 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1215 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1216 TEST_ASSERT_NOT_NULL(ut_params->op,
1217 "Failed to allocate pktmbuf offload");
1219 /* Set crypto operation data parameters */
1220 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1222 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1224 /* set crypto operation source mbuf */
1225 sym_op->m_src = ut_params->ibuf;
1226 sym_op->m_dst = ut_params->obuf;
1229 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1230 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1232 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1233 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1236 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1238 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1239 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1240 sym_op->cipher.iv.length = iv_pad_len;
1242 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1243 sym_op->cipher.data.length = cipher_len;
1244 sym_op->cipher.data.offset = cipher_offset;
1249 create_snow3g_kasumi_cipher_auth_session(uint8_t dev_id,
1250 enum rte_crypto_cipher_operation cipher_op,
1251 enum rte_crypto_auth_operation auth_op,
1252 enum rte_crypto_auth_algorithm auth_algo,
1253 enum rte_crypto_cipher_algorithm cipher_algo,
1254 const uint8_t *key, const uint8_t key_len,
1255 const uint8_t aad_len, const uint8_t auth_len)
1258 uint8_t cipher_auth_key[key_len];
1260 struct crypto_unittest_params *ut_params = &unittest_params;
1262 memcpy(cipher_auth_key, key, key_len);
1264 /* Setup Authentication Parameters */
1265 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1266 ut_params->auth_xform.next = NULL;
1268 ut_params->auth_xform.auth.op = auth_op;
1269 ut_params->auth_xform.auth.algo = auth_algo;
1270 ut_params->auth_xform.auth.key.length = key_len;
1271 /* Hash key = cipher key */
1272 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1273 ut_params->auth_xform.auth.digest_length = auth_len;
1274 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1276 /* Setup Cipher Parameters */
1277 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1278 ut_params->cipher_xform.next = &ut_params->auth_xform;
1280 ut_params->cipher_xform.cipher.algo = cipher_algo;
1281 ut_params->cipher_xform.cipher.op = cipher_op;
1282 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1283 ut_params->cipher_xform.cipher.key.length = key_len;
1285 TEST_HEXDUMP(stdout, "key:", key, key_len);
1287 /* Create Crypto session*/
1288 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1289 &ut_params->cipher_xform);
1291 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1296 create_snow3g_kasumi_auth_cipher_session(uint8_t dev_id,
1297 enum rte_crypto_cipher_operation cipher_op,
1298 enum rte_crypto_auth_operation auth_op,
1299 enum rte_crypto_auth_algorithm auth_algo,
1300 enum rte_crypto_cipher_algorithm cipher_algo,
1301 const uint8_t *key, const uint8_t key_len,
1302 const uint8_t aad_len, const uint8_t auth_len)
1304 uint8_t auth_cipher_key[key_len];
1306 struct crypto_unittest_params *ut_params = &unittest_params;
1308 memcpy(auth_cipher_key, key, key_len);
1310 /* Setup Authentication Parameters */
1311 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1312 ut_params->auth_xform.auth.op = auth_op;
1313 ut_params->auth_xform.next = &ut_params->cipher_xform;
1314 ut_params->auth_xform.auth.algo = auth_algo;
1315 ut_params->auth_xform.auth.key.length = key_len;
1316 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1317 ut_params->auth_xform.auth.digest_length = auth_len;
1318 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1320 /* Setup Cipher Parameters */
1321 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1322 ut_params->cipher_xform.next = NULL;
1323 ut_params->cipher_xform.cipher.algo = cipher_algo;
1324 ut_params->cipher_xform.cipher.op = cipher_op;
1325 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1326 ut_params->cipher_xform.cipher.key.length = key_len;
1328 TEST_HEXDUMP(stdout, "key:", key, key_len);
1330 /* Create Crypto session*/
1331 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1332 &ut_params->auth_xform);
1334 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1340 create_snow3g_kasumi_hash_operation(const uint8_t *auth_tag,
1341 const unsigned auth_tag_len,
1342 const uint8_t *aad, const unsigned aad_len,
1343 unsigned data_pad_len,
1344 enum rte_crypto_auth_operation op,
1345 enum rte_crypto_auth_algorithm algo,
1346 const unsigned auth_len, const unsigned auth_offset)
1348 struct crypto_testsuite_params *ts_params = &testsuite_params;
1350 struct crypto_unittest_params *ut_params = &unittest_params;
1352 unsigned aad_buffer_len;
1354 /* Generate Crypto op data structure */
1355 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1356 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1357 TEST_ASSERT_NOT_NULL(ut_params->op,
1358 "Failed to allocate pktmbuf offload");
1360 /* Set crypto operation data parameters */
1361 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1363 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1365 /* set crypto operation source mbuf */
1366 sym_op->m_src = ut_params->ibuf;
1370 * Always allocate the aad up to the block size.
1371 * The cryptodev API calls out -
1372 * - the array must be big enough to hold the AAD, plus any
1373 * space to round this up to the nearest multiple of the
1374 * block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
1376 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1377 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1379 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1380 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1381 ut_params->ibuf, aad_buffer_len);
1382 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1383 "no room to prepend aad");
1384 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1386 sym_op->auth.aad.length = aad_len;
1388 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1389 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1391 TEST_HEXDUMP(stdout, "aad:",
1392 sym_op->auth.aad.data, aad_len);
1395 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1396 ut_params->ibuf, auth_tag_len);
1398 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1399 "no room to append auth tag");
1400 ut_params->digest = sym_op->auth.digest.data;
1401 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1402 ut_params->ibuf, data_pad_len + aad_len);
1403 sym_op->auth.digest.length = auth_tag_len;
1404 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1405 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1407 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1409 TEST_HEXDUMP(stdout, "digest:",
1410 sym_op->auth.digest.data,
1411 sym_op->auth.digest.length);
1413 sym_op->auth.data.length = auth_len;
1414 sym_op->auth.data.offset = auth_offset;
1420 create_snow3g_kasumi_cipher_hash_operation(const uint8_t *auth_tag,
1421 const unsigned auth_tag_len,
1422 const uint8_t *aad, const uint8_t aad_len,
1423 unsigned data_pad_len,
1424 enum rte_crypto_auth_operation op,
1425 enum rte_crypto_auth_algorithm auth_algo,
1426 enum rte_crypto_cipher_algorithm cipher_algo,
1427 const uint8_t *iv, const uint8_t iv_len,
1428 const unsigned cipher_len, const unsigned cipher_offset,
1429 const unsigned auth_len, const unsigned auth_offset)
1431 struct crypto_testsuite_params *ts_params = &testsuite_params;
1432 struct crypto_unittest_params *ut_params = &unittest_params;
1434 unsigned iv_pad_len = 0;
1435 unsigned aad_buffer_len;
1437 /* Generate Crypto op data structure */
1438 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1439 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1440 TEST_ASSERT_NOT_NULL(ut_params->op,
1441 "Failed to allocate pktmbuf offload");
1442 /* Set crypto operation data parameters */
1443 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1445 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1447 /* set crypto operation source mbuf */
1448 sym_op->m_src = ut_params->ibuf;
1452 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1453 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1455 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1457 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1458 ut_params->ibuf, iv_pad_len);
1459 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1461 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1462 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1463 sym_op->cipher.iv.length = iv_pad_len;
1465 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1467 sym_op->cipher.data.length = cipher_len;
1468 sym_op->cipher.data.offset = cipher_offset;
1472 * Always allocate the aad up to the block size.
1473 * The cryptodev API calls out -
1474 * - the array must be big enough to hold the AAD, plus any
1475 * space to round this up to the nearest multiple of the
1476 * block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
1478 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1479 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1481 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1483 sym_op->auth.aad.data =
1484 (uint8_t *)rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
1485 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1486 "no room to prepend aad");
1487 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1489 sym_op->auth.aad.length = aad_len;
1491 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1492 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1494 TEST_HEXDUMP(stdout, "aad:",
1495 sym_op->auth.aad.data, aad_len);
1498 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1499 ut_params->ibuf, auth_tag_len);
1501 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1502 "no room to append auth tag");
1503 ut_params->digest = sym_op->auth.digest.data;
1504 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1505 ut_params->ibuf, data_pad_len + aad_len);
1506 sym_op->auth.digest.length = auth_tag_len;
1507 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1508 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1510 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1512 TEST_HEXDUMP(stdout, "digest:",
1513 sym_op->auth.digest.data,
1514 sym_op->auth.digest.length);
1516 sym_op->auth.data.length = auth_len;
1517 sym_op->auth.data.offset = auth_offset;
1523 create_snow3g_kasumi_auth_cipher_operation(const unsigned auth_tag_len,
1524 const uint8_t *iv, const uint8_t iv_len,
1525 const uint8_t *aad, const uint8_t aad_len,
1526 unsigned data_pad_len,
1527 const unsigned cipher_len, const unsigned cipher_offset,
1528 const unsigned auth_len, const unsigned auth_offset,
1529 enum rte_crypto_auth_algorithm auth_algo,
1530 enum rte_crypto_cipher_algorithm cipher_algo)
1532 struct crypto_testsuite_params *ts_params = &testsuite_params;
1533 struct crypto_unittest_params *ut_params = &unittest_params;
1535 unsigned iv_pad_len = 0;
1536 unsigned aad_buffer_len = 0;
1538 /* Generate Crypto op data structure */
1539 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1540 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1541 TEST_ASSERT_NOT_NULL(ut_params->op,
1542 "Failed to allocate pktmbuf offload");
1544 /* Set crypto operation data parameters */
1545 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1547 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1549 /* set crypto operation source mbuf */
1550 sym_op->m_src = ut_params->ibuf;
1553 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1554 ut_params->ibuf, auth_tag_len);
1556 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1557 "no room to append auth tag");
1559 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1560 ut_params->ibuf, data_pad_len);
1561 sym_op->auth.digest.length = auth_tag_len;
1563 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1565 TEST_HEXDUMP(stdout, "digest:",
1566 sym_op->auth.digest.data,
1567 sym_op->auth.digest.length);
1570 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1571 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1573 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1575 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1576 ut_params->ibuf, iv_pad_len);
1577 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1579 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1580 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1581 sym_op->cipher.iv.length = iv_pad_len;
1583 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1587 * Always allocate the aad up to the block size.
1588 * The cryptodev API calls out -
1589 * - the array must be big enough to hold the AAD, plus any
1590 * space to round this up to the nearest multiple of the
1591 * block size (8 bytes for KASUMI 16 bytes).
1593 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1594 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1596 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1598 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1599 ut_params->ibuf, aad_buffer_len);
1600 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1601 "no room to prepend aad");
1602 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1604 sym_op->auth.aad.length = aad_len;
1606 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1607 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1609 TEST_HEXDUMP(stdout, "aad:",
1610 sym_op->auth.aad.data, aad_len);
1612 sym_op->cipher.data.length = cipher_len;
1613 sym_op->cipher.data.offset = auth_offset + cipher_offset;
1615 sym_op->auth.data.length = auth_len;
1616 sym_op->auth.data.offset = auth_offset + cipher_offset;
1622 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
1624 struct crypto_testsuite_params *ts_params = &testsuite_params;
1625 struct crypto_unittest_params *ut_params = &unittest_params;
1628 unsigned plaintext_pad_len;
1629 unsigned plaintext_len;
1632 /* Create SNOW3G session */
1633 retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
1634 tdata->key.data, tdata->key.len,
1635 tdata->aad.len, tdata->digest.len,
1636 RTE_CRYPTO_AUTH_OP_GENERATE,
1637 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
1641 /* alloc mbuf and set payload */
1642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1644 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1645 rte_pktmbuf_tailroom(ut_params->ibuf));
1647 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1648 /* Append data which is padded to a multiple of */
1649 /* the algorithms block size */
1650 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
1651 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1653 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1655 /* Create SNOW3G operation */
1656 retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
1657 tdata->aad.data, tdata->aad.len,
1658 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1659 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1660 tdata->validAuthLenInBits.len,
1661 tdata->validAuthOffsetLenInBits.len);
1665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1667 ut_params->obuf = ut_params->op->sym->m_src;
1668 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1669 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1670 + plaintext_pad_len + tdata->aad.len;
1673 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1676 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
1677 "Snow3G Generated auth tag not as expected");
1683 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1686 struct crypto_unittest_params *ut_params = &unittest_params;
1689 unsigned plaintext_pad_len;
1690 unsigned plaintext_len;
1693 /* Create SNOW3G session */
1694 retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
1695 tdata->key.data, tdata->key.len,
1696 tdata->aad.len, tdata->digest.len,
1697 RTE_CRYPTO_AUTH_OP_VERIFY,
1698 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
1701 /* alloc mbuf and set payload */
1702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1704 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1705 rte_pktmbuf_tailroom(ut_params->ibuf));
1707 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1708 /* Append data which is padded to a multiple of */
1709 /* the algorithms block size */
1710 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
1711 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1713 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1715 /* Create SNOW3G operation */
1716 retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
1718 tdata->aad.data, tdata->aad.len,
1720 RTE_CRYPTO_AUTH_OP_VERIFY,
1721 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1722 tdata->validAuthLenInBits.len,
1723 tdata->validAuthOffsetLenInBits.len);
1727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1730 ut_params->obuf = ut_params->op->sym->m_src;
1731 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1732 + plaintext_pad_len + tdata->aad.len;
1735 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
1744 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
1746 struct crypto_testsuite_params *ts_params = &testsuite_params;
1747 struct crypto_unittest_params *ut_params = &unittest_params;
1750 unsigned plaintext_pad_len;
1751 unsigned plaintext_len;
1754 /* Create KASUMI session */
1755 retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
1756 tdata->key.data, tdata->key.len,
1757 tdata->aad.len, tdata->digest.len,
1758 RTE_CRYPTO_AUTH_OP_GENERATE,
1759 RTE_CRYPTO_AUTH_KASUMI_F9);
1763 /* alloc mbuf and set payload */
1764 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1766 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1767 rte_pktmbuf_tailroom(ut_params->ibuf));
1769 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1770 /* Append data which is padded to a multiple of */
1771 /* the algorithms block size */
1772 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1775 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1777 /* Create KASUMI operation */
1778 retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
1779 tdata->aad.data, tdata->aad.len,
1780 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1781 RTE_CRYPTO_AUTH_KASUMI_F9,
1782 tdata->validAuthLenInBits.len,
1783 tdata->validAuthOffsetLenInBits.len);
1787 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1789 ut_params->obuf = ut_params->op->sym->m_src;
1790 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1791 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1792 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
1795 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1798 DIGEST_BYTE_LENGTH_KASUMI_F9,
1799 "KASUMI Generated auth tag not as expected");
1805 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 struct crypto_unittest_params *ut_params = &unittest_params;
1811 unsigned plaintext_pad_len;
1812 unsigned plaintext_len;
1815 /* Create KASUMI session */
1816 retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
1817 tdata->key.data, tdata->key.len,
1818 tdata->aad.len, tdata->digest.len,
1819 RTE_CRYPTO_AUTH_OP_VERIFY,
1820 RTE_CRYPTO_AUTH_KASUMI_F9);
1823 /* alloc mbuf and set payload */
1824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1827 rte_pktmbuf_tailroom(ut_params->ibuf));
1829 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1830 /* Append data which is padded to a multiple */
1831 /* of the algorithms block size */
1832 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1835 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1837 /* Create KASUMI operation */
1838 retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
1840 tdata->aad.data, tdata->aad.len,
1842 RTE_CRYPTO_AUTH_OP_VERIFY,
1843 RTE_CRYPTO_AUTH_KASUMI_F9,
1844 tdata->validAuthLenInBits.len,
1845 tdata->validAuthOffsetLenInBits.len);
1849 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1851 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1852 ut_params->obuf = ut_params->op->sym->m_src;
1853 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1854 + plaintext_pad_len + tdata->aad.len;
1857 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
1866 test_snow3g_hash_generate_test_case_1(void)
1868 return test_snow3g_authentication(&snow3g_hash_test_case_1);
1872 test_snow3g_hash_generate_test_case_2(void)
1874 return test_snow3g_authentication(&snow3g_hash_test_case_2);
1878 test_snow3g_hash_generate_test_case_3(void)
1880 return test_snow3g_authentication(&snow3g_hash_test_case_3);
1884 test_snow3g_hash_generate_test_case_4(void)
1886 return test_snow3g_authentication(&snow3g_hash_test_case_4);
1890 test_snow3g_hash_generate_test_case_5(void)
1892 return test_snow3g_authentication(&snow3g_hash_test_case_5);
1896 test_snow3g_hash_generate_test_case_6(void)
1898 return test_snow3g_authentication(&snow3g_hash_test_case_6);
1902 test_snow3g_hash_verify_test_case_1(void)
1904 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
1909 test_snow3g_hash_verify_test_case_2(void)
1911 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
1915 test_snow3g_hash_verify_test_case_3(void)
1917 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
1921 test_snow3g_hash_verify_test_case_4(void)
1923 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
1927 test_snow3g_hash_verify_test_case_5(void)
1929 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
1933 test_snow3g_hash_verify_test_case_6(void)
1935 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
1939 test_kasumi_hash_generate_test_case_1(void)
1941 return test_kasumi_authentication(&kasumi_hash_test_case_1);
1945 test_kasumi_hash_generate_test_case_2(void)
1947 return test_kasumi_authentication(&kasumi_hash_test_case_2);
1951 test_kasumi_hash_generate_test_case_3(void)
1953 return test_kasumi_authentication(&kasumi_hash_test_case_3);
1957 test_kasumi_hash_generate_test_case_4(void)
1959 return test_kasumi_authentication(&kasumi_hash_test_case_4);
1963 test_kasumi_hash_generate_test_case_5(void)
1965 return test_kasumi_authentication(&kasumi_hash_test_case_5);
1969 test_kasumi_hash_verify_test_case_1(void)
1971 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
1975 test_kasumi_hash_verify_test_case_2(void)
1977 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
1981 test_kasumi_hash_verify_test_case_3(void)
1983 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
1987 test_kasumi_hash_verify_test_case_4(void)
1989 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
1993 test_kasumi_hash_verify_test_case_5(void)
1995 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
1999 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2001 struct crypto_testsuite_params *ts_params = &testsuite_params;
2002 struct crypto_unittest_params *ut_params = &unittest_params;
2005 uint8_t *plaintext, *ciphertext;
2006 unsigned plaintext_pad_len;
2007 unsigned plaintext_len;
2009 /* Create KASUMI session */
2010 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2011 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2012 RTE_CRYPTO_CIPHER_KASUMI_F8,
2013 tdata->key.data, tdata->key.len);
2017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2019 /* Clear mbuf payload */
2020 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2021 rte_pktmbuf_tailroom(ut_params->ibuf));
2023 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2024 /* Append data which is padded to a multiple */
2025 /* of the algorithms block size */
2026 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2027 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2029 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2031 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2033 /* Create KASUMI operation */
2034 retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
2035 tdata->plaintext.len,
2036 tdata->validCipherOffsetLenInBits.len,
2037 RTE_CRYPTO_CIPHER_KASUMI_F8);
2041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2045 ut_params->obuf = ut_params->op->sym->m_dst;
2046 if (ut_params->obuf)
2047 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2050 ciphertext = plaintext;
2052 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2055 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2057 tdata->ciphertext.data,
2058 tdata->validCipherLenInBits.len,
2059 "KASUMI Ciphertext data not as expected");
2064 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2066 struct crypto_testsuite_params *ts_params = &testsuite_params;
2067 struct crypto_unittest_params *ut_params = &unittest_params;
2070 uint8_t *plaintext, *ciphertext;
2071 unsigned plaintext_pad_len;
2072 unsigned plaintext_len;
2074 /* Create KASUMI session */
2075 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2076 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2077 RTE_CRYPTO_CIPHER_KASUMI_F8,
2078 tdata->key.data, tdata->key.len);
2082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2083 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2085 /* Clear mbuf payload */
2086 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2087 rte_pktmbuf_tailroom(ut_params->ibuf));
2089 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2090 /* Append data which is padded to a multiple */
2091 /* of the algorithms block size */
2092 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2093 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2095 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2096 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2098 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2100 /* Create KASUMI operation */
2101 retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
2103 tdata->plaintext.len,
2104 tdata->validCipherOffsetLenInBits.len,
2105 RTE_CRYPTO_CIPHER_KASUMI_F8);
2109 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2111 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2113 ut_params->obuf = ut_params->op->sym->m_dst;
2114 if (ut_params->obuf)
2115 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2118 ciphertext = plaintext;
2120 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2123 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2125 tdata->ciphertext.data,
2126 tdata->validCipherLenInBits.len,
2127 "KASUMI Ciphertext data not as expected");
2132 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2134 struct crypto_testsuite_params *ts_params = &testsuite_params;
2135 struct crypto_unittest_params *ut_params = &unittest_params;
2138 uint8_t *ciphertext, *plaintext;
2139 unsigned ciphertext_pad_len;
2140 unsigned ciphertext_len;
2142 /* Create KASUMI session */
2143 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2144 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2145 RTE_CRYPTO_CIPHER_KASUMI_F8,
2146 tdata->key.data, tdata->key.len);
2150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2151 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2153 /* Clear mbuf payload */
2154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2155 rte_pktmbuf_tailroom(ut_params->ibuf));
2157 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2158 /* Append data which is padded to a multiple */
2159 /* of the algorithms block size */
2160 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2161 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2162 ciphertext_pad_len);
2163 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2164 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2166 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2168 /* Create KASUMI operation */
2169 retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
2171 tdata->ciphertext.len,
2172 tdata->validCipherOffsetLenInBits.len,
2173 RTE_CRYPTO_CIPHER_KASUMI_F8);
2177 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2179 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2181 ut_params->obuf = ut_params->op->sym->m_dst;
2182 if (ut_params->obuf)
2183 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2186 plaintext = ciphertext;
2188 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2191 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2193 tdata->plaintext.data,
2194 tdata->validCipherLenInBits.len,
2195 "KASUMI Plaintext data not as expected");
2200 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2202 struct crypto_testsuite_params *ts_params = &testsuite_params;
2203 struct crypto_unittest_params *ut_params = &unittest_params;
2206 uint8_t *ciphertext, *plaintext;
2207 unsigned ciphertext_pad_len;
2208 unsigned ciphertext_len;
2210 /* Create KASUMI session */
2211 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2212 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2213 RTE_CRYPTO_CIPHER_KASUMI_F8,
2214 tdata->key.data, tdata->key.len);
2218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2220 /* Clear mbuf payload */
2221 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2222 rte_pktmbuf_tailroom(ut_params->ibuf));
2224 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2225 /* Append data which is padded to a multiple */
2226 /* of the algorithms block size */
2227 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2228 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2229 ciphertext_pad_len);
2230 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2232 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2234 /* Create KASUMI operation */
2235 retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data,
2237 tdata->ciphertext.len,
2238 tdata->validCipherOffsetLenInBits.len,
2239 RTE_CRYPTO_CIPHER_KASUMI_F8);
2243 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2245 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2247 ut_params->obuf = ut_params->op->sym->m_dst;
2248 if (ut_params->obuf)
2249 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2252 plaintext = ciphertext;
2254 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2257 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2259 tdata->plaintext.data,
2260 tdata->validCipherLenInBits.len,
2261 "KASUMI Plaintext data not as expected");
2266 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2268 struct crypto_testsuite_params *ts_params = &testsuite_params;
2269 struct crypto_unittest_params *ut_params = &unittest_params;
2272 uint8_t *plaintext, *ciphertext;
2273 unsigned plaintext_pad_len;
2274 unsigned plaintext_len;
2276 /* Create SNOW3G session */
2277 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2278 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2279 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2280 tdata->key.data, tdata->key.len);
2284 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2286 /* Clear mbuf payload */
2287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2288 rte_pktmbuf_tailroom(ut_params->ibuf));
2290 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2291 /* Append data which is padded to a multiple of */
2292 /* the algorithms block size */
2293 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2294 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2296 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2298 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2300 /* Create SNOW3G operation */
2301 retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
2302 tdata->validCipherLenInBits.len,
2303 tdata->validCipherOffsetLenInBits.len,
2304 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2308 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2310 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2312 ut_params->obuf = ut_params->op->sym->m_dst;
2313 if (ut_params->obuf)
2314 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2317 ciphertext = plaintext;
2319 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2322 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2324 tdata->ciphertext.data,
2325 tdata->validDataLenInBits.len,
2326 "Snow3G Ciphertext data not as expected");
2332 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2334 struct crypto_testsuite_params *ts_params = &testsuite_params;
2335 struct crypto_unittest_params *ut_params = &unittest_params;
2336 uint8_t *plaintext, *ciphertext;
2339 unsigned plaintext_pad_len;
2340 unsigned plaintext_len;
2342 /* Create SNOW3G session */
2343 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2344 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2345 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2346 tdata->key.data, tdata->key.len);
2350 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2351 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2353 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2354 "Failed to allocate input buffer in mempool");
2355 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2356 "Failed to allocate output buffer in mempool");
2358 /* Clear mbuf payload */
2359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2360 rte_pktmbuf_tailroom(ut_params->ibuf));
2362 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2363 /* Append data which is padded to a multiple of */
2364 /* the algorithms block size */
2365 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2366 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2368 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2369 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2371 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2373 /* Create SNOW3G operation */
2374 retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
2376 tdata->validCipherLenInBits.len,
2377 tdata->validCipherOffsetLenInBits.len,
2378 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2382 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2384 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2386 ut_params->obuf = ut_params->op->sym->m_dst;
2387 if (ut_params->obuf)
2388 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2391 ciphertext = plaintext;
2393 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2396 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2398 tdata->ciphertext.data,
2399 tdata->validDataLenInBits.len,
2400 "Snow3G Ciphertext data not as expected");
2404 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2406 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2408 uint8_t curr_byte, prev_byte;
2409 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2410 uint8_t lower_byte_mask = (1 << offset) - 1;
2413 prev_byte = buffer[0];
2414 buffer[0] >>= offset;
2416 for (i = 1; i < length_in_bytes; i++) {
2417 curr_byte = buffer[i];
2418 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2419 (curr_byte >> offset);
2420 prev_byte = curr_byte;
2425 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2427 struct crypto_testsuite_params *ts_params = &testsuite_params;
2428 struct crypto_unittest_params *ut_params = &unittest_params;
2429 uint8_t *plaintext, *ciphertext;
2431 uint32_t plaintext_len;
2432 uint32_t plaintext_pad_len;
2433 uint8_t extra_offset = 4;
2434 uint8_t *expected_ciphertext_shifted;
2436 /* Create SNOW3G session */
2437 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2438 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2439 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2440 tdata->key.data, tdata->key.len);
2444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2445 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2447 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2448 "Failed to allocate input buffer in mempool");
2449 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2450 "Failed to allocate output buffer in mempool");
2452 /* Clear mbuf payload */
2453 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2454 rte_pktmbuf_tailroom(ut_params->ibuf));
2456 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2458 * Append data which is padded to a
2459 * multiple of the algorithms block size
2461 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2463 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2466 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2468 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2469 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2471 #ifdef RTE_APP_TEST_DEBUG
2472 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2474 /* Create SNOW3G operation */
2475 retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
2477 tdata->validCipherLenInBits.len,
2478 tdata->validCipherOffsetLenInBits.len +
2480 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2486 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2488 ut_params->obuf = ut_params->op->sym->m_dst;
2489 if (ut_params->obuf)
2490 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2493 ciphertext = plaintext;
2495 #ifdef RTE_APP_TEST_DEBUG
2496 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2499 expected_ciphertext_shifted = rte_malloc(NULL,
2500 ceil_byte_length(plaintext_len + extra_offset), 0);
2502 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2503 "failed to reserve memory for ciphertext shifted\n");
2505 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2506 ceil_byte_length(tdata->ciphertext.len));
2507 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2510 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2512 expected_ciphertext_shifted,
2513 tdata->validDataLenInBits.len,
2515 "Snow3G Ciphertext data not as expected");
2519 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2526 uint8_t *plaintext, *ciphertext;
2527 unsigned ciphertext_pad_len;
2528 unsigned ciphertext_len;
2530 /* Create SNOW3G session */
2531 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2532 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2533 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2534 tdata->key.data, tdata->key.len);
2538 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2540 /* Clear mbuf payload */
2541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2542 rte_pktmbuf_tailroom(ut_params->ibuf));
2544 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2545 /* Append data which is padded to a multiple of */
2546 /* the algorithms block size */
2547 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2548 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2549 ciphertext_pad_len);
2550 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2552 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2554 /* Create SNOW3G operation */
2555 retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
2556 tdata->validCipherLenInBits.len,
2557 tdata->validCipherOffsetLenInBits.len,
2558 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2562 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2564 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2565 ut_params->obuf = ut_params->op->sym->m_dst;
2566 if (ut_params->obuf)
2567 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2570 plaintext = ciphertext;
2572 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
2576 tdata->plaintext.data,
2577 tdata->validDataLenInBits.len,
2578 "Snow3G Plaintext data not as expected");
2582 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
2584 struct crypto_testsuite_params *ts_params = &testsuite_params;
2585 struct crypto_unittest_params *ut_params = &unittest_params;
2589 uint8_t *plaintext, *ciphertext;
2590 unsigned ciphertext_pad_len;
2591 unsigned ciphertext_len;
2593 /* Create SNOW3G session */
2594 retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
2595 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2596 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2597 tdata->key.data, tdata->key.len);
2601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2602 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2604 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2605 "Failed to allocate input buffer");
2606 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2607 "Failed to allocate output buffer");
2609 /* Clear mbuf payload */
2610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2611 rte_pktmbuf_tailroom(ut_params->ibuf));
2613 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
2614 rte_pktmbuf_tailroom(ut_params->obuf));
2616 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2617 /* Append data which is padded to a multiple of */
2618 /* the algorithms block size */
2619 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2620 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2621 ciphertext_pad_len);
2622 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2623 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2625 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2627 /* Create SNOW3G operation */
2628 retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
2630 tdata->validCipherLenInBits.len,
2631 tdata->validCipherOffsetLenInBits.len,
2632 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2636 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2638 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2639 ut_params->obuf = ut_params->op->sym->m_dst;
2640 if (ut_params->obuf)
2641 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2644 plaintext = ciphertext;
2646 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2649 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
2650 tdata->plaintext.data,
2651 tdata->validDataLenInBits.len,
2652 "Snow3G Plaintext data not as expected");
2657 test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
2659 struct crypto_testsuite_params *ts_params = &testsuite_params;
2660 struct crypto_unittest_params *ut_params = &unittest_params;
2664 uint8_t *plaintext, *ciphertext;
2665 unsigned plaintext_pad_len;
2666 unsigned plaintext_len;
2668 /* Create SNOW3G session */
2669 retval = create_snow3g_kasumi_cipher_auth_session(ts_params->valid_devs[0],
2670 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2671 RTE_CRYPTO_AUTH_OP_GENERATE,
2672 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2673 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2674 tdata->key.data, tdata->key.len,
2675 tdata->aad.len, tdata->digest.len);
2678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2680 /* clear mbuf payload */
2681 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2682 rte_pktmbuf_tailroom(ut_params->ibuf));
2684 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2685 /* Append data which is padded to a multiple of */
2686 /* the algorithms block size */
2687 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2688 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2690 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2692 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2694 /* Create SNOW3G operation */
2695 retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data,
2696 tdata->digest.len, tdata->aad.data,
2697 tdata->aad.len, /*tdata->plaintext.len,*/
2698 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2699 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2700 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2701 tdata->iv.data, tdata->iv.len,
2702 tdata->validCipherLenInBits.len,
2703 tdata->validCipherOffsetLenInBits.len,
2704 tdata->validAuthLenInBits.len,
2705 tdata->validAuthOffsetLenInBits.len
2710 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2712 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2713 ut_params->obuf = ut_params->op->sym->m_src;
2714 if (ut_params->obuf)
2715 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2718 ciphertext = plaintext;
2720 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2723 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2725 tdata->ciphertext.data,
2726 tdata->validDataLenInBits.len,
2727 "Snow3G Ciphertext data not as expected");
2729 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2730 + plaintext_pad_len + tdata->aad.len;
2733 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2736 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2737 "Snow3G Generated auth tag not as expected");
2741 test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
2743 struct crypto_testsuite_params *ts_params = &testsuite_params;
2744 struct crypto_unittest_params *ut_params = &unittest_params;
2748 uint8_t *plaintext, *ciphertext;
2749 unsigned plaintext_pad_len;
2750 unsigned plaintext_len;
2752 /* Create SNOW3G session */
2753 retval = create_snow3g_kasumi_auth_cipher_session(ts_params->valid_devs[0],
2754 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2755 RTE_CRYPTO_AUTH_OP_GENERATE,
2756 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2757 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2758 tdata->key.data, tdata->key.len,
2759 tdata->aad.len, tdata->digest.len);
2763 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2765 /* clear mbuf payload */
2766 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2767 rte_pktmbuf_tailroom(ut_params->ibuf));
2769 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2770 /* Append data which is padded to a multiple of */
2771 /* the algorithms block size */
2772 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2775 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2777 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2779 /* Create SNOW3G operation */
2780 retval = create_snow3g_kasumi_auth_cipher_operation(
2782 tdata->iv.data, tdata->iv.len,
2783 tdata->aad.data, tdata->aad.len,
2785 tdata->validCipherLenInBits.len,
2786 tdata->validCipherOffsetLenInBits.len,
2787 tdata->validAuthLenInBits.len,
2788 tdata->validAuthOffsetLenInBits.len,
2789 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2790 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
2796 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2798 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2799 ut_params->obuf = ut_params->op->sym->m_src;
2800 if (ut_params->obuf)
2801 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2802 + tdata->aad.len + tdata->iv.len;
2804 ciphertext = plaintext;
2806 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2807 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
2808 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2811 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2813 tdata->ciphertext.data,
2814 tdata->validDataLenInBits.len,
2815 "Snow3G Ciphertext data not as expected");
2818 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2821 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2822 "Snow3G Generated auth tag not as expected");
2827 test_kasumi_encryption_test_case_1(void)
2829 return test_kasumi_encryption(&kasumi_test_case_1);
2833 test_kasumi_encryption_test_case_1_oop(void)
2835 return test_kasumi_encryption_oop(&kasumi_test_case_1);
2839 test_kasumi_encryption_test_case_2(void)
2841 return test_kasumi_encryption(&kasumi_test_case_2);
2845 test_kasumi_encryption_test_case_3(void)
2847 return test_kasumi_encryption(&kasumi_test_case_3);
2851 test_kasumi_encryption_test_case_4(void)
2853 return test_kasumi_encryption(&kasumi_test_case_4);
2857 test_kasumi_encryption_test_case_5(void)
2859 return test_kasumi_encryption(&kasumi_test_case_5);
2863 test_kasumi_decryption_test_case_1(void)
2865 return test_kasumi_decryption(&kasumi_test_case_1);
2869 test_kasumi_decryption_test_case_1_oop(void)
2871 return test_kasumi_decryption_oop(&kasumi_test_case_1);
2875 test_kasumi_decryption_test_case_2(void)
2877 return test_kasumi_decryption(&kasumi_test_case_2);
2881 test_kasumi_decryption_test_case_3(void)
2883 return test_kasumi_decryption(&kasumi_test_case_3);
2887 test_kasumi_decryption_test_case_4(void)
2889 return test_kasumi_decryption(&kasumi_test_case_4);
2893 test_kasumi_decryption_test_case_5(void)
2895 return test_kasumi_decryption(&kasumi_test_case_5);
2898 test_snow3g_encryption_test_case_1(void)
2900 return test_snow3g_encryption(&snow3g_test_case_1);
2904 test_snow3g_encryption_test_case_1_oop(void)
2906 return test_snow3g_encryption_oop(&snow3g_test_case_1);
2910 test_snow3g_encryption_test_case_1_offset_oop(void)
2912 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
2916 test_snow3g_encryption_test_case_2(void)
2918 return test_snow3g_encryption(&snow3g_test_case_2);
2922 test_snow3g_encryption_test_case_3(void)
2924 return test_snow3g_encryption(&snow3g_test_case_3);
2928 test_snow3g_encryption_test_case_4(void)
2930 return test_snow3g_encryption(&snow3g_test_case_4);
2934 test_snow3g_encryption_test_case_5(void)
2936 return test_snow3g_encryption(&snow3g_test_case_5);
2940 test_snow3g_decryption_test_case_1(void)
2942 return test_snow3g_decryption(&snow3g_test_case_1);
2946 test_snow3g_decryption_test_case_1_oop(void)
2948 return test_snow3g_decryption_oop(&snow3g_test_case_1);
2952 test_snow3g_decryption_test_case_2(void)
2954 return test_snow3g_decryption(&snow3g_test_case_2);
2958 test_snow3g_decryption_test_case_3(void)
2960 return test_snow3g_decryption(&snow3g_test_case_3);
2964 test_snow3g_decryption_test_case_4(void)
2966 return test_snow3g_decryption(&snow3g_test_case_4);
2970 test_snow3g_decryption_test_case_5(void)
2972 return test_snow3g_decryption(&snow3g_test_case_5);
2975 test_snow3g_authenticated_encryption_test_case_1(void)
2977 return test_snow3g_authenticated_encryption(&snow3g_test_case_3);
2981 test_snow3g_encrypted_authentication_test_case_1(void)
2983 return test_snow3g_encrypted_authentication(&snow3g_test_case_6);
2986 /* ***** AES-GCM Tests ***** */
2989 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
2990 const uint8_t *key, const uint8_t key_len,
2991 const uint8_t aad_len, const uint8_t auth_len)
2993 uint8_t cipher_key[key_len];
2995 struct crypto_unittest_params *ut_params = &unittest_params;
2998 memcpy(cipher_key, key, key_len);
3000 /* Setup Cipher Parameters */
3001 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3002 ut_params->cipher_xform.next = NULL;
3004 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3005 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3006 ut_params->cipher_xform.cipher.op = op;
3007 ut_params->cipher_xform.cipher.key.data = cipher_key;
3008 ut_params->cipher_xform.cipher.key.length = key_len;
3010 TEST_HEXDUMP(stdout, "key:", key, key_len);
3012 /* Setup Authentication Parameters */
3013 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3014 ut_params->auth_xform.next = NULL;
3016 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3018 ut_params->auth_xform.auth.digest_length = auth_len;
3019 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3020 ut_params->auth_xform.auth.key.length = 0;
3021 ut_params->auth_xform.auth.key.data = NULL;
3023 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3024 ut_params->cipher_xform.next = &ut_params->auth_xform;
3026 /* Create Crypto session*/
3027 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3028 &ut_params->cipher_xform);
3029 } else {/* Create Crypto session*/
3030 ut_params->auth_xform.next = &ut_params->cipher_xform;
3031 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3032 &ut_params->auth_xform);
3035 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3041 create_gcm_operation(enum rte_crypto_cipher_operation op,
3042 const uint8_t *auth_tag, const unsigned auth_tag_len,
3043 const uint8_t *iv, const unsigned iv_len,
3044 const uint8_t *aad, const unsigned aad_len,
3045 const unsigned data_len, unsigned data_pad_len)
3047 struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 struct crypto_unittest_params *ut_params = &unittest_params;
3050 unsigned iv_pad_len = 0, aad_buffer_len;
3052 /* Generate Crypto op data structure */
3053 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3054 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3055 TEST_ASSERT_NOT_NULL(ut_params->op,
3056 "Failed to allocate symmetric crypto operation struct");
3058 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3062 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3063 ut_params->ibuf, auth_tag_len);
3064 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3065 "no room to append digest");
3066 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3067 ut_params->ibuf, data_pad_len);
3068 sym_op->auth.digest.length = auth_tag_len;
3070 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3071 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3072 TEST_HEXDUMP(stdout, "digest:",
3073 sym_op->auth.digest.data,
3074 sym_op->auth.digest.length);
3078 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3080 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3081 ut_params->ibuf, iv_pad_len);
3082 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3084 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3085 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3086 sym_op->cipher.iv.length = iv_pad_len;
3088 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3092 sym_op->cipher.iv.data[15] = 1;
3095 * Always allocate the aad up to the block size.
3096 * The cryptodev API calls out -
3097 * - the array must be big enough to hold the AAD, plus any
3098 * space to round this up to the nearest multiple of the
3099 * block size (16 bytes).
3101 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3103 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3104 ut_params->ibuf, aad_buffer_len);
3105 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3106 "no room to prepend aad");
3107 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3109 sym_op->auth.aad.length = aad_len;
3111 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3112 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3114 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3115 TEST_HEXDUMP(stdout, "aad:",
3116 sym_op->auth.aad.data, aad_len);
3118 sym_op->cipher.data.length = data_len;
3119 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3121 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3122 sym_op->auth.data.length = data_len;
3128 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3130 struct crypto_testsuite_params *ts_params = &testsuite_params;
3131 struct crypto_unittest_params *ut_params = &unittest_params;
3135 uint8_t *plaintext, *ciphertext, *auth_tag;
3136 uint16_t plaintext_pad_len;
3138 /* Create GCM session */
3139 retval = create_gcm_session(ts_params->valid_devs[0],
3140 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3141 tdata->key.data, tdata->key.len,
3142 tdata->aad.len, tdata->auth_tag.len);
3147 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3149 /* clear mbuf payload */
3150 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3151 rte_pktmbuf_tailroom(ut_params->ibuf));
3154 * Append data which is padded to a multiple
3155 * of the algorithms block size
3157 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
3159 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3161 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
3163 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3165 /* Create GCM opertaion */
3166 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3167 tdata->auth_tag.data, tdata->auth_tag.len,
3168 tdata->iv.data, tdata->iv.len,
3169 tdata->aad.data, tdata->aad.len,
3170 tdata->plaintext.len, plaintext_pad_len);
3174 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3176 ut_params->op->sym->m_src = ut_params->ibuf;
3178 /* Process crypto operation */
3179 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3180 ut_params->op), "failed to process sym crypto op");
3182 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3183 "crypto op processing failed");
3185 if (ut_params->op->sym->m_dst) {
3186 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3188 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
3189 uint8_t *, plaintext_pad_len);
3191 ciphertext = plaintext;
3192 auth_tag = plaintext + plaintext_pad_len;
3195 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3196 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
3199 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3201 tdata->ciphertext.data,
3202 tdata->ciphertext.len,
3203 "GCM Ciphertext data not as expected");
3205 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3207 tdata->auth_tag.data,
3208 tdata->auth_tag.len,
3209 "GCM Generated auth tag not as expected");
3216 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
3218 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
3222 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
3224 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
3228 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
3230 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
3234 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
3236 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
3240 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
3242 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
3246 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
3248 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
3252 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
3254 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
3258 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3265 uint8_t *plaintext, *ciphertext;
3266 uint16_t ciphertext_pad_len;
3268 /* Create GCM session */
3269 retval = create_gcm_session(ts_params->valid_devs[0],
3270 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3271 tdata->key.data, tdata->key.len,
3272 tdata->aad.len, tdata->auth_tag.len);
3277 /* alloc mbuf and set payload */
3278 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3281 rte_pktmbuf_tailroom(ut_params->ibuf));
3283 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
3285 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3286 ciphertext_pad_len);
3287 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
3289 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3291 /* Create GCM opertaion */
3292 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
3293 tdata->auth_tag.data, tdata->auth_tag.len,
3294 tdata->iv.data, tdata->iv.len,
3295 tdata->aad.data, tdata->aad.len,
3296 tdata->ciphertext.len, ciphertext_pad_len);
3301 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3303 ut_params->op->sym->m_src = ut_params->ibuf;
3305 /* Process crypto operation */
3306 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3307 ut_params->op), "failed to process sym crypto op");
3309 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3310 "crypto op processing failed");
3312 if (ut_params->op->sym->m_dst)
3313 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3316 plaintext = ciphertext;
3318 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
3321 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3323 tdata->plaintext.data,
3324 tdata->plaintext.len,
3325 "GCM plaintext data not as expected");
3327 TEST_ASSERT_EQUAL(ut_params->op->status,
3328 RTE_CRYPTO_OP_STATUS_SUCCESS,
3329 "GCM authentication failed");
3334 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
3336 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
3340 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
3342 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
3346 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
3348 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
3352 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
3354 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
3358 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
3360 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
3364 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
3366 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
3370 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
3372 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
3378 struct crypto_testsuite_params *ts_params = &testsuite_params;
3379 struct rte_cryptodev_stats stats;
3380 struct rte_cryptodev *dev;
3381 cryptodev_stats_get_t temp_pfn;
3383 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3384 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
3385 &stats) == -ENODEV),
3386 "rte_cryptodev_stats_get invalid dev failed");
3387 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
3388 "rte_cryptodev_stats_get invalid Param failed");
3389 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
3390 temp_pfn = dev->dev_ops->stats_get;
3391 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
3392 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
3394 "rte_cryptodev_stats_get invalid Param failed");
3395 dev->dev_ops->stats_get = temp_pfn;
3397 /* Test expected values */
3399 test_AES_CBC_HMAC_SHA1_encrypt_digest();
3401 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3403 "rte_cryptodev_stats_get failed");
3404 TEST_ASSERT((stats.enqueued_count == 1),
3405 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3406 TEST_ASSERT((stats.dequeued_count == 1),
3407 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3408 TEST_ASSERT((stats.enqueue_err_count == 0),
3409 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3410 TEST_ASSERT((stats.dequeue_err_count == 0),
3411 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3413 /* invalid device but should ignore and not reset device stats*/
3414 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
3415 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3417 "rte_cryptodev_stats_get failed");
3418 TEST_ASSERT((stats.enqueued_count == 1),
3419 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3421 /* check that a valid reset clears stats */
3422 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3423 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3425 "rte_cryptodev_stats_get failed");
3426 TEST_ASSERT((stats.enqueued_count == 0),
3427 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3428 TEST_ASSERT((stats.dequeued_count == 0),
3429 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3431 return TEST_SUCCESS;
3436 test_multi_session(void)
3438 struct crypto_testsuite_params *ts_params = &testsuite_params;
3439 struct crypto_unittest_params *ut_params = &unittest_params;
3441 struct rte_cryptodev_info dev_info;
3442 struct rte_cryptodev_sym_session **sessions;
3446 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params);
3449 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3451 sessions = rte_malloc(NULL,
3452 (sizeof(struct rte_cryptodev_sym_session *) *
3453 dev_info.sym.max_nb_sessions) + 1, 0);
3455 /* Create multiple crypto sessions*/
3456 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
3457 sessions[i] = rte_cryptodev_sym_session_create(
3458 ts_params->valid_devs[0],
3459 &ut_params->auth_xform);
3460 TEST_ASSERT_NOT_NULL(sessions[i],
3461 "Session creation failed at session number %u",
3464 /* Attempt to send a request on each session */
3465 TEST_ASSERT_SUCCESS(test_AES_CBC_HMAC_SHA512_decrypt_perform(
3466 sessions[i], ut_params, ts_params),
3467 "Failed to perform decrypt on request "
3469 /* free crypto operation structure */
3471 rte_crypto_op_free(ut_params->op);
3474 * free mbuf - both obuf and ibuf are usually the same,
3475 * so check if they point at the same address is necessary,
3476 * to avoid freeing the mbuf twice.
3478 if (ut_params->obuf) {
3479 rte_pktmbuf_free(ut_params->obuf);
3480 if (ut_params->ibuf == ut_params->obuf)
3481 ut_params->ibuf = 0;
3482 ut_params->obuf = 0;
3484 if (ut_params->ibuf) {
3485 rte_pktmbuf_free(ut_params->ibuf);
3486 ut_params->ibuf = 0;
3490 /* Next session create should fail */
3491 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
3492 &ut_params->auth_xform);
3493 TEST_ASSERT_NULL(sessions[i],
3494 "Session creation succeeded unexpectedly!");
3496 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
3497 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
3502 return TEST_SUCCESS;
3506 test_null_cipher_only_operation(void)
3508 struct crypto_testsuite_params *ts_params = &testsuite_params;
3509 struct crypto_unittest_params *ut_params = &unittest_params;
3511 /* Generate test mbuf data and space for digest */
3512 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3513 catch_22_quote, QUOTE_512_BYTES, 0);
3515 /* Setup Cipher Parameters */
3516 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3517 ut_params->cipher_xform.next = NULL;
3519 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3520 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3522 /* Create Crypto session*/
3523 ut_params->sess = rte_cryptodev_sym_session_create(
3524 ts_params->valid_devs[0], &ut_params->cipher_xform);
3525 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3527 /* Generate Crypto op data structure */
3528 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3529 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3530 TEST_ASSERT_NOT_NULL(ut_params->op,
3531 "Failed to allocate symmetric crypto operation struct");
3533 /* Set crypto operation data parameters */
3534 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3536 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3538 /* set crypto operation source mbuf */
3539 sym_op->m_src = ut_params->ibuf;
3541 sym_op->cipher.data.offset = 0;
3542 sym_op->cipher.data.length = QUOTE_512_BYTES;
3544 /* Process crypto operation */
3545 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3547 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3549 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3550 "crypto operation processing failed");
3553 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3554 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3557 "Ciphertext data not as expected");
3559 return TEST_SUCCESS;
3563 test_null_auth_only_operation(void)
3565 struct crypto_testsuite_params *ts_params = &testsuite_params;
3566 struct crypto_unittest_params *ut_params = &unittest_params;
3568 /* Generate test mbuf data and space for digest */
3569 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3570 catch_22_quote, QUOTE_512_BYTES, 0);
3572 /* Setup HMAC Parameters */
3573 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3574 ut_params->auth_xform.next = NULL;
3576 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3577 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3579 /* Create Crypto session*/
3580 ut_params->sess = rte_cryptodev_sym_session_create(
3581 ts_params->valid_devs[0], &ut_params->auth_xform);
3582 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3584 /* Generate Crypto op data structure */
3585 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3586 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3587 TEST_ASSERT_NOT_NULL(ut_params->op,
3588 "Failed to allocate symmetric crypto operation struct");
3590 /* Set crypto operation data parameters */
3591 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3593 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3595 sym_op->m_src = ut_params->ibuf;
3597 sym_op->auth.data.offset = 0;
3598 sym_op->auth.data.length = QUOTE_512_BYTES;
3600 /* Process crypto operation */
3601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3603 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3605 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3606 "crypto operation processing failed");
3608 return TEST_SUCCESS;
3612 test_null_cipher_auth_operation(void)
3614 struct crypto_testsuite_params *ts_params = &testsuite_params;
3615 struct crypto_unittest_params *ut_params = &unittest_params;
3617 /* Generate test mbuf data and space for digest */
3618 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3619 catch_22_quote, QUOTE_512_BYTES, 0);
3621 /* Setup Cipher Parameters */
3622 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3623 ut_params->cipher_xform.next = &ut_params->auth_xform;
3625 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3626 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3628 /* Setup HMAC Parameters */
3629 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3630 ut_params->auth_xform.next = NULL;
3632 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3633 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3635 /* Create Crypto session*/
3636 ut_params->sess = rte_cryptodev_sym_session_create(
3637 ts_params->valid_devs[0], &ut_params->cipher_xform);
3638 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3640 /* Generate Crypto op data structure */
3641 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3642 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3643 TEST_ASSERT_NOT_NULL(ut_params->op,
3644 "Failed to allocate symmetric crypto operation struct");
3646 /* Set crypto operation data parameters */
3647 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3649 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3651 sym_op->m_src = ut_params->ibuf;
3653 sym_op->cipher.data.offset = 0;
3654 sym_op->cipher.data.length = QUOTE_512_BYTES;
3656 sym_op->auth.data.offset = 0;
3657 sym_op->auth.data.length = QUOTE_512_BYTES;
3659 /* Process crypto operation */
3660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3662 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3664 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3665 "crypto operation processing failed");
3668 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3669 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3672 "Ciphertext data not as expected");
3674 return TEST_SUCCESS;
3678 test_null_auth_cipher_operation(void)
3680 struct crypto_testsuite_params *ts_params = &testsuite_params;
3681 struct crypto_unittest_params *ut_params = &unittest_params;
3683 /* Generate test mbuf data and space for digest */
3684 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3685 catch_22_quote, QUOTE_512_BYTES, 0);
3687 /* Setup Cipher Parameters */
3688 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3689 ut_params->cipher_xform.next = NULL;
3691 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3692 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3694 /* Setup HMAC Parameters */
3695 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3696 ut_params->auth_xform.next = &ut_params->cipher_xform;
3698 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3699 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3701 /* Create Crypto session*/
3702 ut_params->sess = rte_cryptodev_sym_session_create(
3703 ts_params->valid_devs[0], &ut_params->cipher_xform);
3704 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3706 /* Generate Crypto op data structure */
3707 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3708 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3709 TEST_ASSERT_NOT_NULL(ut_params->op,
3710 "Failed to allocate symmetric crypto operation struct");
3712 /* Set crypto operation data parameters */
3713 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3715 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3717 sym_op->m_src = ut_params->ibuf;
3719 sym_op->cipher.data.offset = 0;
3720 sym_op->cipher.data.length = QUOTE_512_BYTES;
3722 sym_op->auth.data.offset = 0;
3723 sym_op->auth.data.length = QUOTE_512_BYTES;
3725 /* Process crypto operation */
3726 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3728 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3730 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3731 "crypto operation processing failed");
3734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3735 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3738 "Ciphertext data not as expected");
3740 return TEST_SUCCESS;
3745 test_null_invalid_operation(void)
3747 struct crypto_testsuite_params *ts_params = &testsuite_params;
3748 struct crypto_unittest_params *ut_params = &unittest_params;
3750 /* Setup Cipher Parameters */
3751 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3752 ut_params->cipher_xform.next = NULL;
3754 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
3755 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3757 /* Create Crypto session*/
3758 ut_params->sess = rte_cryptodev_sym_session_create(
3759 ts_params->valid_devs[0], &ut_params->cipher_xform);
3760 TEST_ASSERT_NULL(ut_params->sess,
3761 "Session creation succeeded unexpectedly");
3764 /* Setup HMAC Parameters */
3765 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3766 ut_params->auth_xform.next = NULL;
3768 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
3769 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3771 /* Create Crypto session*/
3772 ut_params->sess = rte_cryptodev_sym_session_create(
3773 ts_params->valid_devs[0], &ut_params->auth_xform);
3774 TEST_ASSERT_NULL(ut_params->sess,
3775 "Session creation succeeded unexpectedly");
3777 return TEST_SUCCESS;
3781 #define NULL_BURST_LENGTH (32)
3784 test_null_burst_operation(void)
3786 struct crypto_testsuite_params *ts_params = &testsuite_params;
3787 struct crypto_unittest_params *ut_params = &unittest_params;
3789 unsigned i, burst_len = NULL_BURST_LENGTH;
3791 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
3792 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
3794 /* Setup Cipher Parameters */
3795 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3796 ut_params->cipher_xform.next = &ut_params->auth_xform;
3798 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3799 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3801 /* Setup HMAC Parameters */
3802 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3803 ut_params->auth_xform.next = NULL;
3805 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3806 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3808 /* Create Crypto session*/
3809 ut_params->sess = rte_cryptodev_sym_session_create(
3810 ts_params->valid_devs[0], &ut_params->cipher_xform);
3811 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3813 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3814 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
3815 burst_len, "failed to generate burst of crypto ops");
3817 /* Generate an operation for each mbuf in burst */
3818 for (i = 0; i < burst_len; i++) {
3819 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3821 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
3823 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
3827 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
3829 burst[i]->sym->m_src = m;
3832 /* Process crypto operation */
3833 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
3834 0, burst, burst_len),
3836 "Error enqueuing burst");
3838 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
3839 0, burst_dequeued, burst_len),
3841 "Error dequeuing burst");
3844 for (i = 0; i < burst_len; i++) {
3846 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
3847 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
3849 "data not as expected");
3851 rte_pktmbuf_free(burst[i]->sym->m_src);
3852 rte_crypto_op_free(burst[i]);
3855 return TEST_SUCCESS;
3861 static struct unit_test_suite cryptodev_qat_testsuite = {
3862 .suite_name = "Crypto QAT Unit Test Suite",
3863 .setup = testsuite_setup,
3864 .teardown = testsuite_teardown,
3865 .unit_test_cases = {
3866 TEST_CASE_ST(ut_setup, ut_teardown,
3867 test_device_configure_invalid_dev_id),
3868 TEST_CASE_ST(ut_setup, ut_teardown,
3869 test_device_configure_invalid_queue_pair_ids),
3870 TEST_CASE_ST(ut_setup, ut_teardown,
3871 test_queue_pair_descriptor_setup),
3872 TEST_CASE_ST(ut_setup, ut_teardown,
3873 test_multi_session),
3875 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_qat_all),
3876 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
3878 /** AES GCM Authenticated Encryption */
3879 TEST_CASE_ST(ut_setup, ut_teardown,
3880 test_mb_AES_GCM_authenticated_encryption_test_case_1),
3881 TEST_CASE_ST(ut_setup, ut_teardown,
3882 test_mb_AES_GCM_authenticated_encryption_test_case_2),
3883 TEST_CASE_ST(ut_setup, ut_teardown,
3884 test_mb_AES_GCM_authenticated_encryption_test_case_3),
3885 TEST_CASE_ST(ut_setup, ut_teardown,
3886 test_mb_AES_GCM_authenticated_encryption_test_case_4),
3887 TEST_CASE_ST(ut_setup, ut_teardown,
3888 test_mb_AES_GCM_authenticated_encryption_test_case_5),
3889 TEST_CASE_ST(ut_setup, ut_teardown,
3890 test_mb_AES_GCM_authenticated_encryption_test_case_6),
3891 TEST_CASE_ST(ut_setup, ut_teardown,
3892 test_mb_AES_GCM_authenticated_encryption_test_case_7),
3894 /** AES GCM Authenticated Decryption */
3895 TEST_CASE_ST(ut_setup, ut_teardown,
3896 test_mb_AES_GCM_authenticated_decryption_test_case_1),
3897 TEST_CASE_ST(ut_setup, ut_teardown,
3898 test_mb_AES_GCM_authenticated_decryption_test_case_2),
3899 TEST_CASE_ST(ut_setup, ut_teardown,
3900 test_mb_AES_GCM_authenticated_decryption_test_case_3),
3901 TEST_CASE_ST(ut_setup, ut_teardown,
3902 test_mb_AES_GCM_authenticated_decryption_test_case_4),
3903 TEST_CASE_ST(ut_setup, ut_teardown,
3904 test_mb_AES_GCM_authenticated_decryption_test_case_5),
3905 TEST_CASE_ST(ut_setup, ut_teardown,
3906 test_mb_AES_GCM_authenticated_decryption_test_case_6),
3907 TEST_CASE_ST(ut_setup, ut_teardown,
3908 test_mb_AES_GCM_authenticated_decryption_test_case_7),
3910 /** Snow3G encrypt only (UEA2) */
3911 TEST_CASE_ST(ut_setup, ut_teardown,
3912 test_snow3g_encryption_test_case_1),
3913 TEST_CASE_ST(ut_setup, ut_teardown,
3914 test_snow3g_encryption_test_case_2),
3915 TEST_CASE_ST(ut_setup, ut_teardown,
3916 test_snow3g_encryption_test_case_3),
3917 TEST_CASE_ST(ut_setup, ut_teardown,
3918 test_snow3g_encryption_test_case_4),
3919 TEST_CASE_ST(ut_setup, ut_teardown,
3920 test_snow3g_encryption_test_case_5),
3922 TEST_CASE_ST(ut_setup, ut_teardown,
3923 test_snow3g_encryption_test_case_1_oop),
3924 TEST_CASE_ST(ut_setup, ut_teardown,
3925 test_snow3g_decryption_test_case_1_oop),
3927 /** Snow3G decrypt only (UEA2) */
3928 TEST_CASE_ST(ut_setup, ut_teardown,
3929 test_snow3g_decryption_test_case_1),
3930 TEST_CASE_ST(ut_setup, ut_teardown,
3931 test_snow3g_decryption_test_case_2),
3932 TEST_CASE_ST(ut_setup, ut_teardown,
3933 test_snow3g_decryption_test_case_3),
3934 TEST_CASE_ST(ut_setup, ut_teardown,
3935 test_snow3g_decryption_test_case_4),
3936 TEST_CASE_ST(ut_setup, ut_teardown,
3937 test_snow3g_decryption_test_case_5),
3938 TEST_CASE_ST(ut_setup, ut_teardown,
3939 test_snow3g_hash_generate_test_case_1),
3940 TEST_CASE_ST(ut_setup, ut_teardown,
3941 test_snow3g_hash_generate_test_case_2),
3942 TEST_CASE_ST(ut_setup, ut_teardown,
3943 test_snow3g_hash_generate_test_case_3),
3944 TEST_CASE_ST(ut_setup, ut_teardown,
3945 test_snow3g_hash_verify_test_case_1),
3946 TEST_CASE_ST(ut_setup, ut_teardown,
3947 test_snow3g_hash_verify_test_case_2),
3948 TEST_CASE_ST(ut_setup, ut_teardown,
3949 test_snow3g_hash_verify_test_case_3),
3950 TEST_CASE_ST(ut_setup, ut_teardown,
3951 test_snow3g_authenticated_encryption_test_case_1),
3952 TEST_CASE_ST(ut_setup, ut_teardown,
3953 test_snow3g_encrypted_authentication_test_case_1),
3954 TEST_CASES_END() /**< NULL terminate unit test array */
3958 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
3959 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
3960 .setup = testsuite_setup,
3961 .teardown = testsuite_teardown,
3962 .unit_test_cases = {
3963 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_mb_all),
3965 TEST_CASES_END() /**< NULL terminate unit test array */
3969 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
3970 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
3971 .setup = testsuite_setup,
3972 .teardown = testsuite_teardown,
3973 .unit_test_cases = {
3974 /** AES GCM Authenticated Encryption */
3975 TEST_CASE_ST(ut_setup, ut_teardown,
3976 test_mb_AES_GCM_authenticated_encryption_test_case_1),
3977 TEST_CASE_ST(ut_setup, ut_teardown,
3978 test_mb_AES_GCM_authenticated_encryption_test_case_2),
3979 TEST_CASE_ST(ut_setup, ut_teardown,
3980 test_mb_AES_GCM_authenticated_encryption_test_case_3),
3981 TEST_CASE_ST(ut_setup, ut_teardown,
3982 test_mb_AES_GCM_authenticated_encryption_test_case_4),
3983 TEST_CASE_ST(ut_setup, ut_teardown,
3984 test_mb_AES_GCM_authenticated_encryption_test_case_5),
3985 TEST_CASE_ST(ut_setup, ut_teardown,
3986 test_mb_AES_GCM_authenticated_encryption_test_case_6),
3987 TEST_CASE_ST(ut_setup, ut_teardown,
3988 test_mb_AES_GCM_authenticated_encryption_test_case_7),
3990 /** AES GCM Authenticated Decryption */
3991 TEST_CASE_ST(ut_setup, ut_teardown,
3992 test_mb_AES_GCM_authenticated_decryption_test_case_1),
3993 TEST_CASE_ST(ut_setup, ut_teardown,
3994 test_mb_AES_GCM_authenticated_decryption_test_case_2),
3995 TEST_CASE_ST(ut_setup, ut_teardown,
3996 test_mb_AES_GCM_authenticated_decryption_test_case_3),
3997 TEST_CASE_ST(ut_setup, ut_teardown,
3998 test_mb_AES_GCM_authenticated_decryption_test_case_4),
3999 TEST_CASE_ST(ut_setup, ut_teardown,
4000 test_mb_AES_GCM_authenticated_decryption_test_case_5),
4001 TEST_CASE_ST(ut_setup, ut_teardown,
4002 test_mb_AES_GCM_authenticated_decryption_test_case_6),
4003 TEST_CASE_ST(ut_setup, ut_teardown,
4004 test_mb_AES_GCM_authenticated_decryption_test_case_7),
4006 TEST_CASES_END() /**< NULL terminate unit test array */
4010 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
4011 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
4012 .setup = testsuite_setup,
4013 .teardown = testsuite_teardown,
4014 .unit_test_cases = {
4015 /** KASUMI encrypt only (UEA1) */
4016 TEST_CASE_ST(ut_setup, ut_teardown,
4017 test_kasumi_encryption_test_case_1),
4018 TEST_CASE_ST(ut_setup, ut_teardown,
4019 test_kasumi_encryption_test_case_2),
4020 TEST_CASE_ST(ut_setup, ut_teardown,
4021 test_kasumi_encryption_test_case_3),
4022 TEST_CASE_ST(ut_setup, ut_teardown,
4023 test_kasumi_encryption_test_case_4),
4024 TEST_CASE_ST(ut_setup, ut_teardown,
4025 test_kasumi_encryption_test_case_5),
4026 /** KASUMI decrypt only (UEA1) */
4027 TEST_CASE_ST(ut_setup, ut_teardown,
4028 test_kasumi_decryption_test_case_1),
4029 TEST_CASE_ST(ut_setup, ut_teardown,
4030 test_kasumi_decryption_test_case_2),
4031 TEST_CASE_ST(ut_setup, ut_teardown,
4032 test_kasumi_decryption_test_case_3),
4033 TEST_CASE_ST(ut_setup, ut_teardown,
4034 test_kasumi_decryption_test_case_4),
4035 TEST_CASE_ST(ut_setup, ut_teardown,
4036 test_kasumi_decryption_test_case_5),
4038 TEST_CASE_ST(ut_setup, ut_teardown,
4039 test_kasumi_encryption_test_case_1_oop),
4040 TEST_CASE_ST(ut_setup, ut_teardown,
4041 test_kasumi_decryption_test_case_1_oop),
4043 /** KASUMI hash only (UIA1) */
4044 TEST_CASE_ST(ut_setup, ut_teardown,
4045 test_kasumi_hash_generate_test_case_1),
4046 TEST_CASE_ST(ut_setup, ut_teardown,
4047 test_kasumi_hash_generate_test_case_2),
4048 TEST_CASE_ST(ut_setup, ut_teardown,
4049 test_kasumi_hash_generate_test_case_3),
4050 TEST_CASE_ST(ut_setup, ut_teardown,
4051 test_kasumi_hash_generate_test_case_4),
4052 TEST_CASE_ST(ut_setup, ut_teardown,
4053 test_kasumi_hash_generate_test_case_5),
4054 TEST_CASE_ST(ut_setup, ut_teardown,
4055 test_kasumi_hash_verify_test_case_1),
4056 TEST_CASE_ST(ut_setup, ut_teardown,
4057 test_kasumi_hash_verify_test_case_2),
4058 TEST_CASE_ST(ut_setup, ut_teardown,
4059 test_kasumi_hash_verify_test_case_3),
4060 TEST_CASE_ST(ut_setup, ut_teardown,
4061 test_kasumi_hash_verify_test_case_4),
4062 TEST_CASE_ST(ut_setup, ut_teardown,
4063 test_kasumi_hash_verify_test_case_5),
4065 TEST_CASES_END() /**< NULL terminate unit test array */
4068 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
4069 .suite_name = "Crypto Device SW Snow3G Unit Test Suite",
4070 .setup = testsuite_setup,
4071 .teardown = testsuite_teardown,
4072 .unit_test_cases = {
4073 /** Snow3G encrypt only (UEA2) */
4074 TEST_CASE_ST(ut_setup, ut_teardown,
4075 test_snow3g_encryption_test_case_1),
4076 TEST_CASE_ST(ut_setup, ut_teardown,
4077 test_snow3g_encryption_test_case_2),
4078 TEST_CASE_ST(ut_setup, ut_teardown,
4079 test_snow3g_encryption_test_case_3),
4080 TEST_CASE_ST(ut_setup, ut_teardown,
4081 test_snow3g_encryption_test_case_4),
4082 TEST_CASE_ST(ut_setup, ut_teardown,
4083 test_snow3g_encryption_test_case_5),
4085 TEST_CASE_ST(ut_setup, ut_teardown,
4086 test_snow3g_encryption_test_case_1_oop),
4087 TEST_CASE_ST(ut_setup, ut_teardown,
4088 test_snow3g_decryption_test_case_1_oop),
4090 TEST_CASE_ST(ut_setup, ut_teardown,
4091 test_snow3g_encryption_test_case_1_offset_oop),
4093 /** Snow3G decrypt only (UEA2) */
4094 TEST_CASE_ST(ut_setup, ut_teardown,
4095 test_snow3g_decryption_test_case_1),
4096 TEST_CASE_ST(ut_setup, ut_teardown,
4097 test_snow3g_decryption_test_case_2),
4098 TEST_CASE_ST(ut_setup, ut_teardown,
4099 test_snow3g_decryption_test_case_3),
4100 TEST_CASE_ST(ut_setup, ut_teardown,
4101 test_snow3g_decryption_test_case_4),
4102 TEST_CASE_ST(ut_setup, ut_teardown,
4103 test_snow3g_decryption_test_case_5),
4104 TEST_CASE_ST(ut_setup, ut_teardown,
4105 test_snow3g_hash_generate_test_case_1),
4106 TEST_CASE_ST(ut_setup, ut_teardown,
4107 test_snow3g_hash_generate_test_case_2),
4108 TEST_CASE_ST(ut_setup, ut_teardown,
4109 test_snow3g_hash_generate_test_case_3),
4110 /* Tests with buffers which length is not byte-aligned */
4111 TEST_CASE_ST(ut_setup, ut_teardown,
4112 test_snow3g_hash_generate_test_case_4),
4113 TEST_CASE_ST(ut_setup, ut_teardown,
4114 test_snow3g_hash_generate_test_case_5),
4115 TEST_CASE_ST(ut_setup, ut_teardown,
4116 test_snow3g_hash_generate_test_case_6),
4117 TEST_CASE_ST(ut_setup, ut_teardown,
4118 test_snow3g_hash_verify_test_case_1),
4119 TEST_CASE_ST(ut_setup, ut_teardown,
4120 test_snow3g_hash_verify_test_case_2),
4121 TEST_CASE_ST(ut_setup, ut_teardown,
4122 test_snow3g_hash_verify_test_case_3),
4123 /* Tests with buffers which length is not byte-aligned */
4124 TEST_CASE_ST(ut_setup, ut_teardown,
4125 test_snow3g_hash_verify_test_case_4),
4126 TEST_CASE_ST(ut_setup, ut_teardown,
4127 test_snow3g_hash_verify_test_case_5),
4128 TEST_CASE_ST(ut_setup, ut_teardown,
4129 test_snow3g_hash_verify_test_case_6),
4130 TEST_CASE_ST(ut_setup, ut_teardown,
4131 test_snow3g_authenticated_encryption_test_case_1),
4132 TEST_CASE_ST(ut_setup, ut_teardown,
4133 test_snow3g_encrypted_authentication_test_case_1),
4135 TEST_CASES_END() /**< NULL terminate unit test array */
4139 static struct unit_test_suite cryptodev_null_testsuite = {
4140 .suite_name = "Crypto Device NULL Unit Test Suite",
4141 .setup = testsuite_setup,
4142 .teardown = testsuite_teardown,
4143 .unit_test_cases = {
4144 TEST_CASE_ST(ut_setup, ut_teardown,
4145 test_null_auth_only_operation),
4146 TEST_CASE_ST(ut_setup, ut_teardown,
4147 test_null_cipher_only_operation),
4148 TEST_CASE_ST(ut_setup, ut_teardown,
4149 test_null_cipher_auth_operation),
4150 TEST_CASE_ST(ut_setup, ut_teardown,
4151 test_null_auth_cipher_operation),
4152 TEST_CASE_ST(ut_setup, ut_teardown,
4153 test_null_invalid_operation),
4154 TEST_CASE_ST(ut_setup, ut_teardown,
4155 test_null_burst_operation),
4157 TEST_CASES_END() /**< NULL terminate unit test array */
4162 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
4164 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
4165 return unit_test_suite_runner(&cryptodev_qat_testsuite);
4169 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
4171 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
4173 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
4177 test_cryptodev_aesni_gcm(void)
4179 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
4181 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
4185 test_cryptodev_null(void)
4187 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
4189 return unit_test_suite_runner(&cryptodev_null_testsuite);
4193 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
4195 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
4197 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
4201 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
4203 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
4205 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
4208 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
4209 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
4210 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
4211 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
4212 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
4213 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);