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 CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
191 TEST_ASSERT(ret == 0,
192 "Failed to create instance %u of"
194 i, 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 CRYPTODEV_NAME_AESNI_GCM_PMD, NULL),
207 "Failed to create instance %u of"
209 i, 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 CRYPTODEV_NAME_SNOW3G_PMD, NULL),
221 "Failed to create instance %u of"
223 i, 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 CRYPTODEV_NAME_KASUMI_PMD, NULL),
235 "Failed to create instance %u of"
237 i, 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 CRYPTODEV_NAME_NULL_PMD, NULL);
251 TEST_ASSERT(dev_id >= 0,
252 "Failed to create instance %u of"
254 i, 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_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_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 * but rte copes even if we call free twice
401 if (ut_params->obuf) {
402 rte_pktmbuf_free(ut_params->obuf);
405 if (ut_params->ibuf) {
406 rte_pktmbuf_free(ut_params->ibuf);
410 if (ts_params->mbuf_pool != NULL)
411 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
412 rte_mempool_count(ts_params->mbuf_pool));
414 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
416 /* Stop the device */
417 rte_cryptodev_stop(ts_params->valid_devs[0]);
421 test_device_configure_invalid_dev_id(void)
423 struct crypto_testsuite_params *ts_params = &testsuite_params;
424 uint16_t dev_id, num_devs = 0;
426 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
427 "Need at least %d devices for test", 1);
429 /* valid dev_id values */
430 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
432 /* Stop the device in case it's started so it can be configured */
433 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
435 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
436 "Failed test for rte_cryptodev_configure: "
437 "invalid dev_num %u", dev_id);
439 /* invalid dev_id values */
442 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
443 "Failed test for rte_cryptodev_configure: "
444 "invalid dev_num %u", dev_id);
448 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
449 "Failed test for rte_cryptodev_configure:"
450 "invalid dev_num %u", dev_id);
456 test_device_configure_invalid_queue_pair_ids(void)
458 struct crypto_testsuite_params *ts_params = &testsuite_params;
460 /* Stop the device in case it's started so it can be configured */
461 rte_cryptodev_stop(ts_params->valid_devs[0]);
463 /* valid - one queue pairs */
464 ts_params->conf.nb_queue_pairs = 1;
466 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
468 "Failed to configure cryptodev: dev_id %u, qp_id %u",
469 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
472 /* valid - max value queue pairs */
473 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
475 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
477 "Failed to configure cryptodev: dev_id %u, qp_id %u",
478 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
481 /* invalid - zero queue pairs */
482 ts_params->conf.nb_queue_pairs = 0;
484 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
486 "Failed test for rte_cryptodev_configure, dev_id %u,"
488 ts_params->valid_devs[0],
489 ts_params->conf.nb_queue_pairs);
492 /* invalid - max value supported by field queue pairs */
493 ts_params->conf.nb_queue_pairs = UINT16_MAX;
495 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
497 "Failed test for rte_cryptodev_configure, dev_id %u,"
499 ts_params->valid_devs[0],
500 ts_params->conf.nb_queue_pairs);
503 /* invalid - max value + 1 queue pairs */
504 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
506 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
508 "Failed test for rte_cryptodev_configure, dev_id %u,"
510 ts_params->valid_devs[0],
511 ts_params->conf.nb_queue_pairs);
517 test_queue_pair_descriptor_setup(void)
519 struct crypto_testsuite_params *ts_params = &testsuite_params;
520 struct rte_cryptodev_info dev_info;
521 struct rte_cryptodev_qp_conf qp_conf = {
522 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
527 /* Stop the device in case it's started so it can be configured */
528 rte_cryptodev_stop(ts_params->valid_devs[0]);
531 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
533 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
535 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
536 &ts_params->conf), "Failed to configure cryptodev %u",
537 ts_params->valid_devs[0]);
541 * Test various ring sizes on this device. memzones can't be
542 * freed so are re-used if ring is released and re-created.
544 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
546 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
547 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
548 ts_params->valid_devs[0], qp_id, &qp_conf,
549 rte_cryptodev_socket_id(
550 ts_params->valid_devs[0])),
552 "rte_cryptodev_queue_pair_setup: num_inflights "
553 "%u on qp %u on cryptodev %u",
554 qp_conf.nb_descriptors, qp_id,
555 ts_params->valid_devs[0]);
558 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
560 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
561 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
562 ts_params->valid_devs[0], qp_id, &qp_conf,
563 rte_cryptodev_socket_id(
564 ts_params->valid_devs[0])),
566 " rte_cryptodev_queue_pair_setup: num_inflights"
567 " %u on qp %u on cryptodev %u",
568 qp_conf.nb_descriptors, qp_id,
569 ts_params->valid_devs[0]);
572 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
574 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
575 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
576 ts_params->valid_devs[0], qp_id, &qp_conf,
577 rte_cryptodev_socket_id(
578 ts_params->valid_devs[0])),
580 "rte_cryptodev_queue_pair_setup: num_inflights"
581 " %u on qp %u on cryptodev %u",
582 qp_conf.nb_descriptors, qp_id,
583 ts_params->valid_devs[0]);
586 /* invalid number of descriptors - max supported + 2 */
587 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
589 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
590 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
591 ts_params->valid_devs[0], qp_id, &qp_conf,
592 rte_cryptodev_socket_id(
593 ts_params->valid_devs[0])),
594 "Unexpectedly passed test for "
595 "rte_cryptodev_queue_pair_setup:"
596 "num_inflights %u on qp %u on cryptodev %u",
597 qp_conf.nb_descriptors, qp_id,
598 ts_params->valid_devs[0]);
601 /* invalid number of descriptors - max value of parameter */
602 qp_conf.nb_descriptors = UINT32_MAX-1;
604 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
605 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
606 ts_params->valid_devs[0], qp_id, &qp_conf,
607 rte_cryptodev_socket_id(
608 ts_params->valid_devs[0])),
609 "Unexpectedly passed test for "
610 "rte_cryptodev_queue_pair_setup:"
611 "num_inflights %u on qp %u on cryptodev %u",
612 qp_conf.nb_descriptors, qp_id,
613 ts_params->valid_devs[0]);
616 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
618 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
619 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
620 ts_params->valid_devs[0], qp_id, &qp_conf,
621 rte_cryptodev_socket_id(
622 ts_params->valid_devs[0])),
624 " rte_cryptodev_queue_pair_setup:"
625 "num_inflights %u on qp %u on cryptodev %u",
626 qp_conf.nb_descriptors, qp_id,
627 ts_params->valid_devs[0]);
630 /* invalid number of descriptors - max supported + 1 */
631 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
633 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
634 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
635 ts_params->valid_devs[0], qp_id, &qp_conf,
636 rte_cryptodev_socket_id(
637 ts_params->valid_devs[0])),
638 "Unexpectedly passed test for "
639 "rte_cryptodev_queue_pair_setup:"
640 "num_inflights %u on qp %u on cryptodev %u",
641 qp_conf.nb_descriptors, qp_id,
642 ts_params->valid_devs[0]);
645 /* test invalid queue pair id */
646 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
648 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
650 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
651 ts_params->valid_devs[0],
653 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
654 "Failed test for rte_cryptodev_queue_pair_setup:"
655 "invalid qp %u on cryptodev %u",
656 qp_id, ts_params->valid_devs[0]);
658 qp_id = 0xffff; /*invalid*/
660 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
661 ts_params->valid_devs[0],
663 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
664 "Failed test for rte_cryptodev_queue_pair_setup:"
665 "invalid qp %u on cryptodev %u",
666 qp_id, ts_params->valid_devs[0]);
671 /* ***** Plaintext data for tests ***** */
673 const char catch_22_quote_1[] =
674 "There was only one catch and that was Catch-22, which "
675 "specified that a concern for one's safety in the face of "
676 "dangers that were real and immediate was the process of a "
677 "rational mind. Orr was crazy and could be grounded. All he "
678 "had to do was ask; and as soon as he did, he would no longer "
679 "be crazy and would have to fly more missions. Orr would be "
680 "crazy to fly more missions and sane if he didn't, but if he "
681 "was sane he had to fly them. If he flew them he was crazy "
682 "and didn't have to; but if he didn't want to he was sane and "
683 "had to. Yossarian was moved very deeply by the absolute "
684 "simplicity of this clause of Catch-22 and let out a "
685 "respectful whistle. \"That's some catch, that Catch-22\", he "
686 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
688 const char catch_22_quote[] =
689 "What a lousy earth! He wondered how many people were "
690 "destitute that same night even in his own prosperous country, "
691 "how many homes were shanties, how many husbands were drunk "
692 "and wives socked, and how many children were bullied, abused, "
693 "or abandoned. How many families hungered for food they could "
694 "not afford to buy? How many hearts were broken? How many "
695 "suicides would take place that same night, how many people "
696 "would go insane? How many cockroaches and landlords would "
697 "triumph? How many winners were losers, successes failures, "
698 "and rich men poor men? How many wise guys were stupid? How "
699 "many happy endings were unhappy endings? How many honest men "
700 "were liars, brave men cowards, loyal men traitors, how many "
701 "sainted men were corrupt, how many people in positions of "
702 "trust had sold their souls to bodyguards, how many had never "
703 "had souls? How many straight-and-narrow paths were crooked "
704 "paths? How many best families were worst families and how "
705 "many good people were bad people? When you added them all up "
706 "and then subtracted, you might be left with only the children, "
707 "and perhaps with Albert Einstein and an old violinist or "
708 "sculptor somewhere.";
710 #define QUOTE_480_BYTES (480)
711 #define QUOTE_512_BYTES (512)
712 #define QUOTE_768_BYTES (768)
713 #define QUOTE_1024_BYTES (1024)
717 /* ***** SHA1 Hash Tests ***** */
719 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
721 static uint8_t hmac_sha1_key[] = {
722 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
723 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
724 0xDE, 0xF4, 0xDE, 0xAD };
726 /* ***** SHA224 Hash Tests ***** */
728 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
731 /* ***** AES-CBC Cipher Tests ***** */
733 #define CIPHER_KEY_LENGTH_AES_CBC (16)
734 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
736 static uint8_t aes_cbc_key[] = {
737 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
738 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
740 static uint8_t aes_cbc_iv[] = {
741 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
742 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
745 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
747 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
748 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
749 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
750 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
751 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
752 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
753 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
754 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
755 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
756 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
757 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
758 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
759 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
760 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
761 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
762 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
763 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
764 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
765 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
766 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
767 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
768 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
769 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
770 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
771 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
772 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
773 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
774 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
775 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
776 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
777 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
778 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
779 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
780 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
781 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
782 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
783 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
784 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
785 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
786 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
787 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
788 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
789 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
790 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
791 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
792 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
793 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
794 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
795 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
796 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
797 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
798 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
799 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
800 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
801 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
802 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
803 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
804 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
805 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
806 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
807 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
808 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
809 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
810 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
811 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
814 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
815 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
816 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
817 0x18, 0x8c, 0x1d, 0x32
822 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
824 struct crypto_testsuite_params *ts_params = &testsuite_params;
825 struct crypto_unittest_params *ut_params = &unittest_params;
827 /* Generate test mbuf data and space for digest */
828 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
829 catch_22_quote, QUOTE_512_BYTES, 0);
831 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
832 DIGEST_BYTE_LENGTH_SHA1);
833 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
835 /* Setup Cipher Parameters */
836 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
837 ut_params->cipher_xform.next = &ut_params->auth_xform;
839 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
840 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
841 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
842 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
844 /* Setup HMAC Parameters */
845 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
847 ut_params->auth_xform.next = NULL;
849 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
850 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
851 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
852 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
853 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
855 /* Create crypto session*/
856 ut_params->sess = rte_cryptodev_sym_session_create(
857 ts_params->valid_devs[0],
858 &ut_params->cipher_xform);
859 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
861 /* Generate crypto op data structure */
862 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
863 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
864 TEST_ASSERT_NOT_NULL(ut_params->op,
865 "Failed to allocate symmetric crypto operation struct");
867 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
869 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
871 /* set crypto operation source mbuf */
872 sym_op->m_src = ut_params->ibuf;
874 /* Set crypto operation authentication parameters */
875 sym_op->auth.digest.data = ut_params->digest;
876 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
877 ut_params->ibuf, QUOTE_512_BYTES);
878 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
880 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
881 sym_op->auth.data.length = QUOTE_512_BYTES;
883 /* Set crypto operation cipher parameters */
884 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
885 CIPHER_IV_LENGTH_AES_CBC);
886 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
887 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
889 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
890 CIPHER_IV_LENGTH_AES_CBC);
892 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
893 sym_op->cipher.data.length = QUOTE_512_BYTES;
895 /* Process crypto operation */
896 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
897 ut_params->op), "failed to process sym crypto op");
899 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
900 "crypto op processing failed");
903 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
904 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
906 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
907 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
909 "ciphertext data not as expected");
911 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
913 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
914 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
915 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
916 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
917 DIGEST_BYTE_LENGTH_SHA1,
918 "Generated digest data not as expected");
923 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
925 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
927 static uint8_t hmac_sha512_key[] = {
928 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
929 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
930 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
931 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
932 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
933 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
934 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
935 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
937 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
938 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
939 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
940 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
941 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
942 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
943 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
944 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
945 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
950 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
951 struct crypto_unittest_params *ut_params);
954 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
955 struct crypto_unittest_params *ut_params,
956 struct crypto_testsuite_params *ts_params);
960 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
961 struct crypto_unittest_params *ut_params)
964 /* Setup Cipher Parameters */
965 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
966 ut_params->cipher_xform.next = NULL;
968 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
969 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
970 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
971 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
973 /* Setup HMAC Parameters */
974 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
975 ut_params->auth_xform.next = &ut_params->cipher_xform;
977 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
978 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
979 ut_params->auth_xform.auth.key.data = hmac_sha512_key;
980 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
981 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
988 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
989 struct crypto_unittest_params *ut_params,
990 struct crypto_testsuite_params *ts_params)
992 /* Generate test mbuf data and digest */
993 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
995 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
998 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
999 DIGEST_BYTE_LENGTH_SHA512);
1000 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1002 rte_memcpy(ut_params->digest,
1003 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1004 DIGEST_BYTE_LENGTH_SHA512);
1006 /* Generate Crypto op data structure */
1007 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1008 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1009 TEST_ASSERT_NOT_NULL(ut_params->op,
1010 "Failed to allocate symmetric crypto operation struct");
1012 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1014 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1016 /* set crypto operation source mbuf */
1017 sym_op->m_src = ut_params->ibuf;
1019 sym_op->auth.digest.data = ut_params->digest;
1020 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1021 ut_params->ibuf, QUOTE_512_BYTES);
1022 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1024 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1025 sym_op->auth.data.length = QUOTE_512_BYTES;
1027 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1028 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1029 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1030 ut_params->ibuf, 0);
1031 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1033 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1034 CIPHER_IV_LENGTH_AES_CBC);
1036 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1037 sym_op->cipher.data.length = QUOTE_512_BYTES;
1039 /* Process crypto operation */
1040 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1041 ut_params->op), "failed to process sym crypto op");
1043 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1044 "crypto op processing failed");
1046 ut_params->obuf = ut_params->op->sym->m_src;
1049 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1050 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1051 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1053 "Plaintext data not as expected");
1056 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1057 "Digest verification failed");
1059 return TEST_SUCCESS;
1063 test_AES_mb_all(void)
1065 struct crypto_testsuite_params *ts_params = &testsuite_params;
1068 status = test_AES_all_tests(ts_params->mbuf_pool,
1069 ts_params->op_mpool, ts_params->valid_devs[0],
1070 RTE_CRYPTODEV_AESNI_MB_PMD);
1072 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1074 return TEST_SUCCESS;
1078 test_AES_qat_all(void)
1080 struct crypto_testsuite_params *ts_params = &testsuite_params;
1083 status = test_AES_all_tests(ts_params->mbuf_pool,
1084 ts_params->op_mpool, ts_params->valid_devs[0],
1085 RTE_CRYPTODEV_QAT_SYM_PMD);
1087 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1089 return TEST_SUCCESS;
1092 /* ***** Snow3G Tests ***** */
1094 create_snow3g_hash_session(uint8_t dev_id,
1095 const uint8_t *key, const uint8_t key_len,
1096 const uint8_t aad_len, const uint8_t auth_len,
1097 enum rte_crypto_auth_operation op)
1099 uint8_t hash_key[key_len];
1101 struct crypto_unittest_params *ut_params = &unittest_params;
1103 memcpy(hash_key, key, key_len);
1105 TEST_HEXDUMP(stdout, "key:", key, key_len);
1107 /* Setup Authentication Parameters */
1108 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1109 ut_params->auth_xform.next = NULL;
1111 ut_params->auth_xform.auth.op = op;
1112 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
1113 ut_params->auth_xform.auth.key.length = key_len;
1114 ut_params->auth_xform.auth.key.data = hash_key;
1115 ut_params->auth_xform.auth.digest_length = auth_len;
1116 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1117 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1118 &ut_params->auth_xform);
1119 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1124 create_kasumi_hash_session(uint8_t dev_id,
1125 const uint8_t *key, const uint8_t key_len,
1126 const uint8_t aad_len, const uint8_t auth_len,
1127 enum rte_crypto_auth_operation op)
1129 uint8_t hash_key[key_len];
1131 struct crypto_unittest_params *ut_params = &unittest_params;
1133 memcpy(hash_key, key, key_len);
1134 TEST_HEXDUMP(stdout, "key:", key, key_len);
1135 /* Setup Authentication Parameters */
1136 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1137 ut_params->auth_xform.next = NULL;
1139 ut_params->auth_xform.auth.op = op;
1140 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
1141 ut_params->auth_xform.auth.key.length = key_len;
1142 ut_params->auth_xform.auth.key.data = hash_key;
1143 ut_params->auth_xform.auth.digest_length = auth_len;
1144 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1145 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1146 &ut_params->auth_xform);
1147 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1152 create_kasumi_cipher_session(uint8_t dev_id,
1153 enum rte_crypto_cipher_operation op,
1154 const uint8_t *key, const uint8_t key_len)
1156 uint8_t cipher_key[key_len];
1158 struct crypto_unittest_params *ut_params = &unittest_params;
1160 memcpy(cipher_key, key, key_len);
1162 /* Setup Cipher Parameters */
1163 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1164 ut_params->cipher_xform.next = NULL;
1166 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
1167 ut_params->cipher_xform.cipher.op = op;
1168 ut_params->cipher_xform.cipher.key.data = cipher_key;
1169 ut_params->cipher_xform.cipher.key.length = key_len;
1171 TEST_HEXDUMP(stdout, "key:", key, key_len);
1173 /* Create Crypto session */
1174 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1177 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1182 create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1183 const unsigned cipher_len,
1184 const unsigned cipher_offset)
1186 struct crypto_testsuite_params *ts_params = &testsuite_params;
1187 struct crypto_unittest_params *ut_params = &unittest_params;
1188 unsigned iv_pad_len = 0;
1190 /* Generate Crypto op data structure */
1191 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1192 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1193 TEST_ASSERT_NOT_NULL(ut_params->op,
1194 "Failed to allocate pktmbuf offload");
1196 /* Set crypto operation data parameters */
1197 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1199 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1201 /* set crypto operation source mbuf */
1202 sym_op->m_src = ut_params->ibuf;
1205 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1206 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1209 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1211 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1212 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1213 sym_op->cipher.iv.length = iv_pad_len;
1215 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1216 sym_op->cipher.data.length = cipher_len;
1217 sym_op->cipher.data.offset = cipher_offset;
1222 create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1223 const unsigned cipher_len,
1224 const unsigned cipher_offset)
1226 struct crypto_testsuite_params *ts_params = &testsuite_params;
1227 struct crypto_unittest_params *ut_params = &unittest_params;
1228 unsigned iv_pad_len = 0;
1230 /* Generate Crypto op data structure */
1231 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1232 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1233 TEST_ASSERT_NOT_NULL(ut_params->op,
1234 "Failed to allocate pktmbuf offload");
1236 /* Set crypto operation data parameters */
1237 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1239 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1241 /* set crypto operation source mbuf */
1242 sym_op->m_src = ut_params->ibuf;
1243 sym_op->m_dst = ut_params->obuf;
1246 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1247 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1250 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1252 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1253 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1254 sym_op->cipher.iv.length = iv_pad_len;
1256 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1257 sym_op->cipher.data.length = cipher_len;
1258 sym_op->cipher.data.offset = cipher_offset;
1263 create_snow3g_cipher_session(uint8_t dev_id,
1264 enum rte_crypto_cipher_operation op,
1265 const uint8_t *key, const uint8_t key_len)
1267 uint8_t cipher_key[key_len];
1269 struct crypto_unittest_params *ut_params = &unittest_params;
1271 memcpy(cipher_key, key, key_len);
1273 /* Setup Cipher Parameters */
1274 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1275 ut_params->cipher_xform.next = NULL;
1277 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
1278 ut_params->cipher_xform.cipher.op = op;
1279 ut_params->cipher_xform.cipher.key.data = cipher_key;
1280 ut_params->cipher_xform.cipher.key.length = key_len;
1282 TEST_HEXDUMP(stdout, "key:", key, key_len);
1284 /* Create Crypto session */
1285 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1288 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1293 create_snow3g_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1294 const unsigned cipher_len,
1295 const unsigned cipher_offset)
1297 struct crypto_testsuite_params *ts_params = &testsuite_params;
1298 struct crypto_unittest_params *ut_params = &unittest_params;
1299 unsigned iv_pad_len = 0;
1301 /* Generate Crypto op data structure */
1302 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1303 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1304 TEST_ASSERT_NOT_NULL(ut_params->op,
1305 "Failed to allocate pktmbuf offload");
1307 /* Set crypto operation data parameters */
1308 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1310 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1312 /* set crypto operation source mbuf */
1313 sym_op->m_src = ut_params->ibuf;
1316 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1317 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1320 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1322 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1323 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1324 sym_op->cipher.iv.length = iv_pad_len;
1326 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1327 sym_op->cipher.data.length = cipher_len;
1328 sym_op->cipher.data.offset = cipher_offset;
1333 create_snow3g_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1334 const unsigned cipher_len,
1335 const unsigned cipher_offset)
1337 struct crypto_testsuite_params *ts_params = &testsuite_params;
1338 struct crypto_unittest_params *ut_params = &unittest_params;
1339 unsigned iv_pad_len = 0;
1341 /* Generate Crypto op data structure */
1342 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1343 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1344 TEST_ASSERT_NOT_NULL(ut_params->op,
1345 "Failed to allocate pktmbuf offload");
1347 /* Set crypto operation data parameters */
1348 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1350 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1352 /* set crypto operation source mbuf */
1353 sym_op->m_src = ut_params->ibuf;
1354 sym_op->m_dst = ut_params->obuf;
1357 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1358 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1361 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1363 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1364 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1365 sym_op->cipher.iv.length = iv_pad_len;
1367 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1368 sym_op->cipher.data.length = cipher_len;
1369 sym_op->cipher.data.offset = cipher_offset;
1374 create_snow3g_cipher_auth_session(uint8_t dev_id,
1375 enum rte_crypto_cipher_operation cipher_op,
1376 enum rte_crypto_auth_operation auth_op,
1377 const uint8_t *key, const uint8_t key_len,
1378 const uint8_t aad_len, const uint8_t auth_len)
1380 uint8_t cipher_auth_key[key_len];
1382 struct crypto_unittest_params *ut_params = &unittest_params;
1384 memcpy(cipher_auth_key, key, key_len);
1386 /* Setup Authentication Parameters */
1387 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1388 ut_params->auth_xform.next = NULL;
1390 ut_params->auth_xform.auth.op = auth_op;
1391 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
1392 ut_params->auth_xform.auth.key.length = key_len;
1393 /* Hash key = cipher key */
1394 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1395 ut_params->auth_xform.auth.digest_length = auth_len;
1396 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1398 /* Setup Cipher Parameters */
1399 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1400 ut_params->cipher_xform.next = &ut_params->auth_xform;
1402 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
1403 ut_params->cipher_xform.cipher.op = cipher_op;
1404 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1405 ut_params->cipher_xform.cipher.key.length = key_len;
1407 TEST_HEXDUMP(stdout, "key:", key, key_len);
1409 /* Create Crypto session*/
1410 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1411 &ut_params->cipher_xform);
1413 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1418 create_snow3g_auth_cipher_session(uint8_t dev_id,
1419 enum rte_crypto_cipher_operation cipher_op,
1420 enum rte_crypto_auth_operation auth_op,
1421 const uint8_t *key, const uint8_t key_len,
1422 const uint8_t aad_len, const uint8_t auth_len)
1424 uint8_t auth_cipher_key[key_len];
1426 struct crypto_unittest_params *ut_params = &unittest_params;
1428 memcpy(auth_cipher_key, key, key_len);
1430 /* Setup Authentication Parameters */
1431 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1432 ut_params->auth_xform.auth.op = auth_op;
1433 ut_params->auth_xform.next = &ut_params->cipher_xform;
1434 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
1435 ut_params->auth_xform.auth.key.length = key_len;
1436 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1437 ut_params->auth_xform.auth.digest_length = auth_len;
1438 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1440 /* Setup Cipher Parameters */
1441 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1442 ut_params->cipher_xform.next = NULL;
1443 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
1444 ut_params->cipher_xform.cipher.op = cipher_op;
1445 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1446 ut_params->cipher_xform.cipher.key.length = key_len;
1448 TEST_HEXDUMP(stdout, "key:", key, key_len);
1450 /* Create Crypto session*/
1451 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1452 &ut_params->auth_xform);
1454 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1460 create_snow3g_hash_operation(const uint8_t *auth_tag,
1461 const unsigned auth_tag_len,
1462 const uint8_t *aad, const unsigned aad_len,
1463 unsigned data_pad_len,
1464 enum rte_crypto_auth_operation op,
1465 const unsigned auth_len, const unsigned auth_offset)
1467 struct crypto_testsuite_params *ts_params = &testsuite_params;
1469 struct crypto_unittest_params *ut_params = &unittest_params;
1471 unsigned aad_buffer_len;
1473 /* Generate Crypto op data structure */
1474 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1475 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1476 TEST_ASSERT_NOT_NULL(ut_params->op,
1477 "Failed to allocate pktmbuf offload");
1479 /* Set crypto operation data parameters */
1480 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1482 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1484 /* set crypto operation source mbuf */
1485 sym_op->m_src = ut_params->ibuf;
1489 * Always allocate the aad up to the block size.
1490 * The cryptodev API calls out -
1491 * - the array must be big enough to hold the AAD, plus any
1492 * space to round this up to the nearest multiple of the
1493 * block size (16 bytes).
1495 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1496 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1497 ut_params->ibuf, aad_buffer_len);
1498 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1499 "no room to prepend aad");
1500 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1502 sym_op->auth.aad.length = aad_len;
1504 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1505 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1507 TEST_HEXDUMP(stdout, "aad:",
1508 sym_op->auth.aad.data, aad_len);
1511 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1512 ut_params->ibuf, auth_tag_len);
1514 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1515 "no room to append auth tag");
1516 ut_params->digest = sym_op->auth.digest.data;
1517 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1518 ut_params->ibuf, data_pad_len + aad_len);
1519 sym_op->auth.digest.length = auth_tag_len;
1520 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1521 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1523 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1525 TEST_HEXDUMP(stdout, "digest:",
1526 sym_op->auth.digest.data,
1527 sym_op->auth.digest.length);
1529 sym_op->auth.data.length = auth_len;
1530 sym_op->auth.data.offset = auth_offset;
1536 create_kasumi_hash_operation(const uint8_t *auth_tag,
1537 const unsigned auth_tag_len,
1538 const uint8_t *aad, const unsigned aad_len,
1539 unsigned data_pad_len,
1540 enum rte_crypto_auth_operation op,
1541 const unsigned auth_len, const unsigned auth_offset)
1543 struct crypto_testsuite_params *ts_params = &testsuite_params;
1545 struct crypto_unittest_params *ut_params = &unittest_params;
1547 unsigned aad_buffer_len;
1549 /* Generate Crypto op data structure */
1550 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1551 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1552 TEST_ASSERT_NOT_NULL(ut_params->op,
1553 "Failed to allocate pktmbuf offload");
1555 /* Set crypto operation data parameters */
1556 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1558 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1560 /* set crypto operation source mbuf */
1561 sym_op->m_src = ut_params->ibuf;
1565 * Always allocate the aad up to the block size.
1566 * The cryptodev API calls out -
1567 * - the array must be big enough to hold the AAD, plus any
1568 * space to round this up to the nearest multiple of the
1569 * block size (16 bytes).
1571 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1572 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1573 ut_params->ibuf, aad_buffer_len);
1574 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1575 "no room to prepend aad");
1576 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1578 sym_op->auth.aad.length = aad_len;
1580 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1581 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1583 TEST_HEXDUMP(stdout, "aad:",
1584 sym_op->auth.aad.data, aad_len);
1587 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1588 ut_params->ibuf, auth_tag_len);
1590 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1591 "no room to append auth tag");
1592 ut_params->digest = sym_op->auth.digest.data;
1593 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1594 ut_params->ibuf, data_pad_len + aad_len);
1595 sym_op->auth.digest.length = auth_tag_len;
1596 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1597 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1599 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1601 TEST_HEXDUMP(stdout, "digest:",
1602 sym_op->auth.digest.data,
1603 sym_op->auth.digest.length);
1605 sym_op->auth.data.length = auth_len;
1606 sym_op->auth.data.offset = auth_offset;
1611 create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
1612 const unsigned auth_tag_len,
1613 const uint8_t *aad, const uint8_t aad_len,
1614 unsigned data_pad_len,
1615 enum rte_crypto_auth_operation op,
1616 const uint8_t *iv, const uint8_t iv_len,
1617 const unsigned cipher_len, const unsigned cipher_offset,
1618 const unsigned auth_len, const unsigned auth_offset)
1620 struct crypto_testsuite_params *ts_params = &testsuite_params;
1621 struct crypto_unittest_params *ut_params = &unittest_params;
1623 unsigned iv_pad_len = 0;
1624 unsigned aad_buffer_len;
1626 /* Generate Crypto op data structure */
1627 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1628 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1629 TEST_ASSERT_NOT_NULL(ut_params->op,
1630 "Failed to allocate pktmbuf offload");
1631 /* Set crypto operation data parameters */
1632 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1634 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1636 /* set crypto operation source mbuf */
1637 sym_op->m_src = ut_params->ibuf;
1641 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1643 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1644 ut_params->ibuf, iv_pad_len);
1645 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1647 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1648 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1649 sym_op->cipher.iv.length = iv_pad_len;
1651 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1653 sym_op->cipher.data.length = cipher_len;
1654 sym_op->cipher.data.offset = cipher_offset;
1658 * Always allocate the aad up to the block size.
1659 * The cryptodev API calls out -
1660 * - the array must be big enough to hold the AAD, plus any
1661 * space to round this up to the nearest multiple of the
1662 * block size (16 bytes).
1664 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1666 sym_op->auth.aad.data =
1667 (uint8_t *)rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
1668 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1669 "no room to prepend aad");
1670 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1672 sym_op->auth.aad.length = aad_len;
1674 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1675 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1677 TEST_HEXDUMP(stdout, "aad:",
1678 sym_op->auth.aad.data, aad_len);
1681 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1682 ut_params->ibuf, auth_tag_len);
1684 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1685 "no room to append auth tag");
1686 ut_params->digest = sym_op->auth.digest.data;
1687 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1688 ut_params->ibuf, data_pad_len + aad_len);
1689 sym_op->auth.digest.length = auth_tag_len;
1690 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1691 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1693 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1695 TEST_HEXDUMP(stdout, "digest:",
1696 sym_op->auth.digest.data,
1697 sym_op->auth.digest.length);
1699 sym_op->auth.data.length = auth_len;
1700 sym_op->auth.data.offset = auth_offset;
1706 create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
1707 const uint8_t *iv, const uint8_t iv_len,
1708 const uint8_t *aad, const uint8_t aad_len,
1709 unsigned data_pad_len,
1710 const unsigned cipher_len, const unsigned cipher_offset,
1711 const unsigned auth_len, const unsigned auth_offset)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1714 struct crypto_unittest_params *ut_params = &unittest_params;
1716 unsigned iv_pad_len = 0;
1717 unsigned aad_buffer_len = 0;
1719 /* Generate Crypto op data structure */
1720 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1721 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1722 TEST_ASSERT_NOT_NULL(ut_params->op,
1723 "Failed to allocate pktmbuf offload");
1725 /* Set crypto operation data parameters */
1726 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1728 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1730 /* set crypto operation source mbuf */
1731 sym_op->m_src = ut_params->ibuf;
1734 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1735 ut_params->ibuf, auth_tag_len);
1737 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1738 "no room to append auth tag");
1740 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1741 ut_params->ibuf, data_pad_len);
1742 sym_op->auth.digest.length = auth_tag_len;
1744 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1746 TEST_HEXDUMP(stdout, "digest:",
1747 sym_op->auth.digest.data,
1748 sym_op->auth.digest.length);
1751 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1753 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1754 ut_params->ibuf, iv_pad_len);
1755 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1757 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1758 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1759 sym_op->cipher.iv.length = iv_pad_len;
1761 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1765 * Always allocate the aad up to the block size.
1766 * The cryptodev API calls out -
1767 * - the array must be big enough to hold the AAD, plus any
1768 * space to round this up to the nearest multiple of the
1769 * block size (16 bytes).
1771 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1773 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1774 ut_params->ibuf, aad_buffer_len);
1775 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1776 "no room to prepend aad");
1777 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1779 sym_op->auth.aad.length = aad_len;
1781 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1782 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1784 TEST_HEXDUMP(stdout, "aad:",
1785 sym_op->auth.aad.data, aad_len);
1787 sym_op->cipher.data.length = cipher_len;
1788 sym_op->cipher.data.offset = auth_offset + cipher_offset;
1790 sym_op->auth.data.length = auth_len;
1791 sym_op->auth.data.offset = auth_offset + cipher_offset;
1797 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
1799 struct crypto_testsuite_params *ts_params = &testsuite_params;
1800 struct crypto_unittest_params *ut_params = &unittest_params;
1803 unsigned plaintext_pad_len;
1806 /* Create SNOW3G session */
1807 retval = create_snow3g_hash_session(ts_params->valid_devs[0],
1808 tdata->key.data, tdata->key.len,
1809 tdata->aad.len, tdata->digest.len,
1810 RTE_CRYPTO_AUTH_OP_GENERATE);
1814 /* alloc mbuf and set payload */
1815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1817 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1818 rte_pktmbuf_tailroom(ut_params->ibuf));
1820 /* Append data which is padded to a multiple of */
1821 /* the algorithms block size */
1822 plaintext_pad_len = tdata->plaintext.len >> 3;
1823 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1825 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
1827 /* Create SNOW3G opertaion */
1828 retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
1829 tdata->aad.data, tdata->aad.len,
1830 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1831 tdata->validAuthLenInBits.len,
1832 tdata->validAuthOffsetLenInBits.len);
1836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1838 ut_params->obuf = ut_params->op->sym->m_src;
1839 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1840 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1841 + plaintext_pad_len + tdata->aad.len;
1844 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1847 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
1848 "Snow3G Generated auth tag not as expected");
1854 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
1856 struct crypto_testsuite_params *ts_params = &testsuite_params;
1857 struct crypto_unittest_params *ut_params = &unittest_params;
1860 unsigned plaintext_pad_len;
1863 /* Create SNOW3G session */
1864 retval = create_snow3g_hash_session(ts_params->valid_devs[0],
1865 tdata->key.data, tdata->key.len,
1866 tdata->aad.len, tdata->digest.len,
1867 RTE_CRYPTO_AUTH_OP_VERIFY);
1870 /* alloc mbuf and set payload */
1871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1873 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1874 rte_pktmbuf_tailroom(ut_params->ibuf));
1876 /* Append data which is padded to a multiple */
1877 /* of the algorithms block size */
1878 plaintext_pad_len = tdata->plaintext.len >> 3;
1879 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1881 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
1883 /* Create SNOW3G operation */
1884 retval = create_snow3g_hash_operation(tdata->digest.data,
1886 tdata->aad.data, tdata->aad.len,
1888 RTE_CRYPTO_AUTH_OP_VERIFY,
1889 tdata->validAuthLenInBits.len,
1890 tdata->validAuthOffsetLenInBits.len);
1894 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1896 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1897 ut_params->obuf = ut_params->op->sym->m_src;
1898 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1899 + plaintext_pad_len + tdata->aad.len;
1902 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
1911 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
1913 struct crypto_testsuite_params *ts_params = &testsuite_params;
1914 struct crypto_unittest_params *ut_params = &unittest_params;
1917 unsigned plaintext_pad_len;
1918 unsigned plaintext_len;
1921 /* Create KASUMI session */
1922 retval = create_kasumi_hash_session(ts_params->valid_devs[0],
1923 tdata->key.data, tdata->key.len,
1924 tdata->aad.len, tdata->digest.len,
1925 RTE_CRYPTO_AUTH_OP_GENERATE);
1929 /* alloc mbuf and set payload */
1930 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1932 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1933 rte_pktmbuf_tailroom(ut_params->ibuf));
1935 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1936 /* Append data which is padded to a multiple of */
1937 /* the algorithms block size */
1938 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1939 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1941 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
1943 /* Create KASUMI operation */
1944 retval = create_kasumi_hash_operation(NULL, tdata->digest.len,
1945 tdata->aad.data, tdata->aad.len,
1946 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
1947 tdata->validAuthLenInBits.len,
1948 tdata->validAuthOffsetLenInBits.len);
1952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1954 ut_params->obuf = ut_params->op->sym->m_src;
1955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
1956 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
1957 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
1960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1963 DIGEST_BYTE_LENGTH_KASUMI_F9,
1964 "KASUMI Generated auth tag not as expected");
1970 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
1972 struct crypto_testsuite_params *ts_params = &testsuite_params;
1973 struct crypto_unittest_params *ut_params = &unittest_params;
1976 unsigned plaintext_pad_len;
1977 unsigned plaintext_len;
1980 /* Create KASUMI session */
1981 retval = create_kasumi_hash_session(ts_params->valid_devs[0],
1982 tdata->key.data, tdata->key.len,
1983 tdata->aad.len, tdata->digest.len,
1984 RTE_CRYPTO_AUTH_OP_VERIFY);
1987 /* alloc mbuf and set payload */
1988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1990 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
1991 rte_pktmbuf_tailroom(ut_params->ibuf));
1993 plaintext_len = ceil_byte_length(tdata->plaintext.len);
1994 /* Append data which is padded to a multiple */
1995 /* of the algorithms block size */
1996 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
1997 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1999 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2001 /* Create KASUMI operation */
2002 retval = create_kasumi_hash_operation(tdata->digest.data,
2004 tdata->aad.data, tdata->aad.len,
2006 RTE_CRYPTO_AUTH_OP_VERIFY,
2007 tdata->validAuthLenInBits.len,
2008 tdata->validAuthOffsetLenInBits.len);
2012 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2014 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2015 ut_params->obuf = ut_params->op->sym->m_src;
2016 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2017 + plaintext_pad_len + tdata->aad.len;
2020 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2029 test_snow3g_hash_generate_test_case_1(void)
2031 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2035 test_snow3g_hash_generate_test_case_2(void)
2037 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2041 test_snow3g_hash_generate_test_case_3(void)
2043 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2047 test_snow3g_hash_verify_test_case_1(void)
2049 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2054 test_snow3g_hash_verify_test_case_2(void)
2056 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2060 test_snow3g_hash_verify_test_case_3(void)
2062 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2066 test_kasumi_hash_generate_test_case_1(void)
2068 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2072 test_kasumi_hash_generate_test_case_2(void)
2074 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2078 test_kasumi_hash_generate_test_case_3(void)
2080 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2084 test_kasumi_hash_generate_test_case_4(void)
2086 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2090 test_kasumi_hash_generate_test_case_5(void)
2092 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2096 test_kasumi_hash_verify_test_case_1(void)
2098 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2102 test_kasumi_hash_verify_test_case_2(void)
2104 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2108 test_kasumi_hash_verify_test_case_3(void)
2110 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2114 test_kasumi_hash_verify_test_case_4(void)
2116 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2120 test_kasumi_hash_verify_test_case_5(void)
2122 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2126 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2128 struct crypto_testsuite_params *ts_params = &testsuite_params;
2129 struct crypto_unittest_params *ut_params = &unittest_params;
2132 uint8_t *plaintext, *ciphertext;
2133 unsigned plaintext_pad_len;
2134 unsigned plaintext_len;
2136 /* Create KASUMI session */
2137 retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
2138 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2139 tdata->key.data, tdata->key.len);
2143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2145 /* Clear mbuf payload */
2146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2147 rte_pktmbuf_tailroom(ut_params->ibuf));
2149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2150 /* Append data which is padded to a multiple */
2151 /* of the algorithms block size */
2152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2157 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2159 /* Create KASUMI operation */
2160 retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
2161 tdata->plaintext.len,
2162 tdata->validCipherOffsetLenInBits.len);
2166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2168 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2170 ut_params->obuf = ut_params->op->sym->m_dst;
2171 if (ut_params->obuf)
2172 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2175 ciphertext = plaintext;
2177 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2180 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2182 tdata->ciphertext.data,
2183 tdata->validCipherLenInBits.len,
2184 "KASUMI Ciphertext data not as expected");
2189 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2191 struct crypto_testsuite_params *ts_params = &testsuite_params;
2192 struct crypto_unittest_params *ut_params = &unittest_params;
2195 uint8_t *plaintext, *ciphertext;
2196 unsigned plaintext_pad_len;
2197 unsigned plaintext_len;
2199 /* Create KASUMI session */
2200 retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
2201 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2202 tdata->key.data, tdata->key.len);
2206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2209 /* Clear mbuf payload */
2210 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2211 rte_pktmbuf_tailroom(ut_params->ibuf));
2213 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2214 /* Append data which is padded to a multiple */
2215 /* of the algorithms block size */
2216 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2217 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2219 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2220 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2222 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2224 /* Create KASUMI operation */
2225 retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
2226 tdata->plaintext.len,
2227 tdata->validCipherOffsetLenInBits.len);
2231 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2233 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2235 ut_params->obuf = ut_params->op->sym->m_dst;
2236 if (ut_params->obuf)
2237 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2240 ciphertext = plaintext;
2242 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2245 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2247 tdata->ciphertext.data,
2248 tdata->validCipherLenInBits.len,
2249 "KASUMI Ciphertext data not as expected");
2254 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2256 struct crypto_testsuite_params *ts_params = &testsuite_params;
2257 struct crypto_unittest_params *ut_params = &unittest_params;
2260 uint8_t *ciphertext, *plaintext;
2261 unsigned ciphertext_pad_len;
2262 unsigned ciphertext_len;
2264 /* Create KASUMI session */
2265 retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
2266 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2267 tdata->key.data, tdata->key.len);
2271 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2272 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2274 /* Clear mbuf payload */
2275 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2276 rte_pktmbuf_tailroom(ut_params->ibuf));
2278 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2279 /* Append data which is padded to a multiple */
2280 /* of the algorithms block size */
2281 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2282 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2283 ciphertext_pad_len);
2284 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2285 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2287 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2289 /* Create KASUMI operation */
2290 retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
2291 tdata->ciphertext.len,
2292 tdata->validCipherOffsetLenInBits.len);
2296 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2298 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2300 ut_params->obuf = ut_params->op->sym->m_dst;
2301 if (ut_params->obuf)
2302 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2305 plaintext = ciphertext;
2307 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2310 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2312 tdata->plaintext.data,
2313 tdata->validCipherLenInBits.len,
2314 "KASUMI Plaintext data not as expected");
2319 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2321 struct crypto_testsuite_params *ts_params = &testsuite_params;
2322 struct crypto_unittest_params *ut_params = &unittest_params;
2325 uint8_t *ciphertext, *plaintext;
2326 unsigned ciphertext_pad_len;
2327 unsigned ciphertext_len;
2329 /* Create KASUMI session */
2330 retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
2331 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2332 tdata->key.data, tdata->key.len);
2336 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2338 /* Clear mbuf payload */
2339 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2340 rte_pktmbuf_tailroom(ut_params->ibuf));
2342 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2343 /* Append data which is padded to a multiple */
2344 /* of the algorithms block size */
2345 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2346 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2347 ciphertext_pad_len);
2348 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2350 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2352 /* Create KASUMI operation */
2353 retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
2354 tdata->ciphertext.len,
2355 tdata->validCipherOffsetLenInBits.len);
2359 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2361 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2363 ut_params->obuf = ut_params->op->sym->m_dst;
2364 if (ut_params->obuf)
2365 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2368 plaintext = ciphertext;
2370 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2373 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2375 tdata->plaintext.data,
2376 tdata->validCipherLenInBits.len,
2377 "KASUMI Plaintext data not as expected");
2382 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2384 struct crypto_testsuite_params *ts_params = &testsuite_params;
2385 struct crypto_unittest_params *ut_params = &unittest_params;
2388 uint8_t *plaintext, *ciphertext;
2389 uint8_t plaintext_pad_len;
2390 uint8_t lastByteValidBits = 8;
2391 uint8_t lastByteMask = 0xFF;
2393 /* Create SNOW3G session */
2394 retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
2395 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2396 tdata->key.data, tdata->key.len);
2400 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2402 /* Clear mbuf payload */
2403 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2404 rte_pktmbuf_tailroom(ut_params->ibuf));
2407 * Append data which is padded to a
2408 * multiple of the algorithms block size
2410 /*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
2411 plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
2413 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2415 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2417 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2419 /* Create SNOW3G operation */
2420 retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
2421 tdata->validCipherLenInBits.len,
2422 tdata->validCipherOffsetLenInBits.len);
2426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2430 ut_params->obuf = ut_params->op->sym->m_dst;
2431 if (ut_params->obuf)
2432 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2435 ciphertext = plaintext;
2437 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2438 if (lastByteValidBits == 0)
2439 lastByteValidBits = 8;
2440 lastByteMask = lastByteMask << (8 - lastByteValidBits);
2441 (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2443 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2446 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2448 tdata->ciphertext.data,
2449 tdata->ciphertext.len >> 3,
2450 "Snow3G Ciphertext data not as expected");
2456 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2458 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2460 uint8_t *plaintext, *ciphertext;
2463 uint8_t plaintext_pad_len;
2464 uint8_t lastByteValidBits = 8;
2465 uint8_t lastByteMask = 0xFF;
2467 /* Create SNOW3G session */
2468 retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
2469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2470 tdata->key.data, tdata->key.len);
2474 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2475 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2477 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2478 "Failed to allocate input buffer in mempool");
2479 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2480 "Failed to allocate output buffer in mempool");
2482 /* Clear mbuf payload */
2483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2484 rte_pktmbuf_tailroom(ut_params->ibuf));
2487 * Append data which is padded to a
2488 * multiple of the algorithms block size
2490 /*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
2491 plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
2493 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2496 rte_pktmbuf_append(ut_params->obuf,
2499 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2501 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2503 /* Create SNOW3G operation */
2504 retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
2506 tdata->validCipherLenInBits.len,
2507 tdata->validCipherOffsetLenInBits.len);
2511 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2513 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2515 ut_params->obuf = ut_params->op->sym->m_dst;
2516 if (ut_params->obuf)
2517 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2520 ciphertext = plaintext;
2522 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2523 if (lastByteValidBits == 0)
2524 lastByteValidBits = 8;
2525 lastByteMask = lastByteMask << (8 - lastByteValidBits);
2526 (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2528 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2531 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2533 tdata->ciphertext.data,
2534 tdata->ciphertext.len >> 3,
2535 "Snow3G Ciphertext data not as expected");
2540 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2542 struct crypto_testsuite_params *ts_params = &testsuite_params;
2543 struct crypto_unittest_params *ut_params = &unittest_params;
2547 uint8_t *plaintext, *ciphertext;
2548 uint8_t ciphertext_pad_len;
2549 uint8_t lastByteValidBits = 8;
2550 uint8_t lastByteMask = 0xFF;
2552 /* Create SNOW3G session */
2553 retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
2554 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2555 tdata->key.data, tdata->key.len);
2559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2561 /* Clear mbuf payload */
2562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2563 rte_pktmbuf_tailroom(ut_params->ibuf));
2566 * Append data which is padded to a
2567 * multiple of the algorithms block size
2569 ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
2571 ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2572 ciphertext_pad_len);
2573 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
2575 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2577 /* Create SNOW3G operation */
2578 retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
2579 tdata->validCipherLenInBits.len,
2580 tdata->validCipherOffsetLenInBits.len);
2584 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2586 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2587 ut_params->obuf = ut_params->op->sym->m_src;
2588 if (ut_params->obuf)
2589 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2592 plaintext = ciphertext;
2593 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2594 if (lastByteValidBits == 0)
2595 lastByteValidBits = 8;
2596 lastByteMask = lastByteMask << (8 - lastByteValidBits);
2597 (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2599 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2602 TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
2603 tdata->plaintext.data,
2604 tdata->plaintext.len >> 3,
2605 "Snow3G Plaintext data not as expected");
2609 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
2611 struct crypto_testsuite_params *ts_params = &testsuite_params;
2612 struct crypto_unittest_params *ut_params = &unittest_params;
2616 uint8_t *plaintext, *ciphertext;
2617 uint8_t ciphertext_pad_len;
2618 uint8_t lastByteValidBits = 8;
2619 uint8_t lastByteMask = 0xFF;
2621 /* Create SNOW3G session */
2622 retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
2623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2624 tdata->key.data, tdata->key.len);
2628 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2629 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2631 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2632 "Failed to allocate input buffer");
2633 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2634 "Failed to allocate output buffer");
2636 /* Clear mbuf payload */
2637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2638 rte_pktmbuf_tailroom(ut_params->ibuf));
2640 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
2641 rte_pktmbuf_tailroom(ut_params->obuf));
2644 * Append data which is padded to a
2645 * multiple of the algorithms block size
2647 ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
2649 ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2650 ciphertext_pad_len);
2652 rte_pktmbuf_append(ut_params->obuf,
2653 ciphertext_pad_len);
2655 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
2657 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2659 /* Create SNOW3G operation */
2660 retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
2662 tdata->validCipherLenInBits.len,
2663 tdata->validCipherOffsetLenInBits.len);
2667 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2669 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2670 ut_params->obuf = ut_params->op->sym->m_dst;
2671 if (ut_params->obuf)
2672 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2675 plaintext = ciphertext;
2676 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2677 if (lastByteValidBits == 0)
2678 lastByteValidBits = 8;
2679 lastByteMask = lastByteMask << (8 - lastByteValidBits);
2680 (*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2682 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2685 TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
2686 tdata->plaintext.data,
2687 tdata->plaintext.len >> 3,
2688 "Snow3G Plaintext data not as expected");
2693 test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
2695 struct crypto_testsuite_params *ts_params = &testsuite_params;
2696 struct crypto_unittest_params *ut_params = &unittest_params;
2700 uint8_t *plaintext, *ciphertext;
2701 uint8_t plaintext_pad_len;
2702 uint8_t lastByteValidBits = 8;
2703 uint8_t lastByteMask = 0xFF;
2705 /* Create SNOW3G session */
2706 retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
2707 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2708 RTE_CRYPTO_AUTH_OP_GENERATE,
2709 tdata->key.data, tdata->key.len,
2710 tdata->aad.len, tdata->digest.len);
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 /* clear mbuf payload */
2716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2717 rte_pktmbuf_tailroom(ut_params->ibuf));
2719 /* Append data which is padded to a multiple */
2720 /* of the algorithms block size */
2721 plaintext_pad_len = tdata->plaintext.len >> 3;
2723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2725 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
2727 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2729 /* Create SNOW3G operation */
2730 retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
2731 tdata->digest.len, tdata->aad.data,
2732 tdata->aad.len, /*tdata->plaintext.len,*/
2733 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2734 tdata->iv.data, tdata->iv.len,
2735 tdata->validCipherLenInBits.len,
2736 tdata->validCipherOffsetLenInBits.len,
2737 tdata->validAuthLenInBits.len,
2738 tdata->validAuthOffsetLenInBits.len);
2742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2744 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2745 ut_params->obuf = ut_params->op->sym->m_src;
2746 if (ut_params->obuf)
2747 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2750 ciphertext = plaintext;
2751 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2752 if (lastByteValidBits == 0)
2753 lastByteValidBits = 8;
2754 lastByteMask = lastByteMask << (8-lastByteValidBits);
2755 (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2757 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2760 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2762 tdata->ciphertext.data,
2763 tdata->ciphertext.len >> 3,
2764 "Snow3G Ciphertext data not as expected");
2766 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2767 + plaintext_pad_len + tdata->aad.len;
2770 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2773 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2774 "Snow3G Generated auth tag not as expected");
2778 test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
2780 struct crypto_testsuite_params *ts_params = &testsuite_params;
2781 struct crypto_unittest_params *ut_params = &unittest_params;
2785 uint8_t *plaintext, *ciphertext;
2786 uint8_t plaintext_pad_len;
2787 uint8_t lastByteValidBits = 8;
2788 uint8_t lastByteMask = 0xFF;
2790 /* Create SNOW3G session */
2791 retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
2792 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2793 RTE_CRYPTO_AUTH_OP_GENERATE,
2794 tdata->key.data, tdata->key.len,
2795 tdata->aad.len, tdata->digest.len);
2799 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2801 /* clear mbuf payload */
2802 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2803 rte_pktmbuf_tailroom(ut_params->ibuf));
2805 /* Append data which is padded to a multiple */
2806 /* of the algorithms block size */
2807 plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
2809 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2811 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
2813 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2815 /* Create SNOW3G operation */
2816 retval = create_snow3g_auth_cipher_operation(
2818 tdata->iv.data, tdata->iv.len,
2819 tdata->aad.data, tdata->aad.len,
2821 tdata->validCipherLenInBits.len,
2822 tdata->validCipherOffsetLenInBits.len,
2823 tdata->validAuthLenInBits.len,
2824 tdata->validAuthOffsetLenInBits.len
2830 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2832 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2833 ut_params->obuf = ut_params->op->sym->m_src;
2834 if (ut_params->obuf)
2835 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2836 + tdata->aad.len + tdata->iv.len;
2838 ciphertext = plaintext;
2840 lastByteValidBits = (tdata->validDataLenInBits.len % 8);
2841 if (lastByteValidBits == 0)
2842 lastByteValidBits = 8;
2843 lastByteMask = lastByteMask << (8-lastByteValidBits);
2844 (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
2845 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2846 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
2847 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
2850 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2852 tdata->ciphertext.data,
2853 tdata->ciphertext.len >> 3,
2854 "Snow3G Ciphertext data not as expected");
2857 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2860 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2861 "Snow3G Generated auth tag not as expected");
2866 test_kasumi_encryption_test_case_1(void)
2868 return test_kasumi_encryption(&kasumi_test_case_1);
2872 test_kasumi_encryption_test_case_1_oop(void)
2874 return test_kasumi_encryption_oop(&kasumi_test_case_1);
2878 test_kasumi_encryption_test_case_2(void)
2880 return test_kasumi_encryption(&kasumi_test_case_2);
2884 test_kasumi_encryption_test_case_3(void)
2886 return test_kasumi_encryption(&kasumi_test_case_3);
2890 test_kasumi_encryption_test_case_4(void)
2892 return test_kasumi_encryption(&kasumi_test_case_4);
2896 test_kasumi_encryption_test_case_5(void)
2898 return test_kasumi_encryption(&kasumi_test_case_5);
2902 test_kasumi_decryption_test_case_1(void)
2904 return test_kasumi_decryption(&kasumi_test_case_1);
2908 test_kasumi_decryption_test_case_1_oop(void)
2910 return test_kasumi_decryption_oop(&kasumi_test_case_1);
2914 test_kasumi_decryption_test_case_2(void)
2916 return test_kasumi_decryption(&kasumi_test_case_2);
2920 test_kasumi_decryption_test_case_3(void)
2922 return test_kasumi_decryption(&kasumi_test_case_3);
2926 test_kasumi_decryption_test_case_4(void)
2928 return test_kasumi_decryption(&kasumi_test_case_4);
2932 test_kasumi_decryption_test_case_5(void)
2934 return test_kasumi_decryption(&kasumi_test_case_5);
2937 test_snow3g_encryption_test_case_1(void)
2939 return test_snow3g_encryption(&snow3g_test_case_1);
2943 test_snow3g_encryption_test_case_1_oop(void)
2945 return test_snow3g_encryption_oop(&snow3g_test_case_1);
2949 test_snow3g_encryption_test_case_2(void)
2951 return test_snow3g_encryption(&snow3g_test_case_2);
2955 test_snow3g_encryption_test_case_3(void)
2957 return test_snow3g_encryption(&snow3g_test_case_3);
2961 test_snow3g_encryption_test_case_4(void)
2963 return test_snow3g_encryption(&snow3g_test_case_4);
2967 test_snow3g_encryption_test_case_5(void)
2969 return test_snow3g_encryption(&snow3g_test_case_5);
2973 test_snow3g_decryption_test_case_1(void)
2975 return test_snow3g_decryption(&snow3g_test_case_1);
2979 test_snow3g_decryption_test_case_1_oop(void)
2981 return test_snow3g_decryption_oop(&snow3g_test_case_1);
2985 test_snow3g_decryption_test_case_2(void)
2987 return test_snow3g_decryption(&snow3g_test_case_2);
2991 test_snow3g_decryption_test_case_3(void)
2993 return test_snow3g_decryption(&snow3g_test_case_3);
2997 test_snow3g_decryption_test_case_4(void)
2999 return test_snow3g_decryption(&snow3g_test_case_4);
3003 test_snow3g_decryption_test_case_5(void)
3005 return test_snow3g_decryption(&snow3g_test_case_5);
3008 test_snow3g_authenticated_encryption_test_case_1(void)
3010 return test_snow3g_authenticated_encryption(&snow3g_test_case_3);
3014 test_snow3g_encrypted_authentication_test_case_1(void)
3016 return test_snow3g_encrypted_authentication(&snow3g_test_case_6);
3019 /* ***** AES-GCM Tests ***** */
3022 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3023 const uint8_t *key, const uint8_t key_len,
3024 const uint8_t aad_len, const uint8_t auth_len)
3026 uint8_t cipher_key[key_len];
3028 struct crypto_unittest_params *ut_params = &unittest_params;
3031 memcpy(cipher_key, key, key_len);
3033 /* Setup Cipher Parameters */
3034 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3035 ut_params->cipher_xform.next = NULL;
3037 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3038 ut_params->cipher_xform.cipher.op = op;
3039 ut_params->cipher_xform.cipher.key.data = cipher_key;
3040 ut_params->cipher_xform.cipher.key.length = key_len;
3042 TEST_HEXDUMP(stdout, "key:", key, key_len);
3044 /* Setup Authentication Parameters */
3045 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3046 ut_params->auth_xform.next = NULL;
3048 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3050 ut_params->auth_xform.auth.digest_length = auth_len;
3051 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3052 ut_params->auth_xform.auth.key.length = 0;
3053 ut_params->auth_xform.auth.key.data = NULL;
3055 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3056 ut_params->cipher_xform.next = &ut_params->auth_xform;
3058 /* Create Crypto session*/
3059 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3060 &ut_params->cipher_xform);
3061 } else {/* Create Crypto session*/
3062 ut_params->auth_xform.next = &ut_params->cipher_xform;
3063 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3064 &ut_params->auth_xform);
3067 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3073 create_gcm_operation(enum rte_crypto_cipher_operation op,
3074 const uint8_t *auth_tag, const unsigned auth_tag_len,
3075 const uint8_t *iv, const unsigned iv_len,
3076 const uint8_t *aad, const unsigned aad_len,
3077 const unsigned data_len, unsigned data_pad_len)
3079 struct crypto_testsuite_params *ts_params = &testsuite_params;
3080 struct crypto_unittest_params *ut_params = &unittest_params;
3082 unsigned iv_pad_len = 0, aad_buffer_len;
3084 /* Generate Crypto op data structure */
3085 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3086 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3087 TEST_ASSERT_NOT_NULL(ut_params->op,
3088 "Failed to allocate symmetric crypto operation struct");
3090 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3094 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3095 ut_params->ibuf, auth_tag_len);
3096 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3097 "no room to append digest");
3098 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3099 ut_params->ibuf, data_pad_len);
3100 sym_op->auth.digest.length = auth_tag_len;
3102 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3103 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3104 TEST_HEXDUMP(stdout, "digest:",
3105 sym_op->auth.digest.data,
3106 sym_op->auth.digest.length);
3110 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3112 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3113 ut_params->ibuf, iv_pad_len);
3114 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3116 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3117 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3118 sym_op->cipher.iv.length = iv_pad_len;
3120 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3124 sym_op->cipher.iv.data[15] = 1;
3127 * Always allocate the aad up to the block size.
3128 * The cryptodev API calls out -
3129 * - the array must be big enough to hold the AAD, plus any
3130 * space to round this up to the nearest multiple of the
3131 * block size (16 bytes).
3133 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3135 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3136 ut_params->ibuf, aad_buffer_len);
3137 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3138 "no room to prepend aad");
3139 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3141 sym_op->auth.aad.length = aad_len;
3143 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3144 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3146 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3147 TEST_HEXDUMP(stdout, "aad:",
3148 sym_op->auth.aad.data, aad_len);
3150 sym_op->cipher.data.length = data_len;
3151 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3153 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3154 sym_op->auth.data.length = data_len;
3160 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3162 struct crypto_testsuite_params *ts_params = &testsuite_params;
3163 struct crypto_unittest_params *ut_params = &unittest_params;
3167 uint8_t *plaintext, *ciphertext, *auth_tag;
3168 uint16_t plaintext_pad_len;
3170 /* Create GCM session */
3171 retval = create_gcm_session(ts_params->valid_devs[0],
3172 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3173 tdata->key.data, tdata->key.len,
3174 tdata->aad.len, tdata->auth_tag.len);
3179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3181 /* clear mbuf payload */
3182 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3183 rte_pktmbuf_tailroom(ut_params->ibuf));
3186 * Append data which is padded to a multiple
3187 * of the algorithms block size
3189 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
3191 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3193 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
3195 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3197 /* Create GCM opertaion */
3198 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3199 tdata->auth_tag.data, tdata->auth_tag.len,
3200 tdata->iv.data, tdata->iv.len,
3201 tdata->aad.data, tdata->aad.len,
3202 tdata->plaintext.len, plaintext_pad_len);
3206 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3208 ut_params->op->sym->m_src = ut_params->ibuf;
3210 /* Process crypto operation */
3211 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3212 ut_params->op), "failed to process sym crypto op");
3214 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3215 "crypto op processing failed");
3217 if (ut_params->op->sym->m_dst) {
3218 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3220 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
3221 uint8_t *, plaintext_pad_len);
3223 ciphertext = plaintext;
3224 auth_tag = plaintext + plaintext_pad_len;
3227 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3228 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
3231 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3233 tdata->ciphertext.data,
3234 tdata->ciphertext.len,
3235 "GCM Ciphertext data not as expected");
3237 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3239 tdata->auth_tag.data,
3240 tdata->auth_tag.len,
3241 "GCM Generated auth tag not as expected");
3248 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
3250 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
3254 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
3256 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
3260 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
3262 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
3266 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
3268 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
3272 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
3274 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
3278 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
3280 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
3284 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
3286 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
3290 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
3292 struct crypto_testsuite_params *ts_params = &testsuite_params;
3293 struct crypto_unittest_params *ut_params = &unittest_params;
3297 uint8_t *plaintext, *ciphertext;
3298 uint16_t ciphertext_pad_len;
3300 /* Create GCM session */
3301 retval = create_gcm_session(ts_params->valid_devs[0],
3302 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3303 tdata->key.data, tdata->key.len,
3304 tdata->aad.len, tdata->auth_tag.len);
3309 /* alloc mbuf and set payload */
3310 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3312 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3313 rte_pktmbuf_tailroom(ut_params->ibuf));
3315 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
3317 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3318 ciphertext_pad_len);
3319 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
3321 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
3323 /* Create GCM opertaion */
3324 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
3325 tdata->auth_tag.data, tdata->auth_tag.len,
3326 tdata->iv.data, tdata->iv.len,
3327 tdata->aad.data, tdata->aad.len,
3328 tdata->ciphertext.len, ciphertext_pad_len);
3333 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3335 ut_params->op->sym->m_src = ut_params->ibuf;
3337 /* Process crypto operation */
3338 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
3339 ut_params->op), "failed to process sym crypto op");
3341 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3342 "crypto op processing failed");
3344 if (ut_params->op->sym->m_dst)
3345 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
3348 plaintext = ciphertext;
3350 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
3353 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3355 tdata->plaintext.data,
3356 tdata->plaintext.len,
3357 "GCM plaintext data not as expected");
3359 TEST_ASSERT_EQUAL(ut_params->op->status,
3360 RTE_CRYPTO_OP_STATUS_SUCCESS,
3361 "GCM authentication failed");
3366 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
3368 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
3372 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
3374 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
3378 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
3380 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
3384 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
3386 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
3390 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
3392 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
3396 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
3398 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
3402 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
3404 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
3410 struct crypto_testsuite_params *ts_params = &testsuite_params;
3411 struct rte_cryptodev_stats stats;
3412 struct rte_cryptodev *dev;
3413 cryptodev_stats_get_t temp_pfn;
3415 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3416 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
3417 &stats) == -ENODEV),
3418 "rte_cryptodev_stats_get invalid dev failed");
3419 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
3420 "rte_cryptodev_stats_get invalid Param failed");
3421 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
3422 temp_pfn = dev->dev_ops->stats_get;
3423 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
3424 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
3426 "rte_cryptodev_stats_get invalid Param failed");
3427 dev->dev_ops->stats_get = temp_pfn;
3429 /* Test expected values */
3431 test_AES_CBC_HMAC_SHA1_encrypt_digest();
3433 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3435 "rte_cryptodev_stats_get failed");
3436 TEST_ASSERT((stats.enqueued_count == 1),
3437 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3438 TEST_ASSERT((stats.dequeued_count == 1),
3439 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3440 TEST_ASSERT((stats.enqueue_err_count == 0),
3441 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3442 TEST_ASSERT((stats.dequeue_err_count == 0),
3443 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3445 /* invalid device but should ignore and not reset device stats*/
3446 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
3447 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3449 "rte_cryptodev_stats_get failed");
3450 TEST_ASSERT((stats.enqueued_count == 1),
3451 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3453 /* check that a valid reset clears stats */
3454 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
3455 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
3457 "rte_cryptodev_stats_get failed");
3458 TEST_ASSERT((stats.enqueued_count == 0),
3459 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3460 TEST_ASSERT((stats.dequeued_count == 0),
3461 "rte_cryptodev_stats_get returned unexpected enqueued stat");
3463 return TEST_SUCCESS;
3468 test_multi_session(void)
3470 struct crypto_testsuite_params *ts_params = &testsuite_params;
3471 struct crypto_unittest_params *ut_params = &unittest_params;
3473 struct rte_cryptodev_info dev_info;
3474 struct rte_cryptodev_sym_session **sessions;
3478 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params);
3481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3483 sessions = rte_malloc(NULL,
3484 (sizeof(struct rte_cryptodev_sym_session *) *
3485 dev_info.sym.max_nb_sessions) + 1, 0);
3487 /* Create multiple crypto sessions*/
3488 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
3489 sessions[i] = rte_cryptodev_sym_session_create(
3490 ts_params->valid_devs[0],
3491 &ut_params->auth_xform);
3492 TEST_ASSERT_NOT_NULL(sessions[i],
3493 "Session creation failed at session number %u",
3496 /* Attempt to send a request on each session */
3497 TEST_ASSERT_SUCCESS(test_AES_CBC_HMAC_SHA512_decrypt_perform(
3498 sessions[i], ut_params, ts_params),
3499 "Failed to perform decrypt on request "
3501 /* free crypto operation structure */
3503 rte_crypto_op_free(ut_params->op);
3506 * free mbuf - both obuf and ibuf are usually the same,
3507 * but rte copes even if we call free twice
3509 if (ut_params->obuf) {
3510 rte_pktmbuf_free(ut_params->obuf);
3511 ut_params->obuf = 0;
3515 /* Next session create should fail */
3516 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
3517 &ut_params->auth_xform);
3518 TEST_ASSERT_NULL(sessions[i],
3519 "Session creation succeeded unexpectedly!");
3521 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
3522 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
3527 return TEST_SUCCESS;
3531 test_null_cipher_only_operation(void)
3533 struct crypto_testsuite_params *ts_params = &testsuite_params;
3534 struct crypto_unittest_params *ut_params = &unittest_params;
3536 /* Generate test mbuf data and space for digest */
3537 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3538 catch_22_quote, QUOTE_512_BYTES, 0);
3540 /* Setup Cipher Parameters */
3541 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3542 ut_params->cipher_xform.next = NULL;
3544 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3545 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3547 /* Create Crypto session*/
3548 ut_params->sess = rte_cryptodev_sym_session_create(
3549 ts_params->valid_devs[0], &ut_params->cipher_xform);
3550 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3552 /* Generate Crypto op data structure */
3553 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3554 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3555 TEST_ASSERT_NOT_NULL(ut_params->op,
3556 "Failed to allocate symmetric crypto operation struct");
3558 /* Set crypto operation data parameters */
3559 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3561 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3563 /* set crypto operation source mbuf */
3564 sym_op->m_src = ut_params->ibuf;
3566 sym_op->cipher.data.offset = 0;
3567 sym_op->cipher.data.length = QUOTE_512_BYTES;
3569 /* Process crypto operation */
3570 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3572 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3575 "crypto operation processing failed");
3578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3579 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3582 "Ciphertext data not as expected");
3584 return TEST_SUCCESS;
3588 test_null_auth_only_operation(void)
3590 struct crypto_testsuite_params *ts_params = &testsuite_params;
3591 struct crypto_unittest_params *ut_params = &unittest_params;
3593 /* Generate test mbuf data and space for digest */
3594 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3595 catch_22_quote, QUOTE_512_BYTES, 0);
3597 /* Setup HMAC Parameters */
3598 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3599 ut_params->auth_xform.next = NULL;
3601 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3602 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3604 /* Create Crypto session*/
3605 ut_params->sess = rte_cryptodev_sym_session_create(
3606 ts_params->valid_devs[0], &ut_params->auth_xform);
3607 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3609 /* Generate Crypto op data structure */
3610 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3611 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3612 TEST_ASSERT_NOT_NULL(ut_params->op,
3613 "Failed to allocate symmetric crypto operation struct");
3615 /* Set crypto operation data parameters */
3616 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3618 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3620 sym_op->m_src = ut_params->ibuf;
3622 sym_op->auth.data.offset = 0;
3623 sym_op->auth.data.length = QUOTE_512_BYTES;
3625 /* Process crypto operation */
3626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3628 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3630 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3631 "crypto operation processing failed");
3633 return TEST_SUCCESS;
3637 test_null_cipher_auth_operation(void)
3639 struct crypto_testsuite_params *ts_params = &testsuite_params;
3640 struct crypto_unittest_params *ut_params = &unittest_params;
3642 /* Generate test mbuf data and space for digest */
3643 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3644 catch_22_quote, QUOTE_512_BYTES, 0);
3646 /* Setup Cipher Parameters */
3647 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3648 ut_params->cipher_xform.next = &ut_params->auth_xform;
3650 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3651 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3653 /* Setup HMAC Parameters */
3654 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3655 ut_params->auth_xform.next = NULL;
3657 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3658 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3660 /* Create Crypto session*/
3661 ut_params->sess = rte_cryptodev_sym_session_create(
3662 ts_params->valid_devs[0], &ut_params->cipher_xform);
3663 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3665 /* Generate Crypto op data structure */
3666 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3667 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3668 TEST_ASSERT_NOT_NULL(ut_params->op,
3669 "Failed to allocate symmetric crypto operation struct");
3671 /* Set crypto operation data parameters */
3672 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3674 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3676 sym_op->m_src = ut_params->ibuf;
3678 sym_op->cipher.data.offset = 0;
3679 sym_op->cipher.data.length = QUOTE_512_BYTES;
3681 sym_op->auth.data.offset = 0;
3682 sym_op->auth.data.length = QUOTE_512_BYTES;
3684 /* Process crypto operation */
3685 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3687 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3689 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3690 "crypto operation processing failed");
3693 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3694 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3697 "Ciphertext data not as expected");
3699 return TEST_SUCCESS;
3703 test_null_auth_cipher_operation(void)
3705 struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 struct crypto_unittest_params *ut_params = &unittest_params;
3708 /* Generate test mbuf data and space for digest */
3709 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
3710 catch_22_quote, QUOTE_512_BYTES, 0);
3712 /* Setup Cipher Parameters */
3713 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3714 ut_params->cipher_xform.next = NULL;
3716 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3717 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3719 /* Setup HMAC Parameters */
3720 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3721 ut_params->auth_xform.next = &ut_params->cipher_xform;
3723 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3724 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3726 /* Create Crypto session*/
3727 ut_params->sess = rte_cryptodev_sym_session_create(
3728 ts_params->valid_devs[0], &ut_params->cipher_xform);
3729 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3731 /* Generate Crypto op data structure */
3732 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3733 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3734 TEST_ASSERT_NOT_NULL(ut_params->op,
3735 "Failed to allocate symmetric crypto operation struct");
3737 /* Set crypto operation data parameters */
3738 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3740 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3742 sym_op->m_src = ut_params->ibuf;
3744 sym_op->cipher.data.offset = 0;
3745 sym_op->cipher.data.length = QUOTE_512_BYTES;
3747 sym_op->auth.data.offset = 0;
3748 sym_op->auth.data.length = QUOTE_512_BYTES;
3750 /* Process crypto operation */
3751 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3753 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
3755 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
3756 "crypto operation processing failed");
3759 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3760 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
3763 "Ciphertext data not as expected");
3765 return TEST_SUCCESS;
3770 test_null_invalid_operation(void)
3772 struct crypto_testsuite_params *ts_params = &testsuite_params;
3773 struct crypto_unittest_params *ut_params = &unittest_params;
3775 /* Setup Cipher Parameters */
3776 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3777 ut_params->cipher_xform.next = NULL;
3779 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
3780 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3782 /* Create Crypto session*/
3783 ut_params->sess = rte_cryptodev_sym_session_create(
3784 ts_params->valid_devs[0], &ut_params->cipher_xform);
3785 TEST_ASSERT_NULL(ut_params->sess,
3786 "Session creation succeeded unexpectedly");
3789 /* Setup HMAC Parameters */
3790 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3791 ut_params->auth_xform.next = NULL;
3793 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
3794 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3796 /* Create Crypto session*/
3797 ut_params->sess = rte_cryptodev_sym_session_create(
3798 ts_params->valid_devs[0], &ut_params->auth_xform);
3799 TEST_ASSERT_NULL(ut_params->sess,
3800 "Session creation succeeded unexpectedly");
3802 return TEST_SUCCESS;
3806 #define NULL_BURST_LENGTH (32)
3809 test_null_burst_operation(void)
3811 struct crypto_testsuite_params *ts_params = &testsuite_params;
3812 struct crypto_unittest_params *ut_params = &unittest_params;
3814 unsigned i, burst_len = NULL_BURST_LENGTH;
3816 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
3817 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
3819 /* Setup Cipher Parameters */
3820 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3821 ut_params->cipher_xform.next = &ut_params->auth_xform;
3823 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
3824 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
3826 /* Setup HMAC Parameters */
3827 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3828 ut_params->auth_xform.next = NULL;
3830 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
3831 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
3833 /* Create Crypto session*/
3834 ut_params->sess = rte_cryptodev_sym_session_create(
3835 ts_params->valid_devs[0], &ut_params->cipher_xform);
3836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3838 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3839 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
3840 burst_len, "failed to generate burst of crypto ops");
3842 /* Generate an operation for each mbuf in burst */
3843 for (i = 0; i < burst_len; i++) {
3844 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3846 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
3848 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
3852 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
3854 burst[i]->sym->m_src = m;
3857 /* Process crypto operation */
3858 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
3859 0, burst, burst_len),
3861 "Error enqueuing burst");
3863 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
3864 0, burst_dequeued, burst_len),
3866 "Error dequeuing burst");
3869 for (i = 0; i < burst_len; i++) {
3871 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
3872 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
3874 "data not as expected");
3876 rte_pktmbuf_free(burst[i]->sym->m_src);
3877 rte_crypto_op_free(burst[i]);
3880 return TEST_SUCCESS;
3886 static struct unit_test_suite cryptodev_qat_testsuite = {
3887 .suite_name = "Crypto QAT Unit Test Suite",
3888 .setup = testsuite_setup,
3889 .teardown = testsuite_teardown,
3890 .unit_test_cases = {
3891 TEST_CASE_ST(ut_setup, ut_teardown,
3892 test_device_configure_invalid_dev_id),
3893 TEST_CASE_ST(ut_setup, ut_teardown,
3894 test_device_configure_invalid_queue_pair_ids),
3895 TEST_CASE_ST(ut_setup, ut_teardown,
3896 test_queue_pair_descriptor_setup),
3897 TEST_CASE_ST(ut_setup, ut_teardown,
3898 test_multi_session),
3900 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_qat_all),
3901 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
3903 /** AES GCM Authenticated Encryption */
3904 TEST_CASE_ST(ut_setup, ut_teardown,
3905 test_mb_AES_GCM_authenticated_encryption_test_case_1),
3906 TEST_CASE_ST(ut_setup, ut_teardown,
3907 test_mb_AES_GCM_authenticated_encryption_test_case_2),
3908 TEST_CASE_ST(ut_setup, ut_teardown,
3909 test_mb_AES_GCM_authenticated_encryption_test_case_3),
3910 TEST_CASE_ST(ut_setup, ut_teardown,
3911 test_mb_AES_GCM_authenticated_encryption_test_case_4),
3912 TEST_CASE_ST(ut_setup, ut_teardown,
3913 test_mb_AES_GCM_authenticated_encryption_test_case_5),
3914 TEST_CASE_ST(ut_setup, ut_teardown,
3915 test_mb_AES_GCM_authenticated_encryption_test_case_6),
3916 TEST_CASE_ST(ut_setup, ut_teardown,
3917 test_mb_AES_GCM_authenticated_encryption_test_case_7),
3919 /** AES GCM Authenticated Decryption */
3920 TEST_CASE_ST(ut_setup, ut_teardown,
3921 test_mb_AES_GCM_authenticated_decryption_test_case_1),
3922 TEST_CASE_ST(ut_setup, ut_teardown,
3923 test_mb_AES_GCM_authenticated_decryption_test_case_2),
3924 TEST_CASE_ST(ut_setup, ut_teardown,
3925 test_mb_AES_GCM_authenticated_decryption_test_case_3),
3926 TEST_CASE_ST(ut_setup, ut_teardown,
3927 test_mb_AES_GCM_authenticated_decryption_test_case_4),
3928 TEST_CASE_ST(ut_setup, ut_teardown,
3929 test_mb_AES_GCM_authenticated_decryption_test_case_5),
3930 TEST_CASE_ST(ut_setup, ut_teardown,
3931 test_mb_AES_GCM_authenticated_decryption_test_case_6),
3932 TEST_CASE_ST(ut_setup, ut_teardown,
3933 test_mb_AES_GCM_authenticated_decryption_test_case_7),
3935 /** Snow3G encrypt only (UEA2) */
3936 TEST_CASE_ST(ut_setup, ut_teardown,
3937 test_snow3g_encryption_test_case_1),
3938 TEST_CASE_ST(ut_setup, ut_teardown,
3939 test_snow3g_encryption_test_case_2),
3940 TEST_CASE_ST(ut_setup, ut_teardown,
3941 test_snow3g_encryption_test_case_3),
3942 TEST_CASE_ST(ut_setup, ut_teardown,
3943 test_snow3g_encryption_test_case_4),
3944 TEST_CASE_ST(ut_setup, ut_teardown,
3945 test_snow3g_encryption_test_case_5),
3947 TEST_CASE_ST(ut_setup, ut_teardown,
3948 test_snow3g_encryption_test_case_1_oop),
3949 TEST_CASE_ST(ut_setup, ut_teardown,
3950 test_snow3g_decryption_test_case_1_oop),
3952 /** Snow3G decrypt only (UEA2) */
3953 TEST_CASE_ST(ut_setup, ut_teardown,
3954 test_snow3g_decryption_test_case_1),
3955 TEST_CASE_ST(ut_setup, ut_teardown,
3956 test_snow3g_decryption_test_case_2),
3957 TEST_CASE_ST(ut_setup, ut_teardown,
3958 test_snow3g_decryption_test_case_3),
3959 TEST_CASE_ST(ut_setup, ut_teardown,
3960 test_snow3g_decryption_test_case_4),
3961 TEST_CASE_ST(ut_setup, ut_teardown,
3962 test_snow3g_decryption_test_case_5),
3963 TEST_CASE_ST(ut_setup, ut_teardown,
3964 test_snow3g_hash_generate_test_case_1),
3965 TEST_CASE_ST(ut_setup, ut_teardown,
3966 test_snow3g_hash_generate_test_case_2),
3967 TEST_CASE_ST(ut_setup, ut_teardown,
3968 test_snow3g_hash_generate_test_case_3),
3969 TEST_CASE_ST(ut_setup, ut_teardown,
3970 test_snow3g_hash_verify_test_case_1),
3971 TEST_CASE_ST(ut_setup, ut_teardown,
3972 test_snow3g_hash_verify_test_case_2),
3973 TEST_CASE_ST(ut_setup, ut_teardown,
3974 test_snow3g_hash_verify_test_case_3),
3975 TEST_CASE_ST(ut_setup, ut_teardown,
3976 test_snow3g_authenticated_encryption_test_case_1),
3977 TEST_CASE_ST(ut_setup, ut_teardown,
3978 test_snow3g_encrypted_authentication_test_case_1),
3979 TEST_CASES_END() /**< NULL terminate unit test array */
3983 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
3984 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
3985 .setup = testsuite_setup,
3986 .teardown = testsuite_teardown,
3987 .unit_test_cases = {
3988 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_mb_all),
3990 TEST_CASES_END() /**< NULL terminate unit test array */
3994 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
3995 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
3996 .setup = testsuite_setup,
3997 .teardown = testsuite_teardown,
3998 .unit_test_cases = {
3999 /** AES GCM Authenticated Encryption */
4000 TEST_CASE_ST(ut_setup, ut_teardown,
4001 test_mb_AES_GCM_authenticated_encryption_test_case_1),
4002 TEST_CASE_ST(ut_setup, ut_teardown,
4003 test_mb_AES_GCM_authenticated_encryption_test_case_2),
4004 TEST_CASE_ST(ut_setup, ut_teardown,
4005 test_mb_AES_GCM_authenticated_encryption_test_case_3),
4006 TEST_CASE_ST(ut_setup, ut_teardown,
4007 test_mb_AES_GCM_authenticated_encryption_test_case_4),
4008 TEST_CASE_ST(ut_setup, ut_teardown,
4009 test_mb_AES_GCM_authenticated_encryption_test_case_5),
4010 TEST_CASE_ST(ut_setup, ut_teardown,
4011 test_mb_AES_GCM_authenticated_encryption_test_case_6),
4012 TEST_CASE_ST(ut_setup, ut_teardown,
4013 test_mb_AES_GCM_authenticated_encryption_test_case_7),
4015 /** AES GCM Authenticated Decryption */
4016 TEST_CASE_ST(ut_setup, ut_teardown,
4017 test_mb_AES_GCM_authenticated_decryption_test_case_1),
4018 TEST_CASE_ST(ut_setup, ut_teardown,
4019 test_mb_AES_GCM_authenticated_decryption_test_case_2),
4020 TEST_CASE_ST(ut_setup, ut_teardown,
4021 test_mb_AES_GCM_authenticated_decryption_test_case_3),
4022 TEST_CASE_ST(ut_setup, ut_teardown,
4023 test_mb_AES_GCM_authenticated_decryption_test_case_4),
4024 TEST_CASE_ST(ut_setup, ut_teardown,
4025 test_mb_AES_GCM_authenticated_decryption_test_case_5),
4026 TEST_CASE_ST(ut_setup, ut_teardown,
4027 test_mb_AES_GCM_authenticated_decryption_test_case_6),
4028 TEST_CASE_ST(ut_setup, ut_teardown,
4029 test_mb_AES_GCM_authenticated_decryption_test_case_7),
4031 TEST_CASES_END() /**< NULL terminate unit test array */
4035 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
4036 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
4037 .setup = testsuite_setup,
4038 .teardown = testsuite_teardown,
4039 .unit_test_cases = {
4040 /** KASUMI encrypt only (UEA1) */
4041 TEST_CASE_ST(ut_setup, ut_teardown,
4042 test_kasumi_encryption_test_case_1),
4043 TEST_CASE_ST(ut_setup, ut_teardown,
4044 test_kasumi_encryption_test_case_2),
4045 TEST_CASE_ST(ut_setup, ut_teardown,
4046 test_kasumi_encryption_test_case_3),
4047 TEST_CASE_ST(ut_setup, ut_teardown,
4048 test_kasumi_encryption_test_case_4),
4049 TEST_CASE_ST(ut_setup, ut_teardown,
4050 test_kasumi_encryption_test_case_5),
4051 /** KASUMI decrypt only (UEA1) */
4052 TEST_CASE_ST(ut_setup, ut_teardown,
4053 test_kasumi_decryption_test_case_1),
4054 TEST_CASE_ST(ut_setup, ut_teardown,
4055 test_kasumi_decryption_test_case_2),
4056 TEST_CASE_ST(ut_setup, ut_teardown,
4057 test_kasumi_decryption_test_case_3),
4058 TEST_CASE_ST(ut_setup, ut_teardown,
4059 test_kasumi_decryption_test_case_4),
4060 TEST_CASE_ST(ut_setup, ut_teardown,
4061 test_kasumi_decryption_test_case_5),
4063 TEST_CASE_ST(ut_setup, ut_teardown,
4064 test_kasumi_encryption_test_case_1_oop),
4065 TEST_CASE_ST(ut_setup, ut_teardown,
4066 test_kasumi_decryption_test_case_1_oop),
4068 /** KASUMI hash only (UIA1) */
4069 TEST_CASE_ST(ut_setup, ut_teardown,
4070 test_kasumi_hash_generate_test_case_1),
4071 TEST_CASE_ST(ut_setup, ut_teardown,
4072 test_kasumi_hash_generate_test_case_2),
4073 TEST_CASE_ST(ut_setup, ut_teardown,
4074 test_kasumi_hash_generate_test_case_3),
4075 TEST_CASE_ST(ut_setup, ut_teardown,
4076 test_kasumi_hash_generate_test_case_4),
4077 TEST_CASE_ST(ut_setup, ut_teardown,
4078 test_kasumi_hash_generate_test_case_5),
4079 TEST_CASE_ST(ut_setup, ut_teardown,
4080 test_kasumi_hash_verify_test_case_1),
4081 TEST_CASE_ST(ut_setup, ut_teardown,
4082 test_kasumi_hash_verify_test_case_2),
4083 TEST_CASE_ST(ut_setup, ut_teardown,
4084 test_kasumi_hash_verify_test_case_3),
4085 TEST_CASE_ST(ut_setup, ut_teardown,
4086 test_kasumi_hash_verify_test_case_4),
4087 TEST_CASE_ST(ut_setup, ut_teardown,
4088 test_kasumi_hash_verify_test_case_5),
4090 TEST_CASES_END() /**< NULL terminate unit test array */
4093 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
4094 .suite_name = "Crypto Device SW Snow3G Unit Test Suite",
4095 .setup = testsuite_setup,
4096 .teardown = testsuite_teardown,
4097 .unit_test_cases = {
4098 /** Snow3G encrypt only (UEA2) */
4099 TEST_CASE_ST(ut_setup, ut_teardown,
4100 test_snow3g_encryption_test_case_1),
4101 TEST_CASE_ST(ut_setup, ut_teardown,
4102 test_snow3g_encryption_test_case_2),
4103 TEST_CASE_ST(ut_setup, ut_teardown,
4104 test_snow3g_encryption_test_case_3),
4105 TEST_CASE_ST(ut_setup, ut_teardown,
4106 test_snow3g_encryption_test_case_4),
4107 TEST_CASE_ST(ut_setup, ut_teardown,
4108 test_snow3g_encryption_test_case_5),
4111 /** Snow3G decrypt only (UEA2) */
4112 TEST_CASE_ST(ut_setup, ut_teardown,
4113 test_snow3g_decryption_test_case_1),
4114 TEST_CASE_ST(ut_setup, ut_teardown,
4115 test_snow3g_decryption_test_case_2),
4116 TEST_CASE_ST(ut_setup, ut_teardown,
4117 test_snow3g_decryption_test_case_3),
4118 TEST_CASE_ST(ut_setup, ut_teardown,
4119 test_snow3g_decryption_test_case_4),
4120 TEST_CASE_ST(ut_setup, ut_teardown,
4121 test_snow3g_decryption_test_case_5),
4122 TEST_CASE_ST(ut_setup, ut_teardown,
4123 test_snow3g_hash_generate_test_case_1),
4124 TEST_CASE_ST(ut_setup, ut_teardown,
4125 test_snow3g_hash_generate_test_case_2),
4126 TEST_CASE_ST(ut_setup, ut_teardown,
4127 test_snow3g_hash_generate_test_case_3),
4128 TEST_CASE_ST(ut_setup, ut_teardown,
4129 test_snow3g_hash_verify_test_case_1),
4130 TEST_CASE_ST(ut_setup, ut_teardown,
4131 test_snow3g_hash_verify_test_case_2),
4132 TEST_CASE_ST(ut_setup, ut_teardown,
4133 test_snow3g_hash_verify_test_case_3),
4134 TEST_CASE_ST(ut_setup, ut_teardown,
4135 test_snow3g_authenticated_encryption_test_case_1),
4136 TEST_CASE_ST(ut_setup, ut_teardown,
4137 test_snow3g_encrypted_authentication_test_case_1),
4139 TEST_CASES_END() /**< NULL terminate unit test array */
4143 static struct unit_test_suite cryptodev_null_testsuite = {
4144 .suite_name = "Crypto Device NULL Unit Test Suite",
4145 .setup = testsuite_setup,
4146 .teardown = testsuite_teardown,
4147 .unit_test_cases = {
4148 TEST_CASE_ST(ut_setup, ut_teardown,
4149 test_null_auth_only_operation),
4150 TEST_CASE_ST(ut_setup, ut_teardown,
4151 test_null_cipher_only_operation),
4152 TEST_CASE_ST(ut_setup, ut_teardown,
4153 test_null_cipher_auth_operation),
4154 TEST_CASE_ST(ut_setup, ut_teardown,
4155 test_null_auth_cipher_operation),
4156 TEST_CASE_ST(ut_setup, ut_teardown,
4157 test_null_invalid_operation),
4158 TEST_CASE_ST(ut_setup, ut_teardown,
4159 test_null_burst_operation),
4161 TEST_CASES_END() /**< NULL terminate unit test array */
4166 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
4168 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
4169 return unit_test_suite_runner(&cryptodev_qat_testsuite);
4171 static struct test_command cryptodev_qat_cmd = {
4172 .command = "cryptodev_qat_autotest",
4173 .callback = test_cryptodev_qat,
4177 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
4179 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
4181 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
4184 static struct test_command cryptodev_aesni_mb_cmd = {
4185 .command = "cryptodev_aesni_mb_autotest",
4186 .callback = test_cryptodev_aesni_mb,
4190 test_cryptodev_aesni_gcm(void)
4192 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
4194 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
4197 static struct test_command cryptodev_aesni_gcm_cmd = {
4198 .command = "cryptodev_aesni_gcm_autotest",
4199 .callback = test_cryptodev_aesni_gcm,
4203 test_cryptodev_null(void)
4205 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
4207 return unit_test_suite_runner(&cryptodev_null_testsuite);
4210 static struct test_command cryptodev_null_cmd = {
4211 .command = "cryptodev_null_autotest",
4212 .callback = test_cryptodev_null,
4216 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
4218 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
4220 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
4223 static struct test_command cryptodev_sw_snow3g_cmd = {
4224 .command = "cryptodev_sw_snow3g_autotest",
4225 .callback = test_cryptodev_sw_snow3g,
4229 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
4231 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
4233 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
4236 static struct test_command cryptodev_sw_kasumi_cmd = {
4237 .command = "cryptodev_sw_kasumi_autotest",
4238 .callback = test_cryptodev_sw_kasumi,
4241 REGISTER_TEST_COMMAND(cryptodev_qat_cmd);
4242 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_cmd);
4243 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_cmd);
4244 REGISTER_TEST_COMMAND(cryptodev_null_cmd);
4245 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_cmd);
4246 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_cmd);