4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static 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_dpaa2_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_DPAA2_SEC_PMD)),
1782 BLKCIPHER_AES_CHAIN_TYPE);
1784 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1786 return TEST_SUCCESS;
1790 test_AES_cipheronly_dpaa2_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_DPAA2_SEC_PMD)),
1801 BLKCIPHER_AES_CIPHERONLY_TYPE);
1803 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1805 return TEST_SUCCESS;
1809 test_authonly_dpaa2_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_DPAA2_SEC_PMD)),
1820 BLKCIPHER_AUTHONLY_TYPE);
1822 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1824 return TEST_SUCCESS;
1828 test_authonly_openssl_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_OPENSSL_PMD)),
1839 BLKCIPHER_AUTHONLY_TYPE);
1841 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1843 return TEST_SUCCESS;
1847 test_AES_chain_armv8_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_ARMV8_PMD)),
1858 BLKCIPHER_AES_CHAIN_TYPE);
1860 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1862 return TEST_SUCCESS;
1865 /* ***** SNOW 3G Tests ***** */
1867 create_wireless_algo_hash_session(uint8_t dev_id,
1868 const uint8_t *key, const uint8_t key_len,
1869 const uint8_t iv_len, const uint8_t auth_len,
1870 enum rte_crypto_auth_operation op,
1871 enum rte_crypto_auth_algorithm algo)
1873 uint8_t hash_key[key_len];
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 struct crypto_unittest_params *ut_params = &unittest_params;
1878 memcpy(hash_key, key, key_len);
1880 TEST_HEXDUMP(stdout, "key:", key, key_len);
1882 /* Setup Authentication Parameters */
1883 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1884 ut_params->auth_xform.next = NULL;
1886 ut_params->auth_xform.auth.op = op;
1887 ut_params->auth_xform.auth.algo = algo;
1888 ut_params->auth_xform.auth.key.length = key_len;
1889 ut_params->auth_xform.auth.key.data = hash_key;
1890 ut_params->auth_xform.auth.digest_length = auth_len;
1891 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1892 ut_params->auth_xform.auth.iv.length = iv_len;
1893 ut_params->sess = rte_cryptodev_sym_session_create(
1894 ts_params->session_mpool);
1896 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1897 &ut_params->auth_xform, ts_params->session_mpool);
1898 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1903 create_wireless_algo_cipher_session(uint8_t dev_id,
1904 enum rte_crypto_cipher_operation op,
1905 enum rte_crypto_cipher_algorithm algo,
1906 const uint8_t *key, const uint8_t key_len,
1909 uint8_t cipher_key[key_len];
1911 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 struct crypto_unittest_params *ut_params = &unittest_params;
1914 memcpy(cipher_key, key, key_len);
1916 /* Setup Cipher Parameters */
1917 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1918 ut_params->cipher_xform.next = NULL;
1920 ut_params->cipher_xform.cipher.algo = algo;
1921 ut_params->cipher_xform.cipher.op = op;
1922 ut_params->cipher_xform.cipher.key.data = cipher_key;
1923 ut_params->cipher_xform.cipher.key.length = key_len;
1924 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1925 ut_params->cipher_xform.cipher.iv.length = iv_len;
1927 TEST_HEXDUMP(stdout, "key:", key, key_len);
1929 /* Create Crypto session */
1930 ut_params->sess = rte_cryptodev_sym_session_create(
1931 ts_params->session_mpool);
1933 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1934 &ut_params->cipher_xform, ts_params->session_mpool);
1935 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1940 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1941 unsigned int cipher_len,
1942 unsigned int cipher_offset)
1944 struct crypto_testsuite_params *ts_params = &testsuite_params;
1945 struct crypto_unittest_params *ut_params = &unittest_params;
1947 /* Generate Crypto op data structure */
1948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1950 TEST_ASSERT_NOT_NULL(ut_params->op,
1951 "Failed to allocate pktmbuf offload");
1953 /* Set crypto operation data parameters */
1954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1956 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1958 /* set crypto operation source mbuf */
1959 sym_op->m_src = ut_params->ibuf;
1962 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1964 sym_op->cipher.data.length = cipher_len;
1965 sym_op->cipher.data.offset = cipher_offset;
1970 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1971 unsigned int cipher_len,
1972 unsigned int cipher_offset)
1974 struct crypto_testsuite_params *ts_params = &testsuite_params;
1975 struct crypto_unittest_params *ut_params = &unittest_params;
1977 /* Generate Crypto op data structure */
1978 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1979 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1980 TEST_ASSERT_NOT_NULL(ut_params->op,
1981 "Failed to allocate pktmbuf offload");
1983 /* Set crypto operation data parameters */
1984 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1986 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1988 /* set crypto operation source mbuf */
1989 sym_op->m_src = ut_params->ibuf;
1990 sym_op->m_dst = ut_params->obuf;
1993 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1995 sym_op->cipher.data.length = cipher_len;
1996 sym_op->cipher.data.offset = cipher_offset;
2001 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2002 enum rte_crypto_cipher_operation cipher_op,
2003 enum rte_crypto_auth_operation auth_op,
2004 enum rte_crypto_auth_algorithm auth_algo,
2005 enum rte_crypto_cipher_algorithm cipher_algo,
2006 const uint8_t *key, uint8_t key_len,
2007 uint8_t auth_iv_len, uint8_t auth_len,
2008 uint8_t cipher_iv_len)
2011 uint8_t cipher_auth_key[key_len];
2013 struct crypto_testsuite_params *ts_params = &testsuite_params;
2014 struct crypto_unittest_params *ut_params = &unittest_params;
2016 memcpy(cipher_auth_key, key, key_len);
2018 /* Setup Authentication Parameters */
2019 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2020 ut_params->auth_xform.next = NULL;
2022 ut_params->auth_xform.auth.op = auth_op;
2023 ut_params->auth_xform.auth.algo = auth_algo;
2024 ut_params->auth_xform.auth.key.length = key_len;
2025 /* Hash key = cipher key */
2026 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 /* Auth IV will be after cipher IV */
2029 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2030 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2032 /* Setup Cipher Parameters */
2033 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2034 ut_params->cipher_xform.next = &ut_params->auth_xform;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2041 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2043 TEST_HEXDUMP(stdout, "key:", key, key_len);
2045 /* Create Crypto session*/
2046 ut_params->sess = rte_cryptodev_sym_session_create(
2047 ts_params->session_mpool);
2049 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2050 &ut_params->cipher_xform, ts_params->session_mpool);
2052 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2057 create_wireless_cipher_auth_session(uint8_t dev_id,
2058 enum rte_crypto_cipher_operation cipher_op,
2059 enum rte_crypto_auth_operation auth_op,
2060 enum rte_crypto_auth_algorithm auth_algo,
2061 enum rte_crypto_cipher_algorithm cipher_algo,
2062 const struct wireless_test_data *tdata)
2064 const uint8_t key_len = tdata->key.len;
2065 uint8_t cipher_auth_key[key_len];
2067 struct crypto_testsuite_params *ts_params = &testsuite_params;
2068 struct crypto_unittest_params *ut_params = &unittest_params;
2069 const uint8_t *key = tdata->key.data;
2070 const uint8_t auth_len = tdata->digest.len;
2071 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2072 uint8_t auth_iv_len = tdata->auth_iv.len;
2074 memcpy(cipher_auth_key, key, key_len);
2076 /* Setup Authentication Parameters */
2077 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2078 ut_params->auth_xform.next = NULL;
2080 ut_params->auth_xform.auth.op = auth_op;
2081 ut_params->auth_xform.auth.algo = auth_algo;
2082 ut_params->auth_xform.auth.key.length = key_len;
2083 /* Hash key = cipher key */
2084 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2085 ut_params->auth_xform.auth.digest_length = auth_len;
2086 /* Auth IV will be after cipher IV */
2087 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2088 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2090 /* Setup Cipher Parameters */
2091 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2092 ut_params->cipher_xform.next = &ut_params->auth_xform;
2094 ut_params->cipher_xform.cipher.algo = cipher_algo;
2095 ut_params->cipher_xform.cipher.op = cipher_op;
2096 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2097 ut_params->cipher_xform.cipher.key.length = key_len;
2098 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2099 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2102 TEST_HEXDUMP(stdout, "key:", key, key_len);
2104 /* Create Crypto session*/
2105 ut_params->sess = rte_cryptodev_sym_session_create(
2106 ts_params->session_mpool);
2108 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2109 &ut_params->cipher_xform, ts_params->session_mpool);
2111 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2116 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2117 const struct wireless_test_data *tdata)
2119 return create_wireless_cipher_auth_session(dev_id,
2120 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2121 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2122 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2126 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2127 enum rte_crypto_cipher_operation cipher_op,
2128 enum rte_crypto_auth_operation auth_op,
2129 enum rte_crypto_auth_algorithm auth_algo,
2130 enum rte_crypto_cipher_algorithm cipher_algo,
2131 const uint8_t *key, const uint8_t key_len,
2132 uint8_t auth_iv_len, uint8_t auth_len,
2133 uint8_t cipher_iv_len)
2135 uint8_t auth_cipher_key[key_len];
2137 struct crypto_testsuite_params *ts_params = &testsuite_params;
2138 struct crypto_unittest_params *ut_params = &unittest_params;
2140 memcpy(auth_cipher_key, key, key_len);
2142 /* Setup Authentication Parameters */
2143 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2144 ut_params->auth_xform.auth.op = auth_op;
2145 ut_params->auth_xform.next = &ut_params->cipher_xform;
2146 ut_params->auth_xform.auth.algo = auth_algo;
2147 ut_params->auth_xform.auth.key.length = key_len;
2148 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2149 ut_params->auth_xform.auth.digest_length = auth_len;
2150 /* Auth IV will be after cipher IV */
2151 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2152 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2154 /* Setup Cipher Parameters */
2155 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2156 ut_params->cipher_xform.next = NULL;
2157 ut_params->cipher_xform.cipher.algo = cipher_algo;
2158 ut_params->cipher_xform.cipher.op = cipher_op;
2159 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2160 ut_params->cipher_xform.cipher.key.length = key_len;
2161 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2162 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2164 TEST_HEXDUMP(stdout, "key:", key, key_len);
2166 /* Create Crypto session*/
2167 ut_params->sess = rte_cryptodev_sym_session_create(
2168 ts_params->session_mpool);
2170 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2171 &ut_params->auth_xform, ts_params->session_mpool);
2173 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2179 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2180 unsigned int auth_tag_len,
2181 const uint8_t *iv, unsigned int iv_len,
2182 unsigned int data_pad_len,
2183 enum rte_crypto_auth_operation op,
2184 unsigned int auth_len, unsigned int auth_offset)
2186 struct crypto_testsuite_params *ts_params = &testsuite_params;
2188 struct crypto_unittest_params *ut_params = &unittest_params;
2190 /* Generate Crypto op data structure */
2191 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2192 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2193 TEST_ASSERT_NOT_NULL(ut_params->op,
2194 "Failed to allocate pktmbuf offload");
2196 /* Set crypto operation data parameters */
2197 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2199 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2201 /* set crypto operation source mbuf */
2202 sym_op->m_src = ut_params->ibuf;
2205 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2208 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2209 ut_params->ibuf, auth_tag_len);
2211 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2212 "no room to append auth tag");
2213 ut_params->digest = sym_op->auth.digest.data;
2214 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2215 ut_params->ibuf, data_pad_len);
2216 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2217 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2219 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2221 TEST_HEXDUMP(stdout, "digest:",
2222 sym_op->auth.digest.data,
2225 sym_op->auth.data.length = auth_len;
2226 sym_op->auth.data.offset = auth_offset;
2232 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2233 enum rte_crypto_auth_operation op)
2235 struct crypto_testsuite_params *ts_params = &testsuite_params;
2236 struct crypto_unittest_params *ut_params = &unittest_params;
2238 const uint8_t *auth_tag = tdata->digest.data;
2239 const unsigned int auth_tag_len = tdata->digest.len;
2240 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2241 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2243 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2244 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2245 const uint8_t *auth_iv = tdata->auth_iv.data;
2246 const uint8_t auth_iv_len = tdata->auth_iv.len;
2247 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2248 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2250 /* Generate Crypto op data structure */
2251 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2252 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2253 TEST_ASSERT_NOT_NULL(ut_params->op,
2254 "Failed to allocate pktmbuf offload");
2255 /* Set crypto operation data parameters */
2256 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2258 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2260 /* set crypto operation source mbuf */
2261 sym_op->m_src = ut_params->ibuf;
2264 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2265 ut_params->ibuf, auth_tag_len);
2267 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2268 "no room to append auth tag");
2269 ut_params->digest = sym_op->auth.digest.data;
2270 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2271 ut_params->ibuf, data_pad_len);
2272 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2273 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2275 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2277 TEST_HEXDUMP(stdout, "digest:",
2278 sym_op->auth.digest.data,
2281 /* Copy cipher and auth IVs at the end of the crypto operation */
2282 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2284 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2285 iv_ptr += cipher_iv_len;
2286 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2288 sym_op->cipher.data.length = cipher_len;
2289 sym_op->cipher.data.offset = 0;
2290 sym_op->auth.data.length = auth_len;
2291 sym_op->auth.data.offset = 0;
2297 create_zuc_cipher_hash_generate_operation(
2298 const struct wireless_test_data *tdata)
2300 return create_wireless_cipher_hash_operation(tdata,
2301 RTE_CRYPTO_AUTH_OP_GENERATE);
2305 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2306 const unsigned auth_tag_len,
2307 const uint8_t *auth_iv, uint8_t auth_iv_len,
2308 unsigned data_pad_len,
2309 enum rte_crypto_auth_operation op,
2310 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2311 const unsigned cipher_len, const unsigned cipher_offset,
2312 const unsigned auth_len, const unsigned auth_offset)
2314 struct crypto_testsuite_params *ts_params = &testsuite_params;
2315 struct crypto_unittest_params *ut_params = &unittest_params;
2317 /* Generate Crypto op data structure */
2318 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2319 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2320 TEST_ASSERT_NOT_NULL(ut_params->op,
2321 "Failed to allocate pktmbuf offload");
2322 /* Set crypto operation data parameters */
2323 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2325 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2327 /* set crypto operation source mbuf */
2328 sym_op->m_src = ut_params->ibuf;
2331 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2332 ut_params->ibuf, auth_tag_len);
2334 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2335 "no room to append auth tag");
2336 ut_params->digest = sym_op->auth.digest.data;
2337 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2338 ut_params->ibuf, data_pad_len);
2339 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2340 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2342 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2344 TEST_HEXDUMP(stdout, "digest:",
2345 sym_op->auth.digest.data,
2348 /* Copy cipher and auth IVs at the end of the crypto operation */
2349 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2351 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2352 iv_ptr += cipher_iv_len;
2353 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2355 sym_op->cipher.data.length = cipher_len;
2356 sym_op->cipher.data.offset = cipher_offset;
2357 sym_op->auth.data.length = auth_len;
2358 sym_op->auth.data.offset = auth_offset;
2364 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2365 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2366 const uint8_t *auth_iv, uint8_t auth_iv_len,
2367 unsigned int data_pad_len,
2368 unsigned int cipher_len, unsigned int cipher_offset,
2369 unsigned int auth_len, unsigned int 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");
2380 /* Set crypto operation data parameters */
2381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2383 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2385 /* set crypto operation source mbuf */
2386 sym_op->m_src = ut_params->ibuf;
2389 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2390 ut_params->ibuf, auth_tag_len);
2392 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2393 "no room to append auth tag");
2395 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2396 ut_params->ibuf, data_pad_len);
2398 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2400 TEST_HEXDUMP(stdout, "digest:",
2401 sym_op->auth.digest.data,
2404 /* Copy cipher and auth IVs at the end of the crypto operation */
2405 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2407 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2408 iv_ptr += cipher_iv_len;
2409 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2411 sym_op->cipher.data.length = cipher_len;
2412 sym_op->cipher.data.offset = cipher_offset;
2414 sym_op->auth.data.length = auth_len;
2415 sym_op->auth.data.offset = auth_offset;
2421 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2424 struct crypto_unittest_params *ut_params = &unittest_params;
2427 unsigned plaintext_pad_len;
2428 unsigned plaintext_len;
2431 /* Create SNOW 3G session */
2432 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2433 tdata->key.data, tdata->key.len,
2434 tdata->auth_iv.len, tdata->digest.len,
2435 RTE_CRYPTO_AUTH_OP_GENERATE,
2436 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2440 /* alloc mbuf and set payload */
2441 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2443 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2444 rte_pktmbuf_tailroom(ut_params->ibuf));
2446 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2447 /* Append data which is padded to a multiple of */
2448 /* the algorithms block size */
2449 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2450 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2452 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2454 /* Create SNOW 3G operation */
2455 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2456 tdata->auth_iv.data, tdata->auth_iv.len,
2457 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2458 tdata->validAuthLenInBits.len,
2463 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2465 ut_params->obuf = ut_params->op->sym->m_src;
2466 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2467 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2468 + plaintext_pad_len;
2471 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2474 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2475 "SNOW 3G Generated auth tag not as expected");
2481 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2483 struct crypto_testsuite_params *ts_params = &testsuite_params;
2484 struct crypto_unittest_params *ut_params = &unittest_params;
2487 unsigned plaintext_pad_len;
2488 unsigned plaintext_len;
2491 /* Create SNOW 3G session */
2492 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2493 tdata->key.data, tdata->key.len,
2494 tdata->auth_iv.len, tdata->digest.len,
2495 RTE_CRYPTO_AUTH_OP_VERIFY,
2496 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2499 /* alloc mbuf and set payload */
2500 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2502 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2503 rte_pktmbuf_tailroom(ut_params->ibuf));
2505 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2506 /* Append data which is padded to a multiple of */
2507 /* the algorithms block size */
2508 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2509 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2511 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2513 /* Create SNOW 3G operation */
2514 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2516 tdata->auth_iv.data, tdata->auth_iv.len,
2518 RTE_CRYPTO_AUTH_OP_VERIFY,
2519 tdata->validAuthLenInBits.len,
2524 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2526 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2527 ut_params->obuf = ut_params->op->sym->m_src;
2528 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2529 + plaintext_pad_len;
2532 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2541 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2543 struct crypto_testsuite_params *ts_params = &testsuite_params;
2544 struct crypto_unittest_params *ut_params = &unittest_params;
2547 unsigned plaintext_pad_len;
2548 unsigned plaintext_len;
2551 /* Create KASUMI session */
2552 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2553 tdata->key.data, tdata->key.len,
2554 0, tdata->digest.len,
2555 RTE_CRYPTO_AUTH_OP_GENERATE,
2556 RTE_CRYPTO_AUTH_KASUMI_F9);
2560 /* alloc mbuf and set payload */
2561 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2564 rte_pktmbuf_tailroom(ut_params->ibuf));
2566 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2567 /* Append data which is padded to a multiple of */
2568 /* the algorithms block size */
2569 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2570 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2572 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2574 /* Create KASUMI operation */
2575 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2577 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2578 tdata->plaintext.len,
2583 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2585 ut_params->obuf = ut_params->op->sym->m_src;
2586 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2587 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2588 + plaintext_pad_len;
2591 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2594 DIGEST_BYTE_LENGTH_KASUMI_F9,
2595 "KASUMI Generated auth tag not as expected");
2601 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2603 struct crypto_testsuite_params *ts_params = &testsuite_params;
2604 struct crypto_unittest_params *ut_params = &unittest_params;
2607 unsigned plaintext_pad_len;
2608 unsigned plaintext_len;
2611 /* Create KASUMI session */
2612 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2613 tdata->key.data, tdata->key.len,
2614 0, tdata->digest.len,
2615 RTE_CRYPTO_AUTH_OP_VERIFY,
2616 RTE_CRYPTO_AUTH_KASUMI_F9);
2619 /* alloc mbuf and set payload */
2620 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2622 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2623 rte_pktmbuf_tailroom(ut_params->ibuf));
2625 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2626 /* Append data which is padded to a multiple */
2627 /* of the algorithms block size */
2628 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2629 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2631 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2633 /* Create KASUMI operation */
2634 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2638 RTE_CRYPTO_AUTH_OP_VERIFY,
2639 tdata->plaintext.len,
2644 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2646 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2647 ut_params->obuf = ut_params->op->sym->m_src;
2648 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2649 + plaintext_pad_len;
2652 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2661 test_snow3g_hash_generate_test_case_1(void)
2663 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2667 test_snow3g_hash_generate_test_case_2(void)
2669 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2673 test_snow3g_hash_generate_test_case_3(void)
2675 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2679 test_snow3g_hash_generate_test_case_4(void)
2681 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2685 test_snow3g_hash_generate_test_case_5(void)
2687 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2691 test_snow3g_hash_generate_test_case_6(void)
2693 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2697 test_snow3g_hash_verify_test_case_1(void)
2699 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2704 test_snow3g_hash_verify_test_case_2(void)
2706 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2710 test_snow3g_hash_verify_test_case_3(void)
2712 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2716 test_snow3g_hash_verify_test_case_4(void)
2718 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2722 test_snow3g_hash_verify_test_case_5(void)
2724 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2728 test_snow3g_hash_verify_test_case_6(void)
2730 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2734 test_kasumi_hash_generate_test_case_1(void)
2736 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2740 test_kasumi_hash_generate_test_case_2(void)
2742 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2746 test_kasumi_hash_generate_test_case_3(void)
2748 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2752 test_kasumi_hash_generate_test_case_4(void)
2754 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2758 test_kasumi_hash_generate_test_case_5(void)
2760 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2764 test_kasumi_hash_generate_test_case_6(void)
2766 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2770 test_kasumi_hash_verify_test_case_1(void)
2772 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2776 test_kasumi_hash_verify_test_case_2(void)
2778 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2782 test_kasumi_hash_verify_test_case_3(void)
2784 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2788 test_kasumi_hash_verify_test_case_4(void)
2790 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2794 test_kasumi_hash_verify_test_case_5(void)
2796 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2800 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2802 struct crypto_testsuite_params *ts_params = &testsuite_params;
2803 struct crypto_unittest_params *ut_params = &unittest_params;
2806 uint8_t *plaintext, *ciphertext;
2807 unsigned plaintext_pad_len;
2808 unsigned plaintext_len;
2810 /* Create KASUMI session */
2811 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2812 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2813 RTE_CRYPTO_CIPHER_KASUMI_F8,
2814 tdata->key.data, tdata->key.len,
2815 tdata->cipher_iv.len);
2819 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2821 /* Clear mbuf payload */
2822 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2823 rte_pktmbuf_tailroom(ut_params->ibuf));
2825 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2826 /* Append data which is padded to a multiple */
2827 /* of the algorithms block size */
2828 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2829 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2831 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2833 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2835 /* Create KASUMI operation */
2836 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2837 tdata->cipher_iv.len,
2838 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2839 tdata->validCipherOffsetInBits.len);
2843 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2845 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2847 ut_params->obuf = ut_params->op->sym->m_dst;
2848 if (ut_params->obuf)
2849 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2851 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2853 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2855 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2856 (tdata->validCipherOffsetInBits.len >> 3);
2858 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2860 reference_ciphertext,
2861 tdata->validCipherLenInBits.len,
2862 "KASUMI Ciphertext data not as expected");
2867 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2869 struct crypto_testsuite_params *ts_params = &testsuite_params;
2870 struct crypto_unittest_params *ut_params = &unittest_params;
2874 unsigned int plaintext_pad_len;
2875 unsigned int plaintext_len;
2877 uint8_t buffer[10000];
2878 const uint8_t *ciphertext;
2880 struct rte_cryptodev_info dev_info;
2882 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2883 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2884 printf("Device doesn't support scatter-gather. "
2889 /* Create KASUMI session */
2890 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2891 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2892 RTE_CRYPTO_CIPHER_KASUMI_F8,
2893 tdata->key.data, tdata->key.len,
2894 tdata->cipher_iv.len);
2898 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2901 /* Append data which is padded to a multiple */
2902 /* of the algorithms block size */
2903 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2905 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2906 plaintext_pad_len, 10, 0);
2908 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2910 /* Create KASUMI operation */
2911 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2912 tdata->cipher_iv.len,
2913 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2914 tdata->validCipherOffsetInBits.len);
2918 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2920 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2922 ut_params->obuf = ut_params->op->sym->m_dst;
2924 if (ut_params->obuf)
2925 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2926 plaintext_len, buffer);
2928 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2929 tdata->validCipherOffsetInBits.len >> 3,
2930 plaintext_len, buffer);
2933 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2935 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2936 (tdata->validCipherOffsetInBits.len >> 3);
2938 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2940 reference_ciphertext,
2941 tdata->validCipherLenInBits.len,
2942 "KASUMI Ciphertext data not as expected");
2947 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2949 struct crypto_testsuite_params *ts_params = &testsuite_params;
2950 struct crypto_unittest_params *ut_params = &unittest_params;
2953 uint8_t *plaintext, *ciphertext;
2954 unsigned plaintext_pad_len;
2955 unsigned plaintext_len;
2957 /* Create KASUMI session */
2958 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2959 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2960 RTE_CRYPTO_CIPHER_KASUMI_F8,
2961 tdata->key.data, tdata->key.len,
2962 tdata->cipher_iv.len);
2966 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2967 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2969 /* Clear mbuf payload */
2970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2971 rte_pktmbuf_tailroom(ut_params->ibuf));
2973 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2974 /* Append data which is padded to a multiple */
2975 /* of the algorithms block size */
2976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2977 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2979 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2980 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2982 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2984 /* Create KASUMI operation */
2985 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2986 tdata->cipher_iv.len,
2987 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2988 tdata->validCipherOffsetInBits.len);
2992 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2994 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2996 ut_params->obuf = ut_params->op->sym->m_dst;
2997 if (ut_params->obuf)
2998 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3000 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3002 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3004 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3005 (tdata->validCipherOffsetInBits.len >> 3);
3007 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3009 reference_ciphertext,
3010 tdata->validCipherLenInBits.len,
3011 "KASUMI Ciphertext data not as expected");
3016 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3018 struct crypto_testsuite_params *ts_params = &testsuite_params;
3019 struct crypto_unittest_params *ut_params = &unittest_params;
3022 unsigned int plaintext_pad_len;
3023 unsigned int plaintext_len;
3025 const uint8_t *ciphertext;
3026 uint8_t buffer[2048];
3028 struct rte_cryptodev_info dev_info;
3030 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3031 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3032 printf("Device doesn't support scatter-gather. "
3037 /* Create KASUMI session */
3038 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3039 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3040 RTE_CRYPTO_CIPHER_KASUMI_F8,
3041 tdata->key.data, tdata->key.len,
3042 tdata->cipher_iv.len);
3046 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3047 /* Append data which is padded to a multiple */
3048 /* of the algorithms block size */
3049 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3051 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3052 plaintext_pad_len, 10, 0);
3053 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3054 plaintext_pad_len, 3, 0);
3056 /* Append data which is padded to a multiple */
3057 /* of the algorithms block size */
3058 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3060 /* Create KASUMI operation */
3061 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3062 tdata->cipher_iv.len,
3063 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3064 tdata->validCipherOffsetInBits.len);
3068 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3070 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3072 ut_params->obuf = ut_params->op->sym->m_dst;
3073 if (ut_params->obuf)
3074 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3075 plaintext_pad_len, buffer);
3077 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3078 tdata->validCipherOffsetInBits.len >> 3,
3079 plaintext_pad_len, buffer);
3081 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3082 (tdata->validCipherOffsetInBits.len >> 3);
3084 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3086 reference_ciphertext,
3087 tdata->validCipherLenInBits.len,
3088 "KASUMI Ciphertext data not as expected");
3094 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3096 struct crypto_testsuite_params *ts_params = &testsuite_params;
3097 struct crypto_unittest_params *ut_params = &unittest_params;
3100 uint8_t *ciphertext, *plaintext;
3101 unsigned ciphertext_pad_len;
3102 unsigned ciphertext_len;
3104 /* Create KASUMI session */
3105 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3106 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3107 RTE_CRYPTO_CIPHER_KASUMI_F8,
3108 tdata->key.data, tdata->key.len,
3109 tdata->cipher_iv.len);
3113 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3114 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3116 /* Clear mbuf payload */
3117 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3118 rte_pktmbuf_tailroom(ut_params->ibuf));
3120 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3121 /* Append data which is padded to a multiple */
3122 /* of the algorithms block size */
3123 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3124 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3125 ciphertext_pad_len);
3126 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3127 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3129 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3131 /* Create KASUMI operation */
3132 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3133 tdata->cipher_iv.len,
3134 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3135 tdata->validCipherOffsetInBits.len);
3139 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3141 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3143 ut_params->obuf = ut_params->op->sym->m_dst;
3144 if (ut_params->obuf)
3145 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3147 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3149 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3151 const uint8_t *reference_plaintext = tdata->plaintext.data +
3152 (tdata->validCipherOffsetInBits.len >> 3);
3154 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3156 reference_plaintext,
3157 tdata->validCipherLenInBits.len,
3158 "KASUMI Plaintext data not as expected");
3163 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3165 struct crypto_testsuite_params *ts_params = &testsuite_params;
3166 struct crypto_unittest_params *ut_params = &unittest_params;
3169 uint8_t *ciphertext, *plaintext;
3170 unsigned ciphertext_pad_len;
3171 unsigned ciphertext_len;
3173 /* Create KASUMI session */
3174 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3175 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3176 RTE_CRYPTO_CIPHER_KASUMI_F8,
3177 tdata->key.data, tdata->key.len,
3178 tdata->cipher_iv.len);
3182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3184 /* Clear mbuf payload */
3185 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3186 rte_pktmbuf_tailroom(ut_params->ibuf));
3188 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3189 /* Append data which is padded to a multiple */
3190 /* of the algorithms block size */
3191 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3192 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3193 ciphertext_pad_len);
3194 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3196 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3198 /* Create KASUMI operation */
3199 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3200 tdata->cipher_iv.len,
3201 tdata->ciphertext.len,
3202 tdata->validCipherOffsetInBits.len);
3206 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3208 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3210 ut_params->obuf = ut_params->op->sym->m_dst;
3211 if (ut_params->obuf)
3212 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3214 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3216 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3218 const uint8_t *reference_plaintext = tdata->plaintext.data +
3219 (tdata->validCipherOffsetInBits.len >> 3);
3221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3223 reference_plaintext,
3224 tdata->validCipherLenInBits.len,
3225 "KASUMI Plaintext data not as expected");
3230 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3232 struct crypto_testsuite_params *ts_params = &testsuite_params;
3233 struct crypto_unittest_params *ut_params = &unittest_params;
3236 uint8_t *plaintext, *ciphertext;
3237 unsigned plaintext_pad_len;
3238 unsigned plaintext_len;
3240 /* Create SNOW 3G session */
3241 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3242 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3243 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3244 tdata->key.data, tdata->key.len,
3245 tdata->cipher_iv.len);
3249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3251 /* Clear mbuf payload */
3252 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3253 rte_pktmbuf_tailroom(ut_params->ibuf));
3255 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3256 /* Append data which is padded to a multiple of */
3257 /* the algorithms block size */
3258 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3259 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3261 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3263 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3265 /* Create SNOW 3G operation */
3266 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3267 tdata->cipher_iv.len,
3268 tdata->validCipherLenInBits.len,
3273 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3275 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3277 ut_params->obuf = ut_params->op->sym->m_dst;
3278 if (ut_params->obuf)
3279 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3281 ciphertext = plaintext;
3283 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3286 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3288 tdata->ciphertext.data,
3289 tdata->validDataLenInBits.len,
3290 "SNOW 3G Ciphertext data not as expected");
3296 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3298 struct crypto_testsuite_params *ts_params = &testsuite_params;
3299 struct crypto_unittest_params *ut_params = &unittest_params;
3300 uint8_t *plaintext, *ciphertext;
3303 unsigned plaintext_pad_len;
3304 unsigned plaintext_len;
3306 /* Create SNOW 3G session */
3307 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3308 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3309 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3310 tdata->key.data, tdata->key.len,
3311 tdata->cipher_iv.len);
3315 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3316 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3318 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3319 "Failed to allocate input buffer in mempool");
3320 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3321 "Failed to allocate output buffer in mempool");
3323 /* Clear mbuf payload */
3324 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3325 rte_pktmbuf_tailroom(ut_params->ibuf));
3327 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3328 /* Append data which is padded to a multiple of */
3329 /* the algorithms block size */
3330 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3331 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3333 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3334 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3336 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3338 /* Create SNOW 3G operation */
3339 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3340 tdata->cipher_iv.len,
3341 tdata->validCipherLenInBits.len,
3346 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3348 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3350 ut_params->obuf = ut_params->op->sym->m_dst;
3351 if (ut_params->obuf)
3352 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3354 ciphertext = plaintext;
3356 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3359 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3361 tdata->ciphertext.data,
3362 tdata->validDataLenInBits.len,
3363 "SNOW 3G Ciphertext data not as expected");
3368 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3370 struct crypto_testsuite_params *ts_params = &testsuite_params;
3371 struct crypto_unittest_params *ut_params = &unittest_params;
3374 unsigned int plaintext_pad_len;
3375 unsigned int plaintext_len;
3376 uint8_t buffer[10000];
3377 const uint8_t *ciphertext;
3379 struct rte_cryptodev_info dev_info;
3381 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3382 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3383 printf("Device doesn't support scatter-gather. "
3388 /* Create SNOW 3G session */
3389 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3390 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3391 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3392 tdata->key.data, tdata->key.len,
3393 tdata->cipher_iv.len);
3397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3398 /* Append data which is padded to a multiple of */
3399 /* the algorithms block size */
3400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3402 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3403 plaintext_pad_len, 10, 0);
3404 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3405 plaintext_pad_len, 3, 0);
3407 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3408 "Failed to allocate input buffer in mempool");
3409 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3410 "Failed to allocate output buffer in mempool");
3412 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3414 /* Create SNOW 3G operation */
3415 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3416 tdata->cipher_iv.len,
3417 tdata->validCipherLenInBits.len,
3422 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3426 ut_params->obuf = ut_params->op->sym->m_dst;
3427 if (ut_params->obuf)
3428 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3429 plaintext_len, buffer);
3431 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3432 plaintext_len, buffer);
3434 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3437 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3439 tdata->ciphertext.data,
3440 tdata->validDataLenInBits.len,
3441 "SNOW 3G Ciphertext data not as expected");
3446 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3448 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3450 uint8_t curr_byte, prev_byte;
3451 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3452 uint8_t lower_byte_mask = (1 << offset) - 1;
3455 prev_byte = buffer[0];
3456 buffer[0] >>= offset;
3458 for (i = 1; i < length_in_bytes; i++) {
3459 curr_byte = buffer[i];
3460 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3461 (curr_byte >> offset);
3462 prev_byte = curr_byte;
3467 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3469 struct crypto_testsuite_params *ts_params = &testsuite_params;
3470 struct crypto_unittest_params *ut_params = &unittest_params;
3471 uint8_t *plaintext, *ciphertext;
3473 uint32_t plaintext_len;
3474 uint32_t plaintext_pad_len;
3475 uint8_t extra_offset = 4;
3476 uint8_t *expected_ciphertext_shifted;
3478 /* Create SNOW 3G session */
3479 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3480 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3481 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3482 tdata->key.data, tdata->key.len,
3483 tdata->cipher_iv.len);
3487 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3488 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3490 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3491 "Failed to allocate input buffer in mempool");
3492 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3493 "Failed to allocate output buffer in mempool");
3495 /* Clear mbuf payload */
3496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3497 rte_pktmbuf_tailroom(ut_params->ibuf));
3499 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3501 * Append data which is padded to a
3502 * multiple of the algorithms block size
3504 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3506 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3509 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3511 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3512 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3514 #ifdef RTE_APP_TEST_DEBUG
3515 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3517 /* Create SNOW 3G operation */
3518 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3519 tdata->cipher_iv.len,
3520 tdata->validCipherLenInBits.len,
3525 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3527 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3529 ut_params->obuf = ut_params->op->sym->m_dst;
3530 if (ut_params->obuf)
3531 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3533 ciphertext = plaintext;
3535 #ifdef RTE_APP_TEST_DEBUG
3536 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3539 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3541 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3542 "failed to reserve memory for ciphertext shifted\n");
3544 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3545 ceil_byte_length(tdata->ciphertext.len));
3546 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3549 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3551 expected_ciphertext_shifted,
3552 tdata->validDataLenInBits.len,
3554 "SNOW 3G Ciphertext data not as expected");
3558 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3560 struct crypto_testsuite_params *ts_params = &testsuite_params;
3561 struct crypto_unittest_params *ut_params = &unittest_params;
3565 uint8_t *plaintext, *ciphertext;
3566 unsigned ciphertext_pad_len;
3567 unsigned ciphertext_len;
3569 /* Create SNOW 3G session */
3570 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3571 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3572 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3573 tdata->key.data, tdata->key.len,
3574 tdata->cipher_iv.len);
3578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3580 /* Clear mbuf payload */
3581 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3582 rte_pktmbuf_tailroom(ut_params->ibuf));
3584 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3585 /* Append data which is padded to a multiple of */
3586 /* the algorithms block size */
3587 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3588 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3589 ciphertext_pad_len);
3590 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3592 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3594 /* Create SNOW 3G operation */
3595 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3596 tdata->cipher_iv.len,
3597 tdata->validCipherLenInBits.len,
3602 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3604 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3605 ut_params->obuf = ut_params->op->sym->m_dst;
3606 if (ut_params->obuf)
3607 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3609 plaintext = ciphertext;
3611 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3614 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3615 tdata->plaintext.data,
3616 tdata->validDataLenInBits.len,
3617 "SNOW 3G Plaintext data not as expected");
3621 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3623 struct crypto_testsuite_params *ts_params = &testsuite_params;
3624 struct crypto_unittest_params *ut_params = &unittest_params;
3628 uint8_t *plaintext, *ciphertext;
3629 unsigned ciphertext_pad_len;
3630 unsigned ciphertext_len;
3632 /* Create SNOW 3G session */
3633 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3634 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3635 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3636 tdata->key.data, tdata->key.len,
3637 tdata->cipher_iv.len);
3641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3642 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3644 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3645 "Failed to allocate input buffer");
3646 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3647 "Failed to allocate output buffer");
3649 /* Clear mbuf payload */
3650 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3651 rte_pktmbuf_tailroom(ut_params->ibuf));
3653 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3654 rte_pktmbuf_tailroom(ut_params->obuf));
3656 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3657 /* Append data which is padded to a multiple of */
3658 /* the algorithms block size */
3659 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3661 ciphertext_pad_len);
3662 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3663 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3665 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3667 /* Create SNOW 3G operation */
3668 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3669 tdata->cipher_iv.len,
3670 tdata->validCipherLenInBits.len,
3675 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3677 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3678 ut_params->obuf = ut_params->op->sym->m_dst;
3679 if (ut_params->obuf)
3680 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3682 plaintext = ciphertext;
3684 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3687 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3688 tdata->plaintext.data,
3689 tdata->validDataLenInBits.len,
3690 "SNOW 3G Plaintext data not as expected");
3695 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3697 struct crypto_testsuite_params *ts_params = &testsuite_params;
3698 struct crypto_unittest_params *ut_params = &unittest_params;
3702 uint8_t *plaintext, *ciphertext;
3703 unsigned int plaintext_pad_len;
3704 unsigned int plaintext_len;
3706 struct rte_cryptodev_sym_capability_idx cap_idx;
3708 /* Check if device supports ZUC EEA3 */
3709 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3710 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3712 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3716 /* Check if device supports ZUC EIA3 */
3717 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3718 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3720 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3724 /* Create ZUC session */
3725 retval = create_zuc_cipher_auth_encrypt_generate_session(
3726 ts_params->valid_devs[0],
3730 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3732 /* clear mbuf payload */
3733 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3734 rte_pktmbuf_tailroom(ut_params->ibuf));
3736 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3737 /* Append data which is padded to a multiple of */
3738 /* the algorithms block size */
3739 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3740 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3742 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3744 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3746 /* Create ZUC operation */
3747 retval = create_zuc_cipher_hash_generate_operation(tdata);
3751 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3753 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3754 ut_params->obuf = ut_params->op->sym->m_src;
3755 if (ut_params->obuf)
3756 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3758 ciphertext = plaintext;
3760 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3762 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3764 tdata->ciphertext.data,
3765 tdata->validDataLenInBits.len,
3766 "ZUC Ciphertext data not as expected");
3768 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3769 + plaintext_pad_len;
3772 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3776 "ZUC Generated auth tag not as expected");
3781 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3783 struct crypto_testsuite_params *ts_params = &testsuite_params;
3784 struct crypto_unittest_params *ut_params = &unittest_params;
3788 uint8_t *plaintext, *ciphertext;
3789 unsigned plaintext_pad_len;
3790 unsigned plaintext_len;
3792 /* Create SNOW 3G session */
3793 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3795 RTE_CRYPTO_AUTH_OP_GENERATE,
3796 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3797 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3798 tdata->key.data, tdata->key.len,
3799 tdata->auth_iv.len, tdata->digest.len,
3800 tdata->cipher_iv.len);
3803 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3805 /* clear mbuf payload */
3806 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3807 rte_pktmbuf_tailroom(ut_params->ibuf));
3809 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3810 /* Append data which is padded to a multiple of */
3811 /* the algorithms block size */
3812 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3813 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3815 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3817 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3819 /* Create SNOW 3G operation */
3820 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3821 tdata->digest.len, tdata->auth_iv.data,
3823 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3824 tdata->cipher_iv.data, tdata->cipher_iv.len,
3825 tdata->validCipherLenInBits.len,
3827 tdata->validAuthLenInBits.len,
3833 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3835 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3836 ut_params->obuf = ut_params->op->sym->m_src;
3837 if (ut_params->obuf)
3838 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3840 ciphertext = plaintext;
3842 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3844 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3846 tdata->ciphertext.data,
3847 tdata->validDataLenInBits.len,
3848 "SNOW 3G Ciphertext data not as expected");
3850 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3851 + plaintext_pad_len;
3854 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3857 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3858 "SNOW 3G Generated auth tag not as expected");
3862 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3864 struct crypto_testsuite_params *ts_params = &testsuite_params;
3865 struct crypto_unittest_params *ut_params = &unittest_params;
3869 uint8_t *plaintext, *ciphertext;
3870 unsigned plaintext_pad_len;
3871 unsigned plaintext_len;
3873 /* Create SNOW 3G session */
3874 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3875 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3876 RTE_CRYPTO_AUTH_OP_GENERATE,
3877 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3878 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3879 tdata->key.data, tdata->key.len,
3880 tdata->auth_iv.len, tdata->digest.len,
3881 tdata->cipher_iv.len);
3885 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3887 /* clear mbuf payload */
3888 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3889 rte_pktmbuf_tailroom(ut_params->ibuf));
3891 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3892 /* Append data which is padded to a multiple of */
3893 /* the algorithms block size */
3894 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3895 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3897 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3899 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3901 /* Create SNOW 3G operation */
3902 retval = create_wireless_algo_auth_cipher_operation(
3904 tdata->cipher_iv.data, tdata->cipher_iv.len,
3905 tdata->auth_iv.data, tdata->auth_iv.len,
3907 tdata->validCipherLenInBits.len,
3909 tdata->validAuthLenInBits.len,
3915 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3917 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3918 ut_params->obuf = ut_params->op->sym->m_src;
3919 if (ut_params->obuf)
3920 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3922 ciphertext = plaintext;
3924 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3925 + plaintext_pad_len;
3926 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3929 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3931 tdata->ciphertext.data,
3932 tdata->validDataLenInBits.len,
3933 "SNOW 3G Ciphertext data not as expected");
3936 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3939 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3940 "SNOW 3G Generated auth tag not as expected");
3945 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3947 struct crypto_testsuite_params *ts_params = &testsuite_params;
3948 struct crypto_unittest_params *ut_params = &unittest_params;
3952 uint8_t *plaintext, *ciphertext;
3953 unsigned plaintext_pad_len;
3954 unsigned plaintext_len;
3956 /* Create KASUMI session */
3957 retval = create_wireless_algo_auth_cipher_session(
3958 ts_params->valid_devs[0],
3959 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3960 RTE_CRYPTO_AUTH_OP_GENERATE,
3961 RTE_CRYPTO_AUTH_KASUMI_F9,
3962 RTE_CRYPTO_CIPHER_KASUMI_F8,
3963 tdata->key.data, tdata->key.len,
3964 0, tdata->digest.len,
3965 tdata->cipher_iv.len);
3968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3970 /* clear mbuf payload */
3971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3972 rte_pktmbuf_tailroom(ut_params->ibuf));
3974 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3975 /* Append data which is padded to a multiple of */
3976 /* the algorithms block size */
3977 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3978 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3980 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3982 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3984 /* Create KASUMI operation */
3985 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3986 tdata->cipher_iv.data, tdata->cipher_iv.len,
3989 tdata->validCipherLenInBits.len,
3990 tdata->validCipherOffsetInBits.len,
3991 tdata->validAuthLenInBits.len,
3998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4001 if (ut_params->op->sym->m_dst)
4002 ut_params->obuf = ut_params->op->sym->m_dst;
4004 ut_params->obuf = ut_params->op->sym->m_src;
4006 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4007 tdata->validCipherOffsetInBits.len >> 3);
4009 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4010 (tdata->validCipherOffsetInBits.len >> 3);
4012 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4014 reference_ciphertext,
4015 tdata->validCipherLenInBits.len,
4016 "KASUMI Ciphertext data not as expected");
4017 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4018 + plaintext_pad_len;
4021 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4024 DIGEST_BYTE_LENGTH_KASUMI_F9,
4025 "KASUMI Generated auth tag not as expected");
4030 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4032 struct crypto_testsuite_params *ts_params = &testsuite_params;
4033 struct crypto_unittest_params *ut_params = &unittest_params;
4037 uint8_t *plaintext, *ciphertext;
4038 unsigned plaintext_pad_len;
4039 unsigned plaintext_len;
4041 /* Create KASUMI session */
4042 retval = create_wireless_algo_cipher_auth_session(
4043 ts_params->valid_devs[0],
4044 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4045 RTE_CRYPTO_AUTH_OP_GENERATE,
4046 RTE_CRYPTO_AUTH_KASUMI_F9,
4047 RTE_CRYPTO_CIPHER_KASUMI_F8,
4048 tdata->key.data, tdata->key.len,
4049 0, tdata->digest.len,
4050 tdata->cipher_iv.len);
4054 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4056 /* clear mbuf payload */
4057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4058 rte_pktmbuf_tailroom(ut_params->ibuf));
4060 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4061 /* Append data which is padded to a multiple of */
4062 /* the algorithms block size */
4063 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4064 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4066 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4068 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4070 /* Create KASUMI operation */
4071 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4072 tdata->digest.len, NULL, 0,
4073 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4074 tdata->cipher_iv.data, tdata->cipher_iv.len,
4075 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4076 tdata->validCipherOffsetInBits.len,
4077 tdata->validAuthLenInBits.len,
4083 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4087 if (ut_params->op->sym->m_dst)
4088 ut_params->obuf = ut_params->op->sym->m_dst;
4090 ut_params->obuf = ut_params->op->sym->m_src;
4092 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4093 tdata->validCipherOffsetInBits.len >> 3);
4095 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4096 + plaintext_pad_len;
4098 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4099 (tdata->validCipherOffsetInBits.len >> 3);
4101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4103 reference_ciphertext,
4104 tdata->validCipherLenInBits.len,
4105 "KASUMI Ciphertext data not as expected");
4108 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4111 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4112 "KASUMI Generated auth tag not as expected");
4117 test_zuc_encryption(const struct wireless_test_data *tdata)
4119 struct crypto_testsuite_params *ts_params = &testsuite_params;
4120 struct crypto_unittest_params *ut_params = &unittest_params;
4123 uint8_t *plaintext, *ciphertext;
4124 unsigned plaintext_pad_len;
4125 unsigned plaintext_len;
4127 struct rte_cryptodev_sym_capability_idx cap_idx;
4129 /* Check if device supports ZUC EEA3 */
4130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4131 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4133 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4137 /* Create ZUC session */
4138 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4139 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4140 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4141 tdata->key.data, tdata->key.len,
4142 tdata->cipher_iv.len);
4146 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4148 /* Clear mbuf payload */
4149 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4150 rte_pktmbuf_tailroom(ut_params->ibuf));
4152 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4153 /* Append data which is padded to a multiple */
4154 /* of the algorithms block size */
4155 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4156 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4158 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4160 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4162 /* Create ZUC operation */
4163 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4164 tdata->cipher_iv.len,
4165 tdata->plaintext.len,
4170 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4172 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4174 ut_params->obuf = ut_params->op->sym->m_dst;
4175 if (ut_params->obuf)
4176 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4178 ciphertext = plaintext;
4180 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4183 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4185 tdata->ciphertext.data,
4186 tdata->validCipherLenInBits.len,
4187 "ZUC Ciphertext data not as expected");
4192 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4194 struct crypto_testsuite_params *ts_params = &testsuite_params;
4195 struct crypto_unittest_params *ut_params = &unittest_params;
4199 unsigned int plaintext_pad_len;
4200 unsigned int plaintext_len;
4201 const uint8_t *ciphertext;
4202 uint8_t ciphertext_buffer[2048];
4203 struct rte_cryptodev_info dev_info;
4205 struct rte_cryptodev_sym_capability_idx cap_idx;
4207 /* Check if device supports ZUC EEA3 */
4208 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4209 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4211 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4215 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4216 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4217 printf("Device doesn't support scatter-gather. "
4222 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4224 /* Append data which is padded to a multiple */
4225 /* of the algorithms block size */
4226 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4228 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4229 plaintext_pad_len, 10, 0);
4231 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4232 tdata->plaintext.data);
4234 /* Create ZUC session */
4235 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4236 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4237 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4238 tdata->key.data, tdata->key.len,
4239 tdata->cipher_iv.len);
4243 /* Clear mbuf payload */
4245 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4247 /* Create ZUC operation */
4248 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4249 tdata->cipher_iv.len, tdata->plaintext.len,
4254 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4256 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4258 ut_params->obuf = ut_params->op->sym->m_dst;
4259 if (ut_params->obuf)
4260 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4261 0, plaintext_len, ciphertext_buffer);
4263 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4264 0, plaintext_len, ciphertext_buffer);
4267 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4270 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4272 tdata->ciphertext.data,
4273 tdata->validCipherLenInBits.len,
4274 "ZUC Ciphertext data not as expected");
4280 test_zuc_authentication(const struct wireless_test_data *tdata)
4282 struct crypto_testsuite_params *ts_params = &testsuite_params;
4283 struct crypto_unittest_params *ut_params = &unittest_params;
4286 unsigned plaintext_pad_len;
4287 unsigned plaintext_len;
4290 struct rte_cryptodev_sym_capability_idx cap_idx;
4292 /* Check if device supports ZUC EIA3 */
4293 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4294 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4300 /* Create ZUC session */
4301 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4302 tdata->key.data, tdata->key.len,
4303 tdata->auth_iv.len, tdata->digest.len,
4304 RTE_CRYPTO_AUTH_OP_GENERATE,
4305 RTE_CRYPTO_AUTH_ZUC_EIA3);
4309 /* alloc mbuf and set payload */
4310 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4312 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4313 rte_pktmbuf_tailroom(ut_params->ibuf));
4315 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4316 /* Append data which is padded to a multiple of */
4317 /* the algorithms block size */
4318 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4319 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4321 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4323 /* Create ZUC operation */
4324 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4325 tdata->auth_iv.data, tdata->auth_iv.len,
4326 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4327 tdata->validAuthLenInBits.len,
4332 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4334 ut_params->obuf = ut_params->op->sym->m_src;
4335 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4336 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4337 + plaintext_pad_len;
4340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4343 DIGEST_BYTE_LENGTH_KASUMI_F9,
4344 "ZUC Generated auth tag not as expected");
4350 test_kasumi_encryption_test_case_1(void)
4352 return test_kasumi_encryption(&kasumi_test_case_1);
4356 test_kasumi_encryption_test_case_1_sgl(void)
4358 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4362 test_kasumi_encryption_test_case_1_oop(void)
4364 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4368 test_kasumi_encryption_test_case_1_oop_sgl(void)
4370 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4374 test_kasumi_encryption_test_case_2(void)
4376 return test_kasumi_encryption(&kasumi_test_case_2);
4380 test_kasumi_encryption_test_case_3(void)
4382 return test_kasumi_encryption(&kasumi_test_case_3);
4386 test_kasumi_encryption_test_case_4(void)
4388 return test_kasumi_encryption(&kasumi_test_case_4);
4392 test_kasumi_encryption_test_case_5(void)
4394 return test_kasumi_encryption(&kasumi_test_case_5);
4398 test_kasumi_decryption_test_case_1(void)
4400 return test_kasumi_decryption(&kasumi_test_case_1);
4404 test_kasumi_decryption_test_case_1_oop(void)
4406 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4410 test_kasumi_decryption_test_case_2(void)
4412 return test_kasumi_decryption(&kasumi_test_case_2);
4416 test_kasumi_decryption_test_case_3(void)
4418 return test_kasumi_decryption(&kasumi_test_case_3);
4422 test_kasumi_decryption_test_case_4(void)
4424 return test_kasumi_decryption(&kasumi_test_case_4);
4428 test_kasumi_decryption_test_case_5(void)
4430 return test_kasumi_decryption(&kasumi_test_case_5);
4433 test_snow3g_encryption_test_case_1(void)
4435 return test_snow3g_encryption(&snow3g_test_case_1);
4439 test_snow3g_encryption_test_case_1_oop(void)
4441 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4445 test_snow3g_encryption_test_case_1_oop_sgl(void)
4447 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4452 test_snow3g_encryption_test_case_1_offset_oop(void)
4454 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4458 test_snow3g_encryption_test_case_2(void)
4460 return test_snow3g_encryption(&snow3g_test_case_2);
4464 test_snow3g_encryption_test_case_3(void)
4466 return test_snow3g_encryption(&snow3g_test_case_3);
4470 test_snow3g_encryption_test_case_4(void)
4472 return test_snow3g_encryption(&snow3g_test_case_4);
4476 test_snow3g_encryption_test_case_5(void)
4478 return test_snow3g_encryption(&snow3g_test_case_5);
4482 test_snow3g_decryption_test_case_1(void)
4484 return test_snow3g_decryption(&snow3g_test_case_1);
4488 test_snow3g_decryption_test_case_1_oop(void)
4490 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4494 test_snow3g_decryption_test_case_2(void)
4496 return test_snow3g_decryption(&snow3g_test_case_2);
4500 test_snow3g_decryption_test_case_3(void)
4502 return test_snow3g_decryption(&snow3g_test_case_3);
4506 test_snow3g_decryption_test_case_4(void)
4508 return test_snow3g_decryption(&snow3g_test_case_4);
4512 test_snow3g_decryption_test_case_5(void)
4514 return test_snow3g_decryption(&snow3g_test_case_5);
4517 test_snow3g_cipher_auth_test_case_1(void)
4519 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4523 test_snow3g_auth_cipher_test_case_1(void)
4525 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4529 test_kasumi_auth_cipher_test_case_1(void)
4531 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4535 test_kasumi_cipher_auth_test_case_1(void)
4537 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4541 test_zuc_encryption_test_case_1(void)
4543 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4547 test_zuc_encryption_test_case_2(void)
4549 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4553 test_zuc_encryption_test_case_3(void)
4555 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4559 test_zuc_encryption_test_case_4(void)
4561 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4565 test_zuc_encryption_test_case_5(void)
4567 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4571 test_zuc_encryption_test_case_6_sgl(void)
4573 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4577 test_zuc_hash_generate_test_case_1(void)
4579 return test_zuc_authentication(&zuc_test_case_auth_1b);
4583 test_zuc_hash_generate_test_case_2(void)
4585 return test_zuc_authentication(&zuc_test_case_auth_90b);
4589 test_zuc_hash_generate_test_case_3(void)
4591 return test_zuc_authentication(&zuc_test_case_auth_577b);
4595 test_zuc_hash_generate_test_case_4(void)
4597 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4601 test_zuc_hash_generate_test_case_5(void)
4603 return test_zuc_authentication(&zuc_test_auth_5670b);
4607 test_zuc_hash_generate_test_case_6(void)
4609 return test_zuc_authentication(&zuc_test_case_auth_128b);
4613 test_zuc_hash_generate_test_case_7(void)
4615 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4619 test_zuc_hash_generate_test_case_8(void)
4621 return test_zuc_authentication(&zuc_test_case_auth_584b);
4625 test_zuc_cipher_auth_test_case_1(void)
4627 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4631 test_zuc_cipher_auth_test_case_2(void)
4633 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4637 test_3DES_chain_qat_all(void)
4639 struct crypto_testsuite_params *ts_params = &testsuite_params;
4642 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4643 ts_params->op_mpool,
4644 ts_params->session_mpool,
4645 ts_params->valid_devs[0],
4646 rte_cryptodev_driver_id_get(
4647 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4648 BLKCIPHER_3DES_CHAIN_TYPE);
4650 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4652 return TEST_SUCCESS;
4656 test_DES_cipheronly_qat_all(void)
4658 struct crypto_testsuite_params *ts_params = &testsuite_params;
4661 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4662 ts_params->op_mpool,
4663 ts_params->session_mpool,
4664 ts_params->valid_devs[0],
4665 rte_cryptodev_driver_id_get(
4666 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4667 BLKCIPHER_DES_CIPHERONLY_TYPE);
4669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4671 return TEST_SUCCESS;
4675 test_DES_cipheronly_openssl_all(void)
4677 struct crypto_testsuite_params *ts_params = &testsuite_params;
4680 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4681 ts_params->op_mpool,
4682 ts_params->session_mpool,
4683 ts_params->valid_devs[0],
4684 rte_cryptodev_driver_id_get(
4685 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4686 BLKCIPHER_DES_CIPHERONLY_TYPE);
4688 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4690 return TEST_SUCCESS;
4694 test_DES_docsis_openssl_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_OPENSSL_PMD)),
4705 BLKCIPHER_DES_DOCSIS_TYPE);
4707 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4709 return TEST_SUCCESS;
4713 test_DES_cipheronly_mb_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_AESNI_MB_PMD)),
4724 BLKCIPHER_DES_CIPHERONLY_TYPE);
4726 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4728 return TEST_SUCCESS;
4732 test_DES_docsis_mb_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_AESNI_MB_PMD)),
4743 BLKCIPHER_DES_DOCSIS_TYPE);
4745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4747 return TEST_SUCCESS;
4751 test_3DES_chain_dpaa2_sec_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_DPAA2_SEC_PMD)),
4762 BLKCIPHER_3DES_CHAIN_TYPE);
4764 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4766 return TEST_SUCCESS;
4770 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD)),
4781 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4783 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4785 return TEST_SUCCESS;
4789 test_3DES_cipheronly_qat_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_QAT_SYM_PMD)),
4800 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4802 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4804 return TEST_SUCCESS;
4808 test_3DES_chain_openssl_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_OPENSSL_PMD)),
4819 BLKCIPHER_3DES_CHAIN_TYPE);
4821 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4823 return TEST_SUCCESS;
4827 test_3DES_cipheronly_openssl_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_OPENSSL_PMD)),
4838 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4840 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4842 return TEST_SUCCESS;
4845 /* ***** AES-GCM Tests ***** */
4848 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4849 const uint8_t *key, const uint8_t key_len,
4850 const uint16_t aad_len, const uint8_t auth_len,
4853 uint8_t aead_key[key_len];
4855 struct crypto_testsuite_params *ts_params = &testsuite_params;
4856 struct crypto_unittest_params *ut_params = &unittest_params;
4858 memcpy(aead_key, key, key_len);
4860 /* Setup AEAD Parameters */
4861 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4862 ut_params->aead_xform.next = NULL;
4863 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4864 ut_params->aead_xform.aead.op = op;
4865 ut_params->aead_xform.aead.key.data = aead_key;
4866 ut_params->aead_xform.aead.key.length = key_len;
4867 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4868 ut_params->aead_xform.aead.iv.length = iv_len;
4869 ut_params->aead_xform.aead.digest_length = auth_len;
4870 ut_params->aead_xform.aead.aad_length = aad_len;
4872 TEST_HEXDUMP(stdout, "key:", key, key_len);
4874 /* Create Crypto session*/
4875 ut_params->sess = rte_cryptodev_sym_session_create(
4876 ts_params->session_mpool);
4878 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
4879 &ut_params->aead_xform, ts_params->session_mpool);
4881 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4887 create_gcm_xforms(struct rte_crypto_op *op,
4888 enum rte_crypto_aead_operation aead_op,
4889 uint8_t *key, const uint8_t key_len,
4890 const uint8_t aad_len, const uint8_t auth_len,
4893 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4894 "failed to allocate space for crypto transform");
4896 struct rte_crypto_sym_op *sym_op = op->sym;
4898 /* Setup AEAD Parameters */
4899 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4900 sym_op->xform->next = NULL;
4901 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4902 sym_op->xform->aead.op = aead_op;
4903 sym_op->xform->aead.key.data = key;
4904 sym_op->xform->aead.key.length = key_len;
4905 sym_op->xform->aead.iv.offset = IV_OFFSET;
4906 sym_op->xform->aead.iv.length = iv_len;
4907 sym_op->xform->aead.digest_length = auth_len;
4908 sym_op->xform->aead.aad_length = aad_len;
4910 TEST_HEXDUMP(stdout, "key:", key, key_len);
4916 create_gcm_operation(enum rte_crypto_aead_operation op,
4917 const struct gcm_test_data *tdata)
4919 struct crypto_testsuite_params *ts_params = &testsuite_params;
4920 struct crypto_unittest_params *ut_params = &unittest_params;
4922 uint8_t *plaintext, *ciphertext;
4923 unsigned int aad_pad_len, plaintext_pad_len;
4925 /* Generate Crypto op data structure */
4926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4928 TEST_ASSERT_NOT_NULL(ut_params->op,
4929 "Failed to allocate symmetric crypto operation struct");
4931 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4933 /* Append aad data */
4934 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4935 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4937 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4938 "no room to append aad");
4940 sym_op->aead.aad.phys_addr =
4941 rte_pktmbuf_mtophys(ut_params->ibuf);
4942 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4943 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4946 /* Append IV at the end of the crypto operation*/
4947 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4948 uint8_t *, IV_OFFSET);
4950 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4951 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4954 /* Append plaintext/ciphertext */
4955 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4956 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4957 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4959 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4961 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4962 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4963 tdata->plaintext.len);
4965 if (ut_params->obuf) {
4966 ciphertext = (uint8_t *)rte_pktmbuf_append(
4968 plaintext_pad_len + aad_pad_len);
4969 TEST_ASSERT_NOT_NULL(ciphertext,
4970 "no room to append ciphertext");
4972 memset(ciphertext + aad_pad_len, 0,
4973 tdata->ciphertext.len);
4976 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4977 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4979 TEST_ASSERT_NOT_NULL(ciphertext,
4980 "no room to append ciphertext");
4982 memcpy(ciphertext, tdata->ciphertext.data,
4983 tdata->ciphertext.len);
4984 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4985 tdata->ciphertext.len);
4987 if (ut_params->obuf) {
4988 plaintext = (uint8_t *)rte_pktmbuf_append(
4990 plaintext_pad_len + aad_pad_len);
4991 TEST_ASSERT_NOT_NULL(plaintext,
4992 "no room to append plaintext");
4994 memset(plaintext + aad_pad_len, 0,
4995 tdata->plaintext.len);
4999 /* Append digest data */
5000 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5001 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5002 ut_params->obuf ? ut_params->obuf :
5004 tdata->auth_tag.len);
5005 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5006 "no room to append digest");
5007 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5008 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5009 ut_params->obuf ? ut_params->obuf :
5014 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5015 ut_params->ibuf, tdata->auth_tag.len);
5016 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5017 "no room to append digest");
5018 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5020 plaintext_pad_len + aad_pad_len);
5022 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5023 tdata->auth_tag.len);
5024 TEST_HEXDUMP(stdout, "digest:",
5025 sym_op->aead.digest.data,
5026 tdata->auth_tag.len);
5029 sym_op->aead.data.length = tdata->plaintext.len;
5030 sym_op->aead.data.offset = aad_pad_len;
5036 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
5038 struct crypto_testsuite_params *ts_params = &testsuite_params;
5039 struct crypto_unittest_params *ut_params = &unittest_params;
5042 uint8_t *ciphertext, *auth_tag;
5043 uint16_t plaintext_pad_len;
5046 /* Create GCM session */
5047 retval = create_gcm_session(ts_params->valid_devs[0],
5048 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5049 tdata->key.data, tdata->key.len,
5050 tdata->aad.len, tdata->auth_tag.len,
5055 if (tdata->aad.len > MBUF_SIZE) {
5056 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5057 /* Populate full size of add data */
5058 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5059 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5061 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5063 /* clear mbuf payload */
5064 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5065 rte_pktmbuf_tailroom(ut_params->ibuf));
5067 /* Create GCM operation */
5068 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5072 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5074 ut_params->op->sym->m_src = ut_params->ibuf;
5076 /* Process crypto operation */
5077 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5078 ut_params->op), "failed to process sym crypto op");
5080 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5081 "crypto op processing failed");
5083 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5085 if (ut_params->op->sym->m_dst) {
5086 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5088 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5089 uint8_t *, plaintext_pad_len);
5091 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5093 ut_params->op->sym->cipher.data.offset);
5094 auth_tag = ciphertext + plaintext_pad_len;
5097 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5098 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5101 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5103 tdata->ciphertext.data,
5104 tdata->ciphertext.len,
5105 "GCM Ciphertext data not as expected");
5107 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5109 tdata->auth_tag.data,
5110 tdata->auth_tag.len,
5111 "GCM Generated auth tag not as expected");
5118 test_AES_GCM_authenticated_encryption_test_case_1(void)
5120 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5124 test_AES_GCM_authenticated_encryption_test_case_2(void)
5126 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5130 test_AES_GCM_authenticated_encryption_test_case_3(void)
5132 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5136 test_AES_GCM_authenticated_encryption_test_case_4(void)
5138 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5142 test_AES_GCM_authenticated_encryption_test_case_5(void)
5144 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5148 test_AES_GCM_authenticated_encryption_test_case_6(void)
5150 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5154 test_AES_GCM_authenticated_encryption_test_case_7(void)
5156 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5160 test_AES_GCM_auth_encryption_test_case_192_1(void)
5162 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
5166 test_AES_GCM_auth_encryption_test_case_192_2(void)
5168 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
5172 test_AES_GCM_auth_encryption_test_case_192_3(void)
5174 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
5178 test_AES_GCM_auth_encryption_test_case_192_4(void)
5180 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
5184 test_AES_GCM_auth_encryption_test_case_192_5(void)
5186 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
5190 test_AES_GCM_auth_encryption_test_case_192_6(void)
5192 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
5196 test_AES_GCM_auth_encryption_test_case_192_7(void)
5198 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
5202 test_AES_GCM_auth_encryption_test_case_256_1(void)
5204 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5208 test_AES_GCM_auth_encryption_test_case_256_2(void)
5210 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5214 test_AES_GCM_auth_encryption_test_case_256_3(void)
5216 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5220 test_AES_GCM_auth_encryption_test_case_256_4(void)
5222 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5226 test_AES_GCM_auth_encryption_test_case_256_5(void)
5228 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5232 test_AES_GCM_auth_encryption_test_case_256_6(void)
5234 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5238 test_AES_GCM_auth_encryption_test_case_256_7(void)
5240 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5244 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5246 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5250 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5252 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5256 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5258 struct crypto_testsuite_params *ts_params = &testsuite_params;
5259 struct crypto_unittest_params *ut_params = &unittest_params;
5265 /* Create GCM session */
5266 retval = create_gcm_session(ts_params->valid_devs[0],
5267 RTE_CRYPTO_AEAD_OP_DECRYPT,
5268 tdata->key.data, tdata->key.len,
5269 tdata->aad.len, tdata->auth_tag.len,
5274 /* alloc mbuf and set payload */
5275 if (tdata->aad.len > MBUF_SIZE) {
5276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5277 /* Populate full size of add data */
5278 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5279 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5281 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5283 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5284 rte_pktmbuf_tailroom(ut_params->ibuf));
5286 /* Create GCM operation */
5287 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5291 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5293 ut_params->op->sym->m_src = ut_params->ibuf;
5295 /* Process crypto operation */
5296 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5297 ut_params->op), "failed to process sym crypto op");
5299 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5300 "crypto op processing failed");
5302 if (ut_params->op->sym->m_dst)
5303 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5306 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5308 ut_params->op->sym->cipher.data.offset);
5310 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5315 tdata->plaintext.data,
5316 tdata->plaintext.len,
5317 "GCM plaintext data not as expected");
5319 TEST_ASSERT_EQUAL(ut_params->op->status,
5320 RTE_CRYPTO_OP_STATUS_SUCCESS,
5321 "GCM authentication failed");
5326 test_AES_GCM_authenticated_decryption_test_case_1(void)
5328 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5332 test_AES_GCM_authenticated_decryption_test_case_2(void)
5334 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5338 test_AES_GCM_authenticated_decryption_test_case_3(void)
5340 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5344 test_AES_GCM_authenticated_decryption_test_case_4(void)
5346 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5350 test_AES_GCM_authenticated_decryption_test_case_5(void)
5352 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5356 test_AES_GCM_authenticated_decryption_test_case_6(void)
5358 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5362 test_AES_GCM_authenticated_decryption_test_case_7(void)
5364 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5368 test_AES_GCM_auth_decryption_test_case_192_1(void)
5370 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5374 test_AES_GCM_auth_decryption_test_case_192_2(void)
5376 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5380 test_AES_GCM_auth_decryption_test_case_192_3(void)
5382 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5386 test_AES_GCM_auth_decryption_test_case_192_4(void)
5388 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5392 test_AES_GCM_auth_decryption_test_case_192_5(void)
5394 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5398 test_AES_GCM_auth_decryption_test_case_192_6(void)
5400 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5404 test_AES_GCM_auth_decryption_test_case_192_7(void)
5406 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5410 test_AES_GCM_auth_decryption_test_case_256_1(void)
5412 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5416 test_AES_GCM_auth_decryption_test_case_256_2(void)
5418 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5422 test_AES_GCM_auth_decryption_test_case_256_3(void)
5424 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5428 test_AES_GCM_auth_decryption_test_case_256_4(void)
5430 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5434 test_AES_GCM_auth_decryption_test_case_256_5(void)
5436 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5440 test_AES_GCM_auth_decryption_test_case_256_6(void)
5442 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5446 test_AES_GCM_auth_decryption_test_case_256_7(void)
5448 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5452 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5454 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5458 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5460 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5464 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5466 struct crypto_testsuite_params *ts_params = &testsuite_params;
5467 struct crypto_unittest_params *ut_params = &unittest_params;
5470 uint8_t *ciphertext, *auth_tag;
5471 uint16_t plaintext_pad_len;
5473 /* Create GCM session */
5474 retval = create_gcm_session(ts_params->valid_devs[0],
5475 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5476 tdata->key.data, tdata->key.len,
5477 tdata->aad.len, tdata->auth_tag.len,
5482 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5483 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5485 /* clear mbuf payload */
5486 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5487 rte_pktmbuf_tailroom(ut_params->ibuf));
5488 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5489 rte_pktmbuf_tailroom(ut_params->obuf));
5491 /* Create GCM operation */
5492 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5496 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5498 ut_params->op->sym->m_src = ut_params->ibuf;
5499 ut_params->op->sym->m_dst = ut_params->obuf;
5501 /* Process crypto operation */
5502 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5503 ut_params->op), "failed to process sym crypto op");
5505 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5506 "crypto op processing failed");
5508 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5510 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5511 ut_params->op->sym->cipher.data.offset);
5512 auth_tag = ciphertext + plaintext_pad_len;
5514 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5515 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5518 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5520 tdata->ciphertext.data,
5521 tdata->ciphertext.len,
5522 "GCM Ciphertext data not as expected");
5524 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5526 tdata->auth_tag.data,
5527 tdata->auth_tag.len,
5528 "GCM Generated auth tag not as expected");
5535 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5537 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5541 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5543 struct crypto_testsuite_params *ts_params = &testsuite_params;
5544 struct crypto_unittest_params *ut_params = &unittest_params;
5549 /* Create GCM session */
5550 retval = create_gcm_session(ts_params->valid_devs[0],
5551 RTE_CRYPTO_AEAD_OP_DECRYPT,
5552 tdata->key.data, tdata->key.len,
5553 tdata->aad.len, tdata->auth_tag.len,
5558 /* alloc mbuf and set payload */
5559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5560 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5563 rte_pktmbuf_tailroom(ut_params->ibuf));
5564 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5565 rte_pktmbuf_tailroom(ut_params->obuf));
5567 /* Create GCM operation */
5568 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5572 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5574 ut_params->op->sym->m_src = ut_params->ibuf;
5575 ut_params->op->sym->m_dst = ut_params->obuf;
5577 /* Process crypto operation */
5578 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5579 ut_params->op), "failed to process sym crypto op");
5581 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5582 "crypto op processing failed");
5584 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5585 ut_params->op->sym->cipher.data.offset);
5587 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5590 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5592 tdata->plaintext.data,
5593 tdata->plaintext.len,
5594 "GCM plaintext data not as expected");
5596 TEST_ASSERT_EQUAL(ut_params->op->status,
5597 RTE_CRYPTO_OP_STATUS_SUCCESS,
5598 "GCM authentication failed");
5603 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5605 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5609 test_AES_GCM_authenticated_encryption_sessionless(
5610 const struct gcm_test_data *tdata)
5612 struct crypto_testsuite_params *ts_params = &testsuite_params;
5613 struct crypto_unittest_params *ut_params = &unittest_params;
5616 uint8_t *ciphertext, *auth_tag;
5617 uint16_t plaintext_pad_len;
5618 uint8_t key[tdata->key.len + 1];
5620 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5622 /* clear mbuf payload */
5623 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5624 rte_pktmbuf_tailroom(ut_params->ibuf));
5626 /* Create GCM operation */
5627 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5631 /* Create GCM xforms */
5632 memcpy(key, tdata->key.data, tdata->key.len);
5633 retval = create_gcm_xforms(ut_params->op,
5634 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5635 key, tdata->key.len,
5636 tdata->aad.len, tdata->auth_tag.len,
5641 ut_params->op->sym->m_src = ut_params->ibuf;
5643 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5644 RTE_CRYPTO_OP_SESSIONLESS,
5645 "crypto op session type not sessionless");
5647 /* Process crypto operation */
5648 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5649 ut_params->op), "failed to process sym crypto op");
5651 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5653 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5654 "crypto op status not success");
5656 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5658 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5659 ut_params->op->sym->cipher.data.offset);
5660 auth_tag = ciphertext + plaintext_pad_len;
5662 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5663 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5666 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5668 tdata->ciphertext.data,
5669 tdata->ciphertext.len,
5670 "GCM Ciphertext data not as expected");
5672 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5674 tdata->auth_tag.data,
5675 tdata->auth_tag.len,
5676 "GCM Generated auth tag not as expected");
5683 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5685 return test_AES_GCM_authenticated_encryption_sessionless(
5690 test_AES_GCM_authenticated_decryption_sessionless(
5691 const struct gcm_test_data *tdata)
5693 struct crypto_testsuite_params *ts_params = &testsuite_params;
5694 struct crypto_unittest_params *ut_params = &unittest_params;
5698 uint8_t key[tdata->key.len + 1];
5700 /* alloc mbuf and set payload */
5701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5703 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5704 rte_pktmbuf_tailroom(ut_params->ibuf));
5706 /* Create GCM operation */
5707 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5711 /* Create GCM xforms */
5712 memcpy(key, tdata->key.data, tdata->key.len);
5713 retval = create_gcm_xforms(ut_params->op,
5714 RTE_CRYPTO_AEAD_OP_DECRYPT,
5715 key, tdata->key.len,
5716 tdata->aad.len, tdata->auth_tag.len,
5721 ut_params->op->sym->m_src = ut_params->ibuf;
5723 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5724 RTE_CRYPTO_OP_SESSIONLESS,
5725 "crypto op session type not sessionless");
5727 /* Process crypto operation */
5728 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5729 ut_params->op), "failed to process sym crypto op");
5731 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5733 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5734 "crypto op status not success");
5736 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5737 ut_params->op->sym->cipher.data.offset);
5739 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5742 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5744 tdata->plaintext.data,
5745 tdata->plaintext.len,
5746 "GCM plaintext data not as expected");
5748 TEST_ASSERT_EQUAL(ut_params->op->status,
5749 RTE_CRYPTO_OP_STATUS_SUCCESS,
5750 "GCM authentication failed");
5755 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5757 return test_AES_GCM_authenticated_decryption_sessionless(
5764 struct crypto_testsuite_params *ts_params = &testsuite_params;
5765 struct rte_cryptodev_stats stats;
5766 struct rte_cryptodev *dev;
5767 cryptodev_stats_get_t temp_pfn;
5769 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5770 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5771 &stats) == -ENODEV),
5772 "rte_cryptodev_stats_get invalid dev failed");
5773 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5774 "rte_cryptodev_stats_get invalid Param failed");
5775 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5776 temp_pfn = dev->dev_ops->stats_get;
5777 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5778 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5780 "rte_cryptodev_stats_get invalid Param failed");
5781 dev->dev_ops->stats_get = temp_pfn;
5783 /* Test expected values */
5785 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5787 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5789 "rte_cryptodev_stats_get failed");
5790 TEST_ASSERT((stats.enqueued_count == 1),
5791 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5792 TEST_ASSERT((stats.dequeued_count == 1),
5793 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5794 TEST_ASSERT((stats.enqueue_err_count == 0),
5795 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5796 TEST_ASSERT((stats.dequeue_err_count == 0),
5797 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5799 /* invalid device but should ignore and not reset device stats*/
5800 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5801 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5803 "rte_cryptodev_stats_get failed");
5804 TEST_ASSERT((stats.enqueued_count == 1),
5805 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5807 /* check that a valid reset clears stats */
5808 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5809 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5811 "rte_cryptodev_stats_get failed");
5812 TEST_ASSERT((stats.enqueued_count == 0),
5813 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5814 TEST_ASSERT((stats.dequeued_count == 0),
5815 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5817 return TEST_SUCCESS;
5820 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5821 struct crypto_unittest_params *ut_params,
5822 enum rte_crypto_auth_operation op,
5823 const struct HMAC_MD5_vector *test_case)
5827 memcpy(key, test_case->key.data, test_case->key.len);
5829 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5830 ut_params->auth_xform.next = NULL;
5831 ut_params->auth_xform.auth.op = op;
5833 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5835 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5836 ut_params->auth_xform.auth.key.length = test_case->key.len;
5837 ut_params->auth_xform.auth.key.data = key;
5839 ut_params->sess = rte_cryptodev_sym_session_create(
5840 ts_params->session_mpool);
5842 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5843 ut_params->sess, &ut_params->auth_xform,
5844 ts_params->session_mpool);
5846 if (ut_params->sess == NULL)
5849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5851 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5852 rte_pktmbuf_tailroom(ut_params->ibuf));
5857 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5858 const struct HMAC_MD5_vector *test_case,
5859 uint8_t **plaintext)
5861 uint16_t plaintext_pad_len;
5863 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5865 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5868 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5870 memcpy(*plaintext, test_case->plaintext.data,
5871 test_case->plaintext.len);
5873 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5874 ut_params->ibuf, MD5_DIGEST_LEN);
5875 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5876 "no room to append digest");
5877 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5878 ut_params->ibuf, plaintext_pad_len);
5880 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5881 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5882 test_case->auth_tag.len);
5885 sym_op->auth.data.offset = 0;
5886 sym_op->auth.data.length = test_case->plaintext.len;
5888 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5889 ut_params->op->sym->m_src = ut_params->ibuf;
5895 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5897 uint16_t plaintext_pad_len;
5898 uint8_t *plaintext, *auth_tag;
5900 struct crypto_testsuite_params *ts_params = &testsuite_params;
5901 struct crypto_unittest_params *ut_params = &unittest_params;
5903 if (MD5_HMAC_create_session(ts_params, ut_params,
5904 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5907 /* Generate Crypto op data structure */
5908 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5909 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5910 TEST_ASSERT_NOT_NULL(ut_params->op,
5911 "Failed to allocate symmetric crypto operation struct");
5913 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5916 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5919 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5920 ut_params->op), "failed to process sym crypto op");
5922 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5923 "crypto op processing failed");
5925 if (ut_params->op->sym->m_dst) {
5926 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5927 uint8_t *, plaintext_pad_len);
5929 auth_tag = plaintext + plaintext_pad_len;
5932 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5934 test_case->auth_tag.data,
5935 test_case->auth_tag.len,
5936 "HMAC_MD5 generated tag not as expected");
5938 return TEST_SUCCESS;
5942 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5946 struct crypto_testsuite_params *ts_params = &testsuite_params;
5947 struct crypto_unittest_params *ut_params = &unittest_params;
5949 if (MD5_HMAC_create_session(ts_params, ut_params,
5950 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5954 /* Generate Crypto op data structure */
5955 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5956 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5957 TEST_ASSERT_NOT_NULL(ut_params->op,
5958 "Failed to allocate symmetric crypto operation struct");
5960 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5963 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5964 ut_params->op), "failed to process sym crypto op");
5966 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5967 "HMAC_MD5 crypto op processing failed");
5969 return TEST_SUCCESS;
5973 test_MD5_HMAC_generate_case_1(void)
5975 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5979 test_MD5_HMAC_verify_case_1(void)
5981 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5985 test_MD5_HMAC_generate_case_2(void)
5987 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5991 test_MD5_HMAC_verify_case_2(void)
5993 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5997 test_multi_session(void)
5999 struct crypto_testsuite_params *ts_params = &testsuite_params;
6000 struct crypto_unittest_params *ut_params = &unittest_params;
6002 struct rte_cryptodev_info dev_info;
6003 struct rte_cryptodev_sym_session **sessions;
6007 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6008 aes_cbc_key, hmac_sha512_key);
6011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6013 sessions = rte_malloc(NULL,
6014 (sizeof(struct rte_cryptodev_sym_session *) *
6015 dev_info.sym.max_nb_sessions) + 1, 0);
6017 /* Create multiple crypto sessions*/
6018 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6020 sessions[i] = rte_cryptodev_sym_session_create(
6021 ts_params->session_mpool);
6023 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6024 sessions[i], &ut_params->auth_xform,
6025 ts_params->session_mpool);
6026 TEST_ASSERT_NOT_NULL(sessions[i],
6027 "Session creation failed at session number %u",
6030 /* Attempt to send a request on each session */
6031 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6035 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6036 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6038 "Failed to perform decrypt on request number %u.", i);
6039 /* free crypto operation structure */
6041 rte_crypto_op_free(ut_params->op);
6044 * free mbuf - both obuf and ibuf are usually the same,
6045 * so check if they point at the same address is necessary,
6046 * to avoid freeing the mbuf twice.
6048 if (ut_params->obuf) {
6049 rte_pktmbuf_free(ut_params->obuf);
6050 if (ut_params->ibuf == ut_params->obuf)
6051 ut_params->ibuf = 0;
6052 ut_params->obuf = 0;
6054 if (ut_params->ibuf) {
6055 rte_pktmbuf_free(ut_params->ibuf);
6056 ut_params->ibuf = 0;
6060 /* Next session create should fail */
6061 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6062 sessions[i], &ut_params->auth_xform,
6063 ts_params->session_mpool);
6064 TEST_ASSERT_NULL(sessions[i],
6065 "Session creation succeeded unexpectedly!");
6067 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6068 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6070 rte_cryptodev_sym_session_free(sessions[i]);
6075 return TEST_SUCCESS;
6078 struct multi_session_params {
6079 struct crypto_unittest_params ut_params;
6080 uint8_t *cipher_key;
6082 const uint8_t *cipher;
6083 const uint8_t *digest;
6087 #define MB_SESSION_NUMBER 3
6090 test_multi_session_random_usage(void)
6092 struct crypto_testsuite_params *ts_params = &testsuite_params;
6093 struct rte_cryptodev_info dev_info;
6094 struct rte_cryptodev_sym_session **sessions;
6096 struct multi_session_params ut_paramz[] = {
6099 .cipher_key = ms_aes_cbc_key0,
6100 .hmac_key = ms_hmac_key0,
6101 .cipher = ms_aes_cbc_cipher0,
6102 .digest = ms_hmac_digest0,
6103 .iv = ms_aes_cbc_iv0
6106 .cipher_key = ms_aes_cbc_key1,
6107 .hmac_key = ms_hmac_key1,
6108 .cipher = ms_aes_cbc_cipher1,
6109 .digest = ms_hmac_digest1,
6110 .iv = ms_aes_cbc_iv1
6113 .cipher_key = ms_aes_cbc_key2,
6114 .hmac_key = ms_hmac_key2,
6115 .cipher = ms_aes_cbc_cipher2,
6116 .digest = ms_hmac_digest2,
6117 .iv = ms_aes_cbc_iv2
6122 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6124 sessions = rte_malloc(NULL,
6125 (sizeof(struct rte_cryptodev_sym_session *)
6126 * dev_info.sym.max_nb_sessions) + 1, 0);
6128 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6129 sessions[i] = rte_cryptodev_sym_session_create(
6130 ts_params->session_mpool);
6132 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6133 sizeof(struct crypto_unittest_params));
6135 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6136 &ut_paramz[i].ut_params,
6137 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6139 /* Create multiple crypto sessions*/
6140 rte_cryptodev_sym_session_init(
6141 ts_params->valid_devs[0],
6143 &ut_paramz[i].ut_params.auth_xform,
6144 ts_params->session_mpool);
6146 TEST_ASSERT_NOT_NULL(sessions[i],
6147 "Session creation failed at session number %u",
6153 for (i = 0; i < 40000; i++) {
6155 j = rand() % MB_SESSION_NUMBER;
6157 TEST_ASSERT_SUCCESS(
6158 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6160 &ut_paramz[j].ut_params,
6161 ts_params, ut_paramz[j].cipher,
6162 ut_paramz[j].digest,
6164 "Failed to perform decrypt on request number %u.", i);
6166 if (ut_paramz[j].ut_params.op)
6167 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6170 * free mbuf - both obuf and ibuf are usually the same,
6171 * so check if they point at the same address is necessary,
6172 * to avoid freeing the mbuf twice.
6174 if (ut_paramz[j].ut_params.obuf) {
6175 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6176 if (ut_paramz[j].ut_params.ibuf
6177 == ut_paramz[j].ut_params.obuf)
6178 ut_paramz[j].ut_params.ibuf = 0;
6179 ut_paramz[j].ut_params.obuf = 0;
6181 if (ut_paramz[j].ut_params.ibuf) {
6182 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6183 ut_paramz[j].ut_params.ibuf = 0;
6187 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6188 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6190 rte_cryptodev_sym_session_free(sessions[i]);
6195 return TEST_SUCCESS;
6199 test_null_cipher_only_operation(void)
6201 struct crypto_testsuite_params *ts_params = &testsuite_params;
6202 struct crypto_unittest_params *ut_params = &unittest_params;
6204 /* Generate test mbuf data and space for digest */
6205 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6206 catch_22_quote, QUOTE_512_BYTES, 0);
6208 /* Setup Cipher Parameters */
6209 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6210 ut_params->cipher_xform.next = NULL;
6212 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6213 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6215 ut_params->sess = rte_cryptodev_sym_session_create(
6216 ts_params->session_mpool);
6218 /* Create Crypto session*/
6219 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6221 &ut_params->cipher_xform,
6222 ts_params->session_mpool);
6223 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6225 /* Generate Crypto op data structure */
6226 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6227 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6228 TEST_ASSERT_NOT_NULL(ut_params->op,
6229 "Failed to allocate symmetric crypto operation struct");
6231 /* Set crypto operation data parameters */
6232 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6234 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6236 /* set crypto operation source mbuf */
6237 sym_op->m_src = ut_params->ibuf;
6239 sym_op->cipher.data.offset = 0;
6240 sym_op->cipher.data.length = QUOTE_512_BYTES;
6242 /* Process crypto operation */
6243 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6245 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6247 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6248 "crypto operation processing failed");
6251 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6252 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6255 "Ciphertext data not as expected");
6257 return TEST_SUCCESS;
6261 test_null_auth_only_operation(void)
6263 struct crypto_testsuite_params *ts_params = &testsuite_params;
6264 struct crypto_unittest_params *ut_params = &unittest_params;
6266 /* Generate test mbuf data and space for digest */
6267 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6268 catch_22_quote, QUOTE_512_BYTES, 0);
6270 /* Setup HMAC Parameters */
6271 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6272 ut_params->auth_xform.next = NULL;
6274 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6275 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6277 ut_params->sess = rte_cryptodev_sym_session_create(
6278 ts_params->session_mpool);
6280 /* Create Crypto session*/
6281 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6282 ut_params->sess, &ut_params->auth_xform,
6283 ts_params->session_mpool);
6284 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6286 /* Generate Crypto op data structure */
6287 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6288 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6289 TEST_ASSERT_NOT_NULL(ut_params->op,
6290 "Failed to allocate symmetric crypto operation struct");
6292 /* Set crypto operation data parameters */
6293 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6295 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6297 sym_op->m_src = ut_params->ibuf;
6299 sym_op->auth.data.offset = 0;
6300 sym_op->auth.data.length = QUOTE_512_BYTES;
6302 /* Process crypto operation */
6303 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6305 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6307 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6308 "crypto operation processing failed");
6310 return TEST_SUCCESS;
6314 test_null_cipher_auth_operation(void)
6316 struct crypto_testsuite_params *ts_params = &testsuite_params;
6317 struct crypto_unittest_params *ut_params = &unittest_params;
6319 /* Generate test mbuf data and space for digest */
6320 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6321 catch_22_quote, QUOTE_512_BYTES, 0);
6323 /* Setup Cipher Parameters */
6324 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6325 ut_params->cipher_xform.next = &ut_params->auth_xform;
6327 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6328 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6330 /* Setup HMAC Parameters */
6331 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6332 ut_params->auth_xform.next = NULL;
6334 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6335 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6337 ut_params->sess = rte_cryptodev_sym_session_create(
6338 ts_params->session_mpool);
6340 /* Create Crypto session*/
6341 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6342 ut_params->sess, &ut_params->cipher_xform,
6343 ts_params->session_mpool);
6344 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6346 /* Generate Crypto op data structure */
6347 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6348 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6349 TEST_ASSERT_NOT_NULL(ut_params->op,
6350 "Failed to allocate symmetric crypto operation struct");
6352 /* Set crypto operation data parameters */
6353 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6355 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6357 sym_op->m_src = ut_params->ibuf;
6359 sym_op->cipher.data.offset = 0;
6360 sym_op->cipher.data.length = QUOTE_512_BYTES;
6362 sym_op->auth.data.offset = 0;
6363 sym_op->auth.data.length = QUOTE_512_BYTES;
6365 /* Process crypto operation */
6366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6368 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6370 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6371 "crypto operation processing failed");
6374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6375 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6378 "Ciphertext data not as expected");
6380 return TEST_SUCCESS;
6384 test_null_auth_cipher_operation(void)
6386 struct crypto_testsuite_params *ts_params = &testsuite_params;
6387 struct crypto_unittest_params *ut_params = &unittest_params;
6389 /* Generate test mbuf data and space for digest */
6390 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6391 catch_22_quote, QUOTE_512_BYTES, 0);
6393 /* Setup Cipher Parameters */
6394 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6395 ut_params->cipher_xform.next = NULL;
6397 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6398 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6400 /* Setup HMAC Parameters */
6401 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6402 ut_params->auth_xform.next = &ut_params->cipher_xform;
6404 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6405 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6407 ut_params->sess = rte_cryptodev_sym_session_create(
6408 ts_params->session_mpool);
6410 /* Create Crypto session*/
6411 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6412 ut_params->sess, &ut_params->cipher_xform,
6413 ts_params->session_mpool);
6414 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6416 /* Generate Crypto op data structure */
6417 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6418 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6419 TEST_ASSERT_NOT_NULL(ut_params->op,
6420 "Failed to allocate symmetric crypto operation struct");
6422 /* Set crypto operation data parameters */
6423 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6425 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6427 sym_op->m_src = ut_params->ibuf;
6429 sym_op->cipher.data.offset = 0;
6430 sym_op->cipher.data.length = QUOTE_512_BYTES;
6432 sym_op->auth.data.offset = 0;
6433 sym_op->auth.data.length = QUOTE_512_BYTES;
6435 /* Process crypto operation */
6436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6438 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6440 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6441 "crypto operation processing failed");
6444 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6445 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6448 "Ciphertext data not as expected");
6450 return TEST_SUCCESS;
6455 test_null_invalid_operation(void)
6457 struct crypto_testsuite_params *ts_params = &testsuite_params;
6458 struct crypto_unittest_params *ut_params = &unittest_params;
6461 /* Setup Cipher Parameters */
6462 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6463 ut_params->cipher_xform.next = NULL;
6465 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6466 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6468 ut_params->sess = rte_cryptodev_sym_session_create(
6469 ts_params->session_mpool);
6471 /* Create Crypto session*/
6472 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6473 ut_params->sess, &ut_params->cipher_xform,
6474 ts_params->session_mpool);
6475 TEST_ASSERT(ret < 0,
6476 "Session creation succeeded unexpectedly");
6479 /* Setup HMAC Parameters */
6480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6481 ut_params->auth_xform.next = NULL;
6483 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6484 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6486 ut_params->sess = rte_cryptodev_sym_session_create(
6487 ts_params->session_mpool);
6489 /* Create Crypto session*/
6490 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6491 ut_params->sess, &ut_params->auth_xform,
6492 ts_params->session_mpool);
6493 TEST_ASSERT(ret < 0,
6494 "Session creation succeeded unexpectedly");
6496 return TEST_SUCCESS;
6500 #define NULL_BURST_LENGTH (32)
6503 test_null_burst_operation(void)
6505 struct crypto_testsuite_params *ts_params = &testsuite_params;
6506 struct crypto_unittest_params *ut_params = &unittest_params;
6508 unsigned i, burst_len = NULL_BURST_LENGTH;
6510 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6511 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6513 /* Setup Cipher Parameters */
6514 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6515 ut_params->cipher_xform.next = &ut_params->auth_xform;
6517 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6518 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6520 /* Setup HMAC Parameters */
6521 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6522 ut_params->auth_xform.next = NULL;
6524 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6525 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6527 ut_params->sess = rte_cryptodev_sym_session_create(
6528 ts_params->session_mpool);
6530 /* Create Crypto session*/
6531 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6532 ut_params->sess, &ut_params->cipher_xform,
6533 ts_params->session_mpool);
6534 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6536 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6537 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6538 burst_len, "failed to generate burst of crypto ops");
6540 /* Generate an operation for each mbuf in burst */
6541 for (i = 0; i < burst_len; i++) {
6542 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6544 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6546 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6550 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6552 burst[i]->sym->m_src = m;
6555 /* Process crypto operation */
6556 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6557 0, burst, burst_len),
6559 "Error enqueuing burst");
6561 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6562 0, burst_dequeued, burst_len),
6564 "Error dequeuing burst");
6567 for (i = 0; i < burst_len; i++) {
6569 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6570 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6572 "data not as expected");
6574 rte_pktmbuf_free(burst[i]->sym->m_src);
6575 rte_crypto_op_free(burst[i]);
6578 return TEST_SUCCESS;
6582 generate_gmac_large_plaintext(uint8_t *data)
6586 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6587 memcpy(&data[i], &data[0], 32);
6591 create_gmac_operation(enum rte_crypto_auth_operation op,
6592 const struct gmac_test_data *tdata)
6594 struct crypto_testsuite_params *ts_params = &testsuite_params;
6595 struct crypto_unittest_params *ut_params = &unittest_params;
6596 struct rte_crypto_sym_op *sym_op;
6598 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6600 /* Generate Crypto op data structure */
6601 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6602 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6603 TEST_ASSERT_NOT_NULL(ut_params->op,
6604 "Failed to allocate symmetric crypto operation struct");
6606 sym_op = ut_params->op->sym;
6608 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6609 ut_params->ibuf, tdata->gmac_tag.len);
6610 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6611 "no room to append digest");
6613 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6614 ut_params->ibuf, plaintext_pad_len);
6616 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6617 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6618 tdata->gmac_tag.len);
6619 TEST_HEXDUMP(stdout, "digest:",
6620 sym_op->auth.digest.data,
6621 tdata->gmac_tag.len);
6624 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6625 uint8_t *, IV_OFFSET);
6627 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6629 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6631 sym_op->cipher.data.length = 0;
6632 sym_op->cipher.data.offset = 0;
6634 sym_op->auth.data.offset = 0;
6635 sym_op->auth.data.length = tdata->plaintext.len;
6640 static int create_gmac_session(uint8_t dev_id,
6641 const struct gmac_test_data *tdata,
6642 enum rte_crypto_auth_operation auth_op)
6644 uint8_t auth_key[tdata->key.len];
6646 struct crypto_testsuite_params *ts_params = &testsuite_params;
6647 struct crypto_unittest_params *ut_params = &unittest_params;
6649 memcpy(auth_key, tdata->key.data, tdata->key.len);
6651 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6652 ut_params->auth_xform.next = NULL;
6654 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6655 ut_params->auth_xform.auth.op = auth_op;
6656 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6657 ut_params->auth_xform.auth.key.length = tdata->key.len;
6658 ut_params->auth_xform.auth.key.data = auth_key;
6659 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6660 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6663 ut_params->sess = rte_cryptodev_sym_session_create(
6664 ts_params->session_mpool);
6666 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6667 &ut_params->auth_xform,
6668 ts_params->session_mpool);
6670 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6676 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6678 struct crypto_testsuite_params *ts_params = &testsuite_params;
6679 struct crypto_unittest_params *ut_params = &unittest_params;
6683 uint8_t *auth_tag, *plaintext;
6684 uint16_t plaintext_pad_len;
6686 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6687 "No GMAC length in the source data");
6689 retval = create_gmac_session(ts_params->valid_devs[0],
6690 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6695 if (tdata->plaintext.len > MBUF_SIZE)
6696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6698 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6699 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6700 "Failed to allocate input buffer in mempool");
6702 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6703 rte_pktmbuf_tailroom(ut_params->ibuf));
6705 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6707 * Runtime generate the large plain text instead of use hard code
6708 * plain text vector. It is done to avoid create huge source file
6709 * with the test vector.
6711 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6712 generate_gmac_large_plaintext(tdata->plaintext.data);
6714 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6716 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6718 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6719 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6720 tdata->plaintext.len);
6722 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6728 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6730 ut_params->op->sym->m_src = ut_params->ibuf;
6732 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6733 ut_params->op), "failed to process sym crypto op");
6735 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6736 "crypto op processing failed");
6738 if (ut_params->op->sym->m_dst) {
6739 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6740 uint8_t *, plaintext_pad_len);
6742 auth_tag = plaintext + plaintext_pad_len;
6745 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6747 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6749 tdata->gmac_tag.data,
6750 tdata->gmac_tag.len,
6751 "GMAC Generated auth tag not as expected");
6757 test_AES_GMAC_authentication_test_case_1(void)
6759 return test_AES_GMAC_authentication(&gmac_test_case_1);
6763 test_AES_GMAC_authentication_test_case_2(void)
6765 return test_AES_GMAC_authentication(&gmac_test_case_2);
6769 test_AES_GMAC_authentication_test_case_3(void)
6771 return test_AES_GMAC_authentication(&gmac_test_case_3);
6775 test_AES_GMAC_authentication_test_case_4(void)
6777 return test_AES_GMAC_authentication(&gmac_test_case_4);
6781 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6783 struct crypto_testsuite_params *ts_params = &testsuite_params;
6784 struct crypto_unittest_params *ut_params = &unittest_params;
6786 uint32_t plaintext_pad_len;
6789 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6790 "No GMAC length in the source data");
6792 retval = create_gmac_session(ts_params->valid_devs[0],
6793 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6798 if (tdata->plaintext.len > MBUF_SIZE)
6799 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6802 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6803 "Failed to allocate input buffer in mempool");
6805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6806 rte_pktmbuf_tailroom(ut_params->ibuf));
6808 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6811 * Runtime generate the large plain text instead of use hard code
6812 * plain text vector. It is done to avoid create huge source file
6813 * with the test vector.
6815 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6816 generate_gmac_large_plaintext(tdata->plaintext.data);
6818 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6820 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6822 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6823 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6824 tdata->plaintext.len);
6826 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6832 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6834 ut_params->op->sym->m_src = ut_params->ibuf;
6836 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6837 ut_params->op), "failed to process sym crypto op");
6839 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6840 "crypto op processing failed");
6847 test_AES_GMAC_authentication_verify_test_case_1(void)
6849 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6853 test_AES_GMAC_authentication_verify_test_case_2(void)
6855 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6859 test_AES_GMAC_authentication_verify_test_case_3(void)
6861 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6865 test_AES_GMAC_authentication_verify_test_case_4(void)
6867 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6870 struct test_crypto_vector {
6871 enum rte_crypto_cipher_algorithm crypto_algo;
6884 const uint8_t *data;
6889 const uint8_t *data;
6893 enum rte_crypto_auth_algorithm auth_algo;
6901 const uint8_t *data;
6911 static const struct test_crypto_vector
6912 hmac_sha1_test_crypto_vector = {
6913 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6915 .data = plaintext_hash,
6920 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6921 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6922 0xDE, 0xF4, 0xDE, 0xAD
6928 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6929 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6930 0x3F, 0x91, 0x64, 0x59
6936 static const struct test_crypto_vector
6937 aes128_gmac_test_vector = {
6938 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6940 .data = plaintext_hash,
6945 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6946 0x08, 0x09, 0x0A, 0x0B
6952 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6953 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6959 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6960 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6966 static const struct test_crypto_vector
6967 aes128cbc_hmac_sha1_test_vector = {
6968 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6971 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6972 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6978 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6979 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6984 .data = plaintext_hash,
6988 .data = ciphertext512_aes128cbc,
6991 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6994 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6995 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6996 0xDE, 0xF4, 0xDE, 0xAD
7002 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7003 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7004 0x18, 0x8C, 0x1D, 0x32
7011 data_corruption(uint8_t *data)
7017 tag_corruption(uint8_t *data, unsigned int tag_offset)
7019 data[tag_offset] += 1;
7023 create_auth_session(struct crypto_unittest_params *ut_params,
7025 const struct test_crypto_vector *reference,
7026 enum rte_crypto_auth_operation auth_op)
7028 struct crypto_testsuite_params *ts_params = &testsuite_params;
7029 uint8_t auth_key[reference->auth_key.len + 1];
7031 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7033 /* Setup Authentication Parameters */
7034 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7035 ut_params->auth_xform.auth.op = auth_op;
7036 ut_params->auth_xform.next = NULL;
7037 ut_params->auth_xform.auth.algo = reference->auth_algo;
7038 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7039 ut_params->auth_xform.auth.key.data = auth_key;
7040 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7042 /* Create Crypto session*/
7043 ut_params->sess = rte_cryptodev_sym_session_create(
7044 ts_params->session_mpool);
7046 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7047 &ut_params->auth_xform,
7048 ts_params->session_mpool);
7050 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7056 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7058 const struct test_crypto_vector *reference,
7059 enum rte_crypto_auth_operation auth_op,
7060 enum rte_crypto_cipher_operation cipher_op)
7062 struct crypto_testsuite_params *ts_params = &testsuite_params;
7063 uint8_t cipher_key[reference->cipher_key.len + 1];
7064 uint8_t auth_key[reference->auth_key.len + 1];
7066 memcpy(cipher_key, reference->cipher_key.data,
7067 reference->cipher_key.len);
7068 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7070 /* Setup Authentication Parameters */
7071 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7072 ut_params->auth_xform.auth.op = auth_op;
7073 ut_params->auth_xform.auth.algo = reference->auth_algo;
7074 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7075 ut_params->auth_xform.auth.key.data = auth_key;
7076 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7078 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7079 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7080 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7082 ut_params->auth_xform.next = &ut_params->cipher_xform;
7084 /* Setup Cipher Parameters */
7085 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7086 ut_params->cipher_xform.next = NULL;
7087 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7088 ut_params->cipher_xform.cipher.op = cipher_op;
7089 ut_params->cipher_xform.cipher.key.data = cipher_key;
7090 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7091 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7092 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7095 /* Create Crypto session*/
7096 ut_params->sess = rte_cryptodev_sym_session_create(
7097 ts_params->session_mpool);
7099 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7100 &ut_params->auth_xform,
7101 ts_params->session_mpool);
7103 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7109 create_auth_operation(struct crypto_testsuite_params *ts_params,
7110 struct crypto_unittest_params *ut_params,
7111 const struct test_crypto_vector *reference,
7112 unsigned int auth_generate)
7114 /* Generate Crypto op data structure */
7115 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7116 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7117 TEST_ASSERT_NOT_NULL(ut_params->op,
7118 "Failed to allocate pktmbuf offload");
7120 /* Set crypto operation data parameters */
7121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7123 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7125 /* set crypto operation source mbuf */
7126 sym_op->m_src = ut_params->ibuf;
7129 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7130 ut_params->ibuf, reference->digest.len);
7132 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7133 "no room to append auth tag");
7135 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7136 ut_params->ibuf, reference->plaintext.len);
7139 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7141 memcpy(sym_op->auth.digest.data,
7142 reference->digest.data,
7143 reference->digest.len);
7145 TEST_HEXDUMP(stdout, "digest:",
7146 sym_op->auth.digest.data,
7147 reference->digest.len);
7149 sym_op->auth.data.length = reference->plaintext.len;
7150 sym_op->auth.data.offset = 0;
7156 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7157 struct crypto_unittest_params *ut_params,
7158 const struct test_crypto_vector *reference,
7159 unsigned int auth_generate)
7161 /* Generate Crypto op data structure */
7162 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7163 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7164 TEST_ASSERT_NOT_NULL(ut_params->op,
7165 "Failed to allocate pktmbuf offload");
7167 /* Set crypto operation data parameters */
7168 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7170 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7172 /* set crypto operation source mbuf */
7173 sym_op->m_src = ut_params->ibuf;
7176 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7177 ut_params->ibuf, reference->digest.len);
7179 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7180 "no room to append auth tag");
7182 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7183 ut_params->ibuf, reference->ciphertext.len);
7186 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7188 memcpy(sym_op->auth.digest.data,
7189 reference->digest.data,
7190 reference->digest.len);
7192 TEST_HEXDUMP(stdout, "digest:",
7193 sym_op->auth.digest.data,
7194 reference->digest.len);
7196 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7197 reference->iv.data, reference->iv.len);
7199 sym_op->cipher.data.length = 0;
7200 sym_op->cipher.data.offset = 0;
7202 sym_op->auth.data.length = reference->plaintext.len;
7203 sym_op->auth.data.offset = 0;
7209 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7210 struct crypto_unittest_params *ut_params,
7211 const struct test_crypto_vector *reference,
7212 unsigned int auth_generate)
7214 /* Generate Crypto op data structure */
7215 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7216 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7217 TEST_ASSERT_NOT_NULL(ut_params->op,
7218 "Failed to allocate pktmbuf offload");
7220 /* Set crypto operation data parameters */
7221 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7223 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7225 /* set crypto operation source mbuf */
7226 sym_op->m_src = ut_params->ibuf;
7229 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7230 ut_params->ibuf, reference->digest.len);
7232 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7233 "no room to append auth tag");
7235 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7236 ut_params->ibuf, reference->ciphertext.len);
7239 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7241 memcpy(sym_op->auth.digest.data,
7242 reference->digest.data,
7243 reference->digest.len);
7245 TEST_HEXDUMP(stdout, "digest:",
7246 sym_op->auth.digest.data,
7247 reference->digest.len);
7249 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7250 reference->iv.data, reference->iv.len);
7252 sym_op->cipher.data.length = reference->ciphertext.len;
7253 sym_op->cipher.data.offset = 0;
7255 sym_op->auth.data.length = reference->ciphertext.len;
7256 sym_op->auth.data.offset = 0;
7262 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7263 struct crypto_unittest_params *ut_params,
7264 const struct test_crypto_vector *reference)
7266 return create_auth_operation(ts_params, ut_params, reference, 0);
7270 create_auth_verify_GMAC_operation(
7271 struct crypto_testsuite_params *ts_params,
7272 struct crypto_unittest_params *ut_params,
7273 const struct test_crypto_vector *reference)
7275 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7279 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7280 struct crypto_unittest_params *ut_params,
7281 const struct test_crypto_vector *reference)
7283 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7287 test_authentication_verify_fail_when_data_corruption(
7288 struct crypto_testsuite_params *ts_params,
7289 struct crypto_unittest_params *ut_params,
7290 const struct test_crypto_vector *reference,
7291 unsigned int data_corrupted)
7297 /* Create session */
7298 retval = create_auth_session(ut_params,
7299 ts_params->valid_devs[0],
7301 RTE_CRYPTO_AUTH_OP_VERIFY);
7305 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7306 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7307 "Failed to allocate input buffer in mempool");
7309 /* clear mbuf payload */
7310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7311 rte_pktmbuf_tailroom(ut_params->ibuf));
7313 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7314 reference->plaintext.len);
7315 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7316 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7318 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7320 /* Create operation */
7321 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7327 data_corruption(plaintext);
7329 tag_corruption(plaintext, reference->plaintext.len);
7331 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7333 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7334 TEST_ASSERT_EQUAL(ut_params->op->status,
7335 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7336 "authentication not failed");
7338 ut_params->obuf = ut_params->op->sym->m_src;
7339 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7345 test_authentication_verify_GMAC_fail_when_corruption(
7346 struct crypto_testsuite_params *ts_params,
7347 struct crypto_unittest_params *ut_params,
7348 const struct test_crypto_vector *reference,
7349 unsigned int data_corrupted)
7354 /* Create session */
7355 retval = create_auth_cipher_session(ut_params,
7356 ts_params->valid_devs[0],
7358 RTE_CRYPTO_AUTH_OP_VERIFY,
7359 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7363 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7364 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7365 "Failed to allocate input buffer in mempool");
7367 /* clear mbuf payload */
7368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7369 rte_pktmbuf_tailroom(ut_params->ibuf));
7371 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7372 reference->plaintext.len);
7373 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7374 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7376 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7378 /* Create operation */
7379 retval = create_auth_verify_GMAC_operation(ts_params,
7387 data_corruption(plaintext);
7389 tag_corruption(plaintext, reference->aad.len);
7391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7394 TEST_ASSERT_EQUAL(ut_params->op->status,
7395 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7396 "authentication not failed");
7398 ut_params->obuf = ut_params->op->sym->m_src;
7399 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7405 test_authenticated_decryption_fail_when_corruption(
7406 struct crypto_testsuite_params *ts_params,
7407 struct crypto_unittest_params *ut_params,
7408 const struct test_crypto_vector *reference,
7409 unsigned int data_corrupted)
7413 uint8_t *ciphertext;
7415 /* Create session */
7416 retval = create_auth_cipher_session(ut_params,
7417 ts_params->valid_devs[0],
7419 RTE_CRYPTO_AUTH_OP_VERIFY,
7420 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7424 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7425 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7426 "Failed to allocate input buffer in mempool");
7428 /* clear mbuf payload */
7429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7430 rte_pktmbuf_tailroom(ut_params->ibuf));
7432 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7433 reference->ciphertext.len);
7434 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7435 memcpy(ciphertext, reference->ciphertext.data,
7436 reference->ciphertext.len);
7438 /* Create operation */
7439 retval = create_cipher_auth_verify_operation(ts_params,
7447 data_corruption(ciphertext);
7449 tag_corruption(ciphertext, reference->ciphertext.len);
7451 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7454 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7455 TEST_ASSERT_EQUAL(ut_params->op->status,
7456 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7457 "authentication not failed");
7459 ut_params->obuf = ut_params->op->sym->m_src;
7460 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7466 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7467 const struct gcm_test_data *tdata,
7468 void *digest_mem, uint64_t digest_phys)
7470 struct crypto_testsuite_params *ts_params = &testsuite_params;
7471 struct crypto_unittest_params *ut_params = &unittest_params;
7473 const unsigned int auth_tag_len = tdata->auth_tag.len;
7474 const unsigned int iv_len = tdata->iv.len;
7475 const unsigned int aad_len = tdata->aad.len;
7477 /* Generate Crypto op data structure */
7478 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7479 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7480 TEST_ASSERT_NOT_NULL(ut_params->op,
7481 "Failed to allocate symmetric crypto operation struct");
7483 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7485 sym_op->aead.digest.data = digest_mem;
7487 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7488 "no room to append digest");
7490 sym_op->aead.digest.phys_addr = digest_phys;
7492 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7493 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7495 TEST_HEXDUMP(stdout, "digest:",
7496 sym_op->aead.digest.data,
7500 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7501 uint8_t *, IV_OFFSET);
7503 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7505 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7506 ut_params->ibuf, aad_len);
7507 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7508 "no room to prepend aad");
7509 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7512 memset(sym_op->aead.aad.data, 0, aad_len);
7513 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7515 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7516 TEST_HEXDUMP(stdout, "aad:",
7517 sym_op->aead.aad.data, aad_len);
7519 sym_op->aead.data.length = tdata->plaintext.len;
7520 sym_op->aead.data.offset = aad_len;
7525 #define SGL_MAX_NO 16
7528 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7529 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7531 struct crypto_testsuite_params *ts_params = &testsuite_params;
7532 struct crypto_unittest_params *ut_params = &unittest_params;
7533 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7536 int to_trn_tbl[SGL_MAX_NO];
7538 unsigned int trn_data = 0;
7539 uint8_t *plaintext, *ciphertext, *auth_tag;
7541 if (fragsz > tdata->plaintext.len)
7542 fragsz = tdata->plaintext.len;
7544 uint16_t plaintext_len = fragsz;
7545 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7547 if (fragsz_oop > tdata->plaintext.len)
7548 frag_size_oop = tdata->plaintext.len;
7551 void *digest_mem = NULL;
7553 uint32_t prepend_len = tdata->aad.len;
7555 if (tdata->plaintext.len % fragsz != 0) {
7556 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7559 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7564 * For out-op-place we need to alloc another mbuf
7567 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7568 rte_pktmbuf_append(ut_params->obuf,
7569 frag_size_oop + prepend_len);
7570 buf_oop = ut_params->obuf;
7573 /* Create GCM session */
7574 retval = create_gcm_session(ts_params->valid_devs[0],
7575 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7576 tdata->key.data, tdata->key.len,
7577 tdata->aad.len, tdata->auth_tag.len,
7582 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7584 /* clear mbuf payload */
7585 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7586 rte_pktmbuf_tailroom(ut_params->ibuf));
7588 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7591 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7593 trn_data += plaintext_len;
7595 buf = ut_params->ibuf;
7598 * Loop until no more fragments
7601 while (trn_data < tdata->plaintext.len) {
7603 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7604 (tdata->plaintext.len - trn_data) : fragsz;
7606 to_trn_tbl[ecx++] = to_trn;
7608 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7611 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7612 rte_pktmbuf_tailroom(buf));
7615 if (oop && !fragsz_oop) {
7616 buf_last_oop = buf_oop->next =
7617 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7618 buf_oop = buf_oop->next;
7619 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7620 0, rte_pktmbuf_tailroom(buf_oop));
7621 rte_pktmbuf_append(buf_oop, to_trn);
7624 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7627 memcpy(plaintext, tdata->plaintext.data + trn_data,
7630 if (trn_data == tdata->plaintext.len) {
7633 digest_mem = rte_pktmbuf_append(buf_oop,
7634 tdata->auth_tag.len);
7636 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7637 tdata->auth_tag.len);
7641 uint64_t digest_phys = 0;
7643 ut_params->ibuf->nb_segs = segs;
7646 if (fragsz_oop && oop) {
7650 if (frag_size_oop == tdata->plaintext.len) {
7651 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7652 tdata->auth_tag.len);
7654 digest_phys = rte_pktmbuf_mtophys_offset(
7656 tdata->plaintext.len + prepend_len);
7659 trn_data = frag_size_oop;
7660 while (trn_data < tdata->plaintext.len) {
7663 (tdata->plaintext.len - trn_data <
7665 (tdata->plaintext.len - trn_data) :
7668 to_trn_tbl[ecx++] = to_trn;
7670 buf_last_oop = buf_oop->next =
7671 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7672 buf_oop = buf_oop->next;
7673 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7674 0, rte_pktmbuf_tailroom(buf_oop));
7675 rte_pktmbuf_append(buf_oop, to_trn);
7679 if (trn_data == tdata->plaintext.len) {
7680 digest_mem = rte_pktmbuf_append(buf_oop,
7681 tdata->auth_tag.len);
7685 ut_params->obuf->nb_segs = segs;
7689 * Place digest at the end of the last buffer
7692 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7693 if (oop && buf_last_oop)
7694 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7696 if (!digest_mem && !oop) {
7697 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7698 + tdata->auth_tag.len);
7699 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7700 tdata->plaintext.len);
7703 /* Create GCM opertaion */
7704 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7705 tdata, digest_mem, digest_phys);
7710 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7712 ut_params->op->sym->m_src = ut_params->ibuf;
7714 ut_params->op->sym->m_dst = ut_params->obuf;
7716 /* Process crypto operation */
7717 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7718 ut_params->op), "failed to process sym crypto op");
7720 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7721 "crypto op processing failed");
7724 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7725 uint8_t *, prepend_len);
7727 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7728 uint8_t *, prepend_len);
7732 fragsz = fragsz_oop;
7734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7736 tdata->ciphertext.data,
7738 "GCM Ciphertext data not as expected");
7740 buf = ut_params->op->sym->m_src->next;
7742 buf = ut_params->op->sym->m_dst->next;
7744 unsigned int off = fragsz;
7748 ciphertext = rte_pktmbuf_mtod(buf,
7751 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7753 tdata->ciphertext.data + off,
7755 "GCM Ciphertext data not as expected");
7757 off += to_trn_tbl[ecx++];
7761 auth_tag = digest_mem;
7762 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7764 tdata->auth_tag.data,
7765 tdata->auth_tag.len,
7766 "GCM Generated auth tag not as expected");
7772 #define OUT_OF_PLACE 1
7775 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7777 return test_AES_GCM_authenticated_encryption_SGL(
7778 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7782 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7784 return test_AES_GCM_authenticated_encryption_SGL(
7785 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7789 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7791 return test_AES_GCM_authenticated_encryption_SGL(
7792 &gcm_test_case_8, OUT_OF_PLACE, 400,
7793 gcm_test_case_8.plaintext.len);
7797 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7800 return test_AES_GCM_authenticated_encryption_SGL(
7801 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7805 test_authentication_verify_fail_when_data_corrupted(
7806 struct crypto_testsuite_params *ts_params,
7807 struct crypto_unittest_params *ut_params,
7808 const struct test_crypto_vector *reference)
7810 return test_authentication_verify_fail_when_data_corruption(
7811 ts_params, ut_params, reference, 1);
7815 test_authentication_verify_fail_when_tag_corrupted(
7816 struct crypto_testsuite_params *ts_params,
7817 struct crypto_unittest_params *ut_params,
7818 const struct test_crypto_vector *reference)
7820 return test_authentication_verify_fail_when_data_corruption(
7821 ts_params, ut_params, reference, 0);
7825 test_authentication_verify_GMAC_fail_when_data_corrupted(
7826 struct crypto_testsuite_params *ts_params,
7827 struct crypto_unittest_params *ut_params,
7828 const struct test_crypto_vector *reference)
7830 return test_authentication_verify_GMAC_fail_when_corruption(
7831 ts_params, ut_params, reference, 1);
7835 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7836 struct crypto_testsuite_params *ts_params,
7837 struct crypto_unittest_params *ut_params,
7838 const struct test_crypto_vector *reference)
7840 return test_authentication_verify_GMAC_fail_when_corruption(
7841 ts_params, ut_params, reference, 0);
7845 test_authenticated_decryption_fail_when_data_corrupted(
7846 struct crypto_testsuite_params *ts_params,
7847 struct crypto_unittest_params *ut_params,
7848 const struct test_crypto_vector *reference)
7850 return test_authenticated_decryption_fail_when_corruption(
7851 ts_params, ut_params, reference, 1);
7855 test_authenticated_decryption_fail_when_tag_corrupted(
7856 struct crypto_testsuite_params *ts_params,
7857 struct crypto_unittest_params *ut_params,
7858 const struct test_crypto_vector *reference)
7860 return test_authenticated_decryption_fail_when_corruption(
7861 ts_params, ut_params, reference, 0);
7865 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7867 return test_authentication_verify_fail_when_data_corrupted(
7868 &testsuite_params, &unittest_params,
7869 &hmac_sha1_test_crypto_vector);
7873 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7875 return test_authentication_verify_fail_when_tag_corrupted(
7876 &testsuite_params, &unittest_params,
7877 &hmac_sha1_test_crypto_vector);
7881 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7883 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7884 &testsuite_params, &unittest_params,
7885 &aes128_gmac_test_vector);
7889 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7891 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7892 &testsuite_params, &unittest_params,
7893 &aes128_gmac_test_vector);
7897 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7899 return test_authenticated_decryption_fail_when_data_corrupted(
7902 &aes128cbc_hmac_sha1_test_vector);
7906 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7908 return test_authenticated_decryption_fail_when_tag_corrupted(
7911 &aes128cbc_hmac_sha1_test_vector);
7914 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7916 /* global AESNI slave IDs for the scheduler test */
7917 uint8_t aesni_ids[2];
7920 test_scheduler_attach_slave_op(void)
7922 struct crypto_testsuite_params *ts_params = &testsuite_params;
7923 uint8_t sched_id = ts_params->valid_devs[0];
7924 uint32_t nb_devs, i, nb_devs_attached = 0;
7928 /* create 2 AESNI_MB if necessary */
7929 nb_devs = rte_cryptodev_device_count_by_driver(
7930 rte_cryptodev_driver_id_get(
7931 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
7933 for (i = nb_devs; i < 2; i++) {
7934 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7935 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7937 ret = rte_vdev_init(vdev_name, NULL);
7939 TEST_ASSERT(ret == 0,
7940 "Failed to create instance %u of"
7942 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7946 /* attach 2 AESNI_MB cdevs */
7947 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7949 struct rte_cryptodev_info info;
7951 rte_cryptodev_info_get(i, &info);
7952 if (info.driver_id != rte_cryptodev_driver_id_get(
7953 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
7957 * Create the session mempool again, since now there are new devices
7958 * to use the mempool.
7960 if (ts_params->session_mpool) {
7961 rte_mempool_free(ts_params->session_mpool);
7962 ts_params->session_mpool = NULL;
7964 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
7967 * Create mempool with maximum number of sessions * 2,
7968 * to include the session headers
7970 if (ts_params->session_mpool == NULL) {
7971 ts_params->session_mpool = rte_mempool_create(
7973 info.sym.max_nb_sessions * 2,
7975 0, 0, NULL, NULL, NULL,
7976 NULL, SOCKET_ID_ANY,
7979 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
7980 "session mempool allocation failed");
7983 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7986 TEST_ASSERT(ret == 0,
7987 "Failed to attach device %u of pmd : %s", i,
7988 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7990 aesni_ids[nb_devs_attached] = (uint8_t)i;
7999 test_scheduler_detach_slave_op(void)
8001 struct crypto_testsuite_params *ts_params = &testsuite_params;
8002 uint8_t sched_id = ts_params->valid_devs[0];
8006 for (i = 0; i < 2; i++) {
8007 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8009 TEST_ASSERT(ret == 0,
8010 "Failed to detach device %u", aesni_ids[i]);
8017 test_scheduler_mode_op(void)
8019 struct crypto_testsuite_params *ts_params = &testsuite_params;
8020 uint8_t sched_id = ts_params->valid_devs[0];
8021 struct rte_cryptodev_scheduler_ops op = {0};
8022 struct rte_cryptodev_scheduler dummy_scheduler = {
8023 .description = "dummy scheduler to test mode",
8024 .name = "dummy scheduler",
8025 .mode = CDEV_SCHED_MODE_USERDEFINED,
8030 /* set user defined mode */
8031 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8033 TEST_ASSERT(ret == 0,
8034 "Failed to set cdev %u to user defined mode", sched_id);
8036 /* set round robin mode */
8037 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8038 CDEV_SCHED_MODE_ROUNDROBIN);
8039 TEST_ASSERT(ret == 0,
8040 "Failed to set cdev %u to round-robin mode", sched_id);
8041 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8042 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8048 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8049 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8050 .setup = testsuite_setup,
8051 .teardown = testsuite_teardown,
8052 .unit_test_cases = {
8053 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8054 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 test_AES_chain_scheduler_all),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_AES_cipheronly_scheduler_all),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_authonly_scheduler_all),
8061 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8062 TEST_CASES_END() /**< NULL terminate unit test array */
8066 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8068 static struct unit_test_suite cryptodev_qat_testsuite = {
8069 .suite_name = "Crypto QAT Unit Test Suite",
8070 .setup = testsuite_setup,
8071 .teardown = testsuite_teardown,
8072 .unit_test_cases = {
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_device_configure_invalid_dev_id),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_device_configure_invalid_queue_pair_ids),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_queue_pair_descriptor_setup),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_multi_session),
8082 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_AES_cipheronly_qat_all),
8085 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_3DES_cipheronly_qat_all),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_DES_cipheronly_qat_all),
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_AES_docsis_qat_all),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_DES_docsis_qat_all),
8094 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8095 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8097 /** AES GCM Authenticated Encryption */
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_AES_GCM_authenticated_encryption_test_case_1),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_AES_GCM_authenticated_encryption_test_case_2),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_AES_GCM_authenticated_encryption_test_case_3),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_AES_GCM_authenticated_encryption_test_case_4),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_AES_GCM_authenticated_encryption_test_case_5),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_AES_GCM_authenticated_encryption_test_case_6),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_AES_GCM_authenticated_encryption_test_case_7),
8119 /** AES GCM Authenticated Decryption */
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_AES_GCM_authenticated_decryption_test_case_1),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_AES_GCM_authenticated_decryption_test_case_2),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_AES_GCM_authenticated_decryption_test_case_3),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_AES_GCM_authenticated_decryption_test_case_4),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_AES_GCM_authenticated_decryption_test_case_5),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_AES_GCM_authenticated_decryption_test_case_6),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_AES_GCM_authenticated_decryption_test_case_7),
8135 /** AES GCM Authenticated Encryption 192 bits key */
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_AES_GCM_auth_encryption_test_case_192_1),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_AES_GCM_auth_encryption_test_case_192_2),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_AES_GCM_auth_encryption_test_case_192_3),
8142 TEST_CASE_ST(ut_setup, ut_teardown,
8143 test_AES_GCM_auth_encryption_test_case_192_4),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_AES_GCM_auth_encryption_test_case_192_5),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_AES_GCM_auth_encryption_test_case_192_6),
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_AES_GCM_auth_encryption_test_case_192_7),
8151 /** AES GCM Authenticated Decryption 192 bits key */
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_AES_GCM_auth_decryption_test_case_192_1),
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_AES_GCM_auth_decryption_test_case_192_2),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_AES_GCM_auth_decryption_test_case_192_3),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_AES_GCM_auth_decryption_test_case_192_4),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_AES_GCM_auth_decryption_test_case_192_5),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_AES_GCM_auth_decryption_test_case_192_6),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_AES_GCM_auth_decryption_test_case_192_7),
8167 /** AES GCM Authenticated Encryption 256 bits key */
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_AES_GCM_auth_encryption_test_case_256_1),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_AES_GCM_auth_encryption_test_case_256_2),
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_AES_GCM_auth_encryption_test_case_256_3),
8174 TEST_CASE_ST(ut_setup, ut_teardown,
8175 test_AES_GCM_auth_encryption_test_case_256_4),
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 test_AES_GCM_auth_encryption_test_case_256_5),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 test_AES_GCM_auth_encryption_test_case_256_6),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 test_AES_GCM_auth_encryption_test_case_256_7),
8183 /** AES GMAC Authentication */
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 test_AES_GMAC_authentication_test_case_1),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 test_AES_GMAC_authentication_verify_test_case_1),
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_AES_GMAC_authentication_test_case_2),
8190 TEST_CASE_ST(ut_setup, ut_teardown,
8191 test_AES_GMAC_authentication_verify_test_case_2),
8192 TEST_CASE_ST(ut_setup, ut_teardown,
8193 test_AES_GMAC_authentication_test_case_3),
8194 TEST_CASE_ST(ut_setup, ut_teardown,
8195 test_AES_GMAC_authentication_verify_test_case_3),
8197 /** SNOW 3G encrypt only (UEA2) */
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_snow3g_encryption_test_case_1),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 test_snow3g_encryption_test_case_2),
8202 TEST_CASE_ST(ut_setup, ut_teardown,
8203 test_snow3g_encryption_test_case_3),
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 test_snow3g_encryption_test_case_4),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 test_snow3g_encryption_test_case_5),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_snow3g_encryption_test_case_1_oop),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_snow3g_decryption_test_case_1_oop),
8214 /** SNOW 3G decrypt only (UEA2) */
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_snow3g_decryption_test_case_1),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_snow3g_decryption_test_case_2),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_snow3g_decryption_test_case_3),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_snow3g_decryption_test_case_4),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_snow3g_decryption_test_case_5),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_snow3g_hash_generate_test_case_1),
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_snow3g_hash_generate_test_case_2),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_snow3g_hash_generate_test_case_3),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_snow3g_hash_verify_test_case_1),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_snow3g_hash_verify_test_case_2),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_snow3g_hash_verify_test_case_3),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_snow3g_cipher_auth_test_case_1),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_snow3g_auth_cipher_test_case_1),
8242 /** ZUC encrypt only (EEA3) */
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_zuc_encryption_test_case_1),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_zuc_encryption_test_case_2),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_zuc_encryption_test_case_3),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_zuc_encryption_test_case_4),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_zuc_encryption_test_case_5),
8254 /** ZUC authenticate (EIA3) */
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_zuc_hash_generate_test_case_6),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_zuc_hash_generate_test_case_7),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_zuc_hash_generate_test_case_8),
8262 /** ZUC alg-chain (EEA3/EIA3) */
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_zuc_cipher_auth_test_case_1),
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_zuc_cipher_auth_test_case_2),
8268 /** HMAC_MD5 Authentication */
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 test_MD5_HMAC_generate_case_1),
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_MD5_HMAC_verify_case_1),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_MD5_HMAC_generate_case_2),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_MD5_HMAC_verify_case_2),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_null_auth_only_operation),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_null_cipher_only_operation),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_null_cipher_auth_operation),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_null_auth_cipher_operation),
8289 TEST_CASE_ST(ut_setup, ut_teardown,
8290 test_kasumi_hash_generate_test_case_1),
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_kasumi_hash_generate_test_case_2),
8293 TEST_CASE_ST(ut_setup, ut_teardown,
8294 test_kasumi_hash_generate_test_case_3),
8295 TEST_CASE_ST(ut_setup, ut_teardown,
8296 test_kasumi_hash_generate_test_case_4),
8297 TEST_CASE_ST(ut_setup, ut_teardown,
8298 test_kasumi_hash_generate_test_case_5),
8299 TEST_CASE_ST(ut_setup, ut_teardown,
8300 test_kasumi_hash_generate_test_case_6),
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_kasumi_hash_verify_test_case_1),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_kasumi_hash_verify_test_case_2),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_kasumi_hash_verify_test_case_3),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_kasumi_hash_verify_test_case_4),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_kasumi_hash_verify_test_case_5),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_kasumi_encryption_test_case_1),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_kasumi_encryption_test_case_3),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_kasumi_auth_cipher_test_case_1),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_kasumi_cipher_auth_test_case_1),
8322 /** Negative tests */
8323 TEST_CASE_ST(ut_setup, ut_teardown,
8324 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8325 TEST_CASE_ST(ut_setup, ut_teardown,
8326 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 authentication_verify_AES128_GMAC_fail_data_corrupt),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8331 TEST_CASE_ST(ut_setup, ut_teardown,
8332 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8336 TEST_CASES_END() /**< NULL terminate unit test array */
8340 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8341 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8342 .setup = testsuite_setup,
8343 .teardown = testsuite_teardown,
8344 .unit_test_cases = {
8345 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8346 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8347 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8348 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8349 TEST_CASE_ST(ut_setup, ut_teardown,
8350 test_DES_cipheronly_mb_all),
8351 TEST_CASE_ST(ut_setup, ut_teardown,
8352 test_DES_docsis_mb_all),
8354 TEST_CASES_END() /**< NULL terminate unit test array */
8358 static struct unit_test_suite cryptodev_openssl_testsuite = {
8359 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8360 .setup = testsuite_setup,
8361 .teardown = testsuite_teardown,
8362 .unit_test_cases = {
8363 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_multi_session_random_usage),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_AES_chain_openssl_all),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_AES_cipheronly_openssl_all),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 test_3DES_chain_openssl_all),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_3DES_cipheronly_openssl_all),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 test_DES_cipheronly_openssl_all),
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 test_DES_docsis_openssl_all),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_authonly_openssl_all),
8381 /** AES GCM Authenticated Encryption */
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),
8414 /** AES GCM Authenticated Encryption 192 bits key */
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_AES_GCM_auth_encryption_test_case_192_1),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_AES_GCM_auth_encryption_test_case_192_2),
8419 TEST_CASE_ST(ut_setup, ut_teardown,
8420 test_AES_GCM_auth_encryption_test_case_192_3),
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_AES_GCM_auth_encryption_test_case_192_4),
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_AES_GCM_auth_encryption_test_case_192_5),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_AES_GCM_auth_encryption_test_case_192_6),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_AES_GCM_auth_encryption_test_case_192_7),
8430 /** AES GCM Authenticated Decryption 192 bits key */
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_AES_GCM_auth_decryption_test_case_192_1),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_AES_GCM_auth_decryption_test_case_192_2),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_AES_GCM_auth_decryption_test_case_192_3),
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_AES_GCM_auth_decryption_test_case_192_4),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_AES_GCM_auth_decryption_test_case_192_5),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_AES_GCM_auth_decryption_test_case_192_6),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_AES_GCM_auth_decryption_test_case_192_7),
8446 /** AES GCM Authenticated Encryption 256 bits key */
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_AES_GCM_auth_encryption_test_case_256_1),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_AES_GCM_auth_encryption_test_case_256_2),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_AES_GCM_auth_encryption_test_case_256_3),
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_AES_GCM_auth_encryption_test_case_256_4),
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_AES_GCM_auth_encryption_test_case_256_5),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_AES_GCM_auth_encryption_test_case_256_6),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_AES_GCM_auth_encryption_test_case_256_7),
8462 /** AES GCM Authenticated Decryption 256 bits key */
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_AES_GCM_auth_decryption_test_case_256_1),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_AES_GCM_auth_decryption_test_case_256_2),
8467 TEST_CASE_ST(ut_setup, ut_teardown,
8468 test_AES_GCM_auth_decryption_test_case_256_3),
8469 TEST_CASE_ST(ut_setup, ut_teardown,
8470 test_AES_GCM_auth_decryption_test_case_256_4),
8471 TEST_CASE_ST(ut_setup, ut_teardown,
8472 test_AES_GCM_auth_decryption_test_case_256_5),
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_AES_GCM_auth_decryption_test_case_256_6),
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_AES_GCM_auth_decryption_test_case_256_7),
8478 /** AES GMAC Authentication */
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_AES_GMAC_authentication_test_case_1),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_AES_GMAC_authentication_verify_test_case_1),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_AES_GMAC_authentication_test_case_2),
8485 TEST_CASE_ST(ut_setup, ut_teardown,
8486 test_AES_GMAC_authentication_verify_test_case_2),
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_AES_GMAC_authentication_test_case_3),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_AES_GMAC_authentication_verify_test_case_3),
8491 TEST_CASE_ST(ut_setup, ut_teardown,
8492 test_AES_GMAC_authentication_test_case_4),
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_AES_GMAC_authentication_verify_test_case_4),
8496 /** Scatter-Gather */
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8500 /** Negative tests */
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8505 TEST_CASE_ST(ut_setup, ut_teardown,
8506 authentication_verify_AES128_GMAC_fail_data_corrupt),
8507 TEST_CASE_ST(ut_setup, ut_teardown,
8508 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8509 TEST_CASE_ST(ut_setup, ut_teardown,
8510 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8511 TEST_CASE_ST(ut_setup, ut_teardown,
8512 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8514 TEST_CASES_END() /**< NULL terminate unit test array */
8518 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8519 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8520 .setup = testsuite_setup,
8521 .teardown = testsuite_teardown,
8522 .unit_test_cases = {
8523 /** AES GCM Authenticated Encryption */
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_GCM_authenticated_encryption_test_case_1),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_AES_GCM_authenticated_encryption_test_case_2),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_authenticated_encryption_test_case_3),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_GCM_authenticated_encryption_test_case_4),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_AES_GCM_authenticated_encryption_test_case_5),
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_GCM_authenticated_encryption_test_case_6),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_authenticated_encryption_test_case_7),
8539 /** AES GCM Authenticated Decryption */
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_authenticated_decryption_test_case_1),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_authenticated_decryption_test_case_2),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_authenticated_decryption_test_case_3),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_authenticated_decryption_test_case_4),
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_AES_GCM_authenticated_decryption_test_case_5),
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_authenticated_decryption_test_case_6),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_authenticated_decryption_test_case_7),
8555 /** AES GCM Authenticated Encryption 192 bits key */
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GCM_auth_encryption_test_case_192_1),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GCM_auth_encryption_test_case_192_2),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GCM_auth_encryption_test_case_192_3),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GCM_auth_encryption_test_case_192_4),
8564 TEST_CASE_ST(ut_setup, ut_teardown,
8565 test_AES_GCM_auth_encryption_test_case_192_5),
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GCM_auth_encryption_test_case_192_6),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_AES_GCM_auth_encryption_test_case_192_7),
8571 /** AES GCM Authenticated Decryption 192 bits key */
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_AES_GCM_auth_decryption_test_case_192_1),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_AES_GCM_auth_decryption_test_case_192_2),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_AES_GCM_auth_decryption_test_case_192_3),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_AES_GCM_auth_decryption_test_case_192_4),
8580 TEST_CASE_ST(ut_setup, ut_teardown,
8581 test_AES_GCM_auth_decryption_test_case_192_5),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_AES_GCM_auth_decryption_test_case_192_6),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_AES_GCM_auth_decryption_test_case_192_7),
8587 /** AES GCM Authenticated Encryption 256 bits key */
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_AES_GCM_auth_encryption_test_case_256_1),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_AES_GCM_auth_encryption_test_case_256_2),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_AES_GCM_auth_encryption_test_case_256_3),
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_AES_GCM_auth_encryption_test_case_256_4),
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_AES_GCM_auth_encryption_test_case_256_5),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_AES_GCM_auth_encryption_test_case_256_6),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_AES_GCM_auth_encryption_test_case_256_7),
8603 /** AES GCM Authenticated Decryption 256 bits key */
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_AES_GCM_auth_decryption_test_case_256_1),
8606 TEST_CASE_ST(ut_setup, ut_teardown,
8607 test_AES_GCM_auth_decryption_test_case_256_2),
8608 TEST_CASE_ST(ut_setup, ut_teardown,
8609 test_AES_GCM_auth_decryption_test_case_256_3),
8610 TEST_CASE_ST(ut_setup, ut_teardown,
8611 test_AES_GCM_auth_decryption_test_case_256_4),
8612 TEST_CASE_ST(ut_setup, ut_teardown,
8613 test_AES_GCM_auth_decryption_test_case_256_5),
8614 TEST_CASE_ST(ut_setup, ut_teardown,
8615 test_AES_GCM_auth_decryption_test_case_256_6),
8616 TEST_CASE_ST(ut_setup, ut_teardown,
8617 test_AES_GCM_auth_decryption_test_case_256_7),
8619 /** AES GCM Authenticated Encryption big aad size */
8620 TEST_CASE_ST(ut_setup, ut_teardown,
8621 test_AES_GCM_auth_encryption_test_case_aad_1),
8622 TEST_CASE_ST(ut_setup, ut_teardown,
8623 test_AES_GCM_auth_encryption_test_case_aad_2),
8625 /** AES GCM Authenticated Decryption big aad size */
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_AES_GCM_auth_decryption_test_case_aad_1),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_AES_GCM_auth_decryption_test_case_aad_2),
8631 /** AES GMAC Authentication */
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_AES_GMAC_authentication_test_case_1),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_AES_GMAC_authentication_verify_test_case_1),
8636 TEST_CASE_ST(ut_setup, ut_teardown,
8637 test_AES_GMAC_authentication_test_case_3),
8638 TEST_CASE_ST(ut_setup, ut_teardown,
8639 test_AES_GMAC_authentication_verify_test_case_3),
8640 TEST_CASE_ST(ut_setup, ut_teardown,
8641 test_AES_GMAC_authentication_test_case_4),
8642 TEST_CASE_ST(ut_setup, ut_teardown,
8643 test_AES_GMAC_authentication_verify_test_case_4),
8645 /** Negative tests */
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 authentication_verify_AES128_GMAC_fail_data_corrupt),
8648 TEST_CASE_ST(ut_setup, ut_teardown,
8649 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8651 /** Out of place tests */
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8657 /** Session-less tests */
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8663 /** Scatter-Gather */
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8667 TEST_CASES_END() /**< NULL terminate unit test array */
8671 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8672 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8673 .setup = testsuite_setup,
8674 .teardown = testsuite_teardown,
8675 .unit_test_cases = {
8676 /** KASUMI encrypt only (UEA1) */
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_kasumi_encryption_test_case_1),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_kasumi_encryption_test_case_1_sgl),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_kasumi_encryption_test_case_2),
8683 TEST_CASE_ST(ut_setup, ut_teardown,
8684 test_kasumi_encryption_test_case_3),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_kasumi_encryption_test_case_4),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_kasumi_encryption_test_case_5),
8689 /** KASUMI decrypt only (UEA1) */
8690 TEST_CASE_ST(ut_setup, ut_teardown,
8691 test_kasumi_decryption_test_case_1),
8692 TEST_CASE_ST(ut_setup, ut_teardown,
8693 test_kasumi_decryption_test_case_2),
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_kasumi_decryption_test_case_3),
8696 TEST_CASE_ST(ut_setup, ut_teardown,
8697 test_kasumi_decryption_test_case_4),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_kasumi_decryption_test_case_5),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_kasumi_encryption_test_case_1_oop),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_kasumi_encryption_test_case_1_oop_sgl),
8707 TEST_CASE_ST(ut_setup, ut_teardown,
8708 test_kasumi_decryption_test_case_1_oop),
8710 /** KASUMI hash only (UIA1) */
8711 TEST_CASE_ST(ut_setup, ut_teardown,
8712 test_kasumi_hash_generate_test_case_1),
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_kasumi_hash_generate_test_case_2),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_kasumi_hash_generate_test_case_3),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_kasumi_hash_generate_test_case_4),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_kasumi_hash_generate_test_case_5),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 test_kasumi_hash_generate_test_case_6),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 test_kasumi_hash_verify_test_case_1),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_kasumi_hash_verify_test_case_2),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_kasumi_hash_verify_test_case_3),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_kasumi_hash_verify_test_case_4),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_kasumi_hash_verify_test_case_5),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_kasumi_auth_cipher_test_case_1),
8735 TEST_CASE_ST(ut_setup, ut_teardown,
8736 test_kasumi_cipher_auth_test_case_1),
8737 TEST_CASES_END() /**< NULL terminate unit test array */
8740 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8741 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8742 .setup = testsuite_setup,
8743 .teardown = testsuite_teardown,
8744 .unit_test_cases = {
8745 /** SNOW 3G encrypt only (UEA2) */
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_snow3g_encryption_test_case_1),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_snow3g_encryption_test_case_2),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_snow3g_encryption_test_case_3),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_snow3g_encryption_test_case_4),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_snow3g_encryption_test_case_5),
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 test_snow3g_encryption_test_case_1_oop),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_snow3g_encryption_test_case_1_oop_sgl),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_snow3g_decryption_test_case_1_oop),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_snow3g_encryption_test_case_1_offset_oop),
8767 /** SNOW 3G decrypt only (UEA2) */
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_snow3g_decryption_test_case_1),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_snow3g_decryption_test_case_2),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_snow3g_decryption_test_case_3),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_snow3g_decryption_test_case_4),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_snow3g_decryption_test_case_5),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_snow3g_hash_generate_test_case_1),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_snow3g_hash_generate_test_case_2),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_snow3g_hash_generate_test_case_3),
8784 /* Tests with buffers which length is not byte-aligned */
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_snow3g_hash_generate_test_case_4),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_snow3g_hash_generate_test_case_5),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_snow3g_hash_generate_test_case_6),
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_snow3g_hash_verify_test_case_1),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_snow3g_hash_verify_test_case_2),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_snow3g_hash_verify_test_case_3),
8797 /* Tests with buffers which length is not byte-aligned */
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_snow3g_hash_verify_test_case_4),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_snow3g_hash_verify_test_case_5),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_snow3g_hash_verify_test_case_6),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_snow3g_cipher_auth_test_case_1),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_snow3g_auth_cipher_test_case_1),
8809 TEST_CASES_END() /**< NULL terminate unit test array */
8813 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8814 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8815 .setup = testsuite_setup,
8816 .teardown = testsuite_teardown,
8817 .unit_test_cases = {
8818 /** ZUC encrypt only (EEA3) */
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_zuc_encryption_test_case_1),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_zuc_encryption_test_case_2),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_zuc_encryption_test_case_3),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_zuc_encryption_test_case_4),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_zuc_encryption_test_case_5),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_zuc_hash_generate_test_case_1),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_zuc_hash_generate_test_case_2),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_zuc_hash_generate_test_case_3),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_zuc_hash_generate_test_case_4),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_zuc_hash_generate_test_case_5),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_zuc_encryption_test_case_6_sgl),
8841 TEST_CASES_END() /**< NULL terminate unit test array */
8845 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8846 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8847 .setup = testsuite_setup,
8848 .teardown = testsuite_teardown,
8849 .unit_test_cases = {
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_device_configure_invalid_dev_id),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_multi_session),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_AES_chain_dpaa2_sec_all),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_3DES_chain_dpaa2_sec_all),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_AES_cipheronly_dpaa2_sec_all),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_3DES_cipheronly_dpaa2_sec_all),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_authonly_dpaa2_sec_all),
8866 /** AES GCM Authenticated Encryption */
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_GCM_authenticated_encryption_test_case_1),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_GCM_authenticated_encryption_test_case_2),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_AES_GCM_authenticated_encryption_test_case_3),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_AES_GCM_authenticated_encryption_test_case_4),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_AES_GCM_authenticated_encryption_test_case_5),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_GCM_authenticated_encryption_test_case_6),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_AES_GCM_authenticated_encryption_test_case_7),
8882 /** AES GCM Authenticated Decryption */
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_GCM_authenticated_decryption_test_case_1),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_GCM_authenticated_decryption_test_case_2),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_AES_GCM_authenticated_decryption_test_case_3),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_GCM_authenticated_decryption_test_case_4),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_GCM_authenticated_decryption_test_case_5),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_GCM_authenticated_decryption_test_case_6),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_AES_GCM_authenticated_decryption_test_case_7),
8898 /** AES GCM Authenticated Encryption 192 bits key */
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_GCM_auth_encryption_test_case_192_1),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_GCM_auth_encryption_test_case_192_2),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_AES_GCM_auth_encryption_test_case_192_3),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_GCM_auth_encryption_test_case_192_4),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_GCM_auth_encryption_test_case_192_5),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_AES_GCM_auth_encryption_test_case_192_6),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_AES_GCM_auth_encryption_test_case_192_7),
8914 /** AES GCM Authenticated Decryption 192 bits key */
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_AES_GCM_auth_decryption_test_case_192_1),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_AES_GCM_auth_decryption_test_case_192_2),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_AES_GCM_auth_decryption_test_case_192_3),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_GCM_auth_decryption_test_case_192_4),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_GCM_auth_decryption_test_case_192_5),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_AES_GCM_auth_decryption_test_case_192_6),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_AES_GCM_auth_decryption_test_case_192_7),
8930 /** AES GCM Authenticated Encryption 256 bits key */
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_AES_GCM_auth_encryption_test_case_256_1),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_AES_GCM_auth_encryption_test_case_256_2),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_AES_GCM_auth_encryption_test_case_256_3),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_AES_GCM_auth_encryption_test_case_256_4),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_AES_GCM_auth_encryption_test_case_256_5),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_AES_GCM_auth_encryption_test_case_256_6),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_AES_GCM_auth_encryption_test_case_256_7),
8946 /** AES GCM Authenticated Decryption 256 bits key */
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 test_AES_GCM_auth_decryption_test_case_256_1),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_AES_GCM_auth_decryption_test_case_256_2),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_AES_GCM_auth_decryption_test_case_256_3),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_AES_GCM_auth_decryption_test_case_256_4),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_AES_GCM_auth_decryption_test_case_256_5),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_AES_GCM_auth_decryption_test_case_256_6),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_AES_GCM_auth_decryption_test_case_256_7),
8962 TEST_CASES_END() /**< NULL terminate unit test array */
8966 static struct unit_test_suite cryptodev_null_testsuite = {
8967 .suite_name = "Crypto Device NULL Unit Test Suite",
8968 .setup = testsuite_setup,
8969 .teardown = testsuite_teardown,
8970 .unit_test_cases = {
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_null_auth_only_operation),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_null_cipher_only_operation),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_null_cipher_auth_operation),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_null_auth_cipher_operation),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_null_invalid_operation),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_null_burst_operation),
8984 TEST_CASES_END() /**< NULL terminate unit test array */
8988 static struct unit_test_suite cryptodev_armv8_testsuite = {
8989 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8990 .setup = testsuite_setup,
8991 .teardown = testsuite_teardown,
8992 .unit_test_cases = {
8993 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8995 /** Negative tests */
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9001 TEST_CASES_END() /**< NULL terminate unit test array */
9006 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9008 gbl_driver_id = rte_cryptodev_driver_id_get(
9009 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9011 if (gbl_driver_id == -1) {
9012 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9013 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9014 "in config file to run this testsuite.\n");
9018 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9022 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9024 gbl_driver_id = rte_cryptodev_driver_id_get(
9025 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9027 if (gbl_driver_id == -1) {
9028 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9029 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9030 "in config file to run this testsuite.\n");
9034 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9038 test_cryptodev_openssl(void)
9040 gbl_driver_id = rte_cryptodev_driver_id_get(
9041 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9043 if (gbl_driver_id == -1) {
9044 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9045 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9046 "in config file to run this testsuite.\n");
9050 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9054 test_cryptodev_aesni_gcm(void)
9056 gbl_driver_id = rte_cryptodev_driver_id_get(
9057 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9059 if (gbl_driver_id == -1) {
9060 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9061 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9062 "in config file to run this testsuite.\n");
9066 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9070 test_cryptodev_null(void)
9072 gbl_driver_id = rte_cryptodev_driver_id_get(
9073 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9075 if (gbl_driver_id == -1) {
9076 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9077 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9078 "in config file to run this testsuite.\n");
9082 return unit_test_suite_runner(&cryptodev_null_testsuite);
9086 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9088 gbl_driver_id = rte_cryptodev_driver_id_get(
9089 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9091 if (gbl_driver_id == -1) {
9092 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9093 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9094 "in config file to run this testsuite.\n");
9098 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9102 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9104 gbl_driver_id = rte_cryptodev_driver_id_get(
9105 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9107 if (gbl_driver_id == -1) {
9108 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9109 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9110 "in config file to run this testsuite.\n");
9114 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9118 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9120 gbl_driver_id = rte_cryptodev_driver_id_get(
9121 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9123 if (gbl_driver_id == -1) {
9124 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9125 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9126 "in config file to run this testsuite.\n");
9130 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9134 test_cryptodev_armv8(void)
9136 gbl_driver_id = rte_cryptodev_driver_id_get(
9137 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9139 if (gbl_driver_id == -1) {
9140 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9141 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9142 "in config file to run this testsuite.\n");
9146 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9149 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9152 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9154 gbl_driver_id = rte_cryptodev_driver_id_get(
9155 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9157 if (gbl_driver_id == -1) {
9158 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9159 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9160 "in config file to run this testsuite.\n");
9164 if (rte_cryptodev_driver_id_get(
9165 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9166 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9167 " enabled in config file to run this testsuite.\n");
9170 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9173 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9178 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9180 gbl_driver_id = rte_cryptodev_driver_id_get(
9181 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9183 if (gbl_driver_id == -1) {
9184 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9185 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9186 "in config file to run this testsuite.\n");
9190 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9193 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9194 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9195 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9196 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9197 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9198 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9199 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9200 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9201 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9202 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);