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>
39 #include <rte_bus_vdev.h>
41 #include <rte_crypto.h>
42 #include <rte_cryptodev.h>
43 #include <rte_cryptodev_pmd.h>
45 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
46 #include <rte_cryptodev_scheduler.h>
47 #include <rte_cryptodev_scheduler_operations.h>
51 #include "test_cryptodev.h"
53 #include "test_cryptodev_blockcipher.h"
54 #include "test_cryptodev_aes_test_vectors.h"
55 #include "test_cryptodev_des_test_vectors.h"
56 #include "test_cryptodev_hash_test_vectors.h"
57 #include "test_cryptodev_kasumi_test_vectors.h"
58 #include "test_cryptodev_kasumi_hash_test_vectors.h"
59 #include "test_cryptodev_snow3g_test_vectors.h"
60 #include "test_cryptodev_snow3g_hash_test_vectors.h"
61 #include "test_cryptodev_zuc_test_vectors.h"
62 #include "test_cryptodev_aead_test_vectors.h"
63 #include "test_cryptodev_hmac_test_vectors.h"
65 static int gbl_driver_id;
67 struct crypto_testsuite_params {
68 struct rte_mempool *mbuf_pool;
69 struct rte_mempool *large_mbuf_pool;
70 struct rte_mempool *op_mpool;
71 struct rte_mempool *session_mpool;
72 struct rte_cryptodev_config conf;
73 struct rte_cryptodev_qp_conf qp_conf;
75 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
76 uint8_t valid_dev_count;
79 struct crypto_unittest_params {
80 struct rte_crypto_sym_xform cipher_xform;
81 struct rte_crypto_sym_xform auth_xform;
82 struct rte_crypto_sym_xform aead_xform;
84 struct rte_cryptodev_sym_session *sess;
86 struct rte_crypto_op *op;
88 struct rte_mbuf *obuf, *ibuf;
93 #define ALIGN_POW2_ROUNDUP(num, align) \
94 (((num) + (align) - 1) & ~((align) - 1))
97 * Forward declarations.
100 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
101 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
105 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
106 struct crypto_unittest_params *ut_params,
107 struct crypto_testsuite_params *ts_param,
108 const uint8_t *cipher,
109 const uint8_t *digest,
112 static struct rte_mbuf *
113 setup_test_string(struct rte_mempool *mpool,
114 const char *string, size_t len, uint8_t blocksize)
116 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
117 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
119 memset(m->buf_addr, 0, m->buf_len);
121 char *dst = rte_pktmbuf_append(m, t_len);
128 rte_memcpy(dst, string, t_len);
130 memset(dst, 0, t_len);
136 /* Get number of bytes in X bits (rounding up) */
138 ceil_byte_length(uint32_t num_bits)
141 return ((num_bits >> 3) + 1);
143 return (num_bits >> 3);
146 static struct rte_crypto_op *
147 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
149 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
150 printf("Error sending packet for encryption");
156 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
162 static struct crypto_testsuite_params testsuite_params = { NULL };
163 static struct crypto_unittest_params unittest_params;
166 testsuite_setup(void)
168 struct crypto_testsuite_params *ts_params = &testsuite_params;
169 struct rte_cryptodev_info info;
170 uint32_t i = 0, nb_devs, dev_id;
174 memset(ts_params, 0, sizeof(*ts_params));
176 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
177 if (ts_params->mbuf_pool == NULL) {
178 /* Not already created so create */
179 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
181 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
183 if (ts_params->mbuf_pool == NULL) {
184 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
189 ts_params->large_mbuf_pool = rte_mempool_lookup(
190 "CRYPTO_LARGE_MBUFPOOL");
191 if (ts_params->large_mbuf_pool == NULL) {
192 /* Not already created so create */
193 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
194 "CRYPTO_LARGE_MBUFPOOL",
197 if (ts_params->large_mbuf_pool == NULL) {
199 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
204 ts_params->op_mpool = rte_crypto_op_pool_create(
205 "MBUF_CRYPTO_SYM_OP_POOL",
206 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
207 NUM_MBUFS, MBUF_CACHE_SIZE,
209 sizeof(struct rte_crypto_sym_xform) +
212 if (ts_params->op_mpool == NULL) {
213 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
217 /* Create an AESNI MB device if required */
218 if (gbl_driver_id == rte_cryptodev_driver_id_get(
219 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
220 nb_devs = rte_cryptodev_device_count_by_driver(
221 rte_cryptodev_driver_id_get(
222 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_driver_id == rte_cryptodev_driver_id_get(
236 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
237 nb_devs = rte_cryptodev_device_count_by_driver(
238 rte_cryptodev_driver_id_get(
239 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
241 TEST_ASSERT_SUCCESS(rte_vdev_init(
242 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
243 "Failed to create instance of"
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
249 /* Create a SNOW 3G device if required */
250 if (gbl_driver_id == rte_cryptodev_driver_id_get(
251 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
252 nb_devs = rte_cryptodev_device_count_by_driver(
253 rte_cryptodev_driver_id_get(
254 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
256 TEST_ASSERT_SUCCESS(rte_vdev_init(
257 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
258 "Failed to create instance of"
260 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
264 /* Create a KASUMI device if required */
265 if (gbl_driver_id == rte_cryptodev_driver_id_get(
266 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
267 nb_devs = rte_cryptodev_device_count_by_driver(
268 rte_cryptodev_driver_id_get(
269 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
271 TEST_ASSERT_SUCCESS(rte_vdev_init(
272 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
273 "Failed to create instance of"
275 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
279 /* Create a ZUC device if required */
280 if (gbl_driver_id == rte_cryptodev_driver_id_get(
281 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
282 nb_devs = rte_cryptodev_device_count_by_driver(
283 rte_cryptodev_driver_id_get(
284 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
286 TEST_ASSERT_SUCCESS(rte_vdev_init(
287 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
288 "Failed to create instance of"
290 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
294 /* Create a NULL device if required */
295 if (gbl_driver_id == rte_cryptodev_driver_id_get(
296 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
297 nb_devs = rte_cryptodev_device_count_by_driver(
298 rte_cryptodev_driver_id_get(
299 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
302 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
304 TEST_ASSERT(ret == 0,
305 "Failed to create instance of"
307 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
311 /* Create an OPENSSL device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
319 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
322 TEST_ASSERT(ret == 0, "Failed to create "
323 "instance of pmd : %s",
324 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
328 /* Create a ARMv8 device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
336 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
339 TEST_ASSERT(ret == 0, "Failed to create "
340 "instance of pmd : %s",
341 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
345 /* Create a MRVL device if required */
346 if (gbl_driver_id == rte_cryptodev_driver_id_get(
347 RTE_STR(CRYPTODEV_MRVL_PMD))) {
348 #ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO
349 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be"
350 " enabled in config file to run this testsuite.\n");
353 nb_devs = rte_cryptodev_device_count_by_driver(
354 rte_cryptodev_driver_id_get(
355 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)));
358 RTE_STR(CRYPTODEV_NAME_MRVL_PMD),
361 TEST_ASSERT(ret == 0, "Failed to create "
362 "instance of pmd : %s",
363 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
367 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
368 if (gbl_driver_id == rte_cryptodev_driver_id_get(
369 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
371 nb_devs = rte_cryptodev_device_count_by_driver(
372 rte_cryptodev_driver_id_get(
373 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
376 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
379 TEST_ASSERT(ret == 0,
380 "Failed to create instance %u of"
382 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
385 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
387 nb_devs = rte_cryptodev_count();
389 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
393 /* Create list of valid crypto devs */
394 for (i = 0; i < nb_devs; i++) {
395 rte_cryptodev_info_get(i, &info);
396 if (info.driver_id == gbl_driver_id)
397 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
400 if (ts_params->valid_dev_count < 1)
403 /* Set up all the qps on the first of the valid devices found */
405 dev_id = ts_params->valid_devs[0];
407 rte_cryptodev_info_get(dev_id, &info);
409 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
410 ts_params->conf.socket_id = SOCKET_ID_ANY;
412 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
415 * Create mempool with maximum number of sessions * 2,
416 * to include the session headers
418 ts_params->session_mpool = rte_mempool_create(
420 info.sym.max_nb_sessions * 2,
422 0, 0, NULL, NULL, NULL,
426 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
427 "session mempool allocation failed");
429 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
431 "Failed to configure cryptodev %u with %u qps",
432 dev_id, ts_params->conf.nb_queue_pairs);
434 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
436 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
437 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
438 dev_id, qp_id, &ts_params->qp_conf,
439 rte_cryptodev_socket_id(dev_id),
440 ts_params->session_mpool),
441 "Failed to setup queue pair %u on cryptodev %u",
449 testsuite_teardown(void)
451 struct crypto_testsuite_params *ts_params = &testsuite_params;
453 if (ts_params->mbuf_pool != NULL) {
454 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
455 rte_mempool_avail_count(ts_params->mbuf_pool));
458 if (ts_params->op_mpool != NULL) {
459 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
460 rte_mempool_avail_count(ts_params->op_mpool));
463 /* Free session mempools */
464 if (ts_params->session_mpool != NULL) {
465 rte_mempool_free(ts_params->session_mpool);
466 ts_params->session_mpool = NULL;
473 struct crypto_testsuite_params *ts_params = &testsuite_params;
474 struct crypto_unittest_params *ut_params = &unittest_params;
478 /* Clear unit test parameters before running test */
479 memset(ut_params, 0, sizeof(*ut_params));
481 /* Reconfigure device to default parameters */
482 ts_params->conf.socket_id = SOCKET_ID_ANY;
484 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
486 "Failed to configure cryptodev %u",
487 ts_params->valid_devs[0]);
489 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
490 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
491 ts_params->valid_devs[0], qp_id,
493 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
494 ts_params->session_mpool),
495 "Failed to setup queue pair %u on cryptodev %u",
496 qp_id, ts_params->valid_devs[0]);
500 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
502 /* Start the device */
503 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
504 "Failed to start cryptodev %u",
505 ts_params->valid_devs[0]);
513 struct crypto_testsuite_params *ts_params = &testsuite_params;
514 struct crypto_unittest_params *ut_params = &unittest_params;
515 struct rte_cryptodev_stats stats;
517 /* free crypto session structure */
518 if (ut_params->sess) {
519 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
521 rte_cryptodev_sym_session_free(ut_params->sess);
522 ut_params->sess = NULL;
525 /* free crypto operation structure */
527 rte_crypto_op_free(ut_params->op);
530 * free mbuf - both obuf and ibuf are usually the same,
531 * so check if they point at the same address is necessary,
532 * to avoid freeing the mbuf twice.
534 if (ut_params->obuf) {
535 rte_pktmbuf_free(ut_params->obuf);
536 if (ut_params->ibuf == ut_params->obuf)
540 if (ut_params->ibuf) {
541 rte_pktmbuf_free(ut_params->ibuf);
545 if (ts_params->mbuf_pool != NULL)
546 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
547 rte_mempool_avail_count(ts_params->mbuf_pool));
549 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
551 /* Stop the device */
552 rte_cryptodev_stop(ts_params->valid_devs[0]);
556 test_device_configure_invalid_dev_id(void)
558 struct crypto_testsuite_params *ts_params = &testsuite_params;
559 uint16_t dev_id, num_devs = 0;
561 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
562 "Need at least %d devices for test", 1);
564 /* valid dev_id values */
565 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
567 /* Stop the device in case it's started so it can be configured */
568 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
570 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
571 "Failed test for rte_cryptodev_configure: "
572 "invalid dev_num %u", dev_id);
574 /* invalid dev_id values */
577 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
578 "Failed test for rte_cryptodev_configure: "
579 "invalid dev_num %u", dev_id);
583 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
584 "Failed test for rte_cryptodev_configure:"
585 "invalid dev_num %u", dev_id);
591 test_device_configure_invalid_queue_pair_ids(void)
593 struct crypto_testsuite_params *ts_params = &testsuite_params;
594 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
596 /* Stop the device in case it's started so it can be configured */
597 rte_cryptodev_stop(ts_params->valid_devs[0]);
599 /* valid - one queue pairs */
600 ts_params->conf.nb_queue_pairs = 1;
602 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
604 "Failed to configure cryptodev: dev_id %u, qp_id %u",
605 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
608 /* valid - max value queue pairs */
609 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
611 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
613 "Failed to configure cryptodev: dev_id %u, qp_id %u",
614 ts_params->valid_devs[0],
615 ts_params->conf.nb_queue_pairs);
618 /* invalid - zero queue pairs */
619 ts_params->conf.nb_queue_pairs = 0;
621 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
623 "Failed test for rte_cryptodev_configure, dev_id %u,"
625 ts_params->valid_devs[0],
626 ts_params->conf.nb_queue_pairs);
629 /* invalid - max value supported by field queue pairs */
630 ts_params->conf.nb_queue_pairs = UINT16_MAX;
632 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
634 "Failed test for rte_cryptodev_configure, dev_id %u,"
636 ts_params->valid_devs[0],
637 ts_params->conf.nb_queue_pairs);
640 /* invalid - max value + 1 queue pairs */
641 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
643 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
645 "Failed test for rte_cryptodev_configure, dev_id %u,"
647 ts_params->valid_devs[0],
648 ts_params->conf.nb_queue_pairs);
650 /* revert to original testsuite value */
651 ts_params->conf.nb_queue_pairs = orig_nb_qps;
657 test_queue_pair_descriptor_setup(void)
659 struct crypto_testsuite_params *ts_params = &testsuite_params;
660 struct rte_cryptodev_info dev_info;
661 struct rte_cryptodev_qp_conf qp_conf = {
662 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
667 /* Stop the device in case it's started so it can be configured */
668 rte_cryptodev_stop(ts_params->valid_devs[0]);
671 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
673 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
675 "Failed to configure cryptodev %u",
676 ts_params->valid_devs[0]);
679 * Test various ring sizes on this device. memzones can't be
680 * freed so are re-used if ring is released and re-created.
682 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
684 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
685 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
686 ts_params->valid_devs[0], qp_id, &qp_conf,
687 rte_cryptodev_socket_id(
688 ts_params->valid_devs[0]),
689 ts_params->session_mpool),
691 "rte_cryptodev_queue_pair_setup: num_inflights "
692 "%u on qp %u on cryptodev %u",
693 qp_conf.nb_descriptors, qp_id,
694 ts_params->valid_devs[0]);
697 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
699 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
700 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
701 ts_params->valid_devs[0], qp_id, &qp_conf,
702 rte_cryptodev_socket_id(
703 ts_params->valid_devs[0]),
704 ts_params->session_mpool),
706 " rte_cryptodev_queue_pair_setup: num_inflights"
707 " %u on qp %u on cryptodev %u",
708 qp_conf.nb_descriptors, qp_id,
709 ts_params->valid_devs[0]);
712 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
714 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
715 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
716 ts_params->valid_devs[0], qp_id, &qp_conf,
717 rte_cryptodev_socket_id(
718 ts_params->valid_devs[0]),
719 ts_params->session_mpool),
721 "rte_cryptodev_queue_pair_setup: num_inflights"
722 " %u on qp %u on cryptodev %u",
723 qp_conf.nb_descriptors, qp_id,
724 ts_params->valid_devs[0]);
727 /* invalid number of descriptors - max supported + 2 */
728 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
730 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
731 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
732 ts_params->valid_devs[0], qp_id, &qp_conf,
733 rte_cryptodev_socket_id(
734 ts_params->valid_devs[0]),
735 ts_params->session_mpool),
736 "Unexpectedly passed test for "
737 "rte_cryptodev_queue_pair_setup:"
738 "num_inflights %u on qp %u on cryptodev %u",
739 qp_conf.nb_descriptors, qp_id,
740 ts_params->valid_devs[0]);
743 /* invalid number of descriptors - max value of parameter */
744 qp_conf.nb_descriptors = UINT32_MAX-1;
746 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
747 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
748 ts_params->valid_devs[0], qp_id, &qp_conf,
749 rte_cryptodev_socket_id(
750 ts_params->valid_devs[0]),
751 ts_params->session_mpool),
752 "Unexpectedly passed test for "
753 "rte_cryptodev_queue_pair_setup:"
754 "num_inflights %u on qp %u on cryptodev %u",
755 qp_conf.nb_descriptors, qp_id,
756 ts_params->valid_devs[0]);
759 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
761 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
762 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
763 ts_params->valid_devs[0], qp_id, &qp_conf,
764 rte_cryptodev_socket_id(
765 ts_params->valid_devs[0]),
766 ts_params->session_mpool),
768 " rte_cryptodev_queue_pair_setup:"
769 "num_inflights %u on qp %u on cryptodev %u",
770 qp_conf.nb_descriptors, qp_id,
771 ts_params->valid_devs[0]);
774 /* invalid number of descriptors - max supported + 1 */
775 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
777 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
778 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
779 ts_params->valid_devs[0], qp_id, &qp_conf,
780 rte_cryptodev_socket_id(
781 ts_params->valid_devs[0]),
782 ts_params->session_mpool),
783 "Unexpectedly passed test for "
784 "rte_cryptodev_queue_pair_setup:"
785 "num_inflights %u on qp %u on cryptodev %u",
786 qp_conf.nb_descriptors, qp_id,
787 ts_params->valid_devs[0]);
790 /* test invalid queue pair id */
791 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
793 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
795 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
796 ts_params->valid_devs[0],
798 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
799 ts_params->session_mpool),
800 "Failed test for rte_cryptodev_queue_pair_setup:"
801 "invalid qp %u on cryptodev %u",
802 qp_id, ts_params->valid_devs[0]);
804 qp_id = 0xffff; /*invalid*/
806 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
807 ts_params->valid_devs[0],
809 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
810 ts_params->session_mpool),
811 "Failed test for rte_cryptodev_queue_pair_setup:"
812 "invalid qp %u on cryptodev %u",
813 qp_id, ts_params->valid_devs[0]);
818 /* ***** Plaintext data for tests ***** */
820 const char catch_22_quote_1[] =
821 "There was only one catch and that was Catch-22, which "
822 "specified that a concern for one's safety in the face of "
823 "dangers that were real and immediate was the process of a "
824 "rational mind. Orr was crazy and could be grounded. All he "
825 "had to do was ask; and as soon as he did, he would no longer "
826 "be crazy and would have to fly more missions. Orr would be "
827 "crazy to fly more missions and sane if he didn't, but if he "
828 "was sane he had to fly them. If he flew them he was crazy "
829 "and didn't have to; but if he didn't want to he was sane and "
830 "had to. Yossarian was moved very deeply by the absolute "
831 "simplicity of this clause of Catch-22 and let out a "
832 "respectful whistle. \"That's some catch, that Catch-22\", he "
833 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
835 const char catch_22_quote[] =
836 "What a lousy earth! He wondered how many people were "
837 "destitute that same night even in his own prosperous country, "
838 "how many homes were shanties, how many husbands were drunk "
839 "and wives socked, and how many children were bullied, abused, "
840 "or abandoned. How many families hungered for food they could "
841 "not afford to buy? How many hearts were broken? How many "
842 "suicides would take place that same night, how many people "
843 "would go insane? How many cockroaches and landlords would "
844 "triumph? How many winners were losers, successes failures, "
845 "and rich men poor men? How many wise guys were stupid? How "
846 "many happy endings were unhappy endings? How many honest men "
847 "were liars, brave men cowards, loyal men traitors, how many "
848 "sainted men were corrupt, how many people in positions of "
849 "trust had sold their souls to bodyguards, how many had never "
850 "had souls? How many straight-and-narrow paths were crooked "
851 "paths? How many best families were worst families and how "
852 "many good people were bad people? When you added them all up "
853 "and then subtracted, you might be left with only the children, "
854 "and perhaps with Albert Einstein and an old violinist or "
855 "sculptor somewhere.";
857 #define QUOTE_480_BYTES (480)
858 #define QUOTE_512_BYTES (512)
859 #define QUOTE_768_BYTES (768)
860 #define QUOTE_1024_BYTES (1024)
864 /* ***** SHA1 Hash Tests ***** */
866 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
868 static uint8_t hmac_sha1_key[] = {
869 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
870 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
871 0xDE, 0xF4, 0xDE, 0xAD };
873 /* ***** SHA224 Hash Tests ***** */
875 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
878 /* ***** AES-CBC Cipher Tests ***** */
880 #define CIPHER_KEY_LENGTH_AES_CBC (16)
881 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
883 static uint8_t aes_cbc_key[] = {
884 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
885 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
887 static uint8_t aes_cbc_iv[] = {
888 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
889 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
892 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
894 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
895 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
896 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
897 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
898 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
899 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
900 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
901 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
902 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
903 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
904 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
905 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
906 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
907 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
908 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
909 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
910 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
911 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
912 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
913 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
914 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
915 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
916 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
917 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
918 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
919 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
920 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
921 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
922 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
923 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
924 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
925 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
926 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
927 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
928 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
929 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
930 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
931 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
932 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
933 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
934 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
935 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
936 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
937 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
938 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
939 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
940 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
941 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
942 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
943 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
944 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
945 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
946 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
947 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
948 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
949 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
950 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
951 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
952 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
953 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
954 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
955 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
956 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
957 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
958 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
961 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
962 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
963 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
964 0x18, 0x8c, 0x1d, 0x32
968 /* Multisession Vector context Test */
970 static uint8_t ms_aes_cbc_key0[] = {
971 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
972 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
975 static uint8_t ms_aes_cbc_iv0[] = {
976 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
977 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
980 static const uint8_t ms_aes_cbc_cipher0[] = {
981 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
982 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
983 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
984 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
985 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
986 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
987 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
988 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
989 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
990 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
991 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
992 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
993 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
994 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
995 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
996 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
997 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
998 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
999 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1000 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1001 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1002 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1003 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1004 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1005 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1006 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1007 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1008 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1009 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1010 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1011 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1012 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1013 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1014 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1015 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1016 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1017 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1018 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1019 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1020 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1021 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1022 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1023 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1024 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1025 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1026 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1027 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1028 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1029 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1030 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1031 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1032 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1033 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1034 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1035 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1036 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1037 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1038 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1039 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1040 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1041 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1042 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1043 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1044 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1048 static uint8_t ms_hmac_key0[] = {
1049 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1050 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1051 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1052 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1053 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1054 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1055 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1056 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1059 static const uint8_t ms_hmac_digest0[] = {
1060 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1061 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1062 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1063 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1064 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1065 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1066 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1067 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1071 /* Begin session 1 */
1073 static uint8_t ms_aes_cbc_key1[] = {
1074 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1075 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1078 static uint8_t ms_aes_cbc_iv1[] = {
1079 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1080 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1083 static const uint8_t ms_aes_cbc_cipher1[] = {
1084 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1085 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1086 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1087 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1088 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1089 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1090 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1091 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1092 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1093 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1094 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1095 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1096 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1097 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1098 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1099 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1100 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1101 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1102 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1103 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1104 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1105 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1106 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1107 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1108 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1109 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1110 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1111 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1112 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1113 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1114 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1115 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1116 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1117 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1118 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1119 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1120 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1121 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1122 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1123 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1124 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1125 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1126 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1127 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1128 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1129 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1130 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1131 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1132 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1133 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1134 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1135 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1136 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1137 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1138 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1139 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1140 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1141 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1142 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1143 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1144 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1145 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1146 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1147 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1151 static uint8_t ms_hmac_key1[] = {
1152 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1153 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1154 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1155 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1156 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1157 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1158 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1159 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1162 static const uint8_t ms_hmac_digest1[] = {
1163 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1164 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1165 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1166 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1167 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1168 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1169 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1170 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1173 /* Begin Session 2 */
1174 static uint8_t ms_aes_cbc_key2[] = {
1175 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1176 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1179 static uint8_t ms_aes_cbc_iv2[] = {
1180 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1181 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1184 static const uint8_t ms_aes_cbc_cipher2[] = {
1185 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1186 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1187 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1188 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1189 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1190 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1191 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1192 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1193 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1194 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1195 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1196 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1197 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1198 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1199 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1200 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1201 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1202 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1203 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1204 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1205 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1206 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1207 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1208 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1209 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1210 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1211 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1212 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1213 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1214 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1215 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1216 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1217 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1218 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1219 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1220 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1221 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1222 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1223 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1224 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1225 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1226 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1227 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1228 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1229 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1230 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1231 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1232 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1233 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1234 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1235 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1236 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1237 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1238 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1239 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1240 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1241 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1242 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1243 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1244 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1245 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1246 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1247 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1248 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1251 static uint8_t ms_hmac_key2[] = {
1252 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1253 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1254 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1255 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1256 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1257 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1258 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1259 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1262 static const uint8_t ms_hmac_digest2[] = {
1263 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1264 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1265 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1266 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1267 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1268 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1269 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1270 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1277 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1279 struct crypto_testsuite_params *ts_params = &testsuite_params;
1280 struct crypto_unittest_params *ut_params = &unittest_params;
1282 /* Generate test mbuf data and space for digest */
1283 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1284 catch_22_quote, QUOTE_512_BYTES, 0);
1286 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1287 DIGEST_BYTE_LENGTH_SHA1);
1288 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1290 /* Setup Cipher Parameters */
1291 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1292 ut_params->cipher_xform.next = &ut_params->auth_xform;
1294 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1295 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1296 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1297 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1298 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1299 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1301 /* Setup HMAC Parameters */
1302 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1304 ut_params->auth_xform.next = NULL;
1306 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1307 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1308 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1309 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1310 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1312 ut_params->sess = rte_cryptodev_sym_session_create(
1313 ts_params->session_mpool);
1315 /* Create crypto session*/
1316 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1317 ut_params->sess, &ut_params->cipher_xform,
1318 ts_params->session_mpool);
1319 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1321 /* Generate crypto op data structure */
1322 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1323 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1324 TEST_ASSERT_NOT_NULL(ut_params->op,
1325 "Failed to allocate symmetric crypto operation struct");
1327 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1329 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1331 /* set crypto operation source mbuf */
1332 sym_op->m_src = ut_params->ibuf;
1334 /* Set crypto operation authentication parameters */
1335 sym_op->auth.digest.data = ut_params->digest;
1336 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1337 ut_params->ibuf, QUOTE_512_BYTES);
1339 sym_op->auth.data.offset = 0;
1340 sym_op->auth.data.length = QUOTE_512_BYTES;
1342 /* Copy IV at the end of the crypto operation */
1343 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1344 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1346 /* Set crypto operation cipher parameters */
1347 sym_op->cipher.data.offset = 0;
1348 sym_op->cipher.data.length = QUOTE_512_BYTES;
1350 /* Process crypto operation */
1351 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1352 ut_params->op), "failed to process sym crypto op");
1354 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1355 "crypto op processing failed");
1358 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1361 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1362 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1364 "ciphertext data not as expected");
1366 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1368 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1369 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1370 gbl_driver_id == rte_cryptodev_driver_id_get(
1371 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1372 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1373 DIGEST_BYTE_LENGTH_SHA1,
1374 "Generated digest data not as expected");
1376 return TEST_SUCCESS;
1379 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1381 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1383 static uint8_t hmac_sha512_key[] = {
1384 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1385 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1386 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1387 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1388 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1389 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1390 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1391 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1393 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1394 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1395 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1396 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1397 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1398 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1399 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1400 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1401 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1406 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1407 struct crypto_unittest_params *ut_params,
1408 uint8_t *cipher_key,
1412 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1413 struct crypto_unittest_params *ut_params,
1414 struct crypto_testsuite_params *ts_params,
1415 const uint8_t *cipher,
1416 const uint8_t *digest,
1421 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1422 struct crypto_unittest_params *ut_params,
1423 uint8_t *cipher_key,
1427 /* Setup Cipher Parameters */
1428 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1429 ut_params->cipher_xform.next = NULL;
1431 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1432 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1433 ut_params->cipher_xform.cipher.key.data = cipher_key;
1434 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1435 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1436 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1438 /* Setup HMAC Parameters */
1439 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1440 ut_params->auth_xform.next = &ut_params->cipher_xform;
1442 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1443 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1444 ut_params->auth_xform.auth.key.data = hmac_key;
1445 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1446 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1448 return TEST_SUCCESS;
1453 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1454 struct crypto_unittest_params *ut_params,
1455 struct crypto_testsuite_params *ts_params,
1456 const uint8_t *cipher,
1457 const uint8_t *digest,
1460 /* Generate test mbuf data and digest */
1461 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1464 QUOTE_512_BYTES, 0);
1466 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1467 DIGEST_BYTE_LENGTH_SHA512);
1468 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1470 rte_memcpy(ut_params->digest,
1472 DIGEST_BYTE_LENGTH_SHA512);
1474 /* Generate Crypto op data structure */
1475 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1476 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1477 TEST_ASSERT_NOT_NULL(ut_params->op,
1478 "Failed to allocate symmetric crypto operation struct");
1480 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1482 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1484 /* set crypto operation source mbuf */
1485 sym_op->m_src = ut_params->ibuf;
1487 sym_op->auth.digest.data = ut_params->digest;
1488 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1489 ut_params->ibuf, QUOTE_512_BYTES);
1491 sym_op->auth.data.offset = 0;
1492 sym_op->auth.data.length = QUOTE_512_BYTES;
1494 /* Copy IV at the end of the crypto operation */
1495 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1496 iv, CIPHER_IV_LENGTH_AES_CBC);
1498 sym_op->cipher.data.offset = 0;
1499 sym_op->cipher.data.length = QUOTE_512_BYTES;
1501 /* Process crypto operation */
1502 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1503 ut_params->op), "failed to process sym crypto op");
1505 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1506 "crypto op processing failed");
1508 ut_params->obuf = ut_params->op->sym->m_src;
1511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1512 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1515 "Plaintext data not as expected");
1518 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1519 "Digest verification failed");
1521 return TEST_SUCCESS;
1525 test_AES_cipheronly_mb_all(void)
1527 struct crypto_testsuite_params *ts_params = &testsuite_params;
1530 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1531 ts_params->op_mpool,
1532 ts_params->session_mpool,
1533 ts_params->valid_devs[0],
1534 rte_cryptodev_driver_id_get(
1535 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1536 BLKCIPHER_AES_CIPHERONLY_TYPE);
1538 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1540 return TEST_SUCCESS;
1544 test_AES_docsis_mb_all(void)
1546 struct crypto_testsuite_params *ts_params = &testsuite_params;
1549 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1550 ts_params->op_mpool,
1551 ts_params->session_mpool,
1552 ts_params->valid_devs[0],
1553 rte_cryptodev_driver_id_get(
1554 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1555 BLKCIPHER_AES_DOCSIS_TYPE);
1557 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1559 return TEST_SUCCESS;
1563 test_AES_docsis_qat_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool,
1570 ts_params->session_mpool,
1571 ts_params->valid_devs[0],
1572 rte_cryptodev_driver_id_get(
1573 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1574 BLKCIPHER_AES_DOCSIS_TYPE);
1576 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1578 return TEST_SUCCESS;
1582 test_DES_docsis_qat_all(void)
1584 struct crypto_testsuite_params *ts_params = &testsuite_params;
1587 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1588 ts_params->op_mpool,
1589 ts_params->session_mpool,
1590 ts_params->valid_devs[0],
1591 rte_cryptodev_driver_id_get(
1592 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1593 BLKCIPHER_DES_DOCSIS_TYPE);
1595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 return TEST_SUCCESS;
1601 test_authonly_mb_all(void)
1603 struct crypto_testsuite_params *ts_params = &testsuite_params;
1606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 ts_params->op_mpool,
1608 ts_params->session_mpool,
1609 ts_params->valid_devs[0],
1610 rte_cryptodev_driver_id_get(
1611 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1612 BLKCIPHER_AUTHONLY_TYPE);
1614 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1616 return TEST_SUCCESS;
1620 test_authonly_qat_all(void)
1622 struct crypto_testsuite_params *ts_params = &testsuite_params;
1625 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1626 ts_params->op_mpool,
1627 ts_params->session_mpool,
1628 ts_params->valid_devs[0],
1629 rte_cryptodev_driver_id_get(
1630 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1631 BLKCIPHER_AUTHONLY_TYPE);
1633 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1635 return TEST_SUCCESS;
1638 test_AES_chain_mb_all(void)
1640 struct crypto_testsuite_params *ts_params = &testsuite_params;
1643 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1644 ts_params->op_mpool,
1645 ts_params->session_mpool,
1646 ts_params->valid_devs[0],
1647 rte_cryptodev_driver_id_get(
1648 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1649 BLKCIPHER_AES_CHAIN_TYPE);
1651 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1653 return TEST_SUCCESS;
1656 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1659 test_AES_cipheronly_scheduler_all(void)
1661 struct crypto_testsuite_params *ts_params = &testsuite_params;
1664 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1665 ts_params->op_mpool,
1666 ts_params->session_mpool,
1667 ts_params->valid_devs[0],
1668 rte_cryptodev_driver_id_get(
1669 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1670 BLKCIPHER_AES_CIPHERONLY_TYPE);
1672 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1674 return TEST_SUCCESS;
1678 test_AES_chain_scheduler_all(void)
1680 struct crypto_testsuite_params *ts_params = &testsuite_params;
1683 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1684 ts_params->op_mpool,
1685 ts_params->session_mpool,
1686 ts_params->valid_devs[0],
1687 rte_cryptodev_driver_id_get(
1688 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1689 BLKCIPHER_AES_CHAIN_TYPE);
1691 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1693 return TEST_SUCCESS;
1697 test_authonly_scheduler_all(void)
1699 struct crypto_testsuite_params *ts_params = &testsuite_params;
1702 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1703 ts_params->op_mpool,
1704 ts_params->session_mpool,
1705 ts_params->valid_devs[0],
1706 rte_cryptodev_driver_id_get(
1707 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1708 BLKCIPHER_AUTHONLY_TYPE);
1710 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1712 return TEST_SUCCESS;
1715 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1718 test_AES_chain_openssl_all(void)
1720 struct crypto_testsuite_params *ts_params = &testsuite_params;
1723 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1724 ts_params->op_mpool,
1725 ts_params->session_mpool,
1726 ts_params->valid_devs[0],
1727 rte_cryptodev_driver_id_get(
1728 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1729 BLKCIPHER_AES_CHAIN_TYPE);
1731 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1733 return TEST_SUCCESS;
1737 test_AES_cipheronly_openssl_all(void)
1739 struct crypto_testsuite_params *ts_params = &testsuite_params;
1742 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1743 ts_params->op_mpool,
1744 ts_params->session_mpool,
1745 ts_params->valid_devs[0],
1746 rte_cryptodev_driver_id_get(
1747 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1748 BLKCIPHER_AES_CIPHERONLY_TYPE);
1750 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1752 return TEST_SUCCESS;
1756 test_AES_chain_qat_all(void)
1758 struct crypto_testsuite_params *ts_params = &testsuite_params;
1761 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1762 ts_params->op_mpool,
1763 ts_params->session_mpool,
1764 ts_params->valid_devs[0],
1765 rte_cryptodev_driver_id_get(
1766 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1767 BLKCIPHER_AES_CHAIN_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1775 test_AES_cipheronly_qat_all(void)
1777 struct crypto_testsuite_params *ts_params = &testsuite_params;
1780 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1781 ts_params->op_mpool,
1782 ts_params->session_mpool,
1783 ts_params->valid_devs[0],
1784 rte_cryptodev_driver_id_get(
1785 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1786 BLKCIPHER_AES_CIPHERONLY_TYPE);
1788 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1790 return TEST_SUCCESS;
1794 test_AES_chain_dpaa_sec_all(void)
1796 struct crypto_testsuite_params *ts_params = &testsuite_params;
1799 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1800 ts_params->op_mpool,
1801 ts_params->session_mpool,
1802 ts_params->valid_devs[0],
1803 rte_cryptodev_driver_id_get(
1804 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1805 BLKCIPHER_AES_CHAIN_TYPE);
1807 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1809 return TEST_SUCCESS;
1813 test_AES_cipheronly_dpaa_sec_all(void)
1815 struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1819 ts_params->op_mpool,
1820 ts_params->session_mpool,
1821 ts_params->valid_devs[0],
1822 rte_cryptodev_driver_id_get(
1823 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1824 BLKCIPHER_AES_CIPHERONLY_TYPE);
1826 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1828 return TEST_SUCCESS;
1832 test_authonly_dpaa_sec_all(void)
1834 struct crypto_testsuite_params *ts_params = &testsuite_params;
1837 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1838 ts_params->op_mpool,
1839 ts_params->session_mpool,
1840 ts_params->valid_devs[0],
1841 rte_cryptodev_driver_id_get(
1842 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1843 BLKCIPHER_AUTHONLY_TYPE);
1845 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1847 return TEST_SUCCESS;
1851 test_AES_chain_dpaa2_sec_all(void)
1853 struct crypto_testsuite_params *ts_params = &testsuite_params;
1856 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1857 ts_params->op_mpool,
1858 ts_params->session_mpool,
1859 ts_params->valid_devs[0],
1860 rte_cryptodev_driver_id_get(
1861 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1862 BLKCIPHER_AES_CHAIN_TYPE);
1864 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1866 return TEST_SUCCESS;
1870 test_AES_cipheronly_dpaa2_sec_all(void)
1872 struct crypto_testsuite_params *ts_params = &testsuite_params;
1875 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1876 ts_params->op_mpool,
1877 ts_params->session_mpool,
1878 ts_params->valid_devs[0],
1879 rte_cryptodev_driver_id_get(
1880 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1881 BLKCIPHER_AES_CIPHERONLY_TYPE);
1883 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1885 return TEST_SUCCESS;
1889 test_authonly_dpaa2_sec_all(void)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1894 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1895 ts_params->op_mpool,
1896 ts_params->session_mpool,
1897 ts_params->valid_devs[0],
1898 rte_cryptodev_driver_id_get(
1899 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1900 BLKCIPHER_AUTHONLY_TYPE);
1902 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1904 return TEST_SUCCESS;
1908 test_authonly_openssl_all(void)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1913 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1914 ts_params->op_mpool,
1915 ts_params->session_mpool,
1916 ts_params->valid_devs[0],
1917 rte_cryptodev_driver_id_get(
1918 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1919 BLKCIPHER_AUTHONLY_TYPE);
1921 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1923 return TEST_SUCCESS;
1927 test_AES_chain_armv8_all(void)
1929 struct crypto_testsuite_params *ts_params = &testsuite_params;
1932 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1933 ts_params->op_mpool,
1934 ts_params->session_mpool,
1935 ts_params->valid_devs[0],
1936 rte_cryptodev_driver_id_get(
1937 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1938 BLKCIPHER_AES_CHAIN_TYPE);
1940 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1942 return TEST_SUCCESS;
1946 test_AES_chain_mrvl_all(void)
1948 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1952 ts_params->op_mpool,
1953 ts_params->session_mpool,
1954 ts_params->valid_devs[0],
1955 rte_cryptodev_driver_id_get(
1956 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1957 BLKCIPHER_AES_CHAIN_TYPE);
1959 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1961 return TEST_SUCCESS;
1965 test_AES_cipheronly_mrvl_all(void)
1967 struct crypto_testsuite_params *ts_params = &testsuite_params;
1970 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1971 ts_params->op_mpool,
1972 ts_params->session_mpool,
1973 ts_params->valid_devs[0],
1974 rte_cryptodev_driver_id_get(
1975 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1976 BLKCIPHER_AES_CIPHERONLY_TYPE);
1978 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1980 return TEST_SUCCESS;
1984 test_authonly_mrvl_all(void)
1986 struct crypto_testsuite_params *ts_params = &testsuite_params;
1989 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1990 ts_params->op_mpool,
1991 ts_params->session_mpool,
1992 ts_params->valid_devs[0],
1993 rte_cryptodev_driver_id_get(
1994 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1995 BLKCIPHER_AUTHONLY_TYPE);
1997 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1999 return TEST_SUCCESS;
2003 test_3DES_chain_mrvl_all(void)
2005 struct crypto_testsuite_params *ts_params = &testsuite_params;
2008 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2009 ts_params->op_mpool,
2010 ts_params->session_mpool,
2011 ts_params->valid_devs[0],
2012 rte_cryptodev_driver_id_get(
2013 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2014 BLKCIPHER_3DES_CHAIN_TYPE);
2016 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2018 return TEST_SUCCESS;
2022 test_3DES_cipheronly_mrvl_all(void)
2024 struct crypto_testsuite_params *ts_params = &testsuite_params;
2027 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2028 ts_params->op_mpool,
2029 ts_params->session_mpool,
2030 ts_params->valid_devs[0],
2031 rte_cryptodev_driver_id_get(
2032 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2033 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2035 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2037 return TEST_SUCCESS;
2040 /* ***** SNOW 3G Tests ***** */
2042 create_wireless_algo_hash_session(uint8_t dev_id,
2043 const uint8_t *key, const uint8_t key_len,
2044 const uint8_t iv_len, const uint8_t auth_len,
2045 enum rte_crypto_auth_operation op,
2046 enum rte_crypto_auth_algorithm algo)
2048 uint8_t hash_key[key_len];
2050 struct crypto_testsuite_params *ts_params = &testsuite_params;
2051 struct crypto_unittest_params *ut_params = &unittest_params;
2053 memcpy(hash_key, key, key_len);
2055 TEST_HEXDUMP(stdout, "key:", key, key_len);
2057 /* Setup Authentication Parameters */
2058 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2059 ut_params->auth_xform.next = NULL;
2061 ut_params->auth_xform.auth.op = op;
2062 ut_params->auth_xform.auth.algo = algo;
2063 ut_params->auth_xform.auth.key.length = key_len;
2064 ut_params->auth_xform.auth.key.data = hash_key;
2065 ut_params->auth_xform.auth.digest_length = auth_len;
2066 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2067 ut_params->auth_xform.auth.iv.length = iv_len;
2068 ut_params->sess = rte_cryptodev_sym_session_create(
2069 ts_params->session_mpool);
2071 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2072 &ut_params->auth_xform, ts_params->session_mpool);
2073 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2078 create_wireless_algo_cipher_session(uint8_t dev_id,
2079 enum rte_crypto_cipher_operation op,
2080 enum rte_crypto_cipher_algorithm algo,
2081 const uint8_t *key, const uint8_t key_len,
2084 uint8_t cipher_key[key_len];
2086 struct crypto_testsuite_params *ts_params = &testsuite_params;
2087 struct crypto_unittest_params *ut_params = &unittest_params;
2089 memcpy(cipher_key, key, key_len);
2091 /* Setup Cipher Parameters */
2092 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2093 ut_params->cipher_xform.next = NULL;
2095 ut_params->cipher_xform.cipher.algo = algo;
2096 ut_params->cipher_xform.cipher.op = op;
2097 ut_params->cipher_xform.cipher.key.data = cipher_key;
2098 ut_params->cipher_xform.cipher.key.length = key_len;
2099 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2100 ut_params->cipher_xform.cipher.iv.length = iv_len;
2102 TEST_HEXDUMP(stdout, "key:", key, key_len);
2104 /* Create Crypto session */
2105 ut_params->sess = rte_cryptodev_sym_session_create(
2106 ts_params->session_mpool);
2108 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2109 &ut_params->cipher_xform, ts_params->session_mpool);
2110 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2115 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2116 unsigned int cipher_len,
2117 unsigned int cipher_offset)
2119 struct crypto_testsuite_params *ts_params = &testsuite_params;
2120 struct crypto_unittest_params *ut_params = &unittest_params;
2122 /* Generate Crypto op data structure */
2123 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2124 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2125 TEST_ASSERT_NOT_NULL(ut_params->op,
2126 "Failed to allocate pktmbuf offload");
2128 /* Set crypto operation data parameters */
2129 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2131 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2133 /* set crypto operation source mbuf */
2134 sym_op->m_src = ut_params->ibuf;
2137 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2139 sym_op->cipher.data.length = cipher_len;
2140 sym_op->cipher.data.offset = cipher_offset;
2145 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2146 unsigned int cipher_len,
2147 unsigned int cipher_offset)
2149 struct crypto_testsuite_params *ts_params = &testsuite_params;
2150 struct crypto_unittest_params *ut_params = &unittest_params;
2152 /* Generate Crypto op data structure */
2153 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2154 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2155 TEST_ASSERT_NOT_NULL(ut_params->op,
2156 "Failed to allocate pktmbuf offload");
2158 /* Set crypto operation data parameters */
2159 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2161 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2163 /* set crypto operation source mbuf */
2164 sym_op->m_src = ut_params->ibuf;
2165 sym_op->m_dst = ut_params->obuf;
2168 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2170 sym_op->cipher.data.length = cipher_len;
2171 sym_op->cipher.data.offset = cipher_offset;
2176 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2177 enum rte_crypto_cipher_operation cipher_op,
2178 enum rte_crypto_auth_operation auth_op,
2179 enum rte_crypto_auth_algorithm auth_algo,
2180 enum rte_crypto_cipher_algorithm cipher_algo,
2181 const uint8_t *key, uint8_t key_len,
2182 uint8_t auth_iv_len, uint8_t auth_len,
2183 uint8_t cipher_iv_len)
2186 uint8_t cipher_auth_key[key_len];
2188 struct crypto_testsuite_params *ts_params = &testsuite_params;
2189 struct crypto_unittest_params *ut_params = &unittest_params;
2191 memcpy(cipher_auth_key, key, key_len);
2193 /* Setup Authentication Parameters */
2194 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2195 ut_params->auth_xform.next = NULL;
2197 ut_params->auth_xform.auth.op = auth_op;
2198 ut_params->auth_xform.auth.algo = auth_algo;
2199 ut_params->auth_xform.auth.key.length = key_len;
2200 /* Hash key = cipher key */
2201 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2202 ut_params->auth_xform.auth.digest_length = auth_len;
2203 /* Auth IV will be after cipher IV */
2204 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2205 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2207 /* Setup Cipher Parameters */
2208 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2209 ut_params->cipher_xform.next = &ut_params->auth_xform;
2211 ut_params->cipher_xform.cipher.algo = cipher_algo;
2212 ut_params->cipher_xform.cipher.op = cipher_op;
2213 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2214 ut_params->cipher_xform.cipher.key.length = key_len;
2215 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2216 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2218 TEST_HEXDUMP(stdout, "key:", key, key_len);
2220 /* Create Crypto session*/
2221 ut_params->sess = rte_cryptodev_sym_session_create(
2222 ts_params->session_mpool);
2224 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2225 &ut_params->cipher_xform, ts_params->session_mpool);
2227 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2232 create_wireless_cipher_auth_session(uint8_t dev_id,
2233 enum rte_crypto_cipher_operation cipher_op,
2234 enum rte_crypto_auth_operation auth_op,
2235 enum rte_crypto_auth_algorithm auth_algo,
2236 enum rte_crypto_cipher_algorithm cipher_algo,
2237 const struct wireless_test_data *tdata)
2239 const uint8_t key_len = tdata->key.len;
2240 uint8_t cipher_auth_key[key_len];
2242 struct crypto_testsuite_params *ts_params = &testsuite_params;
2243 struct crypto_unittest_params *ut_params = &unittest_params;
2244 const uint8_t *key = tdata->key.data;
2245 const uint8_t auth_len = tdata->digest.len;
2246 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2247 uint8_t auth_iv_len = tdata->auth_iv.len;
2249 memcpy(cipher_auth_key, key, key_len);
2251 /* Setup Authentication Parameters */
2252 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2253 ut_params->auth_xform.next = NULL;
2255 ut_params->auth_xform.auth.op = auth_op;
2256 ut_params->auth_xform.auth.algo = auth_algo;
2257 ut_params->auth_xform.auth.key.length = key_len;
2258 /* Hash key = cipher key */
2259 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2260 ut_params->auth_xform.auth.digest_length = auth_len;
2261 /* Auth IV will be after cipher IV */
2262 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2263 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2265 /* Setup Cipher Parameters */
2266 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2267 ut_params->cipher_xform.next = &ut_params->auth_xform;
2269 ut_params->cipher_xform.cipher.algo = cipher_algo;
2270 ut_params->cipher_xform.cipher.op = cipher_op;
2271 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2272 ut_params->cipher_xform.cipher.key.length = key_len;
2273 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2274 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2277 TEST_HEXDUMP(stdout, "key:", key, key_len);
2279 /* Create Crypto session*/
2280 ut_params->sess = rte_cryptodev_sym_session_create(
2281 ts_params->session_mpool);
2283 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2284 &ut_params->cipher_xform, ts_params->session_mpool);
2286 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2291 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2292 const struct wireless_test_data *tdata)
2294 return create_wireless_cipher_auth_session(dev_id,
2295 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2296 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2297 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2301 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2302 enum rte_crypto_cipher_operation cipher_op,
2303 enum rte_crypto_auth_operation auth_op,
2304 enum rte_crypto_auth_algorithm auth_algo,
2305 enum rte_crypto_cipher_algorithm cipher_algo,
2306 const uint8_t *key, const uint8_t key_len,
2307 uint8_t auth_iv_len, uint8_t auth_len,
2308 uint8_t cipher_iv_len)
2310 uint8_t auth_cipher_key[key_len];
2312 struct crypto_testsuite_params *ts_params = &testsuite_params;
2313 struct crypto_unittest_params *ut_params = &unittest_params;
2315 memcpy(auth_cipher_key, key, key_len);
2317 /* Setup Authentication Parameters */
2318 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2319 ut_params->auth_xform.auth.op = auth_op;
2320 ut_params->auth_xform.next = &ut_params->cipher_xform;
2321 ut_params->auth_xform.auth.algo = auth_algo;
2322 ut_params->auth_xform.auth.key.length = key_len;
2323 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2324 ut_params->auth_xform.auth.digest_length = auth_len;
2325 /* Auth IV will be after cipher IV */
2326 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2327 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2329 /* Setup Cipher Parameters */
2330 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2331 ut_params->cipher_xform.next = NULL;
2332 ut_params->cipher_xform.cipher.algo = cipher_algo;
2333 ut_params->cipher_xform.cipher.op = cipher_op;
2334 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2335 ut_params->cipher_xform.cipher.key.length = key_len;
2336 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2337 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2339 TEST_HEXDUMP(stdout, "key:", key, key_len);
2341 /* Create Crypto session*/
2342 ut_params->sess = rte_cryptodev_sym_session_create(
2343 ts_params->session_mpool);
2345 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2346 &ut_params->auth_xform, ts_params->session_mpool);
2348 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2354 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2355 unsigned int auth_tag_len,
2356 const uint8_t *iv, unsigned int iv_len,
2357 unsigned int data_pad_len,
2358 enum rte_crypto_auth_operation op,
2359 unsigned int auth_len, unsigned int auth_offset)
2361 struct crypto_testsuite_params *ts_params = &testsuite_params;
2363 struct crypto_unittest_params *ut_params = &unittest_params;
2365 /* Generate Crypto op data structure */
2366 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2367 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2368 TEST_ASSERT_NOT_NULL(ut_params->op,
2369 "Failed to allocate pktmbuf offload");
2371 /* Set crypto operation data parameters */
2372 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2374 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2376 /* set crypto operation source mbuf */
2377 sym_op->m_src = ut_params->ibuf;
2380 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2383 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2384 ut_params->ibuf, auth_tag_len);
2386 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2387 "no room to append auth tag");
2388 ut_params->digest = sym_op->auth.digest.data;
2389 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2390 ut_params->ibuf, data_pad_len);
2391 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2392 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2394 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2396 TEST_HEXDUMP(stdout, "digest:",
2397 sym_op->auth.digest.data,
2400 sym_op->auth.data.length = auth_len;
2401 sym_op->auth.data.offset = auth_offset;
2407 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2408 enum rte_crypto_auth_operation op)
2410 struct crypto_testsuite_params *ts_params = &testsuite_params;
2411 struct crypto_unittest_params *ut_params = &unittest_params;
2413 const uint8_t *auth_tag = tdata->digest.data;
2414 const unsigned int auth_tag_len = tdata->digest.len;
2415 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2416 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2418 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2419 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2420 const uint8_t *auth_iv = tdata->auth_iv.data;
2421 const uint8_t auth_iv_len = tdata->auth_iv.len;
2422 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2423 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2425 /* Generate Crypto op data structure */
2426 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2427 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2428 TEST_ASSERT_NOT_NULL(ut_params->op,
2429 "Failed to allocate pktmbuf offload");
2430 /* Set crypto operation data parameters */
2431 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2433 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2435 /* set crypto operation source mbuf */
2436 sym_op->m_src = ut_params->ibuf;
2439 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2440 ut_params->ibuf, auth_tag_len);
2442 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2443 "no room to append auth tag");
2444 ut_params->digest = sym_op->auth.digest.data;
2445 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2446 ut_params->ibuf, data_pad_len);
2447 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2448 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2450 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2452 TEST_HEXDUMP(stdout, "digest:",
2453 sym_op->auth.digest.data,
2456 /* Copy cipher and auth IVs at the end of the crypto operation */
2457 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2459 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2460 iv_ptr += cipher_iv_len;
2461 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2463 sym_op->cipher.data.length = cipher_len;
2464 sym_op->cipher.data.offset = 0;
2465 sym_op->auth.data.length = auth_len;
2466 sym_op->auth.data.offset = 0;
2472 create_zuc_cipher_hash_generate_operation(
2473 const struct wireless_test_data *tdata)
2475 return create_wireless_cipher_hash_operation(tdata,
2476 RTE_CRYPTO_AUTH_OP_GENERATE);
2480 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2481 const unsigned auth_tag_len,
2482 const uint8_t *auth_iv, uint8_t auth_iv_len,
2483 unsigned data_pad_len,
2484 enum rte_crypto_auth_operation op,
2485 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2486 const unsigned cipher_len, const unsigned cipher_offset,
2487 const unsigned auth_len, const unsigned auth_offset)
2489 struct crypto_testsuite_params *ts_params = &testsuite_params;
2490 struct crypto_unittest_params *ut_params = &unittest_params;
2492 /* Generate Crypto op data structure */
2493 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2494 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2495 TEST_ASSERT_NOT_NULL(ut_params->op,
2496 "Failed to allocate pktmbuf offload");
2497 /* Set crypto operation data parameters */
2498 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2500 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2502 /* set crypto operation source mbuf */
2503 sym_op->m_src = ut_params->ibuf;
2506 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2507 ut_params->ibuf, auth_tag_len);
2509 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2510 "no room to append auth tag");
2511 ut_params->digest = sym_op->auth.digest.data;
2512 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2513 ut_params->ibuf, data_pad_len);
2514 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2515 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2517 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2519 TEST_HEXDUMP(stdout, "digest:",
2520 sym_op->auth.digest.data,
2523 /* Copy cipher and auth IVs at the end of the crypto operation */
2524 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2526 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2527 iv_ptr += cipher_iv_len;
2528 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2530 sym_op->cipher.data.length = cipher_len;
2531 sym_op->cipher.data.offset = cipher_offset;
2532 sym_op->auth.data.length = auth_len;
2533 sym_op->auth.data.offset = auth_offset;
2539 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2540 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2541 const uint8_t *auth_iv, uint8_t auth_iv_len,
2542 unsigned int data_pad_len,
2543 unsigned int cipher_len, unsigned int cipher_offset,
2544 unsigned int auth_len, unsigned int auth_offset)
2546 struct crypto_testsuite_params *ts_params = &testsuite_params;
2547 struct crypto_unittest_params *ut_params = &unittest_params;
2549 /* Generate Crypto op data structure */
2550 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2551 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2552 TEST_ASSERT_NOT_NULL(ut_params->op,
2553 "Failed to allocate pktmbuf offload");
2555 /* Set crypto operation data parameters */
2556 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2558 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2560 /* set crypto operation source mbuf */
2561 sym_op->m_src = ut_params->ibuf;
2564 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2565 ut_params->ibuf, auth_tag_len);
2567 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2568 "no room to append auth tag");
2570 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2571 ut_params->ibuf, data_pad_len);
2573 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2575 TEST_HEXDUMP(stdout, "digest:",
2576 sym_op->auth.digest.data,
2579 /* Copy cipher and auth IVs at the end of the crypto operation */
2580 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2582 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2583 iv_ptr += cipher_iv_len;
2584 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2586 sym_op->cipher.data.length = cipher_len;
2587 sym_op->cipher.data.offset = cipher_offset;
2589 sym_op->auth.data.length = auth_len;
2590 sym_op->auth.data.offset = auth_offset;
2596 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2598 struct crypto_testsuite_params *ts_params = &testsuite_params;
2599 struct crypto_unittest_params *ut_params = &unittest_params;
2602 unsigned plaintext_pad_len;
2603 unsigned plaintext_len;
2606 /* Create SNOW 3G session */
2607 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2608 tdata->key.data, tdata->key.len,
2609 tdata->auth_iv.len, tdata->digest.len,
2610 RTE_CRYPTO_AUTH_OP_GENERATE,
2611 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2615 /* alloc mbuf and set payload */
2616 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2618 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2619 rte_pktmbuf_tailroom(ut_params->ibuf));
2621 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2622 /* Append data which is padded to a multiple of */
2623 /* the algorithms block size */
2624 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2625 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2627 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2629 /* Create SNOW 3G operation */
2630 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2631 tdata->auth_iv.data, tdata->auth_iv.len,
2632 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2633 tdata->validAuthLenInBits.len,
2638 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2640 ut_params->obuf = ut_params->op->sym->m_src;
2641 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2642 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2643 + plaintext_pad_len;
2646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2649 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2650 "SNOW 3G Generated auth tag not as expected");
2656 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2658 struct crypto_testsuite_params *ts_params = &testsuite_params;
2659 struct crypto_unittest_params *ut_params = &unittest_params;
2662 unsigned plaintext_pad_len;
2663 unsigned plaintext_len;
2666 /* Create SNOW 3G session */
2667 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2668 tdata->key.data, tdata->key.len,
2669 tdata->auth_iv.len, tdata->digest.len,
2670 RTE_CRYPTO_AUTH_OP_VERIFY,
2671 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2674 /* alloc mbuf and set payload */
2675 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2677 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2678 rte_pktmbuf_tailroom(ut_params->ibuf));
2680 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2681 /* Append data which is padded to a multiple of */
2682 /* the algorithms block size */
2683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2684 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2686 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2688 /* Create SNOW 3G operation */
2689 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2691 tdata->auth_iv.data, tdata->auth_iv.len,
2693 RTE_CRYPTO_AUTH_OP_VERIFY,
2694 tdata->validAuthLenInBits.len,
2699 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2701 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2702 ut_params->obuf = ut_params->op->sym->m_src;
2703 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2704 + plaintext_pad_len;
2707 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2716 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2718 struct crypto_testsuite_params *ts_params = &testsuite_params;
2719 struct crypto_unittest_params *ut_params = &unittest_params;
2722 unsigned plaintext_pad_len;
2723 unsigned plaintext_len;
2726 /* Create KASUMI session */
2727 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2728 tdata->key.data, tdata->key.len,
2729 0, tdata->digest.len,
2730 RTE_CRYPTO_AUTH_OP_GENERATE,
2731 RTE_CRYPTO_AUTH_KASUMI_F9);
2735 /* alloc mbuf and set payload */
2736 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2738 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2739 rte_pktmbuf_tailroom(ut_params->ibuf));
2741 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2742 /* Append data which is padded to a multiple of */
2743 /* the algorithms block size */
2744 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2745 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2747 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2749 /* Create KASUMI operation */
2750 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2752 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2753 tdata->plaintext.len,
2758 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2760 ut_params->obuf = ut_params->op->sym->m_src;
2761 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2762 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2763 + plaintext_pad_len;
2766 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2769 DIGEST_BYTE_LENGTH_KASUMI_F9,
2770 "KASUMI Generated auth tag not as expected");
2776 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2778 struct crypto_testsuite_params *ts_params = &testsuite_params;
2779 struct crypto_unittest_params *ut_params = &unittest_params;
2782 unsigned plaintext_pad_len;
2783 unsigned plaintext_len;
2786 /* Create KASUMI session */
2787 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2788 tdata->key.data, tdata->key.len,
2789 0, tdata->digest.len,
2790 RTE_CRYPTO_AUTH_OP_VERIFY,
2791 RTE_CRYPTO_AUTH_KASUMI_F9);
2794 /* alloc mbuf and set payload */
2795 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2798 rte_pktmbuf_tailroom(ut_params->ibuf));
2800 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2801 /* Append data which is padded to a multiple */
2802 /* of the algorithms block size */
2803 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2804 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2806 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2808 /* Create KASUMI operation */
2809 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2813 RTE_CRYPTO_AUTH_OP_VERIFY,
2814 tdata->plaintext.len,
2819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2822 ut_params->obuf = ut_params->op->sym->m_src;
2823 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2824 + plaintext_pad_len;
2827 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2836 test_snow3g_hash_generate_test_case_1(void)
2838 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2842 test_snow3g_hash_generate_test_case_2(void)
2844 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2848 test_snow3g_hash_generate_test_case_3(void)
2850 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2854 test_snow3g_hash_generate_test_case_4(void)
2856 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2860 test_snow3g_hash_generate_test_case_5(void)
2862 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2866 test_snow3g_hash_generate_test_case_6(void)
2868 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2872 test_snow3g_hash_verify_test_case_1(void)
2874 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2879 test_snow3g_hash_verify_test_case_2(void)
2881 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2885 test_snow3g_hash_verify_test_case_3(void)
2887 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2891 test_snow3g_hash_verify_test_case_4(void)
2893 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2897 test_snow3g_hash_verify_test_case_5(void)
2899 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2903 test_snow3g_hash_verify_test_case_6(void)
2905 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2909 test_kasumi_hash_generate_test_case_1(void)
2911 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2915 test_kasumi_hash_generate_test_case_2(void)
2917 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2921 test_kasumi_hash_generate_test_case_3(void)
2923 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2927 test_kasumi_hash_generate_test_case_4(void)
2929 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2933 test_kasumi_hash_generate_test_case_5(void)
2935 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2939 test_kasumi_hash_generate_test_case_6(void)
2941 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2945 test_kasumi_hash_verify_test_case_1(void)
2947 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2951 test_kasumi_hash_verify_test_case_2(void)
2953 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2957 test_kasumi_hash_verify_test_case_3(void)
2959 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2963 test_kasumi_hash_verify_test_case_4(void)
2965 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2969 test_kasumi_hash_verify_test_case_5(void)
2971 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2975 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2977 struct crypto_testsuite_params *ts_params = &testsuite_params;
2978 struct crypto_unittest_params *ut_params = &unittest_params;
2981 uint8_t *plaintext, *ciphertext;
2982 unsigned plaintext_pad_len;
2983 unsigned plaintext_len;
2985 /* Create KASUMI session */
2986 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2987 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2988 RTE_CRYPTO_CIPHER_KASUMI_F8,
2989 tdata->key.data, tdata->key.len,
2990 tdata->cipher_iv.len);
2994 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2996 /* Clear mbuf payload */
2997 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2998 rte_pktmbuf_tailroom(ut_params->ibuf));
3000 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3001 /* Append data which is padded to a multiple */
3002 /* of the algorithms block size */
3003 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3004 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3006 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3008 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3010 /* Create KASUMI operation */
3011 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3012 tdata->cipher_iv.len,
3013 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3014 tdata->validCipherOffsetInBits.len);
3018 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3020 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3022 ut_params->obuf = ut_params->op->sym->m_dst;
3023 if (ut_params->obuf)
3024 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3026 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3028 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3030 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3031 (tdata->validCipherOffsetInBits.len >> 3);
3033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3035 reference_ciphertext,
3036 tdata->validCipherLenInBits.len,
3037 "KASUMI Ciphertext data not as expected");
3042 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3044 struct crypto_testsuite_params *ts_params = &testsuite_params;
3045 struct crypto_unittest_params *ut_params = &unittest_params;
3049 unsigned int plaintext_pad_len;
3050 unsigned int plaintext_len;
3052 uint8_t buffer[10000];
3053 const uint8_t *ciphertext;
3055 struct rte_cryptodev_info dev_info;
3057 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3058 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3059 printf("Device doesn't support scatter-gather. "
3064 /* Create KASUMI session */
3065 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3066 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3067 RTE_CRYPTO_CIPHER_KASUMI_F8,
3068 tdata->key.data, tdata->key.len,
3069 tdata->cipher_iv.len);
3073 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3076 /* Append data which is padded to a multiple */
3077 /* of the algorithms block size */
3078 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3080 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3081 plaintext_pad_len, 10, 0);
3083 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3085 /* Create KASUMI operation */
3086 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3087 tdata->cipher_iv.len,
3088 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3089 tdata->validCipherOffsetInBits.len);
3093 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3095 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3097 ut_params->obuf = ut_params->op->sym->m_dst;
3099 if (ut_params->obuf)
3100 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3101 plaintext_len, buffer);
3103 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3104 tdata->validCipherOffsetInBits.len >> 3,
3105 plaintext_len, buffer);
3108 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3110 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3111 (tdata->validCipherOffsetInBits.len >> 3);
3113 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3115 reference_ciphertext,
3116 tdata->validCipherLenInBits.len,
3117 "KASUMI Ciphertext data not as expected");
3122 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3124 struct crypto_testsuite_params *ts_params = &testsuite_params;
3125 struct crypto_unittest_params *ut_params = &unittest_params;
3128 uint8_t *plaintext, *ciphertext;
3129 unsigned plaintext_pad_len;
3130 unsigned plaintext_len;
3132 /* Create KASUMI session */
3133 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3134 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3135 RTE_CRYPTO_CIPHER_KASUMI_F8,
3136 tdata->key.data, tdata->key.len,
3137 tdata->cipher_iv.len);
3141 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3142 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3144 /* Clear mbuf payload */
3145 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3146 rte_pktmbuf_tailroom(ut_params->ibuf));
3148 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3149 /* Append data which is padded to a multiple */
3150 /* of the algorithms block size */
3151 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3152 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3154 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3157 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3159 /* Create KASUMI operation */
3160 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3161 tdata->cipher_iv.len,
3162 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3163 tdata->validCipherOffsetInBits.len);
3167 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3169 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3171 ut_params->obuf = ut_params->op->sym->m_dst;
3172 if (ut_params->obuf)
3173 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3175 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3177 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3179 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3180 (tdata->validCipherOffsetInBits.len >> 3);
3182 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3184 reference_ciphertext,
3185 tdata->validCipherLenInBits.len,
3186 "KASUMI Ciphertext data not as expected");
3191 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3193 struct crypto_testsuite_params *ts_params = &testsuite_params;
3194 struct crypto_unittest_params *ut_params = &unittest_params;
3197 unsigned int plaintext_pad_len;
3198 unsigned int plaintext_len;
3200 const uint8_t *ciphertext;
3201 uint8_t buffer[2048];
3203 struct rte_cryptodev_info dev_info;
3205 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3206 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3207 printf("Device doesn't support scatter-gather. "
3212 /* Create KASUMI session */
3213 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3214 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3215 RTE_CRYPTO_CIPHER_KASUMI_F8,
3216 tdata->key.data, tdata->key.len,
3217 tdata->cipher_iv.len);
3221 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3222 /* Append data which is padded to a multiple */
3223 /* of the algorithms block size */
3224 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3226 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3227 plaintext_pad_len, 10, 0);
3228 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3229 plaintext_pad_len, 3, 0);
3231 /* Append data which is padded to a multiple */
3232 /* of the algorithms block size */
3233 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3235 /* Create KASUMI operation */
3236 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3237 tdata->cipher_iv.len,
3238 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3239 tdata->validCipherOffsetInBits.len);
3243 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3245 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3247 ut_params->obuf = ut_params->op->sym->m_dst;
3248 if (ut_params->obuf)
3249 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3250 plaintext_pad_len, buffer);
3252 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3253 tdata->validCipherOffsetInBits.len >> 3,
3254 plaintext_pad_len, buffer);
3256 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3257 (tdata->validCipherOffsetInBits.len >> 3);
3259 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3261 reference_ciphertext,
3262 tdata->validCipherLenInBits.len,
3263 "KASUMI Ciphertext data not as expected");
3269 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3271 struct crypto_testsuite_params *ts_params = &testsuite_params;
3272 struct crypto_unittest_params *ut_params = &unittest_params;
3275 uint8_t *ciphertext, *plaintext;
3276 unsigned ciphertext_pad_len;
3277 unsigned ciphertext_len;
3279 /* Create KASUMI session */
3280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3281 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3282 RTE_CRYPTO_CIPHER_KASUMI_F8,
3283 tdata->key.data, tdata->key.len,
3284 tdata->cipher_iv.len);
3288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3289 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3291 /* Clear mbuf payload */
3292 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3293 rte_pktmbuf_tailroom(ut_params->ibuf));
3295 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3296 /* Append data which is padded to a multiple */
3297 /* of the algorithms block size */
3298 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3299 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3300 ciphertext_pad_len);
3301 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3302 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3304 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3306 /* Create KASUMI operation */
3307 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3308 tdata->cipher_iv.len,
3309 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3310 tdata->validCipherOffsetInBits.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 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3322 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3324 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3326 const uint8_t *reference_plaintext = tdata->plaintext.data +
3327 (tdata->validCipherOffsetInBits.len >> 3);
3329 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3331 reference_plaintext,
3332 tdata->validCipherLenInBits.len,
3333 "KASUMI Plaintext data not as expected");
3338 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3340 struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 struct crypto_unittest_params *ut_params = &unittest_params;
3344 uint8_t *ciphertext, *plaintext;
3345 unsigned ciphertext_pad_len;
3346 unsigned ciphertext_len;
3348 /* Create KASUMI session */
3349 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3350 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3351 RTE_CRYPTO_CIPHER_KASUMI_F8,
3352 tdata->key.data, tdata->key.len,
3353 tdata->cipher_iv.len);
3357 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3359 /* Clear mbuf payload */
3360 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3361 rte_pktmbuf_tailroom(ut_params->ibuf));
3363 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3364 /* Append data which is padded to a multiple */
3365 /* of the algorithms block size */
3366 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3367 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3368 ciphertext_pad_len);
3369 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3371 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3373 /* Create KASUMI operation */
3374 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3375 tdata->cipher_iv.len,
3376 tdata->ciphertext.len,
3377 tdata->validCipherOffsetInBits.len);
3381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3385 ut_params->obuf = ut_params->op->sym->m_dst;
3386 if (ut_params->obuf)
3387 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3389 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3391 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3393 const uint8_t *reference_plaintext = tdata->plaintext.data +
3394 (tdata->validCipherOffsetInBits.len >> 3);
3396 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3398 reference_plaintext,
3399 tdata->validCipherLenInBits.len,
3400 "KASUMI Plaintext data not as expected");
3405 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3407 struct crypto_testsuite_params *ts_params = &testsuite_params;
3408 struct crypto_unittest_params *ut_params = &unittest_params;
3411 uint8_t *plaintext, *ciphertext;
3412 unsigned plaintext_pad_len;
3413 unsigned plaintext_len;
3415 /* Create SNOW 3G session */
3416 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3417 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3418 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3419 tdata->key.data, tdata->key.len,
3420 tdata->cipher_iv.len);
3424 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3426 /* Clear mbuf payload */
3427 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3428 rte_pktmbuf_tailroom(ut_params->ibuf));
3430 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3431 /* Append data which is padded to a multiple of */
3432 /* the algorithms block size */
3433 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3434 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3436 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3438 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3440 /* Create SNOW 3G operation */
3441 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3442 tdata->cipher_iv.len,
3443 tdata->validCipherLenInBits.len,
3448 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3452 ut_params->obuf = ut_params->op->sym->m_dst;
3453 if (ut_params->obuf)
3454 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3456 ciphertext = plaintext;
3458 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3461 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3463 tdata->ciphertext.data,
3464 tdata->validDataLenInBits.len,
3465 "SNOW 3G Ciphertext data not as expected");
3471 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3473 struct crypto_testsuite_params *ts_params = &testsuite_params;
3474 struct crypto_unittest_params *ut_params = &unittest_params;
3475 uint8_t *plaintext, *ciphertext;
3478 unsigned plaintext_pad_len;
3479 unsigned plaintext_len;
3481 /* Create SNOW 3G session */
3482 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3483 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3484 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3485 tdata->key.data, tdata->key.len,
3486 tdata->cipher_iv.len);
3490 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3491 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3493 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3494 "Failed to allocate input buffer in mempool");
3495 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3496 "Failed to allocate output buffer in mempool");
3498 /* Clear mbuf payload */
3499 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3500 rte_pktmbuf_tailroom(ut_params->ibuf));
3502 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3503 /* Append data which is padded to a multiple of */
3504 /* the algorithms block size */
3505 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3506 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3508 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3509 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3511 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3513 /* Create SNOW 3G operation */
3514 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3515 tdata->cipher_iv.len,
3516 tdata->validCipherLenInBits.len,
3521 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3525 ut_params->obuf = ut_params->op->sym->m_dst;
3526 if (ut_params->obuf)
3527 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3529 ciphertext = plaintext;
3531 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3534 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3536 tdata->ciphertext.data,
3537 tdata->validDataLenInBits.len,
3538 "SNOW 3G Ciphertext data not as expected");
3543 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3545 struct crypto_testsuite_params *ts_params = &testsuite_params;
3546 struct crypto_unittest_params *ut_params = &unittest_params;
3549 unsigned int plaintext_pad_len;
3550 unsigned int plaintext_len;
3551 uint8_t buffer[10000];
3552 const uint8_t *ciphertext;
3554 struct rte_cryptodev_info dev_info;
3556 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3557 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3558 printf("Device doesn't support scatter-gather. "
3563 /* Create SNOW 3G session */
3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3567 tdata->key.data, tdata->key.len,
3568 tdata->cipher_iv.len);
3572 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 /* Append data which is padded to a multiple of */
3574 /* the algorithms block size */
3575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3577 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 10, 0);
3579 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3580 plaintext_pad_len, 3, 0);
3582 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3583 "Failed to allocate input buffer in mempool");
3584 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3585 "Failed to allocate output buffer in mempool");
3587 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3589 /* Create SNOW 3G operation */
3590 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3591 tdata->cipher_iv.len,
3592 tdata->validCipherLenInBits.len,
3597 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3601 ut_params->obuf = ut_params->op->sym->m_dst;
3602 if (ut_params->obuf)
3603 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3604 plaintext_len, buffer);
3606 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3607 plaintext_len, buffer);
3609 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3614 tdata->ciphertext.data,
3615 tdata->validDataLenInBits.len,
3616 "SNOW 3G Ciphertext data not as expected");
3621 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3623 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3625 uint8_t curr_byte, prev_byte;
3626 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3627 uint8_t lower_byte_mask = (1 << offset) - 1;
3630 prev_byte = buffer[0];
3631 buffer[0] >>= offset;
3633 for (i = 1; i < length_in_bytes; i++) {
3634 curr_byte = buffer[i];
3635 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3636 (curr_byte >> offset);
3637 prev_byte = curr_byte;
3642 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3644 struct crypto_testsuite_params *ts_params = &testsuite_params;
3645 struct crypto_unittest_params *ut_params = &unittest_params;
3646 uint8_t *plaintext, *ciphertext;
3648 uint32_t plaintext_len;
3649 uint32_t plaintext_pad_len;
3650 uint8_t extra_offset = 4;
3651 uint8_t *expected_ciphertext_shifted;
3653 /* Create SNOW 3G session */
3654 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3655 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3656 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3657 tdata->key.data, tdata->key.len,
3658 tdata->cipher_iv.len);
3662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3663 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3665 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3666 "Failed to allocate input buffer in mempool");
3667 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3668 "Failed to allocate output buffer in mempool");
3670 /* Clear mbuf payload */
3671 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3672 rte_pktmbuf_tailroom(ut_params->ibuf));
3674 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3676 * Append data which is padded to a
3677 * multiple of the algorithms block size
3679 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3681 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3684 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3686 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3687 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3689 #ifdef RTE_APP_TEST_DEBUG
3690 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3692 /* Create SNOW 3G operation */
3693 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3694 tdata->cipher_iv.len,
3695 tdata->validCipherLenInBits.len,
3700 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3702 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3704 ut_params->obuf = ut_params->op->sym->m_dst;
3705 if (ut_params->obuf)
3706 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3708 ciphertext = plaintext;
3710 #ifdef RTE_APP_TEST_DEBUG
3711 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3714 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3716 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3717 "failed to reserve memory for ciphertext shifted\n");
3719 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3720 ceil_byte_length(tdata->ciphertext.len));
3721 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3726 expected_ciphertext_shifted,
3727 tdata->validDataLenInBits.len,
3729 "SNOW 3G Ciphertext data not as expected");
3733 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3735 struct crypto_testsuite_params *ts_params = &testsuite_params;
3736 struct crypto_unittest_params *ut_params = &unittest_params;
3740 uint8_t *plaintext, *ciphertext;
3741 unsigned ciphertext_pad_len;
3742 unsigned ciphertext_len;
3744 /* Create SNOW 3G session */
3745 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3746 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3747 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3748 tdata->key.data, tdata->key.len,
3749 tdata->cipher_iv.len);
3753 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3755 /* Clear mbuf payload */
3756 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3757 rte_pktmbuf_tailroom(ut_params->ibuf));
3759 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3760 /* Append data which is padded to a multiple of */
3761 /* the algorithms block size */
3762 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3763 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3764 ciphertext_pad_len);
3765 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3767 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3769 /* Create SNOW 3G operation */
3770 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3771 tdata->cipher_iv.len,
3772 tdata->validCipherLenInBits.len,
3777 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3779 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3780 ut_params->obuf = ut_params->op->sym->m_dst;
3781 if (ut_params->obuf)
3782 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3784 plaintext = ciphertext;
3786 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3789 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3790 tdata->plaintext.data,
3791 tdata->validDataLenInBits.len,
3792 "SNOW 3G Plaintext data not as expected");
3796 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3798 struct crypto_testsuite_params *ts_params = &testsuite_params;
3799 struct crypto_unittest_params *ut_params = &unittest_params;
3803 uint8_t *plaintext, *ciphertext;
3804 unsigned ciphertext_pad_len;
3805 unsigned ciphertext_len;
3807 /* Create SNOW 3G session */
3808 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3809 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3810 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3811 tdata->key.data, tdata->key.len,
3812 tdata->cipher_iv.len);
3816 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3817 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3819 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3820 "Failed to allocate input buffer");
3821 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3822 "Failed to allocate output buffer");
3824 /* Clear mbuf payload */
3825 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3826 rte_pktmbuf_tailroom(ut_params->ibuf));
3828 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3829 rte_pktmbuf_tailroom(ut_params->obuf));
3831 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3832 /* Append data which is padded to a multiple of */
3833 /* the algorithms block size */
3834 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3835 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3836 ciphertext_pad_len);
3837 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3838 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3840 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3842 /* Create SNOW 3G operation */
3843 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3844 tdata->cipher_iv.len,
3845 tdata->validCipherLenInBits.len,
3850 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3852 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3853 ut_params->obuf = ut_params->op->sym->m_dst;
3854 if (ut_params->obuf)
3855 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3857 plaintext = ciphertext;
3859 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3862 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3863 tdata->plaintext.data,
3864 tdata->validDataLenInBits.len,
3865 "SNOW 3G Plaintext data not as expected");
3870 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3872 struct crypto_testsuite_params *ts_params = &testsuite_params;
3873 struct crypto_unittest_params *ut_params = &unittest_params;
3877 uint8_t *plaintext, *ciphertext;
3878 unsigned int plaintext_pad_len;
3879 unsigned int plaintext_len;
3881 struct rte_cryptodev_sym_capability_idx cap_idx;
3883 /* Check if device supports ZUC EEA3 */
3884 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3885 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3887 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3891 /* Check if device supports ZUC EIA3 */
3892 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3893 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3895 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3899 /* Create ZUC session */
3900 retval = create_zuc_cipher_auth_encrypt_generate_session(
3901 ts_params->valid_devs[0],
3905 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3907 /* clear mbuf payload */
3908 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3909 rte_pktmbuf_tailroom(ut_params->ibuf));
3911 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3912 /* Append data which is padded to a multiple of */
3913 /* the algorithms block size */
3914 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3915 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3917 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3919 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3921 /* Create ZUC operation */
3922 retval = create_zuc_cipher_hash_generate_operation(tdata);
3926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3929 ut_params->obuf = ut_params->op->sym->m_src;
3930 if (ut_params->obuf)
3931 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3933 ciphertext = plaintext;
3935 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3937 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3939 tdata->ciphertext.data,
3940 tdata->validDataLenInBits.len,
3941 "ZUC Ciphertext data not as expected");
3943 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3944 + plaintext_pad_len;
3947 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3951 "ZUC Generated auth tag not as expected");
3956 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3958 struct crypto_testsuite_params *ts_params = &testsuite_params;
3959 struct crypto_unittest_params *ut_params = &unittest_params;
3963 uint8_t *plaintext, *ciphertext;
3964 unsigned plaintext_pad_len;
3965 unsigned plaintext_len;
3967 /* Create SNOW 3G session */
3968 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3969 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3970 RTE_CRYPTO_AUTH_OP_GENERATE,
3971 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3972 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3973 tdata->key.data, tdata->key.len,
3974 tdata->auth_iv.len, tdata->digest.len,
3975 tdata->cipher_iv.len);
3978 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3980 /* clear mbuf payload */
3981 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3982 rte_pktmbuf_tailroom(ut_params->ibuf));
3984 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3985 /* Append data which is padded to a multiple of */
3986 /* the algorithms block size */
3987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3988 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3990 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3992 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3994 /* Create SNOW 3G operation */
3995 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3996 tdata->digest.len, tdata->auth_iv.data,
3998 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3999 tdata->cipher_iv.data, tdata->cipher_iv.len,
4000 tdata->validCipherLenInBits.len,
4002 tdata->validAuthLenInBits.len,
4008 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4010 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4011 ut_params->obuf = ut_params->op->sym->m_src;
4012 if (ut_params->obuf)
4013 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4015 ciphertext = plaintext;
4017 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4019 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4021 tdata->ciphertext.data,
4022 tdata->validDataLenInBits.len,
4023 "SNOW 3G Ciphertext data not as expected");
4025 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4026 + plaintext_pad_len;
4029 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4032 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4033 "SNOW 3G Generated auth tag not as expected");
4037 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4039 struct crypto_testsuite_params *ts_params = &testsuite_params;
4040 struct crypto_unittest_params *ut_params = &unittest_params;
4044 uint8_t *plaintext, *ciphertext;
4045 unsigned plaintext_pad_len;
4046 unsigned plaintext_len;
4048 /* Create SNOW 3G session */
4049 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4050 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4051 RTE_CRYPTO_AUTH_OP_GENERATE,
4052 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4053 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4054 tdata->key.data, tdata->key.len,
4055 tdata->auth_iv.len, tdata->digest.len,
4056 tdata->cipher_iv.len);
4060 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4062 /* clear mbuf payload */
4063 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4064 rte_pktmbuf_tailroom(ut_params->ibuf));
4066 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4067 /* Append data which is padded to a multiple of */
4068 /* the algorithms block size */
4069 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4070 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4072 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4074 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4076 /* Create SNOW 3G operation */
4077 retval = create_wireless_algo_auth_cipher_operation(
4079 tdata->cipher_iv.data, tdata->cipher_iv.len,
4080 tdata->auth_iv.data, tdata->auth_iv.len,
4082 tdata->validCipherLenInBits.len,
4084 tdata->validAuthLenInBits.len,
4090 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4092 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4093 ut_params->obuf = ut_params->op->sym->m_src;
4094 if (ut_params->obuf)
4095 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4097 ciphertext = plaintext;
4099 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4100 + plaintext_pad_len;
4101 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4104 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4106 tdata->ciphertext.data,
4107 tdata->validDataLenInBits.len,
4108 "SNOW 3G Ciphertext data not as expected");
4111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4114 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4115 "SNOW 3G Generated auth tag not as expected");
4120 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4122 struct crypto_testsuite_params *ts_params = &testsuite_params;
4123 struct crypto_unittest_params *ut_params = &unittest_params;
4127 uint8_t *plaintext, *ciphertext;
4128 unsigned plaintext_pad_len;
4129 unsigned plaintext_len;
4131 /* Create KASUMI session */
4132 retval = create_wireless_algo_auth_cipher_session(
4133 ts_params->valid_devs[0],
4134 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4135 RTE_CRYPTO_AUTH_OP_GENERATE,
4136 RTE_CRYPTO_AUTH_KASUMI_F9,
4137 RTE_CRYPTO_CIPHER_KASUMI_F8,
4138 tdata->key.data, tdata->key.len,
4139 0, tdata->digest.len,
4140 tdata->cipher_iv.len);
4143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4145 /* clear mbuf payload */
4146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4147 rte_pktmbuf_tailroom(ut_params->ibuf));
4149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4150 /* Append data which is padded to a multiple of */
4151 /* the algorithms block size */
4152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4157 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4159 /* Create KASUMI operation */
4160 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4161 tdata->cipher_iv.data, tdata->cipher_iv.len,
4164 tdata->validCipherLenInBits.len,
4165 tdata->validCipherOffsetInBits.len,
4166 tdata->validAuthLenInBits.len,
4173 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4175 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4176 if (ut_params->op->sym->m_dst)
4177 ut_params->obuf = ut_params->op->sym->m_dst;
4179 ut_params->obuf = ut_params->op->sym->m_src;
4181 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4182 tdata->validCipherOffsetInBits.len >> 3);
4184 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4185 (tdata->validCipherOffsetInBits.len >> 3);
4187 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4189 reference_ciphertext,
4190 tdata->validCipherLenInBits.len,
4191 "KASUMI Ciphertext data not as expected");
4192 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4193 + plaintext_pad_len;
4196 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4199 DIGEST_BYTE_LENGTH_KASUMI_F9,
4200 "KASUMI Generated auth tag not as expected");
4205 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4207 struct crypto_testsuite_params *ts_params = &testsuite_params;
4208 struct crypto_unittest_params *ut_params = &unittest_params;
4212 uint8_t *plaintext, *ciphertext;
4213 unsigned plaintext_pad_len;
4214 unsigned plaintext_len;
4216 /* Create KASUMI session */
4217 retval = create_wireless_algo_cipher_auth_session(
4218 ts_params->valid_devs[0],
4219 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4220 RTE_CRYPTO_AUTH_OP_GENERATE,
4221 RTE_CRYPTO_AUTH_KASUMI_F9,
4222 RTE_CRYPTO_CIPHER_KASUMI_F8,
4223 tdata->key.data, tdata->key.len,
4224 0, tdata->digest.len,
4225 tdata->cipher_iv.len);
4229 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4231 /* clear mbuf payload */
4232 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4233 rte_pktmbuf_tailroom(ut_params->ibuf));
4235 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4236 /* Append data which is padded to a multiple of */
4237 /* the algorithms block size */
4238 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4239 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4241 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4243 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4245 /* Create KASUMI operation */
4246 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4247 tdata->digest.len, NULL, 0,
4248 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4249 tdata->cipher_iv.data, tdata->cipher_iv.len,
4250 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4251 tdata->validCipherOffsetInBits.len,
4252 tdata->validAuthLenInBits.len,
4258 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4260 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4262 if (ut_params->op->sym->m_dst)
4263 ut_params->obuf = ut_params->op->sym->m_dst;
4265 ut_params->obuf = ut_params->op->sym->m_src;
4267 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4268 tdata->validCipherOffsetInBits.len >> 3);
4270 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4271 + plaintext_pad_len;
4273 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4274 (tdata->validCipherOffsetInBits.len >> 3);
4276 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4278 reference_ciphertext,
4279 tdata->validCipherLenInBits.len,
4280 "KASUMI Ciphertext data not as expected");
4283 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4286 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4287 "KASUMI Generated auth tag not as expected");
4292 test_zuc_encryption(const struct wireless_test_data *tdata)
4294 struct crypto_testsuite_params *ts_params = &testsuite_params;
4295 struct crypto_unittest_params *ut_params = &unittest_params;
4298 uint8_t *plaintext, *ciphertext;
4299 unsigned plaintext_pad_len;
4300 unsigned plaintext_len;
4302 struct rte_cryptodev_sym_capability_idx cap_idx;
4304 /* Check if device supports ZUC EEA3 */
4305 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4306 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4308 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4312 /* Create ZUC session */
4313 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4314 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4315 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4316 tdata->key.data, tdata->key.len,
4317 tdata->cipher_iv.len);
4321 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4323 /* Clear mbuf payload */
4324 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4325 rte_pktmbuf_tailroom(ut_params->ibuf));
4327 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4328 /* Append data which is padded to a multiple */
4329 /* of the algorithms block size */
4330 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4331 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4333 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4335 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4337 /* Create ZUC operation */
4338 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4339 tdata->cipher_iv.len,
4340 tdata->plaintext.len,
4345 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4347 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4349 ut_params->obuf = ut_params->op->sym->m_dst;
4350 if (ut_params->obuf)
4351 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4353 ciphertext = plaintext;
4355 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4358 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4360 tdata->ciphertext.data,
4361 tdata->validCipherLenInBits.len,
4362 "ZUC Ciphertext data not as expected");
4367 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4369 struct crypto_testsuite_params *ts_params = &testsuite_params;
4370 struct crypto_unittest_params *ut_params = &unittest_params;
4374 unsigned int plaintext_pad_len;
4375 unsigned int plaintext_len;
4376 const uint8_t *ciphertext;
4377 uint8_t ciphertext_buffer[2048];
4378 struct rte_cryptodev_info dev_info;
4380 struct rte_cryptodev_sym_capability_idx cap_idx;
4382 /* Check if device supports ZUC EEA3 */
4383 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4384 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4386 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4390 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4391 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4392 printf("Device doesn't support scatter-gather. "
4397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4399 /* Append data which is padded to a multiple */
4400 /* of the algorithms block size */
4401 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4403 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4404 plaintext_pad_len, 10, 0);
4406 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4407 tdata->plaintext.data);
4409 /* Create ZUC session */
4410 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4411 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4412 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4413 tdata->key.data, tdata->key.len,
4414 tdata->cipher_iv.len);
4418 /* Clear mbuf payload */
4420 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4422 /* Create ZUC operation */
4423 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4424 tdata->cipher_iv.len, tdata->plaintext.len,
4429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4433 ut_params->obuf = ut_params->op->sym->m_dst;
4434 if (ut_params->obuf)
4435 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4436 0, plaintext_len, ciphertext_buffer);
4438 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4439 0, plaintext_len, ciphertext_buffer);
4442 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4445 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4447 tdata->ciphertext.data,
4448 tdata->validCipherLenInBits.len,
4449 "ZUC Ciphertext data not as expected");
4455 test_zuc_authentication(const struct wireless_test_data *tdata)
4457 struct crypto_testsuite_params *ts_params = &testsuite_params;
4458 struct crypto_unittest_params *ut_params = &unittest_params;
4461 unsigned plaintext_pad_len;
4462 unsigned plaintext_len;
4465 struct rte_cryptodev_sym_capability_idx cap_idx;
4467 /* Check if device supports ZUC EIA3 */
4468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4469 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4471 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4475 /* Create ZUC session */
4476 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4477 tdata->key.data, tdata->key.len,
4478 tdata->auth_iv.len, tdata->digest.len,
4479 RTE_CRYPTO_AUTH_OP_GENERATE,
4480 RTE_CRYPTO_AUTH_ZUC_EIA3);
4484 /* alloc mbuf and set payload */
4485 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4487 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4488 rte_pktmbuf_tailroom(ut_params->ibuf));
4490 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4491 /* Append data which is padded to a multiple of */
4492 /* the algorithms block size */
4493 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4494 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4496 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4498 /* Create ZUC operation */
4499 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4500 tdata->auth_iv.data, tdata->auth_iv.len,
4501 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4502 tdata->validAuthLenInBits.len,
4507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4509 ut_params->obuf = ut_params->op->sym->m_src;
4510 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4511 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4512 + plaintext_pad_len;
4515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4518 DIGEST_BYTE_LENGTH_KASUMI_F9,
4519 "ZUC Generated auth tag not as expected");
4525 test_kasumi_encryption_test_case_1(void)
4527 return test_kasumi_encryption(&kasumi_test_case_1);
4531 test_kasumi_encryption_test_case_1_sgl(void)
4533 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4537 test_kasumi_encryption_test_case_1_oop(void)
4539 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4543 test_kasumi_encryption_test_case_1_oop_sgl(void)
4545 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4549 test_kasumi_encryption_test_case_2(void)
4551 return test_kasumi_encryption(&kasumi_test_case_2);
4555 test_kasumi_encryption_test_case_3(void)
4557 return test_kasumi_encryption(&kasumi_test_case_3);
4561 test_kasumi_encryption_test_case_4(void)
4563 return test_kasumi_encryption(&kasumi_test_case_4);
4567 test_kasumi_encryption_test_case_5(void)
4569 return test_kasumi_encryption(&kasumi_test_case_5);
4573 test_kasumi_decryption_test_case_1(void)
4575 return test_kasumi_decryption(&kasumi_test_case_1);
4579 test_kasumi_decryption_test_case_1_oop(void)
4581 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4585 test_kasumi_decryption_test_case_2(void)
4587 return test_kasumi_decryption(&kasumi_test_case_2);
4591 test_kasumi_decryption_test_case_3(void)
4593 return test_kasumi_decryption(&kasumi_test_case_3);
4597 test_kasumi_decryption_test_case_4(void)
4599 return test_kasumi_decryption(&kasumi_test_case_4);
4603 test_kasumi_decryption_test_case_5(void)
4605 return test_kasumi_decryption(&kasumi_test_case_5);
4608 test_snow3g_encryption_test_case_1(void)
4610 return test_snow3g_encryption(&snow3g_test_case_1);
4614 test_snow3g_encryption_test_case_1_oop(void)
4616 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4620 test_snow3g_encryption_test_case_1_oop_sgl(void)
4622 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4627 test_snow3g_encryption_test_case_1_offset_oop(void)
4629 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4633 test_snow3g_encryption_test_case_2(void)
4635 return test_snow3g_encryption(&snow3g_test_case_2);
4639 test_snow3g_encryption_test_case_3(void)
4641 return test_snow3g_encryption(&snow3g_test_case_3);
4645 test_snow3g_encryption_test_case_4(void)
4647 return test_snow3g_encryption(&snow3g_test_case_4);
4651 test_snow3g_encryption_test_case_5(void)
4653 return test_snow3g_encryption(&snow3g_test_case_5);
4657 test_snow3g_decryption_test_case_1(void)
4659 return test_snow3g_decryption(&snow3g_test_case_1);
4663 test_snow3g_decryption_test_case_1_oop(void)
4665 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4669 test_snow3g_decryption_test_case_2(void)
4671 return test_snow3g_decryption(&snow3g_test_case_2);
4675 test_snow3g_decryption_test_case_3(void)
4677 return test_snow3g_decryption(&snow3g_test_case_3);
4681 test_snow3g_decryption_test_case_4(void)
4683 return test_snow3g_decryption(&snow3g_test_case_4);
4687 test_snow3g_decryption_test_case_5(void)
4689 return test_snow3g_decryption(&snow3g_test_case_5);
4692 test_snow3g_cipher_auth_test_case_1(void)
4694 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4698 test_snow3g_auth_cipher_test_case_1(void)
4700 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4704 test_kasumi_auth_cipher_test_case_1(void)
4706 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4710 test_kasumi_cipher_auth_test_case_1(void)
4712 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4716 test_zuc_encryption_test_case_1(void)
4718 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4722 test_zuc_encryption_test_case_2(void)
4724 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4728 test_zuc_encryption_test_case_3(void)
4730 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4734 test_zuc_encryption_test_case_4(void)
4736 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4740 test_zuc_encryption_test_case_5(void)
4742 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4746 test_zuc_encryption_test_case_6_sgl(void)
4748 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4752 test_zuc_hash_generate_test_case_1(void)
4754 return test_zuc_authentication(&zuc_test_case_auth_1b);
4758 test_zuc_hash_generate_test_case_2(void)
4760 return test_zuc_authentication(&zuc_test_case_auth_90b);
4764 test_zuc_hash_generate_test_case_3(void)
4766 return test_zuc_authentication(&zuc_test_case_auth_577b);
4770 test_zuc_hash_generate_test_case_4(void)
4772 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4776 test_zuc_hash_generate_test_case_5(void)
4778 return test_zuc_authentication(&zuc_test_auth_5670b);
4782 test_zuc_hash_generate_test_case_6(void)
4784 return test_zuc_authentication(&zuc_test_case_auth_128b);
4788 test_zuc_hash_generate_test_case_7(void)
4790 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4794 test_zuc_hash_generate_test_case_8(void)
4796 return test_zuc_authentication(&zuc_test_case_auth_584b);
4800 test_zuc_cipher_auth_test_case_1(void)
4802 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4806 test_zuc_cipher_auth_test_case_2(void)
4808 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4812 test_3DES_chain_qat_all(void)
4814 struct crypto_testsuite_params *ts_params = &testsuite_params;
4817 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4818 ts_params->op_mpool,
4819 ts_params->session_mpool,
4820 ts_params->valid_devs[0],
4821 rte_cryptodev_driver_id_get(
4822 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4823 BLKCIPHER_3DES_CHAIN_TYPE);
4825 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4827 return TEST_SUCCESS;
4831 test_DES_cipheronly_qat_all(void)
4833 struct crypto_testsuite_params *ts_params = &testsuite_params;
4836 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4837 ts_params->op_mpool,
4838 ts_params->session_mpool,
4839 ts_params->valid_devs[0],
4840 rte_cryptodev_driver_id_get(
4841 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4842 BLKCIPHER_DES_CIPHERONLY_TYPE);
4844 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4846 return TEST_SUCCESS;
4850 test_DES_cipheronly_openssl_all(void)
4852 struct crypto_testsuite_params *ts_params = &testsuite_params;
4855 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4856 ts_params->op_mpool,
4857 ts_params->session_mpool,
4858 ts_params->valid_devs[0],
4859 rte_cryptodev_driver_id_get(
4860 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4861 BLKCIPHER_DES_CIPHERONLY_TYPE);
4863 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4865 return TEST_SUCCESS;
4869 test_DES_docsis_openssl_all(void)
4871 struct crypto_testsuite_params *ts_params = &testsuite_params;
4874 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4875 ts_params->op_mpool,
4876 ts_params->session_mpool,
4877 ts_params->valid_devs[0],
4878 rte_cryptodev_driver_id_get(
4879 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4880 BLKCIPHER_DES_DOCSIS_TYPE);
4882 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4884 return TEST_SUCCESS;
4888 test_DES_cipheronly_mb_all(void)
4890 struct crypto_testsuite_params *ts_params = &testsuite_params;
4893 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4894 ts_params->op_mpool,
4895 ts_params->session_mpool,
4896 ts_params->valid_devs[0],
4897 rte_cryptodev_driver_id_get(
4898 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4899 BLKCIPHER_DES_CIPHERONLY_TYPE);
4901 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4903 return TEST_SUCCESS;
4907 test_DES_docsis_mb_all(void)
4909 struct crypto_testsuite_params *ts_params = &testsuite_params;
4912 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4913 ts_params->op_mpool,
4914 ts_params->session_mpool,
4915 ts_params->valid_devs[0],
4916 rte_cryptodev_driver_id_get(
4917 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4918 BLKCIPHER_DES_DOCSIS_TYPE);
4920 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4922 return TEST_SUCCESS;
4926 test_3DES_chain_dpaa_sec_all(void)
4928 struct crypto_testsuite_params *ts_params = &testsuite_params;
4931 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4932 ts_params->op_mpool,
4933 ts_params->session_mpool,
4934 ts_params->valid_devs[0],
4935 rte_cryptodev_driver_id_get(
4936 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4937 BLKCIPHER_3DES_CHAIN_TYPE);
4939 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4941 return TEST_SUCCESS;
4945 test_3DES_cipheronly_dpaa_sec_all(void)
4947 struct crypto_testsuite_params *ts_params = &testsuite_params;
4950 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4951 ts_params->op_mpool,
4952 ts_params->session_mpool,
4953 ts_params->valid_devs[0],
4954 rte_cryptodev_driver_id_get(
4955 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4956 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4958 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4960 return TEST_SUCCESS;
4964 test_3DES_chain_dpaa2_sec_all(void)
4966 struct crypto_testsuite_params *ts_params = &testsuite_params;
4969 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4970 ts_params->op_mpool,
4971 ts_params->session_mpool,
4972 ts_params->valid_devs[0],
4973 rte_cryptodev_driver_id_get(
4974 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4975 BLKCIPHER_3DES_CHAIN_TYPE);
4977 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4979 return TEST_SUCCESS;
4983 test_3DES_cipheronly_dpaa2_sec_all(void)
4985 struct crypto_testsuite_params *ts_params = &testsuite_params;
4988 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4989 ts_params->op_mpool,
4990 ts_params->session_mpool,
4991 ts_params->valid_devs[0],
4992 rte_cryptodev_driver_id_get(
4993 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4994 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4996 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4998 return TEST_SUCCESS;
5002 test_3DES_cipheronly_qat_all(void)
5004 struct crypto_testsuite_params *ts_params = &testsuite_params;
5007 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5008 ts_params->op_mpool,
5009 ts_params->session_mpool,
5010 ts_params->valid_devs[0],
5011 rte_cryptodev_driver_id_get(
5012 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5013 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5015 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5017 return TEST_SUCCESS;
5021 test_3DES_chain_openssl_all(void)
5023 struct crypto_testsuite_params *ts_params = &testsuite_params;
5026 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5027 ts_params->op_mpool,
5028 ts_params->session_mpool,
5029 ts_params->valid_devs[0],
5030 rte_cryptodev_driver_id_get(
5031 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5032 BLKCIPHER_3DES_CHAIN_TYPE);
5034 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5036 return TEST_SUCCESS;
5040 test_3DES_cipheronly_openssl_all(void)
5042 struct crypto_testsuite_params *ts_params = &testsuite_params;
5045 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5046 ts_params->op_mpool,
5047 ts_params->session_mpool,
5048 ts_params->valid_devs[0],
5049 rte_cryptodev_driver_id_get(
5050 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5051 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5053 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5055 return TEST_SUCCESS;
5058 /* ***** AEAD algorithm Tests ***** */
5061 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5062 enum rte_crypto_aead_operation op,
5063 const uint8_t *key, const uint8_t key_len,
5064 const uint16_t aad_len, const uint8_t auth_len,
5067 uint8_t aead_key[key_len];
5069 struct crypto_testsuite_params *ts_params = &testsuite_params;
5070 struct crypto_unittest_params *ut_params = &unittest_params;
5072 memcpy(aead_key, key, key_len);
5074 /* Setup AEAD Parameters */
5075 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5076 ut_params->aead_xform.next = NULL;
5077 ut_params->aead_xform.aead.algo = algo;
5078 ut_params->aead_xform.aead.op = op;
5079 ut_params->aead_xform.aead.key.data = aead_key;
5080 ut_params->aead_xform.aead.key.length = key_len;
5081 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5082 ut_params->aead_xform.aead.iv.length = iv_len;
5083 ut_params->aead_xform.aead.digest_length = auth_len;
5084 ut_params->aead_xform.aead.aad_length = aad_len;
5086 TEST_HEXDUMP(stdout, "key:", key, key_len);
5088 /* Create Crypto session*/
5089 ut_params->sess = rte_cryptodev_sym_session_create(
5090 ts_params->session_mpool);
5092 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5093 &ut_params->aead_xform, ts_params->session_mpool);
5095 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5101 create_aead_xform(struct rte_crypto_op *op,
5102 enum rte_crypto_aead_algorithm algo,
5103 enum rte_crypto_aead_operation aead_op,
5104 uint8_t *key, const uint8_t key_len,
5105 const uint8_t aad_len, const uint8_t auth_len,
5108 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5109 "failed to allocate space for crypto transform");
5111 struct rte_crypto_sym_op *sym_op = op->sym;
5113 /* Setup AEAD Parameters */
5114 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5115 sym_op->xform->next = NULL;
5116 sym_op->xform->aead.algo = algo;
5117 sym_op->xform->aead.op = aead_op;
5118 sym_op->xform->aead.key.data = key;
5119 sym_op->xform->aead.key.length = key_len;
5120 sym_op->xform->aead.iv.offset = IV_OFFSET;
5121 sym_op->xform->aead.iv.length = iv_len;
5122 sym_op->xform->aead.digest_length = auth_len;
5123 sym_op->xform->aead.aad_length = aad_len;
5125 TEST_HEXDUMP(stdout, "key:", key, key_len);
5131 create_aead_operation(enum rte_crypto_aead_operation op,
5132 const struct aead_test_data *tdata)
5134 struct crypto_testsuite_params *ts_params = &testsuite_params;
5135 struct crypto_unittest_params *ut_params = &unittest_params;
5137 uint8_t *plaintext, *ciphertext;
5138 unsigned int aad_pad_len, plaintext_pad_len;
5140 /* Generate Crypto op data structure */
5141 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5142 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5143 TEST_ASSERT_NOT_NULL(ut_params->op,
5144 "Failed to allocate symmetric crypto operation struct");
5146 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5148 /* Append aad data */
5149 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5150 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5151 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5153 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5154 "no room to append aad");
5156 sym_op->aead.aad.phys_addr =
5157 rte_pktmbuf_iova(ut_params->ibuf);
5158 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5159 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5160 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5163 /* Append IV at the end of the crypto operation*/
5164 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5165 uint8_t *, IV_OFFSET);
5167 /* Copy IV 1 byte after the IV pointer, according to the API */
5168 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5169 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5172 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5173 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5175 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5176 "no room to append aad");
5178 sym_op->aead.aad.phys_addr =
5179 rte_pktmbuf_iova(ut_params->ibuf);
5180 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5181 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5184 /* Append IV at the end of the crypto operation*/
5185 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5186 uint8_t *, IV_OFFSET);
5188 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5189 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5193 /* Append plaintext/ciphertext */
5194 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5195 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5196 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5198 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5200 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5201 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
5202 tdata->plaintext.len);
5204 if (ut_params->obuf) {
5205 ciphertext = (uint8_t *)rte_pktmbuf_append(
5207 plaintext_pad_len + aad_pad_len);
5208 TEST_ASSERT_NOT_NULL(ciphertext,
5209 "no room to append ciphertext");
5211 memset(ciphertext + aad_pad_len, 0,
5212 tdata->ciphertext.len);
5215 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5216 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5218 TEST_ASSERT_NOT_NULL(ciphertext,
5219 "no room to append ciphertext");
5221 memcpy(ciphertext, tdata->ciphertext.data,
5222 tdata->ciphertext.len);
5223 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
5224 tdata->ciphertext.len);
5226 if (ut_params->obuf) {
5227 plaintext = (uint8_t *)rte_pktmbuf_append(
5229 plaintext_pad_len + aad_pad_len);
5230 TEST_ASSERT_NOT_NULL(plaintext,
5231 "no room to append plaintext");
5233 memset(plaintext + aad_pad_len, 0,
5234 tdata->plaintext.len);
5238 /* Append digest data */
5239 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5240 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5241 ut_params->obuf ? ut_params->obuf :
5243 tdata->auth_tag.len);
5244 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5245 "no room to append digest");
5246 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5247 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5248 ut_params->obuf ? ut_params->obuf :
5253 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5254 ut_params->ibuf, tdata->auth_tag.len);
5255 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5256 "no room to append digest");
5257 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5259 plaintext_pad_len + aad_pad_len);
5261 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5262 tdata->auth_tag.len);
5263 TEST_HEXDUMP(stdout, "digest:",
5264 sym_op->aead.digest.data,
5265 tdata->auth_tag.len);
5268 sym_op->aead.data.length = tdata->plaintext.len;
5269 sym_op->aead.data.offset = aad_pad_len;
5275 test_authenticated_encryption(const struct aead_test_data *tdata)
5277 struct crypto_testsuite_params *ts_params = &testsuite_params;
5278 struct crypto_unittest_params *ut_params = &unittest_params;
5281 uint8_t *ciphertext, *auth_tag;
5282 uint16_t plaintext_pad_len;
5285 /* Create AEAD session */
5286 retval = create_aead_session(ts_params->valid_devs[0],
5288 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5289 tdata->key.data, tdata->key.len,
5290 tdata->aad.len, tdata->auth_tag.len,
5295 if (tdata->aad.len > MBUF_SIZE) {
5296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5297 /* Populate full size of add data */
5298 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5299 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5303 /* clear mbuf payload */
5304 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5305 rte_pktmbuf_tailroom(ut_params->ibuf));
5307 /* Create AEAD operation */
5308 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5312 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5314 ut_params->op->sym->m_src = ut_params->ibuf;
5316 /* Process crypto operation */
5317 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5318 ut_params->op), "failed to process sym crypto op");
5320 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5321 "crypto op processing failed");
5323 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5325 if (ut_params->op->sym->m_dst) {
5326 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5328 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5329 uint8_t *, plaintext_pad_len);
5331 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5333 ut_params->op->sym->cipher.data.offset);
5334 auth_tag = ciphertext + plaintext_pad_len;
5337 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5338 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5341 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5343 tdata->ciphertext.data,
5344 tdata->ciphertext.len,
5345 "Ciphertext data not as expected");
5347 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5349 tdata->auth_tag.data,
5350 tdata->auth_tag.len,
5351 "Generated auth tag not as expected");
5358 test_AES_GCM_authenticated_encryption_test_case_1(void)
5360 return test_authenticated_encryption(&gcm_test_case_1);
5364 test_AES_GCM_authenticated_encryption_test_case_2(void)
5366 return test_authenticated_encryption(&gcm_test_case_2);
5370 test_AES_GCM_authenticated_encryption_test_case_3(void)
5372 return test_authenticated_encryption(&gcm_test_case_3);
5376 test_AES_GCM_authenticated_encryption_test_case_4(void)
5378 return test_authenticated_encryption(&gcm_test_case_4);
5382 test_AES_GCM_authenticated_encryption_test_case_5(void)
5384 return test_authenticated_encryption(&gcm_test_case_5);
5388 test_AES_GCM_authenticated_encryption_test_case_6(void)
5390 return test_authenticated_encryption(&gcm_test_case_6);
5394 test_AES_GCM_authenticated_encryption_test_case_7(void)
5396 return test_authenticated_encryption(&gcm_test_case_7);
5400 test_AES_GCM_auth_encryption_test_case_192_1(void)
5402 return test_authenticated_encryption(&gcm_test_case_192_1);
5406 test_AES_GCM_auth_encryption_test_case_192_2(void)
5408 return test_authenticated_encryption(&gcm_test_case_192_2);
5412 test_AES_GCM_auth_encryption_test_case_192_3(void)
5414 return test_authenticated_encryption(&gcm_test_case_192_3);
5418 test_AES_GCM_auth_encryption_test_case_192_4(void)
5420 return test_authenticated_encryption(&gcm_test_case_192_4);
5424 test_AES_GCM_auth_encryption_test_case_192_5(void)
5426 return test_authenticated_encryption(&gcm_test_case_192_5);
5430 test_AES_GCM_auth_encryption_test_case_192_6(void)
5432 return test_authenticated_encryption(&gcm_test_case_192_6);
5436 test_AES_GCM_auth_encryption_test_case_192_7(void)
5438 return test_authenticated_encryption(&gcm_test_case_192_7);
5442 test_AES_GCM_auth_encryption_test_case_256_1(void)
5444 return test_authenticated_encryption(&gcm_test_case_256_1);
5448 test_AES_GCM_auth_encryption_test_case_256_2(void)
5450 return test_authenticated_encryption(&gcm_test_case_256_2);
5454 test_AES_GCM_auth_encryption_test_case_256_3(void)
5456 return test_authenticated_encryption(&gcm_test_case_256_3);
5460 test_AES_GCM_auth_encryption_test_case_256_4(void)
5462 return test_authenticated_encryption(&gcm_test_case_256_4);
5466 test_AES_GCM_auth_encryption_test_case_256_5(void)
5468 return test_authenticated_encryption(&gcm_test_case_256_5);
5472 test_AES_GCM_auth_encryption_test_case_256_6(void)
5474 return test_authenticated_encryption(&gcm_test_case_256_6);
5478 test_AES_GCM_auth_encryption_test_case_256_7(void)
5480 return test_authenticated_encryption(&gcm_test_case_256_7);
5484 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5486 return test_authenticated_encryption(&gcm_test_case_aad_1);
5490 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5492 return test_authenticated_encryption(&gcm_test_case_aad_2);
5496 test_authenticated_decryption(const struct aead_test_data *tdata)
5498 struct crypto_testsuite_params *ts_params = &testsuite_params;
5499 struct crypto_unittest_params *ut_params = &unittest_params;
5505 /* Create AEAD session */
5506 retval = create_aead_session(ts_params->valid_devs[0],
5508 RTE_CRYPTO_AEAD_OP_DECRYPT,
5509 tdata->key.data, tdata->key.len,
5510 tdata->aad.len, tdata->auth_tag.len,
5515 /* alloc mbuf and set payload */
5516 if (tdata->aad.len > MBUF_SIZE) {
5517 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5518 /* Populate full size of add data */
5519 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5520 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5522 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5524 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5525 rte_pktmbuf_tailroom(ut_params->ibuf));
5527 /* Create AEAD operation */
5528 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5532 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5534 ut_params->op->sym->m_src = ut_params->ibuf;
5536 /* Process crypto operation */
5537 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5538 ut_params->op), "failed to process sym crypto op");
5540 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5541 "crypto op processing failed");
5543 if (ut_params->op->sym->m_dst)
5544 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5547 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5549 ut_params->op->sym->cipher.data.offset);
5551 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5554 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5556 tdata->plaintext.data,
5557 tdata->plaintext.len,
5558 "Plaintext data not as expected");
5560 TEST_ASSERT_EQUAL(ut_params->op->status,
5561 RTE_CRYPTO_OP_STATUS_SUCCESS,
5562 "Authentication failed");
5567 test_AES_GCM_authenticated_decryption_test_case_1(void)
5569 return test_authenticated_decryption(&gcm_test_case_1);
5573 test_AES_GCM_authenticated_decryption_test_case_2(void)
5575 return test_authenticated_decryption(&gcm_test_case_2);
5579 test_AES_GCM_authenticated_decryption_test_case_3(void)
5581 return test_authenticated_decryption(&gcm_test_case_3);
5585 test_AES_GCM_authenticated_decryption_test_case_4(void)
5587 return test_authenticated_decryption(&gcm_test_case_4);
5591 test_AES_GCM_authenticated_decryption_test_case_5(void)
5593 return test_authenticated_decryption(&gcm_test_case_5);
5597 test_AES_GCM_authenticated_decryption_test_case_6(void)
5599 return test_authenticated_decryption(&gcm_test_case_6);
5603 test_AES_GCM_authenticated_decryption_test_case_7(void)
5605 return test_authenticated_decryption(&gcm_test_case_7);
5609 test_AES_GCM_auth_decryption_test_case_192_1(void)
5611 return test_authenticated_decryption(&gcm_test_case_192_1);
5615 test_AES_GCM_auth_decryption_test_case_192_2(void)
5617 return test_authenticated_decryption(&gcm_test_case_192_2);
5621 test_AES_GCM_auth_decryption_test_case_192_3(void)
5623 return test_authenticated_decryption(&gcm_test_case_192_3);
5627 test_AES_GCM_auth_decryption_test_case_192_4(void)
5629 return test_authenticated_decryption(&gcm_test_case_192_4);
5633 test_AES_GCM_auth_decryption_test_case_192_5(void)
5635 return test_authenticated_decryption(&gcm_test_case_192_5);
5639 test_AES_GCM_auth_decryption_test_case_192_6(void)
5641 return test_authenticated_decryption(&gcm_test_case_192_6);
5645 test_AES_GCM_auth_decryption_test_case_192_7(void)
5647 return test_authenticated_decryption(&gcm_test_case_192_7);
5651 test_AES_GCM_auth_decryption_test_case_256_1(void)
5653 return test_authenticated_decryption(&gcm_test_case_256_1);
5657 test_AES_GCM_auth_decryption_test_case_256_2(void)
5659 return test_authenticated_decryption(&gcm_test_case_256_2);
5663 test_AES_GCM_auth_decryption_test_case_256_3(void)
5665 return test_authenticated_decryption(&gcm_test_case_256_3);
5669 test_AES_GCM_auth_decryption_test_case_256_4(void)
5671 return test_authenticated_decryption(&gcm_test_case_256_4);
5675 test_AES_GCM_auth_decryption_test_case_256_5(void)
5677 return test_authenticated_decryption(&gcm_test_case_256_5);
5681 test_AES_GCM_auth_decryption_test_case_256_6(void)
5683 return test_authenticated_decryption(&gcm_test_case_256_6);
5687 test_AES_GCM_auth_decryption_test_case_256_7(void)
5689 return test_authenticated_decryption(&gcm_test_case_256_7);
5693 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5695 return test_authenticated_decryption(&gcm_test_case_aad_1);
5699 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5701 return test_authenticated_decryption(&gcm_test_case_aad_2);
5705 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5707 struct crypto_testsuite_params *ts_params = &testsuite_params;
5708 struct crypto_unittest_params *ut_params = &unittest_params;
5711 uint8_t *ciphertext, *auth_tag;
5712 uint16_t plaintext_pad_len;
5714 /* Create AEAD session */
5715 retval = create_aead_session(ts_params->valid_devs[0],
5717 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5718 tdata->key.data, tdata->key.len,
5719 tdata->aad.len, tdata->auth_tag.len,
5724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5725 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5727 /* clear mbuf payload */
5728 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5729 rte_pktmbuf_tailroom(ut_params->ibuf));
5730 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5731 rte_pktmbuf_tailroom(ut_params->obuf));
5733 /* Create AEAD operation */
5734 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5738 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5740 ut_params->op->sym->m_src = ut_params->ibuf;
5741 ut_params->op->sym->m_dst = ut_params->obuf;
5743 /* Process crypto operation */
5744 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5745 ut_params->op), "failed to process sym crypto op");
5747 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5748 "crypto op processing failed");
5750 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5752 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5753 ut_params->op->sym->cipher.data.offset);
5754 auth_tag = ciphertext + plaintext_pad_len;
5756 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5757 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5760 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5762 tdata->ciphertext.data,
5763 tdata->ciphertext.len,
5764 "Ciphertext data not as expected");
5766 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5768 tdata->auth_tag.data,
5769 tdata->auth_tag.len,
5770 "Generated auth tag not as expected");
5777 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5779 return test_authenticated_encryption_oop(&gcm_test_case_5);
5783 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5785 struct crypto_testsuite_params *ts_params = &testsuite_params;
5786 struct crypto_unittest_params *ut_params = &unittest_params;
5791 /* Create AEAD session */
5792 retval = create_aead_session(ts_params->valid_devs[0],
5794 RTE_CRYPTO_AEAD_OP_DECRYPT,
5795 tdata->key.data, tdata->key.len,
5796 tdata->aad.len, tdata->auth_tag.len,
5801 /* alloc mbuf and set payload */
5802 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5803 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5806 rte_pktmbuf_tailroom(ut_params->ibuf));
5807 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5808 rte_pktmbuf_tailroom(ut_params->obuf));
5810 /* Create AEAD operation */
5811 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5815 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5817 ut_params->op->sym->m_src = ut_params->ibuf;
5818 ut_params->op->sym->m_dst = ut_params->obuf;
5820 /* Process crypto operation */
5821 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5822 ut_params->op), "failed to process sym crypto op");
5824 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5825 "crypto op processing failed");
5827 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5828 ut_params->op->sym->cipher.data.offset);
5830 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5833 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5835 tdata->plaintext.data,
5836 tdata->plaintext.len,
5837 "Plaintext data not as expected");
5839 TEST_ASSERT_EQUAL(ut_params->op->status,
5840 RTE_CRYPTO_OP_STATUS_SUCCESS,
5841 "Authentication failed");
5846 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5848 return test_authenticated_decryption_oop(&gcm_test_case_5);
5852 test_authenticated_encryption_sessionless(
5853 const struct aead_test_data *tdata)
5855 struct crypto_testsuite_params *ts_params = &testsuite_params;
5856 struct crypto_unittest_params *ut_params = &unittest_params;
5859 uint8_t *ciphertext, *auth_tag;
5860 uint16_t plaintext_pad_len;
5861 uint8_t key[tdata->key.len + 1];
5863 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5865 /* clear mbuf payload */
5866 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5867 rte_pktmbuf_tailroom(ut_params->ibuf));
5869 /* Create AEAD operation */
5870 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5874 /* Create GCM xform */
5875 memcpy(key, tdata->key.data, tdata->key.len);
5876 retval = create_aead_xform(ut_params->op,
5878 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5879 key, tdata->key.len,
5880 tdata->aad.len, tdata->auth_tag.len,
5885 ut_params->op->sym->m_src = ut_params->ibuf;
5887 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5888 RTE_CRYPTO_OP_SESSIONLESS,
5889 "crypto op session type not sessionless");
5891 /* Process crypto operation */
5892 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5893 ut_params->op), "failed to process sym crypto op");
5895 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5897 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5898 "crypto op status not success");
5900 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5902 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5903 ut_params->op->sym->cipher.data.offset);
5904 auth_tag = ciphertext + plaintext_pad_len;
5906 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5907 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5910 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5912 tdata->ciphertext.data,
5913 tdata->ciphertext.len,
5914 "Ciphertext data not as expected");
5916 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5918 tdata->auth_tag.data,
5919 tdata->auth_tag.len,
5920 "Generated auth tag not as expected");
5927 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5929 return test_authenticated_encryption_sessionless(
5934 test_authenticated_decryption_sessionless(
5935 const struct aead_test_data *tdata)
5937 struct crypto_testsuite_params *ts_params = &testsuite_params;
5938 struct crypto_unittest_params *ut_params = &unittest_params;
5942 uint8_t key[tdata->key.len + 1];
5944 /* alloc mbuf and set payload */
5945 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5947 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5948 rte_pktmbuf_tailroom(ut_params->ibuf));
5950 /* Create AEAD operation */
5951 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5955 /* Create AEAD xform */
5956 memcpy(key, tdata->key.data, tdata->key.len);
5957 retval = create_aead_xform(ut_params->op,
5959 RTE_CRYPTO_AEAD_OP_DECRYPT,
5960 key, tdata->key.len,
5961 tdata->aad.len, tdata->auth_tag.len,
5966 ut_params->op->sym->m_src = ut_params->ibuf;
5968 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5969 RTE_CRYPTO_OP_SESSIONLESS,
5970 "crypto op session type not sessionless");
5972 /* Process crypto operation */
5973 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5974 ut_params->op), "failed to process sym crypto op");
5976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5978 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5979 "crypto op status not success");
5981 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5982 ut_params->op->sym->cipher.data.offset);
5984 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5987 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5989 tdata->plaintext.data,
5990 tdata->plaintext.len,
5991 "Plaintext data not as expected");
5993 TEST_ASSERT_EQUAL(ut_params->op->status,
5994 RTE_CRYPTO_OP_STATUS_SUCCESS,
5995 "Authentication failed");
6000 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6002 return test_authenticated_decryption_sessionless(
6007 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6009 return test_authenticated_encryption(&ccm_test_case_128_1);
6013 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6015 return test_authenticated_encryption(&ccm_test_case_128_2);
6019 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6021 return test_authenticated_encryption(&ccm_test_case_128_3);
6025 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6027 return test_authenticated_decryption(&ccm_test_case_128_1);
6031 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6033 return test_authenticated_decryption(&ccm_test_case_128_2);
6037 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6039 return test_authenticated_decryption(&ccm_test_case_128_3);
6043 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6045 return test_authenticated_encryption(&ccm_test_case_192_1);
6049 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6051 return test_authenticated_encryption(&ccm_test_case_192_2);
6055 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6057 return test_authenticated_encryption(&ccm_test_case_192_3);
6061 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6063 return test_authenticated_decryption(&ccm_test_case_192_1);
6067 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6069 return test_authenticated_decryption(&ccm_test_case_192_2);
6073 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6075 return test_authenticated_decryption(&ccm_test_case_192_3);
6079 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6081 return test_authenticated_encryption(&ccm_test_case_256_1);
6085 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6087 return test_authenticated_encryption(&ccm_test_case_256_2);
6091 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6093 return test_authenticated_encryption(&ccm_test_case_256_3);
6097 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6099 return test_authenticated_decryption(&ccm_test_case_256_1);
6103 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6105 return test_authenticated_decryption(&ccm_test_case_256_2);
6109 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6111 return test_authenticated_decryption(&ccm_test_case_256_3);
6117 struct crypto_testsuite_params *ts_params = &testsuite_params;
6118 struct rte_cryptodev_stats stats;
6119 struct rte_cryptodev *dev;
6120 cryptodev_stats_get_t temp_pfn;
6122 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6123 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6124 &stats) == -ENODEV),
6125 "rte_cryptodev_stats_get invalid dev failed");
6126 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6127 "rte_cryptodev_stats_get invalid Param failed");
6128 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6129 temp_pfn = dev->dev_ops->stats_get;
6130 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6131 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6133 "rte_cryptodev_stats_get invalid Param failed");
6134 dev->dev_ops->stats_get = temp_pfn;
6136 /* Test expected values */
6138 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6140 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6142 "rte_cryptodev_stats_get failed");
6143 TEST_ASSERT((stats.enqueued_count == 1),
6144 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6145 TEST_ASSERT((stats.dequeued_count == 1),
6146 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6147 TEST_ASSERT((stats.enqueue_err_count == 0),
6148 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6149 TEST_ASSERT((stats.dequeue_err_count == 0),
6150 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6152 /* invalid device but should ignore and not reset device stats*/
6153 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6154 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6156 "rte_cryptodev_stats_get failed");
6157 TEST_ASSERT((stats.enqueued_count == 1),
6158 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6160 /* check that a valid reset clears stats */
6161 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6162 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6164 "rte_cryptodev_stats_get failed");
6165 TEST_ASSERT((stats.enqueued_count == 0),
6166 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6167 TEST_ASSERT((stats.dequeued_count == 0),
6168 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6170 return TEST_SUCCESS;
6173 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6174 struct crypto_unittest_params *ut_params,
6175 enum rte_crypto_auth_operation op,
6176 const struct HMAC_MD5_vector *test_case)
6180 memcpy(key, test_case->key.data, test_case->key.len);
6182 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6183 ut_params->auth_xform.next = NULL;
6184 ut_params->auth_xform.auth.op = op;
6186 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6188 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6189 ut_params->auth_xform.auth.key.length = test_case->key.len;
6190 ut_params->auth_xform.auth.key.data = key;
6192 ut_params->sess = rte_cryptodev_sym_session_create(
6193 ts_params->session_mpool);
6195 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6196 ut_params->sess, &ut_params->auth_xform,
6197 ts_params->session_mpool);
6199 if (ut_params->sess == NULL)
6202 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6205 rte_pktmbuf_tailroom(ut_params->ibuf));
6210 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6211 const struct HMAC_MD5_vector *test_case,
6212 uint8_t **plaintext)
6214 uint16_t plaintext_pad_len;
6216 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6218 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6221 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6223 memcpy(*plaintext, test_case->plaintext.data,
6224 test_case->plaintext.len);
6226 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6227 ut_params->ibuf, MD5_DIGEST_LEN);
6228 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6229 "no room to append digest");
6230 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6231 ut_params->ibuf, plaintext_pad_len);
6233 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6234 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6235 test_case->auth_tag.len);
6238 sym_op->auth.data.offset = 0;
6239 sym_op->auth.data.length = test_case->plaintext.len;
6241 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6242 ut_params->op->sym->m_src = ut_params->ibuf;
6248 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6250 uint16_t plaintext_pad_len;
6251 uint8_t *plaintext, *auth_tag;
6253 struct crypto_testsuite_params *ts_params = &testsuite_params;
6254 struct crypto_unittest_params *ut_params = &unittest_params;
6256 if (MD5_HMAC_create_session(ts_params, ut_params,
6257 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6260 /* Generate Crypto op data structure */
6261 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6262 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6263 TEST_ASSERT_NOT_NULL(ut_params->op,
6264 "Failed to allocate symmetric crypto operation struct");
6266 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6269 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6272 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6273 ut_params->op), "failed to process sym crypto op");
6275 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6276 "crypto op processing failed");
6278 if (ut_params->op->sym->m_dst) {
6279 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6280 uint8_t *, plaintext_pad_len);
6282 auth_tag = plaintext + plaintext_pad_len;
6285 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6287 test_case->auth_tag.data,
6288 test_case->auth_tag.len,
6289 "HMAC_MD5 generated tag not as expected");
6291 return TEST_SUCCESS;
6295 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6299 struct crypto_testsuite_params *ts_params = &testsuite_params;
6300 struct crypto_unittest_params *ut_params = &unittest_params;
6302 if (MD5_HMAC_create_session(ts_params, ut_params,
6303 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6307 /* Generate Crypto op data structure */
6308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6310 TEST_ASSERT_NOT_NULL(ut_params->op,
6311 "Failed to allocate symmetric crypto operation struct");
6313 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6316 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6317 ut_params->op), "failed to process sym crypto op");
6319 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6320 "HMAC_MD5 crypto op processing failed");
6322 return TEST_SUCCESS;
6326 test_MD5_HMAC_generate_case_1(void)
6328 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6332 test_MD5_HMAC_verify_case_1(void)
6334 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6338 test_MD5_HMAC_generate_case_2(void)
6340 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6344 test_MD5_HMAC_verify_case_2(void)
6346 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6350 test_multi_session(void)
6352 struct crypto_testsuite_params *ts_params = &testsuite_params;
6353 struct crypto_unittest_params *ut_params = &unittest_params;
6355 struct rte_cryptodev_info dev_info;
6356 struct rte_cryptodev_sym_session **sessions;
6360 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6361 aes_cbc_key, hmac_sha512_key);
6364 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6366 sessions = rte_malloc(NULL,
6367 (sizeof(struct rte_cryptodev_sym_session *) *
6368 dev_info.sym.max_nb_sessions) + 1, 0);
6370 /* Create multiple crypto sessions*/
6371 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6373 sessions[i] = rte_cryptodev_sym_session_create(
6374 ts_params->session_mpool);
6376 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6377 sessions[i], &ut_params->auth_xform,
6378 ts_params->session_mpool);
6379 TEST_ASSERT_NOT_NULL(sessions[i],
6380 "Session creation failed at session number %u",
6383 /* Attempt to send a request on each session */
6384 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6388 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6389 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6391 "Failed to perform decrypt on request number %u.", i);
6392 /* free crypto operation structure */
6394 rte_crypto_op_free(ut_params->op);
6397 * free mbuf - both obuf and ibuf are usually the same,
6398 * so check if they point at the same address is necessary,
6399 * to avoid freeing the mbuf twice.
6401 if (ut_params->obuf) {
6402 rte_pktmbuf_free(ut_params->obuf);
6403 if (ut_params->ibuf == ut_params->obuf)
6404 ut_params->ibuf = 0;
6405 ut_params->obuf = 0;
6407 if (ut_params->ibuf) {
6408 rte_pktmbuf_free(ut_params->ibuf);
6409 ut_params->ibuf = 0;
6413 /* Next session create should fail */
6414 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6415 sessions[i], &ut_params->auth_xform,
6416 ts_params->session_mpool);
6417 TEST_ASSERT_NULL(sessions[i],
6418 "Session creation succeeded unexpectedly!");
6420 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6421 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6423 rte_cryptodev_sym_session_free(sessions[i]);
6428 return TEST_SUCCESS;
6431 struct multi_session_params {
6432 struct crypto_unittest_params ut_params;
6433 uint8_t *cipher_key;
6435 const uint8_t *cipher;
6436 const uint8_t *digest;
6440 #define MB_SESSION_NUMBER 3
6443 test_multi_session_random_usage(void)
6445 struct crypto_testsuite_params *ts_params = &testsuite_params;
6446 struct rte_cryptodev_info dev_info;
6447 struct rte_cryptodev_sym_session **sessions;
6449 struct multi_session_params ut_paramz[] = {
6452 .cipher_key = ms_aes_cbc_key0,
6453 .hmac_key = ms_hmac_key0,
6454 .cipher = ms_aes_cbc_cipher0,
6455 .digest = ms_hmac_digest0,
6456 .iv = ms_aes_cbc_iv0
6459 .cipher_key = ms_aes_cbc_key1,
6460 .hmac_key = ms_hmac_key1,
6461 .cipher = ms_aes_cbc_cipher1,
6462 .digest = ms_hmac_digest1,
6463 .iv = ms_aes_cbc_iv1
6466 .cipher_key = ms_aes_cbc_key2,
6467 .hmac_key = ms_hmac_key2,
6468 .cipher = ms_aes_cbc_cipher2,
6469 .digest = ms_hmac_digest2,
6470 .iv = ms_aes_cbc_iv2
6475 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6477 sessions = rte_malloc(NULL,
6478 (sizeof(struct rte_cryptodev_sym_session *)
6479 * dev_info.sym.max_nb_sessions) + 1, 0);
6481 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6482 sessions[i] = rte_cryptodev_sym_session_create(
6483 ts_params->session_mpool);
6485 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6486 sizeof(struct crypto_unittest_params));
6488 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6489 &ut_paramz[i].ut_params,
6490 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6492 /* Create multiple crypto sessions*/
6493 rte_cryptodev_sym_session_init(
6494 ts_params->valid_devs[0],
6496 &ut_paramz[i].ut_params.auth_xform,
6497 ts_params->session_mpool);
6499 TEST_ASSERT_NOT_NULL(sessions[i],
6500 "Session creation failed at session number %u",
6506 for (i = 0; i < 40000; i++) {
6508 j = rand() % MB_SESSION_NUMBER;
6510 TEST_ASSERT_SUCCESS(
6511 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6513 &ut_paramz[j].ut_params,
6514 ts_params, ut_paramz[j].cipher,
6515 ut_paramz[j].digest,
6517 "Failed to perform decrypt on request number %u.", i);
6519 if (ut_paramz[j].ut_params.op)
6520 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6523 * free mbuf - both obuf and ibuf are usually the same,
6524 * so check if they point at the same address is necessary,
6525 * to avoid freeing the mbuf twice.
6527 if (ut_paramz[j].ut_params.obuf) {
6528 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6529 if (ut_paramz[j].ut_params.ibuf
6530 == ut_paramz[j].ut_params.obuf)
6531 ut_paramz[j].ut_params.ibuf = 0;
6532 ut_paramz[j].ut_params.obuf = 0;
6534 if (ut_paramz[j].ut_params.ibuf) {
6535 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6536 ut_paramz[j].ut_params.ibuf = 0;
6540 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6541 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6543 rte_cryptodev_sym_session_free(sessions[i]);
6548 return TEST_SUCCESS;
6552 test_null_cipher_only_operation(void)
6554 struct crypto_testsuite_params *ts_params = &testsuite_params;
6555 struct crypto_unittest_params *ut_params = &unittest_params;
6557 /* Generate test mbuf data and space for digest */
6558 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6559 catch_22_quote, QUOTE_512_BYTES, 0);
6561 /* Setup Cipher Parameters */
6562 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6563 ut_params->cipher_xform.next = NULL;
6565 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6566 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6568 ut_params->sess = rte_cryptodev_sym_session_create(
6569 ts_params->session_mpool);
6571 /* Create Crypto session*/
6572 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6574 &ut_params->cipher_xform,
6575 ts_params->session_mpool);
6576 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6578 /* Generate Crypto op data structure */
6579 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6580 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6581 TEST_ASSERT_NOT_NULL(ut_params->op,
6582 "Failed to allocate symmetric crypto operation struct");
6584 /* Set crypto operation data parameters */
6585 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6587 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6589 /* set crypto operation source mbuf */
6590 sym_op->m_src = ut_params->ibuf;
6592 sym_op->cipher.data.offset = 0;
6593 sym_op->cipher.data.length = QUOTE_512_BYTES;
6595 /* Process crypto operation */
6596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6598 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6600 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6601 "crypto operation processing failed");
6604 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6605 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6608 "Ciphertext data not as expected");
6610 return TEST_SUCCESS;
6614 test_null_auth_only_operation(void)
6616 struct crypto_testsuite_params *ts_params = &testsuite_params;
6617 struct crypto_unittest_params *ut_params = &unittest_params;
6619 /* Generate test mbuf data and space for digest */
6620 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6621 catch_22_quote, QUOTE_512_BYTES, 0);
6623 /* Setup HMAC Parameters */
6624 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6625 ut_params->auth_xform.next = NULL;
6627 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6628 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6630 ut_params->sess = rte_cryptodev_sym_session_create(
6631 ts_params->session_mpool);
6633 /* Create Crypto session*/
6634 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6635 ut_params->sess, &ut_params->auth_xform,
6636 ts_params->session_mpool);
6637 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6639 /* Generate Crypto op data structure */
6640 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6641 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6642 TEST_ASSERT_NOT_NULL(ut_params->op,
6643 "Failed to allocate symmetric crypto operation struct");
6645 /* Set crypto operation data parameters */
6646 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6648 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6650 sym_op->m_src = ut_params->ibuf;
6652 sym_op->auth.data.offset = 0;
6653 sym_op->auth.data.length = QUOTE_512_BYTES;
6655 /* Process crypto operation */
6656 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6658 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6660 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6661 "crypto operation processing failed");
6663 return TEST_SUCCESS;
6667 test_null_cipher_auth_operation(void)
6669 struct crypto_testsuite_params *ts_params = &testsuite_params;
6670 struct crypto_unittest_params *ut_params = &unittest_params;
6672 /* Generate test mbuf data and space for digest */
6673 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6674 catch_22_quote, QUOTE_512_BYTES, 0);
6676 /* Setup Cipher Parameters */
6677 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6678 ut_params->cipher_xform.next = &ut_params->auth_xform;
6680 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6681 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6683 /* Setup HMAC Parameters */
6684 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6685 ut_params->auth_xform.next = NULL;
6687 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6688 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6690 ut_params->sess = rte_cryptodev_sym_session_create(
6691 ts_params->session_mpool);
6693 /* Create Crypto session*/
6694 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6695 ut_params->sess, &ut_params->cipher_xform,
6696 ts_params->session_mpool);
6697 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6699 /* Generate Crypto op data structure */
6700 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6701 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6702 TEST_ASSERT_NOT_NULL(ut_params->op,
6703 "Failed to allocate symmetric crypto operation struct");
6705 /* Set crypto operation data parameters */
6706 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6708 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6710 sym_op->m_src = ut_params->ibuf;
6712 sym_op->cipher.data.offset = 0;
6713 sym_op->cipher.data.length = QUOTE_512_BYTES;
6715 sym_op->auth.data.offset = 0;
6716 sym_op->auth.data.length = QUOTE_512_BYTES;
6718 /* Process crypto operation */
6719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6721 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6723 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6724 "crypto operation processing failed");
6727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6728 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6731 "Ciphertext data not as expected");
6733 return TEST_SUCCESS;
6737 test_null_auth_cipher_operation(void)
6739 struct crypto_testsuite_params *ts_params = &testsuite_params;
6740 struct crypto_unittest_params *ut_params = &unittest_params;
6742 /* Generate test mbuf data and space for digest */
6743 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6744 catch_22_quote, QUOTE_512_BYTES, 0);
6746 /* Setup Cipher Parameters */
6747 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6748 ut_params->cipher_xform.next = NULL;
6750 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6751 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6753 /* Setup HMAC Parameters */
6754 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6755 ut_params->auth_xform.next = &ut_params->cipher_xform;
6757 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6758 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6760 ut_params->sess = rte_cryptodev_sym_session_create(
6761 ts_params->session_mpool);
6763 /* Create Crypto session*/
6764 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6765 ut_params->sess, &ut_params->cipher_xform,
6766 ts_params->session_mpool);
6767 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6769 /* Generate Crypto op data structure */
6770 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6771 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6772 TEST_ASSERT_NOT_NULL(ut_params->op,
6773 "Failed to allocate symmetric crypto operation struct");
6775 /* Set crypto operation data parameters */
6776 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6778 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6780 sym_op->m_src = ut_params->ibuf;
6782 sym_op->cipher.data.offset = 0;
6783 sym_op->cipher.data.length = QUOTE_512_BYTES;
6785 sym_op->auth.data.offset = 0;
6786 sym_op->auth.data.length = QUOTE_512_BYTES;
6788 /* Process crypto operation */
6789 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6791 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6793 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6794 "crypto operation processing failed");
6797 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6798 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6801 "Ciphertext data not as expected");
6803 return TEST_SUCCESS;
6808 test_null_invalid_operation(void)
6810 struct crypto_testsuite_params *ts_params = &testsuite_params;
6811 struct crypto_unittest_params *ut_params = &unittest_params;
6814 /* Setup Cipher Parameters */
6815 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6816 ut_params->cipher_xform.next = NULL;
6818 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6819 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6821 ut_params->sess = rte_cryptodev_sym_session_create(
6822 ts_params->session_mpool);
6824 /* Create Crypto session*/
6825 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6826 ut_params->sess, &ut_params->cipher_xform,
6827 ts_params->session_mpool);
6828 TEST_ASSERT(ret < 0,
6829 "Session creation succeeded unexpectedly");
6832 /* Setup HMAC Parameters */
6833 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6834 ut_params->auth_xform.next = NULL;
6836 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6837 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6839 ut_params->sess = rte_cryptodev_sym_session_create(
6840 ts_params->session_mpool);
6842 /* Create Crypto session*/
6843 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6844 ut_params->sess, &ut_params->auth_xform,
6845 ts_params->session_mpool);
6846 TEST_ASSERT(ret < 0,
6847 "Session creation succeeded unexpectedly");
6849 return TEST_SUCCESS;
6853 #define NULL_BURST_LENGTH (32)
6856 test_null_burst_operation(void)
6858 struct crypto_testsuite_params *ts_params = &testsuite_params;
6859 struct crypto_unittest_params *ut_params = &unittest_params;
6861 unsigned i, burst_len = NULL_BURST_LENGTH;
6863 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6864 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6866 /* Setup Cipher Parameters */
6867 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6868 ut_params->cipher_xform.next = &ut_params->auth_xform;
6870 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6871 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6873 /* Setup HMAC Parameters */
6874 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6875 ut_params->auth_xform.next = NULL;
6877 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6878 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6880 ut_params->sess = rte_cryptodev_sym_session_create(
6881 ts_params->session_mpool);
6883 /* Create Crypto session*/
6884 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6885 ut_params->sess, &ut_params->cipher_xform,
6886 ts_params->session_mpool);
6887 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6889 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6890 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6891 burst_len, "failed to generate burst of crypto ops");
6893 /* Generate an operation for each mbuf in burst */
6894 for (i = 0; i < burst_len; i++) {
6895 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6897 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6899 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6903 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6905 burst[i]->sym->m_src = m;
6908 /* Process crypto operation */
6909 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6910 0, burst, burst_len),
6912 "Error enqueuing burst");
6914 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6915 0, burst_dequeued, burst_len),
6917 "Error dequeuing burst");
6920 for (i = 0; i < burst_len; i++) {
6922 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6923 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6925 "data not as expected");
6927 rte_pktmbuf_free(burst[i]->sym->m_src);
6928 rte_crypto_op_free(burst[i]);
6931 return TEST_SUCCESS;
6935 generate_gmac_large_plaintext(uint8_t *data)
6939 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6940 memcpy(&data[i], &data[0], 32);
6944 create_gmac_operation(enum rte_crypto_auth_operation op,
6945 const struct gmac_test_data *tdata)
6947 struct crypto_testsuite_params *ts_params = &testsuite_params;
6948 struct crypto_unittest_params *ut_params = &unittest_params;
6949 struct rte_crypto_sym_op *sym_op;
6951 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6953 /* Generate Crypto op data structure */
6954 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6955 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6956 TEST_ASSERT_NOT_NULL(ut_params->op,
6957 "Failed to allocate symmetric crypto operation struct");
6959 sym_op = ut_params->op->sym;
6961 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6962 ut_params->ibuf, tdata->gmac_tag.len);
6963 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6964 "no room to append digest");
6966 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6967 ut_params->ibuf, plaintext_pad_len);
6969 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6970 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6971 tdata->gmac_tag.len);
6972 TEST_HEXDUMP(stdout, "digest:",
6973 sym_op->auth.digest.data,
6974 tdata->gmac_tag.len);
6977 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6978 uint8_t *, IV_OFFSET);
6980 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6982 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6984 sym_op->cipher.data.length = 0;
6985 sym_op->cipher.data.offset = 0;
6987 sym_op->auth.data.offset = 0;
6988 sym_op->auth.data.length = tdata->plaintext.len;
6993 static int create_gmac_session(uint8_t dev_id,
6994 const struct gmac_test_data *tdata,
6995 enum rte_crypto_auth_operation auth_op)
6997 uint8_t auth_key[tdata->key.len];
6999 struct crypto_testsuite_params *ts_params = &testsuite_params;
7000 struct crypto_unittest_params *ut_params = &unittest_params;
7002 memcpy(auth_key, tdata->key.data, tdata->key.len);
7004 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7005 ut_params->auth_xform.next = NULL;
7007 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7008 ut_params->auth_xform.auth.op = auth_op;
7009 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7010 ut_params->auth_xform.auth.key.length = tdata->key.len;
7011 ut_params->auth_xform.auth.key.data = auth_key;
7012 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7013 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7016 ut_params->sess = rte_cryptodev_sym_session_create(
7017 ts_params->session_mpool);
7019 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7020 &ut_params->auth_xform,
7021 ts_params->session_mpool);
7023 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7029 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7031 struct crypto_testsuite_params *ts_params = &testsuite_params;
7032 struct crypto_unittest_params *ut_params = &unittest_params;
7036 uint8_t *auth_tag, *plaintext;
7037 uint16_t plaintext_pad_len;
7039 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7040 "No GMAC length in the source data");
7042 retval = create_gmac_session(ts_params->valid_devs[0],
7043 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7048 if (tdata->plaintext.len > MBUF_SIZE)
7049 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7051 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7052 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7053 "Failed to allocate input buffer in mempool");
7055 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7056 rte_pktmbuf_tailroom(ut_params->ibuf));
7058 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7060 * Runtime generate the large plain text instead of use hard code
7061 * plain text vector. It is done to avoid create huge source file
7062 * with the test vector.
7064 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7065 generate_gmac_large_plaintext(tdata->plaintext.data);
7067 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7069 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7071 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7072 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7073 tdata->plaintext.len);
7075 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7081 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7083 ut_params->op->sym->m_src = ut_params->ibuf;
7085 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7086 ut_params->op), "failed to process sym crypto op");
7088 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7089 "crypto op processing failed");
7091 if (ut_params->op->sym->m_dst) {
7092 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7093 uint8_t *, plaintext_pad_len);
7095 auth_tag = plaintext + plaintext_pad_len;
7098 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7100 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7102 tdata->gmac_tag.data,
7103 tdata->gmac_tag.len,
7104 "GMAC Generated auth tag not as expected");
7110 test_AES_GMAC_authentication_test_case_1(void)
7112 return test_AES_GMAC_authentication(&gmac_test_case_1);
7116 test_AES_GMAC_authentication_test_case_2(void)
7118 return test_AES_GMAC_authentication(&gmac_test_case_2);
7122 test_AES_GMAC_authentication_test_case_3(void)
7124 return test_AES_GMAC_authentication(&gmac_test_case_3);
7128 test_AES_GMAC_authentication_test_case_4(void)
7130 return test_AES_GMAC_authentication(&gmac_test_case_4);
7134 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7136 struct crypto_testsuite_params *ts_params = &testsuite_params;
7137 struct crypto_unittest_params *ut_params = &unittest_params;
7139 uint32_t plaintext_pad_len;
7142 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7143 "No GMAC length in the source data");
7145 retval = create_gmac_session(ts_params->valid_devs[0],
7146 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7151 if (tdata->plaintext.len > MBUF_SIZE)
7152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7155 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7156 "Failed to allocate input buffer in mempool");
7158 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7159 rte_pktmbuf_tailroom(ut_params->ibuf));
7161 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7164 * Runtime generate the large plain text instead of use hard code
7165 * plain text vector. It is done to avoid create huge source file
7166 * with the test vector.
7168 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7169 generate_gmac_large_plaintext(tdata->plaintext.data);
7171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7173 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7175 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7176 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7177 tdata->plaintext.len);
7179 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7185 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7187 ut_params->op->sym->m_src = ut_params->ibuf;
7189 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7190 ut_params->op), "failed to process sym crypto op");
7192 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7193 "crypto op processing failed");
7200 test_AES_GMAC_authentication_verify_test_case_1(void)
7202 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7206 test_AES_GMAC_authentication_verify_test_case_2(void)
7208 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7212 test_AES_GMAC_authentication_verify_test_case_3(void)
7214 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7218 test_AES_GMAC_authentication_verify_test_case_4(void)
7220 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7223 struct test_crypto_vector {
7224 enum rte_crypto_cipher_algorithm crypto_algo;
7237 const uint8_t *data;
7242 const uint8_t *data;
7246 enum rte_crypto_auth_algorithm auth_algo;
7254 const uint8_t *data;
7264 static const struct test_crypto_vector
7265 hmac_sha1_test_crypto_vector = {
7266 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7268 .data = plaintext_hash,
7273 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7274 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7275 0xDE, 0xF4, 0xDE, 0xAD
7281 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7282 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7283 0x3F, 0x91, 0x64, 0x59
7289 static const struct test_crypto_vector
7290 aes128_gmac_test_vector = {
7291 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7293 .data = plaintext_hash,
7298 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7299 0x08, 0x09, 0x0A, 0x0B
7305 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7306 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7312 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7313 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7319 static const struct test_crypto_vector
7320 aes128cbc_hmac_sha1_test_vector = {
7321 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7324 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7325 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7331 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7332 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7337 .data = plaintext_hash,
7341 .data = ciphertext512_aes128cbc,
7344 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7347 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7348 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7349 0xDE, 0xF4, 0xDE, 0xAD
7355 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7356 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7357 0x18, 0x8C, 0x1D, 0x32
7364 data_corruption(uint8_t *data)
7370 tag_corruption(uint8_t *data, unsigned int tag_offset)
7372 data[tag_offset] += 1;
7376 create_auth_session(struct crypto_unittest_params *ut_params,
7378 const struct test_crypto_vector *reference,
7379 enum rte_crypto_auth_operation auth_op)
7381 struct crypto_testsuite_params *ts_params = &testsuite_params;
7382 uint8_t auth_key[reference->auth_key.len + 1];
7384 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7386 /* Setup Authentication Parameters */
7387 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7388 ut_params->auth_xform.auth.op = auth_op;
7389 ut_params->auth_xform.next = NULL;
7390 ut_params->auth_xform.auth.algo = reference->auth_algo;
7391 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7392 ut_params->auth_xform.auth.key.data = auth_key;
7393 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7395 /* Create Crypto session*/
7396 ut_params->sess = rte_cryptodev_sym_session_create(
7397 ts_params->session_mpool);
7399 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7400 &ut_params->auth_xform,
7401 ts_params->session_mpool);
7403 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7409 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7411 const struct test_crypto_vector *reference,
7412 enum rte_crypto_auth_operation auth_op,
7413 enum rte_crypto_cipher_operation cipher_op)
7415 struct crypto_testsuite_params *ts_params = &testsuite_params;
7416 uint8_t cipher_key[reference->cipher_key.len + 1];
7417 uint8_t auth_key[reference->auth_key.len + 1];
7419 memcpy(cipher_key, reference->cipher_key.data,
7420 reference->cipher_key.len);
7421 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7423 /* Setup Authentication Parameters */
7424 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7425 ut_params->auth_xform.auth.op = auth_op;
7426 ut_params->auth_xform.auth.algo = reference->auth_algo;
7427 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7428 ut_params->auth_xform.auth.key.data = auth_key;
7429 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7431 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7432 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7433 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7435 ut_params->auth_xform.next = &ut_params->cipher_xform;
7437 /* Setup Cipher Parameters */
7438 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7439 ut_params->cipher_xform.next = NULL;
7440 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7441 ut_params->cipher_xform.cipher.op = cipher_op;
7442 ut_params->cipher_xform.cipher.key.data = cipher_key;
7443 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7444 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7445 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7448 /* Create Crypto session*/
7449 ut_params->sess = rte_cryptodev_sym_session_create(
7450 ts_params->session_mpool);
7452 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7453 &ut_params->auth_xform,
7454 ts_params->session_mpool);
7456 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7462 create_auth_operation(struct crypto_testsuite_params *ts_params,
7463 struct crypto_unittest_params *ut_params,
7464 const struct test_crypto_vector *reference,
7465 unsigned int auth_generate)
7467 /* Generate Crypto op data structure */
7468 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7469 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7470 TEST_ASSERT_NOT_NULL(ut_params->op,
7471 "Failed to allocate pktmbuf offload");
7473 /* Set crypto operation data parameters */
7474 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7476 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7478 /* set crypto operation source mbuf */
7479 sym_op->m_src = ut_params->ibuf;
7482 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7483 ut_params->ibuf, reference->digest.len);
7485 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7486 "no room to append auth tag");
7488 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7489 ut_params->ibuf, reference->plaintext.len);
7492 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7494 memcpy(sym_op->auth.digest.data,
7495 reference->digest.data,
7496 reference->digest.len);
7498 TEST_HEXDUMP(stdout, "digest:",
7499 sym_op->auth.digest.data,
7500 reference->digest.len);
7502 sym_op->auth.data.length = reference->plaintext.len;
7503 sym_op->auth.data.offset = 0;
7509 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7510 struct crypto_unittest_params *ut_params,
7511 const struct test_crypto_vector *reference,
7512 unsigned int auth_generate)
7514 /* Generate Crypto op data structure */
7515 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7516 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7517 TEST_ASSERT_NOT_NULL(ut_params->op,
7518 "Failed to allocate pktmbuf offload");
7520 /* Set crypto operation data parameters */
7521 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7525 /* set crypto operation source mbuf */
7526 sym_op->m_src = ut_params->ibuf;
7529 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7530 ut_params->ibuf, reference->digest.len);
7532 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7533 "no room to append auth tag");
7535 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7536 ut_params->ibuf, reference->ciphertext.len);
7539 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7541 memcpy(sym_op->auth.digest.data,
7542 reference->digest.data,
7543 reference->digest.len);
7545 TEST_HEXDUMP(stdout, "digest:",
7546 sym_op->auth.digest.data,
7547 reference->digest.len);
7549 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7550 reference->iv.data, reference->iv.len);
7552 sym_op->cipher.data.length = 0;
7553 sym_op->cipher.data.offset = 0;
7555 sym_op->auth.data.length = reference->plaintext.len;
7556 sym_op->auth.data.offset = 0;
7562 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7563 struct crypto_unittest_params *ut_params,
7564 const struct test_crypto_vector *reference,
7565 unsigned int auth_generate)
7567 /* Generate Crypto op data structure */
7568 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7569 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7570 TEST_ASSERT_NOT_NULL(ut_params->op,
7571 "Failed to allocate pktmbuf offload");
7573 /* Set crypto operation data parameters */
7574 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7576 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7578 /* set crypto operation source mbuf */
7579 sym_op->m_src = ut_params->ibuf;
7582 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7583 ut_params->ibuf, reference->digest.len);
7585 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7586 "no room to append auth tag");
7588 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7589 ut_params->ibuf, reference->ciphertext.len);
7592 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7594 memcpy(sym_op->auth.digest.data,
7595 reference->digest.data,
7596 reference->digest.len);
7598 TEST_HEXDUMP(stdout, "digest:",
7599 sym_op->auth.digest.data,
7600 reference->digest.len);
7602 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7603 reference->iv.data, reference->iv.len);
7605 sym_op->cipher.data.length = reference->ciphertext.len;
7606 sym_op->cipher.data.offset = 0;
7608 sym_op->auth.data.length = reference->ciphertext.len;
7609 sym_op->auth.data.offset = 0;
7615 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7616 struct crypto_unittest_params *ut_params,
7617 const struct test_crypto_vector *reference)
7619 return create_auth_operation(ts_params, ut_params, reference, 0);
7623 create_auth_verify_GMAC_operation(
7624 struct crypto_testsuite_params *ts_params,
7625 struct crypto_unittest_params *ut_params,
7626 const struct test_crypto_vector *reference)
7628 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7632 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7633 struct crypto_unittest_params *ut_params,
7634 const struct test_crypto_vector *reference)
7636 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7640 test_authentication_verify_fail_when_data_corruption(
7641 struct crypto_testsuite_params *ts_params,
7642 struct crypto_unittest_params *ut_params,
7643 const struct test_crypto_vector *reference,
7644 unsigned int data_corrupted)
7650 /* Create session */
7651 retval = create_auth_session(ut_params,
7652 ts_params->valid_devs[0],
7654 RTE_CRYPTO_AUTH_OP_VERIFY);
7658 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7659 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7660 "Failed to allocate input buffer in mempool");
7662 /* clear mbuf payload */
7663 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7664 rte_pktmbuf_tailroom(ut_params->ibuf));
7666 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7667 reference->plaintext.len);
7668 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7669 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7671 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7673 /* Create operation */
7674 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7680 data_corruption(plaintext);
7682 tag_corruption(plaintext, reference->plaintext.len);
7684 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7686 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7687 TEST_ASSERT_EQUAL(ut_params->op->status,
7688 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7689 "authentication not failed");
7691 ut_params->obuf = ut_params->op->sym->m_src;
7692 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7698 test_authentication_verify_GMAC_fail_when_corruption(
7699 struct crypto_testsuite_params *ts_params,
7700 struct crypto_unittest_params *ut_params,
7701 const struct test_crypto_vector *reference,
7702 unsigned int data_corrupted)
7707 /* Create session */
7708 retval = create_auth_cipher_session(ut_params,
7709 ts_params->valid_devs[0],
7711 RTE_CRYPTO_AUTH_OP_VERIFY,
7712 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7717 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7718 "Failed to allocate input buffer in mempool");
7720 /* clear mbuf payload */
7721 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7722 rte_pktmbuf_tailroom(ut_params->ibuf));
7724 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7725 reference->plaintext.len);
7726 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7727 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7729 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7731 /* Create operation */
7732 retval = create_auth_verify_GMAC_operation(ts_params,
7740 data_corruption(plaintext);
7742 tag_corruption(plaintext, reference->aad.len);
7744 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7746 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7747 TEST_ASSERT_EQUAL(ut_params->op->status,
7748 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7749 "authentication not failed");
7751 ut_params->obuf = ut_params->op->sym->m_src;
7752 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7758 test_authenticated_decryption_fail_when_corruption(
7759 struct crypto_testsuite_params *ts_params,
7760 struct crypto_unittest_params *ut_params,
7761 const struct test_crypto_vector *reference,
7762 unsigned int data_corrupted)
7766 uint8_t *ciphertext;
7768 /* Create session */
7769 retval = create_auth_cipher_session(ut_params,
7770 ts_params->valid_devs[0],
7772 RTE_CRYPTO_AUTH_OP_VERIFY,
7773 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7778 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7779 "Failed to allocate input buffer in mempool");
7781 /* clear mbuf payload */
7782 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7783 rte_pktmbuf_tailroom(ut_params->ibuf));
7785 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7786 reference->ciphertext.len);
7787 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7788 memcpy(ciphertext, reference->ciphertext.data,
7789 reference->ciphertext.len);
7791 /* Create operation */
7792 retval = create_cipher_auth_verify_operation(ts_params,
7800 data_corruption(ciphertext);
7802 tag_corruption(ciphertext, reference->ciphertext.len);
7804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7807 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7808 TEST_ASSERT_EQUAL(ut_params->op->status,
7809 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7810 "authentication not failed");
7812 ut_params->obuf = ut_params->op->sym->m_src;
7813 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7819 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7820 const struct aead_test_data *tdata,
7821 void *digest_mem, uint64_t digest_phys)
7823 struct crypto_testsuite_params *ts_params = &testsuite_params;
7824 struct crypto_unittest_params *ut_params = &unittest_params;
7826 const unsigned int auth_tag_len = tdata->auth_tag.len;
7827 const unsigned int iv_len = tdata->iv.len;
7828 unsigned int aad_len = tdata->aad.len;
7830 /* Generate Crypto op data structure */
7831 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7832 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7833 TEST_ASSERT_NOT_NULL(ut_params->op,
7834 "Failed to allocate symmetric crypto operation struct");
7836 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7838 sym_op->aead.digest.data = digest_mem;
7840 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7841 "no room to append digest");
7843 sym_op->aead.digest.phys_addr = digest_phys;
7845 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7846 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7848 TEST_HEXDUMP(stdout, "digest:",
7849 sym_op->aead.digest.data,
7853 /* Append aad data */
7854 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7855 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7856 uint8_t *, IV_OFFSET);
7858 /* Copy IV 1 byte after the IV pointer, according to the API */
7859 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7861 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7863 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7864 ut_params->ibuf, aad_len);
7865 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7866 "no room to prepend aad");
7867 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7870 memset(sym_op->aead.aad.data, 0, aad_len);
7871 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7872 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7874 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7875 TEST_HEXDUMP(stdout, "aad:",
7876 sym_op->aead.aad.data, aad_len);
7878 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7879 uint8_t *, IV_OFFSET);
7881 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7883 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7884 ut_params->ibuf, aad_len);
7885 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7886 "no room to prepend aad");
7887 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7890 memset(sym_op->aead.aad.data, 0, aad_len);
7891 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7893 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7894 TEST_HEXDUMP(stdout, "aad:",
7895 sym_op->aead.aad.data, aad_len);
7898 sym_op->aead.data.length = tdata->plaintext.len;
7899 sym_op->aead.data.offset = aad_len;
7904 #define SGL_MAX_NO 16
7907 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7908 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7910 struct crypto_testsuite_params *ts_params = &testsuite_params;
7911 struct crypto_unittest_params *ut_params = &unittest_params;
7912 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7915 int to_trn_tbl[SGL_MAX_NO];
7917 unsigned int trn_data = 0;
7918 uint8_t *plaintext, *ciphertext, *auth_tag;
7920 if (fragsz > tdata->plaintext.len)
7921 fragsz = tdata->plaintext.len;
7923 uint16_t plaintext_len = fragsz;
7924 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7926 if (fragsz_oop > tdata->plaintext.len)
7927 frag_size_oop = tdata->plaintext.len;
7930 void *digest_mem = NULL;
7932 uint32_t prepend_len = tdata->aad.len;
7934 if (tdata->plaintext.len % fragsz != 0) {
7935 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7938 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7943 * For out-op-place we need to alloc another mbuf
7946 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7947 rte_pktmbuf_append(ut_params->obuf,
7948 frag_size_oop + prepend_len);
7949 buf_oop = ut_params->obuf;
7952 /* Create AEAD session */
7953 retval = create_aead_session(ts_params->valid_devs[0],
7955 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7956 tdata->key.data, tdata->key.len,
7957 tdata->aad.len, tdata->auth_tag.len,
7962 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7964 /* clear mbuf payload */
7965 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7966 rte_pktmbuf_tailroom(ut_params->ibuf));
7968 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7971 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7973 trn_data += plaintext_len;
7975 buf = ut_params->ibuf;
7978 * Loop until no more fragments
7981 while (trn_data < tdata->plaintext.len) {
7983 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7984 (tdata->plaintext.len - trn_data) : fragsz;
7986 to_trn_tbl[ecx++] = to_trn;
7988 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7991 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7992 rte_pktmbuf_tailroom(buf));
7995 if (oop && !fragsz_oop) {
7996 buf_last_oop = buf_oop->next =
7997 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7998 buf_oop = buf_oop->next;
7999 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8000 0, rte_pktmbuf_tailroom(buf_oop));
8001 rte_pktmbuf_append(buf_oop, to_trn);
8004 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8007 memcpy(plaintext, tdata->plaintext.data + trn_data,
8010 if (trn_data == tdata->plaintext.len) {
8013 digest_mem = rte_pktmbuf_append(buf_oop,
8014 tdata->auth_tag.len);
8016 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8017 tdata->auth_tag.len);
8021 uint64_t digest_phys = 0;
8023 ut_params->ibuf->nb_segs = segs;
8026 if (fragsz_oop && oop) {
8030 if (frag_size_oop == tdata->plaintext.len) {
8031 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8032 tdata->auth_tag.len);
8034 digest_phys = rte_pktmbuf_iova_offset(
8036 tdata->plaintext.len + prepend_len);
8039 trn_data = frag_size_oop;
8040 while (trn_data < tdata->plaintext.len) {
8043 (tdata->plaintext.len - trn_data <
8045 (tdata->plaintext.len - trn_data) :
8048 to_trn_tbl[ecx++] = to_trn;
8050 buf_last_oop = buf_oop->next =
8051 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8052 buf_oop = buf_oop->next;
8053 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8054 0, rte_pktmbuf_tailroom(buf_oop));
8055 rte_pktmbuf_append(buf_oop, to_trn);
8059 if (trn_data == tdata->plaintext.len) {
8060 digest_mem = rte_pktmbuf_append(buf_oop,
8061 tdata->auth_tag.len);
8065 ut_params->obuf->nb_segs = segs;
8069 * Place digest at the end of the last buffer
8072 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8073 if (oop && buf_last_oop)
8074 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8076 if (!digest_mem && !oop) {
8077 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8078 + tdata->auth_tag.len);
8079 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8080 tdata->plaintext.len);
8083 /* Create AEAD operation */
8084 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8085 tdata, digest_mem, digest_phys);
8090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8092 ut_params->op->sym->m_src = ut_params->ibuf;
8094 ut_params->op->sym->m_dst = ut_params->obuf;
8096 /* Process crypto operation */
8097 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8098 ut_params->op), "failed to process sym crypto op");
8100 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8101 "crypto op processing failed");
8104 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8105 uint8_t *, prepend_len);
8107 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8108 uint8_t *, prepend_len);
8112 fragsz = fragsz_oop;
8114 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8116 tdata->ciphertext.data,
8118 "Ciphertext data not as expected");
8120 buf = ut_params->op->sym->m_src->next;
8122 buf = ut_params->op->sym->m_dst->next;
8124 unsigned int off = fragsz;
8128 ciphertext = rte_pktmbuf_mtod(buf,
8131 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8133 tdata->ciphertext.data + off,
8135 "Ciphertext data not as expected");
8137 off += to_trn_tbl[ecx++];
8141 auth_tag = digest_mem;
8142 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8144 tdata->auth_tag.data,
8145 tdata->auth_tag.len,
8146 "Generated auth tag not as expected");
8152 #define OUT_OF_PLACE 1
8155 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8157 return test_authenticated_encryption_SGL(
8158 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8162 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8164 return test_authenticated_encryption_SGL(
8165 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8169 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8171 return test_authenticated_encryption_SGL(
8172 &gcm_test_case_8, OUT_OF_PLACE, 400,
8173 gcm_test_case_8.plaintext.len);
8177 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8180 return test_authenticated_encryption_SGL(
8181 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8185 test_authentication_verify_fail_when_data_corrupted(
8186 struct crypto_testsuite_params *ts_params,
8187 struct crypto_unittest_params *ut_params,
8188 const struct test_crypto_vector *reference)
8190 return test_authentication_verify_fail_when_data_corruption(
8191 ts_params, ut_params, reference, 1);
8195 test_authentication_verify_fail_when_tag_corrupted(
8196 struct crypto_testsuite_params *ts_params,
8197 struct crypto_unittest_params *ut_params,
8198 const struct test_crypto_vector *reference)
8200 return test_authentication_verify_fail_when_data_corruption(
8201 ts_params, ut_params, reference, 0);
8205 test_authentication_verify_GMAC_fail_when_data_corrupted(
8206 struct crypto_testsuite_params *ts_params,
8207 struct crypto_unittest_params *ut_params,
8208 const struct test_crypto_vector *reference)
8210 return test_authentication_verify_GMAC_fail_when_corruption(
8211 ts_params, ut_params, reference, 1);
8215 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8216 struct crypto_testsuite_params *ts_params,
8217 struct crypto_unittest_params *ut_params,
8218 const struct test_crypto_vector *reference)
8220 return test_authentication_verify_GMAC_fail_when_corruption(
8221 ts_params, ut_params, reference, 0);
8225 test_authenticated_decryption_fail_when_data_corrupted(
8226 struct crypto_testsuite_params *ts_params,
8227 struct crypto_unittest_params *ut_params,
8228 const struct test_crypto_vector *reference)
8230 return test_authenticated_decryption_fail_when_corruption(
8231 ts_params, ut_params, reference, 1);
8235 test_authenticated_decryption_fail_when_tag_corrupted(
8236 struct crypto_testsuite_params *ts_params,
8237 struct crypto_unittest_params *ut_params,
8238 const struct test_crypto_vector *reference)
8240 return test_authenticated_decryption_fail_when_corruption(
8241 ts_params, ut_params, reference, 0);
8245 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8247 return test_authentication_verify_fail_when_data_corrupted(
8248 &testsuite_params, &unittest_params,
8249 &hmac_sha1_test_crypto_vector);
8253 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8255 return test_authentication_verify_fail_when_tag_corrupted(
8256 &testsuite_params, &unittest_params,
8257 &hmac_sha1_test_crypto_vector);
8261 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8263 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8264 &testsuite_params, &unittest_params,
8265 &aes128_gmac_test_vector);
8269 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8271 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8272 &testsuite_params, &unittest_params,
8273 &aes128_gmac_test_vector);
8277 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8279 return test_authenticated_decryption_fail_when_data_corrupted(
8282 &aes128cbc_hmac_sha1_test_vector);
8286 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8288 return test_authenticated_decryption_fail_when_tag_corrupted(
8291 &aes128cbc_hmac_sha1_test_vector);
8294 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8296 /* global AESNI slave IDs for the scheduler test */
8297 uint8_t aesni_ids[2];
8300 test_scheduler_attach_slave_op(void)
8302 struct crypto_testsuite_params *ts_params = &testsuite_params;
8303 uint8_t sched_id = ts_params->valid_devs[0];
8304 uint32_t nb_devs, i, nb_devs_attached = 0;
8308 /* create 2 AESNI_MB if necessary */
8309 nb_devs = rte_cryptodev_device_count_by_driver(
8310 rte_cryptodev_driver_id_get(
8311 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8313 for (i = nb_devs; i < 2; i++) {
8314 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8315 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8317 ret = rte_vdev_init(vdev_name, NULL);
8319 TEST_ASSERT(ret == 0,
8320 "Failed to create instance %u of"
8322 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8326 /* attach 2 AESNI_MB cdevs */
8327 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8329 struct rte_cryptodev_info info;
8331 rte_cryptodev_info_get(i, &info);
8332 if (info.driver_id != rte_cryptodev_driver_id_get(
8333 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8337 * Create the session mempool again, since now there are new devices
8338 * to use the mempool.
8340 if (ts_params->session_mpool) {
8341 rte_mempool_free(ts_params->session_mpool);
8342 ts_params->session_mpool = NULL;
8344 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8347 * Create mempool with maximum number of sessions * 2,
8348 * to include the session headers
8350 if (ts_params->session_mpool == NULL) {
8351 ts_params->session_mpool = rte_mempool_create(
8353 info.sym.max_nb_sessions * 2,
8355 0, 0, NULL, NULL, NULL,
8356 NULL, SOCKET_ID_ANY,
8359 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8360 "session mempool allocation failed");
8363 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8366 TEST_ASSERT(ret == 0,
8367 "Failed to attach device %u of pmd : %s", i,
8368 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8370 aesni_ids[nb_devs_attached] = (uint8_t)i;
8379 test_scheduler_detach_slave_op(void)
8381 struct crypto_testsuite_params *ts_params = &testsuite_params;
8382 uint8_t sched_id = ts_params->valid_devs[0];
8386 for (i = 0; i < 2; i++) {
8387 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8389 TEST_ASSERT(ret == 0,
8390 "Failed to detach device %u", aesni_ids[i]);
8397 test_scheduler_mode_op(void)
8399 struct crypto_testsuite_params *ts_params = &testsuite_params;
8400 uint8_t sched_id = ts_params->valid_devs[0];
8401 struct rte_cryptodev_scheduler_ops op = {0};
8402 struct rte_cryptodev_scheduler dummy_scheduler = {
8403 .description = "dummy scheduler to test mode",
8404 .name = "dummy scheduler",
8405 .mode = CDEV_SCHED_MODE_USERDEFINED,
8410 /* set user defined mode */
8411 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8413 TEST_ASSERT(ret == 0,
8414 "Failed to set cdev %u to user defined mode", sched_id);
8416 /* set round robin mode */
8417 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8418 CDEV_SCHED_MODE_ROUNDROBIN);
8419 TEST_ASSERT(ret == 0,
8420 "Failed to set cdev %u to round-robin mode", sched_id);
8421 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8422 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8428 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8429 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8430 .setup = testsuite_setup,
8431 .teardown = testsuite_teardown,
8432 .unit_test_cases = {
8433 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8434 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_AES_chain_scheduler_all),
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_AES_cipheronly_scheduler_all),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_authonly_scheduler_all),
8441 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8442 TEST_CASES_END() /**< NULL terminate unit test array */
8446 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8448 static struct unit_test_suite cryptodev_qat_testsuite = {
8449 .suite_name = "Crypto QAT Unit Test Suite",
8450 .setup = testsuite_setup,
8451 .teardown = testsuite_teardown,
8452 .unit_test_cases = {
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_device_configure_invalid_dev_id),
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_device_configure_invalid_queue_pair_ids),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_queue_pair_descriptor_setup),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_multi_session),
8462 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_AES_cipheronly_qat_all),
8465 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_3DES_cipheronly_qat_all),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_DES_cipheronly_qat_all),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_AES_docsis_qat_all),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_DES_docsis_qat_all),
8474 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8475 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8477 /** AES CCM Authenticated Encryption 128 bits key */
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_AES_CCM_authenticated_encryption_test_case_128_1),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_AES_CCM_authenticated_encryption_test_case_128_2),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_AES_CCM_authenticated_encryption_test_case_128_3),
8485 /** AES CCM Authenticated Decryption 128 bits key*/
8486 TEST_CASE_ST(ut_setup, ut_teardown,
8487 test_AES_CCM_authenticated_decryption_test_case_128_1),
8488 TEST_CASE_ST(ut_setup, ut_teardown,
8489 test_AES_CCM_authenticated_decryption_test_case_128_2),
8490 TEST_CASE_ST(ut_setup, ut_teardown,
8491 test_AES_CCM_authenticated_decryption_test_case_128_3),
8493 /** AES GCM Authenticated Encryption */
8494 TEST_CASE_ST(ut_setup, ut_teardown,
8495 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_AES_GCM_authenticated_encryption_test_case_1),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_AES_GCM_authenticated_encryption_test_case_2),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_AES_GCM_authenticated_encryption_test_case_3),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_AES_GCM_authenticated_encryption_test_case_4),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_AES_GCM_authenticated_encryption_test_case_5),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_AES_GCM_authenticated_encryption_test_case_6),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_AES_GCM_authenticated_encryption_test_case_7),
8515 /** AES GCM Authenticated Decryption */
8516 TEST_CASE_ST(ut_setup, ut_teardown,
8517 test_AES_GCM_authenticated_decryption_test_case_1),
8518 TEST_CASE_ST(ut_setup, ut_teardown,
8519 test_AES_GCM_authenticated_decryption_test_case_2),
8520 TEST_CASE_ST(ut_setup, ut_teardown,
8521 test_AES_GCM_authenticated_decryption_test_case_3),
8522 TEST_CASE_ST(ut_setup, ut_teardown,
8523 test_AES_GCM_authenticated_decryption_test_case_4),
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_GCM_authenticated_decryption_test_case_5),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_AES_GCM_authenticated_decryption_test_case_6),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_authenticated_decryption_test_case_7),
8531 /** AES GCM Authenticated Encryption 192 bits key */
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_AES_GCM_auth_encryption_test_case_192_1),
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_GCM_auth_encryption_test_case_192_2),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_auth_encryption_test_case_192_3),
8538 TEST_CASE_ST(ut_setup, ut_teardown,
8539 test_AES_GCM_auth_encryption_test_case_192_4),
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_auth_encryption_test_case_192_5),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_auth_encryption_test_case_192_6),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_auth_encryption_test_case_192_7),
8547 /** AES GCM Authenticated Decryption 192 bits key */
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_AES_GCM_auth_decryption_test_case_192_1),
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_auth_decryption_test_case_192_2),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_auth_decryption_test_case_192_3),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_AES_GCM_auth_decryption_test_case_192_4),
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GCM_auth_decryption_test_case_192_5),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GCM_auth_decryption_test_case_192_6),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GCM_auth_decryption_test_case_192_7),
8563 /** AES GCM Authenticated Encryption 256 bits key */
8564 TEST_CASE_ST(ut_setup, ut_teardown,
8565 test_AES_GCM_auth_encryption_test_case_256_1),
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GCM_auth_encryption_test_case_256_2),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_AES_GCM_auth_encryption_test_case_256_3),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_AES_GCM_auth_encryption_test_case_256_4),
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_AES_GCM_auth_encryption_test_case_256_5),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_AES_GCM_auth_encryption_test_case_256_6),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_AES_GCM_auth_encryption_test_case_256_7),
8579 /** AES GMAC Authentication */
8580 TEST_CASE_ST(ut_setup, ut_teardown,
8581 test_AES_GMAC_authentication_test_case_1),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_AES_GMAC_authentication_verify_test_case_1),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_AES_GMAC_authentication_test_case_2),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_AES_GMAC_authentication_verify_test_case_2),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_AES_GMAC_authentication_test_case_3),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_AES_GMAC_authentication_verify_test_case_3),
8593 /** SNOW 3G encrypt only (UEA2) */
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_snow3g_encryption_test_case_1),
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_snow3g_encryption_test_case_2),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_snow3g_encryption_test_case_3),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_snow3g_encryption_test_case_4),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_snow3g_encryption_test_case_5),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 test_snow3g_encryption_test_case_1_oop),
8607 TEST_CASE_ST(ut_setup, ut_teardown,
8608 test_snow3g_decryption_test_case_1_oop),
8610 /** SNOW 3G decrypt only (UEA2) */
8611 TEST_CASE_ST(ut_setup, ut_teardown,
8612 test_snow3g_decryption_test_case_1),
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_snow3g_decryption_test_case_2),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_snow3g_decryption_test_case_3),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_snow3g_decryption_test_case_4),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_snow3g_decryption_test_case_5),
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_snow3g_hash_generate_test_case_1),
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_snow3g_hash_generate_test_case_2),
8625 TEST_CASE_ST(ut_setup, ut_teardown,
8626 test_snow3g_hash_generate_test_case_3),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_snow3g_hash_verify_test_case_1),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_snow3g_hash_verify_test_case_2),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_snow3g_hash_verify_test_case_3),
8633 TEST_CASE_ST(ut_setup, ut_teardown,
8634 test_snow3g_cipher_auth_test_case_1),
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_snow3g_auth_cipher_test_case_1),
8638 /** ZUC encrypt only (EEA3) */
8639 TEST_CASE_ST(ut_setup, ut_teardown,
8640 test_zuc_encryption_test_case_1),
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_zuc_encryption_test_case_2),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_zuc_encryption_test_case_3),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_zuc_encryption_test_case_4),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_zuc_encryption_test_case_5),
8650 /** ZUC authenticate (EIA3) */
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_zuc_hash_generate_test_case_6),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_zuc_hash_generate_test_case_7),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_zuc_hash_generate_test_case_8),
8658 /** ZUC alg-chain (EEA3/EIA3) */
8659 TEST_CASE_ST(ut_setup, ut_teardown,
8660 test_zuc_cipher_auth_test_case_1),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_zuc_cipher_auth_test_case_2),
8664 /** HMAC_MD5 Authentication */
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_MD5_HMAC_generate_case_1),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_MD5_HMAC_verify_case_1),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_MD5_HMAC_generate_case_2),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_MD5_HMAC_verify_case_2),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_null_auth_only_operation),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_null_cipher_only_operation),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_null_cipher_auth_operation),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_null_auth_cipher_operation),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_kasumi_hash_generate_test_case_1),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_kasumi_hash_generate_test_case_2),
8689 TEST_CASE_ST(ut_setup, ut_teardown,
8690 test_kasumi_hash_generate_test_case_3),
8691 TEST_CASE_ST(ut_setup, ut_teardown,
8692 test_kasumi_hash_generate_test_case_4),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_kasumi_hash_generate_test_case_5),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_kasumi_hash_generate_test_case_6),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_kasumi_hash_verify_test_case_1),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_kasumi_hash_verify_test_case_2),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_kasumi_hash_verify_test_case_3),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_kasumi_hash_verify_test_case_4),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_kasumi_hash_verify_test_case_5),
8709 TEST_CASE_ST(ut_setup, ut_teardown,
8710 test_kasumi_encryption_test_case_1),
8711 TEST_CASE_ST(ut_setup, ut_teardown,
8712 test_kasumi_encryption_test_case_3),
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_kasumi_auth_cipher_test_case_1),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_kasumi_cipher_auth_test_case_1),
8718 /** Negative tests */
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 authentication_verify_AES128_GMAC_fail_data_corrupt),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8732 TEST_CASES_END() /**< NULL terminate unit test array */
8736 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8737 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8738 .setup = testsuite_setup,
8739 .teardown = testsuite_teardown,
8740 .unit_test_cases = {
8741 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8743 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8744 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_DES_cipheronly_mb_all),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_DES_docsis_mb_all),
8750 TEST_CASES_END() /**< NULL terminate unit test array */
8754 static struct unit_test_suite cryptodev_openssl_testsuite = {
8755 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8756 .setup = testsuite_setup,
8757 .teardown = testsuite_teardown,
8758 .unit_test_cases = {
8759 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_multi_session_random_usage),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_chain_openssl_all),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_cipheronly_openssl_all),
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_3DES_chain_openssl_all),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_3DES_cipheronly_openssl_all),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_DES_cipheronly_openssl_all),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_DES_docsis_openssl_all),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_authonly_openssl_all),
8777 /** AES GCM Authenticated Encryption */
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_authenticated_encryption_test_case_1),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_authenticated_encryption_test_case_2),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_authenticated_encryption_test_case_3),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_authenticated_encryption_test_case_4),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_authenticated_encryption_test_case_5),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_authenticated_encryption_test_case_6),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_authenticated_encryption_test_case_7),
8793 /** AES GCM Authenticated Decryption */
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_authenticated_decryption_test_case_1),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_authenticated_decryption_test_case_2),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_authenticated_decryption_test_case_3),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_authenticated_decryption_test_case_4),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_authenticated_decryption_test_case_5),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_AES_GCM_authenticated_decryption_test_case_6),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_authenticated_decryption_test_case_7),
8810 /** AES GCM Authenticated Encryption 192 bits key */
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_GCM_auth_encryption_test_case_192_1),
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_AES_GCM_auth_encryption_test_case_192_2),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_encryption_test_case_192_3),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_encryption_test_case_192_4),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_encryption_test_case_192_5),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_AES_GCM_auth_encryption_test_case_192_6),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_encryption_test_case_192_7),
8826 /** AES GCM Authenticated Decryption 192 bits key */
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_AES_GCM_auth_decryption_test_case_192_1),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_AES_GCM_auth_decryption_test_case_192_2),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_decryption_test_case_192_3),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_decryption_test_case_192_4),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_decryption_test_case_192_5),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_AES_GCM_auth_decryption_test_case_192_6),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_AES_GCM_auth_decryption_test_case_192_7),
8842 /** AES GCM Authenticated Encryption 256 bits key */
8843 TEST_CASE_ST(ut_setup, ut_teardown,
8844 test_AES_GCM_auth_encryption_test_case_256_1),
8845 TEST_CASE_ST(ut_setup, ut_teardown,
8846 test_AES_GCM_auth_encryption_test_case_256_2),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GCM_auth_encryption_test_case_256_3),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GCM_auth_encryption_test_case_256_4),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_AES_GCM_auth_encryption_test_case_256_5),
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_AES_GCM_auth_encryption_test_case_256_6),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_AES_GCM_auth_encryption_test_case_256_7),
8858 /** AES GCM Authenticated Decryption 256 bits key */
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_AES_GCM_auth_decryption_test_case_256_1),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_AES_GCM_auth_decryption_test_case_256_2),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_AES_GCM_auth_decryption_test_case_256_3),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_AES_GCM_auth_decryption_test_case_256_4),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_GCM_auth_decryption_test_case_256_5),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_GCM_auth_decryption_test_case_256_6),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_AES_GCM_auth_decryption_test_case_256_7),
8874 /** AES GMAC Authentication */
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_AES_GMAC_authentication_test_case_1),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_GMAC_authentication_verify_test_case_1),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_AES_GMAC_authentication_test_case_2),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_GMAC_authentication_verify_test_case_2),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_GMAC_authentication_test_case_3),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_GMAC_authentication_verify_test_case_3),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_AES_GMAC_authentication_test_case_4),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_GMAC_authentication_verify_test_case_4),
8892 /** AES CCM Authenticated Encryption 128 bits key */
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_CCM_authenticated_encryption_test_case_128_1),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_AES_CCM_authenticated_encryption_test_case_128_2),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_CCM_authenticated_encryption_test_case_128_3),
8900 /** AES CCM Authenticated Decryption 128 bits key*/
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_CCM_authenticated_decryption_test_case_128_1),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_AES_CCM_authenticated_decryption_test_case_128_2),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_CCM_authenticated_decryption_test_case_128_3),
8908 /** AES CCM Authenticated Encryption 192 bits key */
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_AES_CCM_authenticated_encryption_test_case_192_1),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_AES_CCM_authenticated_encryption_test_case_192_2),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_CCM_authenticated_encryption_test_case_192_3),
8916 /** AES CCM Authenticated Decryption 192 bits key*/
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_AES_CCM_authenticated_decryption_test_case_192_1),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_AES_CCM_authenticated_decryption_test_case_192_2),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_CCM_authenticated_decryption_test_case_192_3),
8924 /** AES CCM Authenticated Encryption 256 bits key */
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_AES_CCM_authenticated_encryption_test_case_256_1),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_AES_CCM_authenticated_encryption_test_case_256_2),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_AES_CCM_authenticated_encryption_test_case_256_3),
8932 /** AES CCM Authenticated Decryption 256 bits key*/
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_AES_CCM_authenticated_decryption_test_case_256_1),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_AES_CCM_authenticated_decryption_test_case_256_2),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_AES_CCM_authenticated_decryption_test_case_256_3),
8940 /** Scatter-Gather */
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8944 /** Negative tests */
8945 TEST_CASE_ST(ut_setup, ut_teardown,
8946 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 authentication_verify_AES128_GMAC_fail_data_corrupt),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8958 TEST_CASES_END() /**< NULL terminate unit test array */
8962 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8963 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8964 .setup = testsuite_setup,
8965 .teardown = testsuite_teardown,
8966 .unit_test_cases = {
8967 /** AES GCM Authenticated Encryption */
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_GCM_authenticated_encryption_test_case_1),
8970 TEST_CASE_ST(ut_setup, ut_teardown,
8971 test_AES_GCM_authenticated_encryption_test_case_2),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_authenticated_encryption_test_case_3),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_authenticated_encryption_test_case_4),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_AES_GCM_authenticated_encryption_test_case_5),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_encryption_test_case_6),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_encryption_test_case_7),
8983 /** AES GCM Authenticated Decryption */
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_authenticated_decryption_test_case_1),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_AES_GCM_authenticated_decryption_test_case_2),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_authenticated_decryption_test_case_3),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_authenticated_decryption_test_case_4),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_AES_GCM_authenticated_decryption_test_case_5),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_GCM_authenticated_decryption_test_case_6),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_GCM_authenticated_decryption_test_case_7),
8999 /** AES GCM Authenticated Encryption 192 bits key */
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_GCM_auth_encryption_test_case_192_1),
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_GCM_auth_encryption_test_case_192_2),
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_auth_encryption_test_case_192_3),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_auth_encryption_test_case_192_4),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_GCM_auth_encryption_test_case_192_5),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_encryption_test_case_192_6),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_encryption_test_case_192_7),
9015 /** AES GCM Authenticated Decryption 192 bits key */
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_decryption_test_case_192_1),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_auth_decryption_test_case_192_2),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_decryption_test_case_192_3),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_decryption_test_case_192_4),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_auth_decryption_test_case_192_5),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_decryption_test_case_192_6),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_decryption_test_case_192_7),
9031 /** AES GCM Authenticated Encryption 256 bits key */
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_auth_encryption_test_case_256_1),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_AES_GCM_auth_encryption_test_case_256_2),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_encryption_test_case_256_3),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_encryption_test_case_256_4),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_auth_encryption_test_case_256_5),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_encryption_test_case_256_6),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_encryption_test_case_256_7),
9047 /** AES GCM Authenticated Decryption 256 bits key */
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_auth_decryption_test_case_256_1),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_auth_decryption_test_case_256_2),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_decryption_test_case_256_3),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_decryption_test_case_256_4),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_auth_decryption_test_case_256_5),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_decryption_test_case_256_6),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_auth_decryption_test_case_256_7),
9063 /** AES GCM Authenticated Encryption big aad size */
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GCM_auth_encryption_test_case_aad_1),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GCM_auth_encryption_test_case_aad_2),
9069 /** AES GCM Authenticated Decryption big aad size */
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_auth_decryption_test_case_aad_1),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_auth_decryption_test_case_aad_2),
9075 /** AES GMAC Authentication */
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GMAC_authentication_test_case_1),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GMAC_authentication_verify_test_case_1),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GMAC_authentication_test_case_3),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GMAC_authentication_verify_test_case_3),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GMAC_authentication_test_case_4),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GMAC_authentication_verify_test_case_4),
9089 /** Negative tests */
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 authentication_verify_AES128_GMAC_fail_data_corrupt),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9095 /** Out of place tests */
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9101 /** Session-less tests */
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9107 /** Scatter-Gather */
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9111 TEST_CASES_END() /**< NULL terminate unit test array */
9115 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9116 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9117 .setup = testsuite_setup,
9118 .teardown = testsuite_teardown,
9119 .unit_test_cases = {
9120 /** KASUMI encrypt only (UEA1) */
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_kasumi_encryption_test_case_1),
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_kasumi_encryption_test_case_1_sgl),
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_kasumi_encryption_test_case_2),
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_kasumi_encryption_test_case_3),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_kasumi_encryption_test_case_4),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_kasumi_encryption_test_case_5),
9133 /** KASUMI decrypt only (UEA1) */
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_kasumi_decryption_test_case_1),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_kasumi_decryption_test_case_2),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_kasumi_decryption_test_case_3),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_kasumi_decryption_test_case_4),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_kasumi_decryption_test_case_5),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_kasumi_encryption_test_case_1_oop),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_kasumi_encryption_test_case_1_oop_sgl),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_kasumi_decryption_test_case_1_oop),
9154 /** KASUMI hash only (UIA1) */
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_kasumi_hash_generate_test_case_1),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_kasumi_hash_generate_test_case_2),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_kasumi_hash_generate_test_case_3),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_kasumi_hash_generate_test_case_4),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_kasumi_hash_generate_test_case_5),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_kasumi_hash_generate_test_case_6),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_kasumi_hash_verify_test_case_1),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_kasumi_hash_verify_test_case_2),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_kasumi_hash_verify_test_case_3),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_kasumi_hash_verify_test_case_4),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_kasumi_hash_verify_test_case_5),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_kasumi_auth_cipher_test_case_1),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_kasumi_cipher_auth_test_case_1),
9181 TEST_CASES_END() /**< NULL terminate unit test array */
9184 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9185 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9186 .setup = testsuite_setup,
9187 .teardown = testsuite_teardown,
9188 .unit_test_cases = {
9189 /** SNOW 3G encrypt only (UEA2) */
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_snow3g_encryption_test_case_1),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_snow3g_encryption_test_case_2),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_snow3g_encryption_test_case_3),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_snow3g_encryption_test_case_4),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_snow3g_encryption_test_case_5),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_snow3g_encryption_test_case_1_oop),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_snow3g_encryption_test_case_1_oop_sgl),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_snow3g_decryption_test_case_1_oop),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_snow3g_encryption_test_case_1_offset_oop),
9211 /** SNOW 3G decrypt only (UEA2) */
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_snow3g_decryption_test_case_1),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_snow3g_decryption_test_case_2),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_snow3g_decryption_test_case_3),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_snow3g_decryption_test_case_4),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_snow3g_decryption_test_case_5),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_snow3g_hash_generate_test_case_1),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_snow3g_hash_generate_test_case_2),
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_snow3g_hash_generate_test_case_3),
9228 /* Tests with buffers which length is not byte-aligned */
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_snow3g_hash_generate_test_case_4),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_snow3g_hash_generate_test_case_5),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_snow3g_hash_generate_test_case_6),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_snow3g_hash_verify_test_case_1),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_snow3g_hash_verify_test_case_2),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_snow3g_hash_verify_test_case_3),
9241 /* Tests with buffers which length is not byte-aligned */
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_snow3g_hash_verify_test_case_4),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_snow3g_hash_verify_test_case_5),
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 test_snow3g_hash_verify_test_case_6),
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_snow3g_cipher_auth_test_case_1),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_snow3g_auth_cipher_test_case_1),
9253 TEST_CASES_END() /**< NULL terminate unit test array */
9257 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9258 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9259 .setup = testsuite_setup,
9260 .teardown = testsuite_teardown,
9261 .unit_test_cases = {
9262 /** ZUC encrypt only (EEA3) */
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_zuc_encryption_test_case_1),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_zuc_encryption_test_case_2),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_zuc_encryption_test_case_3),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_zuc_encryption_test_case_4),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_zuc_encryption_test_case_5),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_zuc_hash_generate_test_case_1),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_zuc_hash_generate_test_case_2),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_zuc_hash_generate_test_case_3),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_zuc_hash_generate_test_case_4),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_zuc_hash_generate_test_case_5),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_zuc_encryption_test_case_6_sgl),
9285 TEST_CASES_END() /**< NULL terminate unit test array */
9289 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9290 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9291 .setup = testsuite_setup,
9292 .teardown = testsuite_teardown,
9293 .unit_test_cases = {
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_device_configure_invalid_dev_id),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_multi_session),
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_chain_dpaa_sec_all),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_3DES_chain_dpaa_sec_all),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_cipheronly_dpaa_sec_all),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_3DES_cipheronly_dpaa_sec_all),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_authonly_dpaa_sec_all),
9310 /** AES GCM Authenticated Encryption */
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_authenticated_encryption_test_case_1),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_authenticated_encryption_test_case_2),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_authenticated_encryption_test_case_3),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_authenticated_encryption_test_case_4),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_authenticated_encryption_test_case_5),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_authenticated_encryption_test_case_6),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_authenticated_encryption_test_case_7),
9326 /** AES GCM Authenticated Decryption */
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_authenticated_decryption_test_case_1),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_authenticated_decryption_test_case_2),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_authenticated_decryption_test_case_3),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_authenticated_decryption_test_case_4),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_authenticated_decryption_test_case_5),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_authenticated_decryption_test_case_6),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_authenticated_decryption_test_case_7),
9342 /** AES GCM Authenticated Encryption 256 bits key */
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_encryption_test_case_256_1),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GCM_auth_encryption_test_case_256_2),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_encryption_test_case_256_3),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_encryption_test_case_256_4),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_encryption_test_case_256_5),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_AES_GCM_auth_encryption_test_case_256_6),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_encryption_test_case_256_7),
9358 /** AES GCM Authenticated Decryption 256 bits key */
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GCM_auth_decryption_test_case_256_1),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GCM_auth_decryption_test_case_256_2),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_auth_decryption_test_case_256_3),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_auth_decryption_test_case_256_4),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GCM_auth_decryption_test_case_256_5),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GCM_auth_decryption_test_case_256_6),
9371 TEST_CASE_ST(ut_setup, ut_teardown,
9372 test_AES_GCM_auth_decryption_test_case_256_7),
9374 /** Out of place tests */
9375 TEST_CASE_ST(ut_setup, ut_teardown,
9376 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9380 TEST_CASES_END() /**< NULL terminate unit test array */
9384 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9385 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9386 .setup = testsuite_setup,
9387 .teardown = testsuite_teardown,
9388 .unit_test_cases = {
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_device_configure_invalid_dev_id),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_multi_session),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_chain_dpaa2_sec_all),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_3DES_chain_dpaa2_sec_all),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_cipheronly_dpaa2_sec_all),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_3DES_cipheronly_dpaa2_sec_all),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_authonly_dpaa2_sec_all),
9405 /** AES GCM Authenticated Encryption */
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_encryption_test_case_1),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_authenticated_encryption_test_case_2),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_authenticated_encryption_test_case_3),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_encryption_test_case_4),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_encryption_test_case_5),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_encryption_test_case_6),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_authenticated_encryption_test_case_7),
9421 /** AES GCM Authenticated Decryption */
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_test_case_1),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_authenticated_decryption_test_case_2),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_authenticated_decryption_test_case_3),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_authenticated_decryption_test_case_4),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_authenticated_decryption_test_case_5),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_authenticated_decryption_test_case_6),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_authenticated_decryption_test_case_7),
9437 /** AES GCM Authenticated Encryption 192 bits key */
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_192_1),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_AES_GCM_auth_encryption_test_case_192_2),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_encryption_test_case_192_3),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_encryption_test_case_192_4),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_encryption_test_case_192_5),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_encryption_test_case_192_6),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_encryption_test_case_192_7),
9453 /** AES GCM Authenticated Decryption 192 bits key */
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_auth_decryption_test_case_192_1),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GCM_auth_decryption_test_case_192_2),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_decryption_test_case_192_3),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_auth_decryption_test_case_192_4),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_decryption_test_case_192_5),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_decryption_test_case_192_6),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_decryption_test_case_192_7),
9469 /** AES GCM Authenticated Encryption 256 bits key */
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_auth_encryption_test_case_256_1),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_AES_GCM_auth_encryption_test_case_256_2),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_auth_encryption_test_case_256_3),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_auth_encryption_test_case_256_4),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_auth_encryption_test_case_256_5),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_auth_encryption_test_case_256_6),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_auth_encryption_test_case_256_7),
9485 /** AES GCM Authenticated Decryption 256 bits key */
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_auth_decryption_test_case_256_1),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_GCM_auth_decryption_test_case_256_2),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_auth_decryption_test_case_256_3),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_GCM_auth_decryption_test_case_256_4),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_AES_GCM_auth_decryption_test_case_256_5),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GCM_auth_decryption_test_case_256_6),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GCM_auth_decryption_test_case_256_7),
9501 /** Out of place tests */
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9507 TEST_CASES_END() /**< NULL terminate unit test array */
9511 static struct unit_test_suite cryptodev_null_testsuite = {
9512 .suite_name = "Crypto Device NULL Unit Test Suite",
9513 .setup = testsuite_setup,
9514 .teardown = testsuite_teardown,
9515 .unit_test_cases = {
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_null_auth_only_operation),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_null_cipher_only_operation),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_null_cipher_auth_operation),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_null_auth_cipher_operation),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_null_invalid_operation),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_null_burst_operation),
9529 TEST_CASES_END() /**< NULL terminate unit test array */
9533 static struct unit_test_suite cryptodev_armv8_testsuite = {
9534 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9535 .setup = testsuite_setup,
9536 .teardown = testsuite_teardown,
9537 .unit_test_cases = {
9538 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9540 /** Negative tests */
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9546 TEST_CASES_END() /**< NULL terminate unit test array */
9550 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9551 .suite_name = "Crypto Device Marvell Component Test Suite",
9552 .setup = testsuite_setup,
9553 .teardown = testsuite_teardown,
9554 .unit_test_cases = {
9555 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_multi_session_random_usage),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_chain_mrvl_all),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_cipheronly_mrvl_all),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_authonly_mrvl_all),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_3DES_chain_mrvl_all),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_3DES_cipheronly_mrvl_all),
9569 /** Negative tests */
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9579 TEST_CASES_END() /**< NULL terminate unit test array */
9585 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9587 gbl_driver_id = rte_cryptodev_driver_id_get(
9588 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9590 if (gbl_driver_id == -1) {
9591 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9592 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9593 "in config file to run this testsuite.\n");
9597 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9601 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9603 gbl_driver_id = rte_cryptodev_driver_id_get(
9604 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9606 if (gbl_driver_id == -1) {
9607 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9608 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9609 "in config file to run this testsuite.\n");
9613 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9617 test_cryptodev_openssl(void)
9619 gbl_driver_id = rte_cryptodev_driver_id_get(
9620 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9622 if (gbl_driver_id == -1) {
9623 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9624 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9625 "in config file to run this testsuite.\n");
9629 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9633 test_cryptodev_aesni_gcm(void)
9635 gbl_driver_id = rte_cryptodev_driver_id_get(
9636 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9638 if (gbl_driver_id == -1) {
9639 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9640 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9641 "in config file to run this testsuite.\n");
9645 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9649 test_cryptodev_null(void)
9651 gbl_driver_id = rte_cryptodev_driver_id_get(
9652 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9654 if (gbl_driver_id == -1) {
9655 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9656 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9657 "in config file to run this testsuite.\n");
9661 return unit_test_suite_runner(&cryptodev_null_testsuite);
9665 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9667 gbl_driver_id = rte_cryptodev_driver_id_get(
9668 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9670 if (gbl_driver_id == -1) {
9671 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9672 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9673 "in config file to run this testsuite.\n");
9677 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9681 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9683 gbl_driver_id = rte_cryptodev_driver_id_get(
9684 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9686 if (gbl_driver_id == -1) {
9687 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9688 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9689 "in config file to run this testsuite.\n");
9693 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9697 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9699 gbl_driver_id = rte_cryptodev_driver_id_get(
9700 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9702 if (gbl_driver_id == -1) {
9703 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9704 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9705 "in config file to run this testsuite.\n");
9709 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9713 test_cryptodev_armv8(void)
9715 gbl_driver_id = rte_cryptodev_driver_id_get(
9716 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9718 if (gbl_driver_id == -1) {
9719 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9720 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9721 "in config file to run this testsuite.\n");
9725 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9729 test_cryptodev_mrvl(void)
9731 gbl_driver_id = rte_cryptodev_driver_id_get(
9732 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9734 if (gbl_driver_id == -1) {
9735 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9736 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9737 "in config file to run this testsuite.\n");
9741 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9744 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9747 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9749 gbl_driver_id = rte_cryptodev_driver_id_get(
9750 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9752 if (gbl_driver_id == -1) {
9753 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9754 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9755 "in config file to run this testsuite.\n");
9759 if (rte_cryptodev_driver_id_get(
9760 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9761 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9762 " enabled in config file to run this testsuite.\n");
9765 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9768 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9773 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9775 gbl_driver_id = rte_cryptodev_driver_id_get(
9776 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9778 if (gbl_driver_id == -1) {
9779 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9780 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9781 "in config file to run this testsuite.\n");
9785 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9789 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9791 gbl_driver_id = rte_cryptodev_driver_id_get(
9792 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9794 if (gbl_driver_id == -1) {
9795 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9796 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9797 "in config file to run this testsuite.\n");
9801 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9804 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9805 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9806 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9807 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9808 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9809 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9810 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9811 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9812 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9813 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9814 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9815 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);