4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_aead_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static int gbl_driver_id;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_mempool *session_mpool;
71 struct rte_cryptodev_config conf;
72 struct rte_cryptodev_qp_conf qp_conf;
74 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
75 uint8_t valid_dev_count;
78 struct crypto_unittest_params {
79 struct rte_crypto_sym_xform cipher_xform;
80 struct rte_crypto_sym_xform auth_xform;
81 struct rte_crypto_sym_xform aead_xform;
83 struct rte_cryptodev_sym_session *sess;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
145 static struct rte_crypto_op *
146 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
148 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
149 printf("Error sending packet for encryption");
155 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
161 static struct crypto_testsuite_params testsuite_params = { NULL };
162 static struct crypto_unittest_params unittest_params;
165 testsuite_setup(void)
167 struct crypto_testsuite_params *ts_params = &testsuite_params;
168 struct rte_cryptodev_info info;
169 uint32_t i = 0, nb_devs, dev_id;
173 memset(ts_params, 0, sizeof(*ts_params));
175 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
176 if (ts_params->mbuf_pool == NULL) {
177 /* Not already created so create */
178 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
180 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
182 if (ts_params->mbuf_pool == NULL) {
183 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
188 ts_params->large_mbuf_pool = rte_mempool_lookup(
189 "CRYPTO_LARGE_MBUFPOOL");
190 if (ts_params->large_mbuf_pool == NULL) {
191 /* Not already created so create */
192 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
193 "CRYPTO_LARGE_MBUFPOOL",
196 if (ts_params->large_mbuf_pool == NULL) {
198 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
203 ts_params->op_mpool = rte_crypto_op_pool_create(
204 "MBUF_CRYPTO_SYM_OP_POOL",
205 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
206 NUM_MBUFS, MBUF_CACHE_SIZE,
208 sizeof(struct rte_crypto_sym_xform) +
211 if (ts_params->op_mpool == NULL) {
212 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
216 /* Create an AESNI MB device if required */
217 if (gbl_driver_id == rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
219 nb_devs = rte_cryptodev_device_count_by_driver(
220 rte_cryptodev_driver_id_get(
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
226 TEST_ASSERT(ret == 0,
227 "Failed to create instance of"
229 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
233 /* Create an AESNI GCM device if required */
234 if (gbl_driver_id == rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
236 nb_devs = rte_cryptodev_device_count_by_driver(
237 rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
240 TEST_ASSERT_SUCCESS(rte_vdev_init(
241 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
242 "Failed to create instance of"
244 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
248 /* Create a SNOW 3G device if required */
249 if (gbl_driver_id == rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
251 nb_devs = rte_cryptodev_device_count_by_driver(
252 rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
255 TEST_ASSERT_SUCCESS(rte_vdev_init(
256 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
257 "Failed to create instance of"
259 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
263 /* Create a KASUMI device if required */
264 if (gbl_driver_id == rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
266 nb_devs = rte_cryptodev_device_count_by_driver(
267 rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
270 TEST_ASSERT_SUCCESS(rte_vdev_init(
271 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
272 "Failed to create instance of"
274 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
278 /* Create a ZUC device if required */
279 if (gbl_driver_id == rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
281 nb_devs = rte_cryptodev_device_count_by_driver(
282 rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
285 TEST_ASSERT_SUCCESS(rte_vdev_init(
286 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
287 "Failed to create instance of"
289 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
293 /* Create a NULL device if required */
294 if (gbl_driver_id == rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
296 nb_devs = rte_cryptodev_device_count_by_driver(
297 rte_cryptodev_driver_id_get(
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
301 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
303 TEST_ASSERT(ret == 0,
304 "Failed to create instance of"
306 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
310 /* Create an OPENSSL device if required */
311 if (gbl_driver_id == rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
313 nb_devs = rte_cryptodev_device_count_by_driver(
314 rte_cryptodev_driver_id_get(
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
318 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
321 TEST_ASSERT(ret == 0, "Failed to create "
322 "instance of pmd : %s",
323 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
327 /* Create a ARMv8 device if required */
328 if (gbl_driver_id == rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
330 nb_devs = rte_cryptodev_device_count_by_driver(
331 rte_cryptodev_driver_id_get(
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
335 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
338 TEST_ASSERT(ret == 0, "Failed to create "
339 "instance of pmd : %s",
340 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
344 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
345 if (gbl_driver_id == rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
348 nb_devs = rte_cryptodev_device_count_by_driver(
349 rte_cryptodev_driver_id_get(
350 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
353 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
356 TEST_ASSERT(ret == 0,
357 "Failed to create instance %u of"
359 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
362 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
364 nb_devs = rte_cryptodev_count();
366 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
370 /* Create list of valid crypto devs */
371 for (i = 0; i < nb_devs; i++) {
372 rte_cryptodev_info_get(i, &info);
373 if (info.driver_id == gbl_driver_id)
374 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
377 if (ts_params->valid_dev_count < 1)
380 /* Set up all the qps on the first of the valid devices found */
382 dev_id = ts_params->valid_devs[0];
384 rte_cryptodev_info_get(dev_id, &info);
386 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
387 ts_params->conf.socket_id = SOCKET_ID_ANY;
389 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
392 * Create mempool with maximum number of sessions * 2,
393 * to include the session headers
395 ts_params->session_mpool = rte_mempool_create(
397 info.sym.max_nb_sessions * 2,
399 0, 0, NULL, NULL, NULL,
403 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
404 "session mempool allocation failed");
406 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
408 "Failed to configure cryptodev %u with %u qps",
409 dev_id, ts_params->conf.nb_queue_pairs);
411 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
413 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
414 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
415 dev_id, qp_id, &ts_params->qp_conf,
416 rte_cryptodev_socket_id(dev_id),
417 ts_params->session_mpool),
418 "Failed to setup queue pair %u on cryptodev %u",
426 testsuite_teardown(void)
428 struct crypto_testsuite_params *ts_params = &testsuite_params;
430 if (ts_params->mbuf_pool != NULL) {
431 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
432 rte_mempool_avail_count(ts_params->mbuf_pool));
435 if (ts_params->op_mpool != NULL) {
436 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
437 rte_mempool_avail_count(ts_params->op_mpool));
440 /* Free session mempools */
441 if (ts_params->session_mpool != NULL) {
442 rte_mempool_free(ts_params->session_mpool);
443 ts_params->session_mpool = NULL;
450 struct crypto_testsuite_params *ts_params = &testsuite_params;
451 struct crypto_unittest_params *ut_params = &unittest_params;
455 /* Clear unit test parameters before running test */
456 memset(ut_params, 0, sizeof(*ut_params));
458 /* Reconfigure device to default parameters */
459 ts_params->conf.socket_id = SOCKET_ID_ANY;
461 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
463 "Failed to configure cryptodev %u",
464 ts_params->valid_devs[0]);
466 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
467 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
468 ts_params->valid_devs[0], qp_id,
470 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
471 ts_params->session_mpool),
472 "Failed to setup queue pair %u on cryptodev %u",
473 qp_id, ts_params->valid_devs[0]);
477 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
479 /* Start the device */
480 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
481 "Failed to start cryptodev %u",
482 ts_params->valid_devs[0]);
490 struct crypto_testsuite_params *ts_params = &testsuite_params;
491 struct crypto_unittest_params *ut_params = &unittest_params;
492 struct rte_cryptodev_stats stats;
494 /* free crypto session structure */
495 if (ut_params->sess) {
496 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
498 rte_cryptodev_sym_session_free(ut_params->sess);
499 ut_params->sess = NULL;
502 /* free crypto operation structure */
504 rte_crypto_op_free(ut_params->op);
507 * free mbuf - both obuf and ibuf are usually the same,
508 * so check if they point at the same address is necessary,
509 * to avoid freeing the mbuf twice.
511 if (ut_params->obuf) {
512 rte_pktmbuf_free(ut_params->obuf);
513 if (ut_params->ibuf == ut_params->obuf)
517 if (ut_params->ibuf) {
518 rte_pktmbuf_free(ut_params->ibuf);
522 if (ts_params->mbuf_pool != NULL)
523 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
524 rte_mempool_avail_count(ts_params->mbuf_pool));
526 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
528 /* Stop the device */
529 rte_cryptodev_stop(ts_params->valid_devs[0]);
533 test_device_configure_invalid_dev_id(void)
535 struct crypto_testsuite_params *ts_params = &testsuite_params;
536 uint16_t dev_id, num_devs = 0;
538 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
539 "Need at least %d devices for test", 1);
541 /* valid dev_id values */
542 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
544 /* Stop the device in case it's started so it can be configured */
545 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
547 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
548 "Failed test for rte_cryptodev_configure: "
549 "invalid dev_num %u", dev_id);
551 /* invalid dev_id values */
554 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
560 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
561 "Failed test for rte_cryptodev_configure:"
562 "invalid dev_num %u", dev_id);
568 test_device_configure_invalid_queue_pair_ids(void)
570 struct crypto_testsuite_params *ts_params = &testsuite_params;
571 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
573 /* Stop the device in case it's started so it can be configured */
574 rte_cryptodev_stop(ts_params->valid_devs[0]);
576 /* valid - one queue pairs */
577 ts_params->conf.nb_queue_pairs = 1;
579 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
581 "Failed to configure cryptodev: dev_id %u, qp_id %u",
582 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
585 /* valid - max value queue pairs */
586 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
588 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
590 "Failed to configure cryptodev: dev_id %u, qp_id %u",
591 ts_params->valid_devs[0],
592 ts_params->conf.nb_queue_pairs);
595 /* invalid - zero queue pairs */
596 ts_params->conf.nb_queue_pairs = 0;
598 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
600 "Failed test for rte_cryptodev_configure, dev_id %u,"
602 ts_params->valid_devs[0],
603 ts_params->conf.nb_queue_pairs);
606 /* invalid - max value supported by field queue pairs */
607 ts_params->conf.nb_queue_pairs = UINT16_MAX;
609 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
611 "Failed test for rte_cryptodev_configure, dev_id %u,"
613 ts_params->valid_devs[0],
614 ts_params->conf.nb_queue_pairs);
617 /* invalid - max value + 1 queue pairs */
618 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
620 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
622 "Failed test for rte_cryptodev_configure, dev_id %u,"
624 ts_params->valid_devs[0],
625 ts_params->conf.nb_queue_pairs);
627 /* revert to original testsuite value */
628 ts_params->conf.nb_queue_pairs = orig_nb_qps;
634 test_queue_pair_descriptor_setup(void)
636 struct crypto_testsuite_params *ts_params = &testsuite_params;
637 struct rte_cryptodev_info dev_info;
638 struct rte_cryptodev_qp_conf qp_conf = {
639 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
644 /* Stop the device in case it's started so it can be configured */
645 rte_cryptodev_stop(ts_params->valid_devs[0]);
648 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
650 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
652 "Failed to configure cryptodev %u",
653 ts_params->valid_devs[0]);
656 * Test various ring sizes on this device. memzones can't be
657 * freed so are re-used if ring is released and re-created.
659 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
661 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
662 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
663 ts_params->valid_devs[0], qp_id, &qp_conf,
664 rte_cryptodev_socket_id(
665 ts_params->valid_devs[0]),
666 ts_params->session_mpool),
668 "rte_cryptodev_queue_pair_setup: num_inflights "
669 "%u on qp %u on cryptodev %u",
670 qp_conf.nb_descriptors, qp_id,
671 ts_params->valid_devs[0]);
674 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
676 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
677 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
678 ts_params->valid_devs[0], qp_id, &qp_conf,
679 rte_cryptodev_socket_id(
680 ts_params->valid_devs[0]),
681 ts_params->session_mpool),
683 " rte_cryptodev_queue_pair_setup: num_inflights"
684 " %u on qp %u on cryptodev %u",
685 qp_conf.nb_descriptors, qp_id,
686 ts_params->valid_devs[0]);
689 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
691 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
692 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
693 ts_params->valid_devs[0], qp_id, &qp_conf,
694 rte_cryptodev_socket_id(
695 ts_params->valid_devs[0]),
696 ts_params->session_mpool),
698 "rte_cryptodev_queue_pair_setup: num_inflights"
699 " %u on qp %u on cryptodev %u",
700 qp_conf.nb_descriptors, qp_id,
701 ts_params->valid_devs[0]);
704 /* invalid number of descriptors - max supported + 2 */
705 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
707 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
708 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
709 ts_params->valid_devs[0], qp_id, &qp_conf,
710 rte_cryptodev_socket_id(
711 ts_params->valid_devs[0]),
712 ts_params->session_mpool),
713 "Unexpectedly passed test for "
714 "rte_cryptodev_queue_pair_setup:"
715 "num_inflights %u on qp %u on cryptodev %u",
716 qp_conf.nb_descriptors, qp_id,
717 ts_params->valid_devs[0]);
720 /* invalid number of descriptors - max value of parameter */
721 qp_conf.nb_descriptors = UINT32_MAX-1;
723 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
724 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
725 ts_params->valid_devs[0], qp_id, &qp_conf,
726 rte_cryptodev_socket_id(
727 ts_params->valid_devs[0]),
728 ts_params->session_mpool),
729 "Unexpectedly passed test for "
730 "rte_cryptodev_queue_pair_setup:"
731 "num_inflights %u on qp %u on cryptodev %u",
732 qp_conf.nb_descriptors, qp_id,
733 ts_params->valid_devs[0]);
736 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
738 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
739 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
740 ts_params->valid_devs[0], qp_id, &qp_conf,
741 rte_cryptodev_socket_id(
742 ts_params->valid_devs[0]),
743 ts_params->session_mpool),
745 " rte_cryptodev_queue_pair_setup:"
746 "num_inflights %u on qp %u on cryptodev %u",
747 qp_conf.nb_descriptors, qp_id,
748 ts_params->valid_devs[0]);
751 /* invalid number of descriptors - max supported + 1 */
752 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
754 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
755 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
756 ts_params->valid_devs[0], qp_id, &qp_conf,
757 rte_cryptodev_socket_id(
758 ts_params->valid_devs[0]),
759 ts_params->session_mpool),
760 "Unexpectedly passed test for "
761 "rte_cryptodev_queue_pair_setup:"
762 "num_inflights %u on qp %u on cryptodev %u",
763 qp_conf.nb_descriptors, qp_id,
764 ts_params->valid_devs[0]);
767 /* test invalid queue pair id */
768 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
770 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
772 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
773 ts_params->valid_devs[0],
775 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
776 ts_params->session_mpool),
777 "Failed test for rte_cryptodev_queue_pair_setup:"
778 "invalid qp %u on cryptodev %u",
779 qp_id, ts_params->valid_devs[0]);
781 qp_id = 0xffff; /*invalid*/
783 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
784 ts_params->valid_devs[0],
786 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
787 ts_params->session_mpool),
788 "Failed test for rte_cryptodev_queue_pair_setup:"
789 "invalid qp %u on cryptodev %u",
790 qp_id, ts_params->valid_devs[0]);
795 /* ***** Plaintext data for tests ***** */
797 const char catch_22_quote_1[] =
798 "There was only one catch and that was Catch-22, which "
799 "specified that a concern for one's safety in the face of "
800 "dangers that were real and immediate was the process of a "
801 "rational mind. Orr was crazy and could be grounded. All he "
802 "had to do was ask; and as soon as he did, he would no longer "
803 "be crazy and would have to fly more missions. Orr would be "
804 "crazy to fly more missions and sane if he didn't, but if he "
805 "was sane he had to fly them. If he flew them he was crazy "
806 "and didn't have to; but if he didn't want to he was sane and "
807 "had to. Yossarian was moved very deeply by the absolute "
808 "simplicity of this clause of Catch-22 and let out a "
809 "respectful whistle. \"That's some catch, that Catch-22\", he "
810 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
812 const char catch_22_quote[] =
813 "What a lousy earth! He wondered how many people were "
814 "destitute that same night even in his own prosperous country, "
815 "how many homes were shanties, how many husbands were drunk "
816 "and wives socked, and how many children were bullied, abused, "
817 "or abandoned. How many families hungered for food they could "
818 "not afford to buy? How many hearts were broken? How many "
819 "suicides would take place that same night, how many people "
820 "would go insane? How many cockroaches and landlords would "
821 "triumph? How many winners were losers, successes failures, "
822 "and rich men poor men? How many wise guys were stupid? How "
823 "many happy endings were unhappy endings? How many honest men "
824 "were liars, brave men cowards, loyal men traitors, how many "
825 "sainted men were corrupt, how many people in positions of "
826 "trust had sold their souls to bodyguards, how many had never "
827 "had souls? How many straight-and-narrow paths were crooked "
828 "paths? How many best families were worst families and how "
829 "many good people were bad people? When you added them all up "
830 "and then subtracted, you might be left with only the children, "
831 "and perhaps with Albert Einstein and an old violinist or "
832 "sculptor somewhere.";
834 #define QUOTE_480_BYTES (480)
835 #define QUOTE_512_BYTES (512)
836 #define QUOTE_768_BYTES (768)
837 #define QUOTE_1024_BYTES (1024)
841 /* ***** SHA1 Hash Tests ***** */
843 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
845 static uint8_t hmac_sha1_key[] = {
846 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
847 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
848 0xDE, 0xF4, 0xDE, 0xAD };
850 /* ***** SHA224 Hash Tests ***** */
852 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
855 /* ***** AES-CBC Cipher Tests ***** */
857 #define CIPHER_KEY_LENGTH_AES_CBC (16)
858 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
860 static uint8_t aes_cbc_key[] = {
861 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
862 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
864 static uint8_t aes_cbc_iv[] = {
865 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
866 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
869 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
871 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
872 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
873 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
874 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
875 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
876 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
877 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
878 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
879 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
880 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
881 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
882 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
883 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
884 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
885 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
886 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
887 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
888 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
889 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
890 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
891 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
892 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
893 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
894 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
895 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
896 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
897 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
898 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
899 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
900 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
901 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
902 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
903 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
904 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
905 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
906 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
907 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
908 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
909 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
910 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
911 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
912 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
913 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
914 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
915 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
916 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
917 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
918 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
919 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
920 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
921 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
922 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
923 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
924 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
925 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
926 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
927 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
928 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
929 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
930 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
931 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
932 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
933 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
934 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
935 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
938 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
939 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
940 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
941 0x18, 0x8c, 0x1d, 0x32
945 /* Multisession Vector context Test */
947 static uint8_t ms_aes_cbc_key0[] = {
948 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
952 static uint8_t ms_aes_cbc_iv0[] = {
953 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
954 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
957 static const uint8_t ms_aes_cbc_cipher0[] = {
958 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
959 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
960 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
961 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
962 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
963 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
964 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
965 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
966 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
967 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
968 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
969 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
970 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
971 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
972 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
973 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
974 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
975 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
976 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
977 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
978 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
979 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
980 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
981 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
982 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
983 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
984 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
985 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
986 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
987 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
988 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
989 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
990 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
991 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
992 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
993 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
994 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
995 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
996 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
997 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
998 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
999 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1000 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1001 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1002 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1003 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1004 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1005 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1006 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1007 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1008 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1009 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1010 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1011 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1012 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1013 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1014 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1015 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1016 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1017 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1018 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1019 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1020 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1021 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1025 static uint8_t ms_hmac_key0[] = {
1026 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1027 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1028 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1029 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1030 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1031 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1032 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1033 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1036 static const uint8_t ms_hmac_digest0[] = {
1037 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1038 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1039 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1040 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1041 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1042 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1043 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1044 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1048 /* Begin session 1 */
1050 static uint8_t ms_aes_cbc_key1[] = {
1051 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1052 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1055 static uint8_t ms_aes_cbc_iv1[] = {
1056 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1057 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1060 static const uint8_t ms_aes_cbc_cipher1[] = {
1061 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1062 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1063 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1064 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1065 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1066 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1067 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1068 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1069 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1070 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1071 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1072 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1073 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1074 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1075 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1076 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1077 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1078 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1079 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1080 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1081 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1082 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1083 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1084 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1085 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1086 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1087 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1088 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1089 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1090 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1091 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1092 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1093 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1094 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1095 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1096 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1097 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1098 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1099 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1100 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1101 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1102 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1103 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1104 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1105 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1106 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1107 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1108 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1109 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1110 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1111 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1112 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1113 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1114 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1115 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1116 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1117 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1118 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1119 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1120 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1121 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1122 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1123 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1124 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1128 static uint8_t ms_hmac_key1[] = {
1129 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1130 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1131 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1132 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1133 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1134 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1135 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1136 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1139 static const uint8_t ms_hmac_digest1[] = {
1140 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1141 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1142 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1143 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1144 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1145 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1146 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1147 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1150 /* Begin Session 2 */
1151 static uint8_t ms_aes_cbc_key2[] = {
1152 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1153 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1156 static uint8_t ms_aes_cbc_iv2[] = {
1157 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1158 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1161 static const uint8_t ms_aes_cbc_cipher2[] = {
1162 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1163 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1164 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1165 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1166 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1167 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1168 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1169 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1170 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1171 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1172 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1173 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1174 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1175 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1176 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1177 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1178 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1179 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1180 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1181 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1182 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1183 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1184 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1185 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1186 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1187 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1188 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1189 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1190 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1191 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1192 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1193 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1194 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1195 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1196 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1197 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1198 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1199 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1200 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1201 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1202 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1203 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1204 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1205 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1206 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1207 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1208 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1209 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1210 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1211 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1212 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1213 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1214 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1215 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1216 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1217 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1218 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1219 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1220 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1221 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1222 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1223 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1224 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1225 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1228 static uint8_t ms_hmac_key2[] = {
1229 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1230 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1231 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1232 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1233 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1234 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1235 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1236 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1239 static const uint8_t ms_hmac_digest2[] = {
1240 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1241 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1242 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1243 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1244 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1245 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1246 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1247 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1254 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1256 struct crypto_testsuite_params *ts_params = &testsuite_params;
1257 struct crypto_unittest_params *ut_params = &unittest_params;
1259 /* Generate test mbuf data and space for digest */
1260 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1261 catch_22_quote, QUOTE_512_BYTES, 0);
1263 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1264 DIGEST_BYTE_LENGTH_SHA1);
1265 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1267 /* Setup Cipher Parameters */
1268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1269 ut_params->cipher_xform.next = &ut_params->auth_xform;
1271 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1272 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1273 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1274 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1275 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1276 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1278 /* Setup HMAC Parameters */
1279 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1281 ut_params->auth_xform.next = NULL;
1283 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1284 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1285 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1286 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1287 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1289 ut_params->sess = rte_cryptodev_sym_session_create(
1290 ts_params->session_mpool);
1292 /* Create crypto session*/
1293 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1294 ut_params->sess, &ut_params->cipher_xform,
1295 ts_params->session_mpool);
1296 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1298 /* Generate crypto op data structure */
1299 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1300 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1301 TEST_ASSERT_NOT_NULL(ut_params->op,
1302 "Failed to allocate symmetric crypto operation struct");
1304 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1306 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1308 /* set crypto operation source mbuf */
1309 sym_op->m_src = ut_params->ibuf;
1311 /* Set crypto operation authentication parameters */
1312 sym_op->auth.digest.data = ut_params->digest;
1313 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1314 ut_params->ibuf, QUOTE_512_BYTES);
1316 sym_op->auth.data.offset = 0;
1317 sym_op->auth.data.length = QUOTE_512_BYTES;
1319 /* Copy IV at the end of the crypto operation */
1320 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1321 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1323 /* Set crypto operation cipher parameters */
1324 sym_op->cipher.data.offset = 0;
1325 sym_op->cipher.data.length = QUOTE_512_BYTES;
1327 /* Process crypto operation */
1328 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1329 ut_params->op), "failed to process sym crypto op");
1331 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1332 "crypto op processing failed");
1335 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1338 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1339 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1341 "ciphertext data not as expected");
1343 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1345 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1346 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1347 gbl_driver_id == rte_cryptodev_driver_id_get(
1348 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1349 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1350 DIGEST_BYTE_LENGTH_SHA1,
1351 "Generated digest data not as expected");
1353 return TEST_SUCCESS;
1356 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1358 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1360 static uint8_t hmac_sha512_key[] = {
1361 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1362 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1363 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1364 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1365 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1366 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1367 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1368 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1370 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1371 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1372 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1373 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1374 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1375 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1376 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1377 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1378 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1383 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1384 struct crypto_unittest_params *ut_params,
1385 uint8_t *cipher_key,
1389 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1390 struct crypto_unittest_params *ut_params,
1391 struct crypto_testsuite_params *ts_params,
1392 const uint8_t *cipher,
1393 const uint8_t *digest,
1398 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1399 struct crypto_unittest_params *ut_params,
1400 uint8_t *cipher_key,
1404 /* Setup Cipher Parameters */
1405 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1406 ut_params->cipher_xform.next = NULL;
1408 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1409 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1410 ut_params->cipher_xform.cipher.key.data = cipher_key;
1411 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1412 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1413 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1415 /* Setup HMAC Parameters */
1416 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1417 ut_params->auth_xform.next = &ut_params->cipher_xform;
1419 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1420 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1421 ut_params->auth_xform.auth.key.data = hmac_key;
1422 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1423 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1425 return TEST_SUCCESS;
1430 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1431 struct crypto_unittest_params *ut_params,
1432 struct crypto_testsuite_params *ts_params,
1433 const uint8_t *cipher,
1434 const uint8_t *digest,
1437 /* Generate test mbuf data and digest */
1438 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1441 QUOTE_512_BYTES, 0);
1443 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1444 DIGEST_BYTE_LENGTH_SHA512);
1445 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1447 rte_memcpy(ut_params->digest,
1449 DIGEST_BYTE_LENGTH_SHA512);
1451 /* Generate Crypto op data structure */
1452 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1453 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1454 TEST_ASSERT_NOT_NULL(ut_params->op,
1455 "Failed to allocate symmetric crypto operation struct");
1457 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1459 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1461 /* set crypto operation source mbuf */
1462 sym_op->m_src = ut_params->ibuf;
1464 sym_op->auth.digest.data = ut_params->digest;
1465 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1466 ut_params->ibuf, QUOTE_512_BYTES);
1468 sym_op->auth.data.offset = 0;
1469 sym_op->auth.data.length = QUOTE_512_BYTES;
1471 /* Copy IV at the end of the crypto operation */
1472 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1473 iv, CIPHER_IV_LENGTH_AES_CBC);
1475 sym_op->cipher.data.offset = 0;
1476 sym_op->cipher.data.length = QUOTE_512_BYTES;
1478 /* Process crypto operation */
1479 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1480 ut_params->op), "failed to process sym crypto op");
1482 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1483 "crypto op processing failed");
1485 ut_params->obuf = ut_params->op->sym->m_src;
1488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1489 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1492 "Plaintext data not as expected");
1495 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1496 "Digest verification failed");
1498 return TEST_SUCCESS;
1502 test_AES_cipheronly_mb_all(void)
1504 struct crypto_testsuite_params *ts_params = &testsuite_params;
1507 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1508 ts_params->op_mpool,
1509 ts_params->session_mpool,
1510 ts_params->valid_devs[0],
1511 rte_cryptodev_driver_id_get(
1512 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1513 BLKCIPHER_AES_CIPHERONLY_TYPE);
1515 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1517 return TEST_SUCCESS;
1521 test_AES_docsis_mb_all(void)
1523 struct crypto_testsuite_params *ts_params = &testsuite_params;
1526 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1527 ts_params->op_mpool,
1528 ts_params->session_mpool,
1529 ts_params->valid_devs[0],
1530 rte_cryptodev_driver_id_get(
1531 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1532 BLKCIPHER_AES_DOCSIS_TYPE);
1534 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1536 return TEST_SUCCESS;
1540 test_AES_docsis_qat_all(void)
1542 struct crypto_testsuite_params *ts_params = &testsuite_params;
1545 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1546 ts_params->op_mpool,
1547 ts_params->session_mpool,
1548 ts_params->valid_devs[0],
1549 rte_cryptodev_driver_id_get(
1550 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1551 BLKCIPHER_AES_DOCSIS_TYPE);
1553 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1555 return TEST_SUCCESS;
1559 test_DES_docsis_qat_all(void)
1561 struct crypto_testsuite_params *ts_params = &testsuite_params;
1564 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1565 ts_params->op_mpool,
1566 ts_params->session_mpool,
1567 ts_params->valid_devs[0],
1568 rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1570 BLKCIPHER_DES_DOCSIS_TYPE);
1572 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1574 return TEST_SUCCESS;
1578 test_authonly_mb_all(void)
1580 struct crypto_testsuite_params *ts_params = &testsuite_params;
1583 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1584 ts_params->op_mpool,
1585 ts_params->session_mpool,
1586 ts_params->valid_devs[0],
1587 rte_cryptodev_driver_id_get(
1588 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1589 BLKCIPHER_AUTHONLY_TYPE);
1591 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1593 return TEST_SUCCESS;
1597 test_authonly_qat_all(void)
1599 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1603 ts_params->op_mpool,
1604 ts_params->session_mpool,
1605 ts_params->valid_devs[0],
1606 rte_cryptodev_driver_id_get(
1607 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1608 BLKCIPHER_AUTHONLY_TYPE);
1610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1612 return TEST_SUCCESS;
1615 test_AES_chain_mb_all(void)
1617 struct crypto_testsuite_params *ts_params = &testsuite_params;
1620 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1621 ts_params->op_mpool,
1622 ts_params->session_mpool,
1623 ts_params->valid_devs[0],
1624 rte_cryptodev_driver_id_get(
1625 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1626 BLKCIPHER_AES_CHAIN_TYPE);
1628 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1630 return TEST_SUCCESS;
1633 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1636 test_AES_cipheronly_scheduler_all(void)
1638 struct crypto_testsuite_params *ts_params = &testsuite_params;
1641 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1642 ts_params->op_mpool,
1643 ts_params->session_mpool,
1644 ts_params->valid_devs[0],
1645 rte_cryptodev_driver_id_get(
1646 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1647 BLKCIPHER_AES_CIPHERONLY_TYPE);
1649 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1651 return TEST_SUCCESS;
1655 test_AES_chain_scheduler_all(void)
1657 struct crypto_testsuite_params *ts_params = &testsuite_params;
1660 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1661 ts_params->op_mpool,
1662 ts_params->session_mpool,
1663 ts_params->valid_devs[0],
1664 rte_cryptodev_driver_id_get(
1665 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1666 BLKCIPHER_AES_CHAIN_TYPE);
1668 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1670 return TEST_SUCCESS;
1674 test_authonly_scheduler_all(void)
1676 struct crypto_testsuite_params *ts_params = &testsuite_params;
1679 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1680 ts_params->op_mpool,
1681 ts_params->session_mpool,
1682 ts_params->valid_devs[0],
1683 rte_cryptodev_driver_id_get(
1684 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1685 BLKCIPHER_AUTHONLY_TYPE);
1687 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1689 return TEST_SUCCESS;
1692 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1695 test_AES_chain_openssl_all(void)
1697 struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1701 ts_params->op_mpool,
1702 ts_params->session_mpool,
1703 ts_params->valid_devs[0],
1704 rte_cryptodev_driver_id_get(
1705 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1706 BLKCIPHER_AES_CHAIN_TYPE);
1708 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1710 return TEST_SUCCESS;
1714 test_AES_cipheronly_openssl_all(void)
1716 struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1720 ts_params->op_mpool,
1721 ts_params->session_mpool,
1722 ts_params->valid_devs[0],
1723 rte_cryptodev_driver_id_get(
1724 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1725 BLKCIPHER_AES_CIPHERONLY_TYPE);
1727 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1729 return TEST_SUCCESS;
1733 test_AES_chain_qat_all(void)
1735 struct crypto_testsuite_params *ts_params = &testsuite_params;
1738 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1739 ts_params->op_mpool,
1740 ts_params->session_mpool,
1741 ts_params->valid_devs[0],
1742 rte_cryptodev_driver_id_get(
1743 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1744 BLKCIPHER_AES_CHAIN_TYPE);
1746 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1748 return TEST_SUCCESS;
1752 test_AES_cipheronly_qat_all(void)
1754 struct crypto_testsuite_params *ts_params = &testsuite_params;
1757 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1758 ts_params->op_mpool,
1759 ts_params->session_mpool,
1760 ts_params->valid_devs[0],
1761 rte_cryptodev_driver_id_get(
1762 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1763 BLKCIPHER_AES_CIPHERONLY_TYPE);
1765 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1767 return TEST_SUCCESS;
1771 test_AES_chain_dpaa_sec_all(void)
1773 struct crypto_testsuite_params *ts_params = &testsuite_params;
1776 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1777 ts_params->op_mpool,
1778 ts_params->session_mpool,
1779 ts_params->valid_devs[0],
1780 rte_cryptodev_driver_id_get(
1781 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1782 BLKCIPHER_AES_CHAIN_TYPE);
1784 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1786 return TEST_SUCCESS;
1790 test_AES_cipheronly_dpaa_sec_all(void)
1792 struct crypto_testsuite_params *ts_params = &testsuite_params;
1795 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1796 ts_params->op_mpool,
1797 ts_params->session_mpool,
1798 ts_params->valid_devs[0],
1799 rte_cryptodev_driver_id_get(
1800 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1801 BLKCIPHER_AES_CIPHERONLY_TYPE);
1803 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1805 return TEST_SUCCESS;
1809 test_authonly_dpaa_sec_all(void)
1811 struct crypto_testsuite_params *ts_params = &testsuite_params;
1814 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1815 ts_params->op_mpool,
1816 ts_params->session_mpool,
1817 ts_params->valid_devs[0],
1818 rte_cryptodev_driver_id_get(
1819 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1820 BLKCIPHER_AUTHONLY_TYPE);
1822 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1824 return TEST_SUCCESS;
1828 test_AES_chain_dpaa2_sec_all(void)
1830 struct crypto_testsuite_params *ts_params = &testsuite_params;
1833 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1834 ts_params->op_mpool,
1835 ts_params->session_mpool,
1836 ts_params->valid_devs[0],
1837 rte_cryptodev_driver_id_get(
1838 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1839 BLKCIPHER_AES_CHAIN_TYPE);
1841 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1843 return TEST_SUCCESS;
1847 test_AES_cipheronly_dpaa2_sec_all(void)
1849 struct crypto_testsuite_params *ts_params = &testsuite_params;
1852 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1853 ts_params->op_mpool,
1854 ts_params->session_mpool,
1855 ts_params->valid_devs[0],
1856 rte_cryptodev_driver_id_get(
1857 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1858 BLKCIPHER_AES_CIPHERONLY_TYPE);
1860 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1862 return TEST_SUCCESS;
1866 test_authonly_dpaa2_sec_all(void)
1868 struct crypto_testsuite_params *ts_params = &testsuite_params;
1871 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1872 ts_params->op_mpool,
1873 ts_params->session_mpool,
1874 ts_params->valid_devs[0],
1875 rte_cryptodev_driver_id_get(
1876 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1877 BLKCIPHER_AUTHONLY_TYPE);
1879 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1881 return TEST_SUCCESS;
1885 test_authonly_openssl_all(void)
1887 struct crypto_testsuite_params *ts_params = &testsuite_params;
1890 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1891 ts_params->op_mpool,
1892 ts_params->session_mpool,
1893 ts_params->valid_devs[0],
1894 rte_cryptodev_driver_id_get(
1895 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1896 BLKCIPHER_AUTHONLY_TYPE);
1898 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1900 return TEST_SUCCESS;
1904 test_AES_chain_armv8_all(void)
1906 struct crypto_testsuite_params *ts_params = &testsuite_params;
1909 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1910 ts_params->op_mpool,
1911 ts_params->session_mpool,
1912 ts_params->valid_devs[0],
1913 rte_cryptodev_driver_id_get(
1914 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1915 BLKCIPHER_AES_CHAIN_TYPE);
1917 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1919 return TEST_SUCCESS;
1922 /* ***** SNOW 3G Tests ***** */
1924 create_wireless_algo_hash_session(uint8_t dev_id,
1925 const uint8_t *key, const uint8_t key_len,
1926 const uint8_t iv_len, const uint8_t auth_len,
1927 enum rte_crypto_auth_operation op,
1928 enum rte_crypto_auth_algorithm algo)
1930 uint8_t hash_key[key_len];
1932 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 struct crypto_unittest_params *ut_params = &unittest_params;
1935 memcpy(hash_key, key, key_len);
1937 TEST_HEXDUMP(stdout, "key:", key, key_len);
1939 /* Setup Authentication Parameters */
1940 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1941 ut_params->auth_xform.next = NULL;
1943 ut_params->auth_xform.auth.op = op;
1944 ut_params->auth_xform.auth.algo = algo;
1945 ut_params->auth_xform.auth.key.length = key_len;
1946 ut_params->auth_xform.auth.key.data = hash_key;
1947 ut_params->auth_xform.auth.digest_length = auth_len;
1948 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1949 ut_params->auth_xform.auth.iv.length = iv_len;
1950 ut_params->sess = rte_cryptodev_sym_session_create(
1951 ts_params->session_mpool);
1953 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1954 &ut_params->auth_xform, ts_params->session_mpool);
1955 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1960 create_wireless_algo_cipher_session(uint8_t dev_id,
1961 enum rte_crypto_cipher_operation op,
1962 enum rte_crypto_cipher_algorithm algo,
1963 const uint8_t *key, const uint8_t key_len,
1966 uint8_t cipher_key[key_len];
1968 struct crypto_testsuite_params *ts_params = &testsuite_params;
1969 struct crypto_unittest_params *ut_params = &unittest_params;
1971 memcpy(cipher_key, key, key_len);
1973 /* Setup Cipher Parameters */
1974 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1975 ut_params->cipher_xform.next = NULL;
1977 ut_params->cipher_xform.cipher.algo = algo;
1978 ut_params->cipher_xform.cipher.op = op;
1979 ut_params->cipher_xform.cipher.key.data = cipher_key;
1980 ut_params->cipher_xform.cipher.key.length = key_len;
1981 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1982 ut_params->cipher_xform.cipher.iv.length = iv_len;
1984 TEST_HEXDUMP(stdout, "key:", key, key_len);
1986 /* Create Crypto session */
1987 ut_params->sess = rte_cryptodev_sym_session_create(
1988 ts_params->session_mpool);
1990 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1991 &ut_params->cipher_xform, ts_params->session_mpool);
1992 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1997 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1998 unsigned int cipher_len,
1999 unsigned int cipher_offset)
2001 struct crypto_testsuite_params *ts_params = &testsuite_params;
2002 struct crypto_unittest_params *ut_params = &unittest_params;
2004 /* Generate Crypto op data structure */
2005 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2006 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2007 TEST_ASSERT_NOT_NULL(ut_params->op,
2008 "Failed to allocate pktmbuf offload");
2010 /* Set crypto operation data parameters */
2011 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2013 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2015 /* set crypto operation source mbuf */
2016 sym_op->m_src = ut_params->ibuf;
2019 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2021 sym_op->cipher.data.length = cipher_len;
2022 sym_op->cipher.data.offset = cipher_offset;
2027 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2028 unsigned int cipher_len,
2029 unsigned int cipher_offset)
2031 struct crypto_testsuite_params *ts_params = &testsuite_params;
2032 struct crypto_unittest_params *ut_params = &unittest_params;
2034 /* Generate Crypto op data structure */
2035 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2036 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2037 TEST_ASSERT_NOT_NULL(ut_params->op,
2038 "Failed to allocate pktmbuf offload");
2040 /* Set crypto operation data parameters */
2041 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2043 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2045 /* set crypto operation source mbuf */
2046 sym_op->m_src = ut_params->ibuf;
2047 sym_op->m_dst = ut_params->obuf;
2050 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2052 sym_op->cipher.data.length = cipher_len;
2053 sym_op->cipher.data.offset = cipher_offset;
2058 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2059 enum rte_crypto_cipher_operation cipher_op,
2060 enum rte_crypto_auth_operation auth_op,
2061 enum rte_crypto_auth_algorithm auth_algo,
2062 enum rte_crypto_cipher_algorithm cipher_algo,
2063 const uint8_t *key, uint8_t key_len,
2064 uint8_t auth_iv_len, uint8_t auth_len,
2065 uint8_t cipher_iv_len)
2068 uint8_t cipher_auth_key[key_len];
2070 struct crypto_testsuite_params *ts_params = &testsuite_params;
2071 struct crypto_unittest_params *ut_params = &unittest_params;
2073 memcpy(cipher_auth_key, key, key_len);
2075 /* Setup Authentication Parameters */
2076 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2077 ut_params->auth_xform.next = NULL;
2079 ut_params->auth_xform.auth.op = auth_op;
2080 ut_params->auth_xform.auth.algo = auth_algo;
2081 ut_params->auth_xform.auth.key.length = key_len;
2082 /* Hash key = cipher key */
2083 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2084 ut_params->auth_xform.auth.digest_length = auth_len;
2085 /* Auth IV will be after cipher IV */
2086 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2087 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2089 /* Setup Cipher Parameters */
2090 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2091 ut_params->cipher_xform.next = &ut_params->auth_xform;
2093 ut_params->cipher_xform.cipher.algo = cipher_algo;
2094 ut_params->cipher_xform.cipher.op = cipher_op;
2095 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2096 ut_params->cipher_xform.cipher.key.length = key_len;
2097 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2098 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2100 TEST_HEXDUMP(stdout, "key:", key, key_len);
2102 /* Create Crypto session*/
2103 ut_params->sess = rte_cryptodev_sym_session_create(
2104 ts_params->session_mpool);
2106 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2107 &ut_params->cipher_xform, ts_params->session_mpool);
2109 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2114 create_wireless_cipher_auth_session(uint8_t dev_id,
2115 enum rte_crypto_cipher_operation cipher_op,
2116 enum rte_crypto_auth_operation auth_op,
2117 enum rte_crypto_auth_algorithm auth_algo,
2118 enum rte_crypto_cipher_algorithm cipher_algo,
2119 const struct wireless_test_data *tdata)
2121 const uint8_t key_len = tdata->key.len;
2122 uint8_t cipher_auth_key[key_len];
2124 struct crypto_testsuite_params *ts_params = &testsuite_params;
2125 struct crypto_unittest_params *ut_params = &unittest_params;
2126 const uint8_t *key = tdata->key.data;
2127 const uint8_t auth_len = tdata->digest.len;
2128 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2129 uint8_t auth_iv_len = tdata->auth_iv.len;
2131 memcpy(cipher_auth_key, key, key_len);
2133 /* Setup Authentication Parameters */
2134 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2135 ut_params->auth_xform.next = NULL;
2137 ut_params->auth_xform.auth.op = auth_op;
2138 ut_params->auth_xform.auth.algo = auth_algo;
2139 ut_params->auth_xform.auth.key.length = key_len;
2140 /* Hash key = cipher key */
2141 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2142 ut_params->auth_xform.auth.digest_length = auth_len;
2143 /* Auth IV will be after cipher IV */
2144 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2145 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2147 /* Setup Cipher Parameters */
2148 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2149 ut_params->cipher_xform.next = &ut_params->auth_xform;
2151 ut_params->cipher_xform.cipher.algo = cipher_algo;
2152 ut_params->cipher_xform.cipher.op = cipher_op;
2153 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2154 ut_params->cipher_xform.cipher.key.length = key_len;
2155 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2156 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2159 TEST_HEXDUMP(stdout, "key:", key, key_len);
2161 /* Create Crypto session*/
2162 ut_params->sess = rte_cryptodev_sym_session_create(
2163 ts_params->session_mpool);
2165 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2166 &ut_params->cipher_xform, ts_params->session_mpool);
2168 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2173 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2174 const struct wireless_test_data *tdata)
2176 return create_wireless_cipher_auth_session(dev_id,
2177 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2178 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2179 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2183 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2184 enum rte_crypto_cipher_operation cipher_op,
2185 enum rte_crypto_auth_operation auth_op,
2186 enum rte_crypto_auth_algorithm auth_algo,
2187 enum rte_crypto_cipher_algorithm cipher_algo,
2188 const uint8_t *key, const uint8_t key_len,
2189 uint8_t auth_iv_len, uint8_t auth_len,
2190 uint8_t cipher_iv_len)
2192 uint8_t auth_cipher_key[key_len];
2194 struct crypto_testsuite_params *ts_params = &testsuite_params;
2195 struct crypto_unittest_params *ut_params = &unittest_params;
2197 memcpy(auth_cipher_key, key, key_len);
2199 /* Setup Authentication Parameters */
2200 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2201 ut_params->auth_xform.auth.op = auth_op;
2202 ut_params->auth_xform.next = &ut_params->cipher_xform;
2203 ut_params->auth_xform.auth.algo = auth_algo;
2204 ut_params->auth_xform.auth.key.length = key_len;
2205 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2206 ut_params->auth_xform.auth.digest_length = auth_len;
2207 /* Auth IV will be after cipher IV */
2208 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2209 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2211 /* Setup Cipher Parameters */
2212 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2213 ut_params->cipher_xform.next = NULL;
2214 ut_params->cipher_xform.cipher.algo = cipher_algo;
2215 ut_params->cipher_xform.cipher.op = cipher_op;
2216 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2217 ut_params->cipher_xform.cipher.key.length = key_len;
2218 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2219 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2221 TEST_HEXDUMP(stdout, "key:", key, key_len);
2223 /* Create Crypto session*/
2224 ut_params->sess = rte_cryptodev_sym_session_create(
2225 ts_params->session_mpool);
2227 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2228 &ut_params->auth_xform, ts_params->session_mpool);
2230 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2236 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2237 unsigned int auth_tag_len,
2238 const uint8_t *iv, unsigned int iv_len,
2239 unsigned int data_pad_len,
2240 enum rte_crypto_auth_operation op,
2241 unsigned int auth_len, unsigned int auth_offset)
2243 struct crypto_testsuite_params *ts_params = &testsuite_params;
2245 struct crypto_unittest_params *ut_params = &unittest_params;
2247 /* Generate Crypto op data structure */
2248 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2249 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2250 TEST_ASSERT_NOT_NULL(ut_params->op,
2251 "Failed to allocate pktmbuf offload");
2253 /* Set crypto operation data parameters */
2254 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2256 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2258 /* set crypto operation source mbuf */
2259 sym_op->m_src = ut_params->ibuf;
2262 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2265 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2266 ut_params->ibuf, auth_tag_len);
2268 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2269 "no room to append auth tag");
2270 ut_params->digest = sym_op->auth.digest.data;
2271 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2272 ut_params->ibuf, data_pad_len);
2273 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2274 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2276 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2278 TEST_HEXDUMP(stdout, "digest:",
2279 sym_op->auth.digest.data,
2282 sym_op->auth.data.length = auth_len;
2283 sym_op->auth.data.offset = auth_offset;
2289 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2290 enum rte_crypto_auth_operation op)
2292 struct crypto_testsuite_params *ts_params = &testsuite_params;
2293 struct crypto_unittest_params *ut_params = &unittest_params;
2295 const uint8_t *auth_tag = tdata->digest.data;
2296 const unsigned int auth_tag_len = tdata->digest.len;
2297 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2298 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2300 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2301 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2302 const uint8_t *auth_iv = tdata->auth_iv.data;
2303 const uint8_t auth_iv_len = tdata->auth_iv.len;
2304 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2305 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2307 /* Generate Crypto op data structure */
2308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2310 TEST_ASSERT_NOT_NULL(ut_params->op,
2311 "Failed to allocate pktmbuf offload");
2312 /* Set crypto operation data parameters */
2313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2315 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2317 /* set crypto operation source mbuf */
2318 sym_op->m_src = ut_params->ibuf;
2321 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2322 ut_params->ibuf, auth_tag_len);
2324 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2325 "no room to append auth tag");
2326 ut_params->digest = sym_op->auth.digest.data;
2327 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2328 ut_params->ibuf, data_pad_len);
2329 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2330 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2332 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2334 TEST_HEXDUMP(stdout, "digest:",
2335 sym_op->auth.digest.data,
2338 /* Copy cipher and auth IVs at the end of the crypto operation */
2339 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2341 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2342 iv_ptr += cipher_iv_len;
2343 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2345 sym_op->cipher.data.length = cipher_len;
2346 sym_op->cipher.data.offset = 0;
2347 sym_op->auth.data.length = auth_len;
2348 sym_op->auth.data.offset = 0;
2354 create_zuc_cipher_hash_generate_operation(
2355 const struct wireless_test_data *tdata)
2357 return create_wireless_cipher_hash_operation(tdata,
2358 RTE_CRYPTO_AUTH_OP_GENERATE);
2362 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2363 const unsigned auth_tag_len,
2364 const uint8_t *auth_iv, uint8_t auth_iv_len,
2365 unsigned data_pad_len,
2366 enum rte_crypto_auth_operation op,
2367 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2368 const unsigned cipher_len, const unsigned cipher_offset,
2369 const unsigned auth_len, const unsigned auth_offset)
2371 struct crypto_testsuite_params *ts_params = &testsuite_params;
2372 struct crypto_unittest_params *ut_params = &unittest_params;
2374 /* Generate Crypto op data structure */
2375 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2376 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2377 TEST_ASSERT_NOT_NULL(ut_params->op,
2378 "Failed to allocate pktmbuf offload");
2379 /* Set crypto operation data parameters */
2380 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2382 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2384 /* set crypto operation source mbuf */
2385 sym_op->m_src = ut_params->ibuf;
2388 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2389 ut_params->ibuf, auth_tag_len);
2391 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2392 "no room to append auth tag");
2393 ut_params->digest = sym_op->auth.digest.data;
2394 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2395 ut_params->ibuf, data_pad_len);
2396 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2397 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2399 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2401 TEST_HEXDUMP(stdout, "digest:",
2402 sym_op->auth.digest.data,
2405 /* Copy cipher and auth IVs at the end of the crypto operation */
2406 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2408 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2409 iv_ptr += cipher_iv_len;
2410 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2412 sym_op->cipher.data.length = cipher_len;
2413 sym_op->cipher.data.offset = cipher_offset;
2414 sym_op->auth.data.length = auth_len;
2415 sym_op->auth.data.offset = auth_offset;
2421 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2422 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2423 const uint8_t *auth_iv, uint8_t auth_iv_len,
2424 unsigned int data_pad_len,
2425 unsigned int cipher_len, unsigned int cipher_offset,
2426 unsigned int auth_len, unsigned int auth_offset)
2428 struct crypto_testsuite_params *ts_params = &testsuite_params;
2429 struct crypto_unittest_params *ut_params = &unittest_params;
2431 /* Generate Crypto op data structure */
2432 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2433 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2434 TEST_ASSERT_NOT_NULL(ut_params->op,
2435 "Failed to allocate pktmbuf offload");
2437 /* Set crypto operation data parameters */
2438 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2440 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2442 /* set crypto operation source mbuf */
2443 sym_op->m_src = ut_params->ibuf;
2446 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2447 ut_params->ibuf, auth_tag_len);
2449 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2450 "no room to append auth tag");
2452 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2453 ut_params->ibuf, data_pad_len);
2455 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2457 TEST_HEXDUMP(stdout, "digest:",
2458 sym_op->auth.digest.data,
2461 /* Copy cipher and auth IVs at the end of the crypto operation */
2462 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2464 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2465 iv_ptr += cipher_iv_len;
2466 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2468 sym_op->cipher.data.length = cipher_len;
2469 sym_op->cipher.data.offset = cipher_offset;
2471 sym_op->auth.data.length = auth_len;
2472 sym_op->auth.data.offset = auth_offset;
2478 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2480 struct crypto_testsuite_params *ts_params = &testsuite_params;
2481 struct crypto_unittest_params *ut_params = &unittest_params;
2484 unsigned plaintext_pad_len;
2485 unsigned plaintext_len;
2488 /* Create SNOW 3G session */
2489 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2490 tdata->key.data, tdata->key.len,
2491 tdata->auth_iv.len, tdata->digest.len,
2492 RTE_CRYPTO_AUTH_OP_GENERATE,
2493 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2497 /* alloc mbuf and set payload */
2498 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2500 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2501 rte_pktmbuf_tailroom(ut_params->ibuf));
2503 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2504 /* Append data which is padded to a multiple of */
2505 /* the algorithms block size */
2506 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2507 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2509 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2511 /* Create SNOW 3G operation */
2512 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2513 tdata->auth_iv.data, tdata->auth_iv.len,
2514 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2515 tdata->validAuthLenInBits.len,
2520 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2522 ut_params->obuf = ut_params->op->sym->m_src;
2523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2524 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2525 + plaintext_pad_len;
2528 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2531 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2532 "SNOW 3G Generated auth tag not as expected");
2538 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2540 struct crypto_testsuite_params *ts_params = &testsuite_params;
2541 struct crypto_unittest_params *ut_params = &unittest_params;
2544 unsigned plaintext_pad_len;
2545 unsigned plaintext_len;
2548 /* Create SNOW 3G session */
2549 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2550 tdata->key.data, tdata->key.len,
2551 tdata->auth_iv.len, tdata->digest.len,
2552 RTE_CRYPTO_AUTH_OP_VERIFY,
2553 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2556 /* alloc mbuf and set payload */
2557 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2559 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2560 rte_pktmbuf_tailroom(ut_params->ibuf));
2562 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2563 /* Append data which is padded to a multiple of */
2564 /* the algorithms block size */
2565 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2566 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2568 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2570 /* Create SNOW 3G operation */
2571 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2573 tdata->auth_iv.data, tdata->auth_iv.len,
2575 RTE_CRYPTO_AUTH_OP_VERIFY,
2576 tdata->validAuthLenInBits.len,
2581 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2583 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2584 ut_params->obuf = ut_params->op->sym->m_src;
2585 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2586 + plaintext_pad_len;
2589 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2598 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2600 struct crypto_testsuite_params *ts_params = &testsuite_params;
2601 struct crypto_unittest_params *ut_params = &unittest_params;
2604 unsigned plaintext_pad_len;
2605 unsigned plaintext_len;
2608 /* Create KASUMI session */
2609 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2610 tdata->key.data, tdata->key.len,
2611 0, tdata->digest.len,
2612 RTE_CRYPTO_AUTH_OP_GENERATE,
2613 RTE_CRYPTO_AUTH_KASUMI_F9);
2617 /* alloc mbuf and set payload */
2618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2621 rte_pktmbuf_tailroom(ut_params->ibuf));
2623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2624 /* Append data which is padded to a multiple of */
2625 /* the algorithms block size */
2626 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2629 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2631 /* Create KASUMI operation */
2632 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2634 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2635 tdata->plaintext.len,
2640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2642 ut_params->obuf = ut_params->op->sym->m_src;
2643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2644 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2645 + plaintext_pad_len;
2648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2651 DIGEST_BYTE_LENGTH_KASUMI_F9,
2652 "KASUMI Generated auth tag not as expected");
2658 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2660 struct crypto_testsuite_params *ts_params = &testsuite_params;
2661 struct crypto_unittest_params *ut_params = &unittest_params;
2664 unsigned plaintext_pad_len;
2665 unsigned plaintext_len;
2668 /* Create KASUMI session */
2669 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2670 tdata->key.data, tdata->key.len,
2671 0, tdata->digest.len,
2672 RTE_CRYPTO_AUTH_OP_VERIFY,
2673 RTE_CRYPTO_AUTH_KASUMI_F9);
2676 /* alloc mbuf and set payload */
2677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2679 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2680 rte_pktmbuf_tailroom(ut_params->ibuf));
2682 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2683 /* Append data which is padded to a multiple */
2684 /* of the algorithms block size */
2685 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2686 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2688 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2690 /* Create KASUMI operation */
2691 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2695 RTE_CRYPTO_AUTH_OP_VERIFY,
2696 tdata->plaintext.len,
2701 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2703 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2704 ut_params->obuf = ut_params->op->sym->m_src;
2705 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2706 + plaintext_pad_len;
2709 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2718 test_snow3g_hash_generate_test_case_1(void)
2720 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2724 test_snow3g_hash_generate_test_case_2(void)
2726 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2730 test_snow3g_hash_generate_test_case_3(void)
2732 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2736 test_snow3g_hash_generate_test_case_4(void)
2738 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2742 test_snow3g_hash_generate_test_case_5(void)
2744 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2748 test_snow3g_hash_generate_test_case_6(void)
2750 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2754 test_snow3g_hash_verify_test_case_1(void)
2756 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2761 test_snow3g_hash_verify_test_case_2(void)
2763 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2767 test_snow3g_hash_verify_test_case_3(void)
2769 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2773 test_snow3g_hash_verify_test_case_4(void)
2775 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2779 test_snow3g_hash_verify_test_case_5(void)
2781 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2785 test_snow3g_hash_verify_test_case_6(void)
2787 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2791 test_kasumi_hash_generate_test_case_1(void)
2793 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2797 test_kasumi_hash_generate_test_case_2(void)
2799 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2803 test_kasumi_hash_generate_test_case_3(void)
2805 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2809 test_kasumi_hash_generate_test_case_4(void)
2811 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2815 test_kasumi_hash_generate_test_case_5(void)
2817 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2821 test_kasumi_hash_generate_test_case_6(void)
2823 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2827 test_kasumi_hash_verify_test_case_1(void)
2829 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2833 test_kasumi_hash_verify_test_case_2(void)
2835 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2839 test_kasumi_hash_verify_test_case_3(void)
2841 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2845 test_kasumi_hash_verify_test_case_4(void)
2847 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2851 test_kasumi_hash_verify_test_case_5(void)
2853 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2857 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2859 struct crypto_testsuite_params *ts_params = &testsuite_params;
2860 struct crypto_unittest_params *ut_params = &unittest_params;
2863 uint8_t *plaintext, *ciphertext;
2864 unsigned plaintext_pad_len;
2865 unsigned plaintext_len;
2867 /* Create KASUMI session */
2868 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2869 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2870 RTE_CRYPTO_CIPHER_KASUMI_F8,
2871 tdata->key.data, tdata->key.len,
2872 tdata->cipher_iv.len);
2876 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2878 /* Clear mbuf payload */
2879 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2880 rte_pktmbuf_tailroom(ut_params->ibuf));
2882 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2883 /* Append data which is padded to a multiple */
2884 /* of the algorithms block size */
2885 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2886 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2888 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2890 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2892 /* Create KASUMI operation */
2893 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2894 tdata->cipher_iv.len,
2895 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2896 tdata->validCipherOffsetInBits.len);
2900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2902 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2904 ut_params->obuf = ut_params->op->sym->m_dst;
2905 if (ut_params->obuf)
2906 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2908 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2910 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2912 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2913 (tdata->validCipherOffsetInBits.len >> 3);
2915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2917 reference_ciphertext,
2918 tdata->validCipherLenInBits.len,
2919 "KASUMI Ciphertext data not as expected");
2924 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2926 struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 struct crypto_unittest_params *ut_params = &unittest_params;
2931 unsigned int plaintext_pad_len;
2932 unsigned int plaintext_len;
2934 uint8_t buffer[10000];
2935 const uint8_t *ciphertext;
2937 struct rte_cryptodev_info dev_info;
2939 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2940 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2941 printf("Device doesn't support scatter-gather. "
2946 /* Create KASUMI session */
2947 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2948 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2949 RTE_CRYPTO_CIPHER_KASUMI_F8,
2950 tdata->key.data, tdata->key.len,
2951 tdata->cipher_iv.len);
2955 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2958 /* Append data which is padded to a multiple */
2959 /* of the algorithms block size */
2960 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2962 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2963 plaintext_pad_len, 10, 0);
2965 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2967 /* Create KASUMI operation */
2968 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2969 tdata->cipher_iv.len,
2970 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2971 tdata->validCipherOffsetInBits.len);
2975 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2977 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2979 ut_params->obuf = ut_params->op->sym->m_dst;
2981 if (ut_params->obuf)
2982 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2983 plaintext_len, buffer);
2985 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2986 tdata->validCipherOffsetInBits.len >> 3,
2987 plaintext_len, buffer);
2990 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2992 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2993 (tdata->validCipherOffsetInBits.len >> 3);
2995 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2997 reference_ciphertext,
2998 tdata->validCipherLenInBits.len,
2999 "KASUMI Ciphertext data not as expected");
3004 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3006 struct crypto_testsuite_params *ts_params = &testsuite_params;
3007 struct crypto_unittest_params *ut_params = &unittest_params;
3010 uint8_t *plaintext, *ciphertext;
3011 unsigned plaintext_pad_len;
3012 unsigned plaintext_len;
3014 /* Create KASUMI session */
3015 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3017 RTE_CRYPTO_CIPHER_KASUMI_F8,
3018 tdata->key.data, tdata->key.len,
3019 tdata->cipher_iv.len);
3023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3024 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3026 /* Clear mbuf payload */
3027 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3028 rte_pktmbuf_tailroom(ut_params->ibuf));
3030 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3031 /* Append data which is padded to a multiple */
3032 /* of the algorithms block size */
3033 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3034 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3036 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3037 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3039 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3041 /* Create KASUMI operation */
3042 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3043 tdata->cipher_iv.len,
3044 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3045 tdata->validCipherOffsetInBits.len);
3049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3051 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3053 ut_params->obuf = ut_params->op->sym->m_dst;
3054 if (ut_params->obuf)
3055 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3057 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3059 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3061 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3062 (tdata->validCipherOffsetInBits.len >> 3);
3064 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3066 reference_ciphertext,
3067 tdata->validCipherLenInBits.len,
3068 "KASUMI Ciphertext data not as expected");
3073 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3075 struct crypto_testsuite_params *ts_params = &testsuite_params;
3076 struct crypto_unittest_params *ut_params = &unittest_params;
3079 unsigned int plaintext_pad_len;
3080 unsigned int plaintext_len;
3082 const uint8_t *ciphertext;
3083 uint8_t buffer[2048];
3085 struct rte_cryptodev_info dev_info;
3087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3088 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3089 printf("Device doesn't support scatter-gather. "
3094 /* Create KASUMI session */
3095 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3096 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3097 RTE_CRYPTO_CIPHER_KASUMI_F8,
3098 tdata->key.data, tdata->key.len,
3099 tdata->cipher_iv.len);
3103 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3104 /* Append data which is padded to a multiple */
3105 /* of the algorithms block size */
3106 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3108 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3109 plaintext_pad_len, 10, 0);
3110 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3111 plaintext_pad_len, 3, 0);
3113 /* Append data which is padded to a multiple */
3114 /* of the algorithms block size */
3115 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3117 /* Create KASUMI operation */
3118 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3119 tdata->cipher_iv.len,
3120 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3121 tdata->validCipherOffsetInBits.len);
3125 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3127 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3129 ut_params->obuf = ut_params->op->sym->m_dst;
3130 if (ut_params->obuf)
3131 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3132 plaintext_pad_len, buffer);
3134 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3135 tdata->validCipherOffsetInBits.len >> 3,
3136 plaintext_pad_len, buffer);
3138 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3139 (tdata->validCipherOffsetInBits.len >> 3);
3141 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3143 reference_ciphertext,
3144 tdata->validCipherLenInBits.len,
3145 "KASUMI Ciphertext data not as expected");
3151 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3153 struct crypto_testsuite_params *ts_params = &testsuite_params;
3154 struct crypto_unittest_params *ut_params = &unittest_params;
3157 uint8_t *ciphertext, *plaintext;
3158 unsigned ciphertext_pad_len;
3159 unsigned ciphertext_len;
3161 /* Create KASUMI session */
3162 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3163 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3164 RTE_CRYPTO_CIPHER_KASUMI_F8,
3165 tdata->key.data, tdata->key.len,
3166 tdata->cipher_iv.len);
3170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3173 /* Clear mbuf payload */
3174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3175 rte_pktmbuf_tailroom(ut_params->ibuf));
3177 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3178 /* Append data which is padded to a multiple */
3179 /* of the algorithms block size */
3180 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3181 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3182 ciphertext_pad_len);
3183 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3184 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3186 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3188 /* Create KASUMI operation */
3189 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3190 tdata->cipher_iv.len,
3191 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3192 tdata->validCipherOffsetInBits.len);
3196 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3198 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3200 ut_params->obuf = ut_params->op->sym->m_dst;
3201 if (ut_params->obuf)
3202 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3204 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3206 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3208 const uint8_t *reference_plaintext = tdata->plaintext.data +
3209 (tdata->validCipherOffsetInBits.len >> 3);
3211 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3213 reference_plaintext,
3214 tdata->validCipherLenInBits.len,
3215 "KASUMI Plaintext data not as expected");
3220 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3222 struct crypto_testsuite_params *ts_params = &testsuite_params;
3223 struct crypto_unittest_params *ut_params = &unittest_params;
3226 uint8_t *ciphertext, *plaintext;
3227 unsigned ciphertext_pad_len;
3228 unsigned ciphertext_len;
3230 /* Create KASUMI session */
3231 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3232 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3233 RTE_CRYPTO_CIPHER_KASUMI_F8,
3234 tdata->key.data, tdata->key.len,
3235 tdata->cipher_iv.len);
3239 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3241 /* Clear mbuf payload */
3242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3243 rte_pktmbuf_tailroom(ut_params->ibuf));
3245 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3246 /* Append data which is padded to a multiple */
3247 /* of the algorithms block size */
3248 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3249 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3250 ciphertext_pad_len);
3251 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3253 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3255 /* Create KASUMI operation */
3256 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3257 tdata->cipher_iv.len,
3258 tdata->ciphertext.len,
3259 tdata->validCipherOffsetInBits.len);
3263 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3265 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3267 ut_params->obuf = ut_params->op->sym->m_dst;
3268 if (ut_params->obuf)
3269 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3271 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3273 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3275 const uint8_t *reference_plaintext = tdata->plaintext.data +
3276 (tdata->validCipherOffsetInBits.len >> 3);
3278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3280 reference_plaintext,
3281 tdata->validCipherLenInBits.len,
3282 "KASUMI Plaintext data not as expected");
3287 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3289 struct crypto_testsuite_params *ts_params = &testsuite_params;
3290 struct crypto_unittest_params *ut_params = &unittest_params;
3293 uint8_t *plaintext, *ciphertext;
3294 unsigned plaintext_pad_len;
3295 unsigned plaintext_len;
3297 /* Create SNOW 3G session */
3298 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3299 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3300 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3301 tdata->key.data, tdata->key.len,
3302 tdata->cipher_iv.len);
3306 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3308 /* Clear mbuf payload */
3309 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3310 rte_pktmbuf_tailroom(ut_params->ibuf));
3312 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3313 /* Append data which is padded to a multiple of */
3314 /* the algorithms block size */
3315 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3316 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3318 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3320 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3322 /* Create SNOW 3G operation */
3323 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3324 tdata->cipher_iv.len,
3325 tdata->validCipherLenInBits.len,
3330 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3332 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3334 ut_params->obuf = ut_params->op->sym->m_dst;
3335 if (ut_params->obuf)
3336 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3338 ciphertext = plaintext;
3340 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3345 tdata->ciphertext.data,
3346 tdata->validDataLenInBits.len,
3347 "SNOW 3G Ciphertext data not as expected");
3353 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3355 struct crypto_testsuite_params *ts_params = &testsuite_params;
3356 struct crypto_unittest_params *ut_params = &unittest_params;
3357 uint8_t *plaintext, *ciphertext;
3360 unsigned plaintext_pad_len;
3361 unsigned plaintext_len;
3363 /* Create SNOW 3G session */
3364 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3365 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3366 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3367 tdata->key.data, tdata->key.len,
3368 tdata->cipher_iv.len);
3372 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3373 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3375 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3376 "Failed to allocate input buffer in mempool");
3377 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3378 "Failed to allocate output buffer in mempool");
3380 /* Clear mbuf payload */
3381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3382 rte_pktmbuf_tailroom(ut_params->ibuf));
3384 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3385 /* Append data which is padded to a multiple of */
3386 /* the algorithms block size */
3387 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3388 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3390 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3391 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3393 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3395 /* Create SNOW 3G operation */
3396 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3397 tdata->cipher_iv.len,
3398 tdata->validCipherLenInBits.len,
3403 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3407 ut_params->obuf = ut_params->op->sym->m_dst;
3408 if (ut_params->obuf)
3409 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3411 ciphertext = plaintext;
3413 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3416 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3418 tdata->ciphertext.data,
3419 tdata->validDataLenInBits.len,
3420 "SNOW 3G Ciphertext data not as expected");
3425 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3427 struct crypto_testsuite_params *ts_params = &testsuite_params;
3428 struct crypto_unittest_params *ut_params = &unittest_params;
3431 unsigned int plaintext_pad_len;
3432 unsigned int plaintext_len;
3433 uint8_t buffer[10000];
3434 const uint8_t *ciphertext;
3436 struct rte_cryptodev_info dev_info;
3438 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3439 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3440 printf("Device doesn't support scatter-gather. "
3445 /* Create SNOW 3G session */
3446 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3447 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3448 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3449 tdata->key.data, tdata->key.len,
3450 tdata->cipher_iv.len);
3454 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3455 /* Append data which is padded to a multiple of */
3456 /* the algorithms block size */
3457 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3459 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3460 plaintext_pad_len, 10, 0);
3461 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3462 plaintext_pad_len, 3, 0);
3464 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3465 "Failed to allocate input buffer in mempool");
3466 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3467 "Failed to allocate output buffer in mempool");
3469 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3471 /* Create SNOW 3G operation */
3472 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3473 tdata->cipher_iv.len,
3474 tdata->validCipherLenInBits.len,
3479 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3481 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3483 ut_params->obuf = ut_params->op->sym->m_dst;
3484 if (ut_params->obuf)
3485 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3486 plaintext_len, buffer);
3488 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3489 plaintext_len, buffer);
3491 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3496 tdata->ciphertext.data,
3497 tdata->validDataLenInBits.len,
3498 "SNOW 3G Ciphertext data not as expected");
3503 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3505 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3507 uint8_t curr_byte, prev_byte;
3508 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3509 uint8_t lower_byte_mask = (1 << offset) - 1;
3512 prev_byte = buffer[0];
3513 buffer[0] >>= offset;
3515 for (i = 1; i < length_in_bytes; i++) {
3516 curr_byte = buffer[i];
3517 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3518 (curr_byte >> offset);
3519 prev_byte = curr_byte;
3524 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3526 struct crypto_testsuite_params *ts_params = &testsuite_params;
3527 struct crypto_unittest_params *ut_params = &unittest_params;
3528 uint8_t *plaintext, *ciphertext;
3530 uint32_t plaintext_len;
3531 uint32_t plaintext_pad_len;
3532 uint8_t extra_offset = 4;
3533 uint8_t *expected_ciphertext_shifted;
3535 /* Create SNOW 3G session */
3536 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3538 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3539 tdata->key.data, tdata->key.len,
3540 tdata->cipher_iv.len);
3544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3545 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3547 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3548 "Failed to allocate input buffer in mempool");
3549 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3550 "Failed to allocate output buffer in mempool");
3552 /* Clear mbuf payload */
3553 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3554 rte_pktmbuf_tailroom(ut_params->ibuf));
3556 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3558 * Append data which is padded to a
3559 * multiple of the algorithms block size
3561 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3563 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3566 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3568 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3569 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3571 #ifdef RTE_APP_TEST_DEBUG
3572 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3574 /* Create SNOW 3G operation */
3575 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3576 tdata->cipher_iv.len,
3577 tdata->validCipherLenInBits.len,
3582 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3584 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3586 ut_params->obuf = ut_params->op->sym->m_dst;
3587 if (ut_params->obuf)
3588 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3590 ciphertext = plaintext;
3592 #ifdef RTE_APP_TEST_DEBUG
3593 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3596 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3598 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3599 "failed to reserve memory for ciphertext shifted\n");
3601 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3602 ceil_byte_length(tdata->ciphertext.len));
3603 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3606 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3608 expected_ciphertext_shifted,
3609 tdata->validDataLenInBits.len,
3611 "SNOW 3G Ciphertext data not as expected");
3615 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3617 struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 struct crypto_unittest_params *ut_params = &unittest_params;
3622 uint8_t *plaintext, *ciphertext;
3623 unsigned ciphertext_pad_len;
3624 unsigned ciphertext_len;
3626 /* Create SNOW 3G session */
3627 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3628 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3629 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3630 tdata->key.data, tdata->key.len,
3631 tdata->cipher_iv.len);
3635 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 /* Clear mbuf payload */
3638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639 rte_pktmbuf_tailroom(ut_params->ibuf));
3641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642 /* Append data which is padded to a multiple of */
3643 /* the algorithms block size */
3644 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3645 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 ciphertext_pad_len);
3647 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3649 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3651 /* Create SNOW 3G operation */
3652 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3653 tdata->cipher_iv.len,
3654 tdata->validCipherLenInBits.len,
3659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3662 ut_params->obuf = ut_params->op->sym->m_dst;
3663 if (ut_params->obuf)
3664 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3666 plaintext = ciphertext;
3668 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3671 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3672 tdata->plaintext.data,
3673 tdata->validDataLenInBits.len,
3674 "SNOW 3G Plaintext data not as expected");
3678 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3680 struct crypto_testsuite_params *ts_params = &testsuite_params;
3681 struct crypto_unittest_params *ut_params = &unittest_params;
3685 uint8_t *plaintext, *ciphertext;
3686 unsigned ciphertext_pad_len;
3687 unsigned ciphertext_len;
3689 /* Create SNOW 3G session */
3690 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3691 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3692 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3693 tdata->key.data, tdata->key.len,
3694 tdata->cipher_iv.len);
3698 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3699 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3701 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3702 "Failed to allocate input buffer");
3703 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3704 "Failed to allocate output buffer");
3706 /* Clear mbuf payload */
3707 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3708 rte_pktmbuf_tailroom(ut_params->ibuf));
3710 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3711 rte_pktmbuf_tailroom(ut_params->obuf));
3713 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3714 /* Append data which is padded to a multiple of */
3715 /* the algorithms block size */
3716 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3717 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3718 ciphertext_pad_len);
3719 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3720 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3722 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3724 /* Create SNOW 3G operation */
3725 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3726 tdata->cipher_iv.len,
3727 tdata->validCipherLenInBits.len,
3732 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3734 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3735 ut_params->obuf = ut_params->op->sym->m_dst;
3736 if (ut_params->obuf)
3737 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3739 plaintext = ciphertext;
3741 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3744 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3745 tdata->plaintext.data,
3746 tdata->validDataLenInBits.len,
3747 "SNOW 3G Plaintext data not as expected");
3752 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3754 struct crypto_testsuite_params *ts_params = &testsuite_params;
3755 struct crypto_unittest_params *ut_params = &unittest_params;
3759 uint8_t *plaintext, *ciphertext;
3760 unsigned int plaintext_pad_len;
3761 unsigned int plaintext_len;
3763 struct rte_cryptodev_sym_capability_idx cap_idx;
3765 /* Check if device supports ZUC EEA3 */
3766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3767 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3773 /* Check if device supports ZUC EIA3 */
3774 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3775 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3777 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3781 /* Create ZUC session */
3782 retval = create_zuc_cipher_auth_encrypt_generate_session(
3783 ts_params->valid_devs[0],
3787 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3789 /* clear mbuf payload */
3790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3791 rte_pktmbuf_tailroom(ut_params->ibuf));
3793 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3794 /* Append data which is padded to a multiple of */
3795 /* the algorithms block size */
3796 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3797 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3799 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3801 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3803 /* Create ZUC operation */
3804 retval = create_zuc_cipher_hash_generate_operation(tdata);
3808 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3810 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3811 ut_params->obuf = ut_params->op->sym->m_src;
3812 if (ut_params->obuf)
3813 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3815 ciphertext = plaintext;
3817 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3821 tdata->ciphertext.data,
3822 tdata->validDataLenInBits.len,
3823 "ZUC Ciphertext data not as expected");
3825 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3826 + plaintext_pad_len;
3829 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3833 "ZUC Generated auth tag not as expected");
3838 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3840 struct crypto_testsuite_params *ts_params = &testsuite_params;
3841 struct crypto_unittest_params *ut_params = &unittest_params;
3845 uint8_t *plaintext, *ciphertext;
3846 unsigned plaintext_pad_len;
3847 unsigned plaintext_len;
3849 /* Create SNOW 3G session */
3850 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3851 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3852 RTE_CRYPTO_AUTH_OP_GENERATE,
3853 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3854 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3855 tdata->key.data, tdata->key.len,
3856 tdata->auth_iv.len, tdata->digest.len,
3857 tdata->cipher_iv.len);
3860 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3862 /* clear mbuf payload */
3863 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3864 rte_pktmbuf_tailroom(ut_params->ibuf));
3866 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3867 /* Append data which is padded to a multiple of */
3868 /* the algorithms block size */
3869 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3870 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3872 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3874 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3876 /* Create SNOW 3G operation */
3877 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3878 tdata->digest.len, tdata->auth_iv.data,
3880 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3881 tdata->cipher_iv.data, tdata->cipher_iv.len,
3882 tdata->validCipherLenInBits.len,
3884 tdata->validAuthLenInBits.len,
3890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3893 ut_params->obuf = ut_params->op->sym->m_src;
3894 if (ut_params->obuf)
3895 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3897 ciphertext = plaintext;
3899 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3901 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3903 tdata->ciphertext.data,
3904 tdata->validDataLenInBits.len,
3905 "SNOW 3G Ciphertext data not as expected");
3907 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3908 + plaintext_pad_len;
3911 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3914 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3915 "SNOW 3G Generated auth tag not as expected");
3919 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3921 struct crypto_testsuite_params *ts_params = &testsuite_params;
3922 struct crypto_unittest_params *ut_params = &unittest_params;
3926 uint8_t *plaintext, *ciphertext;
3927 unsigned plaintext_pad_len;
3928 unsigned plaintext_len;
3930 /* Create SNOW 3G session */
3931 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3932 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3933 RTE_CRYPTO_AUTH_OP_GENERATE,
3934 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3935 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3936 tdata->key.data, tdata->key.len,
3937 tdata->auth_iv.len, tdata->digest.len,
3938 tdata->cipher_iv.len);
3942 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3944 /* clear mbuf payload */
3945 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3946 rte_pktmbuf_tailroom(ut_params->ibuf));
3948 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3949 /* Append data which is padded to a multiple of */
3950 /* the algorithms block size */
3951 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3952 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3954 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3956 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3958 /* Create SNOW 3G operation */
3959 retval = create_wireless_algo_auth_cipher_operation(
3961 tdata->cipher_iv.data, tdata->cipher_iv.len,
3962 tdata->auth_iv.data, tdata->auth_iv.len,
3964 tdata->validCipherLenInBits.len,
3966 tdata->validAuthLenInBits.len,
3972 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3974 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3975 ut_params->obuf = ut_params->op->sym->m_src;
3976 if (ut_params->obuf)
3977 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3979 ciphertext = plaintext;
3981 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3982 + plaintext_pad_len;
3983 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3986 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3988 tdata->ciphertext.data,
3989 tdata->validDataLenInBits.len,
3990 "SNOW 3G Ciphertext data not as expected");
3993 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3996 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3997 "SNOW 3G Generated auth tag not as expected");
4002 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4004 struct crypto_testsuite_params *ts_params = &testsuite_params;
4005 struct crypto_unittest_params *ut_params = &unittest_params;
4009 uint8_t *plaintext, *ciphertext;
4010 unsigned plaintext_pad_len;
4011 unsigned plaintext_len;
4013 /* Create KASUMI session */
4014 retval = create_wireless_algo_auth_cipher_session(
4015 ts_params->valid_devs[0],
4016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4017 RTE_CRYPTO_AUTH_OP_GENERATE,
4018 RTE_CRYPTO_AUTH_KASUMI_F9,
4019 RTE_CRYPTO_CIPHER_KASUMI_F8,
4020 tdata->key.data, tdata->key.len,
4021 0, tdata->digest.len,
4022 tdata->cipher_iv.len);
4025 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4027 /* clear mbuf payload */
4028 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4029 rte_pktmbuf_tailroom(ut_params->ibuf));
4031 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4032 /* Append data which is padded to a multiple of */
4033 /* the algorithms block size */
4034 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4035 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4037 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4039 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4041 /* Create KASUMI operation */
4042 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4043 tdata->cipher_iv.data, tdata->cipher_iv.len,
4046 tdata->validCipherLenInBits.len,
4047 tdata->validCipherOffsetInBits.len,
4048 tdata->validAuthLenInBits.len,
4055 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4057 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4058 if (ut_params->op->sym->m_dst)
4059 ut_params->obuf = ut_params->op->sym->m_dst;
4061 ut_params->obuf = ut_params->op->sym->m_src;
4063 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4064 tdata->validCipherOffsetInBits.len >> 3);
4066 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4067 (tdata->validCipherOffsetInBits.len >> 3);
4069 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4071 reference_ciphertext,
4072 tdata->validCipherLenInBits.len,
4073 "KASUMI Ciphertext data not as expected");
4074 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4075 + plaintext_pad_len;
4078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4081 DIGEST_BYTE_LENGTH_KASUMI_F9,
4082 "KASUMI Generated auth tag not as expected");
4087 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4089 struct crypto_testsuite_params *ts_params = &testsuite_params;
4090 struct crypto_unittest_params *ut_params = &unittest_params;
4094 uint8_t *plaintext, *ciphertext;
4095 unsigned plaintext_pad_len;
4096 unsigned plaintext_len;
4098 /* Create KASUMI session */
4099 retval = create_wireless_algo_cipher_auth_session(
4100 ts_params->valid_devs[0],
4101 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4102 RTE_CRYPTO_AUTH_OP_GENERATE,
4103 RTE_CRYPTO_AUTH_KASUMI_F9,
4104 RTE_CRYPTO_CIPHER_KASUMI_F8,
4105 tdata->key.data, tdata->key.len,
4106 0, tdata->digest.len,
4107 tdata->cipher_iv.len);
4111 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4113 /* clear mbuf payload */
4114 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4115 rte_pktmbuf_tailroom(ut_params->ibuf));
4117 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4118 /* Append data which is padded to a multiple of */
4119 /* the algorithms block size */
4120 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4121 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4123 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4125 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4127 /* Create KASUMI operation */
4128 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4129 tdata->digest.len, NULL, 0,
4130 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4131 tdata->cipher_iv.data, tdata->cipher_iv.len,
4132 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4133 tdata->validCipherOffsetInBits.len,
4134 tdata->validAuthLenInBits.len,
4140 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4142 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4144 if (ut_params->op->sym->m_dst)
4145 ut_params->obuf = ut_params->op->sym->m_dst;
4147 ut_params->obuf = ut_params->op->sym->m_src;
4149 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4150 tdata->validCipherOffsetInBits.len >> 3);
4152 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4153 + plaintext_pad_len;
4155 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4156 (tdata->validCipherOffsetInBits.len >> 3);
4158 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4160 reference_ciphertext,
4161 tdata->validCipherLenInBits.len,
4162 "KASUMI Ciphertext data not as expected");
4165 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4168 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4169 "KASUMI Generated auth tag not as expected");
4174 test_zuc_encryption(const struct wireless_test_data *tdata)
4176 struct crypto_testsuite_params *ts_params = &testsuite_params;
4177 struct crypto_unittest_params *ut_params = &unittest_params;
4180 uint8_t *plaintext, *ciphertext;
4181 unsigned plaintext_pad_len;
4182 unsigned plaintext_len;
4184 struct rte_cryptodev_sym_capability_idx cap_idx;
4186 /* Check if device supports ZUC EEA3 */
4187 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4188 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4190 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4194 /* Create ZUC session */
4195 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4196 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4197 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4198 tdata->key.data, tdata->key.len,
4199 tdata->cipher_iv.len);
4203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4205 /* Clear mbuf payload */
4206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4207 rte_pktmbuf_tailroom(ut_params->ibuf));
4209 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4210 /* Append data which is padded to a multiple */
4211 /* of the algorithms block size */
4212 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4213 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4215 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4217 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4219 /* Create ZUC operation */
4220 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4221 tdata->cipher_iv.len,
4222 tdata->plaintext.len,
4227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4229 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4231 ut_params->obuf = ut_params->op->sym->m_dst;
4232 if (ut_params->obuf)
4233 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4235 ciphertext = plaintext;
4237 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4240 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4242 tdata->ciphertext.data,
4243 tdata->validCipherLenInBits.len,
4244 "ZUC Ciphertext data not as expected");
4249 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4251 struct crypto_testsuite_params *ts_params = &testsuite_params;
4252 struct crypto_unittest_params *ut_params = &unittest_params;
4256 unsigned int plaintext_pad_len;
4257 unsigned int plaintext_len;
4258 const uint8_t *ciphertext;
4259 uint8_t ciphertext_buffer[2048];
4260 struct rte_cryptodev_info dev_info;
4262 struct rte_cryptodev_sym_capability_idx cap_idx;
4264 /* Check if device supports ZUC EEA3 */
4265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4266 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4273 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4274 printf("Device doesn't support scatter-gather. "
4279 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4281 /* Append data which is padded to a multiple */
4282 /* of the algorithms block size */
4283 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4285 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4286 plaintext_pad_len, 10, 0);
4288 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4289 tdata->plaintext.data);
4291 /* Create ZUC session */
4292 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4293 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4294 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4295 tdata->key.data, tdata->key.len,
4296 tdata->cipher_iv.len);
4300 /* Clear mbuf payload */
4302 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4304 /* Create ZUC operation */
4305 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4306 tdata->cipher_iv.len, tdata->plaintext.len,
4311 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4313 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4315 ut_params->obuf = ut_params->op->sym->m_dst;
4316 if (ut_params->obuf)
4317 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4318 0, plaintext_len, ciphertext_buffer);
4320 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4321 0, plaintext_len, ciphertext_buffer);
4324 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4327 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4329 tdata->ciphertext.data,
4330 tdata->validCipherLenInBits.len,
4331 "ZUC Ciphertext data not as expected");
4337 test_zuc_authentication(const struct wireless_test_data *tdata)
4339 struct crypto_testsuite_params *ts_params = &testsuite_params;
4340 struct crypto_unittest_params *ut_params = &unittest_params;
4343 unsigned plaintext_pad_len;
4344 unsigned plaintext_len;
4347 struct rte_cryptodev_sym_capability_idx cap_idx;
4349 /* Check if device supports ZUC EIA3 */
4350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4351 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4353 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4357 /* Create ZUC session */
4358 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4359 tdata->key.data, tdata->key.len,
4360 tdata->auth_iv.len, tdata->digest.len,
4361 RTE_CRYPTO_AUTH_OP_GENERATE,
4362 RTE_CRYPTO_AUTH_ZUC_EIA3);
4366 /* alloc mbuf and set payload */
4367 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4369 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4370 rte_pktmbuf_tailroom(ut_params->ibuf));
4372 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4373 /* Append data which is padded to a multiple of */
4374 /* the algorithms block size */
4375 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4376 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4378 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4380 /* Create ZUC operation */
4381 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4382 tdata->auth_iv.data, tdata->auth_iv.len,
4383 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4384 tdata->validAuthLenInBits.len,
4389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4391 ut_params->obuf = ut_params->op->sym->m_src;
4392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4393 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4394 + plaintext_pad_len;
4397 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4400 DIGEST_BYTE_LENGTH_KASUMI_F9,
4401 "ZUC Generated auth tag not as expected");
4407 test_kasumi_encryption_test_case_1(void)
4409 return test_kasumi_encryption(&kasumi_test_case_1);
4413 test_kasumi_encryption_test_case_1_sgl(void)
4415 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4419 test_kasumi_encryption_test_case_1_oop(void)
4421 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4425 test_kasumi_encryption_test_case_1_oop_sgl(void)
4427 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4431 test_kasumi_encryption_test_case_2(void)
4433 return test_kasumi_encryption(&kasumi_test_case_2);
4437 test_kasumi_encryption_test_case_3(void)
4439 return test_kasumi_encryption(&kasumi_test_case_3);
4443 test_kasumi_encryption_test_case_4(void)
4445 return test_kasumi_encryption(&kasumi_test_case_4);
4449 test_kasumi_encryption_test_case_5(void)
4451 return test_kasumi_encryption(&kasumi_test_case_5);
4455 test_kasumi_decryption_test_case_1(void)
4457 return test_kasumi_decryption(&kasumi_test_case_1);
4461 test_kasumi_decryption_test_case_1_oop(void)
4463 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4467 test_kasumi_decryption_test_case_2(void)
4469 return test_kasumi_decryption(&kasumi_test_case_2);
4473 test_kasumi_decryption_test_case_3(void)
4475 return test_kasumi_decryption(&kasumi_test_case_3);
4479 test_kasumi_decryption_test_case_4(void)
4481 return test_kasumi_decryption(&kasumi_test_case_4);
4485 test_kasumi_decryption_test_case_5(void)
4487 return test_kasumi_decryption(&kasumi_test_case_5);
4490 test_snow3g_encryption_test_case_1(void)
4492 return test_snow3g_encryption(&snow3g_test_case_1);
4496 test_snow3g_encryption_test_case_1_oop(void)
4498 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4502 test_snow3g_encryption_test_case_1_oop_sgl(void)
4504 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4509 test_snow3g_encryption_test_case_1_offset_oop(void)
4511 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4515 test_snow3g_encryption_test_case_2(void)
4517 return test_snow3g_encryption(&snow3g_test_case_2);
4521 test_snow3g_encryption_test_case_3(void)
4523 return test_snow3g_encryption(&snow3g_test_case_3);
4527 test_snow3g_encryption_test_case_4(void)
4529 return test_snow3g_encryption(&snow3g_test_case_4);
4533 test_snow3g_encryption_test_case_5(void)
4535 return test_snow3g_encryption(&snow3g_test_case_5);
4539 test_snow3g_decryption_test_case_1(void)
4541 return test_snow3g_decryption(&snow3g_test_case_1);
4545 test_snow3g_decryption_test_case_1_oop(void)
4547 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4551 test_snow3g_decryption_test_case_2(void)
4553 return test_snow3g_decryption(&snow3g_test_case_2);
4557 test_snow3g_decryption_test_case_3(void)
4559 return test_snow3g_decryption(&snow3g_test_case_3);
4563 test_snow3g_decryption_test_case_4(void)
4565 return test_snow3g_decryption(&snow3g_test_case_4);
4569 test_snow3g_decryption_test_case_5(void)
4571 return test_snow3g_decryption(&snow3g_test_case_5);
4574 test_snow3g_cipher_auth_test_case_1(void)
4576 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4580 test_snow3g_auth_cipher_test_case_1(void)
4582 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4586 test_kasumi_auth_cipher_test_case_1(void)
4588 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4592 test_kasumi_cipher_auth_test_case_1(void)
4594 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4598 test_zuc_encryption_test_case_1(void)
4600 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4604 test_zuc_encryption_test_case_2(void)
4606 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4610 test_zuc_encryption_test_case_3(void)
4612 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4616 test_zuc_encryption_test_case_4(void)
4618 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4622 test_zuc_encryption_test_case_5(void)
4624 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4628 test_zuc_encryption_test_case_6_sgl(void)
4630 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4634 test_zuc_hash_generate_test_case_1(void)
4636 return test_zuc_authentication(&zuc_test_case_auth_1b);
4640 test_zuc_hash_generate_test_case_2(void)
4642 return test_zuc_authentication(&zuc_test_case_auth_90b);
4646 test_zuc_hash_generate_test_case_3(void)
4648 return test_zuc_authentication(&zuc_test_case_auth_577b);
4652 test_zuc_hash_generate_test_case_4(void)
4654 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4658 test_zuc_hash_generate_test_case_5(void)
4660 return test_zuc_authentication(&zuc_test_auth_5670b);
4664 test_zuc_hash_generate_test_case_6(void)
4666 return test_zuc_authentication(&zuc_test_case_auth_128b);
4670 test_zuc_hash_generate_test_case_7(void)
4672 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4676 test_zuc_hash_generate_test_case_8(void)
4678 return test_zuc_authentication(&zuc_test_case_auth_584b);
4682 test_zuc_cipher_auth_test_case_1(void)
4684 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4688 test_zuc_cipher_auth_test_case_2(void)
4690 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4694 test_3DES_chain_qat_all(void)
4696 struct crypto_testsuite_params *ts_params = &testsuite_params;
4699 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4700 ts_params->op_mpool,
4701 ts_params->session_mpool,
4702 ts_params->valid_devs[0],
4703 rte_cryptodev_driver_id_get(
4704 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4705 BLKCIPHER_3DES_CHAIN_TYPE);
4707 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4709 return TEST_SUCCESS;
4713 test_DES_cipheronly_qat_all(void)
4715 struct crypto_testsuite_params *ts_params = &testsuite_params;
4718 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4719 ts_params->op_mpool,
4720 ts_params->session_mpool,
4721 ts_params->valid_devs[0],
4722 rte_cryptodev_driver_id_get(
4723 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4724 BLKCIPHER_DES_CIPHERONLY_TYPE);
4726 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4728 return TEST_SUCCESS;
4732 test_DES_cipheronly_openssl_all(void)
4734 struct crypto_testsuite_params *ts_params = &testsuite_params;
4737 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4738 ts_params->op_mpool,
4739 ts_params->session_mpool,
4740 ts_params->valid_devs[0],
4741 rte_cryptodev_driver_id_get(
4742 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4743 BLKCIPHER_DES_CIPHERONLY_TYPE);
4745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4747 return TEST_SUCCESS;
4751 test_DES_docsis_openssl_all(void)
4753 struct crypto_testsuite_params *ts_params = &testsuite_params;
4756 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4757 ts_params->op_mpool,
4758 ts_params->session_mpool,
4759 ts_params->valid_devs[0],
4760 rte_cryptodev_driver_id_get(
4761 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4762 BLKCIPHER_DES_DOCSIS_TYPE);
4764 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4766 return TEST_SUCCESS;
4770 test_DES_cipheronly_mb_all(void)
4772 struct crypto_testsuite_params *ts_params = &testsuite_params;
4775 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4776 ts_params->op_mpool,
4777 ts_params->session_mpool,
4778 ts_params->valid_devs[0],
4779 rte_cryptodev_driver_id_get(
4780 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4781 BLKCIPHER_DES_CIPHERONLY_TYPE);
4783 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4785 return TEST_SUCCESS;
4789 test_DES_docsis_mb_all(void)
4791 struct crypto_testsuite_params *ts_params = &testsuite_params;
4794 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4795 ts_params->op_mpool,
4796 ts_params->session_mpool,
4797 ts_params->valid_devs[0],
4798 rte_cryptodev_driver_id_get(
4799 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4800 BLKCIPHER_DES_DOCSIS_TYPE);
4802 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4804 return TEST_SUCCESS;
4808 test_3DES_chain_dpaa_sec_all(void)
4810 struct crypto_testsuite_params *ts_params = &testsuite_params;
4813 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4814 ts_params->op_mpool,
4815 ts_params->session_mpool,
4816 ts_params->valid_devs[0],
4817 rte_cryptodev_driver_id_get(
4818 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4819 BLKCIPHER_3DES_CHAIN_TYPE);
4821 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4823 return TEST_SUCCESS;
4827 test_3DES_cipheronly_dpaa_sec_all(void)
4829 struct crypto_testsuite_params *ts_params = &testsuite_params;
4832 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4833 ts_params->op_mpool,
4834 ts_params->session_mpool,
4835 ts_params->valid_devs[0],
4836 rte_cryptodev_driver_id_get(
4837 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4838 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4840 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4842 return TEST_SUCCESS;
4846 test_3DES_chain_dpaa2_sec_all(void)
4848 struct crypto_testsuite_params *ts_params = &testsuite_params;
4851 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4852 ts_params->op_mpool,
4853 ts_params->session_mpool,
4854 ts_params->valid_devs[0],
4855 rte_cryptodev_driver_id_get(
4856 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4857 BLKCIPHER_3DES_CHAIN_TYPE);
4859 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4861 return TEST_SUCCESS;
4865 test_3DES_cipheronly_dpaa2_sec_all(void)
4867 struct crypto_testsuite_params *ts_params = &testsuite_params;
4870 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4871 ts_params->op_mpool,
4872 ts_params->session_mpool,
4873 ts_params->valid_devs[0],
4874 rte_cryptodev_driver_id_get(
4875 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4876 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4878 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4880 return TEST_SUCCESS;
4884 test_3DES_cipheronly_qat_all(void)
4886 struct crypto_testsuite_params *ts_params = &testsuite_params;
4889 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4890 ts_params->op_mpool,
4891 ts_params->session_mpool,
4892 ts_params->valid_devs[0],
4893 rte_cryptodev_driver_id_get(
4894 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4895 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4897 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4899 return TEST_SUCCESS;
4903 test_3DES_chain_openssl_all(void)
4905 struct crypto_testsuite_params *ts_params = &testsuite_params;
4908 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4909 ts_params->op_mpool,
4910 ts_params->session_mpool,
4911 ts_params->valid_devs[0],
4912 rte_cryptodev_driver_id_get(
4913 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4914 BLKCIPHER_3DES_CHAIN_TYPE);
4916 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4918 return TEST_SUCCESS;
4922 test_3DES_cipheronly_openssl_all(void)
4924 struct crypto_testsuite_params *ts_params = &testsuite_params;
4927 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4928 ts_params->op_mpool,
4929 ts_params->session_mpool,
4930 ts_params->valid_devs[0],
4931 rte_cryptodev_driver_id_get(
4932 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4933 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4935 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4937 return TEST_SUCCESS;
4940 /* ***** AEAD algorithm Tests ***** */
4943 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
4944 enum rte_crypto_aead_operation op,
4945 const uint8_t *key, const uint8_t key_len,
4946 const uint16_t aad_len, const uint8_t auth_len,
4949 uint8_t aead_key[key_len];
4951 struct crypto_testsuite_params *ts_params = &testsuite_params;
4952 struct crypto_unittest_params *ut_params = &unittest_params;
4954 memcpy(aead_key, key, key_len);
4956 /* Setup AEAD Parameters */
4957 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4958 ut_params->aead_xform.next = NULL;
4959 ut_params->aead_xform.aead.algo = algo;
4960 ut_params->aead_xform.aead.op = op;
4961 ut_params->aead_xform.aead.key.data = aead_key;
4962 ut_params->aead_xform.aead.key.length = key_len;
4963 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4964 ut_params->aead_xform.aead.iv.length = iv_len;
4965 ut_params->aead_xform.aead.digest_length = auth_len;
4966 ut_params->aead_xform.aead.aad_length = aad_len;
4968 TEST_HEXDUMP(stdout, "key:", key, key_len);
4970 /* Create Crypto session*/
4971 ut_params->sess = rte_cryptodev_sym_session_create(
4972 ts_params->session_mpool);
4974 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
4975 &ut_params->aead_xform, ts_params->session_mpool);
4977 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4983 create_aead_xform(struct rte_crypto_op *op,
4984 enum rte_crypto_aead_algorithm algo,
4985 enum rte_crypto_aead_operation aead_op,
4986 uint8_t *key, const uint8_t key_len,
4987 const uint8_t aad_len, const uint8_t auth_len,
4990 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4991 "failed to allocate space for crypto transform");
4993 struct rte_crypto_sym_op *sym_op = op->sym;
4995 /* Setup AEAD Parameters */
4996 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4997 sym_op->xform->next = NULL;
4998 sym_op->xform->aead.algo = algo;
4999 sym_op->xform->aead.op = aead_op;
5000 sym_op->xform->aead.key.data = key;
5001 sym_op->xform->aead.key.length = key_len;
5002 sym_op->xform->aead.iv.offset = IV_OFFSET;
5003 sym_op->xform->aead.iv.length = iv_len;
5004 sym_op->xform->aead.digest_length = auth_len;
5005 sym_op->xform->aead.aad_length = aad_len;
5007 TEST_HEXDUMP(stdout, "key:", key, key_len);
5013 create_aead_operation(enum rte_crypto_aead_operation op,
5014 const struct aead_test_data *tdata)
5016 struct crypto_testsuite_params *ts_params = &testsuite_params;
5017 struct crypto_unittest_params *ut_params = &unittest_params;
5019 uint8_t *plaintext, *ciphertext;
5020 unsigned int aad_pad_len, plaintext_pad_len;
5022 /* Generate Crypto op data structure */
5023 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5024 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5025 TEST_ASSERT_NOT_NULL(ut_params->op,
5026 "Failed to allocate symmetric crypto operation struct");
5028 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5030 /* Append aad data */
5031 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5032 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5033 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5035 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5036 "no room to append aad");
5038 sym_op->aead.aad.phys_addr =
5039 rte_pktmbuf_mtophys(ut_params->ibuf);
5040 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5041 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5042 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5045 /* Append IV at the end of the crypto operation*/
5046 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5047 uint8_t *, IV_OFFSET);
5049 /* Copy IV 1 byte after the IV pointer, according to the API */
5050 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5051 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5054 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5055 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5057 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5058 "no room to append aad");
5060 sym_op->aead.aad.phys_addr =
5061 rte_pktmbuf_mtophys(ut_params->ibuf);
5062 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5063 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5066 /* Append IV at the end of the crypto operation*/
5067 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5068 uint8_t *, IV_OFFSET);
5070 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5071 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5075 /* Append plaintext/ciphertext */
5076 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5077 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5078 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5080 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5082 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5083 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
5084 tdata->plaintext.len);
5086 if (ut_params->obuf) {
5087 ciphertext = (uint8_t *)rte_pktmbuf_append(
5089 plaintext_pad_len + aad_pad_len);
5090 TEST_ASSERT_NOT_NULL(ciphertext,
5091 "no room to append ciphertext");
5093 memset(ciphertext + aad_pad_len, 0,
5094 tdata->ciphertext.len);
5097 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5098 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5100 TEST_ASSERT_NOT_NULL(ciphertext,
5101 "no room to append ciphertext");
5103 memcpy(ciphertext, tdata->ciphertext.data,
5104 tdata->ciphertext.len);
5105 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
5106 tdata->ciphertext.len);
5108 if (ut_params->obuf) {
5109 plaintext = (uint8_t *)rte_pktmbuf_append(
5111 plaintext_pad_len + aad_pad_len);
5112 TEST_ASSERT_NOT_NULL(plaintext,
5113 "no room to append plaintext");
5115 memset(plaintext + aad_pad_len, 0,
5116 tdata->plaintext.len);
5120 /* Append digest data */
5121 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5122 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5123 ut_params->obuf ? ut_params->obuf :
5125 tdata->auth_tag.len);
5126 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5127 "no room to append digest");
5128 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5129 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5130 ut_params->obuf ? ut_params->obuf :
5135 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5136 ut_params->ibuf, tdata->auth_tag.len);
5137 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5138 "no room to append digest");
5139 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5141 plaintext_pad_len + aad_pad_len);
5143 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5144 tdata->auth_tag.len);
5145 TEST_HEXDUMP(stdout, "digest:",
5146 sym_op->aead.digest.data,
5147 tdata->auth_tag.len);
5150 sym_op->aead.data.length = tdata->plaintext.len;
5151 sym_op->aead.data.offset = aad_pad_len;
5157 test_authenticated_encryption(const struct aead_test_data *tdata)
5159 struct crypto_testsuite_params *ts_params = &testsuite_params;
5160 struct crypto_unittest_params *ut_params = &unittest_params;
5163 uint8_t *ciphertext, *auth_tag;
5164 uint16_t plaintext_pad_len;
5167 /* Create AEAD session */
5168 retval = create_aead_session(ts_params->valid_devs[0],
5170 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5171 tdata->key.data, tdata->key.len,
5172 tdata->aad.len, tdata->auth_tag.len,
5177 if (tdata->aad.len > MBUF_SIZE) {
5178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5179 /* Populate full size of add data */
5180 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5181 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5185 /* clear mbuf payload */
5186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5187 rte_pktmbuf_tailroom(ut_params->ibuf));
5189 /* Create AEAD operation */
5190 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5194 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5196 ut_params->op->sym->m_src = ut_params->ibuf;
5198 /* Process crypto operation */
5199 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5200 ut_params->op), "failed to process sym crypto op");
5202 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5203 "crypto op processing failed");
5205 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5207 if (ut_params->op->sym->m_dst) {
5208 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5210 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5211 uint8_t *, plaintext_pad_len);
5213 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5215 ut_params->op->sym->cipher.data.offset);
5216 auth_tag = ciphertext + plaintext_pad_len;
5219 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5220 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5223 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5225 tdata->ciphertext.data,
5226 tdata->ciphertext.len,
5227 "Ciphertext data not as expected");
5229 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5231 tdata->auth_tag.data,
5232 tdata->auth_tag.len,
5233 "Generated auth tag not as expected");
5240 test_AES_GCM_authenticated_encryption_test_case_1(void)
5242 return test_authenticated_encryption(&gcm_test_case_1);
5246 test_AES_GCM_authenticated_encryption_test_case_2(void)
5248 return test_authenticated_encryption(&gcm_test_case_2);
5252 test_AES_GCM_authenticated_encryption_test_case_3(void)
5254 return test_authenticated_encryption(&gcm_test_case_3);
5258 test_AES_GCM_authenticated_encryption_test_case_4(void)
5260 return test_authenticated_encryption(&gcm_test_case_4);
5264 test_AES_GCM_authenticated_encryption_test_case_5(void)
5266 return test_authenticated_encryption(&gcm_test_case_5);
5270 test_AES_GCM_authenticated_encryption_test_case_6(void)
5272 return test_authenticated_encryption(&gcm_test_case_6);
5276 test_AES_GCM_authenticated_encryption_test_case_7(void)
5278 return test_authenticated_encryption(&gcm_test_case_7);
5282 test_AES_GCM_auth_encryption_test_case_192_1(void)
5284 return test_authenticated_encryption(&gcm_test_case_192_1);
5288 test_AES_GCM_auth_encryption_test_case_192_2(void)
5290 return test_authenticated_encryption(&gcm_test_case_192_2);
5294 test_AES_GCM_auth_encryption_test_case_192_3(void)
5296 return test_authenticated_encryption(&gcm_test_case_192_3);
5300 test_AES_GCM_auth_encryption_test_case_192_4(void)
5302 return test_authenticated_encryption(&gcm_test_case_192_4);
5306 test_AES_GCM_auth_encryption_test_case_192_5(void)
5308 return test_authenticated_encryption(&gcm_test_case_192_5);
5312 test_AES_GCM_auth_encryption_test_case_192_6(void)
5314 return test_authenticated_encryption(&gcm_test_case_192_6);
5318 test_AES_GCM_auth_encryption_test_case_192_7(void)
5320 return test_authenticated_encryption(&gcm_test_case_192_7);
5324 test_AES_GCM_auth_encryption_test_case_256_1(void)
5326 return test_authenticated_encryption(&gcm_test_case_256_1);
5330 test_AES_GCM_auth_encryption_test_case_256_2(void)
5332 return test_authenticated_encryption(&gcm_test_case_256_2);
5336 test_AES_GCM_auth_encryption_test_case_256_3(void)
5338 return test_authenticated_encryption(&gcm_test_case_256_3);
5342 test_AES_GCM_auth_encryption_test_case_256_4(void)
5344 return test_authenticated_encryption(&gcm_test_case_256_4);
5348 test_AES_GCM_auth_encryption_test_case_256_5(void)
5350 return test_authenticated_encryption(&gcm_test_case_256_5);
5354 test_AES_GCM_auth_encryption_test_case_256_6(void)
5356 return test_authenticated_encryption(&gcm_test_case_256_6);
5360 test_AES_GCM_auth_encryption_test_case_256_7(void)
5362 return test_authenticated_encryption(&gcm_test_case_256_7);
5366 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5368 return test_authenticated_encryption(&gcm_test_case_aad_1);
5372 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5374 return test_authenticated_encryption(&gcm_test_case_aad_2);
5378 test_authenticated_decryption(const struct aead_test_data *tdata)
5380 struct crypto_testsuite_params *ts_params = &testsuite_params;
5381 struct crypto_unittest_params *ut_params = &unittest_params;
5387 /* Create AEAD session */
5388 retval = create_aead_session(ts_params->valid_devs[0],
5390 RTE_CRYPTO_AEAD_OP_DECRYPT,
5391 tdata->key.data, tdata->key.len,
5392 tdata->aad.len, tdata->auth_tag.len,
5397 /* alloc mbuf and set payload */
5398 if (tdata->aad.len > MBUF_SIZE) {
5399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5400 /* Populate full size of add data */
5401 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5402 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5406 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5407 rte_pktmbuf_tailroom(ut_params->ibuf));
5409 /* Create AEAD operation */
5410 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5416 ut_params->op->sym->m_src = ut_params->ibuf;
5418 /* Process crypto operation */
5419 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5420 ut_params->op), "failed to process sym crypto op");
5422 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5423 "crypto op processing failed");
5425 if (ut_params->op->sym->m_dst)
5426 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5429 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5431 ut_params->op->sym->cipher.data.offset);
5433 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5436 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5438 tdata->plaintext.data,
5439 tdata->plaintext.len,
5440 "Plaintext data not as expected");
5442 TEST_ASSERT_EQUAL(ut_params->op->status,
5443 RTE_CRYPTO_OP_STATUS_SUCCESS,
5444 "Authentication failed");
5449 test_AES_GCM_authenticated_decryption_test_case_1(void)
5451 return test_authenticated_decryption(&gcm_test_case_1);
5455 test_AES_GCM_authenticated_decryption_test_case_2(void)
5457 return test_authenticated_decryption(&gcm_test_case_2);
5461 test_AES_GCM_authenticated_decryption_test_case_3(void)
5463 return test_authenticated_decryption(&gcm_test_case_3);
5467 test_AES_GCM_authenticated_decryption_test_case_4(void)
5469 return test_authenticated_decryption(&gcm_test_case_4);
5473 test_AES_GCM_authenticated_decryption_test_case_5(void)
5475 return test_authenticated_decryption(&gcm_test_case_5);
5479 test_AES_GCM_authenticated_decryption_test_case_6(void)
5481 return test_authenticated_decryption(&gcm_test_case_6);
5485 test_AES_GCM_authenticated_decryption_test_case_7(void)
5487 return test_authenticated_decryption(&gcm_test_case_7);
5491 test_AES_GCM_auth_decryption_test_case_192_1(void)
5493 return test_authenticated_decryption(&gcm_test_case_192_1);
5497 test_AES_GCM_auth_decryption_test_case_192_2(void)
5499 return test_authenticated_decryption(&gcm_test_case_192_2);
5503 test_AES_GCM_auth_decryption_test_case_192_3(void)
5505 return test_authenticated_decryption(&gcm_test_case_192_3);
5509 test_AES_GCM_auth_decryption_test_case_192_4(void)
5511 return test_authenticated_decryption(&gcm_test_case_192_4);
5515 test_AES_GCM_auth_decryption_test_case_192_5(void)
5517 return test_authenticated_decryption(&gcm_test_case_192_5);
5521 test_AES_GCM_auth_decryption_test_case_192_6(void)
5523 return test_authenticated_decryption(&gcm_test_case_192_6);
5527 test_AES_GCM_auth_decryption_test_case_192_7(void)
5529 return test_authenticated_decryption(&gcm_test_case_192_7);
5533 test_AES_GCM_auth_decryption_test_case_256_1(void)
5535 return test_authenticated_decryption(&gcm_test_case_256_1);
5539 test_AES_GCM_auth_decryption_test_case_256_2(void)
5541 return test_authenticated_decryption(&gcm_test_case_256_2);
5545 test_AES_GCM_auth_decryption_test_case_256_3(void)
5547 return test_authenticated_decryption(&gcm_test_case_256_3);
5551 test_AES_GCM_auth_decryption_test_case_256_4(void)
5553 return test_authenticated_decryption(&gcm_test_case_256_4);
5557 test_AES_GCM_auth_decryption_test_case_256_5(void)
5559 return test_authenticated_decryption(&gcm_test_case_256_5);
5563 test_AES_GCM_auth_decryption_test_case_256_6(void)
5565 return test_authenticated_decryption(&gcm_test_case_256_6);
5569 test_AES_GCM_auth_decryption_test_case_256_7(void)
5571 return test_authenticated_decryption(&gcm_test_case_256_7);
5575 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5577 return test_authenticated_decryption(&gcm_test_case_aad_1);
5581 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5583 return test_authenticated_decryption(&gcm_test_case_aad_2);
5587 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5589 struct crypto_testsuite_params *ts_params = &testsuite_params;
5590 struct crypto_unittest_params *ut_params = &unittest_params;
5593 uint8_t *ciphertext, *auth_tag;
5594 uint16_t plaintext_pad_len;
5596 /* Create AEAD session */
5597 retval = create_aead_session(ts_params->valid_devs[0],
5599 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5600 tdata->key.data, tdata->key.len,
5601 tdata->aad.len, tdata->auth_tag.len,
5606 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5607 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5609 /* clear mbuf payload */
5610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5611 rte_pktmbuf_tailroom(ut_params->ibuf));
5612 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5613 rte_pktmbuf_tailroom(ut_params->obuf));
5615 /* Create AEAD operation */
5616 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5620 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5622 ut_params->op->sym->m_src = ut_params->ibuf;
5623 ut_params->op->sym->m_dst = ut_params->obuf;
5625 /* Process crypto operation */
5626 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5627 ut_params->op), "failed to process sym crypto op");
5629 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5630 "crypto op processing failed");
5632 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5634 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5635 ut_params->op->sym->cipher.data.offset);
5636 auth_tag = ciphertext + plaintext_pad_len;
5638 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5639 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5642 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5644 tdata->ciphertext.data,
5645 tdata->ciphertext.len,
5646 "Ciphertext data not as expected");
5648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5650 tdata->auth_tag.data,
5651 tdata->auth_tag.len,
5652 "Generated auth tag not as expected");
5659 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5661 return test_authenticated_encryption_oop(&gcm_test_case_5);
5665 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5667 struct crypto_testsuite_params *ts_params = &testsuite_params;
5668 struct crypto_unittest_params *ut_params = &unittest_params;
5673 /* Create AEAD session */
5674 retval = create_aead_session(ts_params->valid_devs[0],
5676 RTE_CRYPTO_AEAD_OP_DECRYPT,
5677 tdata->key.data, tdata->key.len,
5678 tdata->aad.len, tdata->auth_tag.len,
5683 /* alloc mbuf and set payload */
5684 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5685 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5688 rte_pktmbuf_tailroom(ut_params->ibuf));
5689 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5690 rte_pktmbuf_tailroom(ut_params->obuf));
5692 /* Create AEAD operation */
5693 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5697 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5699 ut_params->op->sym->m_src = ut_params->ibuf;
5700 ut_params->op->sym->m_dst = ut_params->obuf;
5702 /* Process crypto operation */
5703 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5704 ut_params->op), "failed to process sym crypto op");
5706 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5707 "crypto op processing failed");
5709 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5710 ut_params->op->sym->cipher.data.offset);
5712 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5717 tdata->plaintext.data,
5718 tdata->plaintext.len,
5719 "Plaintext data not as expected");
5721 TEST_ASSERT_EQUAL(ut_params->op->status,
5722 RTE_CRYPTO_OP_STATUS_SUCCESS,
5723 "Authentication failed");
5728 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5730 return test_authenticated_decryption_oop(&gcm_test_case_5);
5734 test_authenticated_encryption_sessionless(
5735 const struct aead_test_data *tdata)
5737 struct crypto_testsuite_params *ts_params = &testsuite_params;
5738 struct crypto_unittest_params *ut_params = &unittest_params;
5741 uint8_t *ciphertext, *auth_tag;
5742 uint16_t plaintext_pad_len;
5743 uint8_t key[tdata->key.len + 1];
5745 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5747 /* clear mbuf payload */
5748 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5749 rte_pktmbuf_tailroom(ut_params->ibuf));
5751 /* Create AEAD operation */
5752 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5756 /* Create GCM xform */
5757 memcpy(key, tdata->key.data, tdata->key.len);
5758 retval = create_aead_xform(ut_params->op,
5760 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5761 key, tdata->key.len,
5762 tdata->aad.len, tdata->auth_tag.len,
5767 ut_params->op->sym->m_src = ut_params->ibuf;
5769 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5770 RTE_CRYPTO_OP_SESSIONLESS,
5771 "crypto op session type not sessionless");
5773 /* Process crypto operation */
5774 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5775 ut_params->op), "failed to process sym crypto op");
5777 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5779 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5780 "crypto op status not success");
5782 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5784 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5785 ut_params->op->sym->cipher.data.offset);
5786 auth_tag = ciphertext + plaintext_pad_len;
5788 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5789 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5792 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5794 tdata->ciphertext.data,
5795 tdata->ciphertext.len,
5796 "Ciphertext data not as expected");
5798 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5800 tdata->auth_tag.data,
5801 tdata->auth_tag.len,
5802 "Generated auth tag not as expected");
5809 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5811 return test_authenticated_encryption_sessionless(
5816 test_authenticated_decryption_sessionless(
5817 const struct aead_test_data *tdata)
5819 struct crypto_testsuite_params *ts_params = &testsuite_params;
5820 struct crypto_unittest_params *ut_params = &unittest_params;
5824 uint8_t key[tdata->key.len + 1];
5826 /* alloc mbuf and set payload */
5827 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5829 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5830 rte_pktmbuf_tailroom(ut_params->ibuf));
5832 /* Create AEAD operation */
5833 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5837 /* Create AEAD xform */
5838 memcpy(key, tdata->key.data, tdata->key.len);
5839 retval = create_aead_xform(ut_params->op,
5841 RTE_CRYPTO_AEAD_OP_DECRYPT,
5842 key, tdata->key.len,
5843 tdata->aad.len, tdata->auth_tag.len,
5848 ut_params->op->sym->m_src = ut_params->ibuf;
5850 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5851 RTE_CRYPTO_OP_SESSIONLESS,
5852 "crypto op session type not sessionless");
5854 /* Process crypto operation */
5855 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5856 ut_params->op), "failed to process sym crypto op");
5858 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5860 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5861 "crypto op status not success");
5863 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5864 ut_params->op->sym->cipher.data.offset);
5866 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5869 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5871 tdata->plaintext.data,
5872 tdata->plaintext.len,
5873 "Plaintext data not as expected");
5875 TEST_ASSERT_EQUAL(ut_params->op->status,
5876 RTE_CRYPTO_OP_STATUS_SUCCESS,
5877 "Authentication failed");
5882 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5884 return test_authenticated_decryption_sessionless(
5889 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
5891 return test_authenticated_encryption(&ccm_test_case_128_1);
5895 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
5897 return test_authenticated_encryption(&ccm_test_case_128_2);
5901 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
5903 return test_authenticated_encryption(&ccm_test_case_128_3);
5907 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
5909 return test_authenticated_decryption(&ccm_test_case_128_1);
5913 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
5915 return test_authenticated_decryption(&ccm_test_case_128_2);
5919 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
5921 return test_authenticated_decryption(&ccm_test_case_128_3);
5925 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
5927 return test_authenticated_encryption(&ccm_test_case_192_1);
5931 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
5933 return test_authenticated_encryption(&ccm_test_case_192_2);
5937 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
5939 return test_authenticated_encryption(&ccm_test_case_192_3);
5943 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
5945 return test_authenticated_decryption(&ccm_test_case_192_1);
5949 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
5951 return test_authenticated_decryption(&ccm_test_case_192_2);
5955 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
5957 return test_authenticated_decryption(&ccm_test_case_192_3);
5961 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
5963 return test_authenticated_encryption(&ccm_test_case_256_1);
5967 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
5969 return test_authenticated_encryption(&ccm_test_case_256_2);
5973 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
5975 return test_authenticated_encryption(&ccm_test_case_256_3);
5979 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
5981 return test_authenticated_decryption(&ccm_test_case_256_1);
5985 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
5987 return test_authenticated_decryption(&ccm_test_case_256_2);
5991 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
5993 return test_authenticated_decryption(&ccm_test_case_256_3);
5999 struct crypto_testsuite_params *ts_params = &testsuite_params;
6000 struct rte_cryptodev_stats stats;
6001 struct rte_cryptodev *dev;
6002 cryptodev_stats_get_t temp_pfn;
6004 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6005 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6006 &stats) == -ENODEV),
6007 "rte_cryptodev_stats_get invalid dev failed");
6008 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6009 "rte_cryptodev_stats_get invalid Param failed");
6010 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6011 temp_pfn = dev->dev_ops->stats_get;
6012 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6013 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6015 "rte_cryptodev_stats_get invalid Param failed");
6016 dev->dev_ops->stats_get = temp_pfn;
6018 /* Test expected values */
6020 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6022 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6024 "rte_cryptodev_stats_get failed");
6025 TEST_ASSERT((stats.enqueued_count == 1),
6026 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6027 TEST_ASSERT((stats.dequeued_count == 1),
6028 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6029 TEST_ASSERT((stats.enqueue_err_count == 0),
6030 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6031 TEST_ASSERT((stats.dequeue_err_count == 0),
6032 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6034 /* invalid device but should ignore and not reset device stats*/
6035 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6036 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6038 "rte_cryptodev_stats_get failed");
6039 TEST_ASSERT((stats.enqueued_count == 1),
6040 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6042 /* check that a valid reset clears stats */
6043 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6044 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6046 "rte_cryptodev_stats_get failed");
6047 TEST_ASSERT((stats.enqueued_count == 0),
6048 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6049 TEST_ASSERT((stats.dequeued_count == 0),
6050 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6052 return TEST_SUCCESS;
6055 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6056 struct crypto_unittest_params *ut_params,
6057 enum rte_crypto_auth_operation op,
6058 const struct HMAC_MD5_vector *test_case)
6062 memcpy(key, test_case->key.data, test_case->key.len);
6064 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6065 ut_params->auth_xform.next = NULL;
6066 ut_params->auth_xform.auth.op = op;
6068 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6070 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6071 ut_params->auth_xform.auth.key.length = test_case->key.len;
6072 ut_params->auth_xform.auth.key.data = key;
6074 ut_params->sess = rte_cryptodev_sym_session_create(
6075 ts_params->session_mpool);
6077 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6078 ut_params->sess, &ut_params->auth_xform,
6079 ts_params->session_mpool);
6081 if (ut_params->sess == NULL)
6084 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6086 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6087 rte_pktmbuf_tailroom(ut_params->ibuf));
6092 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6093 const struct HMAC_MD5_vector *test_case,
6094 uint8_t **plaintext)
6096 uint16_t plaintext_pad_len;
6098 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6100 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6103 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6105 memcpy(*plaintext, test_case->plaintext.data,
6106 test_case->plaintext.len);
6108 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6109 ut_params->ibuf, MD5_DIGEST_LEN);
6110 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6111 "no room to append digest");
6112 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6113 ut_params->ibuf, plaintext_pad_len);
6115 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6116 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6117 test_case->auth_tag.len);
6120 sym_op->auth.data.offset = 0;
6121 sym_op->auth.data.length = test_case->plaintext.len;
6123 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6124 ut_params->op->sym->m_src = ut_params->ibuf;
6130 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6132 uint16_t plaintext_pad_len;
6133 uint8_t *plaintext, *auth_tag;
6135 struct crypto_testsuite_params *ts_params = &testsuite_params;
6136 struct crypto_unittest_params *ut_params = &unittest_params;
6138 if (MD5_HMAC_create_session(ts_params, ut_params,
6139 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6142 /* Generate Crypto op data structure */
6143 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6144 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6145 TEST_ASSERT_NOT_NULL(ut_params->op,
6146 "Failed to allocate symmetric crypto operation struct");
6148 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6151 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6154 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6155 ut_params->op), "failed to process sym crypto op");
6157 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6158 "crypto op processing failed");
6160 if (ut_params->op->sym->m_dst) {
6161 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6162 uint8_t *, plaintext_pad_len);
6164 auth_tag = plaintext + plaintext_pad_len;
6167 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6169 test_case->auth_tag.data,
6170 test_case->auth_tag.len,
6171 "HMAC_MD5 generated tag not as expected");
6173 return TEST_SUCCESS;
6177 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6181 struct crypto_testsuite_params *ts_params = &testsuite_params;
6182 struct crypto_unittest_params *ut_params = &unittest_params;
6184 if (MD5_HMAC_create_session(ts_params, ut_params,
6185 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6189 /* Generate Crypto op data structure */
6190 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6191 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6192 TEST_ASSERT_NOT_NULL(ut_params->op,
6193 "Failed to allocate symmetric crypto operation struct");
6195 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6198 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6199 ut_params->op), "failed to process sym crypto op");
6201 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6202 "HMAC_MD5 crypto op processing failed");
6204 return TEST_SUCCESS;
6208 test_MD5_HMAC_generate_case_1(void)
6210 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6214 test_MD5_HMAC_verify_case_1(void)
6216 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6220 test_MD5_HMAC_generate_case_2(void)
6222 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6226 test_MD5_HMAC_verify_case_2(void)
6228 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6232 test_multi_session(void)
6234 struct crypto_testsuite_params *ts_params = &testsuite_params;
6235 struct crypto_unittest_params *ut_params = &unittest_params;
6237 struct rte_cryptodev_info dev_info;
6238 struct rte_cryptodev_sym_session **sessions;
6242 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6243 aes_cbc_key, hmac_sha512_key);
6246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6248 sessions = rte_malloc(NULL,
6249 (sizeof(struct rte_cryptodev_sym_session *) *
6250 dev_info.sym.max_nb_sessions) + 1, 0);
6252 /* Create multiple crypto sessions*/
6253 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6255 sessions[i] = rte_cryptodev_sym_session_create(
6256 ts_params->session_mpool);
6258 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6259 sessions[i], &ut_params->auth_xform,
6260 ts_params->session_mpool);
6261 TEST_ASSERT_NOT_NULL(sessions[i],
6262 "Session creation failed at session number %u",
6265 /* Attempt to send a request on each session */
6266 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6270 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6271 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6273 "Failed to perform decrypt on request number %u.", i);
6274 /* free crypto operation structure */
6276 rte_crypto_op_free(ut_params->op);
6279 * free mbuf - both obuf and ibuf are usually the same,
6280 * so check if they point at the same address is necessary,
6281 * to avoid freeing the mbuf twice.
6283 if (ut_params->obuf) {
6284 rte_pktmbuf_free(ut_params->obuf);
6285 if (ut_params->ibuf == ut_params->obuf)
6286 ut_params->ibuf = 0;
6287 ut_params->obuf = 0;
6289 if (ut_params->ibuf) {
6290 rte_pktmbuf_free(ut_params->ibuf);
6291 ut_params->ibuf = 0;
6295 /* Next session create should fail */
6296 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6297 sessions[i], &ut_params->auth_xform,
6298 ts_params->session_mpool);
6299 TEST_ASSERT_NULL(sessions[i],
6300 "Session creation succeeded unexpectedly!");
6302 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6303 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6305 rte_cryptodev_sym_session_free(sessions[i]);
6310 return TEST_SUCCESS;
6313 struct multi_session_params {
6314 struct crypto_unittest_params ut_params;
6315 uint8_t *cipher_key;
6317 const uint8_t *cipher;
6318 const uint8_t *digest;
6322 #define MB_SESSION_NUMBER 3
6325 test_multi_session_random_usage(void)
6327 struct crypto_testsuite_params *ts_params = &testsuite_params;
6328 struct rte_cryptodev_info dev_info;
6329 struct rte_cryptodev_sym_session **sessions;
6331 struct multi_session_params ut_paramz[] = {
6334 .cipher_key = ms_aes_cbc_key0,
6335 .hmac_key = ms_hmac_key0,
6336 .cipher = ms_aes_cbc_cipher0,
6337 .digest = ms_hmac_digest0,
6338 .iv = ms_aes_cbc_iv0
6341 .cipher_key = ms_aes_cbc_key1,
6342 .hmac_key = ms_hmac_key1,
6343 .cipher = ms_aes_cbc_cipher1,
6344 .digest = ms_hmac_digest1,
6345 .iv = ms_aes_cbc_iv1
6348 .cipher_key = ms_aes_cbc_key2,
6349 .hmac_key = ms_hmac_key2,
6350 .cipher = ms_aes_cbc_cipher2,
6351 .digest = ms_hmac_digest2,
6352 .iv = ms_aes_cbc_iv2
6357 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6359 sessions = rte_malloc(NULL,
6360 (sizeof(struct rte_cryptodev_sym_session *)
6361 * dev_info.sym.max_nb_sessions) + 1, 0);
6363 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6364 sessions[i] = rte_cryptodev_sym_session_create(
6365 ts_params->session_mpool);
6367 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6368 sizeof(struct crypto_unittest_params));
6370 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6371 &ut_paramz[i].ut_params,
6372 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6374 /* Create multiple crypto sessions*/
6375 rte_cryptodev_sym_session_init(
6376 ts_params->valid_devs[0],
6378 &ut_paramz[i].ut_params.auth_xform,
6379 ts_params->session_mpool);
6381 TEST_ASSERT_NOT_NULL(sessions[i],
6382 "Session creation failed at session number %u",
6388 for (i = 0; i < 40000; i++) {
6390 j = rand() % MB_SESSION_NUMBER;
6392 TEST_ASSERT_SUCCESS(
6393 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6395 &ut_paramz[j].ut_params,
6396 ts_params, ut_paramz[j].cipher,
6397 ut_paramz[j].digest,
6399 "Failed to perform decrypt on request number %u.", i);
6401 if (ut_paramz[j].ut_params.op)
6402 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6405 * free mbuf - both obuf and ibuf are usually the same,
6406 * so check if they point at the same address is necessary,
6407 * to avoid freeing the mbuf twice.
6409 if (ut_paramz[j].ut_params.obuf) {
6410 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6411 if (ut_paramz[j].ut_params.ibuf
6412 == ut_paramz[j].ut_params.obuf)
6413 ut_paramz[j].ut_params.ibuf = 0;
6414 ut_paramz[j].ut_params.obuf = 0;
6416 if (ut_paramz[j].ut_params.ibuf) {
6417 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6418 ut_paramz[j].ut_params.ibuf = 0;
6422 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6423 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6425 rte_cryptodev_sym_session_free(sessions[i]);
6430 return TEST_SUCCESS;
6434 test_null_cipher_only_operation(void)
6436 struct crypto_testsuite_params *ts_params = &testsuite_params;
6437 struct crypto_unittest_params *ut_params = &unittest_params;
6439 /* Generate test mbuf data and space for digest */
6440 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6441 catch_22_quote, QUOTE_512_BYTES, 0);
6443 /* Setup Cipher Parameters */
6444 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6445 ut_params->cipher_xform.next = NULL;
6447 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6448 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6450 ut_params->sess = rte_cryptodev_sym_session_create(
6451 ts_params->session_mpool);
6453 /* Create Crypto session*/
6454 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6456 &ut_params->cipher_xform,
6457 ts_params->session_mpool);
6458 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6460 /* Generate Crypto op data structure */
6461 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6462 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6463 TEST_ASSERT_NOT_NULL(ut_params->op,
6464 "Failed to allocate symmetric crypto operation struct");
6466 /* Set crypto operation data parameters */
6467 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6469 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6471 /* set crypto operation source mbuf */
6472 sym_op->m_src = ut_params->ibuf;
6474 sym_op->cipher.data.offset = 0;
6475 sym_op->cipher.data.length = QUOTE_512_BYTES;
6477 /* Process crypto operation */
6478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6480 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6482 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6483 "crypto operation processing failed");
6486 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6487 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6490 "Ciphertext data not as expected");
6492 return TEST_SUCCESS;
6496 test_null_auth_only_operation(void)
6498 struct crypto_testsuite_params *ts_params = &testsuite_params;
6499 struct crypto_unittest_params *ut_params = &unittest_params;
6501 /* Generate test mbuf data and space for digest */
6502 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6503 catch_22_quote, QUOTE_512_BYTES, 0);
6505 /* Setup HMAC Parameters */
6506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6507 ut_params->auth_xform.next = NULL;
6509 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6510 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6512 ut_params->sess = rte_cryptodev_sym_session_create(
6513 ts_params->session_mpool);
6515 /* Create Crypto session*/
6516 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6517 ut_params->sess, &ut_params->auth_xform,
6518 ts_params->session_mpool);
6519 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6521 /* Generate Crypto op data structure */
6522 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6523 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6524 TEST_ASSERT_NOT_NULL(ut_params->op,
6525 "Failed to allocate symmetric crypto operation struct");
6527 /* Set crypto operation data parameters */
6528 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6530 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6532 sym_op->m_src = ut_params->ibuf;
6534 sym_op->auth.data.offset = 0;
6535 sym_op->auth.data.length = QUOTE_512_BYTES;
6537 /* Process crypto operation */
6538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6540 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6542 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6543 "crypto operation processing failed");
6545 return TEST_SUCCESS;
6549 test_null_cipher_auth_operation(void)
6551 struct crypto_testsuite_params *ts_params = &testsuite_params;
6552 struct crypto_unittest_params *ut_params = &unittest_params;
6554 /* Generate test mbuf data and space for digest */
6555 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6556 catch_22_quote, QUOTE_512_BYTES, 0);
6558 /* Setup Cipher Parameters */
6559 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6560 ut_params->cipher_xform.next = &ut_params->auth_xform;
6562 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6563 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6565 /* Setup HMAC Parameters */
6566 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6567 ut_params->auth_xform.next = NULL;
6569 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6570 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6572 ut_params->sess = rte_cryptodev_sym_session_create(
6573 ts_params->session_mpool);
6575 /* Create Crypto session*/
6576 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6577 ut_params->sess, &ut_params->cipher_xform,
6578 ts_params->session_mpool);
6579 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6581 /* Generate Crypto op data structure */
6582 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6583 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6584 TEST_ASSERT_NOT_NULL(ut_params->op,
6585 "Failed to allocate symmetric crypto operation struct");
6587 /* Set crypto operation data parameters */
6588 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6590 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6592 sym_op->m_src = ut_params->ibuf;
6594 sym_op->cipher.data.offset = 0;
6595 sym_op->cipher.data.length = QUOTE_512_BYTES;
6597 sym_op->auth.data.offset = 0;
6598 sym_op->auth.data.length = QUOTE_512_BYTES;
6600 /* Process crypto operation */
6601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6603 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6605 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6606 "crypto operation processing failed");
6609 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6610 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6613 "Ciphertext data not as expected");
6615 return TEST_SUCCESS;
6619 test_null_auth_cipher_operation(void)
6621 struct crypto_testsuite_params *ts_params = &testsuite_params;
6622 struct crypto_unittest_params *ut_params = &unittest_params;
6624 /* Generate test mbuf data and space for digest */
6625 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6626 catch_22_quote, QUOTE_512_BYTES, 0);
6628 /* Setup Cipher Parameters */
6629 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6630 ut_params->cipher_xform.next = NULL;
6632 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6633 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6635 /* Setup HMAC Parameters */
6636 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6637 ut_params->auth_xform.next = &ut_params->cipher_xform;
6639 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6640 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6642 ut_params->sess = rte_cryptodev_sym_session_create(
6643 ts_params->session_mpool);
6645 /* Create Crypto session*/
6646 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6647 ut_params->sess, &ut_params->cipher_xform,
6648 ts_params->session_mpool);
6649 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6651 /* Generate Crypto op data structure */
6652 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6653 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6654 TEST_ASSERT_NOT_NULL(ut_params->op,
6655 "Failed to allocate symmetric crypto operation struct");
6657 /* Set crypto operation data parameters */
6658 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6660 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6662 sym_op->m_src = ut_params->ibuf;
6664 sym_op->cipher.data.offset = 0;
6665 sym_op->cipher.data.length = QUOTE_512_BYTES;
6667 sym_op->auth.data.offset = 0;
6668 sym_op->auth.data.length = QUOTE_512_BYTES;
6670 /* Process crypto operation */
6671 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6673 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6675 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6676 "crypto operation processing failed");
6679 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6680 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6683 "Ciphertext data not as expected");
6685 return TEST_SUCCESS;
6690 test_null_invalid_operation(void)
6692 struct crypto_testsuite_params *ts_params = &testsuite_params;
6693 struct crypto_unittest_params *ut_params = &unittest_params;
6696 /* Setup Cipher Parameters */
6697 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6698 ut_params->cipher_xform.next = NULL;
6700 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6701 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6703 ut_params->sess = rte_cryptodev_sym_session_create(
6704 ts_params->session_mpool);
6706 /* Create Crypto session*/
6707 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6708 ut_params->sess, &ut_params->cipher_xform,
6709 ts_params->session_mpool);
6710 TEST_ASSERT(ret < 0,
6711 "Session creation succeeded unexpectedly");
6714 /* Setup HMAC Parameters */
6715 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6716 ut_params->auth_xform.next = NULL;
6718 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6719 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6721 ut_params->sess = rte_cryptodev_sym_session_create(
6722 ts_params->session_mpool);
6724 /* Create Crypto session*/
6725 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6726 ut_params->sess, &ut_params->auth_xform,
6727 ts_params->session_mpool);
6728 TEST_ASSERT(ret < 0,
6729 "Session creation succeeded unexpectedly");
6731 return TEST_SUCCESS;
6735 #define NULL_BURST_LENGTH (32)
6738 test_null_burst_operation(void)
6740 struct crypto_testsuite_params *ts_params = &testsuite_params;
6741 struct crypto_unittest_params *ut_params = &unittest_params;
6743 unsigned i, burst_len = NULL_BURST_LENGTH;
6745 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6746 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6748 /* Setup Cipher Parameters */
6749 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6750 ut_params->cipher_xform.next = &ut_params->auth_xform;
6752 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6753 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6755 /* Setup HMAC Parameters */
6756 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6757 ut_params->auth_xform.next = NULL;
6759 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6760 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6762 ut_params->sess = rte_cryptodev_sym_session_create(
6763 ts_params->session_mpool);
6765 /* Create Crypto session*/
6766 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6767 ut_params->sess, &ut_params->cipher_xform,
6768 ts_params->session_mpool);
6769 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6771 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6772 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6773 burst_len, "failed to generate burst of crypto ops");
6775 /* Generate an operation for each mbuf in burst */
6776 for (i = 0; i < burst_len; i++) {
6777 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6779 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6781 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6785 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6787 burst[i]->sym->m_src = m;
6790 /* Process crypto operation */
6791 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6792 0, burst, burst_len),
6794 "Error enqueuing burst");
6796 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6797 0, burst_dequeued, burst_len),
6799 "Error dequeuing burst");
6802 for (i = 0; i < burst_len; i++) {
6804 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6805 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6807 "data not as expected");
6809 rte_pktmbuf_free(burst[i]->sym->m_src);
6810 rte_crypto_op_free(burst[i]);
6813 return TEST_SUCCESS;
6817 generate_gmac_large_plaintext(uint8_t *data)
6821 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6822 memcpy(&data[i], &data[0], 32);
6826 create_gmac_operation(enum rte_crypto_auth_operation op,
6827 const struct gmac_test_data *tdata)
6829 struct crypto_testsuite_params *ts_params = &testsuite_params;
6830 struct crypto_unittest_params *ut_params = &unittest_params;
6831 struct rte_crypto_sym_op *sym_op;
6833 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6835 /* Generate Crypto op data structure */
6836 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6837 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6838 TEST_ASSERT_NOT_NULL(ut_params->op,
6839 "Failed to allocate symmetric crypto operation struct");
6841 sym_op = ut_params->op->sym;
6843 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6844 ut_params->ibuf, tdata->gmac_tag.len);
6845 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6846 "no room to append digest");
6848 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6849 ut_params->ibuf, plaintext_pad_len);
6851 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6852 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6853 tdata->gmac_tag.len);
6854 TEST_HEXDUMP(stdout, "digest:",
6855 sym_op->auth.digest.data,
6856 tdata->gmac_tag.len);
6859 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6860 uint8_t *, IV_OFFSET);
6862 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6864 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6866 sym_op->cipher.data.length = 0;
6867 sym_op->cipher.data.offset = 0;
6869 sym_op->auth.data.offset = 0;
6870 sym_op->auth.data.length = tdata->plaintext.len;
6875 static int create_gmac_session(uint8_t dev_id,
6876 const struct gmac_test_data *tdata,
6877 enum rte_crypto_auth_operation auth_op)
6879 uint8_t auth_key[tdata->key.len];
6881 struct crypto_testsuite_params *ts_params = &testsuite_params;
6882 struct crypto_unittest_params *ut_params = &unittest_params;
6884 memcpy(auth_key, tdata->key.data, tdata->key.len);
6886 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6887 ut_params->auth_xform.next = NULL;
6889 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6890 ut_params->auth_xform.auth.op = auth_op;
6891 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6892 ut_params->auth_xform.auth.key.length = tdata->key.len;
6893 ut_params->auth_xform.auth.key.data = auth_key;
6894 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6895 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6898 ut_params->sess = rte_cryptodev_sym_session_create(
6899 ts_params->session_mpool);
6901 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6902 &ut_params->auth_xform,
6903 ts_params->session_mpool);
6905 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6911 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6913 struct crypto_testsuite_params *ts_params = &testsuite_params;
6914 struct crypto_unittest_params *ut_params = &unittest_params;
6918 uint8_t *auth_tag, *plaintext;
6919 uint16_t plaintext_pad_len;
6921 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6922 "No GMAC length in the source data");
6924 retval = create_gmac_session(ts_params->valid_devs[0],
6925 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6930 if (tdata->plaintext.len > MBUF_SIZE)
6931 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6933 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6934 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6935 "Failed to allocate input buffer in mempool");
6937 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6938 rte_pktmbuf_tailroom(ut_params->ibuf));
6940 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6942 * Runtime generate the large plain text instead of use hard code
6943 * plain text vector. It is done to avoid create huge source file
6944 * with the test vector.
6946 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6947 generate_gmac_large_plaintext(tdata->plaintext.data);
6949 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6951 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6953 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6954 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6955 tdata->plaintext.len);
6957 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6963 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6965 ut_params->op->sym->m_src = ut_params->ibuf;
6967 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6968 ut_params->op), "failed to process sym crypto op");
6970 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6971 "crypto op processing failed");
6973 if (ut_params->op->sym->m_dst) {
6974 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6975 uint8_t *, plaintext_pad_len);
6977 auth_tag = plaintext + plaintext_pad_len;
6980 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6982 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6984 tdata->gmac_tag.data,
6985 tdata->gmac_tag.len,
6986 "GMAC Generated auth tag not as expected");
6992 test_AES_GMAC_authentication_test_case_1(void)
6994 return test_AES_GMAC_authentication(&gmac_test_case_1);
6998 test_AES_GMAC_authentication_test_case_2(void)
7000 return test_AES_GMAC_authentication(&gmac_test_case_2);
7004 test_AES_GMAC_authentication_test_case_3(void)
7006 return test_AES_GMAC_authentication(&gmac_test_case_3);
7010 test_AES_GMAC_authentication_test_case_4(void)
7012 return test_AES_GMAC_authentication(&gmac_test_case_4);
7016 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7018 struct crypto_testsuite_params *ts_params = &testsuite_params;
7019 struct crypto_unittest_params *ut_params = &unittest_params;
7021 uint32_t plaintext_pad_len;
7024 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7025 "No GMAC length in the source data");
7027 retval = create_gmac_session(ts_params->valid_devs[0],
7028 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7033 if (tdata->plaintext.len > MBUF_SIZE)
7034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7037 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7038 "Failed to allocate input buffer in mempool");
7040 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7041 rte_pktmbuf_tailroom(ut_params->ibuf));
7043 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7046 * Runtime generate the large plain text instead of use hard code
7047 * plain text vector. It is done to avoid create huge source file
7048 * with the test vector.
7050 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7051 generate_gmac_large_plaintext(tdata->plaintext.data);
7053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7055 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7057 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7058 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7059 tdata->plaintext.len);
7061 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7067 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7069 ut_params->op->sym->m_src = ut_params->ibuf;
7071 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7072 ut_params->op), "failed to process sym crypto op");
7074 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7075 "crypto op processing failed");
7082 test_AES_GMAC_authentication_verify_test_case_1(void)
7084 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7088 test_AES_GMAC_authentication_verify_test_case_2(void)
7090 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7094 test_AES_GMAC_authentication_verify_test_case_3(void)
7096 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7100 test_AES_GMAC_authentication_verify_test_case_4(void)
7102 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7105 struct test_crypto_vector {
7106 enum rte_crypto_cipher_algorithm crypto_algo;
7119 const uint8_t *data;
7124 const uint8_t *data;
7128 enum rte_crypto_auth_algorithm auth_algo;
7136 const uint8_t *data;
7146 static const struct test_crypto_vector
7147 hmac_sha1_test_crypto_vector = {
7148 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7150 .data = plaintext_hash,
7155 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7156 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7157 0xDE, 0xF4, 0xDE, 0xAD
7163 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7164 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7165 0x3F, 0x91, 0x64, 0x59
7171 static const struct test_crypto_vector
7172 aes128_gmac_test_vector = {
7173 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7175 .data = plaintext_hash,
7180 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7181 0x08, 0x09, 0x0A, 0x0B
7187 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7188 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7194 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7195 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7201 static const struct test_crypto_vector
7202 aes128cbc_hmac_sha1_test_vector = {
7203 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7206 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7207 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7213 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7214 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7219 .data = plaintext_hash,
7223 .data = ciphertext512_aes128cbc,
7226 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7229 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7230 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7231 0xDE, 0xF4, 0xDE, 0xAD
7237 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7238 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7239 0x18, 0x8C, 0x1D, 0x32
7246 data_corruption(uint8_t *data)
7252 tag_corruption(uint8_t *data, unsigned int tag_offset)
7254 data[tag_offset] += 1;
7258 create_auth_session(struct crypto_unittest_params *ut_params,
7260 const struct test_crypto_vector *reference,
7261 enum rte_crypto_auth_operation auth_op)
7263 struct crypto_testsuite_params *ts_params = &testsuite_params;
7264 uint8_t auth_key[reference->auth_key.len + 1];
7266 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7268 /* Setup Authentication Parameters */
7269 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7270 ut_params->auth_xform.auth.op = auth_op;
7271 ut_params->auth_xform.next = NULL;
7272 ut_params->auth_xform.auth.algo = reference->auth_algo;
7273 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7274 ut_params->auth_xform.auth.key.data = auth_key;
7275 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7277 /* Create Crypto session*/
7278 ut_params->sess = rte_cryptodev_sym_session_create(
7279 ts_params->session_mpool);
7281 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7282 &ut_params->auth_xform,
7283 ts_params->session_mpool);
7285 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7291 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7293 const struct test_crypto_vector *reference,
7294 enum rte_crypto_auth_operation auth_op,
7295 enum rte_crypto_cipher_operation cipher_op)
7297 struct crypto_testsuite_params *ts_params = &testsuite_params;
7298 uint8_t cipher_key[reference->cipher_key.len + 1];
7299 uint8_t auth_key[reference->auth_key.len + 1];
7301 memcpy(cipher_key, reference->cipher_key.data,
7302 reference->cipher_key.len);
7303 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7305 /* Setup Authentication Parameters */
7306 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7307 ut_params->auth_xform.auth.op = auth_op;
7308 ut_params->auth_xform.auth.algo = reference->auth_algo;
7309 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7310 ut_params->auth_xform.auth.key.data = auth_key;
7311 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7313 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7314 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7315 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7317 ut_params->auth_xform.next = &ut_params->cipher_xform;
7319 /* Setup Cipher Parameters */
7320 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7321 ut_params->cipher_xform.next = NULL;
7322 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7323 ut_params->cipher_xform.cipher.op = cipher_op;
7324 ut_params->cipher_xform.cipher.key.data = cipher_key;
7325 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7326 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7327 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7330 /* Create Crypto session*/
7331 ut_params->sess = rte_cryptodev_sym_session_create(
7332 ts_params->session_mpool);
7334 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7335 &ut_params->auth_xform,
7336 ts_params->session_mpool);
7338 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7344 create_auth_operation(struct crypto_testsuite_params *ts_params,
7345 struct crypto_unittest_params *ut_params,
7346 const struct test_crypto_vector *reference,
7347 unsigned int auth_generate)
7349 /* Generate Crypto op data structure */
7350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7352 TEST_ASSERT_NOT_NULL(ut_params->op,
7353 "Failed to allocate pktmbuf offload");
7355 /* Set crypto operation data parameters */
7356 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7360 /* set crypto operation source mbuf */
7361 sym_op->m_src = ut_params->ibuf;
7364 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7365 ut_params->ibuf, reference->digest.len);
7367 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7368 "no room to append auth tag");
7370 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7371 ut_params->ibuf, reference->plaintext.len);
7374 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7376 memcpy(sym_op->auth.digest.data,
7377 reference->digest.data,
7378 reference->digest.len);
7380 TEST_HEXDUMP(stdout, "digest:",
7381 sym_op->auth.digest.data,
7382 reference->digest.len);
7384 sym_op->auth.data.length = reference->plaintext.len;
7385 sym_op->auth.data.offset = 0;
7391 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7392 struct crypto_unittest_params *ut_params,
7393 const struct test_crypto_vector *reference,
7394 unsigned int auth_generate)
7396 /* Generate Crypto op data structure */
7397 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7398 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7399 TEST_ASSERT_NOT_NULL(ut_params->op,
7400 "Failed to allocate pktmbuf offload");
7402 /* Set crypto operation data parameters */
7403 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7405 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7407 /* set crypto operation source mbuf */
7408 sym_op->m_src = ut_params->ibuf;
7411 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7412 ut_params->ibuf, reference->digest.len);
7414 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7415 "no room to append auth tag");
7417 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7418 ut_params->ibuf, reference->ciphertext.len);
7421 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7423 memcpy(sym_op->auth.digest.data,
7424 reference->digest.data,
7425 reference->digest.len);
7427 TEST_HEXDUMP(stdout, "digest:",
7428 sym_op->auth.digest.data,
7429 reference->digest.len);
7431 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7432 reference->iv.data, reference->iv.len);
7434 sym_op->cipher.data.length = 0;
7435 sym_op->cipher.data.offset = 0;
7437 sym_op->auth.data.length = reference->plaintext.len;
7438 sym_op->auth.data.offset = 0;
7444 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7445 struct crypto_unittest_params *ut_params,
7446 const struct test_crypto_vector *reference,
7447 unsigned int auth_generate)
7449 /* Generate Crypto op data structure */
7450 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7451 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7452 TEST_ASSERT_NOT_NULL(ut_params->op,
7453 "Failed to allocate pktmbuf offload");
7455 /* Set crypto operation data parameters */
7456 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7458 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7460 /* set crypto operation source mbuf */
7461 sym_op->m_src = ut_params->ibuf;
7464 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7465 ut_params->ibuf, reference->digest.len);
7467 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7468 "no room to append auth tag");
7470 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7471 ut_params->ibuf, reference->ciphertext.len);
7474 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7476 memcpy(sym_op->auth.digest.data,
7477 reference->digest.data,
7478 reference->digest.len);
7480 TEST_HEXDUMP(stdout, "digest:",
7481 sym_op->auth.digest.data,
7482 reference->digest.len);
7484 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7485 reference->iv.data, reference->iv.len);
7487 sym_op->cipher.data.length = reference->ciphertext.len;
7488 sym_op->cipher.data.offset = 0;
7490 sym_op->auth.data.length = reference->ciphertext.len;
7491 sym_op->auth.data.offset = 0;
7497 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7498 struct crypto_unittest_params *ut_params,
7499 const struct test_crypto_vector *reference)
7501 return create_auth_operation(ts_params, ut_params, reference, 0);
7505 create_auth_verify_GMAC_operation(
7506 struct crypto_testsuite_params *ts_params,
7507 struct crypto_unittest_params *ut_params,
7508 const struct test_crypto_vector *reference)
7510 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7514 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7515 struct crypto_unittest_params *ut_params,
7516 const struct test_crypto_vector *reference)
7518 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7522 test_authentication_verify_fail_when_data_corruption(
7523 struct crypto_testsuite_params *ts_params,
7524 struct crypto_unittest_params *ut_params,
7525 const struct test_crypto_vector *reference,
7526 unsigned int data_corrupted)
7532 /* Create session */
7533 retval = create_auth_session(ut_params,
7534 ts_params->valid_devs[0],
7536 RTE_CRYPTO_AUTH_OP_VERIFY);
7540 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7541 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7542 "Failed to allocate input buffer in mempool");
7544 /* clear mbuf payload */
7545 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7546 rte_pktmbuf_tailroom(ut_params->ibuf));
7548 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7549 reference->plaintext.len);
7550 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7551 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7553 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7555 /* Create operation */
7556 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7562 data_corruption(plaintext);
7564 tag_corruption(plaintext, reference->plaintext.len);
7566 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7569 TEST_ASSERT_EQUAL(ut_params->op->status,
7570 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7571 "authentication not failed");
7573 ut_params->obuf = ut_params->op->sym->m_src;
7574 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7580 test_authentication_verify_GMAC_fail_when_corruption(
7581 struct crypto_testsuite_params *ts_params,
7582 struct crypto_unittest_params *ut_params,
7583 const struct test_crypto_vector *reference,
7584 unsigned int data_corrupted)
7589 /* Create session */
7590 retval = create_auth_cipher_session(ut_params,
7591 ts_params->valid_devs[0],
7593 RTE_CRYPTO_AUTH_OP_VERIFY,
7594 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7598 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7599 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7600 "Failed to allocate input buffer in mempool");
7602 /* clear mbuf payload */
7603 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7604 rte_pktmbuf_tailroom(ut_params->ibuf));
7606 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7607 reference->plaintext.len);
7608 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7609 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7611 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7613 /* Create operation */
7614 retval = create_auth_verify_GMAC_operation(ts_params,
7622 data_corruption(plaintext);
7624 tag_corruption(plaintext, reference->aad.len);
7626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7629 TEST_ASSERT_EQUAL(ut_params->op->status,
7630 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7631 "authentication not failed");
7633 ut_params->obuf = ut_params->op->sym->m_src;
7634 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7640 test_authenticated_decryption_fail_when_corruption(
7641 struct crypto_testsuite_params *ts_params,
7642 struct crypto_unittest_params *ut_params,
7643 const struct test_crypto_vector *reference,
7644 unsigned int data_corrupted)
7648 uint8_t *ciphertext;
7650 /* Create session */
7651 retval = create_auth_cipher_session(ut_params,
7652 ts_params->valid_devs[0],
7654 RTE_CRYPTO_AUTH_OP_VERIFY,
7655 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7659 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7660 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7661 "Failed to allocate input buffer in mempool");
7663 /* clear mbuf payload */
7664 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7665 rte_pktmbuf_tailroom(ut_params->ibuf));
7667 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7668 reference->ciphertext.len);
7669 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7670 memcpy(ciphertext, reference->ciphertext.data,
7671 reference->ciphertext.len);
7673 /* Create operation */
7674 retval = create_cipher_auth_verify_operation(ts_params,
7682 data_corruption(ciphertext);
7684 tag_corruption(ciphertext, reference->ciphertext.len);
7686 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7689 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7690 TEST_ASSERT_EQUAL(ut_params->op->status,
7691 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7692 "authentication not failed");
7694 ut_params->obuf = ut_params->op->sym->m_src;
7695 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7701 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7702 const struct aead_test_data *tdata,
7703 void *digest_mem, uint64_t digest_phys)
7705 struct crypto_testsuite_params *ts_params = &testsuite_params;
7706 struct crypto_unittest_params *ut_params = &unittest_params;
7708 const unsigned int auth_tag_len = tdata->auth_tag.len;
7709 const unsigned int iv_len = tdata->iv.len;
7710 unsigned int aad_len = tdata->aad.len;
7712 /* Generate Crypto op data structure */
7713 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7714 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7715 TEST_ASSERT_NOT_NULL(ut_params->op,
7716 "Failed to allocate symmetric crypto operation struct");
7718 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7720 sym_op->aead.digest.data = digest_mem;
7722 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7723 "no room to append digest");
7725 sym_op->aead.digest.phys_addr = digest_phys;
7727 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7728 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7730 TEST_HEXDUMP(stdout, "digest:",
7731 sym_op->aead.digest.data,
7735 /* Append aad data */
7736 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7737 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7738 uint8_t *, IV_OFFSET);
7740 /* Copy IV 1 byte after the IV pointer, according to the API */
7741 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7743 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7745 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7746 ut_params->ibuf, aad_len);
7747 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7748 "no room to prepend aad");
7749 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7752 memset(sym_op->aead.aad.data, 0, aad_len);
7753 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7754 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7756 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7757 TEST_HEXDUMP(stdout, "aad:",
7758 sym_op->aead.aad.data, aad_len);
7760 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7761 uint8_t *, IV_OFFSET);
7763 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7765 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7766 ut_params->ibuf, aad_len);
7767 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7768 "no room to prepend aad");
7769 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7772 memset(sym_op->aead.aad.data, 0, aad_len);
7773 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7775 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7776 TEST_HEXDUMP(stdout, "aad:",
7777 sym_op->aead.aad.data, aad_len);
7780 sym_op->aead.data.length = tdata->plaintext.len;
7781 sym_op->aead.data.offset = aad_len;
7786 #define SGL_MAX_NO 16
7789 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7790 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7792 struct crypto_testsuite_params *ts_params = &testsuite_params;
7793 struct crypto_unittest_params *ut_params = &unittest_params;
7794 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7797 int to_trn_tbl[SGL_MAX_NO];
7799 unsigned int trn_data = 0;
7800 uint8_t *plaintext, *ciphertext, *auth_tag;
7802 if (fragsz > tdata->plaintext.len)
7803 fragsz = tdata->plaintext.len;
7805 uint16_t plaintext_len = fragsz;
7806 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7808 if (fragsz_oop > tdata->plaintext.len)
7809 frag_size_oop = tdata->plaintext.len;
7812 void *digest_mem = NULL;
7814 uint32_t prepend_len = tdata->aad.len;
7816 if (tdata->plaintext.len % fragsz != 0) {
7817 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7820 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7825 * For out-op-place we need to alloc another mbuf
7828 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7829 rte_pktmbuf_append(ut_params->obuf,
7830 frag_size_oop + prepend_len);
7831 buf_oop = ut_params->obuf;
7834 /* Create AEAD session */
7835 retval = create_aead_session(ts_params->valid_devs[0],
7837 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7838 tdata->key.data, tdata->key.len,
7839 tdata->aad.len, tdata->auth_tag.len,
7844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7846 /* clear mbuf payload */
7847 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7848 rte_pktmbuf_tailroom(ut_params->ibuf));
7850 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7853 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7855 trn_data += plaintext_len;
7857 buf = ut_params->ibuf;
7860 * Loop until no more fragments
7863 while (trn_data < tdata->plaintext.len) {
7865 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7866 (tdata->plaintext.len - trn_data) : fragsz;
7868 to_trn_tbl[ecx++] = to_trn;
7870 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7873 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7874 rte_pktmbuf_tailroom(buf));
7877 if (oop && !fragsz_oop) {
7878 buf_last_oop = buf_oop->next =
7879 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7880 buf_oop = buf_oop->next;
7881 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7882 0, rte_pktmbuf_tailroom(buf_oop));
7883 rte_pktmbuf_append(buf_oop, to_trn);
7886 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7889 memcpy(plaintext, tdata->plaintext.data + trn_data,
7892 if (trn_data == tdata->plaintext.len) {
7895 digest_mem = rte_pktmbuf_append(buf_oop,
7896 tdata->auth_tag.len);
7898 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7899 tdata->auth_tag.len);
7903 uint64_t digest_phys = 0;
7905 ut_params->ibuf->nb_segs = segs;
7908 if (fragsz_oop && oop) {
7912 if (frag_size_oop == tdata->plaintext.len) {
7913 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7914 tdata->auth_tag.len);
7916 digest_phys = rte_pktmbuf_mtophys_offset(
7918 tdata->plaintext.len + prepend_len);
7921 trn_data = frag_size_oop;
7922 while (trn_data < tdata->plaintext.len) {
7925 (tdata->plaintext.len - trn_data <
7927 (tdata->plaintext.len - trn_data) :
7930 to_trn_tbl[ecx++] = to_trn;
7932 buf_last_oop = buf_oop->next =
7933 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7934 buf_oop = buf_oop->next;
7935 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7936 0, rte_pktmbuf_tailroom(buf_oop));
7937 rte_pktmbuf_append(buf_oop, to_trn);
7941 if (trn_data == tdata->plaintext.len) {
7942 digest_mem = rte_pktmbuf_append(buf_oop,
7943 tdata->auth_tag.len);
7947 ut_params->obuf->nb_segs = segs;
7951 * Place digest at the end of the last buffer
7954 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7955 if (oop && buf_last_oop)
7956 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7958 if (!digest_mem && !oop) {
7959 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7960 + tdata->auth_tag.len);
7961 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7962 tdata->plaintext.len);
7965 /* Create AEAD operation */
7966 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7967 tdata, digest_mem, digest_phys);
7972 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7974 ut_params->op->sym->m_src = ut_params->ibuf;
7976 ut_params->op->sym->m_dst = ut_params->obuf;
7978 /* Process crypto operation */
7979 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7980 ut_params->op), "failed to process sym crypto op");
7982 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7983 "crypto op processing failed");
7986 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7987 uint8_t *, prepend_len);
7989 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7990 uint8_t *, prepend_len);
7994 fragsz = fragsz_oop;
7996 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7998 tdata->ciphertext.data,
8000 "Ciphertext data not as expected");
8002 buf = ut_params->op->sym->m_src->next;
8004 buf = ut_params->op->sym->m_dst->next;
8006 unsigned int off = fragsz;
8010 ciphertext = rte_pktmbuf_mtod(buf,
8013 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8015 tdata->ciphertext.data + off,
8017 "Ciphertext data not as expected");
8019 off += to_trn_tbl[ecx++];
8023 auth_tag = digest_mem;
8024 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8026 tdata->auth_tag.data,
8027 tdata->auth_tag.len,
8028 "Generated auth tag not as expected");
8034 #define OUT_OF_PLACE 1
8037 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8039 return test_authenticated_encryption_SGL(
8040 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8044 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8046 return test_authenticated_encryption_SGL(
8047 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8051 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8053 return test_authenticated_encryption_SGL(
8054 &gcm_test_case_8, OUT_OF_PLACE, 400,
8055 gcm_test_case_8.plaintext.len);
8059 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8062 return test_authenticated_encryption_SGL(
8063 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8067 test_authentication_verify_fail_when_data_corrupted(
8068 struct crypto_testsuite_params *ts_params,
8069 struct crypto_unittest_params *ut_params,
8070 const struct test_crypto_vector *reference)
8072 return test_authentication_verify_fail_when_data_corruption(
8073 ts_params, ut_params, reference, 1);
8077 test_authentication_verify_fail_when_tag_corrupted(
8078 struct crypto_testsuite_params *ts_params,
8079 struct crypto_unittest_params *ut_params,
8080 const struct test_crypto_vector *reference)
8082 return test_authentication_verify_fail_when_data_corruption(
8083 ts_params, ut_params, reference, 0);
8087 test_authentication_verify_GMAC_fail_when_data_corrupted(
8088 struct crypto_testsuite_params *ts_params,
8089 struct crypto_unittest_params *ut_params,
8090 const struct test_crypto_vector *reference)
8092 return test_authentication_verify_GMAC_fail_when_corruption(
8093 ts_params, ut_params, reference, 1);
8097 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8098 struct crypto_testsuite_params *ts_params,
8099 struct crypto_unittest_params *ut_params,
8100 const struct test_crypto_vector *reference)
8102 return test_authentication_verify_GMAC_fail_when_corruption(
8103 ts_params, ut_params, reference, 0);
8107 test_authenticated_decryption_fail_when_data_corrupted(
8108 struct crypto_testsuite_params *ts_params,
8109 struct crypto_unittest_params *ut_params,
8110 const struct test_crypto_vector *reference)
8112 return test_authenticated_decryption_fail_when_corruption(
8113 ts_params, ut_params, reference, 1);
8117 test_authenticated_decryption_fail_when_tag_corrupted(
8118 struct crypto_testsuite_params *ts_params,
8119 struct crypto_unittest_params *ut_params,
8120 const struct test_crypto_vector *reference)
8122 return test_authenticated_decryption_fail_when_corruption(
8123 ts_params, ut_params, reference, 0);
8127 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8129 return test_authentication_verify_fail_when_data_corrupted(
8130 &testsuite_params, &unittest_params,
8131 &hmac_sha1_test_crypto_vector);
8135 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8137 return test_authentication_verify_fail_when_tag_corrupted(
8138 &testsuite_params, &unittest_params,
8139 &hmac_sha1_test_crypto_vector);
8143 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8145 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8146 &testsuite_params, &unittest_params,
8147 &aes128_gmac_test_vector);
8151 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8153 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8154 &testsuite_params, &unittest_params,
8155 &aes128_gmac_test_vector);
8159 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8161 return test_authenticated_decryption_fail_when_data_corrupted(
8164 &aes128cbc_hmac_sha1_test_vector);
8168 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8170 return test_authenticated_decryption_fail_when_tag_corrupted(
8173 &aes128cbc_hmac_sha1_test_vector);
8176 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8178 /* global AESNI slave IDs for the scheduler test */
8179 uint8_t aesni_ids[2];
8182 test_scheduler_attach_slave_op(void)
8184 struct crypto_testsuite_params *ts_params = &testsuite_params;
8185 uint8_t sched_id = ts_params->valid_devs[0];
8186 uint32_t nb_devs, i, nb_devs_attached = 0;
8190 /* create 2 AESNI_MB if necessary */
8191 nb_devs = rte_cryptodev_device_count_by_driver(
8192 rte_cryptodev_driver_id_get(
8193 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8195 for (i = nb_devs; i < 2; i++) {
8196 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8197 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8199 ret = rte_vdev_init(vdev_name, NULL);
8201 TEST_ASSERT(ret == 0,
8202 "Failed to create instance %u of"
8204 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8208 /* attach 2 AESNI_MB cdevs */
8209 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8211 struct rte_cryptodev_info info;
8213 rte_cryptodev_info_get(i, &info);
8214 if (info.driver_id != rte_cryptodev_driver_id_get(
8215 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8219 * Create the session mempool again, since now there are new devices
8220 * to use the mempool.
8222 if (ts_params->session_mpool) {
8223 rte_mempool_free(ts_params->session_mpool);
8224 ts_params->session_mpool = NULL;
8226 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8229 * Create mempool with maximum number of sessions * 2,
8230 * to include the session headers
8232 if (ts_params->session_mpool == NULL) {
8233 ts_params->session_mpool = rte_mempool_create(
8235 info.sym.max_nb_sessions * 2,
8237 0, 0, NULL, NULL, NULL,
8238 NULL, SOCKET_ID_ANY,
8241 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8242 "session mempool allocation failed");
8245 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8248 TEST_ASSERT(ret == 0,
8249 "Failed to attach device %u of pmd : %s", i,
8250 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8252 aesni_ids[nb_devs_attached] = (uint8_t)i;
8261 test_scheduler_detach_slave_op(void)
8263 struct crypto_testsuite_params *ts_params = &testsuite_params;
8264 uint8_t sched_id = ts_params->valid_devs[0];
8268 for (i = 0; i < 2; i++) {
8269 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8271 TEST_ASSERT(ret == 0,
8272 "Failed to detach device %u", aesni_ids[i]);
8279 test_scheduler_mode_op(void)
8281 struct crypto_testsuite_params *ts_params = &testsuite_params;
8282 uint8_t sched_id = ts_params->valid_devs[0];
8283 struct rte_cryptodev_scheduler_ops op = {0};
8284 struct rte_cryptodev_scheduler dummy_scheduler = {
8285 .description = "dummy scheduler to test mode",
8286 .name = "dummy scheduler",
8287 .mode = CDEV_SCHED_MODE_USERDEFINED,
8292 /* set user defined mode */
8293 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8295 TEST_ASSERT(ret == 0,
8296 "Failed to set cdev %u to user defined mode", sched_id);
8298 /* set round robin mode */
8299 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8300 CDEV_SCHED_MODE_ROUNDROBIN);
8301 TEST_ASSERT(ret == 0,
8302 "Failed to set cdev %u to round-robin mode", sched_id);
8303 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8304 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8310 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8311 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8312 .setup = testsuite_setup,
8313 .teardown = testsuite_teardown,
8314 .unit_test_cases = {
8315 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8316 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_AES_chain_scheduler_all),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_AES_cipheronly_scheduler_all),
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 test_authonly_scheduler_all),
8323 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8324 TEST_CASES_END() /**< NULL terminate unit test array */
8328 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8330 static struct unit_test_suite cryptodev_qat_testsuite = {
8331 .suite_name = "Crypto QAT Unit Test Suite",
8332 .setup = testsuite_setup,
8333 .teardown = testsuite_teardown,
8334 .unit_test_cases = {
8335 TEST_CASE_ST(ut_setup, ut_teardown,
8336 test_device_configure_invalid_dev_id),
8337 TEST_CASE_ST(ut_setup, ut_teardown,
8338 test_device_configure_invalid_queue_pair_ids),
8339 TEST_CASE_ST(ut_setup, ut_teardown,
8340 test_queue_pair_descriptor_setup),
8341 TEST_CASE_ST(ut_setup, ut_teardown,
8342 test_multi_session),
8344 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 test_AES_cipheronly_qat_all),
8347 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_3DES_cipheronly_qat_all),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_DES_cipheronly_qat_all),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_AES_docsis_qat_all),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_DES_docsis_qat_all),
8356 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8357 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8359 /** AES CCM Authenticated Encryption 128 bits key */
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_AES_CCM_authenticated_encryption_test_case_128_1),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_AES_CCM_authenticated_encryption_test_case_128_2),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_AES_CCM_authenticated_encryption_test_case_128_3),
8367 /** AES CCM Authenticated Decryption 128 bits key*/
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_AES_CCM_authenticated_decryption_test_case_128_1),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_AES_CCM_authenticated_decryption_test_case_128_2),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_AES_CCM_authenticated_decryption_test_case_128_3),
8375 /** AES GCM Authenticated Encryption */
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 test_AES_GCM_authenticated_encryption_test_case_1),
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 test_AES_GCM_authenticated_encryption_test_case_2),
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 test_AES_GCM_authenticated_encryption_test_case_3),
8388 TEST_CASE_ST(ut_setup, ut_teardown,
8389 test_AES_GCM_authenticated_encryption_test_case_4),
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_AES_GCM_authenticated_encryption_test_case_5),
8392 TEST_CASE_ST(ut_setup, ut_teardown,
8393 test_AES_GCM_authenticated_encryption_test_case_6),
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 test_AES_GCM_authenticated_encryption_test_case_7),
8397 /** AES GCM Authenticated Decryption */
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_AES_GCM_authenticated_decryption_test_case_1),
8400 TEST_CASE_ST(ut_setup, ut_teardown,
8401 test_AES_GCM_authenticated_decryption_test_case_2),
8402 TEST_CASE_ST(ut_setup, ut_teardown,
8403 test_AES_GCM_authenticated_decryption_test_case_3),
8404 TEST_CASE_ST(ut_setup, ut_teardown,
8405 test_AES_GCM_authenticated_decryption_test_case_4),
8406 TEST_CASE_ST(ut_setup, ut_teardown,
8407 test_AES_GCM_authenticated_decryption_test_case_5),
8408 TEST_CASE_ST(ut_setup, ut_teardown,
8409 test_AES_GCM_authenticated_decryption_test_case_6),
8410 TEST_CASE_ST(ut_setup, ut_teardown,
8411 test_AES_GCM_authenticated_decryption_test_case_7),
8413 /** AES GCM Authenticated Encryption 192 bits key */
8414 TEST_CASE_ST(ut_setup, ut_teardown,
8415 test_AES_GCM_auth_encryption_test_case_192_1),
8416 TEST_CASE_ST(ut_setup, ut_teardown,
8417 test_AES_GCM_auth_encryption_test_case_192_2),
8418 TEST_CASE_ST(ut_setup, ut_teardown,
8419 test_AES_GCM_auth_encryption_test_case_192_3),
8420 TEST_CASE_ST(ut_setup, ut_teardown,
8421 test_AES_GCM_auth_encryption_test_case_192_4),
8422 TEST_CASE_ST(ut_setup, ut_teardown,
8423 test_AES_GCM_auth_encryption_test_case_192_5),
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_AES_GCM_auth_encryption_test_case_192_6),
8426 TEST_CASE_ST(ut_setup, ut_teardown,
8427 test_AES_GCM_auth_encryption_test_case_192_7),
8429 /** AES GCM Authenticated Decryption 192 bits key */
8430 TEST_CASE_ST(ut_setup, ut_teardown,
8431 test_AES_GCM_auth_decryption_test_case_192_1),
8432 TEST_CASE_ST(ut_setup, ut_teardown,
8433 test_AES_GCM_auth_decryption_test_case_192_2),
8434 TEST_CASE_ST(ut_setup, ut_teardown,
8435 test_AES_GCM_auth_decryption_test_case_192_3),
8436 TEST_CASE_ST(ut_setup, ut_teardown,
8437 test_AES_GCM_auth_decryption_test_case_192_4),
8438 TEST_CASE_ST(ut_setup, ut_teardown,
8439 test_AES_GCM_auth_decryption_test_case_192_5),
8440 TEST_CASE_ST(ut_setup, ut_teardown,
8441 test_AES_GCM_auth_decryption_test_case_192_6),
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_AES_GCM_auth_decryption_test_case_192_7),
8445 /** AES GCM Authenticated Encryption 256 bits key */
8446 TEST_CASE_ST(ut_setup, ut_teardown,
8447 test_AES_GCM_auth_encryption_test_case_256_1),
8448 TEST_CASE_ST(ut_setup, ut_teardown,
8449 test_AES_GCM_auth_encryption_test_case_256_2),
8450 TEST_CASE_ST(ut_setup, ut_teardown,
8451 test_AES_GCM_auth_encryption_test_case_256_3),
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_AES_GCM_auth_encryption_test_case_256_4),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_AES_GCM_auth_encryption_test_case_256_5),
8456 TEST_CASE_ST(ut_setup, ut_teardown,
8457 test_AES_GCM_auth_encryption_test_case_256_6),
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_AES_GCM_auth_encryption_test_case_256_7),
8461 /** AES GMAC Authentication */
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_AES_GMAC_authentication_test_case_1),
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_AES_GMAC_authentication_verify_test_case_1),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_AES_GMAC_authentication_test_case_2),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_AES_GMAC_authentication_verify_test_case_2),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_AES_GMAC_authentication_test_case_3),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_AES_GMAC_authentication_verify_test_case_3),
8475 /** SNOW 3G encrypt only (UEA2) */
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_snow3g_encryption_test_case_1),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_snow3g_encryption_test_case_2),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_snow3g_encryption_test_case_3),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_snow3g_encryption_test_case_4),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_snow3g_encryption_test_case_5),
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_snow3g_encryption_test_case_1_oop),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_snow3g_decryption_test_case_1_oop),
8492 /** SNOW 3G decrypt only (UEA2) */
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_snow3g_decryption_test_case_1),
8495 TEST_CASE_ST(ut_setup, ut_teardown,
8496 test_snow3g_decryption_test_case_2),
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_snow3g_decryption_test_case_3),
8499 TEST_CASE_ST(ut_setup, ut_teardown,
8500 test_snow3g_decryption_test_case_4),
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 test_snow3g_decryption_test_case_5),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 test_snow3g_hash_generate_test_case_1),
8505 TEST_CASE_ST(ut_setup, ut_teardown,
8506 test_snow3g_hash_generate_test_case_2),
8507 TEST_CASE_ST(ut_setup, ut_teardown,
8508 test_snow3g_hash_generate_test_case_3),
8509 TEST_CASE_ST(ut_setup, ut_teardown,
8510 test_snow3g_hash_verify_test_case_1),
8511 TEST_CASE_ST(ut_setup, ut_teardown,
8512 test_snow3g_hash_verify_test_case_2),
8513 TEST_CASE_ST(ut_setup, ut_teardown,
8514 test_snow3g_hash_verify_test_case_3),
8515 TEST_CASE_ST(ut_setup, ut_teardown,
8516 test_snow3g_cipher_auth_test_case_1),
8517 TEST_CASE_ST(ut_setup, ut_teardown,
8518 test_snow3g_auth_cipher_test_case_1),
8520 /** ZUC encrypt only (EEA3) */
8521 TEST_CASE_ST(ut_setup, ut_teardown,
8522 test_zuc_encryption_test_case_1),
8523 TEST_CASE_ST(ut_setup, ut_teardown,
8524 test_zuc_encryption_test_case_2),
8525 TEST_CASE_ST(ut_setup, ut_teardown,
8526 test_zuc_encryption_test_case_3),
8527 TEST_CASE_ST(ut_setup, ut_teardown,
8528 test_zuc_encryption_test_case_4),
8529 TEST_CASE_ST(ut_setup, ut_teardown,
8530 test_zuc_encryption_test_case_5),
8532 /** ZUC authenticate (EIA3) */
8533 TEST_CASE_ST(ut_setup, ut_teardown,
8534 test_zuc_hash_generate_test_case_6),
8535 TEST_CASE_ST(ut_setup, ut_teardown,
8536 test_zuc_hash_generate_test_case_7),
8537 TEST_CASE_ST(ut_setup, ut_teardown,
8538 test_zuc_hash_generate_test_case_8),
8540 /** ZUC alg-chain (EEA3/EIA3) */
8541 TEST_CASE_ST(ut_setup, ut_teardown,
8542 test_zuc_cipher_auth_test_case_1),
8543 TEST_CASE_ST(ut_setup, ut_teardown,
8544 test_zuc_cipher_auth_test_case_2),
8546 /** HMAC_MD5 Authentication */
8547 TEST_CASE_ST(ut_setup, ut_teardown,
8548 test_MD5_HMAC_generate_case_1),
8549 TEST_CASE_ST(ut_setup, ut_teardown,
8550 test_MD5_HMAC_verify_case_1),
8551 TEST_CASE_ST(ut_setup, ut_teardown,
8552 test_MD5_HMAC_generate_case_2),
8553 TEST_CASE_ST(ut_setup, ut_teardown,
8554 test_MD5_HMAC_verify_case_2),
8557 TEST_CASE_ST(ut_setup, ut_teardown,
8558 test_null_auth_only_operation),
8559 TEST_CASE_ST(ut_setup, ut_teardown,
8560 test_null_cipher_only_operation),
8561 TEST_CASE_ST(ut_setup, ut_teardown,
8562 test_null_cipher_auth_operation),
8563 TEST_CASE_ST(ut_setup, ut_teardown,
8564 test_null_auth_cipher_operation),
8567 TEST_CASE_ST(ut_setup, ut_teardown,
8568 test_kasumi_hash_generate_test_case_1),
8569 TEST_CASE_ST(ut_setup, ut_teardown,
8570 test_kasumi_hash_generate_test_case_2),
8571 TEST_CASE_ST(ut_setup, ut_teardown,
8572 test_kasumi_hash_generate_test_case_3),
8573 TEST_CASE_ST(ut_setup, ut_teardown,
8574 test_kasumi_hash_generate_test_case_4),
8575 TEST_CASE_ST(ut_setup, ut_teardown,
8576 test_kasumi_hash_generate_test_case_5),
8577 TEST_CASE_ST(ut_setup, ut_teardown,
8578 test_kasumi_hash_generate_test_case_6),
8580 TEST_CASE_ST(ut_setup, ut_teardown,
8581 test_kasumi_hash_verify_test_case_1),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_kasumi_hash_verify_test_case_2),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_kasumi_hash_verify_test_case_3),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_kasumi_hash_verify_test_case_4),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_kasumi_hash_verify_test_case_5),
8591 TEST_CASE_ST(ut_setup, ut_teardown,
8592 test_kasumi_encryption_test_case_1),
8593 TEST_CASE_ST(ut_setup, ut_teardown,
8594 test_kasumi_encryption_test_case_3),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_kasumi_auth_cipher_test_case_1),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_kasumi_cipher_auth_test_case_1),
8600 /** Negative tests */
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8603 TEST_CASE_ST(ut_setup, ut_teardown,
8604 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 authentication_verify_AES128_GMAC_fail_data_corrupt),
8607 TEST_CASE_ST(ut_setup, ut_teardown,
8608 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8609 TEST_CASE_ST(ut_setup, ut_teardown,
8610 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8611 TEST_CASE_ST(ut_setup, ut_teardown,
8612 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8614 TEST_CASES_END() /**< NULL terminate unit test array */
8618 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8619 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8620 .setup = testsuite_setup,
8621 .teardown = testsuite_teardown,
8622 .unit_test_cases = {
8623 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8624 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8625 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8626 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_DES_cipheronly_mb_all),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_DES_docsis_mb_all),
8632 TEST_CASES_END() /**< NULL terminate unit test array */
8636 static struct unit_test_suite cryptodev_openssl_testsuite = {
8637 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8638 .setup = testsuite_setup,
8639 .teardown = testsuite_teardown,
8640 .unit_test_cases = {
8641 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8642 TEST_CASE_ST(ut_setup, ut_teardown,
8643 test_multi_session_random_usage),
8644 TEST_CASE_ST(ut_setup, ut_teardown,
8645 test_AES_chain_openssl_all),
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 test_AES_cipheronly_openssl_all),
8648 TEST_CASE_ST(ut_setup, ut_teardown,
8649 test_3DES_chain_openssl_all),
8650 TEST_CASE_ST(ut_setup, ut_teardown,
8651 test_3DES_cipheronly_openssl_all),
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_DES_cipheronly_openssl_all),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_DES_docsis_openssl_all),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_authonly_openssl_all),
8659 /** AES GCM Authenticated Encryption */
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_AES_GCM_authenticated_encryption_test_case_1),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_AES_GCM_authenticated_encryption_test_case_2),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_AES_GCM_authenticated_encryption_test_case_3),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_AES_GCM_authenticated_encryption_test_case_4),
8668 TEST_CASE_ST(ut_setup, ut_teardown,
8669 test_AES_GCM_authenticated_encryption_test_case_5),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_AES_GCM_authenticated_encryption_test_case_6),
8672 TEST_CASE_ST(ut_setup, ut_teardown,
8673 test_AES_GCM_authenticated_encryption_test_case_7),
8675 /** AES GCM Authenticated Decryption */
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_AES_GCM_authenticated_decryption_test_case_1),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_AES_GCM_authenticated_decryption_test_case_2),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_AES_GCM_authenticated_decryption_test_case_3),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_AES_GCM_authenticated_decryption_test_case_4),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_AES_GCM_authenticated_decryption_test_case_5),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_AES_GCM_authenticated_decryption_test_case_6),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_AES_GCM_authenticated_decryption_test_case_7),
8692 /** AES GCM Authenticated Encryption 192 bits key */
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_AES_GCM_auth_encryption_test_case_192_1),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_AES_GCM_auth_encryption_test_case_192_2),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_AES_GCM_auth_encryption_test_case_192_3),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_AES_GCM_auth_encryption_test_case_192_4),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_AES_GCM_auth_encryption_test_case_192_5),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_AES_GCM_auth_encryption_test_case_192_6),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_AES_GCM_auth_encryption_test_case_192_7),
8708 /** AES GCM Authenticated Decryption 192 bits key */
8709 TEST_CASE_ST(ut_setup, ut_teardown,
8710 test_AES_GCM_auth_decryption_test_case_192_1),
8711 TEST_CASE_ST(ut_setup, ut_teardown,
8712 test_AES_GCM_auth_decryption_test_case_192_2),
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_AES_GCM_auth_decryption_test_case_192_3),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_AES_GCM_auth_decryption_test_case_192_4),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_AES_GCM_auth_decryption_test_case_192_5),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_AES_GCM_auth_decryption_test_case_192_6),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 test_AES_GCM_auth_decryption_test_case_192_7),
8724 /** AES GCM Authenticated Encryption 256 bits key */
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_AES_GCM_auth_encryption_test_case_256_1),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_AES_GCM_auth_encryption_test_case_256_2),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_AES_GCM_auth_encryption_test_case_256_3),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_AES_GCM_auth_encryption_test_case_256_4),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_AES_GCM_auth_encryption_test_case_256_5),
8735 TEST_CASE_ST(ut_setup, ut_teardown,
8736 test_AES_GCM_auth_encryption_test_case_256_6),
8737 TEST_CASE_ST(ut_setup, ut_teardown,
8738 test_AES_GCM_auth_encryption_test_case_256_7),
8740 /** AES GCM Authenticated Decryption 256 bits key */
8741 TEST_CASE_ST(ut_setup, ut_teardown,
8742 test_AES_GCM_auth_decryption_test_case_256_1),
8743 TEST_CASE_ST(ut_setup, ut_teardown,
8744 test_AES_GCM_auth_decryption_test_case_256_2),
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_AES_GCM_auth_decryption_test_case_256_3),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_AES_GCM_auth_decryption_test_case_256_4),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_AES_GCM_auth_decryption_test_case_256_5),
8751 TEST_CASE_ST(ut_setup, ut_teardown,
8752 test_AES_GCM_auth_decryption_test_case_256_6),
8753 TEST_CASE_ST(ut_setup, ut_teardown,
8754 test_AES_GCM_auth_decryption_test_case_256_7),
8756 /** AES GMAC Authentication */
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 test_AES_GMAC_authentication_test_case_1),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_AES_GMAC_authentication_verify_test_case_1),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_AES_GMAC_authentication_test_case_2),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_AES_GMAC_authentication_verify_test_case_2),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_AES_GMAC_authentication_test_case_3),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_AES_GMAC_authentication_verify_test_case_3),
8769 TEST_CASE_ST(ut_setup, ut_teardown,
8770 test_AES_GMAC_authentication_test_case_4),
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_AES_GMAC_authentication_verify_test_case_4),
8774 /** AES CCM Authenticated Encryption 128 bits key */
8775 TEST_CASE_ST(ut_setup, ut_teardown,
8776 test_AES_CCM_authenticated_encryption_test_case_128_1),
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_AES_CCM_authenticated_encryption_test_case_128_2),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_AES_CCM_authenticated_encryption_test_case_128_3),
8782 /** AES CCM Authenticated Decryption 128 bits key*/
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_CCM_authenticated_decryption_test_case_128_1),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_CCM_authenticated_decryption_test_case_128_2),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_CCM_authenticated_decryption_test_case_128_3),
8790 /** AES CCM Authenticated Encryption 192 bits key */
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_AES_CCM_authenticated_encryption_test_case_192_1),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_CCM_authenticated_encryption_test_case_192_2),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_AES_CCM_authenticated_encryption_test_case_192_3),
8798 /** AES CCM Authenticated Decryption 192 bits key*/
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_CCM_authenticated_decryption_test_case_192_1),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_CCM_authenticated_decryption_test_case_192_2),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_CCM_authenticated_decryption_test_case_192_3),
8806 /** AES CCM Authenticated Encryption 256 bits key */
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_AES_CCM_authenticated_encryption_test_case_256_1),
8809 TEST_CASE_ST(ut_setup, ut_teardown,
8810 test_AES_CCM_authenticated_encryption_test_case_256_2),
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_CCM_authenticated_encryption_test_case_256_3),
8814 /** AES CCM Authenticated Decryption 256 bits key*/
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_CCM_authenticated_decryption_test_case_256_1),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_CCM_authenticated_decryption_test_case_256_2),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_CCM_authenticated_decryption_test_case_256_3),
8822 /** Scatter-Gather */
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8826 /** Negative tests */
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 authentication_verify_AES128_GMAC_fail_data_corrupt),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8840 TEST_CASES_END() /**< NULL terminate unit test array */
8844 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8845 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8846 .setup = testsuite_setup,
8847 .teardown = testsuite_teardown,
8848 .unit_test_cases = {
8849 /** AES GCM Authenticated Encryption */
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_AES_GCM_authenticated_encryption_test_case_1),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_AES_GCM_authenticated_encryption_test_case_2),
8854 TEST_CASE_ST(ut_setup, ut_teardown,
8855 test_AES_GCM_authenticated_encryption_test_case_3),
8856 TEST_CASE_ST(ut_setup, ut_teardown,
8857 test_AES_GCM_authenticated_encryption_test_case_4),
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_AES_GCM_authenticated_encryption_test_case_5),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_AES_GCM_authenticated_encryption_test_case_6),
8862 TEST_CASE_ST(ut_setup, ut_teardown,
8863 test_AES_GCM_authenticated_encryption_test_case_7),
8865 /** AES GCM Authenticated Decryption */
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_AES_GCM_authenticated_decryption_test_case_1),
8868 TEST_CASE_ST(ut_setup, ut_teardown,
8869 test_AES_GCM_authenticated_decryption_test_case_2),
8870 TEST_CASE_ST(ut_setup, ut_teardown,
8871 test_AES_GCM_authenticated_decryption_test_case_3),
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_AES_GCM_authenticated_decryption_test_case_4),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_AES_GCM_authenticated_decryption_test_case_5),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_AES_GCM_authenticated_decryption_test_case_6),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_AES_GCM_authenticated_decryption_test_case_7),
8881 /** AES GCM Authenticated Encryption 192 bits key */
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_AES_GCM_auth_encryption_test_case_192_1),
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 test_AES_GCM_auth_encryption_test_case_192_2),
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 test_AES_GCM_auth_encryption_test_case_192_3),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 test_AES_GCM_auth_encryption_test_case_192_4),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 test_AES_GCM_auth_encryption_test_case_192_5),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_AES_GCM_auth_encryption_test_case_192_6),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_AES_GCM_auth_encryption_test_case_192_7),
8897 /** AES GCM Authenticated Decryption 192 bits key */
8898 TEST_CASE_ST(ut_setup, ut_teardown,
8899 test_AES_GCM_auth_decryption_test_case_192_1),
8900 TEST_CASE_ST(ut_setup, ut_teardown,
8901 test_AES_GCM_auth_decryption_test_case_192_2),
8902 TEST_CASE_ST(ut_setup, ut_teardown,
8903 test_AES_GCM_auth_decryption_test_case_192_3),
8904 TEST_CASE_ST(ut_setup, ut_teardown,
8905 test_AES_GCM_auth_decryption_test_case_192_4),
8906 TEST_CASE_ST(ut_setup, ut_teardown,
8907 test_AES_GCM_auth_decryption_test_case_192_5),
8908 TEST_CASE_ST(ut_setup, ut_teardown,
8909 test_AES_GCM_auth_decryption_test_case_192_6),
8910 TEST_CASE_ST(ut_setup, ut_teardown,
8911 test_AES_GCM_auth_decryption_test_case_192_7),
8913 /** AES GCM Authenticated Encryption 256 bits key */
8914 TEST_CASE_ST(ut_setup, ut_teardown,
8915 test_AES_GCM_auth_encryption_test_case_256_1),
8916 TEST_CASE_ST(ut_setup, ut_teardown,
8917 test_AES_GCM_auth_encryption_test_case_256_2),
8918 TEST_CASE_ST(ut_setup, ut_teardown,
8919 test_AES_GCM_auth_encryption_test_case_256_3),
8920 TEST_CASE_ST(ut_setup, ut_teardown,
8921 test_AES_GCM_auth_encryption_test_case_256_4),
8922 TEST_CASE_ST(ut_setup, ut_teardown,
8923 test_AES_GCM_auth_encryption_test_case_256_5),
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_AES_GCM_auth_encryption_test_case_256_6),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_AES_GCM_auth_encryption_test_case_256_7),
8929 /** AES GCM Authenticated Decryption 256 bits key */
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_AES_GCM_auth_decryption_test_case_256_1),
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_AES_GCM_auth_decryption_test_case_256_2),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_AES_GCM_auth_decryption_test_case_256_3),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_AES_GCM_auth_decryption_test_case_256_4),
8938 TEST_CASE_ST(ut_setup, ut_teardown,
8939 test_AES_GCM_auth_decryption_test_case_256_5),
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_AES_GCM_auth_decryption_test_case_256_6),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_AES_GCM_auth_decryption_test_case_256_7),
8945 /** AES GCM Authenticated Encryption big aad size */
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_AES_GCM_auth_encryption_test_case_aad_1),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_AES_GCM_auth_encryption_test_case_aad_2),
8951 /** AES GCM Authenticated Decryption big aad size */
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_AES_GCM_auth_decryption_test_case_aad_1),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_AES_GCM_auth_decryption_test_case_aad_2),
8957 /** AES GMAC Authentication */
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_AES_GMAC_authentication_test_case_1),
8960 TEST_CASE_ST(ut_setup, ut_teardown,
8961 test_AES_GMAC_authentication_verify_test_case_1),
8962 TEST_CASE_ST(ut_setup, ut_teardown,
8963 test_AES_GMAC_authentication_test_case_3),
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_GMAC_authentication_verify_test_case_3),
8966 TEST_CASE_ST(ut_setup, ut_teardown,
8967 test_AES_GMAC_authentication_test_case_4),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_GMAC_authentication_verify_test_case_4),
8971 /** Negative tests */
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 authentication_verify_AES128_GMAC_fail_data_corrupt),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8977 /** Out of place tests */
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8983 /** Session-less tests */
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8989 /** Scatter-Gather */
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8993 TEST_CASES_END() /**< NULL terminate unit test array */
8997 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8998 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8999 .setup = testsuite_setup,
9000 .teardown = testsuite_teardown,
9001 .unit_test_cases = {
9002 /** KASUMI encrypt only (UEA1) */
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_kasumi_encryption_test_case_1),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_kasumi_encryption_test_case_1_sgl),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_kasumi_encryption_test_case_2),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_kasumi_encryption_test_case_3),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_kasumi_encryption_test_case_4),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_kasumi_encryption_test_case_5),
9015 /** KASUMI decrypt only (UEA1) */
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_kasumi_decryption_test_case_1),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_kasumi_decryption_test_case_2),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_kasumi_decryption_test_case_3),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_kasumi_decryption_test_case_4),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_kasumi_decryption_test_case_5),
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_kasumi_encryption_test_case_1_oop),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_kasumi_encryption_test_case_1_oop_sgl),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_kasumi_decryption_test_case_1_oop),
9036 /** KASUMI hash only (UIA1) */
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_kasumi_hash_generate_test_case_1),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_kasumi_hash_generate_test_case_2),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_kasumi_hash_generate_test_case_3),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_kasumi_hash_generate_test_case_4),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_kasumi_hash_generate_test_case_5),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_kasumi_hash_generate_test_case_6),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_kasumi_hash_verify_test_case_1),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_kasumi_hash_verify_test_case_2),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_kasumi_hash_verify_test_case_3),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_kasumi_hash_verify_test_case_4),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_kasumi_hash_verify_test_case_5),
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_kasumi_auth_cipher_test_case_1),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_kasumi_cipher_auth_test_case_1),
9063 TEST_CASES_END() /**< NULL terminate unit test array */
9066 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9067 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9068 .setup = testsuite_setup,
9069 .teardown = testsuite_teardown,
9070 .unit_test_cases = {
9071 /** SNOW 3G encrypt only (UEA2) */
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_snow3g_encryption_test_case_1),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_snow3g_encryption_test_case_2),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_snow3g_encryption_test_case_3),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_snow3g_encryption_test_case_4),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_snow3g_encryption_test_case_5),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_snow3g_encryption_test_case_1_oop),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_snow3g_encryption_test_case_1_oop_sgl),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_snow3g_decryption_test_case_1_oop),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_snow3g_encryption_test_case_1_offset_oop),
9093 /** SNOW 3G decrypt only (UEA2) */
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_snow3g_decryption_test_case_1),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_snow3g_decryption_test_case_2),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_snow3g_decryption_test_case_3),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_snow3g_decryption_test_case_4),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_snow3g_decryption_test_case_5),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_snow3g_hash_generate_test_case_1),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_snow3g_hash_generate_test_case_2),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_snow3g_hash_generate_test_case_3),
9110 /* Tests with buffers which length is not byte-aligned */
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_snow3g_hash_generate_test_case_4),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_snow3g_hash_generate_test_case_5),
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_snow3g_hash_generate_test_case_6),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_snow3g_hash_verify_test_case_1),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_snow3g_hash_verify_test_case_2),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_snow3g_hash_verify_test_case_3),
9123 /* Tests with buffers which length is not byte-aligned */
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_snow3g_hash_verify_test_case_4),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_snow3g_hash_verify_test_case_5),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_snow3g_hash_verify_test_case_6),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_snow3g_cipher_auth_test_case_1),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_snow3g_auth_cipher_test_case_1),
9135 TEST_CASES_END() /**< NULL terminate unit test array */
9139 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9140 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9141 .setup = testsuite_setup,
9142 .teardown = testsuite_teardown,
9143 .unit_test_cases = {
9144 /** ZUC encrypt only (EEA3) */
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_zuc_encryption_test_case_1),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_zuc_encryption_test_case_2),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_zuc_encryption_test_case_3),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_zuc_encryption_test_case_4),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_zuc_encryption_test_case_5),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_zuc_hash_generate_test_case_1),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_zuc_hash_generate_test_case_2),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_zuc_hash_generate_test_case_3),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_zuc_hash_generate_test_case_4),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_zuc_hash_generate_test_case_5),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_zuc_encryption_test_case_6_sgl),
9167 TEST_CASES_END() /**< NULL terminate unit test array */
9171 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9172 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9173 .setup = testsuite_setup,
9174 .teardown = testsuite_teardown,
9175 .unit_test_cases = {
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_device_configure_invalid_dev_id),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_multi_session),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_AES_chain_dpaa_sec_all),
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_3DES_chain_dpaa_sec_all),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_cipheronly_dpaa_sec_all),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_3DES_cipheronly_dpaa_sec_all),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_authonly_dpaa_sec_all),
9192 /** AES GCM Authenticated Encryption */
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_GCM_authenticated_encryption_test_case_1),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_GCM_authenticated_encryption_test_case_2),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_AES_GCM_authenticated_encryption_test_case_3),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_AES_GCM_authenticated_encryption_test_case_4),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_GCM_authenticated_encryption_test_case_5),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_AES_GCM_authenticated_encryption_test_case_6),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_AES_GCM_authenticated_encryption_test_case_7),
9208 /** AES GCM Authenticated Decryption */
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_AES_GCM_authenticated_decryption_test_case_1),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_AES_GCM_authenticated_decryption_test_case_2),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_AES_GCM_authenticated_decryption_test_case_3),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_AES_GCM_authenticated_decryption_test_case_4),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_AES_GCM_authenticated_decryption_test_case_5),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_AES_GCM_authenticated_decryption_test_case_6),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_AES_GCM_authenticated_decryption_test_case_7),
9224 /** AES GCM Authenticated Encryption 256 bits key */
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_AES_GCM_auth_encryption_test_case_256_1),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_GCM_auth_encryption_test_case_256_2),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_AES_GCM_auth_encryption_test_case_256_3),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_GCM_auth_encryption_test_case_256_4),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_AES_GCM_auth_encryption_test_case_256_5),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_AES_GCM_auth_encryption_test_case_256_6),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_AES_GCM_auth_encryption_test_case_256_7),
9240 /** AES GCM Authenticated Decryption 256 bits key */
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_AES_GCM_auth_decryption_test_case_256_1),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_AES_GCM_auth_decryption_test_case_256_2),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_AES_GCM_auth_decryption_test_case_256_3),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_AES_GCM_auth_decryption_test_case_256_4),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_AES_GCM_auth_decryption_test_case_256_5),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_AES_GCM_auth_decryption_test_case_256_6),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_auth_decryption_test_case_256_7),
9256 TEST_CASES_END() /**< NULL terminate unit test array */
9260 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9261 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9262 .setup = testsuite_setup,
9263 .teardown = testsuite_teardown,
9264 .unit_test_cases = {
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_device_configure_invalid_dev_id),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_multi_session),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_chain_dpaa2_sec_all),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_3DES_chain_dpaa2_sec_all),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_cipheronly_dpaa2_sec_all),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_3DES_cipheronly_dpaa2_sec_all),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_authonly_dpaa2_sec_all),
9281 /** AES GCM Authenticated Encryption */
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_authenticated_encryption_test_case_1),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_authenticated_encryption_test_case_2),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_authenticated_encryption_test_case_3),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_authenticated_encryption_test_case_4),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_authenticated_encryption_test_case_5),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_authenticated_encryption_test_case_6),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_authenticated_encryption_test_case_7),
9297 /** AES GCM Authenticated Decryption */
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_authenticated_decryption_test_case_1),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_authenticated_decryption_test_case_2),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_authenticated_decryption_test_case_3),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_authenticated_decryption_test_case_4),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_authenticated_decryption_test_case_5),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_authenticated_decryption_test_case_6),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_authenticated_decryption_test_case_7),
9313 /** AES GCM Authenticated Encryption 192 bits key */
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_auth_encryption_test_case_192_1),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_encryption_test_case_192_2),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_encryption_test_case_192_3),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_encryption_test_case_192_4),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_encryption_test_case_192_5),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_encryption_test_case_192_6),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_encryption_test_case_192_7),
9329 /** AES GCM Authenticated Decryption 192 bits key */
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_decryption_test_case_192_1),
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_auth_decryption_test_case_192_2),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_decryption_test_case_192_3),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_auth_decryption_test_case_192_4),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_decryption_test_case_192_5),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_auth_decryption_test_case_192_6),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_auth_decryption_test_case_192_7),
9345 /** AES GCM Authenticated Encryption 256 bits key */
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GCM_auth_encryption_test_case_256_1),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GCM_auth_encryption_test_case_256_2),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GCM_auth_encryption_test_case_256_3),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GCM_auth_encryption_test_case_256_4),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GCM_auth_encryption_test_case_256_5),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_GCM_auth_encryption_test_case_256_6),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_GCM_auth_encryption_test_case_256_7),
9361 /** AES GCM Authenticated Decryption 256 bits key */
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_auth_decryption_test_case_256_1),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_auth_decryption_test_case_256_2),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_auth_decryption_test_case_256_3),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_auth_decryption_test_case_256_4),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_auth_decryption_test_case_256_5),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_AES_GCM_auth_decryption_test_case_256_6),
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GCM_auth_decryption_test_case_256_7),
9377 TEST_CASES_END() /**< NULL terminate unit test array */
9381 static struct unit_test_suite cryptodev_null_testsuite = {
9382 .suite_name = "Crypto Device NULL Unit Test Suite",
9383 .setup = testsuite_setup,
9384 .teardown = testsuite_teardown,
9385 .unit_test_cases = {
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_null_auth_only_operation),
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_null_cipher_only_operation),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_null_cipher_auth_operation),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_null_auth_cipher_operation),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_null_invalid_operation),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_null_burst_operation),
9399 TEST_CASES_END() /**< NULL terminate unit test array */
9403 static struct unit_test_suite cryptodev_armv8_testsuite = {
9404 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9405 .setup = testsuite_setup,
9406 .teardown = testsuite_teardown,
9407 .unit_test_cases = {
9408 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9410 /** Negative tests */
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9416 TEST_CASES_END() /**< NULL terminate unit test array */
9421 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9423 gbl_driver_id = rte_cryptodev_driver_id_get(
9424 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9426 if (gbl_driver_id == -1) {
9427 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9428 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9429 "in config file to run this testsuite.\n");
9433 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9437 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9439 gbl_driver_id = rte_cryptodev_driver_id_get(
9440 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9442 if (gbl_driver_id == -1) {
9443 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9444 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9445 "in config file to run this testsuite.\n");
9449 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9453 test_cryptodev_openssl(void)
9455 gbl_driver_id = rte_cryptodev_driver_id_get(
9456 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9458 if (gbl_driver_id == -1) {
9459 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9460 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9461 "in config file to run this testsuite.\n");
9465 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9469 test_cryptodev_aesni_gcm(void)
9471 gbl_driver_id = rte_cryptodev_driver_id_get(
9472 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9474 if (gbl_driver_id == -1) {
9475 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9476 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9477 "in config file to run this testsuite.\n");
9481 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9485 test_cryptodev_null(void)
9487 gbl_driver_id = rte_cryptodev_driver_id_get(
9488 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9490 if (gbl_driver_id == -1) {
9491 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9492 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9493 "in config file to run this testsuite.\n");
9497 return unit_test_suite_runner(&cryptodev_null_testsuite);
9501 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9503 gbl_driver_id = rte_cryptodev_driver_id_get(
9504 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9506 if (gbl_driver_id == -1) {
9507 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9508 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9509 "in config file to run this testsuite.\n");
9513 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9517 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9519 gbl_driver_id = rte_cryptodev_driver_id_get(
9520 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9522 if (gbl_driver_id == -1) {
9523 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9524 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9525 "in config file to run this testsuite.\n");
9529 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9533 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9535 gbl_driver_id = rte_cryptodev_driver_id_get(
9536 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9538 if (gbl_driver_id == -1) {
9539 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9540 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9541 "in config file to run this testsuite.\n");
9545 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9549 test_cryptodev_armv8(void)
9551 gbl_driver_id = rte_cryptodev_driver_id_get(
9552 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9554 if (gbl_driver_id == -1) {
9555 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9556 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9557 "in config file to run this testsuite.\n");
9561 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9564 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9567 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9569 gbl_driver_id = rte_cryptodev_driver_id_get(
9570 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9572 if (gbl_driver_id == -1) {
9573 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9574 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9575 "in config file to run this testsuite.\n");
9579 if (rte_cryptodev_driver_id_get(
9580 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9581 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9582 " enabled in config file to run this testsuite.\n");
9585 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9588 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9593 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9595 gbl_driver_id = rte_cryptodev_driver_id_get(
9596 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9598 if (gbl_driver_id == -1) {
9599 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9600 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9601 "in config file to run this testsuite.\n");
9605 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9609 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9611 gbl_driver_id = rte_cryptodev_driver_id_get(
9612 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9614 if (gbl_driver_id == -1) {
9615 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9616 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9617 "in config file to run this testsuite.\n");
9621 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9624 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9625 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9626 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9627 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9628 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9629 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9630 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9631 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9632 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9633 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9634 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);