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_AES_chain_mb_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_AESNI_MB_PMD)),
1608 BLKCIPHER_AES_CHAIN_TYPE);
1610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1612 return TEST_SUCCESS;
1615 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1618 test_AES_cipheronly_scheduler_all(void)
1620 struct crypto_testsuite_params *ts_params = &testsuite_params;
1623 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1624 ts_params->op_mpool,
1625 ts_params->session_mpool,
1626 ts_params->valid_devs[0],
1627 rte_cryptodev_driver_id_get(
1628 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1629 BLKCIPHER_AES_CIPHERONLY_TYPE);
1631 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1633 return TEST_SUCCESS;
1637 test_AES_chain_scheduler_all(void)
1639 struct crypto_testsuite_params *ts_params = &testsuite_params;
1642 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 ts_params->op_mpool,
1644 ts_params->session_mpool,
1645 ts_params->valid_devs[0],
1646 rte_cryptodev_driver_id_get(
1647 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1648 BLKCIPHER_AES_CHAIN_TYPE);
1650 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1652 return TEST_SUCCESS;
1656 test_authonly_scheduler_all(void)
1658 struct crypto_testsuite_params *ts_params = &testsuite_params;
1661 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1662 ts_params->op_mpool,
1663 ts_params->session_mpool,
1664 ts_params->valid_devs[0],
1665 rte_cryptodev_driver_id_get(
1666 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1667 BLKCIPHER_AUTHONLY_TYPE);
1669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1671 return TEST_SUCCESS;
1674 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1677 test_AES_chain_openssl_all(void)
1679 struct crypto_testsuite_params *ts_params = &testsuite_params;
1682 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1683 ts_params->op_mpool,
1684 ts_params->session_mpool,
1685 ts_params->valid_devs[0],
1686 rte_cryptodev_driver_id_get(
1687 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1688 BLKCIPHER_AES_CHAIN_TYPE);
1690 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1692 return TEST_SUCCESS;
1696 test_AES_cipheronly_openssl_all(void)
1698 struct crypto_testsuite_params *ts_params = &testsuite_params;
1701 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1702 ts_params->op_mpool,
1703 ts_params->session_mpool,
1704 ts_params->valid_devs[0],
1705 rte_cryptodev_driver_id_get(
1706 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1707 BLKCIPHER_AES_CIPHERONLY_TYPE);
1709 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 return TEST_SUCCESS;
1715 test_AES_chain_qat_all(void)
1717 struct crypto_testsuite_params *ts_params = &testsuite_params;
1720 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1721 ts_params->op_mpool,
1722 ts_params->session_mpool,
1723 ts_params->valid_devs[0],
1724 rte_cryptodev_driver_id_get(
1725 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1726 BLKCIPHER_AES_CHAIN_TYPE);
1728 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1730 return TEST_SUCCESS;
1734 test_AES_cipheronly_qat_all(void)
1736 struct crypto_testsuite_params *ts_params = &testsuite_params;
1739 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1740 ts_params->op_mpool,
1741 ts_params->session_mpool,
1742 ts_params->valid_devs[0],
1743 rte_cryptodev_driver_id_get(
1744 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1745 BLKCIPHER_AES_CIPHERONLY_TYPE);
1747 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1749 return TEST_SUCCESS;
1753 test_AES_chain_dpaa2_sec_all(void)
1755 struct crypto_testsuite_params *ts_params = &testsuite_params;
1758 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1759 ts_params->op_mpool,
1760 ts_params->session_mpool,
1761 ts_params->valid_devs[0],
1762 rte_cryptodev_driver_id_get(
1763 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1764 BLKCIPHER_AES_CHAIN_TYPE);
1766 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1768 return TEST_SUCCESS;
1772 test_AES_cipheronly_dpaa2_sec_all(void)
1774 struct crypto_testsuite_params *ts_params = &testsuite_params;
1777 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1778 ts_params->op_mpool,
1779 ts_params->session_mpool,
1780 ts_params->valid_devs[0],
1781 rte_cryptodev_driver_id_get(
1782 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1783 BLKCIPHER_AES_CIPHERONLY_TYPE);
1785 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1787 return TEST_SUCCESS;
1791 test_authonly_dpaa2_sec_all(void)
1793 struct crypto_testsuite_params *ts_params = &testsuite_params;
1796 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1797 ts_params->op_mpool,
1798 ts_params->session_mpool,
1799 ts_params->valid_devs[0],
1800 rte_cryptodev_driver_id_get(
1801 RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
1802 BLKCIPHER_AUTHONLY_TYPE);
1804 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1806 return TEST_SUCCESS;
1810 test_authonly_openssl_all(void)
1812 struct crypto_testsuite_params *ts_params = &testsuite_params;
1815 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1816 ts_params->op_mpool,
1817 ts_params->session_mpool,
1818 ts_params->valid_devs[0],
1819 rte_cryptodev_driver_id_get(
1820 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1821 BLKCIPHER_AUTHONLY_TYPE);
1823 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1825 return TEST_SUCCESS;
1829 test_AES_chain_armv8_all(void)
1831 struct crypto_testsuite_params *ts_params = &testsuite_params;
1834 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1835 ts_params->op_mpool,
1836 ts_params->session_mpool,
1837 ts_params->valid_devs[0],
1838 rte_cryptodev_driver_id_get(
1839 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1840 BLKCIPHER_AES_CHAIN_TYPE);
1842 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1844 return TEST_SUCCESS;
1847 /* ***** SNOW 3G Tests ***** */
1849 create_wireless_algo_hash_session(uint8_t dev_id,
1850 const uint8_t *key, const uint8_t key_len,
1851 const uint8_t iv_len, const uint8_t auth_len,
1852 enum rte_crypto_auth_operation op,
1853 enum rte_crypto_auth_algorithm algo)
1855 uint8_t hash_key[key_len];
1857 struct crypto_testsuite_params *ts_params = &testsuite_params;
1858 struct crypto_unittest_params *ut_params = &unittest_params;
1860 memcpy(hash_key, key, key_len);
1862 TEST_HEXDUMP(stdout, "key:", key, key_len);
1864 /* Setup Authentication Parameters */
1865 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1866 ut_params->auth_xform.next = NULL;
1868 ut_params->auth_xform.auth.op = op;
1869 ut_params->auth_xform.auth.algo = algo;
1870 ut_params->auth_xform.auth.key.length = key_len;
1871 ut_params->auth_xform.auth.key.data = hash_key;
1872 ut_params->auth_xform.auth.digest_length = auth_len;
1873 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1874 ut_params->auth_xform.auth.iv.length = iv_len;
1875 ut_params->sess = rte_cryptodev_sym_session_create(
1876 ts_params->session_mpool);
1878 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1879 &ut_params->auth_xform, ts_params->session_mpool);
1880 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1885 create_wireless_algo_cipher_session(uint8_t dev_id,
1886 enum rte_crypto_cipher_operation op,
1887 enum rte_crypto_cipher_algorithm algo,
1888 const uint8_t *key, const uint8_t key_len,
1891 uint8_t cipher_key[key_len];
1893 struct crypto_testsuite_params *ts_params = &testsuite_params;
1894 struct crypto_unittest_params *ut_params = &unittest_params;
1896 memcpy(cipher_key, key, key_len);
1898 /* Setup Cipher Parameters */
1899 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1900 ut_params->cipher_xform.next = NULL;
1902 ut_params->cipher_xform.cipher.algo = algo;
1903 ut_params->cipher_xform.cipher.op = op;
1904 ut_params->cipher_xform.cipher.key.data = cipher_key;
1905 ut_params->cipher_xform.cipher.key.length = key_len;
1906 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1907 ut_params->cipher_xform.cipher.iv.length = iv_len;
1909 TEST_HEXDUMP(stdout, "key:", key, key_len);
1911 /* Create Crypto session */
1912 ut_params->sess = rte_cryptodev_sym_session_create(
1913 ts_params->session_mpool);
1915 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1916 &ut_params->cipher_xform, ts_params->session_mpool);
1917 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1922 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1923 unsigned int cipher_len,
1924 unsigned int cipher_offset)
1926 struct crypto_testsuite_params *ts_params = &testsuite_params;
1927 struct crypto_unittest_params *ut_params = &unittest_params;
1929 /* Generate Crypto op data structure */
1930 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1931 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1932 TEST_ASSERT_NOT_NULL(ut_params->op,
1933 "Failed to allocate pktmbuf offload");
1935 /* Set crypto operation data parameters */
1936 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1938 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1940 /* set crypto operation source mbuf */
1941 sym_op->m_src = ut_params->ibuf;
1944 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1946 sym_op->cipher.data.length = cipher_len;
1947 sym_op->cipher.data.offset = cipher_offset;
1952 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1953 unsigned int cipher_len,
1954 unsigned int cipher_offset)
1956 struct crypto_testsuite_params *ts_params = &testsuite_params;
1957 struct crypto_unittest_params *ut_params = &unittest_params;
1959 /* Generate Crypto op data structure */
1960 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1961 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1962 TEST_ASSERT_NOT_NULL(ut_params->op,
1963 "Failed to allocate pktmbuf offload");
1965 /* Set crypto operation data parameters */
1966 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1968 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1970 /* set crypto operation source mbuf */
1971 sym_op->m_src = ut_params->ibuf;
1972 sym_op->m_dst = ut_params->obuf;
1975 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1977 sym_op->cipher.data.length = cipher_len;
1978 sym_op->cipher.data.offset = cipher_offset;
1983 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1984 enum rte_crypto_cipher_operation cipher_op,
1985 enum rte_crypto_auth_operation auth_op,
1986 enum rte_crypto_auth_algorithm auth_algo,
1987 enum rte_crypto_cipher_algorithm cipher_algo,
1988 const uint8_t *key, uint8_t key_len,
1989 uint8_t auth_iv_len, uint8_t auth_len,
1990 uint8_t cipher_iv_len)
1993 uint8_t cipher_auth_key[key_len];
1995 struct crypto_testsuite_params *ts_params = &testsuite_params;
1996 struct crypto_unittest_params *ut_params = &unittest_params;
1998 memcpy(cipher_auth_key, key, key_len);
2000 /* Setup Authentication Parameters */
2001 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2002 ut_params->auth_xform.next = NULL;
2004 ut_params->auth_xform.auth.op = auth_op;
2005 ut_params->auth_xform.auth.algo = auth_algo;
2006 ut_params->auth_xform.auth.key.length = key_len;
2007 /* Hash key = cipher key */
2008 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2009 ut_params->auth_xform.auth.digest_length = auth_len;
2010 /* Auth IV will be after cipher IV */
2011 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2012 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2014 /* Setup Cipher Parameters */
2015 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2016 ut_params->cipher_xform.next = &ut_params->auth_xform;
2018 ut_params->cipher_xform.cipher.algo = cipher_algo;
2019 ut_params->cipher_xform.cipher.op = cipher_op;
2020 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2021 ut_params->cipher_xform.cipher.key.length = key_len;
2022 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2023 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2025 TEST_HEXDUMP(stdout, "key:", key, key_len);
2027 /* Create Crypto session*/
2028 ut_params->sess = rte_cryptodev_sym_session_create(
2029 ts_params->session_mpool);
2031 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2032 &ut_params->cipher_xform, ts_params->session_mpool);
2034 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2039 create_wireless_cipher_auth_session(uint8_t dev_id,
2040 enum rte_crypto_cipher_operation cipher_op,
2041 enum rte_crypto_auth_operation auth_op,
2042 enum rte_crypto_auth_algorithm auth_algo,
2043 enum rte_crypto_cipher_algorithm cipher_algo,
2044 const struct wireless_test_data *tdata)
2046 const uint8_t key_len = tdata->key.len;
2047 uint8_t cipher_auth_key[key_len];
2049 struct crypto_testsuite_params *ts_params = &testsuite_params;
2050 struct crypto_unittest_params *ut_params = &unittest_params;
2051 const uint8_t *key = tdata->key.data;
2052 const uint8_t auth_len = tdata->digest.len;
2053 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2054 uint8_t auth_iv_len = tdata->auth_iv.len;
2056 memcpy(cipher_auth_key, key, key_len);
2058 /* Setup Authentication Parameters */
2059 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2060 ut_params->auth_xform.next = NULL;
2062 ut_params->auth_xform.auth.op = auth_op;
2063 ut_params->auth_xform.auth.algo = auth_algo;
2064 ut_params->auth_xform.auth.key.length = key_len;
2065 /* Hash key = cipher key */
2066 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2067 ut_params->auth_xform.auth.digest_length = auth_len;
2068 /* Auth IV will be after cipher IV */
2069 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2070 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2072 /* Setup Cipher Parameters */
2073 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2074 ut_params->cipher_xform.next = &ut_params->auth_xform;
2076 ut_params->cipher_xform.cipher.algo = cipher_algo;
2077 ut_params->cipher_xform.cipher.op = cipher_op;
2078 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2079 ut_params->cipher_xform.cipher.key.length = key_len;
2080 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2081 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2084 TEST_HEXDUMP(stdout, "key:", key, key_len);
2086 /* Create Crypto session*/
2087 ut_params->sess = rte_cryptodev_sym_session_create(
2088 ts_params->session_mpool);
2090 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2091 &ut_params->cipher_xform, ts_params->session_mpool);
2093 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2098 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2099 const struct wireless_test_data *tdata)
2101 return create_wireless_cipher_auth_session(dev_id,
2102 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2103 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2104 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2108 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2109 enum rte_crypto_cipher_operation cipher_op,
2110 enum rte_crypto_auth_operation auth_op,
2111 enum rte_crypto_auth_algorithm auth_algo,
2112 enum rte_crypto_cipher_algorithm cipher_algo,
2113 const uint8_t *key, const uint8_t key_len,
2114 uint8_t auth_iv_len, uint8_t auth_len,
2115 uint8_t cipher_iv_len)
2117 uint8_t auth_cipher_key[key_len];
2119 struct crypto_testsuite_params *ts_params = &testsuite_params;
2120 struct crypto_unittest_params *ut_params = &unittest_params;
2122 memcpy(auth_cipher_key, key, key_len);
2124 /* Setup Authentication Parameters */
2125 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2126 ut_params->auth_xform.auth.op = auth_op;
2127 ut_params->auth_xform.next = &ut_params->cipher_xform;
2128 ut_params->auth_xform.auth.algo = auth_algo;
2129 ut_params->auth_xform.auth.key.length = key_len;
2130 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2131 ut_params->auth_xform.auth.digest_length = auth_len;
2132 /* Auth IV will be after cipher IV */
2133 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2134 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2136 /* Setup Cipher Parameters */
2137 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2138 ut_params->cipher_xform.next = NULL;
2139 ut_params->cipher_xform.cipher.algo = cipher_algo;
2140 ut_params->cipher_xform.cipher.op = cipher_op;
2141 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2142 ut_params->cipher_xform.cipher.key.length = key_len;
2143 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2144 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2146 TEST_HEXDUMP(stdout, "key:", key, key_len);
2148 /* Create Crypto session*/
2149 ut_params->sess = rte_cryptodev_sym_session_create(
2150 ts_params->session_mpool);
2152 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2153 &ut_params->auth_xform, ts_params->session_mpool);
2155 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2161 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2162 unsigned int auth_tag_len,
2163 const uint8_t *iv, unsigned int iv_len,
2164 unsigned int data_pad_len,
2165 enum rte_crypto_auth_operation op,
2166 unsigned int auth_len, unsigned int auth_offset)
2168 struct crypto_testsuite_params *ts_params = &testsuite_params;
2170 struct crypto_unittest_params *ut_params = &unittest_params;
2172 /* Generate Crypto op data structure */
2173 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2174 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2175 TEST_ASSERT_NOT_NULL(ut_params->op,
2176 "Failed to allocate pktmbuf offload");
2178 /* Set crypto operation data parameters */
2179 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2181 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2183 /* set crypto operation source mbuf */
2184 sym_op->m_src = ut_params->ibuf;
2187 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2190 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2191 ut_params->ibuf, auth_tag_len);
2193 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2194 "no room to append auth tag");
2195 ut_params->digest = sym_op->auth.digest.data;
2196 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2197 ut_params->ibuf, data_pad_len);
2198 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2199 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2201 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2203 TEST_HEXDUMP(stdout, "digest:",
2204 sym_op->auth.digest.data,
2207 sym_op->auth.data.length = auth_len;
2208 sym_op->auth.data.offset = auth_offset;
2214 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2215 enum rte_crypto_auth_operation op)
2217 struct crypto_testsuite_params *ts_params = &testsuite_params;
2218 struct crypto_unittest_params *ut_params = &unittest_params;
2220 const uint8_t *auth_tag = tdata->digest.data;
2221 const unsigned int auth_tag_len = tdata->digest.len;
2222 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2223 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2225 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2226 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2227 const uint8_t *auth_iv = tdata->auth_iv.data;
2228 const uint8_t auth_iv_len = tdata->auth_iv.len;
2229 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2230 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2232 /* Generate Crypto op data structure */
2233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2235 TEST_ASSERT_NOT_NULL(ut_params->op,
2236 "Failed to allocate pktmbuf offload");
2237 /* Set crypto operation data parameters */
2238 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2240 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2242 /* set crypto operation source mbuf */
2243 sym_op->m_src = ut_params->ibuf;
2246 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2247 ut_params->ibuf, auth_tag_len);
2249 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2250 "no room to append auth tag");
2251 ut_params->digest = sym_op->auth.digest.data;
2252 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2253 ut_params->ibuf, data_pad_len);
2254 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2255 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2257 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2259 TEST_HEXDUMP(stdout, "digest:",
2260 sym_op->auth.digest.data,
2263 /* Copy cipher and auth IVs at the end of the crypto operation */
2264 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2266 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2267 iv_ptr += cipher_iv_len;
2268 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2270 sym_op->cipher.data.length = cipher_len;
2271 sym_op->cipher.data.offset = 0;
2272 sym_op->auth.data.length = auth_len;
2273 sym_op->auth.data.offset = 0;
2279 create_zuc_cipher_hash_generate_operation(
2280 const struct wireless_test_data *tdata)
2282 return create_wireless_cipher_hash_operation(tdata,
2283 RTE_CRYPTO_AUTH_OP_GENERATE);
2287 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2288 const unsigned auth_tag_len,
2289 const uint8_t *auth_iv, uint8_t auth_iv_len,
2290 unsigned data_pad_len,
2291 enum rte_crypto_auth_operation op,
2292 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2293 const unsigned cipher_len, const unsigned cipher_offset,
2294 const unsigned auth_len, const unsigned auth_offset)
2296 struct crypto_testsuite_params *ts_params = &testsuite_params;
2297 struct crypto_unittest_params *ut_params = &unittest_params;
2299 /* Generate Crypto op data structure */
2300 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2301 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2302 TEST_ASSERT_NOT_NULL(ut_params->op,
2303 "Failed to allocate pktmbuf offload");
2304 /* Set crypto operation data parameters */
2305 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2307 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2309 /* set crypto operation source mbuf */
2310 sym_op->m_src = ut_params->ibuf;
2313 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2314 ut_params->ibuf, auth_tag_len);
2316 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2317 "no room to append auth tag");
2318 ut_params->digest = sym_op->auth.digest.data;
2319 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2320 ut_params->ibuf, data_pad_len);
2321 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2322 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2324 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2326 TEST_HEXDUMP(stdout, "digest:",
2327 sym_op->auth.digest.data,
2330 /* Copy cipher and auth IVs at the end of the crypto operation */
2331 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2333 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2334 iv_ptr += cipher_iv_len;
2335 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2337 sym_op->cipher.data.length = cipher_len;
2338 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2339 sym_op->auth.data.length = auth_len;
2340 sym_op->auth.data.offset = auth_offset + cipher_offset;
2346 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2347 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2348 const uint8_t *auth_iv, uint8_t auth_iv_len,
2349 unsigned int data_pad_len,
2350 unsigned int cipher_len, unsigned int cipher_offset,
2351 unsigned int auth_len, unsigned int auth_offset)
2353 struct crypto_testsuite_params *ts_params = &testsuite_params;
2354 struct crypto_unittest_params *ut_params = &unittest_params;
2356 /* Generate Crypto op data structure */
2357 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2358 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2359 TEST_ASSERT_NOT_NULL(ut_params->op,
2360 "Failed to allocate pktmbuf offload");
2362 /* Set crypto operation data parameters */
2363 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2365 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2367 /* set crypto operation source mbuf */
2368 sym_op->m_src = ut_params->ibuf;
2371 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2372 ut_params->ibuf, auth_tag_len);
2374 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2375 "no room to append auth tag");
2377 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2378 ut_params->ibuf, data_pad_len);
2380 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2382 TEST_HEXDUMP(stdout, "digest:",
2383 sym_op->auth.digest.data,
2386 /* Copy cipher and auth IVs at the end of the crypto operation */
2387 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2389 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2390 iv_ptr += cipher_iv_len;
2391 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2393 sym_op->cipher.data.length = cipher_len;
2394 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2396 sym_op->auth.data.length = auth_len;
2397 sym_op->auth.data.offset = auth_offset + cipher_offset;
2403 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2405 struct crypto_testsuite_params *ts_params = &testsuite_params;
2406 struct crypto_unittest_params *ut_params = &unittest_params;
2409 unsigned plaintext_pad_len;
2410 unsigned plaintext_len;
2413 /* Create SNOW 3G session */
2414 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2415 tdata->key.data, tdata->key.len,
2416 tdata->auth_iv.len, tdata->digest.len,
2417 RTE_CRYPTO_AUTH_OP_GENERATE,
2418 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2422 /* alloc mbuf and set payload */
2423 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2425 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2426 rte_pktmbuf_tailroom(ut_params->ibuf));
2428 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2429 /* Append data which is padded to a multiple of */
2430 /* the algorithms block size */
2431 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2432 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2434 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2436 /* Create SNOW 3G operation */
2437 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2438 tdata->auth_iv.data, tdata->auth_iv.len,
2439 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2440 tdata->validAuthLenInBits.len,
2445 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2447 ut_params->obuf = ut_params->op->sym->m_src;
2448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2449 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2450 + plaintext_pad_len;
2453 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2456 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2457 "SNOW 3G Generated auth tag not as expected");
2463 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2465 struct crypto_testsuite_params *ts_params = &testsuite_params;
2466 struct crypto_unittest_params *ut_params = &unittest_params;
2469 unsigned plaintext_pad_len;
2470 unsigned plaintext_len;
2473 /* Create SNOW 3G session */
2474 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2475 tdata->key.data, tdata->key.len,
2476 tdata->auth_iv.len, tdata->digest.len,
2477 RTE_CRYPTO_AUTH_OP_VERIFY,
2478 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2481 /* alloc mbuf and set payload */
2482 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2484 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2485 rte_pktmbuf_tailroom(ut_params->ibuf));
2487 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2488 /* Append data which is padded to a multiple of */
2489 /* the algorithms block size */
2490 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2491 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2493 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2495 /* Create SNOW 3G operation */
2496 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2498 tdata->auth_iv.data, tdata->auth_iv.len,
2500 RTE_CRYPTO_AUTH_OP_VERIFY,
2501 tdata->validAuthLenInBits.len,
2506 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2509 ut_params->obuf = ut_params->op->sym->m_src;
2510 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2511 + plaintext_pad_len;
2514 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2523 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2525 struct crypto_testsuite_params *ts_params = &testsuite_params;
2526 struct crypto_unittest_params *ut_params = &unittest_params;
2529 unsigned plaintext_pad_len;
2530 unsigned plaintext_len;
2533 /* Create KASUMI session */
2534 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2535 tdata->key.data, tdata->key.len,
2536 tdata->auth_iv.len, tdata->digest.len,
2537 RTE_CRYPTO_AUTH_OP_GENERATE,
2538 RTE_CRYPTO_AUTH_KASUMI_F9);
2542 /* alloc mbuf and set payload */
2543 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2545 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2546 rte_pktmbuf_tailroom(ut_params->ibuf));
2548 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2549 /* Append data which is padded to a multiple of */
2550 /* the algorithms block size */
2551 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2552 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2554 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2556 /* Create KASUMI operation */
2557 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2558 tdata->auth_iv.data, tdata->auth_iv.len,
2559 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2560 tdata->validAuthLenInBits.len,
2565 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2567 ut_params->obuf = ut_params->op->sym->m_src;
2568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2569 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2570 + plaintext_pad_len;
2573 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2576 DIGEST_BYTE_LENGTH_KASUMI_F9,
2577 "KASUMI Generated auth tag not as expected");
2583 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2585 struct crypto_testsuite_params *ts_params = &testsuite_params;
2586 struct crypto_unittest_params *ut_params = &unittest_params;
2589 unsigned plaintext_pad_len;
2590 unsigned plaintext_len;
2593 /* Create KASUMI session */
2594 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2595 tdata->key.data, tdata->key.len,
2596 tdata->auth_iv.len, tdata->digest.len,
2597 RTE_CRYPTO_AUTH_OP_VERIFY,
2598 RTE_CRYPTO_AUTH_KASUMI_F9);
2601 /* alloc mbuf and set payload */
2602 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2604 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2605 rte_pktmbuf_tailroom(ut_params->ibuf));
2607 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2608 /* Append data which is padded to a multiple */
2609 /* of the algorithms block size */
2610 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2611 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2613 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2615 /* Create KASUMI operation */
2616 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2618 tdata->auth_iv.data, tdata->auth_iv.len,
2620 RTE_CRYPTO_AUTH_OP_VERIFY,
2621 tdata->validAuthLenInBits.len,
2626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2629 ut_params->obuf = ut_params->op->sym->m_src;
2630 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2631 + plaintext_pad_len;
2634 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2643 test_snow3g_hash_generate_test_case_1(void)
2645 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2649 test_snow3g_hash_generate_test_case_2(void)
2651 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2655 test_snow3g_hash_generate_test_case_3(void)
2657 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2661 test_snow3g_hash_generate_test_case_4(void)
2663 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2667 test_snow3g_hash_generate_test_case_5(void)
2669 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2673 test_snow3g_hash_generate_test_case_6(void)
2675 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2679 test_snow3g_hash_verify_test_case_1(void)
2681 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2686 test_snow3g_hash_verify_test_case_2(void)
2688 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2692 test_snow3g_hash_verify_test_case_3(void)
2694 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2698 test_snow3g_hash_verify_test_case_4(void)
2700 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2704 test_snow3g_hash_verify_test_case_5(void)
2706 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2710 test_snow3g_hash_verify_test_case_6(void)
2712 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2716 test_kasumi_hash_generate_test_case_1(void)
2718 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2722 test_kasumi_hash_generate_test_case_2(void)
2724 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2728 test_kasumi_hash_generate_test_case_3(void)
2730 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2734 test_kasumi_hash_generate_test_case_4(void)
2736 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2740 test_kasumi_hash_generate_test_case_5(void)
2742 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2746 test_kasumi_hash_generate_test_case_6(void)
2748 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2752 test_kasumi_hash_verify_test_case_1(void)
2754 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2758 test_kasumi_hash_verify_test_case_2(void)
2760 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2764 test_kasumi_hash_verify_test_case_3(void)
2766 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2770 test_kasumi_hash_verify_test_case_4(void)
2772 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2776 test_kasumi_hash_verify_test_case_5(void)
2778 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2782 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2784 struct crypto_testsuite_params *ts_params = &testsuite_params;
2785 struct crypto_unittest_params *ut_params = &unittest_params;
2788 uint8_t *plaintext, *ciphertext;
2789 unsigned plaintext_pad_len;
2790 unsigned plaintext_len;
2792 /* Create KASUMI session */
2793 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2795 RTE_CRYPTO_CIPHER_KASUMI_F8,
2796 tdata->key.data, tdata->key.len,
2797 tdata->cipher_iv.len);
2801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2803 /* Clear mbuf payload */
2804 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2805 rte_pktmbuf_tailroom(ut_params->ibuf));
2807 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2808 /* Append data which is padded to a multiple */
2809 /* of the algorithms block size */
2810 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2811 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2813 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2815 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2817 /* Create KASUMI operation */
2818 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2819 tdata->cipher_iv.len,
2820 tdata->plaintext.len,
2825 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2827 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2829 ut_params->obuf = ut_params->op->sym->m_dst;
2830 if (ut_params->obuf)
2831 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2833 ciphertext = plaintext;
2835 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2838 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2840 tdata->ciphertext.data,
2841 tdata->validCipherLenInBits.len,
2842 "KASUMI Ciphertext data not as expected");
2847 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2849 struct crypto_testsuite_params *ts_params = &testsuite_params;
2850 struct crypto_unittest_params *ut_params = &unittest_params;
2854 unsigned int plaintext_pad_len;
2855 unsigned int plaintext_len;
2857 uint8_t buffer[10000];
2858 const uint8_t *ciphertext;
2860 struct rte_cryptodev_info dev_info;
2862 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2863 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2864 printf("Device doesn't support scatter-gather. "
2869 /* Create KASUMI session */
2870 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2871 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2872 RTE_CRYPTO_CIPHER_KASUMI_F8,
2873 tdata->key.data, tdata->key.len,
2874 tdata->cipher_iv.len);
2878 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2881 /* Append data which is padded to a multiple */
2882 /* of the algorithms block size */
2883 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2885 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2886 plaintext_pad_len, 10, 0);
2888 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2890 /* Create KASUMI operation */
2891 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2892 tdata->cipher_iv.len,
2893 tdata->plaintext.len,
2898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2902 ut_params->obuf = ut_params->op->sym->m_dst;
2904 if (ut_params->obuf)
2905 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2906 plaintext_len, buffer);
2908 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2909 plaintext_len, buffer);
2912 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2917 tdata->ciphertext.data,
2918 tdata->validCipherLenInBits.len,
2919 "KASUMI Ciphertext data not as expected");
2924 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2926 struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 struct crypto_unittest_params *ut_params = &unittest_params;
2930 uint8_t *plaintext, *ciphertext;
2931 unsigned plaintext_pad_len;
2932 unsigned plaintext_len;
2934 /* Create KASUMI session */
2935 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2936 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2937 RTE_CRYPTO_CIPHER_KASUMI_F8,
2938 tdata->key.data, tdata->key.len,
2939 tdata->cipher_iv.len);
2943 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2944 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2946 /* Clear mbuf payload */
2947 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2948 rte_pktmbuf_tailroom(ut_params->ibuf));
2950 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2951 /* Append data which is padded to a multiple */
2952 /* of the algorithms block size */
2953 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2954 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2956 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2957 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2959 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2961 /* Create KASUMI operation */
2962 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2963 tdata->cipher_iv.len,
2964 tdata->plaintext.len,
2969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2973 ut_params->obuf = ut_params->op->sym->m_dst;
2974 if (ut_params->obuf)
2975 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2977 ciphertext = plaintext;
2979 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2982 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2984 tdata->ciphertext.data,
2985 tdata->validCipherLenInBits.len,
2986 "KASUMI Ciphertext data not as expected");
2991 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2993 struct crypto_testsuite_params *ts_params = &testsuite_params;
2994 struct crypto_unittest_params *ut_params = &unittest_params;
2997 unsigned int plaintext_pad_len;
2998 unsigned int plaintext_len;
3000 const uint8_t *ciphertext;
3001 uint8_t buffer[2048];
3003 struct rte_cryptodev_info dev_info;
3005 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3006 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3007 printf("Device doesn't support scatter-gather. "
3012 /* Create KASUMI session */
3013 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3014 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3015 RTE_CRYPTO_CIPHER_KASUMI_F8,
3016 tdata->key.data, tdata->key.len,
3017 tdata->cipher_iv.len);
3021 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3022 /* Append data which is padded to a multiple */
3023 /* of the algorithms block size */
3024 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3026 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3027 plaintext_pad_len, 10, 0);
3028 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3029 plaintext_pad_len, 3, 0);
3031 /* Append data which is padded to a multiple */
3032 /* of the algorithms block size */
3033 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3035 /* Create KASUMI operation */
3036 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3037 tdata->cipher_iv.len,
3038 tdata->plaintext.len,
3043 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3045 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3047 ut_params->obuf = ut_params->op->sym->m_dst;
3048 if (ut_params->obuf)
3049 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3050 plaintext_pad_len, buffer);
3052 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3053 plaintext_pad_len, buffer);
3056 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3058 tdata->ciphertext.data,
3059 tdata->validCipherLenInBits.len,
3060 "KASUMI Ciphertext data not as expected");
3066 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3068 struct crypto_testsuite_params *ts_params = &testsuite_params;
3069 struct crypto_unittest_params *ut_params = &unittest_params;
3072 uint8_t *ciphertext, *plaintext;
3073 unsigned ciphertext_pad_len;
3074 unsigned ciphertext_len;
3076 /* Create KASUMI session */
3077 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3078 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3079 RTE_CRYPTO_CIPHER_KASUMI_F8,
3080 tdata->key.data, tdata->key.len,
3081 tdata->cipher_iv.len);
3085 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3086 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3088 /* Clear mbuf payload */
3089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3090 rte_pktmbuf_tailroom(ut_params->ibuf));
3092 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3093 /* Append data which is padded to a multiple */
3094 /* of the algorithms block size */
3095 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3096 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3097 ciphertext_pad_len);
3098 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3099 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3101 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3103 /* Create KASUMI operation */
3104 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3105 tdata->cipher_iv.len,
3106 tdata->ciphertext.len,
3111 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3113 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3115 ut_params->obuf = ut_params->op->sym->m_dst;
3116 if (ut_params->obuf)
3117 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3119 plaintext = ciphertext;
3121 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3124 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3126 tdata->plaintext.data,
3127 tdata->validCipherLenInBits.len,
3128 "KASUMI Plaintext data not as expected");
3133 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3135 struct crypto_testsuite_params *ts_params = &testsuite_params;
3136 struct crypto_unittest_params *ut_params = &unittest_params;
3139 uint8_t *ciphertext, *plaintext;
3140 unsigned ciphertext_pad_len;
3141 unsigned ciphertext_len;
3143 /* Create KASUMI session */
3144 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3145 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3146 RTE_CRYPTO_CIPHER_KASUMI_F8,
3147 tdata->key.data, tdata->key.len,
3148 tdata->cipher_iv.len);
3152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3154 /* Clear mbuf payload */
3155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3156 rte_pktmbuf_tailroom(ut_params->ibuf));
3158 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3159 /* Append data which is padded to a multiple */
3160 /* of the algorithms block size */
3161 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3162 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3163 ciphertext_pad_len);
3164 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3166 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3168 /* Create KASUMI operation */
3169 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3170 tdata->cipher_iv.len,
3171 tdata->ciphertext.len,
3176 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3178 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3180 ut_params->obuf = ut_params->op->sym->m_dst;
3181 if (ut_params->obuf)
3182 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3184 plaintext = ciphertext;
3186 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3189 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3191 tdata->plaintext.data,
3192 tdata->validCipherLenInBits.len,
3193 "KASUMI Plaintext data not as expected");
3198 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3200 struct crypto_testsuite_params *ts_params = &testsuite_params;
3201 struct crypto_unittest_params *ut_params = &unittest_params;
3204 uint8_t *plaintext, *ciphertext;
3205 unsigned plaintext_pad_len;
3206 unsigned plaintext_len;
3208 /* Create SNOW 3G session */
3209 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3210 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3211 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3212 tdata->key.data, tdata->key.len,
3213 tdata->cipher_iv.len);
3217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3219 /* Clear mbuf payload */
3220 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3221 rte_pktmbuf_tailroom(ut_params->ibuf));
3223 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3224 /* Append data which is padded to a multiple of */
3225 /* the algorithms block size */
3226 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3227 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3229 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3231 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3233 /* Create SNOW 3G operation */
3234 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3235 tdata->cipher_iv.len,
3236 tdata->validCipherLenInBits.len,
3241 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3243 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3245 ut_params->obuf = ut_params->op->sym->m_dst;
3246 if (ut_params->obuf)
3247 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3249 ciphertext = plaintext;
3251 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3256 tdata->ciphertext.data,
3257 tdata->validDataLenInBits.len,
3258 "SNOW 3G Ciphertext data not as expected");
3264 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3266 struct crypto_testsuite_params *ts_params = &testsuite_params;
3267 struct crypto_unittest_params *ut_params = &unittest_params;
3268 uint8_t *plaintext, *ciphertext;
3271 unsigned plaintext_pad_len;
3272 unsigned plaintext_len;
3274 /* Create SNOW 3G session */
3275 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3276 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3277 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3278 tdata->key.data, tdata->key.len,
3279 tdata->cipher_iv.len);
3283 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3284 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3286 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3287 "Failed to allocate input buffer in mempool");
3288 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3289 "Failed to allocate output buffer in mempool");
3291 /* Clear mbuf payload */
3292 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3293 rte_pktmbuf_tailroom(ut_params->ibuf));
3295 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3296 /* Append data which is padded to a multiple of */
3297 /* the algorithms block size */
3298 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3299 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3301 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3302 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3304 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3306 /* Create SNOW 3G operation */
3307 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3308 tdata->cipher_iv.len,
3309 tdata->validCipherLenInBits.len,
3314 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3316 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3318 ut_params->obuf = ut_params->op->sym->m_dst;
3319 if (ut_params->obuf)
3320 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3322 ciphertext = plaintext;
3324 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3327 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3329 tdata->ciphertext.data,
3330 tdata->validDataLenInBits.len,
3331 "SNOW 3G Ciphertext data not as expected");
3336 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3338 struct crypto_testsuite_params *ts_params = &testsuite_params;
3339 struct crypto_unittest_params *ut_params = &unittest_params;
3342 unsigned int plaintext_pad_len;
3343 unsigned int plaintext_len;
3344 uint8_t buffer[10000];
3345 const uint8_t *ciphertext;
3347 struct rte_cryptodev_info dev_info;
3349 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3350 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3351 printf("Device doesn't support scatter-gather. "
3356 /* Create SNOW 3G session */
3357 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3358 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3359 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3360 tdata->key.data, tdata->key.len,
3361 tdata->cipher_iv.len);
3365 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3366 /* Append data which is padded to a multiple of */
3367 /* the algorithms block size */
3368 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3370 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3371 plaintext_pad_len, 10, 0);
3372 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3373 plaintext_pad_len, 3, 0);
3375 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3376 "Failed to allocate input buffer in mempool");
3377 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3378 "Failed to allocate output buffer in mempool");
3380 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3382 /* Create SNOW 3G operation */
3383 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3384 tdata->cipher_iv.len,
3385 tdata->validCipherLenInBits.len,
3390 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3394 ut_params->obuf = ut_params->op->sym->m_dst;
3395 if (ut_params->obuf)
3396 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3397 plaintext_len, buffer);
3399 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3400 plaintext_len, buffer);
3402 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3405 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3407 tdata->ciphertext.data,
3408 tdata->validDataLenInBits.len,
3409 "SNOW 3G Ciphertext data not as expected");
3414 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3416 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3418 uint8_t curr_byte, prev_byte;
3419 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3420 uint8_t lower_byte_mask = (1 << offset) - 1;
3423 prev_byte = buffer[0];
3424 buffer[0] >>= offset;
3426 for (i = 1; i < length_in_bytes; i++) {
3427 curr_byte = buffer[i];
3428 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3429 (curr_byte >> offset);
3430 prev_byte = curr_byte;
3435 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3437 struct crypto_testsuite_params *ts_params = &testsuite_params;
3438 struct crypto_unittest_params *ut_params = &unittest_params;
3439 uint8_t *plaintext, *ciphertext;
3441 uint32_t plaintext_len;
3442 uint32_t plaintext_pad_len;
3443 uint8_t extra_offset = 4;
3444 uint8_t *expected_ciphertext_shifted;
3446 /* Create SNOW 3G session */
3447 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3448 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3449 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3450 tdata->key.data, tdata->key.len,
3451 tdata->cipher_iv.len);
3455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3456 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3458 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3459 "Failed to allocate input buffer in mempool");
3460 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3461 "Failed to allocate output buffer in mempool");
3463 /* Clear mbuf payload */
3464 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3465 rte_pktmbuf_tailroom(ut_params->ibuf));
3467 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3469 * Append data which is padded to a
3470 * multiple of the algorithms block size
3472 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3474 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3477 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3479 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3480 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3482 #ifdef RTE_APP_TEST_DEBUG
3483 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3485 /* Create SNOW 3G operation */
3486 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3487 tdata->cipher_iv.len,
3488 tdata->validCipherLenInBits.len,
3493 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3497 ut_params->obuf = ut_params->op->sym->m_dst;
3498 if (ut_params->obuf)
3499 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3501 ciphertext = plaintext;
3503 #ifdef RTE_APP_TEST_DEBUG
3504 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3507 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3509 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3510 "failed to reserve memory for ciphertext shifted\n");
3512 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3513 ceil_byte_length(tdata->ciphertext.len));
3514 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3517 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3519 expected_ciphertext_shifted,
3520 tdata->validDataLenInBits.len,
3522 "SNOW 3G Ciphertext data not as expected");
3526 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3528 struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 struct crypto_unittest_params *ut_params = &unittest_params;
3533 uint8_t *plaintext, *ciphertext;
3534 unsigned ciphertext_pad_len;
3535 unsigned ciphertext_len;
3537 /* Create SNOW 3G session */
3538 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3539 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3540 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3541 tdata->key.data, tdata->key.len,
3542 tdata->cipher_iv.len);
3546 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3548 /* Clear mbuf payload */
3549 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3550 rte_pktmbuf_tailroom(ut_params->ibuf));
3552 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3553 /* Append data which is padded to a multiple of */
3554 /* the algorithms block size */
3555 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3556 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3557 ciphertext_pad_len);
3558 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3560 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3562 /* Create SNOW 3G operation */
3563 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3564 tdata->cipher_iv.len,
3565 tdata->validCipherLenInBits.len,
3570 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3572 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3573 ut_params->obuf = ut_params->op->sym->m_dst;
3574 if (ut_params->obuf)
3575 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3577 plaintext = ciphertext;
3579 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3582 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3583 tdata->plaintext.data,
3584 tdata->validDataLenInBits.len,
3585 "SNOW 3G Plaintext data not as expected");
3589 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3591 struct crypto_testsuite_params *ts_params = &testsuite_params;
3592 struct crypto_unittest_params *ut_params = &unittest_params;
3596 uint8_t *plaintext, *ciphertext;
3597 unsigned ciphertext_pad_len;
3598 unsigned ciphertext_len;
3600 /* Create SNOW 3G session */
3601 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3602 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3603 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3604 tdata->key.data, tdata->key.len,
3605 tdata->cipher_iv.len);
3609 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3610 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3612 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3613 "Failed to allocate input buffer");
3614 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3615 "Failed to allocate output buffer");
3617 /* Clear mbuf payload */
3618 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3619 rte_pktmbuf_tailroom(ut_params->ibuf));
3621 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3622 rte_pktmbuf_tailroom(ut_params->obuf));
3624 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3625 /* Append data which is padded to a multiple of */
3626 /* the algorithms block size */
3627 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3628 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3629 ciphertext_pad_len);
3630 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3631 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3633 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3635 /* Create SNOW 3G operation */
3636 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3637 tdata->cipher_iv.len,
3638 tdata->validCipherLenInBits.len,
3643 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3645 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3646 ut_params->obuf = ut_params->op->sym->m_dst;
3647 if (ut_params->obuf)
3648 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3650 plaintext = ciphertext;
3652 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3655 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3656 tdata->plaintext.data,
3657 tdata->validDataLenInBits.len,
3658 "SNOW 3G Plaintext data not as expected");
3663 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3665 struct crypto_testsuite_params *ts_params = &testsuite_params;
3666 struct crypto_unittest_params *ut_params = &unittest_params;
3670 uint8_t *plaintext, *ciphertext;
3671 unsigned int plaintext_pad_len;
3672 unsigned int plaintext_len;
3674 struct rte_cryptodev_sym_capability_idx cap_idx;
3676 /* Check if device supports ZUC EEA3 */
3677 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3678 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3680 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3684 /* Check if device supports ZUC EIA3 */
3685 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3686 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3688 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3692 /* Create ZUC session */
3693 retval = create_zuc_cipher_auth_encrypt_generate_session(
3694 ts_params->valid_devs[0],
3698 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3700 /* clear mbuf payload */
3701 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3702 rte_pktmbuf_tailroom(ut_params->ibuf));
3704 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3705 /* Append data which is padded to a multiple of */
3706 /* the algorithms block size */
3707 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3708 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3710 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3712 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3714 /* Create ZUC operation */
3715 retval = create_zuc_cipher_hash_generate_operation(tdata);
3719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3721 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3722 ut_params->obuf = ut_params->op->sym->m_src;
3723 if (ut_params->obuf)
3724 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3726 ciphertext = plaintext;
3728 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3730 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3732 tdata->ciphertext.data,
3733 tdata->validDataLenInBits.len,
3734 "ZUC Ciphertext data not as expected");
3736 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3737 + plaintext_pad_len;
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3744 "ZUC Generated auth tag not as expected");
3749 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3751 struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 struct crypto_unittest_params *ut_params = &unittest_params;
3756 uint8_t *plaintext, *ciphertext;
3757 unsigned plaintext_pad_len;
3758 unsigned plaintext_len;
3760 /* Create SNOW 3G session */
3761 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3762 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3763 RTE_CRYPTO_AUTH_OP_GENERATE,
3764 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3765 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3766 tdata->key.data, tdata->key.len,
3767 tdata->auth_iv.len, tdata->digest.len,
3768 tdata->cipher_iv.len);
3771 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3773 /* clear mbuf payload */
3774 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3775 rte_pktmbuf_tailroom(ut_params->ibuf));
3777 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3778 /* Append data which is padded to a multiple of */
3779 /* the algorithms block size */
3780 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3781 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3783 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3785 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3787 /* Create SNOW 3G operation */
3788 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3789 tdata->digest.len, tdata->auth_iv.data,
3791 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3792 tdata->cipher_iv.data, tdata->cipher_iv.len,
3793 tdata->validCipherLenInBits.len,
3795 tdata->validAuthLenInBits.len,
3801 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3803 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3804 ut_params->obuf = ut_params->op->sym->m_src;
3805 if (ut_params->obuf)
3806 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3808 ciphertext = plaintext;
3810 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3812 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3814 tdata->ciphertext.data,
3815 tdata->validDataLenInBits.len,
3816 "SNOW 3G Ciphertext data not as expected");
3818 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3819 + plaintext_pad_len;
3822 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3825 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3826 "SNOW 3G Generated auth tag not as expected");
3830 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3832 struct crypto_testsuite_params *ts_params = &testsuite_params;
3833 struct crypto_unittest_params *ut_params = &unittest_params;
3837 uint8_t *plaintext, *ciphertext;
3838 unsigned plaintext_pad_len;
3839 unsigned plaintext_len;
3841 /* Create SNOW 3G session */
3842 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3843 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3844 RTE_CRYPTO_AUTH_OP_GENERATE,
3845 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3846 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3847 tdata->key.data, tdata->key.len,
3848 tdata->auth_iv.len, tdata->digest.len,
3849 tdata->cipher_iv.len);
3853 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3855 /* clear mbuf payload */
3856 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3857 rte_pktmbuf_tailroom(ut_params->ibuf));
3859 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3860 /* Append data which is padded to a multiple of */
3861 /* the algorithms block size */
3862 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3863 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3865 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3867 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3869 /* Create SNOW 3G operation */
3870 retval = create_wireless_algo_auth_cipher_operation(
3872 tdata->cipher_iv.data, tdata->cipher_iv.len,
3873 tdata->auth_iv.data, tdata->auth_iv.len,
3875 tdata->validCipherLenInBits.len,
3877 tdata->validAuthLenInBits.len,
3883 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3885 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3886 ut_params->obuf = ut_params->op->sym->m_src;
3887 if (ut_params->obuf)
3888 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3890 ciphertext = plaintext;
3892 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3893 + plaintext_pad_len;
3894 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3897 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3899 tdata->ciphertext.data,
3900 tdata->validDataLenInBits.len,
3901 "SNOW 3G Ciphertext data not as expected");
3904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3907 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3908 "SNOW 3G Generated auth tag not as expected");
3913 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3915 struct crypto_testsuite_params *ts_params = &testsuite_params;
3916 struct crypto_unittest_params *ut_params = &unittest_params;
3920 uint8_t *plaintext, *ciphertext;
3921 unsigned plaintext_pad_len;
3922 unsigned plaintext_len;
3924 /* Create KASUMI session */
3925 retval = create_wireless_algo_auth_cipher_session(
3926 ts_params->valid_devs[0],
3927 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3928 RTE_CRYPTO_AUTH_OP_GENERATE,
3929 RTE_CRYPTO_AUTH_KASUMI_F9,
3930 RTE_CRYPTO_CIPHER_KASUMI_F8,
3931 tdata->key.data, tdata->key.len,
3932 tdata->auth_iv.len, tdata->digest.len,
3933 tdata->cipher_iv.len);
3936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3938 /* clear mbuf payload */
3939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3940 rte_pktmbuf_tailroom(ut_params->ibuf));
3942 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3943 /* Append data which is padded to a multiple of */
3944 /* the algorithms block size */
3945 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3946 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3948 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3950 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3952 /* Create KASUMI operation */
3953 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3954 tdata->cipher_iv.data, tdata->cipher_iv.len,
3955 tdata->auth_iv.data, tdata->auth_iv.len,
3957 tdata->validCipherLenInBits.len,
3959 tdata->validAuthLenInBits.len,
3966 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3968 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3969 ut_params->obuf = ut_params->op->sym->m_src;
3970 if (ut_params->obuf)
3971 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3973 ciphertext = plaintext;
3976 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3978 tdata->ciphertext.data,
3979 tdata->validCipherLenInBits.len,
3980 "KASUMI Ciphertext data not as expected");
3981 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3982 + plaintext_pad_len;
3985 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3988 DIGEST_BYTE_LENGTH_KASUMI_F9,
3989 "KASUMI Generated auth tag not as expected");
3994 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3996 struct crypto_testsuite_params *ts_params = &testsuite_params;
3997 struct crypto_unittest_params *ut_params = &unittest_params;
4001 uint8_t *plaintext, *ciphertext;
4002 unsigned plaintext_pad_len;
4003 unsigned plaintext_len;
4005 /* Create KASUMI session */
4006 retval = create_wireless_algo_cipher_auth_session(
4007 ts_params->valid_devs[0],
4008 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4009 RTE_CRYPTO_AUTH_OP_GENERATE,
4010 RTE_CRYPTO_AUTH_KASUMI_F9,
4011 RTE_CRYPTO_CIPHER_KASUMI_F8,
4012 tdata->key.data, tdata->key.len,
4013 tdata->auth_iv.len, tdata->digest.len,
4014 tdata->cipher_iv.len);
4018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4020 /* clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4025 /* Append data which is padded to a multiple of */
4026 /* the algorithms block size */
4027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4028 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4030 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4032 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4034 /* Create KASUMI operation */
4035 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4036 tdata->digest.len, tdata->auth_iv.data,
4038 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4039 tdata->cipher_iv.data, tdata->cipher_iv.len,
4040 tdata->validCipherLenInBits.len,
4042 tdata->validAuthLenInBits.len,
4048 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4050 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4051 ut_params->obuf = ut_params->op->sym->m_src;
4052 if (ut_params->obuf)
4053 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4055 ciphertext = plaintext;
4057 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4058 + plaintext_pad_len;
4061 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4063 tdata->ciphertext.data,
4064 tdata->validCipherLenInBits.len,
4065 "KASUMI Ciphertext data not as expected");
4068 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4071 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4072 "KASUMI Generated auth tag not as expected");
4077 test_zuc_encryption(const struct wireless_test_data *tdata)
4079 struct crypto_testsuite_params *ts_params = &testsuite_params;
4080 struct crypto_unittest_params *ut_params = &unittest_params;
4083 uint8_t *plaintext, *ciphertext;
4084 unsigned plaintext_pad_len;
4085 unsigned plaintext_len;
4087 struct rte_cryptodev_sym_capability_idx cap_idx;
4089 /* Check if device supports ZUC EEA3 */
4090 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4091 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4093 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4097 /* Create ZUC session */
4098 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4099 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4100 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4101 tdata->key.data, tdata->key.len,
4102 tdata->cipher_iv.len);
4106 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4108 /* Clear mbuf payload */
4109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4110 rte_pktmbuf_tailroom(ut_params->ibuf));
4112 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4113 /* Append data which is padded to a multiple */
4114 /* of the algorithms block size */
4115 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4116 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4118 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4120 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4122 /* Create ZUC operation */
4123 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4124 tdata->cipher_iv.len,
4125 tdata->plaintext.len,
4130 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4132 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4134 ut_params->obuf = ut_params->op->sym->m_dst;
4135 if (ut_params->obuf)
4136 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4138 ciphertext = plaintext;
4140 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4143 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4145 tdata->ciphertext.data,
4146 tdata->validCipherLenInBits.len,
4147 "ZUC Ciphertext data not as expected");
4152 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4159 unsigned int plaintext_pad_len;
4160 unsigned int plaintext_len;
4161 const uint8_t *ciphertext;
4162 uint8_t ciphertext_buffer[2048];
4163 struct rte_cryptodev_info dev_info;
4165 struct rte_cryptodev_sym_capability_idx cap_idx;
4167 /* Check if device supports ZUC EEA3 */
4168 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4169 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4171 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4175 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4176 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4177 printf("Device doesn't support scatter-gather. "
4182 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4184 /* Append data which is padded to a multiple */
4185 /* of the algorithms block size */
4186 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4188 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4189 plaintext_pad_len, 10, 0);
4191 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4192 tdata->plaintext.data);
4194 /* Create ZUC session */
4195 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4196 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4197 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4198 tdata->key.data, tdata->key.len,
4199 tdata->cipher_iv.len);
4203 /* Clear mbuf payload */
4205 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4207 /* Create ZUC operation */
4208 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4209 tdata->cipher_iv.len, tdata->plaintext.len,
4214 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4216 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4218 ut_params->obuf = ut_params->op->sym->m_dst;
4219 if (ut_params->obuf)
4220 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4221 0, plaintext_len, ciphertext_buffer);
4223 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4224 0, plaintext_len, ciphertext_buffer);
4227 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4230 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4232 tdata->ciphertext.data,
4233 tdata->validCipherLenInBits.len,
4234 "ZUC Ciphertext data not as expected");
4240 test_zuc_authentication(const struct wireless_test_data *tdata)
4242 struct crypto_testsuite_params *ts_params = &testsuite_params;
4243 struct crypto_unittest_params *ut_params = &unittest_params;
4246 unsigned plaintext_pad_len;
4247 unsigned plaintext_len;
4250 struct rte_cryptodev_sym_capability_idx cap_idx;
4252 /* Check if device supports ZUC EIA3 */
4253 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4254 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4256 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4260 /* Create ZUC session */
4261 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4262 tdata->key.data, tdata->key.len,
4263 tdata->auth_iv.len, tdata->digest.len,
4264 RTE_CRYPTO_AUTH_OP_GENERATE,
4265 RTE_CRYPTO_AUTH_ZUC_EIA3);
4269 /* alloc mbuf and set payload */
4270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4272 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4273 rte_pktmbuf_tailroom(ut_params->ibuf));
4275 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4276 /* Append data which is padded to a multiple of */
4277 /* the algorithms block size */
4278 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4279 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4281 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4283 /* Create ZUC operation */
4284 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4285 tdata->auth_iv.data, tdata->auth_iv.len,
4286 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4287 tdata->validAuthLenInBits.len,
4292 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4294 ut_params->obuf = ut_params->op->sym->m_src;
4295 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4296 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4297 + plaintext_pad_len;
4300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4303 DIGEST_BYTE_LENGTH_KASUMI_F9,
4304 "ZUC Generated auth tag not as expected");
4310 test_kasumi_encryption_test_case_1(void)
4312 return test_kasumi_encryption(&kasumi_test_case_1);
4316 test_kasumi_encryption_test_case_1_sgl(void)
4318 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4322 test_kasumi_encryption_test_case_1_oop(void)
4324 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4328 test_kasumi_encryption_test_case_1_oop_sgl(void)
4330 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4334 test_kasumi_encryption_test_case_2(void)
4336 return test_kasumi_encryption(&kasumi_test_case_2);
4340 test_kasumi_encryption_test_case_3(void)
4342 return test_kasumi_encryption(&kasumi_test_case_3);
4346 test_kasumi_encryption_test_case_4(void)
4348 return test_kasumi_encryption(&kasumi_test_case_4);
4352 test_kasumi_encryption_test_case_5(void)
4354 return test_kasumi_encryption(&kasumi_test_case_5);
4358 test_kasumi_decryption_test_case_1(void)
4360 return test_kasumi_decryption(&kasumi_test_case_1);
4364 test_kasumi_decryption_test_case_1_oop(void)
4366 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4370 test_kasumi_decryption_test_case_2(void)
4372 return test_kasumi_decryption(&kasumi_test_case_2);
4376 test_kasumi_decryption_test_case_3(void)
4378 return test_kasumi_decryption(&kasumi_test_case_3);
4382 test_kasumi_decryption_test_case_4(void)
4384 return test_kasumi_decryption(&kasumi_test_case_4);
4388 test_kasumi_decryption_test_case_5(void)
4390 return test_kasumi_decryption(&kasumi_test_case_5);
4393 test_snow3g_encryption_test_case_1(void)
4395 return test_snow3g_encryption(&snow3g_test_case_1);
4399 test_snow3g_encryption_test_case_1_oop(void)
4401 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4405 test_snow3g_encryption_test_case_1_oop_sgl(void)
4407 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4412 test_snow3g_encryption_test_case_1_offset_oop(void)
4414 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4418 test_snow3g_encryption_test_case_2(void)
4420 return test_snow3g_encryption(&snow3g_test_case_2);
4424 test_snow3g_encryption_test_case_3(void)
4426 return test_snow3g_encryption(&snow3g_test_case_3);
4430 test_snow3g_encryption_test_case_4(void)
4432 return test_snow3g_encryption(&snow3g_test_case_4);
4436 test_snow3g_encryption_test_case_5(void)
4438 return test_snow3g_encryption(&snow3g_test_case_5);
4442 test_snow3g_decryption_test_case_1(void)
4444 return test_snow3g_decryption(&snow3g_test_case_1);
4448 test_snow3g_decryption_test_case_1_oop(void)
4450 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4454 test_snow3g_decryption_test_case_2(void)
4456 return test_snow3g_decryption(&snow3g_test_case_2);
4460 test_snow3g_decryption_test_case_3(void)
4462 return test_snow3g_decryption(&snow3g_test_case_3);
4466 test_snow3g_decryption_test_case_4(void)
4468 return test_snow3g_decryption(&snow3g_test_case_4);
4472 test_snow3g_decryption_test_case_5(void)
4474 return test_snow3g_decryption(&snow3g_test_case_5);
4477 test_snow3g_cipher_auth_test_case_1(void)
4479 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4483 test_snow3g_auth_cipher_test_case_1(void)
4485 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4489 test_kasumi_auth_cipher_test_case_1(void)
4491 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4495 test_kasumi_cipher_auth_test_case_1(void)
4497 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4501 test_zuc_encryption_test_case_1(void)
4503 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4507 test_zuc_encryption_test_case_2(void)
4509 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4513 test_zuc_encryption_test_case_3(void)
4515 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4519 test_zuc_encryption_test_case_4(void)
4521 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4525 test_zuc_encryption_test_case_5(void)
4527 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4531 test_zuc_encryption_test_case_6_sgl(void)
4533 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4537 test_zuc_hash_generate_test_case_1(void)
4539 return test_zuc_authentication(&zuc_test_case_auth_1b);
4543 test_zuc_hash_generate_test_case_2(void)
4545 return test_zuc_authentication(&zuc_test_case_auth_90b);
4549 test_zuc_hash_generate_test_case_3(void)
4551 return test_zuc_authentication(&zuc_test_case_auth_577b);
4555 test_zuc_hash_generate_test_case_4(void)
4557 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4561 test_zuc_hash_generate_test_case_5(void)
4563 return test_zuc_authentication(&zuc_test_auth_5670b);
4567 test_zuc_hash_generate_test_case_6(void)
4569 return test_zuc_authentication(&zuc_test_case_auth_128b);
4573 test_zuc_hash_generate_test_case_7(void)
4575 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4579 test_zuc_hash_generate_test_case_8(void)
4581 return test_zuc_authentication(&zuc_test_case_auth_584b);
4585 test_zuc_cipher_auth_test_case_1(void)
4587 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4591 test_zuc_cipher_auth_test_case_2(void)
4593 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4597 test_3DES_chain_qat_all(void)
4599 struct crypto_testsuite_params *ts_params = &testsuite_params;
4602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4603 ts_params->op_mpool,
4604 ts_params->session_mpool,
4605 ts_params->valid_devs[0],
4606 rte_cryptodev_driver_id_get(
4607 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4608 BLKCIPHER_3DES_CHAIN_TYPE);
4610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4612 return TEST_SUCCESS;
4616 test_DES_cipheronly_qat_all(void)
4618 struct crypto_testsuite_params *ts_params = &testsuite_params;
4621 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4622 ts_params->op_mpool,
4623 ts_params->session_mpool,
4624 ts_params->valid_devs[0],
4625 rte_cryptodev_driver_id_get(
4626 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4627 BLKCIPHER_DES_CIPHERONLY_TYPE);
4629 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4631 return TEST_SUCCESS;
4635 test_DES_docsis_openssl_all(void)
4637 struct crypto_testsuite_params *ts_params = &testsuite_params;
4640 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4641 ts_params->op_mpool,
4642 ts_params->session_mpool,
4643 ts_params->valid_devs[0],
4644 rte_cryptodev_driver_id_get(
4645 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4646 BLKCIPHER_DES_DOCSIS_TYPE);
4648 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4650 return TEST_SUCCESS;
4654 test_3DES_chain_dpaa2_sec_all(void)
4656 struct crypto_testsuite_params *ts_params = &testsuite_params;
4659 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4660 ts_params->op_mpool,
4661 ts_params->session_mpool,
4662 ts_params->valid_devs[0],
4663 rte_cryptodev_driver_id_get(
4664 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4665 BLKCIPHER_3DES_CHAIN_TYPE);
4667 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4669 return TEST_SUCCESS;
4673 test_3DES_cipheronly_dpaa2_sec_all(void)
4675 struct crypto_testsuite_params *ts_params = &testsuite_params;
4678 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4679 ts_params->op_mpool,
4680 ts_params->session_mpool,
4681 ts_params->valid_devs[0],
4682 rte_cryptodev_driver_id_get(
4683 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4684 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4686 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4688 return TEST_SUCCESS;
4692 test_3DES_cipheronly_qat_all(void)
4694 struct crypto_testsuite_params *ts_params = &testsuite_params;
4697 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4698 ts_params->op_mpool,
4699 ts_params->session_mpool,
4700 ts_params->valid_devs[0],
4701 rte_cryptodev_driver_id_get(
4702 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4703 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4705 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4707 return TEST_SUCCESS;
4711 test_3DES_chain_openssl_all(void)
4713 struct crypto_testsuite_params *ts_params = &testsuite_params;
4716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4717 ts_params->op_mpool,
4718 ts_params->session_mpool,
4719 ts_params->valid_devs[0],
4720 rte_cryptodev_driver_id_get(
4721 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4722 BLKCIPHER_3DES_CHAIN_TYPE);
4724 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4726 return TEST_SUCCESS;
4730 test_3DES_cipheronly_openssl_all(void)
4732 struct crypto_testsuite_params *ts_params = &testsuite_params;
4735 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4736 ts_params->op_mpool,
4737 ts_params->session_mpool,
4738 ts_params->valid_devs[0],
4739 rte_cryptodev_driver_id_get(
4740 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4741 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4745 return TEST_SUCCESS;
4748 /* ***** AES-GCM Tests ***** */
4751 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4752 const uint8_t *key, const uint8_t key_len,
4753 const uint16_t aad_len, const uint8_t auth_len,
4756 uint8_t aead_key[key_len];
4758 struct crypto_testsuite_params *ts_params = &testsuite_params;
4759 struct crypto_unittest_params *ut_params = &unittest_params;
4761 memcpy(aead_key, key, key_len);
4763 /* Setup AEAD Parameters */
4764 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4765 ut_params->aead_xform.next = NULL;
4766 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4767 ut_params->aead_xform.aead.op = op;
4768 ut_params->aead_xform.aead.key.data = aead_key;
4769 ut_params->aead_xform.aead.key.length = key_len;
4770 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4771 ut_params->aead_xform.aead.iv.length = iv_len;
4772 ut_params->aead_xform.aead.digest_length = auth_len;
4773 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4775 TEST_HEXDUMP(stdout, "key:", key, key_len);
4777 /* Create Crypto session*/
4778 ut_params->sess = rte_cryptodev_sym_session_create(
4779 ts_params->session_mpool);
4781 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
4782 &ut_params->aead_xform, ts_params->session_mpool);
4784 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4790 create_gcm_xforms(struct rte_crypto_op *op,
4791 enum rte_crypto_aead_operation aead_op,
4792 uint8_t *key, const uint8_t key_len,
4793 const uint8_t aad_len, const uint8_t auth_len,
4796 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4797 "failed to allocate space for crypto transform");
4799 struct rte_crypto_sym_op *sym_op = op->sym;
4801 /* Setup AEAD Parameters */
4802 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4803 sym_op->xform->next = NULL;
4804 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4805 sym_op->xform->aead.op = aead_op;
4806 sym_op->xform->aead.key.data = key;
4807 sym_op->xform->aead.key.length = key_len;
4808 sym_op->xform->aead.iv.offset = IV_OFFSET;
4809 sym_op->xform->aead.iv.length = iv_len;
4810 sym_op->xform->aead.digest_length = auth_len;
4811 sym_op->xform->aead.add_auth_data_length = aad_len;
4813 TEST_HEXDUMP(stdout, "key:", key, key_len);
4819 create_gcm_operation(enum rte_crypto_aead_operation op,
4820 const struct gcm_test_data *tdata)
4822 struct crypto_testsuite_params *ts_params = &testsuite_params;
4823 struct crypto_unittest_params *ut_params = &unittest_params;
4825 uint8_t *plaintext, *ciphertext;
4826 unsigned int aad_pad_len, plaintext_pad_len;
4828 /* Generate Crypto op data structure */
4829 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4830 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4831 TEST_ASSERT_NOT_NULL(ut_params->op,
4832 "Failed to allocate symmetric crypto operation struct");
4834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4836 /* Append aad data */
4837 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4838 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4840 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4841 "no room to append aad");
4843 sym_op->aead.aad.phys_addr =
4844 rte_pktmbuf_mtophys(ut_params->ibuf);
4845 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4846 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4849 /* Append IV at the end of the crypto operation*/
4850 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4851 uint8_t *, IV_OFFSET);
4853 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4854 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4857 /* Append plaintext/ciphertext */
4858 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4859 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4860 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4862 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4864 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4865 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4866 tdata->plaintext.len);
4868 if (ut_params->obuf) {
4869 ciphertext = (uint8_t *)rte_pktmbuf_append(
4871 plaintext_pad_len + aad_pad_len);
4872 TEST_ASSERT_NOT_NULL(ciphertext,
4873 "no room to append ciphertext");
4875 memset(ciphertext + aad_pad_len, 0,
4876 tdata->ciphertext.len);
4879 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4880 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4882 TEST_ASSERT_NOT_NULL(ciphertext,
4883 "no room to append ciphertext");
4885 memcpy(ciphertext, tdata->ciphertext.data,
4886 tdata->ciphertext.len);
4887 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4888 tdata->ciphertext.len);
4890 if (ut_params->obuf) {
4891 plaintext = (uint8_t *)rte_pktmbuf_append(
4893 plaintext_pad_len + aad_pad_len);
4894 TEST_ASSERT_NOT_NULL(plaintext,
4895 "no room to append plaintext");
4897 memset(plaintext + aad_pad_len, 0,
4898 tdata->plaintext.len);
4902 /* Append digest data */
4903 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4904 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4905 ut_params->obuf ? ut_params->obuf :
4907 tdata->auth_tag.len);
4908 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4909 "no room to append digest");
4910 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4911 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4912 ut_params->obuf ? ut_params->obuf :
4917 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4918 ut_params->ibuf, tdata->auth_tag.len);
4919 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4920 "no room to append digest");
4921 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4923 plaintext_pad_len + aad_pad_len);
4925 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4926 tdata->auth_tag.len);
4927 TEST_HEXDUMP(stdout, "digest:",
4928 sym_op->aead.digest.data,
4929 tdata->auth_tag.len);
4932 sym_op->aead.data.length = tdata->plaintext.len;
4933 sym_op->aead.data.offset = aad_pad_len;
4939 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4941 struct crypto_testsuite_params *ts_params = &testsuite_params;
4942 struct crypto_unittest_params *ut_params = &unittest_params;
4945 uint8_t *ciphertext, *auth_tag;
4946 uint16_t plaintext_pad_len;
4949 /* Create GCM session */
4950 retval = create_gcm_session(ts_params->valid_devs[0],
4951 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4952 tdata->key.data, tdata->key.len,
4953 tdata->aad.len, tdata->auth_tag.len,
4958 if (tdata->aad.len > MBUF_SIZE) {
4959 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4960 /* Populate full size of add data */
4961 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4962 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4964 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4966 /* clear mbuf payload */
4967 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4968 rte_pktmbuf_tailroom(ut_params->ibuf));
4970 /* Create GCM operation */
4971 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4975 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4977 ut_params->op->sym->m_src = ut_params->ibuf;
4979 /* Process crypto operation */
4980 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4981 ut_params->op), "failed to process sym crypto op");
4983 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4984 "crypto op processing failed");
4986 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4988 if (ut_params->op->sym->m_dst) {
4989 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4991 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4992 uint8_t *, plaintext_pad_len);
4994 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4996 ut_params->op->sym->cipher.data.offset);
4997 auth_tag = ciphertext + plaintext_pad_len;
5000 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5001 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5006 tdata->ciphertext.data,
5007 tdata->ciphertext.len,
5008 "GCM Ciphertext data not as expected");
5010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5012 tdata->auth_tag.data,
5013 tdata->auth_tag.len,
5014 "GCM Generated auth tag not as expected");
5021 test_AES_GCM_authenticated_encryption_test_case_1(void)
5023 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5027 test_AES_GCM_authenticated_encryption_test_case_2(void)
5029 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5033 test_AES_GCM_authenticated_encryption_test_case_3(void)
5035 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5039 test_AES_GCM_authenticated_encryption_test_case_4(void)
5041 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5045 test_AES_GCM_authenticated_encryption_test_case_5(void)
5047 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5051 test_AES_GCM_authenticated_encryption_test_case_6(void)
5053 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5057 test_AES_GCM_authenticated_encryption_test_case_7(void)
5059 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5063 test_AES_GCM_auth_encryption_test_case_192_1(void)
5065 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
5069 test_AES_GCM_auth_encryption_test_case_192_2(void)
5071 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
5075 test_AES_GCM_auth_encryption_test_case_192_3(void)
5077 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
5081 test_AES_GCM_auth_encryption_test_case_192_4(void)
5083 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
5087 test_AES_GCM_auth_encryption_test_case_192_5(void)
5089 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
5093 test_AES_GCM_auth_encryption_test_case_192_6(void)
5095 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
5099 test_AES_GCM_auth_encryption_test_case_192_7(void)
5101 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
5105 test_AES_GCM_auth_encryption_test_case_256_1(void)
5107 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5111 test_AES_GCM_auth_encryption_test_case_256_2(void)
5113 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5117 test_AES_GCM_auth_encryption_test_case_256_3(void)
5119 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5123 test_AES_GCM_auth_encryption_test_case_256_4(void)
5125 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5129 test_AES_GCM_auth_encryption_test_case_256_5(void)
5131 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5135 test_AES_GCM_auth_encryption_test_case_256_6(void)
5137 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5141 test_AES_GCM_auth_encryption_test_case_256_7(void)
5143 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5147 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5149 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5153 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5155 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5159 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5161 struct crypto_testsuite_params *ts_params = &testsuite_params;
5162 struct crypto_unittest_params *ut_params = &unittest_params;
5168 /* Create GCM session */
5169 retval = create_gcm_session(ts_params->valid_devs[0],
5170 RTE_CRYPTO_AEAD_OP_DECRYPT,
5171 tdata->key.data, tdata->key.len,
5172 tdata->aad.len, tdata->auth_tag.len,
5177 /* alloc mbuf and set payload */
5178 if (tdata->aad.len > MBUF_SIZE) {
5179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5180 /* Populate full size of add data */
5181 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5182 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5187 rte_pktmbuf_tailroom(ut_params->ibuf));
5189 /* Create GCM operation */
5190 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5194 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5196 ut_params->op->sym->m_src = ut_params->ibuf;
5198 /* Process crypto operation */
5199 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5200 ut_params->op), "failed to process sym crypto op");
5202 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5203 "crypto op processing failed");
5205 if (ut_params->op->sym->m_dst)
5206 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5209 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5211 ut_params->op->sym->cipher.data.offset);
5213 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5216 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5218 tdata->plaintext.data,
5219 tdata->plaintext.len,
5220 "GCM plaintext data not as expected");
5222 TEST_ASSERT_EQUAL(ut_params->op->status,
5223 RTE_CRYPTO_OP_STATUS_SUCCESS,
5224 "GCM authentication failed");
5229 test_AES_GCM_authenticated_decryption_test_case_1(void)
5231 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5235 test_AES_GCM_authenticated_decryption_test_case_2(void)
5237 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5241 test_AES_GCM_authenticated_decryption_test_case_3(void)
5243 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5247 test_AES_GCM_authenticated_decryption_test_case_4(void)
5249 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5253 test_AES_GCM_authenticated_decryption_test_case_5(void)
5255 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5259 test_AES_GCM_authenticated_decryption_test_case_6(void)
5261 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5265 test_AES_GCM_authenticated_decryption_test_case_7(void)
5267 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5271 test_AES_GCM_auth_decryption_test_case_192_1(void)
5273 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5277 test_AES_GCM_auth_decryption_test_case_192_2(void)
5279 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5283 test_AES_GCM_auth_decryption_test_case_192_3(void)
5285 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5289 test_AES_GCM_auth_decryption_test_case_192_4(void)
5291 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5295 test_AES_GCM_auth_decryption_test_case_192_5(void)
5297 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5301 test_AES_GCM_auth_decryption_test_case_192_6(void)
5303 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5307 test_AES_GCM_auth_decryption_test_case_192_7(void)
5309 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5313 test_AES_GCM_auth_decryption_test_case_256_1(void)
5315 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5319 test_AES_GCM_auth_decryption_test_case_256_2(void)
5321 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5325 test_AES_GCM_auth_decryption_test_case_256_3(void)
5327 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5331 test_AES_GCM_auth_decryption_test_case_256_4(void)
5333 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5337 test_AES_GCM_auth_decryption_test_case_256_5(void)
5339 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5343 test_AES_GCM_auth_decryption_test_case_256_6(void)
5345 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5349 test_AES_GCM_auth_decryption_test_case_256_7(void)
5351 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5355 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5357 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5361 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5363 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5367 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5369 struct crypto_testsuite_params *ts_params = &testsuite_params;
5370 struct crypto_unittest_params *ut_params = &unittest_params;
5373 uint8_t *ciphertext, *auth_tag;
5374 uint16_t plaintext_pad_len;
5376 /* Create GCM session */
5377 retval = create_gcm_session(ts_params->valid_devs[0],
5378 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5379 tdata->key.data, tdata->key.len,
5380 tdata->aad.len, tdata->auth_tag.len,
5385 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5386 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5388 /* clear mbuf payload */
5389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5390 rte_pktmbuf_tailroom(ut_params->ibuf));
5391 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5392 rte_pktmbuf_tailroom(ut_params->obuf));
5394 /* Create GCM operation */
5395 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5399 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5401 ut_params->op->sym->m_src = ut_params->ibuf;
5402 ut_params->op->sym->m_dst = ut_params->obuf;
5404 /* Process crypto operation */
5405 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5406 ut_params->op), "failed to process sym crypto op");
5408 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5409 "crypto op processing failed");
5411 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5413 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5414 ut_params->op->sym->cipher.data.offset);
5415 auth_tag = ciphertext + plaintext_pad_len;
5417 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5418 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5421 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5423 tdata->ciphertext.data,
5424 tdata->ciphertext.len,
5425 "GCM Ciphertext data not as expected");
5427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5429 tdata->auth_tag.data,
5430 tdata->auth_tag.len,
5431 "GCM Generated auth tag not as expected");
5438 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5440 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5444 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5446 struct crypto_testsuite_params *ts_params = &testsuite_params;
5447 struct crypto_unittest_params *ut_params = &unittest_params;
5452 /* Create GCM session */
5453 retval = create_gcm_session(ts_params->valid_devs[0],
5454 RTE_CRYPTO_AEAD_OP_DECRYPT,
5455 tdata->key.data, tdata->key.len,
5456 tdata->aad.len, tdata->auth_tag.len,
5461 /* alloc mbuf and set payload */
5462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5463 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5465 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5466 rte_pktmbuf_tailroom(ut_params->ibuf));
5467 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5468 rte_pktmbuf_tailroom(ut_params->obuf));
5470 /* Create GCM operation */
5471 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5475 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5477 ut_params->op->sym->m_src = ut_params->ibuf;
5478 ut_params->op->sym->m_dst = ut_params->obuf;
5480 /* Process crypto operation */
5481 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5482 ut_params->op), "failed to process sym crypto op");
5484 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5485 "crypto op processing failed");
5487 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5488 ut_params->op->sym->cipher.data.offset);
5490 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5495 tdata->plaintext.data,
5496 tdata->plaintext.len,
5497 "GCM plaintext data not as expected");
5499 TEST_ASSERT_EQUAL(ut_params->op->status,
5500 RTE_CRYPTO_OP_STATUS_SUCCESS,
5501 "GCM authentication failed");
5506 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5508 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5512 test_AES_GCM_authenticated_encryption_sessionless(
5513 const struct gcm_test_data *tdata)
5515 struct crypto_testsuite_params *ts_params = &testsuite_params;
5516 struct crypto_unittest_params *ut_params = &unittest_params;
5519 uint8_t *ciphertext, *auth_tag;
5520 uint16_t plaintext_pad_len;
5521 uint8_t key[tdata->key.len + 1];
5523 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5525 /* clear mbuf payload */
5526 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5527 rte_pktmbuf_tailroom(ut_params->ibuf));
5529 /* Create GCM operation */
5530 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5534 /* Create GCM xforms */
5535 memcpy(key, tdata->key.data, tdata->key.len);
5536 retval = create_gcm_xforms(ut_params->op,
5537 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5538 key, tdata->key.len,
5539 tdata->aad.len, tdata->auth_tag.len,
5544 ut_params->op->sym->m_src = ut_params->ibuf;
5546 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5547 RTE_CRYPTO_OP_SESSIONLESS,
5548 "crypto op session type not sessionless");
5550 /* Process crypto operation */
5551 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5552 ut_params->op), "failed to process sym crypto op");
5554 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5556 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5557 "crypto op status not success");
5559 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5561 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5562 ut_params->op->sym->cipher.data.offset);
5563 auth_tag = ciphertext + plaintext_pad_len;
5565 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5566 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5569 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5571 tdata->ciphertext.data,
5572 tdata->ciphertext.len,
5573 "GCM Ciphertext data not as expected");
5575 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5577 tdata->auth_tag.data,
5578 tdata->auth_tag.len,
5579 "GCM Generated auth tag not as expected");
5586 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5588 return test_AES_GCM_authenticated_encryption_sessionless(
5593 test_AES_GCM_authenticated_decryption_sessionless(
5594 const struct gcm_test_data *tdata)
5596 struct crypto_testsuite_params *ts_params = &testsuite_params;
5597 struct crypto_unittest_params *ut_params = &unittest_params;
5601 uint8_t key[tdata->key.len + 1];
5603 /* alloc mbuf and set payload */
5604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5606 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5607 rte_pktmbuf_tailroom(ut_params->ibuf));
5609 /* Create GCM operation */
5610 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5614 /* Create GCM xforms */
5615 memcpy(key, tdata->key.data, tdata->key.len);
5616 retval = create_gcm_xforms(ut_params->op,
5617 RTE_CRYPTO_AEAD_OP_DECRYPT,
5618 key, tdata->key.len,
5619 tdata->aad.len, tdata->auth_tag.len,
5624 ut_params->op->sym->m_src = ut_params->ibuf;
5626 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5627 RTE_CRYPTO_OP_SESSIONLESS,
5628 "crypto op session type not sessionless");
5630 /* Process crypto operation */
5631 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5632 ut_params->op), "failed to process sym crypto op");
5634 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5636 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5637 "crypto op status not success");
5639 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5640 ut_params->op->sym->cipher.data.offset);
5642 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5645 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5647 tdata->plaintext.data,
5648 tdata->plaintext.len,
5649 "GCM plaintext data not as expected");
5651 TEST_ASSERT_EQUAL(ut_params->op->status,
5652 RTE_CRYPTO_OP_STATUS_SUCCESS,
5653 "GCM authentication failed");
5658 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5660 return test_AES_GCM_authenticated_decryption_sessionless(
5667 struct crypto_testsuite_params *ts_params = &testsuite_params;
5668 struct rte_cryptodev_stats stats;
5669 struct rte_cryptodev *dev;
5670 cryptodev_stats_get_t temp_pfn;
5672 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5673 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5674 &stats) == -ENODEV),
5675 "rte_cryptodev_stats_get invalid dev failed");
5676 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5677 "rte_cryptodev_stats_get invalid Param failed");
5678 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5679 temp_pfn = dev->dev_ops->stats_get;
5680 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5681 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5683 "rte_cryptodev_stats_get invalid Param failed");
5684 dev->dev_ops->stats_get = temp_pfn;
5686 /* Test expected values */
5688 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5690 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5692 "rte_cryptodev_stats_get failed");
5693 TEST_ASSERT((stats.enqueued_count == 1),
5694 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5695 TEST_ASSERT((stats.dequeued_count == 1),
5696 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5697 TEST_ASSERT((stats.enqueue_err_count == 0),
5698 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5699 TEST_ASSERT((stats.dequeue_err_count == 0),
5700 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5702 /* invalid device but should ignore and not reset device stats*/
5703 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5704 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5706 "rte_cryptodev_stats_get failed");
5707 TEST_ASSERT((stats.enqueued_count == 1),
5708 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5710 /* check that a valid reset clears stats */
5711 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5712 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5714 "rte_cryptodev_stats_get failed");
5715 TEST_ASSERT((stats.enqueued_count == 0),
5716 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5717 TEST_ASSERT((stats.dequeued_count == 0),
5718 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5720 return TEST_SUCCESS;
5723 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5724 struct crypto_unittest_params *ut_params,
5725 enum rte_crypto_auth_operation op,
5726 const struct HMAC_MD5_vector *test_case)
5730 memcpy(key, test_case->key.data, test_case->key.len);
5732 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5733 ut_params->auth_xform.next = NULL;
5734 ut_params->auth_xform.auth.op = op;
5736 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5738 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5739 ut_params->auth_xform.auth.key.length = test_case->key.len;
5740 ut_params->auth_xform.auth.key.data = key;
5742 ut_params->sess = rte_cryptodev_sym_session_create(
5743 ts_params->session_mpool);
5745 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5746 ut_params->sess, &ut_params->auth_xform,
5747 ts_params->session_mpool);
5749 if (ut_params->sess == NULL)
5752 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5754 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5755 rte_pktmbuf_tailroom(ut_params->ibuf));
5760 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5761 const struct HMAC_MD5_vector *test_case,
5762 uint8_t **plaintext)
5764 uint16_t plaintext_pad_len;
5766 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5768 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5771 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5773 memcpy(*plaintext, test_case->plaintext.data,
5774 test_case->plaintext.len);
5776 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5777 ut_params->ibuf, MD5_DIGEST_LEN);
5778 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5779 "no room to append digest");
5780 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5781 ut_params->ibuf, plaintext_pad_len);
5783 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5784 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5785 test_case->auth_tag.len);
5788 sym_op->auth.data.offset = 0;
5789 sym_op->auth.data.length = test_case->plaintext.len;
5791 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5792 ut_params->op->sym->m_src = ut_params->ibuf;
5798 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5800 uint16_t plaintext_pad_len;
5801 uint8_t *plaintext, *auth_tag;
5803 struct crypto_testsuite_params *ts_params = &testsuite_params;
5804 struct crypto_unittest_params *ut_params = &unittest_params;
5806 if (MD5_HMAC_create_session(ts_params, ut_params,
5807 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5810 /* Generate Crypto op data structure */
5811 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5812 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5813 TEST_ASSERT_NOT_NULL(ut_params->op,
5814 "Failed to allocate symmetric crypto operation struct");
5816 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5819 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5822 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5823 ut_params->op), "failed to process sym crypto op");
5825 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5826 "crypto op processing failed");
5828 if (ut_params->op->sym->m_dst) {
5829 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5830 uint8_t *, plaintext_pad_len);
5832 auth_tag = plaintext + plaintext_pad_len;
5835 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5837 test_case->auth_tag.data,
5838 test_case->auth_tag.len,
5839 "HMAC_MD5 generated tag not as expected");
5841 return TEST_SUCCESS;
5845 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5849 struct crypto_testsuite_params *ts_params = &testsuite_params;
5850 struct crypto_unittest_params *ut_params = &unittest_params;
5852 if (MD5_HMAC_create_session(ts_params, ut_params,
5853 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5857 /* Generate Crypto op data structure */
5858 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5859 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5860 TEST_ASSERT_NOT_NULL(ut_params->op,
5861 "Failed to allocate symmetric crypto operation struct");
5863 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5866 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5867 ut_params->op), "failed to process sym crypto op");
5869 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5870 "HMAC_MD5 crypto op processing failed");
5872 return TEST_SUCCESS;
5876 test_MD5_HMAC_generate_case_1(void)
5878 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5882 test_MD5_HMAC_verify_case_1(void)
5884 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5888 test_MD5_HMAC_generate_case_2(void)
5890 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5894 test_MD5_HMAC_verify_case_2(void)
5896 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5900 test_multi_session(void)
5902 struct crypto_testsuite_params *ts_params = &testsuite_params;
5903 struct crypto_unittest_params *ut_params = &unittest_params;
5905 struct rte_cryptodev_info dev_info;
5906 struct rte_cryptodev_sym_session **sessions;
5910 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5911 aes_cbc_key, hmac_sha512_key);
5914 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5916 sessions = rte_malloc(NULL,
5917 (sizeof(struct rte_cryptodev_sym_session *) *
5918 dev_info.sym.max_nb_sessions) + 1, 0);
5920 /* Create multiple crypto sessions*/
5921 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5923 sessions[i] = rte_cryptodev_sym_session_create(
5924 ts_params->session_mpool);
5926 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5927 sessions[i], &ut_params->auth_xform,
5928 ts_params->session_mpool);
5929 TEST_ASSERT_NOT_NULL(sessions[i],
5930 "Session creation failed at session number %u",
5933 /* Attempt to send a request on each session */
5934 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5938 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5939 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5941 "Failed to perform decrypt on request number %u.", i);
5942 /* free crypto operation structure */
5944 rte_crypto_op_free(ut_params->op);
5947 * free mbuf - both obuf and ibuf are usually the same,
5948 * so check if they point at the same address is necessary,
5949 * to avoid freeing the mbuf twice.
5951 if (ut_params->obuf) {
5952 rte_pktmbuf_free(ut_params->obuf);
5953 if (ut_params->ibuf == ut_params->obuf)
5954 ut_params->ibuf = 0;
5955 ut_params->obuf = 0;
5957 if (ut_params->ibuf) {
5958 rte_pktmbuf_free(ut_params->ibuf);
5959 ut_params->ibuf = 0;
5963 /* Next session create should fail */
5964 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5965 sessions[i], &ut_params->auth_xform,
5966 ts_params->session_mpool);
5967 TEST_ASSERT_NULL(sessions[i],
5968 "Session creation succeeded unexpectedly!");
5970 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5971 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
5973 rte_cryptodev_sym_session_free(sessions[i]);
5978 return TEST_SUCCESS;
5981 struct multi_session_params {
5982 struct crypto_unittest_params ut_params;
5983 uint8_t *cipher_key;
5985 const uint8_t *cipher;
5986 const uint8_t *digest;
5990 #define MB_SESSION_NUMBER 3
5993 test_multi_session_random_usage(void)
5995 struct crypto_testsuite_params *ts_params = &testsuite_params;
5996 struct rte_cryptodev_info dev_info;
5997 struct rte_cryptodev_sym_session **sessions;
5999 struct multi_session_params ut_paramz[] = {
6002 .cipher_key = ms_aes_cbc_key0,
6003 .hmac_key = ms_hmac_key0,
6004 .cipher = ms_aes_cbc_cipher0,
6005 .digest = ms_hmac_digest0,
6006 .iv = ms_aes_cbc_iv0
6009 .cipher_key = ms_aes_cbc_key1,
6010 .hmac_key = ms_hmac_key1,
6011 .cipher = ms_aes_cbc_cipher1,
6012 .digest = ms_hmac_digest1,
6013 .iv = ms_aes_cbc_iv1
6016 .cipher_key = ms_aes_cbc_key2,
6017 .hmac_key = ms_hmac_key2,
6018 .cipher = ms_aes_cbc_cipher2,
6019 .digest = ms_hmac_digest2,
6020 .iv = ms_aes_cbc_iv2
6025 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6027 sessions = rte_malloc(NULL,
6028 (sizeof(struct rte_cryptodev_sym_session *)
6029 * dev_info.sym.max_nb_sessions) + 1, 0);
6031 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6032 sessions[i] = rte_cryptodev_sym_session_create(
6033 ts_params->session_mpool);
6035 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6036 sizeof(struct crypto_unittest_params));
6038 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6039 &ut_paramz[i].ut_params,
6040 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6042 /* Create multiple crypto sessions*/
6043 rte_cryptodev_sym_session_init(
6044 ts_params->valid_devs[0],
6046 &ut_paramz[i].ut_params.auth_xform,
6047 ts_params->session_mpool);
6049 TEST_ASSERT_NOT_NULL(sessions[i],
6050 "Session creation failed at session number %u",
6056 for (i = 0; i < 40000; i++) {
6058 j = rand() % MB_SESSION_NUMBER;
6060 TEST_ASSERT_SUCCESS(
6061 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6063 &ut_paramz[j].ut_params,
6064 ts_params, ut_paramz[j].cipher,
6065 ut_paramz[j].digest,
6067 "Failed to perform decrypt on request number %u.", i);
6069 if (ut_paramz[j].ut_params.op)
6070 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6073 * free mbuf - both obuf and ibuf are usually the same,
6074 * so check if they point at the same address is necessary,
6075 * to avoid freeing the mbuf twice.
6077 if (ut_paramz[j].ut_params.obuf) {
6078 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6079 if (ut_paramz[j].ut_params.ibuf
6080 == ut_paramz[j].ut_params.obuf)
6081 ut_paramz[j].ut_params.ibuf = 0;
6082 ut_paramz[j].ut_params.obuf = 0;
6084 if (ut_paramz[j].ut_params.ibuf) {
6085 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6086 ut_paramz[j].ut_params.ibuf = 0;
6090 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6091 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6093 rte_cryptodev_sym_session_free(sessions[i]);
6098 return TEST_SUCCESS;
6102 test_null_cipher_only_operation(void)
6104 struct crypto_testsuite_params *ts_params = &testsuite_params;
6105 struct crypto_unittest_params *ut_params = &unittest_params;
6107 /* Generate test mbuf data and space for digest */
6108 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6109 catch_22_quote, QUOTE_512_BYTES, 0);
6111 /* Setup Cipher Parameters */
6112 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6113 ut_params->cipher_xform.next = NULL;
6115 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6116 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6118 ut_params->sess = rte_cryptodev_sym_session_create(
6119 ts_params->session_mpool);
6121 /* Create Crypto session*/
6122 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6124 &ut_params->cipher_xform,
6125 ts_params->session_mpool);
6126 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6128 /* Generate Crypto op data structure */
6129 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6130 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6131 TEST_ASSERT_NOT_NULL(ut_params->op,
6132 "Failed to allocate symmetric crypto operation struct");
6134 /* Set crypto operation data parameters */
6135 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6137 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6139 /* set crypto operation source mbuf */
6140 sym_op->m_src = ut_params->ibuf;
6142 sym_op->cipher.data.offset = 0;
6143 sym_op->cipher.data.length = QUOTE_512_BYTES;
6145 /* Process crypto operation */
6146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6148 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6150 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6151 "crypto operation processing failed");
6154 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6155 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6158 "Ciphertext data not as expected");
6160 return TEST_SUCCESS;
6164 test_null_auth_only_operation(void)
6166 struct crypto_testsuite_params *ts_params = &testsuite_params;
6167 struct crypto_unittest_params *ut_params = &unittest_params;
6169 /* Generate test mbuf data and space for digest */
6170 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6171 catch_22_quote, QUOTE_512_BYTES, 0);
6173 /* Setup HMAC Parameters */
6174 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6175 ut_params->auth_xform.next = NULL;
6177 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6178 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6180 ut_params->sess = rte_cryptodev_sym_session_create(
6181 ts_params->session_mpool);
6183 /* Create Crypto session*/
6184 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6185 ut_params->sess, &ut_params->auth_xform,
6186 ts_params->session_mpool);
6187 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6189 /* Generate Crypto op data structure */
6190 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6191 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6192 TEST_ASSERT_NOT_NULL(ut_params->op,
6193 "Failed to allocate symmetric crypto operation struct");
6195 /* Set crypto operation data parameters */
6196 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6198 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6200 sym_op->m_src = ut_params->ibuf;
6202 sym_op->auth.data.offset = 0;
6203 sym_op->auth.data.length = QUOTE_512_BYTES;
6205 /* Process crypto operation */
6206 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6208 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6210 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6211 "crypto operation processing failed");
6213 return TEST_SUCCESS;
6217 test_null_cipher_auth_operation(void)
6219 struct crypto_testsuite_params *ts_params = &testsuite_params;
6220 struct crypto_unittest_params *ut_params = &unittest_params;
6222 /* Generate test mbuf data and space for digest */
6223 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6224 catch_22_quote, QUOTE_512_BYTES, 0);
6226 /* Setup Cipher Parameters */
6227 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6228 ut_params->cipher_xform.next = &ut_params->auth_xform;
6230 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6231 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6233 /* Setup HMAC Parameters */
6234 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6235 ut_params->auth_xform.next = NULL;
6237 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6238 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6240 ut_params->sess = rte_cryptodev_sym_session_create(
6241 ts_params->session_mpool);
6243 /* Create Crypto session*/
6244 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6245 ut_params->sess, &ut_params->cipher_xform,
6246 ts_params->session_mpool);
6247 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6249 /* Generate Crypto op data structure */
6250 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6251 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6252 TEST_ASSERT_NOT_NULL(ut_params->op,
6253 "Failed to allocate symmetric crypto operation struct");
6255 /* Set crypto operation data parameters */
6256 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6258 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6260 sym_op->m_src = ut_params->ibuf;
6262 sym_op->cipher.data.offset = 0;
6263 sym_op->cipher.data.length = QUOTE_512_BYTES;
6265 sym_op->auth.data.offset = 0;
6266 sym_op->auth.data.length = QUOTE_512_BYTES;
6268 /* Process crypto operation */
6269 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6271 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6273 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6274 "crypto operation processing failed");
6277 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6278 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6281 "Ciphertext data not as expected");
6283 return TEST_SUCCESS;
6287 test_null_auth_cipher_operation(void)
6289 struct crypto_testsuite_params *ts_params = &testsuite_params;
6290 struct crypto_unittest_params *ut_params = &unittest_params;
6292 /* Generate test mbuf data and space for digest */
6293 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6294 catch_22_quote, QUOTE_512_BYTES, 0);
6296 /* Setup Cipher Parameters */
6297 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6298 ut_params->cipher_xform.next = NULL;
6300 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6301 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6303 /* Setup HMAC Parameters */
6304 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6305 ut_params->auth_xform.next = &ut_params->cipher_xform;
6307 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6308 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6310 ut_params->sess = rte_cryptodev_sym_session_create(
6311 ts_params->session_mpool);
6313 /* Create Crypto session*/
6314 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6315 ut_params->sess, &ut_params->cipher_xform,
6316 ts_params->session_mpool);
6317 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6319 /* Generate Crypto op data structure */
6320 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6321 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6322 TEST_ASSERT_NOT_NULL(ut_params->op,
6323 "Failed to allocate symmetric crypto operation struct");
6325 /* Set crypto operation data parameters */
6326 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6328 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6330 sym_op->m_src = ut_params->ibuf;
6332 sym_op->cipher.data.offset = 0;
6333 sym_op->cipher.data.length = QUOTE_512_BYTES;
6335 sym_op->auth.data.offset = 0;
6336 sym_op->auth.data.length = QUOTE_512_BYTES;
6338 /* Process crypto operation */
6339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6341 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6343 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6344 "crypto operation processing failed");
6347 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6348 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6351 "Ciphertext data not as expected");
6353 return TEST_SUCCESS;
6358 test_null_invalid_operation(void)
6360 struct crypto_testsuite_params *ts_params = &testsuite_params;
6361 struct crypto_unittest_params *ut_params = &unittest_params;
6364 /* Setup Cipher Parameters */
6365 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6366 ut_params->cipher_xform.next = NULL;
6368 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6369 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6371 ut_params->sess = rte_cryptodev_sym_session_create(
6372 ts_params->session_mpool);
6374 /* Create Crypto session*/
6375 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6376 ut_params->sess, &ut_params->cipher_xform,
6377 ts_params->session_mpool);
6378 TEST_ASSERT(ret == -1,
6379 "Session creation succeeded unexpectedly");
6382 /* Setup HMAC Parameters */
6383 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6384 ut_params->auth_xform.next = NULL;
6386 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6387 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6389 ut_params->sess = rte_cryptodev_sym_session_create(
6390 ts_params->session_mpool);
6392 /* Create Crypto session*/
6393 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6394 ut_params->sess, &ut_params->auth_xform,
6395 ts_params->session_mpool);
6396 TEST_ASSERT(ret == -1,
6397 "Session creation succeeded unexpectedly");
6399 return TEST_SUCCESS;
6403 #define NULL_BURST_LENGTH (32)
6406 test_null_burst_operation(void)
6408 struct crypto_testsuite_params *ts_params = &testsuite_params;
6409 struct crypto_unittest_params *ut_params = &unittest_params;
6411 unsigned i, burst_len = NULL_BURST_LENGTH;
6413 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6414 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6416 /* Setup Cipher Parameters */
6417 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6418 ut_params->cipher_xform.next = &ut_params->auth_xform;
6420 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6421 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6423 /* Setup HMAC Parameters */
6424 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6425 ut_params->auth_xform.next = NULL;
6427 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6428 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6430 ut_params->sess = rte_cryptodev_sym_session_create(
6431 ts_params->session_mpool);
6433 /* Create Crypto session*/
6434 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6435 ut_params->sess, &ut_params->cipher_xform,
6436 ts_params->session_mpool);
6437 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6439 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6440 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6441 burst_len, "failed to generate burst of crypto ops");
6443 /* Generate an operation for each mbuf in burst */
6444 for (i = 0; i < burst_len; i++) {
6445 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6447 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6449 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6453 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6455 burst[i]->sym->m_src = m;
6458 /* Process crypto operation */
6459 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6460 0, burst, burst_len),
6462 "Error enqueuing burst");
6464 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6465 0, burst_dequeued, burst_len),
6467 "Error dequeuing burst");
6470 for (i = 0; i < burst_len; i++) {
6472 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6473 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6475 "data not as expected");
6477 rte_pktmbuf_free(burst[i]->sym->m_src);
6478 rte_crypto_op_free(burst[i]);
6481 return TEST_SUCCESS;
6485 generate_gmac_large_plaintext(uint8_t *data)
6489 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6490 memcpy(&data[i], &data[0], 32);
6494 create_gmac_operation(enum rte_crypto_auth_operation op,
6495 const struct gmac_test_data *tdata)
6497 struct crypto_testsuite_params *ts_params = &testsuite_params;
6498 struct crypto_unittest_params *ut_params = &unittest_params;
6499 struct rte_crypto_sym_op *sym_op;
6501 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6503 /* Generate Crypto op data structure */
6504 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6505 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6506 TEST_ASSERT_NOT_NULL(ut_params->op,
6507 "Failed to allocate symmetric crypto operation struct");
6509 sym_op = ut_params->op->sym;
6511 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6512 ut_params->ibuf, tdata->gmac_tag.len);
6513 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6514 "no room to append digest");
6516 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6517 ut_params->ibuf, plaintext_pad_len);
6519 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6520 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6521 tdata->gmac_tag.len);
6522 TEST_HEXDUMP(stdout, "digest:",
6523 sym_op->auth.digest.data,
6524 tdata->gmac_tag.len);
6527 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6528 uint8_t *, IV_OFFSET);
6530 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6532 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6534 sym_op->cipher.data.length = 0;
6535 sym_op->cipher.data.offset = 0;
6537 sym_op->auth.data.offset = 0;
6538 sym_op->auth.data.length = tdata->plaintext.len;
6543 static int create_gmac_session(uint8_t dev_id,
6544 const struct gmac_test_data *tdata,
6545 enum rte_crypto_auth_operation auth_op)
6547 uint8_t auth_key[tdata->key.len];
6549 struct crypto_testsuite_params *ts_params = &testsuite_params;
6550 struct crypto_unittest_params *ut_params = &unittest_params;
6552 memcpy(auth_key, tdata->key.data, tdata->key.len);
6554 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6555 ut_params->auth_xform.next = NULL;
6557 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6558 ut_params->auth_xform.auth.op = auth_op;
6559 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6560 ut_params->auth_xform.auth.key.length = tdata->key.len;
6561 ut_params->auth_xform.auth.key.data = auth_key;
6562 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6563 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6566 ut_params->sess = rte_cryptodev_sym_session_create(
6567 ts_params->session_mpool);
6569 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6570 &ut_params->auth_xform,
6571 ts_params->session_mpool);
6573 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6579 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6581 struct crypto_testsuite_params *ts_params = &testsuite_params;
6582 struct crypto_unittest_params *ut_params = &unittest_params;
6586 uint8_t *auth_tag, *plaintext;
6587 uint16_t plaintext_pad_len;
6589 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6590 "No GMAC length in the source data");
6592 retval = create_gmac_session(ts_params->valid_devs[0],
6593 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6598 if (tdata->plaintext.len > MBUF_SIZE)
6599 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6602 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6603 "Failed to allocate input buffer in mempool");
6605 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6606 rte_pktmbuf_tailroom(ut_params->ibuf));
6608 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6610 * Runtime generate the large plain text instead of use hard code
6611 * plain text vector. It is done to avoid create huge source file
6612 * with the test vector.
6614 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6615 generate_gmac_large_plaintext(tdata->plaintext.data);
6617 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6619 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6621 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6622 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6623 tdata->plaintext.len);
6625 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6631 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6633 ut_params->op->sym->m_src = ut_params->ibuf;
6635 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6636 ut_params->op), "failed to process sym crypto op");
6638 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6639 "crypto op processing failed");
6641 if (ut_params->op->sym->m_dst) {
6642 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6643 uint8_t *, plaintext_pad_len);
6645 auth_tag = plaintext + plaintext_pad_len;
6648 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6652 tdata->gmac_tag.data,
6653 tdata->gmac_tag.len,
6654 "GMAC Generated auth tag not as expected");
6660 test_AES_GMAC_authentication_test_case_1(void)
6662 return test_AES_GMAC_authentication(&gmac_test_case_1);
6666 test_AES_GMAC_authentication_test_case_2(void)
6668 return test_AES_GMAC_authentication(&gmac_test_case_2);
6672 test_AES_GMAC_authentication_test_case_3(void)
6674 return test_AES_GMAC_authentication(&gmac_test_case_3);
6678 test_AES_GMAC_authentication_test_case_4(void)
6680 return test_AES_GMAC_authentication(&gmac_test_case_4);
6684 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6686 struct crypto_testsuite_params *ts_params = &testsuite_params;
6687 struct crypto_unittest_params *ut_params = &unittest_params;
6689 uint32_t plaintext_pad_len;
6692 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6693 "No GMAC length in the source data");
6695 retval = create_gmac_session(ts_params->valid_devs[0],
6696 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6701 if (tdata->plaintext.len > MBUF_SIZE)
6702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6705 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6706 "Failed to allocate input buffer in mempool");
6708 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6709 rte_pktmbuf_tailroom(ut_params->ibuf));
6711 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6714 * Runtime generate the large plain text instead of use hard code
6715 * plain text vector. It is done to avoid create huge source file
6716 * with the test vector.
6718 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6719 generate_gmac_large_plaintext(tdata->plaintext.data);
6721 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6723 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6725 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6726 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6727 tdata->plaintext.len);
6729 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6735 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6737 ut_params->op->sym->m_src = ut_params->ibuf;
6739 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6740 ut_params->op), "failed to process sym crypto op");
6742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6743 "crypto op processing failed");
6750 test_AES_GMAC_authentication_verify_test_case_1(void)
6752 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6756 test_AES_GMAC_authentication_verify_test_case_2(void)
6758 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6762 test_AES_GMAC_authentication_verify_test_case_3(void)
6764 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6768 test_AES_GMAC_authentication_verify_test_case_4(void)
6770 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6773 struct test_crypto_vector {
6774 enum rte_crypto_cipher_algorithm crypto_algo;
6787 const uint8_t *data;
6792 const uint8_t *data;
6796 enum rte_crypto_auth_algorithm auth_algo;
6804 const uint8_t *data;
6814 static const struct test_crypto_vector
6815 hmac_sha1_test_crypto_vector = {
6816 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6818 .data = plaintext_hash,
6823 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6824 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6825 0xDE, 0xF4, 0xDE, 0xAD
6831 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6832 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6833 0x3F, 0x91, 0x64, 0x59
6839 static const struct test_crypto_vector
6840 aes128_gmac_test_vector = {
6841 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6843 .data = plaintext_hash,
6848 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6849 0x08, 0x09, 0x0A, 0x0B
6855 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6856 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6862 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6863 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6869 static const struct test_crypto_vector
6870 aes128cbc_hmac_sha1_test_vector = {
6871 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6874 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6875 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6881 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6882 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6887 .data = plaintext_hash,
6891 .data = ciphertext512_aes128cbc,
6894 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6897 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6898 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6899 0xDE, 0xF4, 0xDE, 0xAD
6905 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6906 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6907 0x18, 0x8C, 0x1D, 0x32
6914 data_corruption(uint8_t *data)
6920 tag_corruption(uint8_t *data, unsigned int tag_offset)
6922 data[tag_offset] += 1;
6926 create_auth_session(struct crypto_unittest_params *ut_params,
6928 const struct test_crypto_vector *reference,
6929 enum rte_crypto_auth_operation auth_op)
6931 struct crypto_testsuite_params *ts_params = &testsuite_params;
6932 uint8_t auth_key[reference->auth_key.len + 1];
6934 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6936 /* Setup Authentication Parameters */
6937 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6938 ut_params->auth_xform.auth.op = auth_op;
6939 ut_params->auth_xform.next = NULL;
6940 ut_params->auth_xform.auth.algo = reference->auth_algo;
6941 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6942 ut_params->auth_xform.auth.key.data = auth_key;
6943 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6945 /* Create Crypto session*/
6946 ut_params->sess = rte_cryptodev_sym_session_create(
6947 ts_params->session_mpool);
6949 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6950 &ut_params->auth_xform,
6951 ts_params->session_mpool);
6953 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6959 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6961 const struct test_crypto_vector *reference,
6962 enum rte_crypto_auth_operation auth_op,
6963 enum rte_crypto_cipher_operation cipher_op)
6965 struct crypto_testsuite_params *ts_params = &testsuite_params;
6966 uint8_t cipher_key[reference->cipher_key.len + 1];
6967 uint8_t auth_key[reference->auth_key.len + 1];
6969 memcpy(cipher_key, reference->cipher_key.data,
6970 reference->cipher_key.len);
6971 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6973 /* Setup Authentication Parameters */
6974 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6975 ut_params->auth_xform.auth.op = auth_op;
6976 ut_params->auth_xform.auth.algo = reference->auth_algo;
6977 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6978 ut_params->auth_xform.auth.key.data = auth_key;
6979 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6981 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6982 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6983 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6985 ut_params->auth_xform.next = &ut_params->cipher_xform;
6987 /* Setup Cipher Parameters */
6988 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6989 ut_params->cipher_xform.next = NULL;
6990 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6991 ut_params->cipher_xform.cipher.op = cipher_op;
6992 ut_params->cipher_xform.cipher.key.data = cipher_key;
6993 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6994 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6995 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6998 /* Create Crypto session*/
6999 ut_params->sess = rte_cryptodev_sym_session_create(
7000 ts_params->session_mpool);
7002 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7003 &ut_params->auth_xform,
7004 ts_params->session_mpool);
7006 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7012 create_auth_operation(struct crypto_testsuite_params *ts_params,
7013 struct crypto_unittest_params *ut_params,
7014 const struct test_crypto_vector *reference,
7015 unsigned int auth_generate)
7017 /* Generate Crypto op data structure */
7018 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7019 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7020 TEST_ASSERT_NOT_NULL(ut_params->op,
7021 "Failed to allocate pktmbuf offload");
7023 /* Set crypto operation data parameters */
7024 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7026 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7028 /* set crypto operation source mbuf */
7029 sym_op->m_src = ut_params->ibuf;
7032 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7033 ut_params->ibuf, reference->digest.len);
7035 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7036 "no room to append auth tag");
7038 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7039 ut_params->ibuf, reference->plaintext.len);
7042 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7044 memcpy(sym_op->auth.digest.data,
7045 reference->digest.data,
7046 reference->digest.len);
7048 TEST_HEXDUMP(stdout, "digest:",
7049 sym_op->auth.digest.data,
7050 reference->digest.len);
7052 sym_op->auth.data.length = reference->plaintext.len;
7053 sym_op->auth.data.offset = 0;
7059 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7060 struct crypto_unittest_params *ut_params,
7061 const struct test_crypto_vector *reference,
7062 unsigned int auth_generate)
7064 /* Generate Crypto op data structure */
7065 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7066 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7067 TEST_ASSERT_NOT_NULL(ut_params->op,
7068 "Failed to allocate pktmbuf offload");
7070 /* Set crypto operation data parameters */
7071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7073 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7075 /* set crypto operation source mbuf */
7076 sym_op->m_src = ut_params->ibuf;
7079 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7080 ut_params->ibuf, reference->digest.len);
7082 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7083 "no room to append auth tag");
7085 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7086 ut_params->ibuf, reference->ciphertext.len);
7089 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7091 memcpy(sym_op->auth.digest.data,
7092 reference->digest.data,
7093 reference->digest.len);
7095 TEST_HEXDUMP(stdout, "digest:",
7096 sym_op->auth.digest.data,
7097 reference->digest.len);
7099 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7100 reference->iv.data, reference->iv.len);
7102 sym_op->cipher.data.length = 0;
7103 sym_op->cipher.data.offset = 0;
7105 sym_op->auth.data.length = reference->plaintext.len;
7106 sym_op->auth.data.offset = 0;
7112 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7113 struct crypto_unittest_params *ut_params,
7114 const struct test_crypto_vector *reference,
7115 unsigned int auth_generate)
7117 /* Generate Crypto op data structure */
7118 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7119 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7120 TEST_ASSERT_NOT_NULL(ut_params->op,
7121 "Failed to allocate pktmbuf offload");
7123 /* Set crypto operation data parameters */
7124 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7126 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7128 /* set crypto operation source mbuf */
7129 sym_op->m_src = ut_params->ibuf;
7132 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7133 ut_params->ibuf, reference->digest.len);
7135 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7136 "no room to append auth tag");
7138 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7139 ut_params->ibuf, reference->ciphertext.len);
7142 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7144 memcpy(sym_op->auth.digest.data,
7145 reference->digest.data,
7146 reference->digest.len);
7148 TEST_HEXDUMP(stdout, "digest:",
7149 sym_op->auth.digest.data,
7150 reference->digest.len);
7152 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7153 reference->iv.data, reference->iv.len);
7155 sym_op->cipher.data.length = reference->ciphertext.len;
7156 sym_op->cipher.data.offset = 0;
7158 sym_op->auth.data.length = reference->ciphertext.len;
7159 sym_op->auth.data.offset = 0;
7165 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7166 struct crypto_unittest_params *ut_params,
7167 const struct test_crypto_vector *reference)
7169 return create_auth_operation(ts_params, ut_params, reference, 0);
7173 create_auth_verify_GMAC_operation(
7174 struct crypto_testsuite_params *ts_params,
7175 struct crypto_unittest_params *ut_params,
7176 const struct test_crypto_vector *reference)
7178 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7182 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7183 struct crypto_unittest_params *ut_params,
7184 const struct test_crypto_vector *reference)
7186 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7190 test_authentication_verify_fail_when_data_corruption(
7191 struct crypto_testsuite_params *ts_params,
7192 struct crypto_unittest_params *ut_params,
7193 const struct test_crypto_vector *reference,
7194 unsigned int data_corrupted)
7200 /* Create session */
7201 retval = create_auth_session(ut_params,
7202 ts_params->valid_devs[0],
7204 RTE_CRYPTO_AUTH_OP_VERIFY);
7208 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7209 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7210 "Failed to allocate input buffer in mempool");
7212 /* clear mbuf payload */
7213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7214 rte_pktmbuf_tailroom(ut_params->ibuf));
7216 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7217 reference->plaintext.len);
7218 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7219 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7221 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7223 /* Create operation */
7224 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7230 data_corruption(plaintext);
7232 tag_corruption(plaintext, reference->plaintext.len);
7234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7237 TEST_ASSERT_EQUAL(ut_params->op->status,
7238 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7239 "authentication not failed");
7241 ut_params->obuf = ut_params->op->sym->m_src;
7242 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7248 test_authentication_verify_GMAC_fail_when_corruption(
7249 struct crypto_testsuite_params *ts_params,
7250 struct crypto_unittest_params *ut_params,
7251 const struct test_crypto_vector *reference,
7252 unsigned int data_corrupted)
7257 /* Create session */
7258 retval = create_auth_cipher_session(ut_params,
7259 ts_params->valid_devs[0],
7261 RTE_CRYPTO_AUTH_OP_VERIFY,
7262 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7266 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7267 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7268 "Failed to allocate input buffer in mempool");
7270 /* clear mbuf payload */
7271 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7272 rte_pktmbuf_tailroom(ut_params->ibuf));
7274 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7275 reference->plaintext.len);
7276 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7277 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7279 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7281 /* Create operation */
7282 retval = create_auth_verify_GMAC_operation(ts_params,
7290 data_corruption(plaintext);
7292 tag_corruption(plaintext, reference->aad.len);
7294 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7296 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7297 TEST_ASSERT_EQUAL(ut_params->op->status,
7298 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7299 "authentication not failed");
7301 ut_params->obuf = ut_params->op->sym->m_src;
7302 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7308 test_authenticated_decryption_fail_when_corruption(
7309 struct crypto_testsuite_params *ts_params,
7310 struct crypto_unittest_params *ut_params,
7311 const struct test_crypto_vector *reference,
7312 unsigned int data_corrupted)
7316 uint8_t *ciphertext;
7318 /* Create session */
7319 retval = create_auth_cipher_session(ut_params,
7320 ts_params->valid_devs[0],
7322 RTE_CRYPTO_AUTH_OP_VERIFY,
7323 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7328 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7329 "Failed to allocate input buffer in mempool");
7331 /* clear mbuf payload */
7332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7333 rte_pktmbuf_tailroom(ut_params->ibuf));
7335 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7336 reference->ciphertext.len);
7337 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7338 memcpy(ciphertext, reference->ciphertext.data,
7339 reference->ciphertext.len);
7341 /* Create operation */
7342 retval = create_cipher_auth_verify_operation(ts_params,
7350 data_corruption(ciphertext);
7352 tag_corruption(ciphertext, reference->ciphertext.len);
7354 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7357 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7358 TEST_ASSERT_EQUAL(ut_params->op->status,
7359 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7360 "authentication not failed");
7362 ut_params->obuf = ut_params->op->sym->m_src;
7363 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7369 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7370 const struct gcm_test_data *tdata,
7371 void *digest_mem, uint64_t digest_phys)
7373 struct crypto_testsuite_params *ts_params = &testsuite_params;
7374 struct crypto_unittest_params *ut_params = &unittest_params;
7376 const unsigned int auth_tag_len = tdata->auth_tag.len;
7377 const unsigned int iv_len = tdata->iv.len;
7378 const unsigned int aad_len = tdata->aad.len;
7380 /* Generate Crypto op data structure */
7381 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7382 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7383 TEST_ASSERT_NOT_NULL(ut_params->op,
7384 "Failed to allocate symmetric crypto operation struct");
7386 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7388 sym_op->aead.digest.data = digest_mem;
7390 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7391 "no room to append digest");
7393 sym_op->aead.digest.phys_addr = digest_phys;
7395 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7396 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7398 TEST_HEXDUMP(stdout, "digest:",
7399 sym_op->aead.digest.data,
7403 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7404 uint8_t *, IV_OFFSET);
7406 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7408 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7409 ut_params->ibuf, aad_len);
7410 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7411 "no room to prepend aad");
7412 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7415 memset(sym_op->aead.aad.data, 0, aad_len);
7416 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7418 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7419 TEST_HEXDUMP(stdout, "aad:",
7420 sym_op->aead.aad.data, aad_len);
7422 sym_op->aead.data.length = tdata->plaintext.len;
7423 sym_op->aead.data.offset = aad_len;
7428 #define SGL_MAX_NO 16
7431 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7432 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7434 struct crypto_testsuite_params *ts_params = &testsuite_params;
7435 struct crypto_unittest_params *ut_params = &unittest_params;
7436 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7439 int to_trn_tbl[SGL_MAX_NO];
7441 unsigned int trn_data = 0;
7442 uint8_t *plaintext, *ciphertext, *auth_tag;
7444 if (fragsz > tdata->plaintext.len)
7445 fragsz = tdata->plaintext.len;
7447 uint16_t plaintext_len = fragsz;
7448 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7450 if (fragsz_oop > tdata->plaintext.len)
7451 frag_size_oop = tdata->plaintext.len;
7454 void *digest_mem = NULL;
7456 uint32_t prepend_len = tdata->aad.len;
7458 if (tdata->plaintext.len % fragsz != 0) {
7459 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7462 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7467 * For out-op-place we need to alloc another mbuf
7470 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7471 rte_pktmbuf_append(ut_params->obuf,
7472 frag_size_oop + prepend_len);
7473 buf_oop = ut_params->obuf;
7476 /* Create GCM session */
7477 retval = create_gcm_session(ts_params->valid_devs[0],
7478 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7479 tdata->key.data, tdata->key.len,
7480 tdata->aad.len, tdata->auth_tag.len,
7485 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7487 /* clear mbuf payload */
7488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7489 rte_pktmbuf_tailroom(ut_params->ibuf));
7491 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7494 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7496 trn_data += plaintext_len;
7498 buf = ut_params->ibuf;
7501 * Loop until no more fragments
7504 while (trn_data < tdata->plaintext.len) {
7506 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7507 (tdata->plaintext.len - trn_data) : fragsz;
7509 to_trn_tbl[ecx++] = to_trn;
7511 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7514 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7515 rte_pktmbuf_tailroom(buf));
7518 if (oop && !fragsz_oop) {
7519 buf_last_oop = buf_oop->next =
7520 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7521 buf_oop = buf_oop->next;
7522 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7523 0, rte_pktmbuf_tailroom(buf_oop));
7524 rte_pktmbuf_append(buf_oop, to_trn);
7527 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7530 memcpy(plaintext, tdata->plaintext.data + trn_data,
7533 if (trn_data == tdata->plaintext.len) {
7536 digest_mem = rte_pktmbuf_append(buf_oop,
7537 tdata->auth_tag.len);
7539 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7540 tdata->auth_tag.len);
7544 uint64_t digest_phys = 0;
7546 ut_params->ibuf->nb_segs = segs;
7549 if (fragsz_oop && oop) {
7553 if (frag_size_oop == tdata->plaintext.len) {
7554 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7555 tdata->auth_tag.len);
7557 digest_phys = rte_pktmbuf_mtophys_offset(
7559 tdata->plaintext.len + prepend_len);
7562 trn_data = frag_size_oop;
7563 while (trn_data < tdata->plaintext.len) {
7566 (tdata->plaintext.len - trn_data <
7568 (tdata->plaintext.len - trn_data) :
7571 to_trn_tbl[ecx++] = to_trn;
7573 buf_last_oop = buf_oop->next =
7574 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7575 buf_oop = buf_oop->next;
7576 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7577 0, rte_pktmbuf_tailroom(buf_oop));
7578 rte_pktmbuf_append(buf_oop, to_trn);
7582 if (trn_data == tdata->plaintext.len) {
7583 digest_mem = rte_pktmbuf_append(buf_oop,
7584 tdata->auth_tag.len);
7588 ut_params->obuf->nb_segs = segs;
7592 * Place digest at the end of the last buffer
7595 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7596 if (oop && buf_last_oop)
7597 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7599 if (!digest_mem && !oop) {
7600 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7601 + tdata->auth_tag.len);
7602 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7603 tdata->plaintext.len);
7606 /* Create GCM opertaion */
7607 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7608 tdata, digest_mem, digest_phys);
7613 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7615 ut_params->op->sym->m_src = ut_params->ibuf;
7617 ut_params->op->sym->m_dst = ut_params->obuf;
7619 /* Process crypto operation */
7620 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7621 ut_params->op), "failed to process sym crypto op");
7623 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7624 "crypto op processing failed");
7627 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7628 uint8_t *, prepend_len);
7630 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7631 uint8_t *, prepend_len);
7635 fragsz = fragsz_oop;
7637 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7639 tdata->ciphertext.data,
7641 "GCM Ciphertext data not as expected");
7643 buf = ut_params->op->sym->m_src->next;
7645 buf = ut_params->op->sym->m_dst->next;
7647 unsigned int off = fragsz;
7651 ciphertext = rte_pktmbuf_mtod(buf,
7654 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7656 tdata->ciphertext.data + off,
7658 "GCM Ciphertext data not as expected");
7660 off += to_trn_tbl[ecx++];
7664 auth_tag = digest_mem;
7665 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7667 tdata->auth_tag.data,
7668 tdata->auth_tag.len,
7669 "GCM Generated auth tag not as expected");
7675 #define OUT_OF_PLACE 1
7678 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7680 return test_AES_GCM_authenticated_encryption_SGL(
7681 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7685 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7687 return test_AES_GCM_authenticated_encryption_SGL(
7688 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7692 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7694 return test_AES_GCM_authenticated_encryption_SGL(
7695 &gcm_test_case_8, OUT_OF_PLACE, 400,
7696 gcm_test_case_8.plaintext.len);
7700 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7703 return test_AES_GCM_authenticated_encryption_SGL(
7704 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7708 test_authentication_verify_fail_when_data_corrupted(
7709 struct crypto_testsuite_params *ts_params,
7710 struct crypto_unittest_params *ut_params,
7711 const struct test_crypto_vector *reference)
7713 return test_authentication_verify_fail_when_data_corruption(
7714 ts_params, ut_params, reference, 1);
7718 test_authentication_verify_fail_when_tag_corrupted(
7719 struct crypto_testsuite_params *ts_params,
7720 struct crypto_unittest_params *ut_params,
7721 const struct test_crypto_vector *reference)
7723 return test_authentication_verify_fail_when_data_corruption(
7724 ts_params, ut_params, reference, 0);
7728 test_authentication_verify_GMAC_fail_when_data_corrupted(
7729 struct crypto_testsuite_params *ts_params,
7730 struct crypto_unittest_params *ut_params,
7731 const struct test_crypto_vector *reference)
7733 return test_authentication_verify_GMAC_fail_when_corruption(
7734 ts_params, ut_params, reference, 1);
7738 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7739 struct crypto_testsuite_params *ts_params,
7740 struct crypto_unittest_params *ut_params,
7741 const struct test_crypto_vector *reference)
7743 return test_authentication_verify_GMAC_fail_when_corruption(
7744 ts_params, ut_params, reference, 0);
7748 test_authenticated_decryption_fail_when_data_corrupted(
7749 struct crypto_testsuite_params *ts_params,
7750 struct crypto_unittest_params *ut_params,
7751 const struct test_crypto_vector *reference)
7753 return test_authenticated_decryption_fail_when_corruption(
7754 ts_params, ut_params, reference, 1);
7758 test_authenticated_decryption_fail_when_tag_corrupted(
7759 struct crypto_testsuite_params *ts_params,
7760 struct crypto_unittest_params *ut_params,
7761 const struct test_crypto_vector *reference)
7763 return test_authenticated_decryption_fail_when_corruption(
7764 ts_params, ut_params, reference, 0);
7768 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7770 return test_authentication_verify_fail_when_data_corrupted(
7771 &testsuite_params, &unittest_params,
7772 &hmac_sha1_test_crypto_vector);
7776 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7778 return test_authentication_verify_fail_when_tag_corrupted(
7779 &testsuite_params, &unittest_params,
7780 &hmac_sha1_test_crypto_vector);
7784 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7786 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7787 &testsuite_params, &unittest_params,
7788 &aes128_gmac_test_vector);
7792 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7794 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7795 &testsuite_params, &unittest_params,
7796 &aes128_gmac_test_vector);
7800 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7802 return test_authenticated_decryption_fail_when_data_corrupted(
7805 &aes128cbc_hmac_sha1_test_vector);
7809 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7811 return test_authenticated_decryption_fail_when_tag_corrupted(
7814 &aes128cbc_hmac_sha1_test_vector);
7817 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7819 /* global AESNI slave IDs for the scheduler test */
7820 uint8_t aesni_ids[2];
7823 test_scheduler_attach_slave_op(void)
7825 struct crypto_testsuite_params *ts_params = &testsuite_params;
7826 uint8_t sched_id = ts_params->valid_devs[0];
7827 uint32_t nb_devs, i, nb_devs_attached = 0;
7831 /* create 2 AESNI_MB if necessary */
7832 nb_devs = rte_cryptodev_device_count_by_driver(
7833 rte_cryptodev_driver_id_get(
7834 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
7836 for (i = nb_devs; i < 2; i++) {
7837 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7838 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7840 ret = rte_vdev_init(vdev_name, NULL);
7842 TEST_ASSERT(ret == 0,
7843 "Failed to create instance %u of"
7845 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7849 /* attach 2 AESNI_MB cdevs */
7850 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7852 struct rte_cryptodev_info info;
7854 rte_cryptodev_info_get(i, &info);
7855 if (info.driver_id != rte_cryptodev_driver_id_get(
7856 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
7860 * Create the session mempool again, since now there are new devices
7861 * to use the mempool.
7863 if (ts_params->session_mpool) {
7864 rte_mempool_free(ts_params->session_mpool);
7865 ts_params->session_mpool = NULL;
7867 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
7870 * Create mempool with maximum number of sessions * 2,
7871 * to include the session headers
7873 if (ts_params->session_mpool == NULL) {
7874 ts_params->session_mpool = rte_mempool_create(
7876 info.sym.max_nb_sessions * 2,
7878 0, 0, NULL, NULL, NULL,
7879 NULL, SOCKET_ID_ANY,
7882 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
7883 "session mempool allocation failed");
7886 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7889 TEST_ASSERT(ret == 0,
7890 "Failed to attach device %u of pmd : %s", i,
7891 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7893 aesni_ids[nb_devs_attached] = (uint8_t)i;
7902 test_scheduler_detach_slave_op(void)
7904 struct crypto_testsuite_params *ts_params = &testsuite_params;
7905 uint8_t sched_id = ts_params->valid_devs[0];
7909 for (i = 0; i < 2; i++) {
7910 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7912 TEST_ASSERT(ret == 0,
7913 "Failed to detach device %u", aesni_ids[i]);
7920 test_scheduler_mode_op(void)
7922 struct crypto_testsuite_params *ts_params = &testsuite_params;
7923 uint8_t sched_id = ts_params->valid_devs[0];
7924 struct rte_cryptodev_scheduler_ops op = {0};
7925 struct rte_cryptodev_scheduler dummy_scheduler = {
7926 .description = "dummy scheduler to test mode",
7927 .name = "dummy scheduler",
7928 .mode = CDEV_SCHED_MODE_USERDEFINED,
7933 /* set user defined mode */
7934 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7936 TEST_ASSERT(ret == 0,
7937 "Failed to set cdev %u to user defined mode", sched_id);
7939 /* set round robin mode */
7940 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7941 CDEV_SCHED_MODE_ROUNDROBIN);
7942 TEST_ASSERT(ret == 0,
7943 "Failed to set cdev %u to round-robin mode", sched_id);
7944 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7945 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7951 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7952 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7953 .setup = testsuite_setup,
7954 .teardown = testsuite_teardown,
7955 .unit_test_cases = {
7956 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7957 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7958 TEST_CASE_ST(ut_setup, ut_teardown,
7959 test_AES_chain_scheduler_all),
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_AES_cipheronly_scheduler_all),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_authonly_scheduler_all),
7964 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7965 TEST_CASES_END() /**< NULL terminate unit test array */
7969 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7971 static struct unit_test_suite cryptodev_qat_testsuite = {
7972 .suite_name = "Crypto QAT Unit Test Suite",
7973 .setup = testsuite_setup,
7974 .teardown = testsuite_teardown,
7975 .unit_test_cases = {
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_device_configure_invalid_dev_id),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_device_configure_invalid_queue_pair_ids),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_queue_pair_descriptor_setup),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_multi_session),
7985 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 test_AES_cipheronly_qat_all),
7988 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7989 TEST_CASE_ST(ut_setup, ut_teardown,
7990 test_3DES_cipheronly_qat_all),
7991 TEST_CASE_ST(ut_setup, ut_teardown,
7992 test_DES_cipheronly_qat_all),
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_AES_docsis_qat_all),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_DES_docsis_qat_all),
7997 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7999 /** AES GCM Authenticated Encryption */
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_AES_GCM_authenticated_encryption_test_case_1),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_AES_GCM_authenticated_encryption_test_case_2),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_AES_GCM_authenticated_encryption_test_case_3),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_AES_GCM_authenticated_encryption_test_case_4),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_AES_GCM_authenticated_encryption_test_case_5),
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_AES_GCM_authenticated_encryption_test_case_6),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_AES_GCM_authenticated_encryption_test_case_7),
8021 /** AES GCM Authenticated Decryption */
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_AES_GCM_authenticated_decryption_test_case_1),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 test_AES_GCM_authenticated_decryption_test_case_2),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_AES_GCM_authenticated_decryption_test_case_3),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_AES_GCM_authenticated_decryption_test_case_4),
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_AES_GCM_authenticated_decryption_test_case_5),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_AES_GCM_authenticated_decryption_test_case_6),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_AES_GCM_authenticated_decryption_test_case_7),
8037 /** AES GCM Authenticated Encryption 192 bits key */
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_AES_GCM_auth_encryption_test_case_192_1),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_AES_GCM_auth_encryption_test_case_192_2),
8042 TEST_CASE_ST(ut_setup, ut_teardown,
8043 test_AES_GCM_auth_encryption_test_case_192_3),
8044 TEST_CASE_ST(ut_setup, ut_teardown,
8045 test_AES_GCM_auth_encryption_test_case_192_4),
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_AES_GCM_auth_encryption_test_case_192_5),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_AES_GCM_auth_encryption_test_case_192_6),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_AES_GCM_auth_encryption_test_case_192_7),
8053 /** AES GCM Authenticated Decryption 192 bits key */
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_AES_GCM_auth_decryption_test_case_192_1),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_AES_GCM_auth_decryption_test_case_192_2),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_AES_GCM_auth_decryption_test_case_192_3),
8060 TEST_CASE_ST(ut_setup, ut_teardown,
8061 test_AES_GCM_auth_decryption_test_case_192_4),
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_AES_GCM_auth_decryption_test_case_192_5),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_AES_GCM_auth_decryption_test_case_192_6),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_AES_GCM_auth_decryption_test_case_192_7),
8069 /** AES GCM Authenticated Encryption 256 bits key */
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_AES_GCM_auth_encryption_test_case_256_1),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_AES_GCM_auth_encryption_test_case_256_2),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_AES_GCM_auth_encryption_test_case_256_3),
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 test_AES_GCM_auth_encryption_test_case_256_4),
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_AES_GCM_auth_encryption_test_case_256_5),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_AES_GCM_auth_encryption_test_case_256_6),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_AES_GCM_auth_encryption_test_case_256_7),
8085 /** AES GMAC Authentication */
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_AES_GMAC_authentication_test_case_1),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_AES_GMAC_authentication_verify_test_case_1),
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_AES_GMAC_authentication_test_case_2),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_AES_GMAC_authentication_verify_test_case_2),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_AES_GMAC_authentication_test_case_3),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_AES_GMAC_authentication_verify_test_case_3),
8099 /** SNOW 3G encrypt only (UEA2) */
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_snow3g_encryption_test_case_1),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_snow3g_encryption_test_case_2),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_snow3g_encryption_test_case_3),
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_snow3g_encryption_test_case_4),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_snow3g_encryption_test_case_5),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 test_snow3g_encryption_test_case_1_oop),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_snow3g_decryption_test_case_1_oop),
8116 /** SNOW 3G decrypt only (UEA2) */
8117 TEST_CASE_ST(ut_setup, ut_teardown,
8118 test_snow3g_decryption_test_case_1),
8119 TEST_CASE_ST(ut_setup, ut_teardown,
8120 test_snow3g_decryption_test_case_2),
8121 TEST_CASE_ST(ut_setup, ut_teardown,
8122 test_snow3g_decryption_test_case_3),
8123 TEST_CASE_ST(ut_setup, ut_teardown,
8124 test_snow3g_decryption_test_case_4),
8125 TEST_CASE_ST(ut_setup, ut_teardown,
8126 test_snow3g_decryption_test_case_5),
8127 TEST_CASE_ST(ut_setup, ut_teardown,
8128 test_snow3g_hash_generate_test_case_1),
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 test_snow3g_hash_generate_test_case_2),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 test_snow3g_hash_generate_test_case_3),
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 test_snow3g_hash_verify_test_case_1),
8135 TEST_CASE_ST(ut_setup, ut_teardown,
8136 test_snow3g_hash_verify_test_case_2),
8137 TEST_CASE_ST(ut_setup, ut_teardown,
8138 test_snow3g_hash_verify_test_case_3),
8139 TEST_CASE_ST(ut_setup, ut_teardown,
8140 test_snow3g_cipher_auth_test_case_1),
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_snow3g_auth_cipher_test_case_1),
8144 /** ZUC encrypt only (EEA3) */
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_zuc_encryption_test_case_1),
8147 TEST_CASE_ST(ut_setup, ut_teardown,
8148 test_zuc_encryption_test_case_2),
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_zuc_encryption_test_case_3),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_zuc_encryption_test_case_4),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_zuc_encryption_test_case_5),
8156 /** ZUC authenticate (EIA3) */
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_zuc_hash_generate_test_case_6),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_zuc_hash_generate_test_case_7),
8161 TEST_CASE_ST(ut_setup, ut_teardown,
8162 test_zuc_hash_generate_test_case_8),
8164 /** ZUC alg-chain (EEA3/EIA3) */
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_zuc_cipher_auth_test_case_1),
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_zuc_cipher_auth_test_case_2),
8170 /** HMAC_MD5 Authentication */
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_MD5_HMAC_generate_case_1),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_MD5_HMAC_verify_case_1),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_MD5_HMAC_generate_case_2),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_MD5_HMAC_verify_case_2),
8181 TEST_CASE_ST(ut_setup, ut_teardown,
8182 test_null_auth_only_operation),
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_null_cipher_only_operation),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_null_cipher_auth_operation),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_null_auth_cipher_operation),
8190 TEST_CASE_ST(ut_setup, ut_teardown,
8191 test_kasumi_hash_generate_test_case_6),
8194 TEST_CASE_ST(ut_setup, ut_teardown,
8195 test_kasumi_encryption_test_case_1),
8196 TEST_CASE_ST(ut_setup, ut_teardown,
8197 test_kasumi_encryption_test_case_3),
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_kasumi_auth_cipher_test_case_1),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 test_kasumi_cipher_auth_test_case_1),
8203 /** Negative tests */
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8208 TEST_CASE_ST(ut_setup, ut_teardown,
8209 authentication_verify_AES128_GMAC_fail_data_corrupt),
8210 TEST_CASE_ST(ut_setup, ut_teardown,
8211 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8212 TEST_CASE_ST(ut_setup, ut_teardown,
8213 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8214 TEST_CASE_ST(ut_setup, ut_teardown,
8215 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8217 TEST_CASES_END() /**< NULL terminate unit test array */
8221 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8222 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8223 .setup = testsuite_setup,
8224 .teardown = testsuite_teardown,
8225 .unit_test_cases = {
8226 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8227 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8228 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8229 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8231 TEST_CASES_END() /**< NULL terminate unit test array */
8235 static struct unit_test_suite cryptodev_openssl_testsuite = {
8236 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8237 .setup = testsuite_setup,
8238 .teardown = testsuite_teardown,
8239 .unit_test_cases = {
8240 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 test_multi_session_random_usage),
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_AES_chain_openssl_all),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_AES_cipheronly_openssl_all),
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_3DES_chain_openssl_all),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_3DES_cipheronly_openssl_all),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_DES_docsis_openssl_all),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_authonly_openssl_all),
8256 /** AES GCM Authenticated Encryption */
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_AES_GCM_authenticated_encryption_test_case_1),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_AES_GCM_authenticated_encryption_test_case_2),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_AES_GCM_authenticated_encryption_test_case_3),
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_AES_GCM_authenticated_encryption_test_case_4),
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_AES_GCM_authenticated_encryption_test_case_5),
8267 TEST_CASE_ST(ut_setup, ut_teardown,
8268 test_AES_GCM_authenticated_encryption_test_case_6),
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 test_AES_GCM_authenticated_encryption_test_case_7),
8272 /** AES GCM Authenticated Decryption */
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_AES_GCM_authenticated_decryption_test_case_1),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_AES_GCM_authenticated_decryption_test_case_2),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_AES_GCM_authenticated_decryption_test_case_3),
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_AES_GCM_authenticated_decryption_test_case_4),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_AES_GCM_authenticated_decryption_test_case_5),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_AES_GCM_authenticated_decryption_test_case_6),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_AES_GCM_authenticated_decryption_test_case_7),
8289 /** AES GCM Authenticated Encryption 192 bits key */
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_AES_GCM_auth_encryption_test_case_192_1),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_AES_GCM_auth_encryption_test_case_192_2),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_AES_GCM_auth_encryption_test_case_192_3),
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_AES_GCM_auth_encryption_test_case_192_4),
8298 TEST_CASE_ST(ut_setup, ut_teardown,
8299 test_AES_GCM_auth_encryption_test_case_192_5),
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_AES_GCM_auth_encryption_test_case_192_6),
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_AES_GCM_auth_encryption_test_case_192_7),
8305 /** AES GCM Authenticated Decryption 192 bits key */
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_AES_GCM_auth_decryption_test_case_192_1),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_AES_GCM_auth_decryption_test_case_192_2),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_AES_GCM_auth_decryption_test_case_192_3),
8312 TEST_CASE_ST(ut_setup, ut_teardown,
8313 test_AES_GCM_auth_decryption_test_case_192_4),
8314 TEST_CASE_ST(ut_setup, ut_teardown,
8315 test_AES_GCM_auth_decryption_test_case_192_5),
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_AES_GCM_auth_decryption_test_case_192_6),
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_AES_GCM_auth_decryption_test_case_192_7),
8321 /** AES GCM Authenticated Encryption 256 bits key */
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_AES_GCM_auth_encryption_test_case_256_1),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_AES_GCM_auth_encryption_test_case_256_2),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_AES_GCM_auth_encryption_test_case_256_3),
8328 TEST_CASE_ST(ut_setup, ut_teardown,
8329 test_AES_GCM_auth_encryption_test_case_256_4),
8330 TEST_CASE_ST(ut_setup, ut_teardown,
8331 test_AES_GCM_auth_encryption_test_case_256_5),
8332 TEST_CASE_ST(ut_setup, ut_teardown,
8333 test_AES_GCM_auth_encryption_test_case_256_6),
8334 TEST_CASE_ST(ut_setup, ut_teardown,
8335 test_AES_GCM_auth_encryption_test_case_256_7),
8337 /** AES GCM Authenticated Decryption 256 bits key */
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_AES_GCM_auth_decryption_test_case_256_1),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_AES_GCM_auth_decryption_test_case_256_2),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_AES_GCM_auth_decryption_test_case_256_3),
8344 TEST_CASE_ST(ut_setup, ut_teardown,
8345 test_AES_GCM_auth_decryption_test_case_256_4),
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_AES_GCM_auth_decryption_test_case_256_5),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_AES_GCM_auth_decryption_test_case_256_6),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_AES_GCM_auth_decryption_test_case_256_7),
8353 /** AES GMAC Authentication */
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_AES_GMAC_authentication_test_case_1),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_AES_GMAC_authentication_verify_test_case_1),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_AES_GMAC_authentication_test_case_2),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_AES_GMAC_authentication_verify_test_case_2),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_AES_GMAC_authentication_test_case_3),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_AES_GMAC_authentication_verify_test_case_3),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_AES_GMAC_authentication_test_case_4),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_AES_GMAC_authentication_verify_test_case_4),
8371 /** Scatter-Gather */
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8375 /** Negative tests */
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 authentication_verify_AES128_GMAC_fail_data_corrupt),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8389 TEST_CASES_END() /**< NULL terminate unit test array */
8393 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8394 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8395 .setup = testsuite_setup,
8396 .teardown = testsuite_teardown,
8397 .unit_test_cases = {
8398 /** AES GCM Authenticated Encryption */
8399 TEST_CASE_ST(ut_setup, ut_teardown,
8400 test_AES_GCM_authenticated_encryption_test_case_1),
8401 TEST_CASE_ST(ut_setup, ut_teardown,
8402 test_AES_GCM_authenticated_encryption_test_case_2),
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_AES_GCM_authenticated_encryption_test_case_3),
8405 TEST_CASE_ST(ut_setup, ut_teardown,
8406 test_AES_GCM_authenticated_encryption_test_case_4),
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_AES_GCM_authenticated_encryption_test_case_5),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_AES_GCM_authenticated_encryption_test_case_6),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_AES_GCM_authenticated_encryption_test_case_7),
8414 /** AES GCM Authenticated Decryption */
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_AES_GCM_authenticated_decryption_test_case_1),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_AES_GCM_authenticated_decryption_test_case_2),
8419 TEST_CASE_ST(ut_setup, ut_teardown,
8420 test_AES_GCM_authenticated_decryption_test_case_3),
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_AES_GCM_authenticated_decryption_test_case_4),
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_AES_GCM_authenticated_decryption_test_case_5),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_AES_GCM_authenticated_decryption_test_case_6),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_AES_GCM_authenticated_decryption_test_case_7),
8430 /** AES GCM Authenticated Encryption 192 bits key */
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_AES_GCM_auth_encryption_test_case_192_1),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_AES_GCM_auth_encryption_test_case_192_2),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_AES_GCM_auth_encryption_test_case_192_3),
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_AES_GCM_auth_encryption_test_case_192_4),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_AES_GCM_auth_encryption_test_case_192_5),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_AES_GCM_auth_encryption_test_case_192_6),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_AES_GCM_auth_encryption_test_case_192_7),
8446 /** AES GCM Authenticated Decryption 192 bits key */
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_AES_GCM_auth_decryption_test_case_192_1),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_AES_GCM_auth_decryption_test_case_192_2),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_AES_GCM_auth_decryption_test_case_192_3),
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_AES_GCM_auth_decryption_test_case_192_4),
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_AES_GCM_auth_decryption_test_case_192_5),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_AES_GCM_auth_decryption_test_case_192_6),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_AES_GCM_auth_decryption_test_case_192_7),
8462 /** AES GCM Authenticated Encryption 256 bits key */
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_AES_GCM_auth_encryption_test_case_256_1),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_AES_GCM_auth_encryption_test_case_256_2),
8467 TEST_CASE_ST(ut_setup, ut_teardown,
8468 test_AES_GCM_auth_encryption_test_case_256_3),
8469 TEST_CASE_ST(ut_setup, ut_teardown,
8470 test_AES_GCM_auth_encryption_test_case_256_4),
8471 TEST_CASE_ST(ut_setup, ut_teardown,
8472 test_AES_GCM_auth_encryption_test_case_256_5),
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_AES_GCM_auth_encryption_test_case_256_6),
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_AES_GCM_auth_encryption_test_case_256_7),
8478 /** AES GCM Authenticated Decryption 256 bits key */
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_AES_GCM_auth_decryption_test_case_256_1),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_AES_GCM_auth_decryption_test_case_256_2),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_AES_GCM_auth_decryption_test_case_256_3),
8485 TEST_CASE_ST(ut_setup, ut_teardown,
8486 test_AES_GCM_auth_decryption_test_case_256_4),
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_AES_GCM_auth_decryption_test_case_256_5),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_AES_GCM_auth_decryption_test_case_256_6),
8491 TEST_CASE_ST(ut_setup, ut_teardown,
8492 test_AES_GCM_auth_decryption_test_case_256_7),
8494 /** AES GCM Authenticated Encryption big aad size */
8495 TEST_CASE_ST(ut_setup, ut_teardown,
8496 test_AES_GCM_auth_encryption_test_case_aad_1),
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_AES_GCM_auth_encryption_test_case_aad_2),
8500 /** AES GCM Authenticated Decryption big aad size */
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 test_AES_GCM_auth_decryption_test_case_aad_1),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 test_AES_GCM_auth_decryption_test_case_aad_2),
8506 /** AES GMAC Authentication */
8507 TEST_CASE_ST(ut_setup, ut_teardown,
8508 test_AES_GMAC_authentication_test_case_1),
8509 TEST_CASE_ST(ut_setup, ut_teardown,
8510 test_AES_GMAC_authentication_verify_test_case_1),
8511 TEST_CASE_ST(ut_setup, ut_teardown,
8512 test_AES_GMAC_authentication_test_case_3),
8513 TEST_CASE_ST(ut_setup, ut_teardown,
8514 test_AES_GMAC_authentication_verify_test_case_3),
8515 TEST_CASE_ST(ut_setup, ut_teardown,
8516 test_AES_GMAC_authentication_test_case_4),
8517 TEST_CASE_ST(ut_setup, ut_teardown,
8518 test_AES_GMAC_authentication_verify_test_case_4),
8520 /** Negative tests */
8521 TEST_CASE_ST(ut_setup, ut_teardown,
8522 authentication_verify_AES128_GMAC_fail_data_corrupt),
8523 TEST_CASE_ST(ut_setup, ut_teardown,
8524 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8526 /** Out of place tests */
8527 TEST_CASE_ST(ut_setup, ut_teardown,
8528 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8529 TEST_CASE_ST(ut_setup, ut_teardown,
8530 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8532 /** Session-less tests */
8533 TEST_CASE_ST(ut_setup, ut_teardown,
8534 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8535 TEST_CASE_ST(ut_setup, ut_teardown,
8536 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8538 /** Scatter-Gather */
8539 TEST_CASE_ST(ut_setup, ut_teardown,
8540 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8542 TEST_CASES_END() /**< NULL terminate unit test array */
8546 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8547 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8548 .setup = testsuite_setup,
8549 .teardown = testsuite_teardown,
8550 .unit_test_cases = {
8551 /** KASUMI encrypt only (UEA1) */
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_kasumi_encryption_test_case_1),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_kasumi_encryption_test_case_1_sgl),
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_kasumi_encryption_test_case_2),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_kasumi_encryption_test_case_3),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_kasumi_encryption_test_case_4),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_kasumi_encryption_test_case_5),
8564 /** KASUMI decrypt only (UEA1) */
8565 TEST_CASE_ST(ut_setup, ut_teardown,
8566 test_kasumi_decryption_test_case_1),
8567 TEST_CASE_ST(ut_setup, ut_teardown,
8568 test_kasumi_decryption_test_case_2),
8569 TEST_CASE_ST(ut_setup, ut_teardown,
8570 test_kasumi_decryption_test_case_3),
8571 TEST_CASE_ST(ut_setup, ut_teardown,
8572 test_kasumi_decryption_test_case_4),
8573 TEST_CASE_ST(ut_setup, ut_teardown,
8574 test_kasumi_decryption_test_case_5),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_kasumi_encryption_test_case_1_oop),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_kasumi_encryption_test_case_1_oop_sgl),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_kasumi_decryption_test_case_1_oop),
8585 /** KASUMI hash only (UIA1) */
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_kasumi_hash_generate_test_case_1),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_kasumi_hash_generate_test_case_2),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_kasumi_hash_generate_test_case_3),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_kasumi_hash_generate_test_case_4),
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_kasumi_hash_generate_test_case_5),
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_kasumi_hash_generate_test_case_6),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_kasumi_hash_verify_test_case_1),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_kasumi_hash_verify_test_case_2),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_kasumi_hash_verify_test_case_3),
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_kasumi_hash_verify_test_case_4),
8606 TEST_CASE_ST(ut_setup, ut_teardown,
8607 test_kasumi_hash_verify_test_case_5),
8608 TEST_CASE_ST(ut_setup, ut_teardown,
8609 test_kasumi_auth_cipher_test_case_1),
8610 TEST_CASE_ST(ut_setup, ut_teardown,
8611 test_kasumi_cipher_auth_test_case_1),
8612 TEST_CASES_END() /**< NULL terminate unit test array */
8615 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8616 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8617 .setup = testsuite_setup,
8618 .teardown = testsuite_teardown,
8619 .unit_test_cases = {
8620 /** SNOW 3G encrypt only (UEA2) */
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_snow3g_encryption_test_case_1),
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_snow3g_encryption_test_case_2),
8625 TEST_CASE_ST(ut_setup, ut_teardown,
8626 test_snow3g_encryption_test_case_3),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_snow3g_encryption_test_case_4),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_snow3g_encryption_test_case_5),
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_snow3g_encryption_test_case_1_oop),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_snow3g_encryption_test_case_1_oop_sgl),
8636 TEST_CASE_ST(ut_setup, ut_teardown,
8637 test_snow3g_decryption_test_case_1_oop),
8639 TEST_CASE_ST(ut_setup, ut_teardown,
8640 test_snow3g_encryption_test_case_1_offset_oop),
8642 /** SNOW 3G decrypt only (UEA2) */
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_snow3g_decryption_test_case_1),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_snow3g_decryption_test_case_2),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_snow3g_decryption_test_case_3),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_snow3g_decryption_test_case_4),
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_snow3g_decryption_test_case_5),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_snow3g_hash_generate_test_case_1),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_snow3g_hash_generate_test_case_2),
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_snow3g_hash_generate_test_case_3),
8659 /* Tests with buffers which length is not byte-aligned */
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_snow3g_hash_generate_test_case_4),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_snow3g_hash_generate_test_case_5),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_snow3g_hash_generate_test_case_6),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_snow3g_hash_verify_test_case_1),
8668 TEST_CASE_ST(ut_setup, ut_teardown,
8669 test_snow3g_hash_verify_test_case_2),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_snow3g_hash_verify_test_case_3),
8672 /* Tests with buffers which length is not byte-aligned */
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_snow3g_hash_verify_test_case_4),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_snow3g_hash_verify_test_case_5),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_snow3g_hash_verify_test_case_6),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_snow3g_cipher_auth_test_case_1),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_snow3g_auth_cipher_test_case_1),
8684 TEST_CASES_END() /**< NULL terminate unit test array */
8688 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8689 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8690 .setup = testsuite_setup,
8691 .teardown = testsuite_teardown,
8692 .unit_test_cases = {
8693 /** ZUC encrypt only (EEA3) */
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_zuc_encryption_test_case_1),
8696 TEST_CASE_ST(ut_setup, ut_teardown,
8697 test_zuc_encryption_test_case_2),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_zuc_encryption_test_case_3),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_zuc_encryption_test_case_4),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_zuc_encryption_test_case_5),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_zuc_hash_generate_test_case_1),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_zuc_hash_generate_test_case_2),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_zuc_hash_generate_test_case_3),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_zuc_hash_generate_test_case_4),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_zuc_hash_generate_test_case_5),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_zuc_encryption_test_case_6_sgl),
8716 TEST_CASES_END() /**< NULL terminate unit test array */
8720 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8721 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8722 .setup = testsuite_setup,
8723 .teardown = testsuite_teardown,
8724 .unit_test_cases = {
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_device_configure_invalid_dev_id),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_multi_session),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_AES_chain_dpaa2_sec_all),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_3DES_chain_dpaa2_sec_all),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_cipheronly_dpaa2_sec_all),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_3DES_cipheronly_dpaa2_sec_all),
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_authonly_dpaa2_sec_all),
8741 /** AES GCM Authenticated Encryption */
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_AES_GCM_authenticated_encryption_test_case_1),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_GCM_authenticated_encryption_test_case_2),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_AES_GCM_authenticated_encryption_test_case_3),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_AES_GCM_authenticated_encryption_test_case_4),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GCM_authenticated_encryption_test_case_5),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_GCM_authenticated_encryption_test_case_6),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_GCM_authenticated_encryption_test_case_7),
8757 /** AES GCM Authenticated Decryption */
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_AES_GCM_authenticated_decryption_test_case_1),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_GCM_authenticated_decryption_test_case_2),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_GCM_authenticated_decryption_test_case_3),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_GCM_authenticated_decryption_test_case_4),
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_authenticated_decryption_test_case_5),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_authenticated_decryption_test_case_6),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_authenticated_decryption_test_case_7),
8773 /** AES GCM Authenticated Encryption 192 bits key */
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_auth_encryption_test_case_192_1),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_auth_encryption_test_case_192_2),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_auth_encryption_test_case_192_3),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_auth_encryption_test_case_192_4),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_auth_encryption_test_case_192_5),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_auth_encryption_test_case_192_6),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_auth_encryption_test_case_192_7),
8789 /** AES GCM Authenticated Decryption 192 bits key */
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_auth_decryption_test_case_192_1),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_auth_decryption_test_case_192_2),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_auth_decryption_test_case_192_3),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_auth_decryption_test_case_192_4),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_auth_decryption_test_case_192_5),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_auth_decryption_test_case_192_6),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_auth_decryption_test_case_192_7),
8805 /** AES GCM Authenticated Encryption 256 bits key */
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_auth_encryption_test_case_256_1),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_auth_encryption_test_case_256_2),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_256_3),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_auth_encryption_test_case_256_4),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_encryption_test_case_256_5),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_encryption_test_case_256_6),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_encryption_test_case_256_7),
8821 /** AES GCM Authenticated Decryption 256 bits key */
8822 TEST_CASE_ST(ut_setup, ut_teardown,
8823 test_AES_GCM_auth_decryption_test_case_256_1),
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GCM_auth_decryption_test_case_256_2),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_auth_decryption_test_case_256_3),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GCM_auth_decryption_test_case_256_4),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GCM_auth_decryption_test_case_256_5),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GCM_auth_decryption_test_case_256_6),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GCM_auth_decryption_test_case_256_7),
8837 TEST_CASES_END() /**< NULL terminate unit test array */
8841 static struct unit_test_suite cryptodev_null_testsuite = {
8842 .suite_name = "Crypto Device NULL Unit Test Suite",
8843 .setup = testsuite_setup,
8844 .teardown = testsuite_teardown,
8845 .unit_test_cases = {
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_null_auth_only_operation),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_null_cipher_only_operation),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_null_cipher_auth_operation),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_null_auth_cipher_operation),
8854 TEST_CASE_ST(ut_setup, ut_teardown,
8855 test_null_invalid_operation),
8856 TEST_CASE_ST(ut_setup, ut_teardown,
8857 test_null_burst_operation),
8859 TEST_CASES_END() /**< NULL terminate unit test array */
8863 static struct unit_test_suite cryptodev_armv8_testsuite = {
8864 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8865 .setup = testsuite_setup,
8866 .teardown = testsuite_teardown,
8867 .unit_test_cases = {
8868 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8870 /** Negative tests */
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8876 TEST_CASES_END() /**< NULL terminate unit test array */
8881 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8883 gbl_driver_id = rte_cryptodev_driver_id_get(
8884 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
8886 if (gbl_driver_id == -1) {
8887 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
8888 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
8889 "in config file to run this testsuite.\n");
8893 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8897 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8899 gbl_driver_id = rte_cryptodev_driver_id_get(
8900 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8902 if (gbl_driver_id == -1) {
8903 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8904 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8905 "in config file to run this testsuite.\n");
8909 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8913 test_cryptodev_openssl(void)
8915 gbl_driver_id = rte_cryptodev_driver_id_get(
8916 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
8918 if (gbl_driver_id == -1) {
8919 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8920 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8921 "in config file to run this testsuite.\n");
8925 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8929 test_cryptodev_aesni_gcm(void)
8931 gbl_driver_id = rte_cryptodev_driver_id_get(
8932 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
8934 if (gbl_driver_id == -1) {
8935 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
8936 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
8937 "in config file to run this testsuite.\n");
8941 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8945 test_cryptodev_null(void)
8947 gbl_driver_id = rte_cryptodev_driver_id_get(
8948 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
8950 if (gbl_driver_id == -1) {
8951 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
8952 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
8953 "in config file to run this testsuite.\n");
8957 return unit_test_suite_runner(&cryptodev_null_testsuite);
8961 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8963 gbl_driver_id = rte_cryptodev_driver_id_get(
8964 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
8966 if (gbl_driver_id == -1) {
8967 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
8968 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
8969 "in config file to run this testsuite.\n");
8973 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8977 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8979 gbl_driver_id = rte_cryptodev_driver_id_get(
8980 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
8982 if (gbl_driver_id == -1) {
8983 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8984 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
8985 "in config file to run this testsuite.\n");
8989 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8993 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8995 gbl_driver_id = rte_cryptodev_driver_id_get(
8996 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
8998 if (gbl_driver_id == -1) {
8999 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9000 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9001 "in config file to run this testsuite.\n");
9005 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9009 test_cryptodev_armv8(void)
9011 gbl_driver_id = rte_cryptodev_driver_id_get(
9012 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9014 if (gbl_driver_id == -1) {
9015 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9016 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9017 "in config file to run this testsuite.\n");
9021 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9024 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9027 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9029 gbl_driver_id = rte_cryptodev_driver_id_get(
9030 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9032 if (gbl_driver_id == -1) {
9033 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9034 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9035 "in config file to run this testsuite.\n");
9039 if (rte_cryptodev_driver_id_get(
9040 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9041 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9042 " enabled in config file to run this testsuite.\n");
9045 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9048 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9053 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9055 gbl_driver_id = rte_cryptodev_driver_id_get(
9056 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9058 if (gbl_driver_id == -1) {
9059 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9060 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9061 "in config file to run this testsuite.\n");
9065 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9068 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9069 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9070 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9071 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9072 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9073 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9074 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9075 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9076 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9077 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);