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.
35 #include <rte_common.h>
36 #include <rte_hexdump.h>
38 #include <rte_malloc.h>
39 #include <rte_memcpy.h>
40 #include <rte_pause.h>
41 #include <rte_bus_vdev.h>
43 #include <rte_crypto.h>
44 #include <rte_cryptodev.h>
45 #include <rte_cryptodev_pmd.h>
47 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
48 #include <rte_cryptodev_scheduler.h>
49 #include <rte_cryptodev_scheduler_operations.h>
53 #include "test_cryptodev.h"
55 #include "test_cryptodev_blockcipher.h"
56 #include "test_cryptodev_aes_test_vectors.h"
57 #include "test_cryptodev_des_test_vectors.h"
58 #include "test_cryptodev_hash_test_vectors.h"
59 #include "test_cryptodev_kasumi_test_vectors.h"
60 #include "test_cryptodev_kasumi_hash_test_vectors.h"
61 #include "test_cryptodev_snow3g_test_vectors.h"
62 #include "test_cryptodev_snow3g_hash_test_vectors.h"
63 #include "test_cryptodev_zuc_test_vectors.h"
64 #include "test_cryptodev_aead_test_vectors.h"
65 #include "test_cryptodev_hmac_test_vectors.h"
67 static int gbl_driver_id;
69 struct crypto_testsuite_params {
70 struct rte_mempool *mbuf_pool;
71 struct rte_mempool *large_mbuf_pool;
72 struct rte_mempool *op_mpool;
73 struct rte_mempool *session_mpool;
74 struct rte_cryptodev_config conf;
75 struct rte_cryptodev_qp_conf qp_conf;
77 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
78 uint8_t valid_dev_count;
81 struct crypto_unittest_params {
82 struct rte_crypto_sym_xform cipher_xform;
83 struct rte_crypto_sym_xform auth_xform;
84 struct rte_crypto_sym_xform aead_xform;
86 struct rte_cryptodev_sym_session *sess;
88 struct rte_crypto_op *op;
90 struct rte_mbuf *obuf, *ibuf;
95 #define ALIGN_POW2_ROUNDUP(num, align) \
96 (((num) + (align) - 1) & ~((align) - 1))
99 * Forward declarations.
102 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
103 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
107 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
108 struct crypto_unittest_params *ut_params,
109 struct crypto_testsuite_params *ts_param,
110 const uint8_t *cipher,
111 const uint8_t *digest,
114 static struct rte_mbuf *
115 setup_test_string(struct rte_mempool *mpool,
116 const char *string, size_t len, uint8_t blocksize)
118 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
119 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
121 memset(m->buf_addr, 0, m->buf_len);
123 char *dst = rte_pktmbuf_append(m, t_len);
130 rte_memcpy(dst, string, t_len);
132 memset(dst, 0, t_len);
138 /* Get number of bytes in X bits (rounding up) */
140 ceil_byte_length(uint32_t num_bits)
143 return ((num_bits >> 3) + 1);
145 return (num_bits >> 3);
148 static struct rte_crypto_op *
149 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
151 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
152 printf("Error sending packet for encryption");
158 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
164 static struct crypto_testsuite_params testsuite_params = { NULL };
165 static struct crypto_unittest_params unittest_params;
168 testsuite_setup(void)
170 struct crypto_testsuite_params *ts_params = &testsuite_params;
171 struct rte_cryptodev_info info;
172 uint32_t i = 0, nb_devs, dev_id;
176 memset(ts_params, 0, sizeof(*ts_params));
178 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
179 if (ts_params->mbuf_pool == NULL) {
180 /* Not already created so create */
181 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
183 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
185 if (ts_params->mbuf_pool == NULL) {
186 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
191 ts_params->large_mbuf_pool = rte_mempool_lookup(
192 "CRYPTO_LARGE_MBUFPOOL");
193 if (ts_params->large_mbuf_pool == NULL) {
194 /* Not already created so create */
195 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
196 "CRYPTO_LARGE_MBUFPOOL",
199 if (ts_params->large_mbuf_pool == NULL) {
201 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
206 ts_params->op_mpool = rte_crypto_op_pool_create(
207 "MBUF_CRYPTO_SYM_OP_POOL",
208 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
209 NUM_MBUFS, MBUF_CACHE_SIZE,
211 sizeof(struct rte_crypto_sym_xform) +
214 if (ts_params->op_mpool == NULL) {
215 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
219 /* Create an AESNI MB device if required */
220 if (gbl_driver_id == rte_cryptodev_driver_id_get(
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
222 nb_devs = rte_cryptodev_device_count_by_driver(
223 rte_cryptodev_driver_id_get(
224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
227 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
229 TEST_ASSERT(ret == 0,
230 "Failed to create instance of"
232 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
236 /* Create an AESNI GCM device if required */
237 if (gbl_driver_id == rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
239 nb_devs = rte_cryptodev_device_count_by_driver(
240 rte_cryptodev_driver_id_get(
241 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
243 TEST_ASSERT_SUCCESS(rte_vdev_init(
244 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
245 "Failed to create instance of"
247 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
251 /* Create a SNOW 3G device if required */
252 if (gbl_driver_id == rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
254 nb_devs = rte_cryptodev_device_count_by_driver(
255 rte_cryptodev_driver_id_get(
256 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
258 TEST_ASSERT_SUCCESS(rte_vdev_init(
259 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
260 "Failed to create instance of"
262 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
266 /* Create a KASUMI device if required */
267 if (gbl_driver_id == rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
269 nb_devs = rte_cryptodev_device_count_by_driver(
270 rte_cryptodev_driver_id_get(
271 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
273 TEST_ASSERT_SUCCESS(rte_vdev_init(
274 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
275 "Failed to create instance of"
277 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
281 /* Create a ZUC device if required */
282 if (gbl_driver_id == rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
284 nb_devs = rte_cryptodev_device_count_by_driver(
285 rte_cryptodev_driver_id_get(
286 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
288 TEST_ASSERT_SUCCESS(rte_vdev_init(
289 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
290 "Failed to create instance of"
292 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
296 /* Create a NULL device if required */
297 if (gbl_driver_id == rte_cryptodev_driver_id_get(
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
299 nb_devs = rte_cryptodev_device_count_by_driver(
300 rte_cryptodev_driver_id_get(
301 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
304 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
306 TEST_ASSERT(ret == 0,
307 "Failed to create instance of"
309 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
313 /* Create an OPENSSL device if required */
314 if (gbl_driver_id == rte_cryptodev_driver_id_get(
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
316 nb_devs = rte_cryptodev_device_count_by_driver(
317 rte_cryptodev_driver_id_get(
318 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
321 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
324 TEST_ASSERT(ret == 0, "Failed to create "
325 "instance of pmd : %s",
326 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
330 /* Create a ARMv8 device if required */
331 if (gbl_driver_id == rte_cryptodev_driver_id_get(
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
333 nb_devs = rte_cryptodev_device_count_by_driver(
334 rte_cryptodev_driver_id_get(
335 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
338 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
341 TEST_ASSERT(ret == 0, "Failed to create "
342 "instance of pmd : %s",
343 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
347 /* Create a MRVL device if required */
348 if (gbl_driver_id == rte_cryptodev_driver_id_get(
349 RTE_STR(CRYPTODEV_MRVL_PMD))) {
350 #ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO
351 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be"
352 " enabled in config file to run this testsuite.\n");
355 nb_devs = rte_cryptodev_device_count_by_driver(
356 rte_cryptodev_driver_id_get(
357 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)));
360 RTE_STR(CRYPTODEV_NAME_MRVL_PMD),
363 TEST_ASSERT(ret == 0, "Failed to create "
364 "instance of pmd : %s",
365 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
369 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
370 if (gbl_driver_id == rte_cryptodev_driver_id_get(
371 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
373 nb_devs = rte_cryptodev_device_count_by_driver(
374 rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
378 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
381 TEST_ASSERT(ret == 0,
382 "Failed to create instance %u of"
384 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
387 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
389 nb_devs = rte_cryptodev_count();
391 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
395 /* Create list of valid crypto devs */
396 for (i = 0; i < nb_devs; i++) {
397 rte_cryptodev_info_get(i, &info);
398 if (info.driver_id == gbl_driver_id)
399 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
402 if (ts_params->valid_dev_count < 1)
405 /* Set up all the qps on the first of the valid devices found */
407 dev_id = ts_params->valid_devs[0];
409 rte_cryptodev_info_get(dev_id, &info);
411 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
412 ts_params->conf.socket_id = SOCKET_ID_ANY;
414 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
417 * Create mempool with maximum number of sessions * 2,
418 * to include the session headers
420 ts_params->session_mpool = rte_mempool_create(
422 info.sym.max_nb_sessions * 2,
424 0, 0, NULL, NULL, NULL,
428 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
429 "session mempool allocation failed");
431 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
433 "Failed to configure cryptodev %u with %u qps",
434 dev_id, ts_params->conf.nb_queue_pairs);
436 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
438 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
439 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
440 dev_id, qp_id, &ts_params->qp_conf,
441 rte_cryptodev_socket_id(dev_id),
442 ts_params->session_mpool),
443 "Failed to setup queue pair %u on cryptodev %u",
451 testsuite_teardown(void)
453 struct crypto_testsuite_params *ts_params = &testsuite_params;
455 if (ts_params->mbuf_pool != NULL) {
456 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
457 rte_mempool_avail_count(ts_params->mbuf_pool));
460 if (ts_params->op_mpool != NULL) {
461 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
462 rte_mempool_avail_count(ts_params->op_mpool));
465 /* Free session mempools */
466 if (ts_params->session_mpool != NULL) {
467 rte_mempool_free(ts_params->session_mpool);
468 ts_params->session_mpool = NULL;
475 struct crypto_testsuite_params *ts_params = &testsuite_params;
476 struct crypto_unittest_params *ut_params = &unittest_params;
480 /* Clear unit test parameters before running test */
481 memset(ut_params, 0, sizeof(*ut_params));
483 /* Reconfigure device to default parameters */
484 ts_params->conf.socket_id = SOCKET_ID_ANY;
486 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
488 "Failed to configure cryptodev %u",
489 ts_params->valid_devs[0]);
491 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
492 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
493 ts_params->valid_devs[0], qp_id,
495 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
496 ts_params->session_mpool),
497 "Failed to setup queue pair %u on cryptodev %u",
498 qp_id, ts_params->valid_devs[0]);
502 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
504 /* Start the device */
505 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
506 "Failed to start cryptodev %u",
507 ts_params->valid_devs[0]);
515 struct crypto_testsuite_params *ts_params = &testsuite_params;
516 struct crypto_unittest_params *ut_params = &unittest_params;
517 struct rte_cryptodev_stats stats;
519 /* free crypto session structure */
520 if (ut_params->sess) {
521 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
523 rte_cryptodev_sym_session_free(ut_params->sess);
524 ut_params->sess = NULL;
527 /* free crypto operation structure */
529 rte_crypto_op_free(ut_params->op);
532 * free mbuf - both obuf and ibuf are usually the same,
533 * so check if they point at the same address is necessary,
534 * to avoid freeing the mbuf twice.
536 if (ut_params->obuf) {
537 rte_pktmbuf_free(ut_params->obuf);
538 if (ut_params->ibuf == ut_params->obuf)
542 if (ut_params->ibuf) {
543 rte_pktmbuf_free(ut_params->ibuf);
547 if (ts_params->mbuf_pool != NULL)
548 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
549 rte_mempool_avail_count(ts_params->mbuf_pool));
551 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
553 /* Stop the device */
554 rte_cryptodev_stop(ts_params->valid_devs[0]);
558 test_device_configure_invalid_dev_id(void)
560 struct crypto_testsuite_params *ts_params = &testsuite_params;
561 uint16_t dev_id, num_devs = 0;
563 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
564 "Need at least %d devices for test", 1);
566 /* valid dev_id values */
567 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
569 /* Stop the device in case it's started so it can be configured */
570 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
572 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
573 "Failed test for rte_cryptodev_configure: "
574 "invalid dev_num %u", dev_id);
576 /* invalid dev_id values */
579 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
580 "Failed test for rte_cryptodev_configure: "
581 "invalid dev_num %u", dev_id);
585 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
586 "Failed test for rte_cryptodev_configure:"
587 "invalid dev_num %u", dev_id);
593 test_device_configure_invalid_queue_pair_ids(void)
595 struct crypto_testsuite_params *ts_params = &testsuite_params;
596 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
598 /* Stop the device in case it's started so it can be configured */
599 rte_cryptodev_stop(ts_params->valid_devs[0]);
601 /* valid - one queue pairs */
602 ts_params->conf.nb_queue_pairs = 1;
604 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed to configure cryptodev: dev_id %u, qp_id %u",
607 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
610 /* valid - max value queue pairs */
611 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
613 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
615 "Failed to configure cryptodev: dev_id %u, qp_id %u",
616 ts_params->valid_devs[0],
617 ts_params->conf.nb_queue_pairs);
620 /* invalid - zero queue pairs */
621 ts_params->conf.nb_queue_pairs = 0;
623 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
625 "Failed test for rte_cryptodev_configure, dev_id %u,"
627 ts_params->valid_devs[0],
628 ts_params->conf.nb_queue_pairs);
631 /* invalid - max value supported by field queue pairs */
632 ts_params->conf.nb_queue_pairs = UINT16_MAX;
634 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
636 "Failed test for rte_cryptodev_configure, dev_id %u,"
638 ts_params->valid_devs[0],
639 ts_params->conf.nb_queue_pairs);
642 /* invalid - max value + 1 queue pairs */
643 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
645 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
647 "Failed test for rte_cryptodev_configure, dev_id %u,"
649 ts_params->valid_devs[0],
650 ts_params->conf.nb_queue_pairs);
652 /* revert to original testsuite value */
653 ts_params->conf.nb_queue_pairs = orig_nb_qps;
659 test_queue_pair_descriptor_setup(void)
661 struct crypto_testsuite_params *ts_params = &testsuite_params;
662 struct rte_cryptodev_info dev_info;
663 struct rte_cryptodev_qp_conf qp_conf = {
664 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
669 /* Stop the device in case it's started so it can be configured */
670 rte_cryptodev_stop(ts_params->valid_devs[0]);
673 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
675 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
677 "Failed to configure cryptodev %u",
678 ts_params->valid_devs[0]);
681 * Test various ring sizes on this device. memzones can't be
682 * freed so are re-used if ring is released and re-created.
684 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
686 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
687 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
688 ts_params->valid_devs[0], qp_id, &qp_conf,
689 rte_cryptodev_socket_id(
690 ts_params->valid_devs[0]),
691 ts_params->session_mpool),
693 "rte_cryptodev_queue_pair_setup: num_inflights "
694 "%u on qp %u on cryptodev %u",
695 qp_conf.nb_descriptors, qp_id,
696 ts_params->valid_devs[0]);
699 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
701 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
702 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
703 ts_params->valid_devs[0], qp_id, &qp_conf,
704 rte_cryptodev_socket_id(
705 ts_params->valid_devs[0]),
706 ts_params->session_mpool),
708 " rte_cryptodev_queue_pair_setup: num_inflights"
709 " %u on qp %u on cryptodev %u",
710 qp_conf.nb_descriptors, qp_id,
711 ts_params->valid_devs[0]);
714 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
716 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
717 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
718 ts_params->valid_devs[0], qp_id, &qp_conf,
719 rte_cryptodev_socket_id(
720 ts_params->valid_devs[0]),
721 ts_params->session_mpool),
723 "rte_cryptodev_queue_pair_setup: num_inflights"
724 " %u on qp %u on cryptodev %u",
725 qp_conf.nb_descriptors, qp_id,
726 ts_params->valid_devs[0]);
729 /* invalid number of descriptors - max supported + 2 */
730 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
732 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
733 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
734 ts_params->valid_devs[0], qp_id, &qp_conf,
735 rte_cryptodev_socket_id(
736 ts_params->valid_devs[0]),
737 ts_params->session_mpool),
738 "Unexpectedly passed test for "
739 "rte_cryptodev_queue_pair_setup:"
740 "num_inflights %u on qp %u on cryptodev %u",
741 qp_conf.nb_descriptors, qp_id,
742 ts_params->valid_devs[0]);
745 /* invalid number of descriptors - max value of parameter */
746 qp_conf.nb_descriptors = UINT32_MAX-1;
748 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
749 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
750 ts_params->valid_devs[0], qp_id, &qp_conf,
751 rte_cryptodev_socket_id(
752 ts_params->valid_devs[0]),
753 ts_params->session_mpool),
754 "Unexpectedly passed test for "
755 "rte_cryptodev_queue_pair_setup:"
756 "num_inflights %u on qp %u on cryptodev %u",
757 qp_conf.nb_descriptors, qp_id,
758 ts_params->valid_devs[0]);
761 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
763 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
764 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
765 ts_params->valid_devs[0], qp_id, &qp_conf,
766 rte_cryptodev_socket_id(
767 ts_params->valid_devs[0]),
768 ts_params->session_mpool),
770 " rte_cryptodev_queue_pair_setup:"
771 "num_inflights %u on qp %u on cryptodev %u",
772 qp_conf.nb_descriptors, qp_id,
773 ts_params->valid_devs[0]);
776 /* invalid number of descriptors - max supported + 1 */
777 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
779 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
780 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
781 ts_params->valid_devs[0], qp_id, &qp_conf,
782 rte_cryptodev_socket_id(
783 ts_params->valid_devs[0]),
784 ts_params->session_mpool),
785 "Unexpectedly passed test for "
786 "rte_cryptodev_queue_pair_setup:"
787 "num_inflights %u on qp %u on cryptodev %u",
788 qp_conf.nb_descriptors, qp_id,
789 ts_params->valid_devs[0]);
792 /* test invalid queue pair id */
793 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
795 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
797 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
798 ts_params->valid_devs[0],
800 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
801 ts_params->session_mpool),
802 "Failed test for rte_cryptodev_queue_pair_setup:"
803 "invalid qp %u on cryptodev %u",
804 qp_id, ts_params->valid_devs[0]);
806 qp_id = 0xffff; /*invalid*/
808 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
809 ts_params->valid_devs[0],
811 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
812 ts_params->session_mpool),
813 "Failed test for rte_cryptodev_queue_pair_setup:"
814 "invalid qp %u on cryptodev %u",
815 qp_id, ts_params->valid_devs[0]);
820 /* ***** Plaintext data for tests ***** */
822 const char catch_22_quote_1[] =
823 "There was only one catch and that was Catch-22, which "
824 "specified that a concern for one's safety in the face of "
825 "dangers that were real and immediate was the process of a "
826 "rational mind. Orr was crazy and could be grounded. All he "
827 "had to do was ask; and as soon as he did, he would no longer "
828 "be crazy and would have to fly more missions. Orr would be "
829 "crazy to fly more missions and sane if he didn't, but if he "
830 "was sane he had to fly them. If he flew them he was crazy "
831 "and didn't have to; but if he didn't want to he was sane and "
832 "had to. Yossarian was moved very deeply by the absolute "
833 "simplicity of this clause of Catch-22 and let out a "
834 "respectful whistle. \"That's some catch, that Catch-22\", he "
835 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
837 const char catch_22_quote[] =
838 "What a lousy earth! He wondered how many people were "
839 "destitute that same night even in his own prosperous country, "
840 "how many homes were shanties, how many husbands were drunk "
841 "and wives socked, and how many children were bullied, abused, "
842 "or abandoned. How many families hungered for food they could "
843 "not afford to buy? How many hearts were broken? How many "
844 "suicides would take place that same night, how many people "
845 "would go insane? How many cockroaches and landlords would "
846 "triumph? How many winners were losers, successes failures, "
847 "and rich men poor men? How many wise guys were stupid? How "
848 "many happy endings were unhappy endings? How many honest men "
849 "were liars, brave men cowards, loyal men traitors, how many "
850 "sainted men were corrupt, how many people in positions of "
851 "trust had sold their souls to bodyguards, how many had never "
852 "had souls? How many straight-and-narrow paths were crooked "
853 "paths? How many best families were worst families and how "
854 "many good people were bad people? When you added them all up "
855 "and then subtracted, you might be left with only the children, "
856 "and perhaps with Albert Einstein and an old violinist or "
857 "sculptor somewhere.";
859 #define QUOTE_480_BYTES (480)
860 #define QUOTE_512_BYTES (512)
861 #define QUOTE_768_BYTES (768)
862 #define QUOTE_1024_BYTES (1024)
866 /* ***** SHA1 Hash Tests ***** */
868 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
870 static uint8_t hmac_sha1_key[] = {
871 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
872 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
873 0xDE, 0xF4, 0xDE, 0xAD };
875 /* ***** SHA224 Hash Tests ***** */
877 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
880 /* ***** AES-CBC Cipher Tests ***** */
882 #define CIPHER_KEY_LENGTH_AES_CBC (16)
883 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
885 static uint8_t aes_cbc_key[] = {
886 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
887 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
889 static uint8_t aes_cbc_iv[] = {
890 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
891 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
894 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
896 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
897 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
898 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
899 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
900 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
901 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
902 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
903 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
904 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
905 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
906 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
907 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
908 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
909 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
910 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
911 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
912 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
913 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
914 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
915 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
916 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
917 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
918 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
919 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
920 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
921 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
922 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
923 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
924 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
925 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
926 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
927 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
928 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
929 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
930 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
931 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
932 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
933 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
934 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
935 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
936 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
937 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
938 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
939 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
940 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
941 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
942 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
943 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
944 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
945 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
946 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
947 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
948 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
949 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
950 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
951 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
952 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
953 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
954 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
955 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
956 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
957 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
958 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
959 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
960 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
963 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
964 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
965 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
966 0x18, 0x8c, 0x1d, 0x32
970 /* Multisession Vector context Test */
972 static uint8_t ms_aes_cbc_key0[] = {
973 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
974 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
977 static uint8_t ms_aes_cbc_iv0[] = {
978 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
979 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
982 static const uint8_t ms_aes_cbc_cipher0[] = {
983 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
984 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
985 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
986 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
987 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
988 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
989 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
990 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
991 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
992 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
993 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
994 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
995 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
996 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
997 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
998 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
999 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1000 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1001 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1002 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1003 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1004 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1005 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1006 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1007 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1008 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1009 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1010 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1011 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1012 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1013 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1014 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1015 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1016 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1017 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1018 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1019 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1020 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1021 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1022 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1023 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1024 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1025 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1026 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1027 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1028 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1029 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1030 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1031 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1032 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1033 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1034 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1035 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1036 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1037 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1038 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1039 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1040 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1041 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1042 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1043 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1044 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1045 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1046 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1050 static uint8_t ms_hmac_key0[] = {
1051 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1052 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1053 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1054 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1055 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1056 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1057 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1058 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1061 static const uint8_t ms_hmac_digest0[] = {
1062 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1063 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1064 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1065 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1066 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1067 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1068 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1069 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1073 /* Begin session 1 */
1075 static uint8_t ms_aes_cbc_key1[] = {
1076 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1077 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1080 static uint8_t ms_aes_cbc_iv1[] = {
1081 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1082 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1085 static const uint8_t ms_aes_cbc_cipher1[] = {
1086 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1087 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1088 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1089 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1090 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1091 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1092 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1093 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1094 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1095 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1096 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1097 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1098 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1099 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1100 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1101 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1102 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1103 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1104 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1105 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1106 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1107 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1108 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1109 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1110 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1111 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1112 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1113 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1114 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1115 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1116 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1117 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1118 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1119 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1120 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1121 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1122 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1123 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1124 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1125 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1126 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1127 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1128 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1129 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1130 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1131 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1132 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1133 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1134 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1135 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1136 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1137 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1138 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1139 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1140 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1141 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1142 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1143 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1144 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1145 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1146 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1147 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1148 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1149 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1153 static uint8_t ms_hmac_key1[] = {
1154 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1155 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1156 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1157 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1158 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1159 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1160 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1161 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1164 static const uint8_t ms_hmac_digest1[] = {
1165 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1166 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1167 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1168 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1169 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1170 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1171 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1172 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1175 /* Begin Session 2 */
1176 static uint8_t ms_aes_cbc_key2[] = {
1177 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1178 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1181 static uint8_t ms_aes_cbc_iv2[] = {
1182 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1183 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1186 static const uint8_t ms_aes_cbc_cipher2[] = {
1187 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1188 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1189 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1190 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1191 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1192 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1193 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1194 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1195 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1196 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1197 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1198 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1199 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1200 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1201 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1202 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1203 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1204 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1205 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1206 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1207 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1208 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1209 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1210 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1211 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1212 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1213 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1214 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1215 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1216 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1217 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1218 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1219 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1220 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1221 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1222 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1223 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1224 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1225 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1226 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1227 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1228 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1229 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1230 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1231 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1232 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1233 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1234 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1235 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1236 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1237 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1238 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1239 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1240 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1241 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1242 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1243 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1244 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1245 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1246 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1247 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1248 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1249 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1250 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1253 static uint8_t ms_hmac_key2[] = {
1254 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1255 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1256 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1257 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1258 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1259 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1260 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1261 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1264 static const uint8_t ms_hmac_digest2[] = {
1265 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1266 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1267 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1268 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1269 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1270 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1271 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1272 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1279 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1281 struct crypto_testsuite_params *ts_params = &testsuite_params;
1282 struct crypto_unittest_params *ut_params = &unittest_params;
1284 /* Generate test mbuf data and space for digest */
1285 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1286 catch_22_quote, QUOTE_512_BYTES, 0);
1288 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1289 DIGEST_BYTE_LENGTH_SHA1);
1290 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1292 /* Setup Cipher Parameters */
1293 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1294 ut_params->cipher_xform.next = &ut_params->auth_xform;
1296 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1297 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1298 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1299 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1300 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1301 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1303 /* Setup HMAC Parameters */
1304 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1306 ut_params->auth_xform.next = NULL;
1308 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1309 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1310 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1311 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1312 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1314 ut_params->sess = rte_cryptodev_sym_session_create(
1315 ts_params->session_mpool);
1317 /* Create crypto session*/
1318 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1319 ut_params->sess, &ut_params->cipher_xform,
1320 ts_params->session_mpool);
1321 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1323 /* Generate crypto op data structure */
1324 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1325 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1326 TEST_ASSERT_NOT_NULL(ut_params->op,
1327 "Failed to allocate symmetric crypto operation struct");
1329 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1331 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1333 /* set crypto operation source mbuf */
1334 sym_op->m_src = ut_params->ibuf;
1336 /* Set crypto operation authentication parameters */
1337 sym_op->auth.digest.data = ut_params->digest;
1338 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1339 ut_params->ibuf, QUOTE_512_BYTES);
1341 sym_op->auth.data.offset = 0;
1342 sym_op->auth.data.length = QUOTE_512_BYTES;
1344 /* Copy IV at the end of the crypto operation */
1345 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1346 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1348 /* Set crypto operation cipher parameters */
1349 sym_op->cipher.data.offset = 0;
1350 sym_op->cipher.data.length = QUOTE_512_BYTES;
1352 /* Process crypto operation */
1353 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1354 ut_params->op), "failed to process sym crypto op");
1356 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1357 "crypto op processing failed");
1360 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1363 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1364 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1366 "ciphertext data not as expected");
1368 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1370 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1371 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1372 gbl_driver_id == rte_cryptodev_driver_id_get(
1373 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1374 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1375 DIGEST_BYTE_LENGTH_SHA1,
1376 "Generated digest data not as expected");
1378 return TEST_SUCCESS;
1381 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1383 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1385 static uint8_t hmac_sha512_key[] = {
1386 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1387 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1388 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1389 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1390 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1391 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1392 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1393 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1395 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1396 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1397 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1398 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1399 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1400 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1401 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1402 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1403 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1408 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1409 struct crypto_unittest_params *ut_params,
1410 uint8_t *cipher_key,
1414 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1415 struct crypto_unittest_params *ut_params,
1416 struct crypto_testsuite_params *ts_params,
1417 const uint8_t *cipher,
1418 const uint8_t *digest,
1423 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1424 struct crypto_unittest_params *ut_params,
1425 uint8_t *cipher_key,
1429 /* Setup Cipher Parameters */
1430 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1431 ut_params->cipher_xform.next = NULL;
1433 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1434 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1435 ut_params->cipher_xform.cipher.key.data = cipher_key;
1436 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1437 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1438 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1440 /* Setup HMAC Parameters */
1441 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1442 ut_params->auth_xform.next = &ut_params->cipher_xform;
1444 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1445 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1446 ut_params->auth_xform.auth.key.data = hmac_key;
1447 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1448 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1450 return TEST_SUCCESS;
1455 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1456 struct crypto_unittest_params *ut_params,
1457 struct crypto_testsuite_params *ts_params,
1458 const uint8_t *cipher,
1459 const uint8_t *digest,
1462 /* Generate test mbuf data and digest */
1463 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1466 QUOTE_512_BYTES, 0);
1468 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1469 DIGEST_BYTE_LENGTH_SHA512);
1470 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1472 rte_memcpy(ut_params->digest,
1474 DIGEST_BYTE_LENGTH_SHA512);
1476 /* Generate Crypto op data structure */
1477 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1478 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1479 TEST_ASSERT_NOT_NULL(ut_params->op,
1480 "Failed to allocate symmetric crypto operation struct");
1482 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1484 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1486 /* set crypto operation source mbuf */
1487 sym_op->m_src = ut_params->ibuf;
1489 sym_op->auth.digest.data = ut_params->digest;
1490 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1491 ut_params->ibuf, QUOTE_512_BYTES);
1493 sym_op->auth.data.offset = 0;
1494 sym_op->auth.data.length = QUOTE_512_BYTES;
1496 /* Copy IV at the end of the crypto operation */
1497 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1498 iv, CIPHER_IV_LENGTH_AES_CBC);
1500 sym_op->cipher.data.offset = 0;
1501 sym_op->cipher.data.length = QUOTE_512_BYTES;
1503 /* Process crypto operation */
1504 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1505 ut_params->op), "failed to process sym crypto op");
1507 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1508 "crypto op processing failed");
1510 ut_params->obuf = ut_params->op->sym->m_src;
1513 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1514 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1517 "Plaintext data not as expected");
1520 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1521 "Digest verification failed");
1523 return TEST_SUCCESS;
1527 test_AES_cipheronly_mb_all(void)
1529 struct crypto_testsuite_params *ts_params = &testsuite_params;
1532 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1533 ts_params->op_mpool,
1534 ts_params->session_mpool,
1535 ts_params->valid_devs[0],
1536 rte_cryptodev_driver_id_get(
1537 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1538 BLKCIPHER_AES_CIPHERONLY_TYPE);
1540 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1542 return TEST_SUCCESS;
1546 test_AES_docsis_mb_all(void)
1548 struct crypto_testsuite_params *ts_params = &testsuite_params;
1551 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1552 ts_params->op_mpool,
1553 ts_params->session_mpool,
1554 ts_params->valid_devs[0],
1555 rte_cryptodev_driver_id_get(
1556 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1557 BLKCIPHER_AES_DOCSIS_TYPE);
1559 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1561 return TEST_SUCCESS;
1565 test_AES_docsis_qat_all(void)
1567 struct crypto_testsuite_params *ts_params = &testsuite_params;
1570 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1571 ts_params->op_mpool,
1572 ts_params->session_mpool,
1573 ts_params->valid_devs[0],
1574 rte_cryptodev_driver_id_get(
1575 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1576 BLKCIPHER_AES_DOCSIS_TYPE);
1578 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1580 return TEST_SUCCESS;
1584 test_DES_docsis_qat_all(void)
1586 struct crypto_testsuite_params *ts_params = &testsuite_params;
1589 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1590 ts_params->op_mpool,
1591 ts_params->session_mpool,
1592 ts_params->valid_devs[0],
1593 rte_cryptodev_driver_id_get(
1594 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1595 BLKCIPHER_DES_DOCSIS_TYPE);
1597 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1599 return TEST_SUCCESS;
1603 test_authonly_mb_all(void)
1605 struct crypto_testsuite_params *ts_params = &testsuite_params;
1608 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1609 ts_params->op_mpool,
1610 ts_params->session_mpool,
1611 ts_params->valid_devs[0],
1612 rte_cryptodev_driver_id_get(
1613 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1614 BLKCIPHER_AUTHONLY_TYPE);
1616 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1618 return TEST_SUCCESS;
1622 test_authonly_qat_all(void)
1624 struct crypto_testsuite_params *ts_params = &testsuite_params;
1627 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1628 ts_params->op_mpool,
1629 ts_params->session_mpool,
1630 ts_params->valid_devs[0],
1631 rte_cryptodev_driver_id_get(
1632 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1633 BLKCIPHER_AUTHONLY_TYPE);
1635 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1637 return TEST_SUCCESS;
1640 test_AES_chain_mb_all(void)
1642 struct crypto_testsuite_params *ts_params = &testsuite_params;
1645 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1646 ts_params->op_mpool,
1647 ts_params->session_mpool,
1648 ts_params->valid_devs[0],
1649 rte_cryptodev_driver_id_get(
1650 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1651 BLKCIPHER_AES_CHAIN_TYPE);
1653 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1655 return TEST_SUCCESS;
1658 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1661 test_AES_cipheronly_scheduler_all(void)
1663 struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1667 ts_params->op_mpool,
1668 ts_params->session_mpool,
1669 ts_params->valid_devs[0],
1670 rte_cryptodev_driver_id_get(
1671 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1672 BLKCIPHER_AES_CIPHERONLY_TYPE);
1674 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1676 return TEST_SUCCESS;
1680 test_AES_chain_scheduler_all(void)
1682 struct crypto_testsuite_params *ts_params = &testsuite_params;
1685 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1686 ts_params->op_mpool,
1687 ts_params->session_mpool,
1688 ts_params->valid_devs[0],
1689 rte_cryptodev_driver_id_get(
1690 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1691 BLKCIPHER_AES_CHAIN_TYPE);
1693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1695 return TEST_SUCCESS;
1699 test_authonly_scheduler_all(void)
1701 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1705 ts_params->op_mpool,
1706 ts_params->session_mpool,
1707 ts_params->valid_devs[0],
1708 rte_cryptodev_driver_id_get(
1709 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1710 BLKCIPHER_AUTHONLY_TYPE);
1712 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1714 return TEST_SUCCESS;
1717 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1720 test_AES_chain_openssl_all(void)
1722 struct crypto_testsuite_params *ts_params = &testsuite_params;
1725 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1726 ts_params->op_mpool,
1727 ts_params->session_mpool,
1728 ts_params->valid_devs[0],
1729 rte_cryptodev_driver_id_get(
1730 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1731 BLKCIPHER_AES_CHAIN_TYPE);
1733 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1735 return TEST_SUCCESS;
1739 test_AES_cipheronly_openssl_all(void)
1741 struct crypto_testsuite_params *ts_params = &testsuite_params;
1744 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1745 ts_params->op_mpool,
1746 ts_params->session_mpool,
1747 ts_params->valid_devs[0],
1748 rte_cryptodev_driver_id_get(
1749 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1750 BLKCIPHER_AES_CIPHERONLY_TYPE);
1752 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1754 return TEST_SUCCESS;
1758 test_AES_chain_qat_all(void)
1760 struct crypto_testsuite_params *ts_params = &testsuite_params;
1763 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764 ts_params->op_mpool,
1765 ts_params->session_mpool,
1766 ts_params->valid_devs[0],
1767 rte_cryptodev_driver_id_get(
1768 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1769 BLKCIPHER_AES_CHAIN_TYPE);
1771 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1773 return TEST_SUCCESS;
1777 test_AES_cipheronly_qat_all(void)
1779 struct crypto_testsuite_params *ts_params = &testsuite_params;
1782 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1783 ts_params->op_mpool,
1784 ts_params->session_mpool,
1785 ts_params->valid_devs[0],
1786 rte_cryptodev_driver_id_get(
1787 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1788 BLKCIPHER_AES_CIPHERONLY_TYPE);
1790 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1792 return TEST_SUCCESS;
1796 test_AES_chain_dpaa_sec_all(void)
1798 struct crypto_testsuite_params *ts_params = &testsuite_params;
1801 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1802 ts_params->op_mpool,
1803 ts_params->session_mpool,
1804 ts_params->valid_devs[0],
1805 rte_cryptodev_driver_id_get(
1806 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1807 BLKCIPHER_AES_CHAIN_TYPE);
1809 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1811 return TEST_SUCCESS;
1815 test_AES_cipheronly_dpaa_sec_all(void)
1817 struct crypto_testsuite_params *ts_params = &testsuite_params;
1820 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1821 ts_params->op_mpool,
1822 ts_params->session_mpool,
1823 ts_params->valid_devs[0],
1824 rte_cryptodev_driver_id_get(
1825 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1826 BLKCIPHER_AES_CIPHERONLY_TYPE);
1828 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1830 return TEST_SUCCESS;
1834 test_authonly_dpaa_sec_all(void)
1836 struct crypto_testsuite_params *ts_params = &testsuite_params;
1839 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1840 ts_params->op_mpool,
1841 ts_params->session_mpool,
1842 ts_params->valid_devs[0],
1843 rte_cryptodev_driver_id_get(
1844 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1845 BLKCIPHER_AUTHONLY_TYPE);
1847 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1849 return TEST_SUCCESS;
1853 test_AES_chain_dpaa2_sec_all(void)
1855 struct crypto_testsuite_params *ts_params = &testsuite_params;
1858 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1859 ts_params->op_mpool,
1860 ts_params->session_mpool,
1861 ts_params->valid_devs[0],
1862 rte_cryptodev_driver_id_get(
1863 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1864 BLKCIPHER_AES_CHAIN_TYPE);
1866 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1868 return TEST_SUCCESS;
1872 test_AES_cipheronly_dpaa2_sec_all(void)
1874 struct crypto_testsuite_params *ts_params = &testsuite_params;
1877 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1878 ts_params->op_mpool,
1879 ts_params->session_mpool,
1880 ts_params->valid_devs[0],
1881 rte_cryptodev_driver_id_get(
1882 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1883 BLKCIPHER_AES_CIPHERONLY_TYPE);
1885 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1887 return TEST_SUCCESS;
1891 test_authonly_dpaa2_sec_all(void)
1893 struct crypto_testsuite_params *ts_params = &testsuite_params;
1896 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1897 ts_params->op_mpool,
1898 ts_params->session_mpool,
1899 ts_params->valid_devs[0],
1900 rte_cryptodev_driver_id_get(
1901 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1902 BLKCIPHER_AUTHONLY_TYPE);
1904 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1906 return TEST_SUCCESS;
1910 test_authonly_openssl_all(void)
1912 struct crypto_testsuite_params *ts_params = &testsuite_params;
1915 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1916 ts_params->op_mpool,
1917 ts_params->session_mpool,
1918 ts_params->valid_devs[0],
1919 rte_cryptodev_driver_id_get(
1920 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1921 BLKCIPHER_AUTHONLY_TYPE);
1923 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1925 return TEST_SUCCESS;
1929 test_AES_chain_armv8_all(void)
1931 struct crypto_testsuite_params *ts_params = &testsuite_params;
1934 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1935 ts_params->op_mpool,
1936 ts_params->session_mpool,
1937 ts_params->valid_devs[0],
1938 rte_cryptodev_driver_id_get(
1939 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1940 BLKCIPHER_AES_CHAIN_TYPE);
1942 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1944 return TEST_SUCCESS;
1948 test_AES_chain_mrvl_all(void)
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1953 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1954 ts_params->op_mpool,
1955 ts_params->session_mpool,
1956 ts_params->valid_devs[0],
1957 rte_cryptodev_driver_id_get(
1958 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1959 BLKCIPHER_AES_CHAIN_TYPE);
1961 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1963 return TEST_SUCCESS;
1967 test_AES_cipheronly_mrvl_all(void)
1969 struct crypto_testsuite_params *ts_params = &testsuite_params;
1972 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1973 ts_params->op_mpool,
1974 ts_params->session_mpool,
1975 ts_params->valid_devs[0],
1976 rte_cryptodev_driver_id_get(
1977 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1978 BLKCIPHER_AES_CIPHERONLY_TYPE);
1980 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1982 return TEST_SUCCESS;
1986 test_authonly_mrvl_all(void)
1988 struct crypto_testsuite_params *ts_params = &testsuite_params;
1991 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1992 ts_params->op_mpool,
1993 ts_params->session_mpool,
1994 ts_params->valid_devs[0],
1995 rte_cryptodev_driver_id_get(
1996 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1997 BLKCIPHER_AUTHONLY_TYPE);
1999 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2001 return TEST_SUCCESS;
2005 test_3DES_chain_mrvl_all(void)
2007 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2011 ts_params->op_mpool,
2012 ts_params->session_mpool,
2013 ts_params->valid_devs[0],
2014 rte_cryptodev_driver_id_get(
2015 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2016 BLKCIPHER_3DES_CHAIN_TYPE);
2018 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2020 return TEST_SUCCESS;
2024 test_3DES_cipheronly_mrvl_all(void)
2026 struct crypto_testsuite_params *ts_params = &testsuite_params;
2029 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2030 ts_params->op_mpool,
2031 ts_params->session_mpool,
2032 ts_params->valid_devs[0],
2033 rte_cryptodev_driver_id_get(
2034 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2035 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2037 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2039 return TEST_SUCCESS;
2042 /* ***** SNOW 3G Tests ***** */
2044 create_wireless_algo_hash_session(uint8_t dev_id,
2045 const uint8_t *key, const uint8_t key_len,
2046 const uint8_t iv_len, const uint8_t auth_len,
2047 enum rte_crypto_auth_operation op,
2048 enum rte_crypto_auth_algorithm algo)
2050 uint8_t hash_key[key_len];
2052 struct crypto_testsuite_params *ts_params = &testsuite_params;
2053 struct crypto_unittest_params *ut_params = &unittest_params;
2055 memcpy(hash_key, key, key_len);
2057 TEST_HEXDUMP(stdout, "key:", key, key_len);
2059 /* Setup Authentication Parameters */
2060 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2061 ut_params->auth_xform.next = NULL;
2063 ut_params->auth_xform.auth.op = op;
2064 ut_params->auth_xform.auth.algo = algo;
2065 ut_params->auth_xform.auth.key.length = key_len;
2066 ut_params->auth_xform.auth.key.data = hash_key;
2067 ut_params->auth_xform.auth.digest_length = auth_len;
2068 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2069 ut_params->auth_xform.auth.iv.length = iv_len;
2070 ut_params->sess = rte_cryptodev_sym_session_create(
2071 ts_params->session_mpool);
2073 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2074 &ut_params->auth_xform, ts_params->session_mpool);
2075 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2080 create_wireless_algo_cipher_session(uint8_t dev_id,
2081 enum rte_crypto_cipher_operation op,
2082 enum rte_crypto_cipher_algorithm algo,
2083 const uint8_t *key, const uint8_t key_len,
2086 uint8_t cipher_key[key_len];
2088 struct crypto_testsuite_params *ts_params = &testsuite_params;
2089 struct crypto_unittest_params *ut_params = &unittest_params;
2091 memcpy(cipher_key, key, key_len);
2093 /* Setup Cipher Parameters */
2094 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2095 ut_params->cipher_xform.next = NULL;
2097 ut_params->cipher_xform.cipher.algo = algo;
2098 ut_params->cipher_xform.cipher.op = op;
2099 ut_params->cipher_xform.cipher.key.data = cipher_key;
2100 ut_params->cipher_xform.cipher.key.length = key_len;
2101 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2102 ut_params->cipher_xform.cipher.iv.length = iv_len;
2104 TEST_HEXDUMP(stdout, "key:", key, key_len);
2106 /* Create Crypto session */
2107 ut_params->sess = rte_cryptodev_sym_session_create(
2108 ts_params->session_mpool);
2110 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2111 &ut_params->cipher_xform, ts_params->session_mpool);
2112 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2117 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2118 unsigned int cipher_len,
2119 unsigned int cipher_offset)
2121 struct crypto_testsuite_params *ts_params = &testsuite_params;
2122 struct crypto_unittest_params *ut_params = &unittest_params;
2124 /* Generate Crypto op data structure */
2125 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2126 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2127 TEST_ASSERT_NOT_NULL(ut_params->op,
2128 "Failed to allocate pktmbuf offload");
2130 /* Set crypto operation data parameters */
2131 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2133 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2135 /* set crypto operation source mbuf */
2136 sym_op->m_src = ut_params->ibuf;
2139 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2141 sym_op->cipher.data.length = cipher_len;
2142 sym_op->cipher.data.offset = cipher_offset;
2147 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2148 unsigned int cipher_len,
2149 unsigned int cipher_offset)
2151 struct crypto_testsuite_params *ts_params = &testsuite_params;
2152 struct crypto_unittest_params *ut_params = &unittest_params;
2154 /* Generate Crypto op data structure */
2155 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2156 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2157 TEST_ASSERT_NOT_NULL(ut_params->op,
2158 "Failed to allocate pktmbuf offload");
2160 /* Set crypto operation data parameters */
2161 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2163 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2165 /* set crypto operation source mbuf */
2166 sym_op->m_src = ut_params->ibuf;
2167 sym_op->m_dst = ut_params->obuf;
2170 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2172 sym_op->cipher.data.length = cipher_len;
2173 sym_op->cipher.data.offset = cipher_offset;
2178 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2179 enum rte_crypto_cipher_operation cipher_op,
2180 enum rte_crypto_auth_operation auth_op,
2181 enum rte_crypto_auth_algorithm auth_algo,
2182 enum rte_crypto_cipher_algorithm cipher_algo,
2183 const uint8_t *key, uint8_t key_len,
2184 uint8_t auth_iv_len, uint8_t auth_len,
2185 uint8_t cipher_iv_len)
2188 uint8_t cipher_auth_key[key_len];
2190 struct crypto_testsuite_params *ts_params = &testsuite_params;
2191 struct crypto_unittest_params *ut_params = &unittest_params;
2193 memcpy(cipher_auth_key, key, key_len);
2195 /* Setup Authentication Parameters */
2196 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2197 ut_params->auth_xform.next = NULL;
2199 ut_params->auth_xform.auth.op = auth_op;
2200 ut_params->auth_xform.auth.algo = auth_algo;
2201 ut_params->auth_xform.auth.key.length = key_len;
2202 /* Hash key = cipher key */
2203 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2204 ut_params->auth_xform.auth.digest_length = auth_len;
2205 /* Auth IV will be after cipher IV */
2206 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2207 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2209 /* Setup Cipher Parameters */
2210 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2211 ut_params->cipher_xform.next = &ut_params->auth_xform;
2213 ut_params->cipher_xform.cipher.algo = cipher_algo;
2214 ut_params->cipher_xform.cipher.op = cipher_op;
2215 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2216 ut_params->cipher_xform.cipher.key.length = key_len;
2217 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2218 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2220 TEST_HEXDUMP(stdout, "key:", key, key_len);
2222 /* Create Crypto session*/
2223 ut_params->sess = rte_cryptodev_sym_session_create(
2224 ts_params->session_mpool);
2226 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2227 &ut_params->cipher_xform, ts_params->session_mpool);
2229 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2234 create_wireless_cipher_auth_session(uint8_t dev_id,
2235 enum rte_crypto_cipher_operation cipher_op,
2236 enum rte_crypto_auth_operation auth_op,
2237 enum rte_crypto_auth_algorithm auth_algo,
2238 enum rte_crypto_cipher_algorithm cipher_algo,
2239 const struct wireless_test_data *tdata)
2241 const uint8_t key_len = tdata->key.len;
2242 uint8_t cipher_auth_key[key_len];
2244 struct crypto_testsuite_params *ts_params = &testsuite_params;
2245 struct crypto_unittest_params *ut_params = &unittest_params;
2246 const uint8_t *key = tdata->key.data;
2247 const uint8_t auth_len = tdata->digest.len;
2248 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2249 uint8_t auth_iv_len = tdata->auth_iv.len;
2251 memcpy(cipher_auth_key, key, key_len);
2253 /* Setup Authentication Parameters */
2254 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2255 ut_params->auth_xform.next = NULL;
2257 ut_params->auth_xform.auth.op = auth_op;
2258 ut_params->auth_xform.auth.algo = auth_algo;
2259 ut_params->auth_xform.auth.key.length = key_len;
2260 /* Hash key = cipher key */
2261 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2262 ut_params->auth_xform.auth.digest_length = auth_len;
2263 /* Auth IV will be after cipher IV */
2264 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2265 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2267 /* Setup Cipher Parameters */
2268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2269 ut_params->cipher_xform.next = &ut_params->auth_xform;
2271 ut_params->cipher_xform.cipher.algo = cipher_algo;
2272 ut_params->cipher_xform.cipher.op = cipher_op;
2273 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2274 ut_params->cipher_xform.cipher.key.length = key_len;
2275 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2276 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2279 TEST_HEXDUMP(stdout, "key:", key, key_len);
2281 /* Create Crypto session*/
2282 ut_params->sess = rte_cryptodev_sym_session_create(
2283 ts_params->session_mpool);
2285 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2286 &ut_params->cipher_xform, ts_params->session_mpool);
2288 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2293 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2294 const struct wireless_test_data *tdata)
2296 return create_wireless_cipher_auth_session(dev_id,
2297 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2298 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2299 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2303 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2304 enum rte_crypto_cipher_operation cipher_op,
2305 enum rte_crypto_auth_operation auth_op,
2306 enum rte_crypto_auth_algorithm auth_algo,
2307 enum rte_crypto_cipher_algorithm cipher_algo,
2308 const uint8_t *key, const uint8_t key_len,
2309 uint8_t auth_iv_len, uint8_t auth_len,
2310 uint8_t cipher_iv_len)
2312 uint8_t auth_cipher_key[key_len];
2314 struct crypto_testsuite_params *ts_params = &testsuite_params;
2315 struct crypto_unittest_params *ut_params = &unittest_params;
2317 memcpy(auth_cipher_key, key, key_len);
2319 /* Setup Authentication Parameters */
2320 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2321 ut_params->auth_xform.auth.op = auth_op;
2322 ut_params->auth_xform.next = &ut_params->cipher_xform;
2323 ut_params->auth_xform.auth.algo = auth_algo;
2324 ut_params->auth_xform.auth.key.length = key_len;
2325 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2326 ut_params->auth_xform.auth.digest_length = auth_len;
2327 /* Auth IV will be after cipher IV */
2328 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2329 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2331 /* Setup Cipher Parameters */
2332 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2333 ut_params->cipher_xform.next = NULL;
2334 ut_params->cipher_xform.cipher.algo = cipher_algo;
2335 ut_params->cipher_xform.cipher.op = cipher_op;
2336 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2337 ut_params->cipher_xform.cipher.key.length = key_len;
2338 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2339 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2341 TEST_HEXDUMP(stdout, "key:", key, key_len);
2343 /* Create Crypto session*/
2344 ut_params->sess = rte_cryptodev_sym_session_create(
2345 ts_params->session_mpool);
2347 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2348 &ut_params->auth_xform, ts_params->session_mpool);
2350 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2356 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2357 unsigned int auth_tag_len,
2358 const uint8_t *iv, unsigned int iv_len,
2359 unsigned int data_pad_len,
2360 enum rte_crypto_auth_operation op,
2361 unsigned int auth_len, unsigned int auth_offset)
2363 struct crypto_testsuite_params *ts_params = &testsuite_params;
2365 struct crypto_unittest_params *ut_params = &unittest_params;
2367 /* Generate Crypto op data structure */
2368 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2369 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2370 TEST_ASSERT_NOT_NULL(ut_params->op,
2371 "Failed to allocate pktmbuf offload");
2373 /* Set crypto operation data parameters */
2374 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2376 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2378 /* set crypto operation source mbuf */
2379 sym_op->m_src = ut_params->ibuf;
2382 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2385 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2386 ut_params->ibuf, auth_tag_len);
2388 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2389 "no room to append auth tag");
2390 ut_params->digest = sym_op->auth.digest.data;
2391 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2392 ut_params->ibuf, data_pad_len);
2393 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2394 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2396 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2398 TEST_HEXDUMP(stdout, "digest:",
2399 sym_op->auth.digest.data,
2402 sym_op->auth.data.length = auth_len;
2403 sym_op->auth.data.offset = auth_offset;
2409 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2410 enum rte_crypto_auth_operation op)
2412 struct crypto_testsuite_params *ts_params = &testsuite_params;
2413 struct crypto_unittest_params *ut_params = &unittest_params;
2415 const uint8_t *auth_tag = tdata->digest.data;
2416 const unsigned int auth_tag_len = tdata->digest.len;
2417 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2418 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2420 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2421 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2422 const uint8_t *auth_iv = tdata->auth_iv.data;
2423 const uint8_t auth_iv_len = tdata->auth_iv.len;
2424 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2425 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2427 /* Generate Crypto op data structure */
2428 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2429 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2430 TEST_ASSERT_NOT_NULL(ut_params->op,
2431 "Failed to allocate pktmbuf offload");
2432 /* Set crypto operation data parameters */
2433 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2435 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2437 /* set crypto operation source mbuf */
2438 sym_op->m_src = ut_params->ibuf;
2441 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2442 ut_params->ibuf, auth_tag_len);
2444 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2445 "no room to append auth tag");
2446 ut_params->digest = sym_op->auth.digest.data;
2447 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2448 ut_params->ibuf, data_pad_len);
2449 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2450 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2452 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2454 TEST_HEXDUMP(stdout, "digest:",
2455 sym_op->auth.digest.data,
2458 /* Copy cipher and auth IVs at the end of the crypto operation */
2459 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2461 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2462 iv_ptr += cipher_iv_len;
2463 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2465 sym_op->cipher.data.length = cipher_len;
2466 sym_op->cipher.data.offset = 0;
2467 sym_op->auth.data.length = auth_len;
2468 sym_op->auth.data.offset = 0;
2474 create_zuc_cipher_hash_generate_operation(
2475 const struct wireless_test_data *tdata)
2477 return create_wireless_cipher_hash_operation(tdata,
2478 RTE_CRYPTO_AUTH_OP_GENERATE);
2482 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2483 const unsigned auth_tag_len,
2484 const uint8_t *auth_iv, uint8_t auth_iv_len,
2485 unsigned data_pad_len,
2486 enum rte_crypto_auth_operation op,
2487 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2488 const unsigned cipher_len, const unsigned cipher_offset,
2489 const unsigned auth_len, const unsigned auth_offset)
2491 struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 struct crypto_unittest_params *ut_params = &unittest_params;
2494 /* Generate Crypto op data structure */
2495 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2496 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2497 TEST_ASSERT_NOT_NULL(ut_params->op,
2498 "Failed to allocate pktmbuf offload");
2499 /* Set crypto operation data parameters */
2500 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2502 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2504 /* set crypto operation source mbuf */
2505 sym_op->m_src = ut_params->ibuf;
2508 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2509 ut_params->ibuf, auth_tag_len);
2511 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2512 "no room to append auth tag");
2513 ut_params->digest = sym_op->auth.digest.data;
2514 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2515 ut_params->ibuf, data_pad_len);
2516 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2517 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2519 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2521 TEST_HEXDUMP(stdout, "digest:",
2522 sym_op->auth.digest.data,
2525 /* Copy cipher and auth IVs at the end of the crypto operation */
2526 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2528 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2529 iv_ptr += cipher_iv_len;
2530 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2532 sym_op->cipher.data.length = cipher_len;
2533 sym_op->cipher.data.offset = cipher_offset;
2534 sym_op->auth.data.length = auth_len;
2535 sym_op->auth.data.offset = auth_offset;
2541 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2542 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2543 const uint8_t *auth_iv, uint8_t auth_iv_len,
2544 unsigned int data_pad_len,
2545 unsigned int cipher_len, unsigned int cipher_offset,
2546 unsigned int auth_len, unsigned int auth_offset)
2548 struct crypto_testsuite_params *ts_params = &testsuite_params;
2549 struct crypto_unittest_params *ut_params = &unittest_params;
2551 /* Generate Crypto op data structure */
2552 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2553 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2554 TEST_ASSERT_NOT_NULL(ut_params->op,
2555 "Failed to allocate pktmbuf offload");
2557 /* Set crypto operation data parameters */
2558 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2560 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2562 /* set crypto operation source mbuf */
2563 sym_op->m_src = ut_params->ibuf;
2566 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2567 ut_params->ibuf, auth_tag_len);
2569 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2570 "no room to append auth tag");
2572 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2573 ut_params->ibuf, data_pad_len);
2575 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2577 TEST_HEXDUMP(stdout, "digest:",
2578 sym_op->auth.digest.data,
2581 /* Copy cipher and auth IVs at the end of the crypto operation */
2582 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2584 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2585 iv_ptr += cipher_iv_len;
2586 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2588 sym_op->cipher.data.length = cipher_len;
2589 sym_op->cipher.data.offset = cipher_offset;
2591 sym_op->auth.data.length = auth_len;
2592 sym_op->auth.data.offset = auth_offset;
2598 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2600 struct crypto_testsuite_params *ts_params = &testsuite_params;
2601 struct crypto_unittest_params *ut_params = &unittest_params;
2604 unsigned plaintext_pad_len;
2605 unsigned plaintext_len;
2608 /* Create SNOW 3G session */
2609 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2610 tdata->key.data, tdata->key.len,
2611 tdata->auth_iv.len, tdata->digest.len,
2612 RTE_CRYPTO_AUTH_OP_GENERATE,
2613 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2617 /* alloc mbuf and set payload */
2618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2621 rte_pktmbuf_tailroom(ut_params->ibuf));
2623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2624 /* Append data which is padded to a multiple of */
2625 /* the algorithms block size */
2626 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2629 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2631 /* Create SNOW 3G operation */
2632 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2633 tdata->auth_iv.data, tdata->auth_iv.len,
2634 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2635 tdata->validAuthLenInBits.len,
2640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2642 ut_params->obuf = ut_params->op->sym->m_src;
2643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2644 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2645 + plaintext_pad_len;
2648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2651 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2652 "SNOW 3G Generated auth tag not as expected");
2658 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2660 struct crypto_testsuite_params *ts_params = &testsuite_params;
2661 struct crypto_unittest_params *ut_params = &unittest_params;
2664 unsigned plaintext_pad_len;
2665 unsigned plaintext_len;
2668 /* Create SNOW 3G session */
2669 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2670 tdata->key.data, tdata->key.len,
2671 tdata->auth_iv.len, tdata->digest.len,
2672 RTE_CRYPTO_AUTH_OP_VERIFY,
2673 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2676 /* alloc mbuf and set payload */
2677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2679 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2680 rte_pktmbuf_tailroom(ut_params->ibuf));
2682 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2683 /* Append data which is padded to a multiple of */
2684 /* the algorithms block size */
2685 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2686 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2688 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2690 /* Create SNOW 3G operation */
2691 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2693 tdata->auth_iv.data, tdata->auth_iv.len,
2695 RTE_CRYPTO_AUTH_OP_VERIFY,
2696 tdata->validAuthLenInBits.len,
2701 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2703 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2704 ut_params->obuf = ut_params->op->sym->m_src;
2705 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2706 + plaintext_pad_len;
2709 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2718 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2720 struct crypto_testsuite_params *ts_params = &testsuite_params;
2721 struct crypto_unittest_params *ut_params = &unittest_params;
2724 unsigned plaintext_pad_len;
2725 unsigned plaintext_len;
2728 /* Create KASUMI session */
2729 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2730 tdata->key.data, tdata->key.len,
2731 0, tdata->digest.len,
2732 RTE_CRYPTO_AUTH_OP_GENERATE,
2733 RTE_CRYPTO_AUTH_KASUMI_F9);
2737 /* alloc mbuf and set payload */
2738 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2740 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2741 rte_pktmbuf_tailroom(ut_params->ibuf));
2743 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2744 /* Append data which is padded to a multiple of */
2745 /* the algorithms block size */
2746 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2747 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2749 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2751 /* Create KASUMI operation */
2752 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2754 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2755 tdata->plaintext.len,
2760 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2762 ut_params->obuf = ut_params->op->sym->m_src;
2763 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2764 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2765 + plaintext_pad_len;
2768 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2771 DIGEST_BYTE_LENGTH_KASUMI_F9,
2772 "KASUMI Generated auth tag not as expected");
2778 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2780 struct crypto_testsuite_params *ts_params = &testsuite_params;
2781 struct crypto_unittest_params *ut_params = &unittest_params;
2784 unsigned plaintext_pad_len;
2785 unsigned plaintext_len;
2788 /* Create KASUMI session */
2789 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2790 tdata->key.data, tdata->key.len,
2791 0, tdata->digest.len,
2792 RTE_CRYPTO_AUTH_OP_VERIFY,
2793 RTE_CRYPTO_AUTH_KASUMI_F9);
2796 /* alloc mbuf and set payload */
2797 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2800 rte_pktmbuf_tailroom(ut_params->ibuf));
2802 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2803 /* Append data which is padded to a multiple */
2804 /* of the algorithms block size */
2805 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2806 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2808 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2810 /* Create KASUMI operation */
2811 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2815 RTE_CRYPTO_AUTH_OP_VERIFY,
2816 tdata->plaintext.len,
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->obuf = ut_params->op->sym->m_src;
2825 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2826 + plaintext_pad_len;
2829 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2838 test_snow3g_hash_generate_test_case_1(void)
2840 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2844 test_snow3g_hash_generate_test_case_2(void)
2846 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2850 test_snow3g_hash_generate_test_case_3(void)
2852 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2856 test_snow3g_hash_generate_test_case_4(void)
2858 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2862 test_snow3g_hash_generate_test_case_5(void)
2864 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2868 test_snow3g_hash_generate_test_case_6(void)
2870 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2874 test_snow3g_hash_verify_test_case_1(void)
2876 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2881 test_snow3g_hash_verify_test_case_2(void)
2883 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2887 test_snow3g_hash_verify_test_case_3(void)
2889 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2893 test_snow3g_hash_verify_test_case_4(void)
2895 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2899 test_snow3g_hash_verify_test_case_5(void)
2901 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2905 test_snow3g_hash_verify_test_case_6(void)
2907 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2911 test_kasumi_hash_generate_test_case_1(void)
2913 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2917 test_kasumi_hash_generate_test_case_2(void)
2919 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2923 test_kasumi_hash_generate_test_case_3(void)
2925 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2929 test_kasumi_hash_generate_test_case_4(void)
2931 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2935 test_kasumi_hash_generate_test_case_5(void)
2937 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2941 test_kasumi_hash_generate_test_case_6(void)
2943 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2947 test_kasumi_hash_verify_test_case_1(void)
2949 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2953 test_kasumi_hash_verify_test_case_2(void)
2955 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2959 test_kasumi_hash_verify_test_case_3(void)
2961 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2965 test_kasumi_hash_verify_test_case_4(void)
2967 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2971 test_kasumi_hash_verify_test_case_5(void)
2973 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2977 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2979 struct crypto_testsuite_params *ts_params = &testsuite_params;
2980 struct crypto_unittest_params *ut_params = &unittest_params;
2983 uint8_t *plaintext, *ciphertext;
2984 unsigned plaintext_pad_len;
2985 unsigned plaintext_len;
2987 /* Create KASUMI session */
2988 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2989 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2990 RTE_CRYPTO_CIPHER_KASUMI_F8,
2991 tdata->key.data, tdata->key.len,
2992 tdata->cipher_iv.len);
2996 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2998 /* Clear mbuf payload */
2999 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3000 rte_pktmbuf_tailroom(ut_params->ibuf));
3002 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3003 /* Append data which is padded to a multiple */
3004 /* of the algorithms block size */
3005 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3006 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3008 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3010 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3012 /* Create KASUMI operation */
3013 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3014 tdata->cipher_iv.len,
3015 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3016 tdata->validCipherOffsetInBits.len);
3020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3024 ut_params->obuf = ut_params->op->sym->m_dst;
3025 if (ut_params->obuf)
3026 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3028 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3030 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3032 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3033 (tdata->validCipherOffsetInBits.len >> 3);
3035 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3037 reference_ciphertext,
3038 tdata->validCipherLenInBits.len,
3039 "KASUMI Ciphertext data not as expected");
3044 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3046 struct crypto_testsuite_params *ts_params = &testsuite_params;
3047 struct crypto_unittest_params *ut_params = &unittest_params;
3051 unsigned int plaintext_pad_len;
3052 unsigned int plaintext_len;
3054 uint8_t buffer[10000];
3055 const uint8_t *ciphertext;
3057 struct rte_cryptodev_info dev_info;
3059 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3060 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3061 printf("Device doesn't support scatter-gather. "
3066 /* Create KASUMI session */
3067 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3068 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3069 RTE_CRYPTO_CIPHER_KASUMI_F8,
3070 tdata->key.data, tdata->key.len,
3071 tdata->cipher_iv.len);
3075 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3078 /* Append data which is padded to a multiple */
3079 /* of the algorithms block size */
3080 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3082 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3083 plaintext_pad_len, 10, 0);
3085 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3087 /* Create KASUMI operation */
3088 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3089 tdata->cipher_iv.len,
3090 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3091 tdata->validCipherOffsetInBits.len);
3095 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3097 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3099 ut_params->obuf = ut_params->op->sym->m_dst;
3101 if (ut_params->obuf)
3102 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3103 plaintext_len, buffer);
3105 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3106 tdata->validCipherOffsetInBits.len >> 3,
3107 plaintext_len, buffer);
3110 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3112 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3113 (tdata->validCipherOffsetInBits.len >> 3);
3115 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3117 reference_ciphertext,
3118 tdata->validCipherLenInBits.len,
3119 "KASUMI Ciphertext data not as expected");
3124 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3126 struct crypto_testsuite_params *ts_params = &testsuite_params;
3127 struct crypto_unittest_params *ut_params = &unittest_params;
3130 uint8_t *plaintext, *ciphertext;
3131 unsigned plaintext_pad_len;
3132 unsigned plaintext_len;
3134 /* Create KASUMI session */
3135 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3136 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3137 RTE_CRYPTO_CIPHER_KASUMI_F8,
3138 tdata->key.data, tdata->key.len,
3139 tdata->cipher_iv.len);
3143 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3144 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3146 /* Clear mbuf payload */
3147 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3148 rte_pktmbuf_tailroom(ut_params->ibuf));
3150 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3151 /* Append data which is padded to a multiple */
3152 /* of the algorithms block size */
3153 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3154 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3156 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3157 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3159 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3161 /* Create KASUMI operation */
3162 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3163 tdata->cipher_iv.len,
3164 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3165 tdata->validCipherOffsetInBits.len);
3169 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3171 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3173 ut_params->obuf = ut_params->op->sym->m_dst;
3174 if (ut_params->obuf)
3175 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3177 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3179 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3181 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3182 (tdata->validCipherOffsetInBits.len >> 3);
3184 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3186 reference_ciphertext,
3187 tdata->validCipherLenInBits.len,
3188 "KASUMI Ciphertext data not as expected");
3193 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3195 struct crypto_testsuite_params *ts_params = &testsuite_params;
3196 struct crypto_unittest_params *ut_params = &unittest_params;
3199 unsigned int plaintext_pad_len;
3200 unsigned int plaintext_len;
3202 const uint8_t *ciphertext;
3203 uint8_t buffer[2048];
3205 struct rte_cryptodev_info dev_info;
3207 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3208 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3209 printf("Device doesn't support scatter-gather. "
3214 /* Create KASUMI session */
3215 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3216 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3217 RTE_CRYPTO_CIPHER_KASUMI_F8,
3218 tdata->key.data, tdata->key.len,
3219 tdata->cipher_iv.len);
3223 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3224 /* Append data which is padded to a multiple */
3225 /* of the algorithms block size */
3226 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3228 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3229 plaintext_pad_len, 10, 0);
3230 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3231 plaintext_pad_len, 3, 0);
3233 /* Append data which is padded to a multiple */
3234 /* of the algorithms block size */
3235 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3237 /* Create KASUMI operation */
3238 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3239 tdata->cipher_iv.len,
3240 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3241 tdata->validCipherOffsetInBits.len);
3245 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3247 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3249 ut_params->obuf = ut_params->op->sym->m_dst;
3250 if (ut_params->obuf)
3251 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3252 plaintext_pad_len, buffer);
3254 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3255 tdata->validCipherOffsetInBits.len >> 3,
3256 plaintext_pad_len, buffer);
3258 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3259 (tdata->validCipherOffsetInBits.len >> 3);
3261 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3263 reference_ciphertext,
3264 tdata->validCipherLenInBits.len,
3265 "KASUMI Ciphertext data not as expected");
3271 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3273 struct crypto_testsuite_params *ts_params = &testsuite_params;
3274 struct crypto_unittest_params *ut_params = &unittest_params;
3277 uint8_t *ciphertext, *plaintext;
3278 unsigned ciphertext_pad_len;
3279 unsigned ciphertext_len;
3281 /* Create KASUMI session */
3282 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3283 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3284 RTE_CRYPTO_CIPHER_KASUMI_F8,
3285 tdata->key.data, tdata->key.len,
3286 tdata->cipher_iv.len);
3290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3291 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3293 /* Clear mbuf payload */
3294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3295 rte_pktmbuf_tailroom(ut_params->ibuf));
3297 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3298 /* Append data which is padded to a multiple */
3299 /* of the algorithms block size */
3300 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3301 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3302 ciphertext_pad_len);
3303 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3304 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3306 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3308 /* Create KASUMI operation */
3309 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3310 tdata->cipher_iv.len,
3311 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3312 tdata->validCipherOffsetInBits.len);
3316 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3318 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3320 ut_params->obuf = ut_params->op->sym->m_dst;
3321 if (ut_params->obuf)
3322 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3324 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3326 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3328 const uint8_t *reference_plaintext = tdata->plaintext.data +
3329 (tdata->validCipherOffsetInBits.len >> 3);
3331 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3333 reference_plaintext,
3334 tdata->validCipherLenInBits.len,
3335 "KASUMI Plaintext data not as expected");
3340 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3342 struct crypto_testsuite_params *ts_params = &testsuite_params;
3343 struct crypto_unittest_params *ut_params = &unittest_params;
3346 uint8_t *ciphertext, *plaintext;
3347 unsigned ciphertext_pad_len;
3348 unsigned ciphertext_len;
3350 /* Create KASUMI session */
3351 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3352 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3353 RTE_CRYPTO_CIPHER_KASUMI_F8,
3354 tdata->key.data, tdata->key.len,
3355 tdata->cipher_iv.len);
3359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3361 /* Clear mbuf payload */
3362 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3363 rte_pktmbuf_tailroom(ut_params->ibuf));
3365 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3366 /* Append data which is padded to a multiple */
3367 /* of the algorithms block size */
3368 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3369 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3370 ciphertext_pad_len);
3371 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3373 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3375 /* Create KASUMI operation */
3376 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3377 tdata->cipher_iv.len,
3378 tdata->ciphertext.len,
3379 tdata->validCipherOffsetInBits.len);
3383 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3385 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3387 ut_params->obuf = ut_params->op->sym->m_dst;
3388 if (ut_params->obuf)
3389 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3391 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3393 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3395 const uint8_t *reference_plaintext = tdata->plaintext.data +
3396 (tdata->validCipherOffsetInBits.len >> 3);
3398 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3400 reference_plaintext,
3401 tdata->validCipherLenInBits.len,
3402 "KASUMI Plaintext data not as expected");
3407 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3409 struct crypto_testsuite_params *ts_params = &testsuite_params;
3410 struct crypto_unittest_params *ut_params = &unittest_params;
3413 uint8_t *plaintext, *ciphertext;
3414 unsigned plaintext_pad_len;
3415 unsigned plaintext_len;
3417 /* Create SNOW 3G session */
3418 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3419 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3420 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3421 tdata->key.data, tdata->key.len,
3422 tdata->cipher_iv.len);
3426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3428 /* Clear mbuf payload */
3429 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3430 rte_pktmbuf_tailroom(ut_params->ibuf));
3432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3433 /* Append data which is padded to a multiple of */
3434 /* the algorithms block size */
3435 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3436 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3438 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3440 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3442 /* Create SNOW 3G operation */
3443 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3444 tdata->cipher_iv.len,
3445 tdata->validCipherLenInBits.len,
3450 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3452 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3454 ut_params->obuf = ut_params->op->sym->m_dst;
3455 if (ut_params->obuf)
3456 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3458 ciphertext = plaintext;
3460 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3463 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3465 tdata->ciphertext.data,
3466 tdata->validDataLenInBits.len,
3467 "SNOW 3G Ciphertext data not as expected");
3473 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3475 struct crypto_testsuite_params *ts_params = &testsuite_params;
3476 struct crypto_unittest_params *ut_params = &unittest_params;
3477 uint8_t *plaintext, *ciphertext;
3480 unsigned plaintext_pad_len;
3481 unsigned plaintext_len;
3483 /* Create SNOW 3G session */
3484 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3485 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3486 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3487 tdata->key.data, tdata->key.len,
3488 tdata->cipher_iv.len);
3492 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3493 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3495 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3496 "Failed to allocate input buffer in mempool");
3497 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3498 "Failed to allocate output buffer in mempool");
3500 /* Clear mbuf payload */
3501 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3502 rte_pktmbuf_tailroom(ut_params->ibuf));
3504 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3505 /* Append data which is padded to a multiple of */
3506 /* the algorithms block size */
3507 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3508 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3510 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3511 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3513 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3515 /* Create SNOW 3G operation */
3516 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3517 tdata->cipher_iv.len,
3518 tdata->validCipherLenInBits.len,
3523 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3525 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3527 ut_params->obuf = ut_params->op->sym->m_dst;
3528 if (ut_params->obuf)
3529 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3531 ciphertext = plaintext;
3533 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3538 tdata->ciphertext.data,
3539 tdata->validDataLenInBits.len,
3540 "SNOW 3G Ciphertext data not as expected");
3545 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3547 struct crypto_testsuite_params *ts_params = &testsuite_params;
3548 struct crypto_unittest_params *ut_params = &unittest_params;
3551 unsigned int plaintext_pad_len;
3552 unsigned int plaintext_len;
3553 uint8_t buffer[10000];
3554 const uint8_t *ciphertext;
3556 struct rte_cryptodev_info dev_info;
3558 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3559 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3560 printf("Device doesn't support scatter-gather. "
3565 /* Create SNOW 3G session */
3566 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3567 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3568 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3569 tdata->key.data, tdata->key.len,
3570 tdata->cipher_iv.len);
3574 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3575 /* Append data which is padded to a multiple of */
3576 /* the algorithms block size */
3577 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3579 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3580 plaintext_pad_len, 10, 0);
3581 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3582 plaintext_pad_len, 3, 0);
3584 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3585 "Failed to allocate input buffer in mempool");
3586 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3587 "Failed to allocate output buffer in mempool");
3589 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3591 /* Create SNOW 3G operation */
3592 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3593 tdata->cipher_iv.len,
3594 tdata->validCipherLenInBits.len,
3599 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3601 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3603 ut_params->obuf = ut_params->op->sym->m_dst;
3604 if (ut_params->obuf)
3605 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3606 plaintext_len, buffer);
3608 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3609 plaintext_len, buffer);
3611 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3614 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3616 tdata->ciphertext.data,
3617 tdata->validDataLenInBits.len,
3618 "SNOW 3G Ciphertext data not as expected");
3623 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3625 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3627 uint8_t curr_byte, prev_byte;
3628 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3629 uint8_t lower_byte_mask = (1 << offset) - 1;
3632 prev_byte = buffer[0];
3633 buffer[0] >>= offset;
3635 for (i = 1; i < length_in_bytes; i++) {
3636 curr_byte = buffer[i];
3637 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3638 (curr_byte >> offset);
3639 prev_byte = curr_byte;
3644 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3646 struct crypto_testsuite_params *ts_params = &testsuite_params;
3647 struct crypto_unittest_params *ut_params = &unittest_params;
3648 uint8_t *plaintext, *ciphertext;
3650 uint32_t plaintext_len;
3651 uint32_t plaintext_pad_len;
3652 uint8_t extra_offset = 4;
3653 uint8_t *expected_ciphertext_shifted;
3655 /* Create SNOW 3G session */
3656 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3657 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3658 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3659 tdata->key.data, tdata->key.len,
3660 tdata->cipher_iv.len);
3664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3665 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3667 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3668 "Failed to allocate input buffer in mempool");
3669 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3670 "Failed to allocate output buffer in mempool");
3672 /* Clear mbuf payload */
3673 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3674 rte_pktmbuf_tailroom(ut_params->ibuf));
3676 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3678 * Append data which is padded to a
3679 * multiple of the algorithms block size
3681 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3683 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3686 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3688 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3689 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3691 #ifdef RTE_APP_TEST_DEBUG
3692 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3694 /* Create SNOW 3G operation */
3695 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3696 tdata->cipher_iv.len,
3697 tdata->validCipherLenInBits.len,
3702 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3704 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3706 ut_params->obuf = ut_params->op->sym->m_dst;
3707 if (ut_params->obuf)
3708 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3710 ciphertext = plaintext;
3712 #ifdef RTE_APP_TEST_DEBUG
3713 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3716 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3718 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3719 "failed to reserve memory for ciphertext shifted\n");
3721 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3722 ceil_byte_length(tdata->ciphertext.len));
3723 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3726 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3728 expected_ciphertext_shifted,
3729 tdata->validDataLenInBits.len,
3731 "SNOW 3G Ciphertext data not as expected");
3735 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3737 struct crypto_testsuite_params *ts_params = &testsuite_params;
3738 struct crypto_unittest_params *ut_params = &unittest_params;
3742 uint8_t *plaintext, *ciphertext;
3743 unsigned ciphertext_pad_len;
3744 unsigned ciphertext_len;
3746 /* Create SNOW 3G session */
3747 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3748 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3749 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3750 tdata->key.data, tdata->key.len,
3751 tdata->cipher_iv.len);
3755 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3757 /* Clear mbuf payload */
3758 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3759 rte_pktmbuf_tailroom(ut_params->ibuf));
3761 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3762 /* Append data which is padded to a multiple of */
3763 /* the algorithms block size */
3764 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3765 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3766 ciphertext_pad_len);
3767 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3769 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3771 /* Create SNOW 3G operation */
3772 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3773 tdata->cipher_iv.len,
3774 tdata->validCipherLenInBits.len,
3779 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3781 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3782 ut_params->obuf = ut_params->op->sym->m_dst;
3783 if (ut_params->obuf)
3784 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3786 plaintext = ciphertext;
3788 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3792 tdata->plaintext.data,
3793 tdata->validDataLenInBits.len,
3794 "SNOW 3G Plaintext data not as expected");
3798 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3800 struct crypto_testsuite_params *ts_params = &testsuite_params;
3801 struct crypto_unittest_params *ut_params = &unittest_params;
3805 uint8_t *plaintext, *ciphertext;
3806 unsigned ciphertext_pad_len;
3807 unsigned ciphertext_len;
3809 /* Create SNOW 3G session */
3810 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3811 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3812 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3813 tdata->key.data, tdata->key.len,
3814 tdata->cipher_iv.len);
3818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3819 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3821 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3822 "Failed to allocate input buffer");
3823 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3824 "Failed to allocate output buffer");
3826 /* Clear mbuf payload */
3827 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3828 rte_pktmbuf_tailroom(ut_params->ibuf));
3830 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3831 rte_pktmbuf_tailroom(ut_params->obuf));
3833 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3834 /* Append data which is padded to a multiple of */
3835 /* the algorithms block size */
3836 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3837 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3838 ciphertext_pad_len);
3839 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3840 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3842 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3844 /* Create SNOW 3G operation */
3845 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3846 tdata->cipher_iv.len,
3847 tdata->validCipherLenInBits.len,
3852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3855 ut_params->obuf = ut_params->op->sym->m_dst;
3856 if (ut_params->obuf)
3857 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3859 plaintext = ciphertext;
3861 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3864 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3865 tdata->plaintext.data,
3866 tdata->validDataLenInBits.len,
3867 "SNOW 3G Plaintext data not as expected");
3872 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3874 struct crypto_testsuite_params *ts_params = &testsuite_params;
3875 struct crypto_unittest_params *ut_params = &unittest_params;
3879 uint8_t *plaintext, *ciphertext;
3880 unsigned int plaintext_pad_len;
3881 unsigned int plaintext_len;
3883 struct rte_cryptodev_sym_capability_idx cap_idx;
3885 /* Check if device supports ZUC EEA3 */
3886 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3887 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3889 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3893 /* Check if device supports ZUC EIA3 */
3894 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3895 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3897 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3901 /* Create ZUC session */
3902 retval = create_zuc_cipher_auth_encrypt_generate_session(
3903 ts_params->valid_devs[0],
3907 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3909 /* clear mbuf payload */
3910 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3911 rte_pktmbuf_tailroom(ut_params->ibuf));
3913 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3914 /* Append data which is padded to a multiple of */
3915 /* the algorithms block size */
3916 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3917 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3919 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3921 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3923 /* Create ZUC operation */
3924 retval = create_zuc_cipher_hash_generate_operation(tdata);
3928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3930 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3931 ut_params->obuf = ut_params->op->sym->m_src;
3932 if (ut_params->obuf)
3933 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3935 ciphertext = plaintext;
3937 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3939 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3941 tdata->ciphertext.data,
3942 tdata->validDataLenInBits.len,
3943 "ZUC Ciphertext data not as expected");
3945 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3946 + plaintext_pad_len;
3949 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3953 "ZUC Generated auth tag not as expected");
3958 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3960 struct crypto_testsuite_params *ts_params = &testsuite_params;
3961 struct crypto_unittest_params *ut_params = &unittest_params;
3965 uint8_t *plaintext, *ciphertext;
3966 unsigned plaintext_pad_len;
3967 unsigned plaintext_len;
3969 /* Create SNOW 3G session */
3970 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3971 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3972 RTE_CRYPTO_AUTH_OP_GENERATE,
3973 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3974 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3975 tdata->key.data, tdata->key.len,
3976 tdata->auth_iv.len, tdata->digest.len,
3977 tdata->cipher_iv.len);
3980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3982 /* clear mbuf payload */
3983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3984 rte_pktmbuf_tailroom(ut_params->ibuf));
3986 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3987 /* Append data which is padded to a multiple of */
3988 /* the algorithms block size */
3989 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3990 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3992 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3994 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3996 /* Create SNOW 3G operation */
3997 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3998 tdata->digest.len, tdata->auth_iv.data,
4000 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4001 tdata->cipher_iv.data, tdata->cipher_iv.len,
4002 tdata->validCipherLenInBits.len,
4004 tdata->validAuthLenInBits.len,
4010 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4012 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4013 ut_params->obuf = ut_params->op->sym->m_src;
4014 if (ut_params->obuf)
4015 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4017 ciphertext = plaintext;
4019 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4021 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4023 tdata->ciphertext.data,
4024 tdata->validDataLenInBits.len,
4025 "SNOW 3G Ciphertext data not as expected");
4027 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4028 + plaintext_pad_len;
4031 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4034 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4035 "SNOW 3G Generated auth tag not as expected");
4039 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4041 struct crypto_testsuite_params *ts_params = &testsuite_params;
4042 struct crypto_unittest_params *ut_params = &unittest_params;
4046 uint8_t *plaintext, *ciphertext;
4047 unsigned plaintext_pad_len;
4048 unsigned plaintext_len;
4050 /* Create SNOW 3G session */
4051 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4052 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4053 RTE_CRYPTO_AUTH_OP_GENERATE,
4054 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4055 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4056 tdata->key.data, tdata->key.len,
4057 tdata->auth_iv.len, tdata->digest.len,
4058 tdata->cipher_iv.len);
4062 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4064 /* clear mbuf payload */
4065 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4066 rte_pktmbuf_tailroom(ut_params->ibuf));
4068 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4069 /* Append data which is padded to a multiple of */
4070 /* the algorithms block size */
4071 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4072 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4074 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4076 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4078 /* Create SNOW 3G operation */
4079 retval = create_wireless_algo_auth_cipher_operation(
4081 tdata->cipher_iv.data, tdata->cipher_iv.len,
4082 tdata->auth_iv.data, tdata->auth_iv.len,
4084 tdata->validCipherLenInBits.len,
4086 tdata->validAuthLenInBits.len,
4092 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4094 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4095 ut_params->obuf = ut_params->op->sym->m_src;
4096 if (ut_params->obuf)
4097 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4099 ciphertext = plaintext;
4101 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4102 + plaintext_pad_len;
4103 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4106 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4108 tdata->ciphertext.data,
4109 tdata->validDataLenInBits.len,
4110 "SNOW 3G Ciphertext data not as expected");
4113 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4116 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4117 "SNOW 3G Generated auth tag not as expected");
4122 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4124 struct crypto_testsuite_params *ts_params = &testsuite_params;
4125 struct crypto_unittest_params *ut_params = &unittest_params;
4129 uint8_t *plaintext, *ciphertext;
4130 unsigned plaintext_pad_len;
4131 unsigned plaintext_len;
4133 /* Create KASUMI session */
4134 retval = create_wireless_algo_auth_cipher_session(
4135 ts_params->valid_devs[0],
4136 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4137 RTE_CRYPTO_AUTH_OP_GENERATE,
4138 RTE_CRYPTO_AUTH_KASUMI_F9,
4139 RTE_CRYPTO_CIPHER_KASUMI_F8,
4140 tdata->key.data, tdata->key.len,
4141 0, tdata->digest.len,
4142 tdata->cipher_iv.len);
4145 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4147 /* clear mbuf payload */
4148 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4149 rte_pktmbuf_tailroom(ut_params->ibuf));
4151 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4152 /* Append data which is padded to a multiple of */
4153 /* the algorithms block size */
4154 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4155 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4157 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4159 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4161 /* Create KASUMI operation */
4162 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4163 tdata->cipher_iv.data, tdata->cipher_iv.len,
4166 tdata->validCipherLenInBits.len,
4167 tdata->validCipherOffsetInBits.len,
4168 tdata->validAuthLenInBits.len,
4175 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4177 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4178 if (ut_params->op->sym->m_dst)
4179 ut_params->obuf = ut_params->op->sym->m_dst;
4181 ut_params->obuf = ut_params->op->sym->m_src;
4183 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4184 tdata->validCipherOffsetInBits.len >> 3);
4186 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4187 (tdata->validCipherOffsetInBits.len >> 3);
4189 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4191 reference_ciphertext,
4192 tdata->validCipherLenInBits.len,
4193 "KASUMI Ciphertext data not as expected");
4194 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4195 + plaintext_pad_len;
4198 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4201 DIGEST_BYTE_LENGTH_KASUMI_F9,
4202 "KASUMI Generated auth tag not as expected");
4207 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4209 struct crypto_testsuite_params *ts_params = &testsuite_params;
4210 struct crypto_unittest_params *ut_params = &unittest_params;
4214 uint8_t *plaintext, *ciphertext;
4215 unsigned plaintext_pad_len;
4216 unsigned plaintext_len;
4218 /* Create KASUMI session */
4219 retval = create_wireless_algo_cipher_auth_session(
4220 ts_params->valid_devs[0],
4221 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4222 RTE_CRYPTO_AUTH_OP_GENERATE,
4223 RTE_CRYPTO_AUTH_KASUMI_F9,
4224 RTE_CRYPTO_CIPHER_KASUMI_F8,
4225 tdata->key.data, tdata->key.len,
4226 0, tdata->digest.len,
4227 tdata->cipher_iv.len);
4231 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4233 /* clear mbuf payload */
4234 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4235 rte_pktmbuf_tailroom(ut_params->ibuf));
4237 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4238 /* Append data which is padded to a multiple of */
4239 /* the algorithms block size */
4240 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4241 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4243 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4245 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4247 /* Create KASUMI operation */
4248 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4249 tdata->digest.len, NULL, 0,
4250 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4251 tdata->cipher_iv.data, tdata->cipher_iv.len,
4252 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4253 tdata->validCipherOffsetInBits.len,
4254 tdata->validAuthLenInBits.len,
4260 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4264 if (ut_params->op->sym->m_dst)
4265 ut_params->obuf = ut_params->op->sym->m_dst;
4267 ut_params->obuf = ut_params->op->sym->m_src;
4269 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4270 tdata->validCipherOffsetInBits.len >> 3);
4272 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4273 + plaintext_pad_len;
4275 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4276 (tdata->validCipherOffsetInBits.len >> 3);
4278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4280 reference_ciphertext,
4281 tdata->validCipherLenInBits.len,
4282 "KASUMI Ciphertext data not as expected");
4285 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4288 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4289 "KASUMI Generated auth tag not as expected");
4294 test_zuc_encryption(const struct wireless_test_data *tdata)
4296 struct crypto_testsuite_params *ts_params = &testsuite_params;
4297 struct crypto_unittest_params *ut_params = &unittest_params;
4300 uint8_t *plaintext, *ciphertext;
4301 unsigned plaintext_pad_len;
4302 unsigned plaintext_len;
4304 struct rte_cryptodev_sym_capability_idx cap_idx;
4306 /* Check if device supports ZUC EEA3 */
4307 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4308 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4310 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4314 /* Create ZUC session */
4315 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4316 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4317 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4318 tdata->key.data, tdata->key.len,
4319 tdata->cipher_iv.len);
4323 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4325 /* Clear mbuf payload */
4326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4327 rte_pktmbuf_tailroom(ut_params->ibuf));
4329 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4330 /* Append data which is padded to a multiple */
4331 /* of the algorithms block size */
4332 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4333 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4335 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4337 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4339 /* Create ZUC operation */
4340 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4341 tdata->cipher_iv.len,
4342 tdata->plaintext.len,
4347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4351 ut_params->obuf = ut_params->op->sym->m_dst;
4352 if (ut_params->obuf)
4353 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4355 ciphertext = plaintext;
4357 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4360 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4362 tdata->ciphertext.data,
4363 tdata->validCipherLenInBits.len,
4364 "ZUC Ciphertext data not as expected");
4369 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4371 struct crypto_testsuite_params *ts_params = &testsuite_params;
4372 struct crypto_unittest_params *ut_params = &unittest_params;
4376 unsigned int plaintext_pad_len;
4377 unsigned int plaintext_len;
4378 const uint8_t *ciphertext;
4379 uint8_t ciphertext_buffer[2048];
4380 struct rte_cryptodev_info dev_info;
4382 struct rte_cryptodev_sym_capability_idx cap_idx;
4384 /* Check if device supports ZUC EEA3 */
4385 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4386 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4388 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4392 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4393 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4394 printf("Device doesn't support scatter-gather. "
4399 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4401 /* Append data which is padded to a multiple */
4402 /* of the algorithms block size */
4403 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4405 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4406 plaintext_pad_len, 10, 0);
4408 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4409 tdata->plaintext.data);
4411 /* Create ZUC session */
4412 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4413 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4414 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4415 tdata->key.data, tdata->key.len,
4416 tdata->cipher_iv.len);
4420 /* Clear mbuf payload */
4422 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4424 /* Create ZUC operation */
4425 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4426 tdata->cipher_iv.len, tdata->plaintext.len,
4431 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4433 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4435 ut_params->obuf = ut_params->op->sym->m_dst;
4436 if (ut_params->obuf)
4437 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4438 0, plaintext_len, ciphertext_buffer);
4440 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4441 0, plaintext_len, ciphertext_buffer);
4444 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4447 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4449 tdata->ciphertext.data,
4450 tdata->validCipherLenInBits.len,
4451 "ZUC Ciphertext data not as expected");
4457 test_zuc_authentication(const struct wireless_test_data *tdata)
4459 struct crypto_testsuite_params *ts_params = &testsuite_params;
4460 struct crypto_unittest_params *ut_params = &unittest_params;
4463 unsigned plaintext_pad_len;
4464 unsigned plaintext_len;
4467 struct rte_cryptodev_sym_capability_idx cap_idx;
4469 /* Check if device supports ZUC EIA3 */
4470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4471 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4477 /* Create ZUC session */
4478 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4479 tdata->key.data, tdata->key.len,
4480 tdata->auth_iv.len, tdata->digest.len,
4481 RTE_CRYPTO_AUTH_OP_GENERATE,
4482 RTE_CRYPTO_AUTH_ZUC_EIA3);
4486 /* alloc mbuf and set payload */
4487 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4489 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4490 rte_pktmbuf_tailroom(ut_params->ibuf));
4492 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4493 /* Append data which is padded to a multiple of */
4494 /* the algorithms block size */
4495 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4496 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4498 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4500 /* Create ZUC operation */
4501 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4502 tdata->auth_iv.data, tdata->auth_iv.len,
4503 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4504 tdata->validAuthLenInBits.len,
4509 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4511 ut_params->obuf = ut_params->op->sym->m_src;
4512 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4513 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4514 + plaintext_pad_len;
4517 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4520 DIGEST_BYTE_LENGTH_KASUMI_F9,
4521 "ZUC Generated auth tag not as expected");
4527 test_kasumi_encryption_test_case_1(void)
4529 return test_kasumi_encryption(&kasumi_test_case_1);
4533 test_kasumi_encryption_test_case_1_sgl(void)
4535 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4539 test_kasumi_encryption_test_case_1_oop(void)
4541 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4545 test_kasumi_encryption_test_case_1_oop_sgl(void)
4547 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4551 test_kasumi_encryption_test_case_2(void)
4553 return test_kasumi_encryption(&kasumi_test_case_2);
4557 test_kasumi_encryption_test_case_3(void)
4559 return test_kasumi_encryption(&kasumi_test_case_3);
4563 test_kasumi_encryption_test_case_4(void)
4565 return test_kasumi_encryption(&kasumi_test_case_4);
4569 test_kasumi_encryption_test_case_5(void)
4571 return test_kasumi_encryption(&kasumi_test_case_5);
4575 test_kasumi_decryption_test_case_1(void)
4577 return test_kasumi_decryption(&kasumi_test_case_1);
4581 test_kasumi_decryption_test_case_1_oop(void)
4583 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4587 test_kasumi_decryption_test_case_2(void)
4589 return test_kasumi_decryption(&kasumi_test_case_2);
4593 test_kasumi_decryption_test_case_3(void)
4595 return test_kasumi_decryption(&kasumi_test_case_3);
4599 test_kasumi_decryption_test_case_4(void)
4601 return test_kasumi_decryption(&kasumi_test_case_4);
4605 test_kasumi_decryption_test_case_5(void)
4607 return test_kasumi_decryption(&kasumi_test_case_5);
4610 test_snow3g_encryption_test_case_1(void)
4612 return test_snow3g_encryption(&snow3g_test_case_1);
4616 test_snow3g_encryption_test_case_1_oop(void)
4618 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4622 test_snow3g_encryption_test_case_1_oop_sgl(void)
4624 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4629 test_snow3g_encryption_test_case_1_offset_oop(void)
4631 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4635 test_snow3g_encryption_test_case_2(void)
4637 return test_snow3g_encryption(&snow3g_test_case_2);
4641 test_snow3g_encryption_test_case_3(void)
4643 return test_snow3g_encryption(&snow3g_test_case_3);
4647 test_snow3g_encryption_test_case_4(void)
4649 return test_snow3g_encryption(&snow3g_test_case_4);
4653 test_snow3g_encryption_test_case_5(void)
4655 return test_snow3g_encryption(&snow3g_test_case_5);
4659 test_snow3g_decryption_test_case_1(void)
4661 return test_snow3g_decryption(&snow3g_test_case_1);
4665 test_snow3g_decryption_test_case_1_oop(void)
4667 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4671 test_snow3g_decryption_test_case_2(void)
4673 return test_snow3g_decryption(&snow3g_test_case_2);
4677 test_snow3g_decryption_test_case_3(void)
4679 return test_snow3g_decryption(&snow3g_test_case_3);
4683 test_snow3g_decryption_test_case_4(void)
4685 return test_snow3g_decryption(&snow3g_test_case_4);
4689 test_snow3g_decryption_test_case_5(void)
4691 return test_snow3g_decryption(&snow3g_test_case_5);
4694 test_snow3g_cipher_auth_test_case_1(void)
4696 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4700 test_snow3g_auth_cipher_test_case_1(void)
4702 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4706 test_kasumi_auth_cipher_test_case_1(void)
4708 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4712 test_kasumi_cipher_auth_test_case_1(void)
4714 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4718 test_zuc_encryption_test_case_1(void)
4720 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4724 test_zuc_encryption_test_case_2(void)
4726 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4730 test_zuc_encryption_test_case_3(void)
4732 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4736 test_zuc_encryption_test_case_4(void)
4738 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4742 test_zuc_encryption_test_case_5(void)
4744 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4748 test_zuc_encryption_test_case_6_sgl(void)
4750 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4754 test_zuc_hash_generate_test_case_1(void)
4756 return test_zuc_authentication(&zuc_test_case_auth_1b);
4760 test_zuc_hash_generate_test_case_2(void)
4762 return test_zuc_authentication(&zuc_test_case_auth_90b);
4766 test_zuc_hash_generate_test_case_3(void)
4768 return test_zuc_authentication(&zuc_test_case_auth_577b);
4772 test_zuc_hash_generate_test_case_4(void)
4774 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4778 test_zuc_hash_generate_test_case_5(void)
4780 return test_zuc_authentication(&zuc_test_auth_5670b);
4784 test_zuc_hash_generate_test_case_6(void)
4786 return test_zuc_authentication(&zuc_test_case_auth_128b);
4790 test_zuc_hash_generate_test_case_7(void)
4792 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4796 test_zuc_hash_generate_test_case_8(void)
4798 return test_zuc_authentication(&zuc_test_case_auth_584b);
4802 test_zuc_cipher_auth_test_case_1(void)
4804 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4808 test_zuc_cipher_auth_test_case_2(void)
4810 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4814 test_3DES_chain_qat_all(void)
4816 struct crypto_testsuite_params *ts_params = &testsuite_params;
4819 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4820 ts_params->op_mpool,
4821 ts_params->session_mpool,
4822 ts_params->valid_devs[0],
4823 rte_cryptodev_driver_id_get(
4824 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4825 BLKCIPHER_3DES_CHAIN_TYPE);
4827 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4829 return TEST_SUCCESS;
4833 test_DES_cipheronly_qat_all(void)
4835 struct crypto_testsuite_params *ts_params = &testsuite_params;
4838 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4839 ts_params->op_mpool,
4840 ts_params->session_mpool,
4841 ts_params->valid_devs[0],
4842 rte_cryptodev_driver_id_get(
4843 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4844 BLKCIPHER_DES_CIPHERONLY_TYPE);
4846 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4848 return TEST_SUCCESS;
4852 test_DES_cipheronly_openssl_all(void)
4854 struct crypto_testsuite_params *ts_params = &testsuite_params;
4857 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4858 ts_params->op_mpool,
4859 ts_params->session_mpool,
4860 ts_params->valid_devs[0],
4861 rte_cryptodev_driver_id_get(
4862 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4863 BLKCIPHER_DES_CIPHERONLY_TYPE);
4865 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4867 return TEST_SUCCESS;
4871 test_DES_docsis_openssl_all(void)
4873 struct crypto_testsuite_params *ts_params = &testsuite_params;
4876 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4877 ts_params->op_mpool,
4878 ts_params->session_mpool,
4879 ts_params->valid_devs[0],
4880 rte_cryptodev_driver_id_get(
4881 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4882 BLKCIPHER_DES_DOCSIS_TYPE);
4884 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4886 return TEST_SUCCESS;
4890 test_DES_cipheronly_mb_all(void)
4892 struct crypto_testsuite_params *ts_params = &testsuite_params;
4895 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4896 ts_params->op_mpool,
4897 ts_params->session_mpool,
4898 ts_params->valid_devs[0],
4899 rte_cryptodev_driver_id_get(
4900 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4901 BLKCIPHER_DES_CIPHERONLY_TYPE);
4903 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4905 return TEST_SUCCESS;
4909 test_DES_docsis_mb_all(void)
4911 struct crypto_testsuite_params *ts_params = &testsuite_params;
4914 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4915 ts_params->op_mpool,
4916 ts_params->session_mpool,
4917 ts_params->valid_devs[0],
4918 rte_cryptodev_driver_id_get(
4919 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4920 BLKCIPHER_DES_DOCSIS_TYPE);
4922 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4924 return TEST_SUCCESS;
4928 test_3DES_chain_dpaa_sec_all(void)
4930 struct crypto_testsuite_params *ts_params = &testsuite_params;
4933 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4934 ts_params->op_mpool,
4935 ts_params->session_mpool,
4936 ts_params->valid_devs[0],
4937 rte_cryptodev_driver_id_get(
4938 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4939 BLKCIPHER_3DES_CHAIN_TYPE);
4941 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4943 return TEST_SUCCESS;
4947 test_3DES_cipheronly_dpaa_sec_all(void)
4949 struct crypto_testsuite_params *ts_params = &testsuite_params;
4952 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4953 ts_params->op_mpool,
4954 ts_params->session_mpool,
4955 ts_params->valid_devs[0],
4956 rte_cryptodev_driver_id_get(
4957 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4958 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4960 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4962 return TEST_SUCCESS;
4966 test_3DES_chain_dpaa2_sec_all(void)
4968 struct crypto_testsuite_params *ts_params = &testsuite_params;
4971 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4972 ts_params->op_mpool,
4973 ts_params->session_mpool,
4974 ts_params->valid_devs[0],
4975 rte_cryptodev_driver_id_get(
4976 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4977 BLKCIPHER_3DES_CHAIN_TYPE);
4979 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4981 return TEST_SUCCESS;
4985 test_3DES_cipheronly_dpaa2_sec_all(void)
4987 struct crypto_testsuite_params *ts_params = &testsuite_params;
4990 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4991 ts_params->op_mpool,
4992 ts_params->session_mpool,
4993 ts_params->valid_devs[0],
4994 rte_cryptodev_driver_id_get(
4995 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4996 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4998 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5000 return TEST_SUCCESS;
5004 test_3DES_cipheronly_qat_all(void)
5006 struct crypto_testsuite_params *ts_params = &testsuite_params;
5009 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5010 ts_params->op_mpool,
5011 ts_params->session_mpool,
5012 ts_params->valid_devs[0],
5013 rte_cryptodev_driver_id_get(
5014 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5015 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5017 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5019 return TEST_SUCCESS;
5023 test_3DES_chain_openssl_all(void)
5025 struct crypto_testsuite_params *ts_params = &testsuite_params;
5028 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5029 ts_params->op_mpool,
5030 ts_params->session_mpool,
5031 ts_params->valid_devs[0],
5032 rte_cryptodev_driver_id_get(
5033 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5034 BLKCIPHER_3DES_CHAIN_TYPE);
5036 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5038 return TEST_SUCCESS;
5042 test_3DES_cipheronly_openssl_all(void)
5044 struct crypto_testsuite_params *ts_params = &testsuite_params;
5047 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5048 ts_params->op_mpool,
5049 ts_params->session_mpool,
5050 ts_params->valid_devs[0],
5051 rte_cryptodev_driver_id_get(
5052 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5053 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5055 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5057 return TEST_SUCCESS;
5060 /* ***** AEAD algorithm Tests ***** */
5063 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5064 enum rte_crypto_aead_operation op,
5065 const uint8_t *key, const uint8_t key_len,
5066 const uint16_t aad_len, const uint8_t auth_len,
5069 uint8_t aead_key[key_len];
5071 struct crypto_testsuite_params *ts_params = &testsuite_params;
5072 struct crypto_unittest_params *ut_params = &unittest_params;
5074 memcpy(aead_key, key, key_len);
5076 /* Setup AEAD Parameters */
5077 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5078 ut_params->aead_xform.next = NULL;
5079 ut_params->aead_xform.aead.algo = algo;
5080 ut_params->aead_xform.aead.op = op;
5081 ut_params->aead_xform.aead.key.data = aead_key;
5082 ut_params->aead_xform.aead.key.length = key_len;
5083 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5084 ut_params->aead_xform.aead.iv.length = iv_len;
5085 ut_params->aead_xform.aead.digest_length = auth_len;
5086 ut_params->aead_xform.aead.aad_length = aad_len;
5088 TEST_HEXDUMP(stdout, "key:", key, key_len);
5090 /* Create Crypto session*/
5091 ut_params->sess = rte_cryptodev_sym_session_create(
5092 ts_params->session_mpool);
5094 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5095 &ut_params->aead_xform, ts_params->session_mpool);
5097 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5103 create_aead_xform(struct rte_crypto_op *op,
5104 enum rte_crypto_aead_algorithm algo,
5105 enum rte_crypto_aead_operation aead_op,
5106 uint8_t *key, const uint8_t key_len,
5107 const uint8_t aad_len, const uint8_t auth_len,
5110 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5111 "failed to allocate space for crypto transform");
5113 struct rte_crypto_sym_op *sym_op = op->sym;
5115 /* Setup AEAD Parameters */
5116 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5117 sym_op->xform->next = NULL;
5118 sym_op->xform->aead.algo = algo;
5119 sym_op->xform->aead.op = aead_op;
5120 sym_op->xform->aead.key.data = key;
5121 sym_op->xform->aead.key.length = key_len;
5122 sym_op->xform->aead.iv.offset = IV_OFFSET;
5123 sym_op->xform->aead.iv.length = iv_len;
5124 sym_op->xform->aead.digest_length = auth_len;
5125 sym_op->xform->aead.aad_length = aad_len;
5127 TEST_HEXDUMP(stdout, "key:", key, key_len);
5133 create_aead_operation(enum rte_crypto_aead_operation op,
5134 const struct aead_test_data *tdata)
5136 struct crypto_testsuite_params *ts_params = &testsuite_params;
5137 struct crypto_unittest_params *ut_params = &unittest_params;
5139 uint8_t *plaintext, *ciphertext;
5140 unsigned int aad_pad_len, plaintext_pad_len;
5142 /* Generate Crypto op data structure */
5143 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5144 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5145 TEST_ASSERT_NOT_NULL(ut_params->op,
5146 "Failed to allocate symmetric crypto operation struct");
5148 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5150 /* Append aad data */
5151 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5152 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5153 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5155 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5156 "no room to append aad");
5158 sym_op->aead.aad.phys_addr =
5159 rte_pktmbuf_iova(ut_params->ibuf);
5160 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5161 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5162 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5165 /* Append IV at the end of the crypto operation*/
5166 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5167 uint8_t *, IV_OFFSET);
5169 /* Copy IV 1 byte after the IV pointer, according to the API */
5170 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5171 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5174 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5175 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5177 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5178 "no room to append aad");
5180 sym_op->aead.aad.phys_addr =
5181 rte_pktmbuf_iova(ut_params->ibuf);
5182 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5183 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5186 /* Append IV at the end of the crypto operation*/
5187 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5188 uint8_t *, IV_OFFSET);
5190 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5191 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5195 /* Append plaintext/ciphertext */
5196 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5197 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5198 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5200 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5202 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5203 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
5204 tdata->plaintext.len);
5206 if (ut_params->obuf) {
5207 ciphertext = (uint8_t *)rte_pktmbuf_append(
5209 plaintext_pad_len + aad_pad_len);
5210 TEST_ASSERT_NOT_NULL(ciphertext,
5211 "no room to append ciphertext");
5213 memset(ciphertext + aad_pad_len, 0,
5214 tdata->ciphertext.len);
5217 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5218 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5220 TEST_ASSERT_NOT_NULL(ciphertext,
5221 "no room to append ciphertext");
5223 memcpy(ciphertext, tdata->ciphertext.data,
5224 tdata->ciphertext.len);
5225 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
5226 tdata->ciphertext.len);
5228 if (ut_params->obuf) {
5229 plaintext = (uint8_t *)rte_pktmbuf_append(
5231 plaintext_pad_len + aad_pad_len);
5232 TEST_ASSERT_NOT_NULL(plaintext,
5233 "no room to append plaintext");
5235 memset(plaintext + aad_pad_len, 0,
5236 tdata->plaintext.len);
5240 /* Append digest data */
5241 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5242 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5243 ut_params->obuf ? ut_params->obuf :
5245 tdata->auth_tag.len);
5246 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5247 "no room to append digest");
5248 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5249 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5250 ut_params->obuf ? ut_params->obuf :
5255 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5256 ut_params->ibuf, tdata->auth_tag.len);
5257 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5258 "no room to append digest");
5259 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5261 plaintext_pad_len + aad_pad_len);
5263 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5264 tdata->auth_tag.len);
5265 TEST_HEXDUMP(stdout, "digest:",
5266 sym_op->aead.digest.data,
5267 tdata->auth_tag.len);
5270 sym_op->aead.data.length = tdata->plaintext.len;
5271 sym_op->aead.data.offset = aad_pad_len;
5277 test_authenticated_encryption(const struct aead_test_data *tdata)
5279 struct crypto_testsuite_params *ts_params = &testsuite_params;
5280 struct crypto_unittest_params *ut_params = &unittest_params;
5283 uint8_t *ciphertext, *auth_tag;
5284 uint16_t plaintext_pad_len;
5287 /* Create AEAD session */
5288 retval = create_aead_session(ts_params->valid_devs[0],
5290 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5291 tdata->key.data, tdata->key.len,
5292 tdata->aad.len, tdata->auth_tag.len,
5297 if (tdata->aad.len > MBUF_SIZE) {
5298 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5299 /* Populate full size of add data */
5300 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5301 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5303 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5305 /* clear mbuf payload */
5306 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5307 rte_pktmbuf_tailroom(ut_params->ibuf));
5309 /* Create AEAD operation */
5310 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5314 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5316 ut_params->op->sym->m_src = ut_params->ibuf;
5318 /* Process crypto operation */
5319 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5320 ut_params->op), "failed to process sym crypto op");
5322 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5323 "crypto op processing failed");
5325 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5327 if (ut_params->op->sym->m_dst) {
5328 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5330 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5331 uint8_t *, plaintext_pad_len);
5333 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5335 ut_params->op->sym->cipher.data.offset);
5336 auth_tag = ciphertext + plaintext_pad_len;
5339 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5340 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5343 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5345 tdata->ciphertext.data,
5346 tdata->ciphertext.len,
5347 "Ciphertext data not as expected");
5349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5351 tdata->auth_tag.data,
5352 tdata->auth_tag.len,
5353 "Generated auth tag not as expected");
5360 test_AES_GCM_authenticated_encryption_test_case_1(void)
5362 return test_authenticated_encryption(&gcm_test_case_1);
5366 test_AES_GCM_authenticated_encryption_test_case_2(void)
5368 return test_authenticated_encryption(&gcm_test_case_2);
5372 test_AES_GCM_authenticated_encryption_test_case_3(void)
5374 return test_authenticated_encryption(&gcm_test_case_3);
5378 test_AES_GCM_authenticated_encryption_test_case_4(void)
5380 return test_authenticated_encryption(&gcm_test_case_4);
5384 test_AES_GCM_authenticated_encryption_test_case_5(void)
5386 return test_authenticated_encryption(&gcm_test_case_5);
5390 test_AES_GCM_authenticated_encryption_test_case_6(void)
5392 return test_authenticated_encryption(&gcm_test_case_6);
5396 test_AES_GCM_authenticated_encryption_test_case_7(void)
5398 return test_authenticated_encryption(&gcm_test_case_7);
5402 test_AES_GCM_auth_encryption_test_case_192_1(void)
5404 return test_authenticated_encryption(&gcm_test_case_192_1);
5408 test_AES_GCM_auth_encryption_test_case_192_2(void)
5410 return test_authenticated_encryption(&gcm_test_case_192_2);
5414 test_AES_GCM_auth_encryption_test_case_192_3(void)
5416 return test_authenticated_encryption(&gcm_test_case_192_3);
5420 test_AES_GCM_auth_encryption_test_case_192_4(void)
5422 return test_authenticated_encryption(&gcm_test_case_192_4);
5426 test_AES_GCM_auth_encryption_test_case_192_5(void)
5428 return test_authenticated_encryption(&gcm_test_case_192_5);
5432 test_AES_GCM_auth_encryption_test_case_192_6(void)
5434 return test_authenticated_encryption(&gcm_test_case_192_6);
5438 test_AES_GCM_auth_encryption_test_case_192_7(void)
5440 return test_authenticated_encryption(&gcm_test_case_192_7);
5444 test_AES_GCM_auth_encryption_test_case_256_1(void)
5446 return test_authenticated_encryption(&gcm_test_case_256_1);
5450 test_AES_GCM_auth_encryption_test_case_256_2(void)
5452 return test_authenticated_encryption(&gcm_test_case_256_2);
5456 test_AES_GCM_auth_encryption_test_case_256_3(void)
5458 return test_authenticated_encryption(&gcm_test_case_256_3);
5462 test_AES_GCM_auth_encryption_test_case_256_4(void)
5464 return test_authenticated_encryption(&gcm_test_case_256_4);
5468 test_AES_GCM_auth_encryption_test_case_256_5(void)
5470 return test_authenticated_encryption(&gcm_test_case_256_5);
5474 test_AES_GCM_auth_encryption_test_case_256_6(void)
5476 return test_authenticated_encryption(&gcm_test_case_256_6);
5480 test_AES_GCM_auth_encryption_test_case_256_7(void)
5482 return test_authenticated_encryption(&gcm_test_case_256_7);
5486 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5488 return test_authenticated_encryption(&gcm_test_case_aad_1);
5492 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5494 return test_authenticated_encryption(&gcm_test_case_aad_2);
5498 test_authenticated_decryption(const struct aead_test_data *tdata)
5500 struct crypto_testsuite_params *ts_params = &testsuite_params;
5501 struct crypto_unittest_params *ut_params = &unittest_params;
5507 /* Create AEAD session */
5508 retval = create_aead_session(ts_params->valid_devs[0],
5510 RTE_CRYPTO_AEAD_OP_DECRYPT,
5511 tdata->key.data, tdata->key.len,
5512 tdata->aad.len, tdata->auth_tag.len,
5517 /* alloc mbuf and set payload */
5518 if (tdata->aad.len > MBUF_SIZE) {
5519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5520 /* Populate full size of add data */
5521 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5522 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5524 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5526 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5527 rte_pktmbuf_tailroom(ut_params->ibuf));
5529 /* Create AEAD operation */
5530 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5534 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5536 ut_params->op->sym->m_src = ut_params->ibuf;
5538 /* Process crypto operation */
5539 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5540 ut_params->op), "failed to process sym crypto op");
5542 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5543 "crypto op processing failed");
5545 if (ut_params->op->sym->m_dst)
5546 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5549 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5551 ut_params->op->sym->cipher.data.offset);
5553 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5556 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5558 tdata->plaintext.data,
5559 tdata->plaintext.len,
5560 "Plaintext data not as expected");
5562 TEST_ASSERT_EQUAL(ut_params->op->status,
5563 RTE_CRYPTO_OP_STATUS_SUCCESS,
5564 "Authentication failed");
5569 test_AES_GCM_authenticated_decryption_test_case_1(void)
5571 return test_authenticated_decryption(&gcm_test_case_1);
5575 test_AES_GCM_authenticated_decryption_test_case_2(void)
5577 return test_authenticated_decryption(&gcm_test_case_2);
5581 test_AES_GCM_authenticated_decryption_test_case_3(void)
5583 return test_authenticated_decryption(&gcm_test_case_3);
5587 test_AES_GCM_authenticated_decryption_test_case_4(void)
5589 return test_authenticated_decryption(&gcm_test_case_4);
5593 test_AES_GCM_authenticated_decryption_test_case_5(void)
5595 return test_authenticated_decryption(&gcm_test_case_5);
5599 test_AES_GCM_authenticated_decryption_test_case_6(void)
5601 return test_authenticated_decryption(&gcm_test_case_6);
5605 test_AES_GCM_authenticated_decryption_test_case_7(void)
5607 return test_authenticated_decryption(&gcm_test_case_7);
5611 test_AES_GCM_auth_decryption_test_case_192_1(void)
5613 return test_authenticated_decryption(&gcm_test_case_192_1);
5617 test_AES_GCM_auth_decryption_test_case_192_2(void)
5619 return test_authenticated_decryption(&gcm_test_case_192_2);
5623 test_AES_GCM_auth_decryption_test_case_192_3(void)
5625 return test_authenticated_decryption(&gcm_test_case_192_3);
5629 test_AES_GCM_auth_decryption_test_case_192_4(void)
5631 return test_authenticated_decryption(&gcm_test_case_192_4);
5635 test_AES_GCM_auth_decryption_test_case_192_5(void)
5637 return test_authenticated_decryption(&gcm_test_case_192_5);
5641 test_AES_GCM_auth_decryption_test_case_192_6(void)
5643 return test_authenticated_decryption(&gcm_test_case_192_6);
5647 test_AES_GCM_auth_decryption_test_case_192_7(void)
5649 return test_authenticated_decryption(&gcm_test_case_192_7);
5653 test_AES_GCM_auth_decryption_test_case_256_1(void)
5655 return test_authenticated_decryption(&gcm_test_case_256_1);
5659 test_AES_GCM_auth_decryption_test_case_256_2(void)
5661 return test_authenticated_decryption(&gcm_test_case_256_2);
5665 test_AES_GCM_auth_decryption_test_case_256_3(void)
5667 return test_authenticated_decryption(&gcm_test_case_256_3);
5671 test_AES_GCM_auth_decryption_test_case_256_4(void)
5673 return test_authenticated_decryption(&gcm_test_case_256_4);
5677 test_AES_GCM_auth_decryption_test_case_256_5(void)
5679 return test_authenticated_decryption(&gcm_test_case_256_5);
5683 test_AES_GCM_auth_decryption_test_case_256_6(void)
5685 return test_authenticated_decryption(&gcm_test_case_256_6);
5689 test_AES_GCM_auth_decryption_test_case_256_7(void)
5691 return test_authenticated_decryption(&gcm_test_case_256_7);
5695 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5697 return test_authenticated_decryption(&gcm_test_case_aad_1);
5701 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5703 return test_authenticated_decryption(&gcm_test_case_aad_2);
5707 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5709 struct crypto_testsuite_params *ts_params = &testsuite_params;
5710 struct crypto_unittest_params *ut_params = &unittest_params;
5713 uint8_t *ciphertext, *auth_tag;
5714 uint16_t plaintext_pad_len;
5716 /* Create AEAD session */
5717 retval = create_aead_session(ts_params->valid_devs[0],
5719 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5720 tdata->key.data, tdata->key.len,
5721 tdata->aad.len, tdata->auth_tag.len,
5726 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5727 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5729 /* clear mbuf payload */
5730 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5731 rte_pktmbuf_tailroom(ut_params->ibuf));
5732 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5733 rte_pktmbuf_tailroom(ut_params->obuf));
5735 /* Create AEAD operation */
5736 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5740 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5742 ut_params->op->sym->m_src = ut_params->ibuf;
5743 ut_params->op->sym->m_dst = ut_params->obuf;
5745 /* Process crypto operation */
5746 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5747 ut_params->op), "failed to process sym crypto op");
5749 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5750 "crypto op processing failed");
5752 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5754 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5755 ut_params->op->sym->cipher.data.offset);
5756 auth_tag = ciphertext + plaintext_pad_len;
5758 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5759 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5762 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5764 tdata->ciphertext.data,
5765 tdata->ciphertext.len,
5766 "Ciphertext data not as expected");
5768 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5770 tdata->auth_tag.data,
5771 tdata->auth_tag.len,
5772 "Generated auth tag not as expected");
5779 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5781 return test_authenticated_encryption_oop(&gcm_test_case_5);
5785 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5787 struct crypto_testsuite_params *ts_params = &testsuite_params;
5788 struct crypto_unittest_params *ut_params = &unittest_params;
5793 /* Create AEAD session */
5794 retval = create_aead_session(ts_params->valid_devs[0],
5796 RTE_CRYPTO_AEAD_OP_DECRYPT,
5797 tdata->key.data, tdata->key.len,
5798 tdata->aad.len, tdata->auth_tag.len,
5803 /* alloc mbuf and set payload */
5804 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5805 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5807 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5808 rte_pktmbuf_tailroom(ut_params->ibuf));
5809 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5810 rte_pktmbuf_tailroom(ut_params->obuf));
5812 /* Create AEAD operation */
5813 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5817 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5819 ut_params->op->sym->m_src = ut_params->ibuf;
5820 ut_params->op->sym->m_dst = ut_params->obuf;
5822 /* Process crypto operation */
5823 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5824 ut_params->op), "failed to process sym crypto op");
5826 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5827 "crypto op processing failed");
5829 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5830 ut_params->op->sym->cipher.data.offset);
5832 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5835 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5837 tdata->plaintext.data,
5838 tdata->plaintext.len,
5839 "Plaintext data not as expected");
5841 TEST_ASSERT_EQUAL(ut_params->op->status,
5842 RTE_CRYPTO_OP_STATUS_SUCCESS,
5843 "Authentication failed");
5848 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5850 return test_authenticated_decryption_oop(&gcm_test_case_5);
5854 test_authenticated_encryption_sessionless(
5855 const struct aead_test_data *tdata)
5857 struct crypto_testsuite_params *ts_params = &testsuite_params;
5858 struct crypto_unittest_params *ut_params = &unittest_params;
5861 uint8_t *ciphertext, *auth_tag;
5862 uint16_t plaintext_pad_len;
5863 uint8_t key[tdata->key.len + 1];
5865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5867 /* clear mbuf payload */
5868 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5869 rte_pktmbuf_tailroom(ut_params->ibuf));
5871 /* Create AEAD operation */
5872 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5876 /* Create GCM xform */
5877 memcpy(key, tdata->key.data, tdata->key.len);
5878 retval = create_aead_xform(ut_params->op,
5880 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5881 key, tdata->key.len,
5882 tdata->aad.len, tdata->auth_tag.len,
5887 ut_params->op->sym->m_src = ut_params->ibuf;
5889 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5890 RTE_CRYPTO_OP_SESSIONLESS,
5891 "crypto op session type not sessionless");
5893 /* Process crypto operation */
5894 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5895 ut_params->op), "failed to process sym crypto op");
5897 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5899 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5900 "crypto op status not success");
5902 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5904 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5905 ut_params->op->sym->cipher.data.offset);
5906 auth_tag = ciphertext + plaintext_pad_len;
5908 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5909 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5912 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5914 tdata->ciphertext.data,
5915 tdata->ciphertext.len,
5916 "Ciphertext data not as expected");
5918 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5920 tdata->auth_tag.data,
5921 tdata->auth_tag.len,
5922 "Generated auth tag not as expected");
5929 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5931 return test_authenticated_encryption_sessionless(
5936 test_authenticated_decryption_sessionless(
5937 const struct aead_test_data *tdata)
5939 struct crypto_testsuite_params *ts_params = &testsuite_params;
5940 struct crypto_unittest_params *ut_params = &unittest_params;
5944 uint8_t key[tdata->key.len + 1];
5946 /* alloc mbuf and set payload */
5947 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5950 rte_pktmbuf_tailroom(ut_params->ibuf));
5952 /* Create AEAD operation */
5953 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5957 /* Create AEAD xform */
5958 memcpy(key, tdata->key.data, tdata->key.len);
5959 retval = create_aead_xform(ut_params->op,
5961 RTE_CRYPTO_AEAD_OP_DECRYPT,
5962 key, tdata->key.len,
5963 tdata->aad.len, tdata->auth_tag.len,
5968 ut_params->op->sym->m_src = ut_params->ibuf;
5970 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5971 RTE_CRYPTO_OP_SESSIONLESS,
5972 "crypto op session type not sessionless");
5974 /* Process crypto operation */
5975 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5976 ut_params->op), "failed to process sym crypto op");
5978 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5980 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5981 "crypto op status not success");
5983 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5984 ut_params->op->sym->cipher.data.offset);
5986 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5989 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5991 tdata->plaintext.data,
5992 tdata->plaintext.len,
5993 "Plaintext data not as expected");
5995 TEST_ASSERT_EQUAL(ut_params->op->status,
5996 RTE_CRYPTO_OP_STATUS_SUCCESS,
5997 "Authentication failed");
6002 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6004 return test_authenticated_decryption_sessionless(
6009 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6011 return test_authenticated_encryption(&ccm_test_case_128_1);
6015 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6017 return test_authenticated_encryption(&ccm_test_case_128_2);
6021 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6023 return test_authenticated_encryption(&ccm_test_case_128_3);
6027 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6029 return test_authenticated_decryption(&ccm_test_case_128_1);
6033 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6035 return test_authenticated_decryption(&ccm_test_case_128_2);
6039 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6041 return test_authenticated_decryption(&ccm_test_case_128_3);
6045 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6047 return test_authenticated_encryption(&ccm_test_case_192_1);
6051 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6053 return test_authenticated_encryption(&ccm_test_case_192_2);
6057 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6059 return test_authenticated_encryption(&ccm_test_case_192_3);
6063 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6065 return test_authenticated_decryption(&ccm_test_case_192_1);
6069 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6071 return test_authenticated_decryption(&ccm_test_case_192_2);
6075 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6077 return test_authenticated_decryption(&ccm_test_case_192_3);
6081 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6083 return test_authenticated_encryption(&ccm_test_case_256_1);
6087 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6089 return test_authenticated_encryption(&ccm_test_case_256_2);
6093 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6095 return test_authenticated_encryption(&ccm_test_case_256_3);
6099 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6101 return test_authenticated_decryption(&ccm_test_case_256_1);
6105 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6107 return test_authenticated_decryption(&ccm_test_case_256_2);
6111 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6113 return test_authenticated_decryption(&ccm_test_case_256_3);
6119 struct crypto_testsuite_params *ts_params = &testsuite_params;
6120 struct rte_cryptodev_stats stats;
6121 struct rte_cryptodev *dev;
6122 cryptodev_stats_get_t temp_pfn;
6124 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6125 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6126 &stats) == -ENODEV),
6127 "rte_cryptodev_stats_get invalid dev failed");
6128 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6129 "rte_cryptodev_stats_get invalid Param failed");
6130 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6131 temp_pfn = dev->dev_ops->stats_get;
6132 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6133 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6135 "rte_cryptodev_stats_get invalid Param failed");
6136 dev->dev_ops->stats_get = temp_pfn;
6138 /* Test expected values */
6140 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6142 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6144 "rte_cryptodev_stats_get failed");
6145 TEST_ASSERT((stats.enqueued_count == 1),
6146 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6147 TEST_ASSERT((stats.dequeued_count == 1),
6148 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6149 TEST_ASSERT((stats.enqueue_err_count == 0),
6150 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6151 TEST_ASSERT((stats.dequeue_err_count == 0),
6152 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6154 /* invalid device but should ignore and not reset device stats*/
6155 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6156 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6158 "rte_cryptodev_stats_get failed");
6159 TEST_ASSERT((stats.enqueued_count == 1),
6160 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6162 /* check that a valid reset clears stats */
6163 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6164 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6166 "rte_cryptodev_stats_get failed");
6167 TEST_ASSERT((stats.enqueued_count == 0),
6168 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6169 TEST_ASSERT((stats.dequeued_count == 0),
6170 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6172 return TEST_SUCCESS;
6175 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6176 struct crypto_unittest_params *ut_params,
6177 enum rte_crypto_auth_operation op,
6178 const struct HMAC_MD5_vector *test_case)
6182 memcpy(key, test_case->key.data, test_case->key.len);
6184 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6185 ut_params->auth_xform.next = NULL;
6186 ut_params->auth_xform.auth.op = op;
6188 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6190 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6191 ut_params->auth_xform.auth.key.length = test_case->key.len;
6192 ut_params->auth_xform.auth.key.data = key;
6194 ut_params->sess = rte_cryptodev_sym_session_create(
6195 ts_params->session_mpool);
6197 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6198 ut_params->sess, &ut_params->auth_xform,
6199 ts_params->session_mpool);
6201 if (ut_params->sess == NULL)
6204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6207 rte_pktmbuf_tailroom(ut_params->ibuf));
6212 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6213 const struct HMAC_MD5_vector *test_case,
6214 uint8_t **plaintext)
6216 uint16_t plaintext_pad_len;
6218 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6220 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6223 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6225 memcpy(*plaintext, test_case->plaintext.data,
6226 test_case->plaintext.len);
6228 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6229 ut_params->ibuf, MD5_DIGEST_LEN);
6230 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6231 "no room to append digest");
6232 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6233 ut_params->ibuf, plaintext_pad_len);
6235 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6236 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6237 test_case->auth_tag.len);
6240 sym_op->auth.data.offset = 0;
6241 sym_op->auth.data.length = test_case->plaintext.len;
6243 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6244 ut_params->op->sym->m_src = ut_params->ibuf;
6250 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6252 uint16_t plaintext_pad_len;
6253 uint8_t *plaintext, *auth_tag;
6255 struct crypto_testsuite_params *ts_params = &testsuite_params;
6256 struct crypto_unittest_params *ut_params = &unittest_params;
6258 if (MD5_HMAC_create_session(ts_params, ut_params,
6259 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6262 /* Generate Crypto op data structure */
6263 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6264 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6265 TEST_ASSERT_NOT_NULL(ut_params->op,
6266 "Failed to allocate symmetric crypto operation struct");
6268 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6271 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6274 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6275 ut_params->op), "failed to process sym crypto op");
6277 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6278 "crypto op processing failed");
6280 if (ut_params->op->sym->m_dst) {
6281 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6282 uint8_t *, plaintext_pad_len);
6284 auth_tag = plaintext + plaintext_pad_len;
6287 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6289 test_case->auth_tag.data,
6290 test_case->auth_tag.len,
6291 "HMAC_MD5 generated tag not as expected");
6293 return TEST_SUCCESS;
6297 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6301 struct crypto_testsuite_params *ts_params = &testsuite_params;
6302 struct crypto_unittest_params *ut_params = &unittest_params;
6304 if (MD5_HMAC_create_session(ts_params, ut_params,
6305 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6309 /* Generate Crypto op data structure */
6310 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6311 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6312 TEST_ASSERT_NOT_NULL(ut_params->op,
6313 "Failed to allocate symmetric crypto operation struct");
6315 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6318 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6319 ut_params->op), "failed to process sym crypto op");
6321 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6322 "HMAC_MD5 crypto op processing failed");
6324 return TEST_SUCCESS;
6328 test_MD5_HMAC_generate_case_1(void)
6330 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6334 test_MD5_HMAC_verify_case_1(void)
6336 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6340 test_MD5_HMAC_generate_case_2(void)
6342 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6346 test_MD5_HMAC_verify_case_2(void)
6348 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6352 test_multi_session(void)
6354 struct crypto_testsuite_params *ts_params = &testsuite_params;
6355 struct crypto_unittest_params *ut_params = &unittest_params;
6357 struct rte_cryptodev_info dev_info;
6358 struct rte_cryptodev_sym_session **sessions;
6362 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6363 aes_cbc_key, hmac_sha512_key);
6366 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6368 sessions = rte_malloc(NULL,
6369 (sizeof(struct rte_cryptodev_sym_session *) *
6370 dev_info.sym.max_nb_sessions) + 1, 0);
6372 /* Create multiple crypto sessions*/
6373 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6375 sessions[i] = rte_cryptodev_sym_session_create(
6376 ts_params->session_mpool);
6378 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6379 sessions[i], &ut_params->auth_xform,
6380 ts_params->session_mpool);
6381 TEST_ASSERT_NOT_NULL(sessions[i],
6382 "Session creation failed at session number %u",
6385 /* Attempt to send a request on each session */
6386 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6390 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6391 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6393 "Failed to perform decrypt on request number %u.", i);
6394 /* free crypto operation structure */
6396 rte_crypto_op_free(ut_params->op);
6399 * free mbuf - both obuf and ibuf are usually the same,
6400 * so check if they point at the same address is necessary,
6401 * to avoid freeing the mbuf twice.
6403 if (ut_params->obuf) {
6404 rte_pktmbuf_free(ut_params->obuf);
6405 if (ut_params->ibuf == ut_params->obuf)
6406 ut_params->ibuf = 0;
6407 ut_params->obuf = 0;
6409 if (ut_params->ibuf) {
6410 rte_pktmbuf_free(ut_params->ibuf);
6411 ut_params->ibuf = 0;
6415 /* Next session create should fail */
6416 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6417 sessions[i], &ut_params->auth_xform,
6418 ts_params->session_mpool);
6419 TEST_ASSERT_NULL(sessions[i],
6420 "Session creation succeeded unexpectedly!");
6422 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6423 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6425 rte_cryptodev_sym_session_free(sessions[i]);
6430 return TEST_SUCCESS;
6433 struct multi_session_params {
6434 struct crypto_unittest_params ut_params;
6435 uint8_t *cipher_key;
6437 const uint8_t *cipher;
6438 const uint8_t *digest;
6442 #define MB_SESSION_NUMBER 3
6445 test_multi_session_random_usage(void)
6447 struct crypto_testsuite_params *ts_params = &testsuite_params;
6448 struct rte_cryptodev_info dev_info;
6449 struct rte_cryptodev_sym_session **sessions;
6451 struct multi_session_params ut_paramz[] = {
6454 .cipher_key = ms_aes_cbc_key0,
6455 .hmac_key = ms_hmac_key0,
6456 .cipher = ms_aes_cbc_cipher0,
6457 .digest = ms_hmac_digest0,
6458 .iv = ms_aes_cbc_iv0
6461 .cipher_key = ms_aes_cbc_key1,
6462 .hmac_key = ms_hmac_key1,
6463 .cipher = ms_aes_cbc_cipher1,
6464 .digest = ms_hmac_digest1,
6465 .iv = ms_aes_cbc_iv1
6468 .cipher_key = ms_aes_cbc_key2,
6469 .hmac_key = ms_hmac_key2,
6470 .cipher = ms_aes_cbc_cipher2,
6471 .digest = ms_hmac_digest2,
6472 .iv = ms_aes_cbc_iv2
6477 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6479 sessions = rte_malloc(NULL,
6480 (sizeof(struct rte_cryptodev_sym_session *)
6481 * dev_info.sym.max_nb_sessions) + 1, 0);
6483 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6484 sessions[i] = rte_cryptodev_sym_session_create(
6485 ts_params->session_mpool);
6487 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6488 sizeof(struct crypto_unittest_params));
6490 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6491 &ut_paramz[i].ut_params,
6492 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6494 /* Create multiple crypto sessions*/
6495 rte_cryptodev_sym_session_init(
6496 ts_params->valid_devs[0],
6498 &ut_paramz[i].ut_params.auth_xform,
6499 ts_params->session_mpool);
6501 TEST_ASSERT_NOT_NULL(sessions[i],
6502 "Session creation failed at session number %u",
6508 for (i = 0; i < 40000; i++) {
6510 j = rand() % MB_SESSION_NUMBER;
6512 TEST_ASSERT_SUCCESS(
6513 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6515 &ut_paramz[j].ut_params,
6516 ts_params, ut_paramz[j].cipher,
6517 ut_paramz[j].digest,
6519 "Failed to perform decrypt on request number %u.", i);
6521 if (ut_paramz[j].ut_params.op)
6522 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6525 * free mbuf - both obuf and ibuf are usually the same,
6526 * so check if they point at the same address is necessary,
6527 * to avoid freeing the mbuf twice.
6529 if (ut_paramz[j].ut_params.obuf) {
6530 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6531 if (ut_paramz[j].ut_params.ibuf
6532 == ut_paramz[j].ut_params.obuf)
6533 ut_paramz[j].ut_params.ibuf = 0;
6534 ut_paramz[j].ut_params.obuf = 0;
6536 if (ut_paramz[j].ut_params.ibuf) {
6537 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6538 ut_paramz[j].ut_params.ibuf = 0;
6542 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6543 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6545 rte_cryptodev_sym_session_free(sessions[i]);
6550 return TEST_SUCCESS;
6554 test_null_cipher_only_operation(void)
6556 struct crypto_testsuite_params *ts_params = &testsuite_params;
6557 struct crypto_unittest_params *ut_params = &unittest_params;
6559 /* Generate test mbuf data and space for digest */
6560 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6561 catch_22_quote, QUOTE_512_BYTES, 0);
6563 /* Setup Cipher Parameters */
6564 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6565 ut_params->cipher_xform.next = NULL;
6567 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6568 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6570 ut_params->sess = rte_cryptodev_sym_session_create(
6571 ts_params->session_mpool);
6573 /* Create Crypto session*/
6574 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6576 &ut_params->cipher_xform,
6577 ts_params->session_mpool);
6578 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6580 /* Generate Crypto op data structure */
6581 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6582 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6583 TEST_ASSERT_NOT_NULL(ut_params->op,
6584 "Failed to allocate symmetric crypto operation struct");
6586 /* Set crypto operation data parameters */
6587 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6589 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6591 /* set crypto operation source mbuf */
6592 sym_op->m_src = ut_params->ibuf;
6594 sym_op->cipher.data.offset = 0;
6595 sym_op->cipher.data.length = QUOTE_512_BYTES;
6597 /* Process crypto operation */
6598 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6600 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6602 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6603 "crypto operation processing failed");
6606 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6607 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6610 "Ciphertext data not as expected");
6612 return TEST_SUCCESS;
6616 test_null_auth_only_operation(void)
6618 struct crypto_testsuite_params *ts_params = &testsuite_params;
6619 struct crypto_unittest_params *ut_params = &unittest_params;
6621 /* Generate test mbuf data and space for digest */
6622 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6623 catch_22_quote, QUOTE_512_BYTES, 0);
6625 /* Setup HMAC Parameters */
6626 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6627 ut_params->auth_xform.next = NULL;
6629 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6630 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6632 ut_params->sess = rte_cryptodev_sym_session_create(
6633 ts_params->session_mpool);
6635 /* Create Crypto session*/
6636 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6637 ut_params->sess, &ut_params->auth_xform,
6638 ts_params->session_mpool);
6639 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6641 /* Generate Crypto op data structure */
6642 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6643 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6644 TEST_ASSERT_NOT_NULL(ut_params->op,
6645 "Failed to allocate symmetric crypto operation struct");
6647 /* Set crypto operation data parameters */
6648 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6650 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6652 sym_op->m_src = ut_params->ibuf;
6654 sym_op->auth.data.offset = 0;
6655 sym_op->auth.data.length = QUOTE_512_BYTES;
6657 /* Process crypto operation */
6658 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6660 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6662 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6663 "crypto operation processing failed");
6665 return TEST_SUCCESS;
6669 test_null_cipher_auth_operation(void)
6671 struct crypto_testsuite_params *ts_params = &testsuite_params;
6672 struct crypto_unittest_params *ut_params = &unittest_params;
6674 /* Generate test mbuf data and space for digest */
6675 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6676 catch_22_quote, QUOTE_512_BYTES, 0);
6678 /* Setup Cipher Parameters */
6679 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6680 ut_params->cipher_xform.next = &ut_params->auth_xform;
6682 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6683 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6685 /* Setup HMAC Parameters */
6686 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6687 ut_params->auth_xform.next = NULL;
6689 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6690 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6692 ut_params->sess = rte_cryptodev_sym_session_create(
6693 ts_params->session_mpool);
6695 /* Create Crypto session*/
6696 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6697 ut_params->sess, &ut_params->cipher_xform,
6698 ts_params->session_mpool);
6699 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6701 /* Generate Crypto op data structure */
6702 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6703 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6704 TEST_ASSERT_NOT_NULL(ut_params->op,
6705 "Failed to allocate symmetric crypto operation struct");
6707 /* Set crypto operation data parameters */
6708 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6710 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6712 sym_op->m_src = ut_params->ibuf;
6714 sym_op->cipher.data.offset = 0;
6715 sym_op->cipher.data.length = QUOTE_512_BYTES;
6717 sym_op->auth.data.offset = 0;
6718 sym_op->auth.data.length = QUOTE_512_BYTES;
6720 /* Process crypto operation */
6721 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6723 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6725 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6726 "crypto operation processing failed");
6729 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6730 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6733 "Ciphertext data not as expected");
6735 return TEST_SUCCESS;
6739 test_null_auth_cipher_operation(void)
6741 struct crypto_testsuite_params *ts_params = &testsuite_params;
6742 struct crypto_unittest_params *ut_params = &unittest_params;
6744 /* Generate test mbuf data and space for digest */
6745 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6746 catch_22_quote, QUOTE_512_BYTES, 0);
6748 /* Setup Cipher Parameters */
6749 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6750 ut_params->cipher_xform.next = NULL;
6752 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6753 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6755 /* Setup HMAC Parameters */
6756 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6757 ut_params->auth_xform.next = &ut_params->cipher_xform;
6759 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6760 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6762 ut_params->sess = rte_cryptodev_sym_session_create(
6763 ts_params->session_mpool);
6765 /* Create Crypto session*/
6766 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6767 ut_params->sess, &ut_params->cipher_xform,
6768 ts_params->session_mpool);
6769 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6771 /* Generate Crypto op data structure */
6772 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6773 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6774 TEST_ASSERT_NOT_NULL(ut_params->op,
6775 "Failed to allocate symmetric crypto operation struct");
6777 /* Set crypto operation data parameters */
6778 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6780 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6782 sym_op->m_src = ut_params->ibuf;
6784 sym_op->cipher.data.offset = 0;
6785 sym_op->cipher.data.length = QUOTE_512_BYTES;
6787 sym_op->auth.data.offset = 0;
6788 sym_op->auth.data.length = QUOTE_512_BYTES;
6790 /* Process crypto operation */
6791 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6793 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6795 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6796 "crypto operation processing failed");
6799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6800 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6803 "Ciphertext data not as expected");
6805 return TEST_SUCCESS;
6810 test_null_invalid_operation(void)
6812 struct crypto_testsuite_params *ts_params = &testsuite_params;
6813 struct crypto_unittest_params *ut_params = &unittest_params;
6816 /* Setup Cipher Parameters */
6817 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6818 ut_params->cipher_xform.next = NULL;
6820 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6821 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6823 ut_params->sess = rte_cryptodev_sym_session_create(
6824 ts_params->session_mpool);
6826 /* Create Crypto session*/
6827 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6828 ut_params->sess, &ut_params->cipher_xform,
6829 ts_params->session_mpool);
6830 TEST_ASSERT(ret < 0,
6831 "Session creation succeeded unexpectedly");
6834 /* Setup HMAC Parameters */
6835 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6836 ut_params->auth_xform.next = NULL;
6838 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6839 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6841 ut_params->sess = rte_cryptodev_sym_session_create(
6842 ts_params->session_mpool);
6844 /* Create Crypto session*/
6845 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6846 ut_params->sess, &ut_params->auth_xform,
6847 ts_params->session_mpool);
6848 TEST_ASSERT(ret < 0,
6849 "Session creation succeeded unexpectedly");
6851 return TEST_SUCCESS;
6855 #define NULL_BURST_LENGTH (32)
6858 test_null_burst_operation(void)
6860 struct crypto_testsuite_params *ts_params = &testsuite_params;
6861 struct crypto_unittest_params *ut_params = &unittest_params;
6863 unsigned i, burst_len = NULL_BURST_LENGTH;
6865 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6866 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6868 /* Setup Cipher Parameters */
6869 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6870 ut_params->cipher_xform.next = &ut_params->auth_xform;
6872 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6873 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6875 /* Setup HMAC Parameters */
6876 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6877 ut_params->auth_xform.next = NULL;
6879 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6880 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6882 ut_params->sess = rte_cryptodev_sym_session_create(
6883 ts_params->session_mpool);
6885 /* Create Crypto session*/
6886 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6887 ut_params->sess, &ut_params->cipher_xform,
6888 ts_params->session_mpool);
6889 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6891 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6892 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6893 burst_len, "failed to generate burst of crypto ops");
6895 /* Generate an operation for each mbuf in burst */
6896 for (i = 0; i < burst_len; i++) {
6897 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6899 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6901 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6905 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6907 burst[i]->sym->m_src = m;
6910 /* Process crypto operation */
6911 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6912 0, burst, burst_len),
6914 "Error enqueuing burst");
6916 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6917 0, burst_dequeued, burst_len),
6919 "Error dequeuing burst");
6922 for (i = 0; i < burst_len; i++) {
6924 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6925 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6927 "data not as expected");
6929 rte_pktmbuf_free(burst[i]->sym->m_src);
6930 rte_crypto_op_free(burst[i]);
6933 return TEST_SUCCESS;
6937 generate_gmac_large_plaintext(uint8_t *data)
6941 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6942 memcpy(&data[i], &data[0], 32);
6946 create_gmac_operation(enum rte_crypto_auth_operation op,
6947 const struct gmac_test_data *tdata)
6949 struct crypto_testsuite_params *ts_params = &testsuite_params;
6950 struct crypto_unittest_params *ut_params = &unittest_params;
6951 struct rte_crypto_sym_op *sym_op;
6953 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6955 /* Generate Crypto op data structure */
6956 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6957 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6958 TEST_ASSERT_NOT_NULL(ut_params->op,
6959 "Failed to allocate symmetric crypto operation struct");
6961 sym_op = ut_params->op->sym;
6963 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6964 ut_params->ibuf, tdata->gmac_tag.len);
6965 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6966 "no room to append digest");
6968 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6969 ut_params->ibuf, plaintext_pad_len);
6971 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6972 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6973 tdata->gmac_tag.len);
6974 TEST_HEXDUMP(stdout, "digest:",
6975 sym_op->auth.digest.data,
6976 tdata->gmac_tag.len);
6979 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6980 uint8_t *, IV_OFFSET);
6982 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6984 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6986 sym_op->cipher.data.length = 0;
6987 sym_op->cipher.data.offset = 0;
6989 sym_op->auth.data.offset = 0;
6990 sym_op->auth.data.length = tdata->plaintext.len;
6995 static int create_gmac_session(uint8_t dev_id,
6996 const struct gmac_test_data *tdata,
6997 enum rte_crypto_auth_operation auth_op)
6999 uint8_t auth_key[tdata->key.len];
7001 struct crypto_testsuite_params *ts_params = &testsuite_params;
7002 struct crypto_unittest_params *ut_params = &unittest_params;
7004 memcpy(auth_key, tdata->key.data, tdata->key.len);
7006 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7007 ut_params->auth_xform.next = NULL;
7009 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7010 ut_params->auth_xform.auth.op = auth_op;
7011 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7012 ut_params->auth_xform.auth.key.length = tdata->key.len;
7013 ut_params->auth_xform.auth.key.data = auth_key;
7014 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7015 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7018 ut_params->sess = rte_cryptodev_sym_session_create(
7019 ts_params->session_mpool);
7021 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7022 &ut_params->auth_xform,
7023 ts_params->session_mpool);
7025 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7031 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7033 struct crypto_testsuite_params *ts_params = &testsuite_params;
7034 struct crypto_unittest_params *ut_params = &unittest_params;
7038 uint8_t *auth_tag, *plaintext;
7039 uint16_t plaintext_pad_len;
7041 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7042 "No GMAC length in the source data");
7044 retval = create_gmac_session(ts_params->valid_devs[0],
7045 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7050 if (tdata->plaintext.len > MBUF_SIZE)
7051 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7053 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7054 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7055 "Failed to allocate input buffer in mempool");
7057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7058 rte_pktmbuf_tailroom(ut_params->ibuf));
7060 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7062 * Runtime generate the large plain text instead of use hard code
7063 * plain text vector. It is done to avoid create huge source file
7064 * with the test vector.
7066 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7067 generate_gmac_large_plaintext(tdata->plaintext.data);
7069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7071 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7073 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7074 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7075 tdata->plaintext.len);
7077 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7083 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7085 ut_params->op->sym->m_src = ut_params->ibuf;
7087 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7088 ut_params->op), "failed to process sym crypto op");
7090 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7091 "crypto op processing failed");
7093 if (ut_params->op->sym->m_dst) {
7094 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7095 uint8_t *, plaintext_pad_len);
7097 auth_tag = plaintext + plaintext_pad_len;
7100 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7102 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7104 tdata->gmac_tag.data,
7105 tdata->gmac_tag.len,
7106 "GMAC Generated auth tag not as expected");
7112 test_AES_GMAC_authentication_test_case_1(void)
7114 return test_AES_GMAC_authentication(&gmac_test_case_1);
7118 test_AES_GMAC_authentication_test_case_2(void)
7120 return test_AES_GMAC_authentication(&gmac_test_case_2);
7124 test_AES_GMAC_authentication_test_case_3(void)
7126 return test_AES_GMAC_authentication(&gmac_test_case_3);
7130 test_AES_GMAC_authentication_test_case_4(void)
7132 return test_AES_GMAC_authentication(&gmac_test_case_4);
7136 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7138 struct crypto_testsuite_params *ts_params = &testsuite_params;
7139 struct crypto_unittest_params *ut_params = &unittest_params;
7141 uint32_t plaintext_pad_len;
7144 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7145 "No GMAC length in the source data");
7147 retval = create_gmac_session(ts_params->valid_devs[0],
7148 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7153 if (tdata->plaintext.len > MBUF_SIZE)
7154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7157 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7158 "Failed to allocate input buffer in mempool");
7160 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7161 rte_pktmbuf_tailroom(ut_params->ibuf));
7163 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7166 * Runtime generate the large plain text instead of use hard code
7167 * plain text vector. It is done to avoid create huge source file
7168 * with the test vector.
7170 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7171 generate_gmac_large_plaintext(tdata->plaintext.data);
7173 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7175 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7177 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7178 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7179 tdata->plaintext.len);
7181 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7187 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7189 ut_params->op->sym->m_src = ut_params->ibuf;
7191 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7192 ut_params->op), "failed to process sym crypto op");
7194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7195 "crypto op processing failed");
7202 test_AES_GMAC_authentication_verify_test_case_1(void)
7204 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7208 test_AES_GMAC_authentication_verify_test_case_2(void)
7210 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7214 test_AES_GMAC_authentication_verify_test_case_3(void)
7216 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7220 test_AES_GMAC_authentication_verify_test_case_4(void)
7222 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7225 struct test_crypto_vector {
7226 enum rte_crypto_cipher_algorithm crypto_algo;
7239 const uint8_t *data;
7244 const uint8_t *data;
7248 enum rte_crypto_auth_algorithm auth_algo;
7256 const uint8_t *data;
7266 static const struct test_crypto_vector
7267 hmac_sha1_test_crypto_vector = {
7268 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7270 .data = plaintext_hash,
7275 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7276 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7277 0xDE, 0xF4, 0xDE, 0xAD
7283 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7284 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7285 0x3F, 0x91, 0x64, 0x59
7291 static const struct test_crypto_vector
7292 aes128_gmac_test_vector = {
7293 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7295 .data = plaintext_hash,
7300 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7301 0x08, 0x09, 0x0A, 0x0B
7307 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7308 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7314 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7315 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7321 static const struct test_crypto_vector
7322 aes128cbc_hmac_sha1_test_vector = {
7323 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7326 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7327 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7333 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7334 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7339 .data = plaintext_hash,
7343 .data = ciphertext512_aes128cbc,
7346 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7349 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7350 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7351 0xDE, 0xF4, 0xDE, 0xAD
7357 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7358 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7359 0x18, 0x8C, 0x1D, 0x32
7366 data_corruption(uint8_t *data)
7372 tag_corruption(uint8_t *data, unsigned int tag_offset)
7374 data[tag_offset] += 1;
7378 create_auth_session(struct crypto_unittest_params *ut_params,
7380 const struct test_crypto_vector *reference,
7381 enum rte_crypto_auth_operation auth_op)
7383 struct crypto_testsuite_params *ts_params = &testsuite_params;
7384 uint8_t auth_key[reference->auth_key.len + 1];
7386 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7388 /* Setup Authentication Parameters */
7389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7390 ut_params->auth_xform.auth.op = auth_op;
7391 ut_params->auth_xform.next = NULL;
7392 ut_params->auth_xform.auth.algo = reference->auth_algo;
7393 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7394 ut_params->auth_xform.auth.key.data = auth_key;
7395 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7397 /* Create Crypto session*/
7398 ut_params->sess = rte_cryptodev_sym_session_create(
7399 ts_params->session_mpool);
7401 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7402 &ut_params->auth_xform,
7403 ts_params->session_mpool);
7405 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7411 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7413 const struct test_crypto_vector *reference,
7414 enum rte_crypto_auth_operation auth_op,
7415 enum rte_crypto_cipher_operation cipher_op)
7417 struct crypto_testsuite_params *ts_params = &testsuite_params;
7418 uint8_t cipher_key[reference->cipher_key.len + 1];
7419 uint8_t auth_key[reference->auth_key.len + 1];
7421 memcpy(cipher_key, reference->cipher_key.data,
7422 reference->cipher_key.len);
7423 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7425 /* Setup Authentication Parameters */
7426 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7427 ut_params->auth_xform.auth.op = auth_op;
7428 ut_params->auth_xform.auth.algo = reference->auth_algo;
7429 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7430 ut_params->auth_xform.auth.key.data = auth_key;
7431 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7433 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7434 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7435 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7437 ut_params->auth_xform.next = &ut_params->cipher_xform;
7439 /* Setup Cipher Parameters */
7440 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7441 ut_params->cipher_xform.next = NULL;
7442 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7443 ut_params->cipher_xform.cipher.op = cipher_op;
7444 ut_params->cipher_xform.cipher.key.data = cipher_key;
7445 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7446 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7447 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7450 /* Create Crypto session*/
7451 ut_params->sess = rte_cryptodev_sym_session_create(
7452 ts_params->session_mpool);
7454 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7455 &ut_params->auth_xform,
7456 ts_params->session_mpool);
7458 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7464 create_auth_operation(struct crypto_testsuite_params *ts_params,
7465 struct crypto_unittest_params *ut_params,
7466 const struct test_crypto_vector *reference,
7467 unsigned int auth_generate)
7469 /* Generate Crypto op data structure */
7470 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7471 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7472 TEST_ASSERT_NOT_NULL(ut_params->op,
7473 "Failed to allocate pktmbuf offload");
7475 /* Set crypto operation data parameters */
7476 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7478 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7480 /* set crypto operation source mbuf */
7481 sym_op->m_src = ut_params->ibuf;
7484 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7485 ut_params->ibuf, reference->digest.len);
7487 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7488 "no room to append auth tag");
7490 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7491 ut_params->ibuf, reference->plaintext.len);
7494 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7496 memcpy(sym_op->auth.digest.data,
7497 reference->digest.data,
7498 reference->digest.len);
7500 TEST_HEXDUMP(stdout, "digest:",
7501 sym_op->auth.digest.data,
7502 reference->digest.len);
7504 sym_op->auth.data.length = reference->plaintext.len;
7505 sym_op->auth.data.offset = 0;
7511 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7512 struct crypto_unittest_params *ut_params,
7513 const struct test_crypto_vector *reference,
7514 unsigned int auth_generate)
7516 /* Generate Crypto op data structure */
7517 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7518 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7519 TEST_ASSERT_NOT_NULL(ut_params->op,
7520 "Failed to allocate pktmbuf offload");
7522 /* Set crypto operation data parameters */
7523 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7525 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7527 /* set crypto operation source mbuf */
7528 sym_op->m_src = ut_params->ibuf;
7531 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7532 ut_params->ibuf, reference->digest.len);
7534 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7535 "no room to append auth tag");
7537 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7538 ut_params->ibuf, reference->ciphertext.len);
7541 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7543 memcpy(sym_op->auth.digest.data,
7544 reference->digest.data,
7545 reference->digest.len);
7547 TEST_HEXDUMP(stdout, "digest:",
7548 sym_op->auth.digest.data,
7549 reference->digest.len);
7551 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7552 reference->iv.data, reference->iv.len);
7554 sym_op->cipher.data.length = 0;
7555 sym_op->cipher.data.offset = 0;
7557 sym_op->auth.data.length = reference->plaintext.len;
7558 sym_op->auth.data.offset = 0;
7564 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7565 struct crypto_unittest_params *ut_params,
7566 const struct test_crypto_vector *reference,
7567 unsigned int auth_generate)
7569 /* Generate Crypto op data structure */
7570 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7571 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7572 TEST_ASSERT_NOT_NULL(ut_params->op,
7573 "Failed to allocate pktmbuf offload");
7575 /* Set crypto operation data parameters */
7576 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7578 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7580 /* set crypto operation source mbuf */
7581 sym_op->m_src = ut_params->ibuf;
7584 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7585 ut_params->ibuf, reference->digest.len);
7587 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7588 "no room to append auth tag");
7590 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7591 ut_params->ibuf, reference->ciphertext.len);
7594 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7596 memcpy(sym_op->auth.digest.data,
7597 reference->digest.data,
7598 reference->digest.len);
7600 TEST_HEXDUMP(stdout, "digest:",
7601 sym_op->auth.digest.data,
7602 reference->digest.len);
7604 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7605 reference->iv.data, reference->iv.len);
7607 sym_op->cipher.data.length = reference->ciphertext.len;
7608 sym_op->cipher.data.offset = 0;
7610 sym_op->auth.data.length = reference->ciphertext.len;
7611 sym_op->auth.data.offset = 0;
7617 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7618 struct crypto_unittest_params *ut_params,
7619 const struct test_crypto_vector *reference)
7621 return create_auth_operation(ts_params, ut_params, reference, 0);
7625 create_auth_verify_GMAC_operation(
7626 struct crypto_testsuite_params *ts_params,
7627 struct crypto_unittest_params *ut_params,
7628 const struct test_crypto_vector *reference)
7630 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7634 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7635 struct crypto_unittest_params *ut_params,
7636 const struct test_crypto_vector *reference)
7638 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7642 test_authentication_verify_fail_when_data_corruption(
7643 struct crypto_testsuite_params *ts_params,
7644 struct crypto_unittest_params *ut_params,
7645 const struct test_crypto_vector *reference,
7646 unsigned int data_corrupted)
7652 /* Create session */
7653 retval = create_auth_session(ut_params,
7654 ts_params->valid_devs[0],
7656 RTE_CRYPTO_AUTH_OP_VERIFY);
7660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7661 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7662 "Failed to allocate input buffer in mempool");
7664 /* clear mbuf payload */
7665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7666 rte_pktmbuf_tailroom(ut_params->ibuf));
7668 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7669 reference->plaintext.len);
7670 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7671 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7673 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7675 /* Create operation */
7676 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7682 data_corruption(plaintext);
7684 tag_corruption(plaintext, reference->plaintext.len);
7686 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7688 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7689 TEST_ASSERT_EQUAL(ut_params->op->status,
7690 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7691 "authentication not failed");
7693 ut_params->obuf = ut_params->op->sym->m_src;
7694 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7700 test_authentication_verify_GMAC_fail_when_corruption(
7701 struct crypto_testsuite_params *ts_params,
7702 struct crypto_unittest_params *ut_params,
7703 const struct test_crypto_vector *reference,
7704 unsigned int data_corrupted)
7709 /* Create session */
7710 retval = create_auth_cipher_session(ut_params,
7711 ts_params->valid_devs[0],
7713 RTE_CRYPTO_AUTH_OP_VERIFY,
7714 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7720 "Failed to allocate input buffer in mempool");
7722 /* clear mbuf payload */
7723 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7724 rte_pktmbuf_tailroom(ut_params->ibuf));
7726 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7727 reference->plaintext.len);
7728 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7729 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7731 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7733 /* Create operation */
7734 retval = create_auth_verify_GMAC_operation(ts_params,
7742 data_corruption(plaintext);
7744 tag_corruption(plaintext, reference->aad.len);
7746 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7748 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7749 TEST_ASSERT_EQUAL(ut_params->op->status,
7750 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7751 "authentication not failed");
7753 ut_params->obuf = ut_params->op->sym->m_src;
7754 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7760 test_authenticated_decryption_fail_when_corruption(
7761 struct crypto_testsuite_params *ts_params,
7762 struct crypto_unittest_params *ut_params,
7763 const struct test_crypto_vector *reference,
7764 unsigned int data_corrupted)
7768 uint8_t *ciphertext;
7770 /* Create session */
7771 retval = create_auth_cipher_session(ut_params,
7772 ts_params->valid_devs[0],
7774 RTE_CRYPTO_AUTH_OP_VERIFY,
7775 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7779 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7780 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7781 "Failed to allocate input buffer in mempool");
7783 /* clear mbuf payload */
7784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7785 rte_pktmbuf_tailroom(ut_params->ibuf));
7787 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7788 reference->ciphertext.len);
7789 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7790 memcpy(ciphertext, reference->ciphertext.data,
7791 reference->ciphertext.len);
7793 /* Create operation */
7794 retval = create_cipher_auth_verify_operation(ts_params,
7802 data_corruption(ciphertext);
7804 tag_corruption(ciphertext, reference->ciphertext.len);
7806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7809 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7810 TEST_ASSERT_EQUAL(ut_params->op->status,
7811 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7812 "authentication not failed");
7814 ut_params->obuf = ut_params->op->sym->m_src;
7815 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7821 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7822 const struct aead_test_data *tdata,
7823 void *digest_mem, uint64_t digest_phys)
7825 struct crypto_testsuite_params *ts_params = &testsuite_params;
7826 struct crypto_unittest_params *ut_params = &unittest_params;
7828 const unsigned int auth_tag_len = tdata->auth_tag.len;
7829 const unsigned int iv_len = tdata->iv.len;
7830 unsigned int aad_len = tdata->aad.len;
7832 /* Generate Crypto op data structure */
7833 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7834 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7835 TEST_ASSERT_NOT_NULL(ut_params->op,
7836 "Failed to allocate symmetric crypto operation struct");
7838 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7840 sym_op->aead.digest.data = digest_mem;
7842 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7843 "no room to append digest");
7845 sym_op->aead.digest.phys_addr = digest_phys;
7847 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7848 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7850 TEST_HEXDUMP(stdout, "digest:",
7851 sym_op->aead.digest.data,
7855 /* Append aad data */
7856 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7857 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7858 uint8_t *, IV_OFFSET);
7860 /* Copy IV 1 byte after the IV pointer, according to the API */
7861 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7863 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7865 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7866 ut_params->ibuf, aad_len);
7867 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7868 "no room to prepend aad");
7869 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7872 memset(sym_op->aead.aad.data, 0, aad_len);
7873 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7874 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7876 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7877 TEST_HEXDUMP(stdout, "aad:",
7878 sym_op->aead.aad.data, aad_len);
7880 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7881 uint8_t *, IV_OFFSET);
7883 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7885 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7886 ut_params->ibuf, aad_len);
7887 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7888 "no room to prepend aad");
7889 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7892 memset(sym_op->aead.aad.data, 0, aad_len);
7893 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7895 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7896 TEST_HEXDUMP(stdout, "aad:",
7897 sym_op->aead.aad.data, aad_len);
7900 sym_op->aead.data.length = tdata->plaintext.len;
7901 sym_op->aead.data.offset = aad_len;
7906 #define SGL_MAX_NO 16
7909 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7910 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7912 struct crypto_testsuite_params *ts_params = &testsuite_params;
7913 struct crypto_unittest_params *ut_params = &unittest_params;
7914 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7917 int to_trn_tbl[SGL_MAX_NO];
7919 unsigned int trn_data = 0;
7920 uint8_t *plaintext, *ciphertext, *auth_tag;
7922 if (fragsz > tdata->plaintext.len)
7923 fragsz = tdata->plaintext.len;
7925 uint16_t plaintext_len = fragsz;
7926 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7928 if (fragsz_oop > tdata->plaintext.len)
7929 frag_size_oop = tdata->plaintext.len;
7932 void *digest_mem = NULL;
7934 uint32_t prepend_len = tdata->aad.len;
7936 if (tdata->plaintext.len % fragsz != 0) {
7937 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7940 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7945 * For out-op-place we need to alloc another mbuf
7948 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7949 rte_pktmbuf_append(ut_params->obuf,
7950 frag_size_oop + prepend_len);
7951 buf_oop = ut_params->obuf;
7954 /* Create AEAD session */
7955 retval = create_aead_session(ts_params->valid_devs[0],
7957 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7958 tdata->key.data, tdata->key.len,
7959 tdata->aad.len, tdata->auth_tag.len,
7964 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7966 /* clear mbuf payload */
7967 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7968 rte_pktmbuf_tailroom(ut_params->ibuf));
7970 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7973 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7975 trn_data += plaintext_len;
7977 buf = ut_params->ibuf;
7980 * Loop until no more fragments
7983 while (trn_data < tdata->plaintext.len) {
7985 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7986 (tdata->plaintext.len - trn_data) : fragsz;
7988 to_trn_tbl[ecx++] = to_trn;
7990 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7993 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7994 rte_pktmbuf_tailroom(buf));
7997 if (oop && !fragsz_oop) {
7998 buf_last_oop = buf_oop->next =
7999 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8000 buf_oop = buf_oop->next;
8001 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8002 0, rte_pktmbuf_tailroom(buf_oop));
8003 rte_pktmbuf_append(buf_oop, to_trn);
8006 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8009 memcpy(plaintext, tdata->plaintext.data + trn_data,
8012 if (trn_data == tdata->plaintext.len) {
8015 digest_mem = rte_pktmbuf_append(buf_oop,
8016 tdata->auth_tag.len);
8018 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8019 tdata->auth_tag.len);
8023 uint64_t digest_phys = 0;
8025 ut_params->ibuf->nb_segs = segs;
8028 if (fragsz_oop && oop) {
8032 if (frag_size_oop == tdata->plaintext.len) {
8033 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8034 tdata->auth_tag.len);
8036 digest_phys = rte_pktmbuf_iova_offset(
8038 tdata->plaintext.len + prepend_len);
8041 trn_data = frag_size_oop;
8042 while (trn_data < tdata->plaintext.len) {
8045 (tdata->plaintext.len - trn_data <
8047 (tdata->plaintext.len - trn_data) :
8050 to_trn_tbl[ecx++] = to_trn;
8052 buf_last_oop = buf_oop->next =
8053 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8054 buf_oop = buf_oop->next;
8055 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8056 0, rte_pktmbuf_tailroom(buf_oop));
8057 rte_pktmbuf_append(buf_oop, to_trn);
8061 if (trn_data == tdata->plaintext.len) {
8062 digest_mem = rte_pktmbuf_append(buf_oop,
8063 tdata->auth_tag.len);
8067 ut_params->obuf->nb_segs = segs;
8071 * Place digest at the end of the last buffer
8074 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8075 if (oop && buf_last_oop)
8076 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8078 if (!digest_mem && !oop) {
8079 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8080 + tdata->auth_tag.len);
8081 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8082 tdata->plaintext.len);
8085 /* Create AEAD operation */
8086 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8087 tdata, digest_mem, digest_phys);
8092 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8094 ut_params->op->sym->m_src = ut_params->ibuf;
8096 ut_params->op->sym->m_dst = ut_params->obuf;
8098 /* Process crypto operation */
8099 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8100 ut_params->op), "failed to process sym crypto op");
8102 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8103 "crypto op processing failed");
8106 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8107 uint8_t *, prepend_len);
8109 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8110 uint8_t *, prepend_len);
8114 fragsz = fragsz_oop;
8116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8118 tdata->ciphertext.data,
8120 "Ciphertext data not as expected");
8122 buf = ut_params->op->sym->m_src->next;
8124 buf = ut_params->op->sym->m_dst->next;
8126 unsigned int off = fragsz;
8130 ciphertext = rte_pktmbuf_mtod(buf,
8133 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8135 tdata->ciphertext.data + off,
8137 "Ciphertext data not as expected");
8139 off += to_trn_tbl[ecx++];
8143 auth_tag = digest_mem;
8144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8146 tdata->auth_tag.data,
8147 tdata->auth_tag.len,
8148 "Generated auth tag not as expected");
8154 #define OUT_OF_PLACE 1
8157 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8159 return test_authenticated_encryption_SGL(
8160 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8164 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8166 return test_authenticated_encryption_SGL(
8167 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8171 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8173 return test_authenticated_encryption_SGL(
8174 &gcm_test_case_8, OUT_OF_PLACE, 400,
8175 gcm_test_case_8.plaintext.len);
8179 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8182 return test_authenticated_encryption_SGL(
8183 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8187 test_authentication_verify_fail_when_data_corrupted(
8188 struct crypto_testsuite_params *ts_params,
8189 struct crypto_unittest_params *ut_params,
8190 const struct test_crypto_vector *reference)
8192 return test_authentication_verify_fail_when_data_corruption(
8193 ts_params, ut_params, reference, 1);
8197 test_authentication_verify_fail_when_tag_corrupted(
8198 struct crypto_testsuite_params *ts_params,
8199 struct crypto_unittest_params *ut_params,
8200 const struct test_crypto_vector *reference)
8202 return test_authentication_verify_fail_when_data_corruption(
8203 ts_params, ut_params, reference, 0);
8207 test_authentication_verify_GMAC_fail_when_data_corrupted(
8208 struct crypto_testsuite_params *ts_params,
8209 struct crypto_unittest_params *ut_params,
8210 const struct test_crypto_vector *reference)
8212 return test_authentication_verify_GMAC_fail_when_corruption(
8213 ts_params, ut_params, reference, 1);
8217 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8218 struct crypto_testsuite_params *ts_params,
8219 struct crypto_unittest_params *ut_params,
8220 const struct test_crypto_vector *reference)
8222 return test_authentication_verify_GMAC_fail_when_corruption(
8223 ts_params, ut_params, reference, 0);
8227 test_authenticated_decryption_fail_when_data_corrupted(
8228 struct crypto_testsuite_params *ts_params,
8229 struct crypto_unittest_params *ut_params,
8230 const struct test_crypto_vector *reference)
8232 return test_authenticated_decryption_fail_when_corruption(
8233 ts_params, ut_params, reference, 1);
8237 test_authenticated_decryption_fail_when_tag_corrupted(
8238 struct crypto_testsuite_params *ts_params,
8239 struct crypto_unittest_params *ut_params,
8240 const struct test_crypto_vector *reference)
8242 return test_authenticated_decryption_fail_when_corruption(
8243 ts_params, ut_params, reference, 0);
8247 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8249 return test_authentication_verify_fail_when_data_corrupted(
8250 &testsuite_params, &unittest_params,
8251 &hmac_sha1_test_crypto_vector);
8255 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8257 return test_authentication_verify_fail_when_tag_corrupted(
8258 &testsuite_params, &unittest_params,
8259 &hmac_sha1_test_crypto_vector);
8263 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8265 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8266 &testsuite_params, &unittest_params,
8267 &aes128_gmac_test_vector);
8271 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8273 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8274 &testsuite_params, &unittest_params,
8275 &aes128_gmac_test_vector);
8279 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8281 return test_authenticated_decryption_fail_when_data_corrupted(
8284 &aes128cbc_hmac_sha1_test_vector);
8288 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8290 return test_authenticated_decryption_fail_when_tag_corrupted(
8293 &aes128cbc_hmac_sha1_test_vector);
8296 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8298 /* global AESNI slave IDs for the scheduler test */
8299 uint8_t aesni_ids[2];
8302 test_scheduler_attach_slave_op(void)
8304 struct crypto_testsuite_params *ts_params = &testsuite_params;
8305 uint8_t sched_id = ts_params->valid_devs[0];
8306 uint32_t nb_devs, i, nb_devs_attached = 0;
8310 /* create 2 AESNI_MB if necessary */
8311 nb_devs = rte_cryptodev_device_count_by_driver(
8312 rte_cryptodev_driver_id_get(
8313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8315 for (i = nb_devs; i < 2; i++) {
8316 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8317 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8319 ret = rte_vdev_init(vdev_name, NULL);
8321 TEST_ASSERT(ret == 0,
8322 "Failed to create instance %u of"
8324 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8328 /* attach 2 AESNI_MB cdevs */
8329 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8331 struct rte_cryptodev_info info;
8333 rte_cryptodev_info_get(i, &info);
8334 if (info.driver_id != rte_cryptodev_driver_id_get(
8335 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8339 * Create the session mempool again, since now there are new devices
8340 * to use the mempool.
8342 if (ts_params->session_mpool) {
8343 rte_mempool_free(ts_params->session_mpool);
8344 ts_params->session_mpool = NULL;
8346 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8349 * Create mempool with maximum number of sessions * 2,
8350 * to include the session headers
8352 if (ts_params->session_mpool == NULL) {
8353 ts_params->session_mpool = rte_mempool_create(
8355 info.sym.max_nb_sessions * 2,
8357 0, 0, NULL, NULL, NULL,
8358 NULL, SOCKET_ID_ANY,
8361 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8362 "session mempool allocation failed");
8365 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8368 TEST_ASSERT(ret == 0,
8369 "Failed to attach device %u of pmd : %s", i,
8370 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8372 aesni_ids[nb_devs_attached] = (uint8_t)i;
8381 test_scheduler_detach_slave_op(void)
8383 struct crypto_testsuite_params *ts_params = &testsuite_params;
8384 uint8_t sched_id = ts_params->valid_devs[0];
8388 for (i = 0; i < 2; i++) {
8389 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8391 TEST_ASSERT(ret == 0,
8392 "Failed to detach device %u", aesni_ids[i]);
8399 test_scheduler_mode_op(void)
8401 struct crypto_testsuite_params *ts_params = &testsuite_params;
8402 uint8_t sched_id = ts_params->valid_devs[0];
8403 struct rte_cryptodev_scheduler_ops op = {0};
8404 struct rte_cryptodev_scheduler dummy_scheduler = {
8405 .description = "dummy scheduler to test mode",
8406 .name = "dummy scheduler",
8407 .mode = CDEV_SCHED_MODE_USERDEFINED,
8412 /* set user defined mode */
8413 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8415 TEST_ASSERT(ret == 0,
8416 "Failed to set cdev %u to user defined mode", sched_id);
8418 /* set round robin mode */
8419 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8420 CDEV_SCHED_MODE_ROUNDROBIN);
8421 TEST_ASSERT(ret == 0,
8422 "Failed to set cdev %u to round-robin mode", sched_id);
8423 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8424 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8430 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8431 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8432 .setup = testsuite_setup,
8433 .teardown = testsuite_teardown,
8434 .unit_test_cases = {
8435 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8436 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_AES_chain_scheduler_all),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_AES_cipheronly_scheduler_all),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_authonly_scheduler_all),
8443 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8444 TEST_CASES_END() /**< NULL terminate unit test array */
8448 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8450 static struct unit_test_suite cryptodev_qat_testsuite = {
8451 .suite_name = "Crypto QAT Unit Test Suite",
8452 .setup = testsuite_setup,
8453 .teardown = testsuite_teardown,
8454 .unit_test_cases = {
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_device_configure_invalid_dev_id),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_device_configure_invalid_queue_pair_ids),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_queue_pair_descriptor_setup),
8461 TEST_CASE_ST(ut_setup, ut_teardown,
8462 test_multi_session),
8464 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_AES_cipheronly_qat_all),
8467 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_3DES_cipheronly_qat_all),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_DES_cipheronly_qat_all),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_AES_docsis_qat_all),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_DES_docsis_qat_all),
8476 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8477 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8479 /** AES CCM Authenticated Encryption 128 bits key */
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_AES_CCM_authenticated_encryption_test_case_128_1),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_AES_CCM_authenticated_encryption_test_case_128_2),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_AES_CCM_authenticated_encryption_test_case_128_3),
8487 /** AES CCM Authenticated Decryption 128 bits key*/
8488 TEST_CASE_ST(ut_setup, ut_teardown,
8489 test_AES_CCM_authenticated_decryption_test_case_128_1),
8490 TEST_CASE_ST(ut_setup, ut_teardown,
8491 test_AES_CCM_authenticated_decryption_test_case_128_2),
8492 TEST_CASE_ST(ut_setup, ut_teardown,
8493 test_AES_CCM_authenticated_decryption_test_case_128_3),
8495 /** AES GCM Authenticated Encryption */
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_AES_GCM_authenticated_encryption_test_case_1),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_AES_GCM_authenticated_encryption_test_case_2),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_AES_GCM_authenticated_encryption_test_case_3),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_AES_GCM_authenticated_encryption_test_case_4),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_AES_GCM_authenticated_encryption_test_case_5),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_AES_GCM_authenticated_encryption_test_case_6),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_AES_GCM_authenticated_encryption_test_case_7),
8517 /** AES GCM Authenticated Decryption */
8518 TEST_CASE_ST(ut_setup, ut_teardown,
8519 test_AES_GCM_authenticated_decryption_test_case_1),
8520 TEST_CASE_ST(ut_setup, ut_teardown,
8521 test_AES_GCM_authenticated_decryption_test_case_2),
8522 TEST_CASE_ST(ut_setup, ut_teardown,
8523 test_AES_GCM_authenticated_decryption_test_case_3),
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_GCM_authenticated_decryption_test_case_4),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_AES_GCM_authenticated_decryption_test_case_5),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_authenticated_decryption_test_case_6),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_GCM_authenticated_decryption_test_case_7),
8533 /** AES GCM Authenticated Encryption 192 bits key */
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_GCM_auth_encryption_test_case_192_1),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_auth_encryption_test_case_192_2),
8538 TEST_CASE_ST(ut_setup, ut_teardown,
8539 test_AES_GCM_auth_encryption_test_case_192_3),
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_auth_encryption_test_case_192_4),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_auth_encryption_test_case_192_5),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_auth_encryption_test_case_192_6),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_auth_encryption_test_case_192_7),
8549 /** AES GCM Authenticated Decryption 192 bits key */
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_auth_decryption_test_case_192_1),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_auth_decryption_test_case_192_2),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_AES_GCM_auth_decryption_test_case_192_3),
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GCM_auth_decryption_test_case_192_4),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GCM_auth_decryption_test_case_192_5),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GCM_auth_decryption_test_case_192_6),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GCM_auth_decryption_test_case_192_7),
8565 /** AES GCM Authenticated Encryption 256 bits key */
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GCM_auth_encryption_test_case_256_1),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_AES_GCM_auth_encryption_test_case_256_2),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_AES_GCM_auth_encryption_test_case_256_3),
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_AES_GCM_auth_encryption_test_case_256_4),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_AES_GCM_auth_encryption_test_case_256_5),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_AES_GCM_auth_encryption_test_case_256_6),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_AES_GCM_auth_encryption_test_case_256_7),
8581 /** AES GMAC Authentication */
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_AES_GMAC_authentication_test_case_1),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_AES_GMAC_authentication_verify_test_case_1),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_AES_GMAC_authentication_test_case_2),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_AES_GMAC_authentication_verify_test_case_2),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_AES_GMAC_authentication_test_case_3),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_AES_GMAC_authentication_verify_test_case_3),
8595 /** SNOW 3G encrypt only (UEA2) */
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_snow3g_encryption_test_case_1),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_snow3g_encryption_test_case_2),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_snow3g_encryption_test_case_3),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_snow3g_encryption_test_case_4),
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_snow3g_encryption_test_case_5),
8607 TEST_CASE_ST(ut_setup, ut_teardown,
8608 test_snow3g_encryption_test_case_1_oop),
8609 TEST_CASE_ST(ut_setup, ut_teardown,
8610 test_snow3g_decryption_test_case_1_oop),
8612 /** SNOW 3G decrypt only (UEA2) */
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_snow3g_decryption_test_case_1),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_snow3g_decryption_test_case_2),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_snow3g_decryption_test_case_3),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_snow3g_decryption_test_case_4),
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_snow3g_decryption_test_case_5),
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_snow3g_hash_generate_test_case_1),
8625 TEST_CASE_ST(ut_setup, ut_teardown,
8626 test_snow3g_hash_generate_test_case_2),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_snow3g_hash_generate_test_case_3),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_snow3g_hash_verify_test_case_1),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_snow3g_hash_verify_test_case_2),
8633 TEST_CASE_ST(ut_setup, ut_teardown,
8634 test_snow3g_hash_verify_test_case_3),
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_snow3g_cipher_auth_test_case_1),
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_snow3g_auth_cipher_test_case_1),
8640 /** ZUC encrypt only (EEA3) */
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_zuc_encryption_test_case_1),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_zuc_encryption_test_case_2),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_zuc_encryption_test_case_3),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_zuc_encryption_test_case_4),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_zuc_encryption_test_case_5),
8652 /** ZUC authenticate (EIA3) */
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_zuc_hash_generate_test_case_6),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_zuc_hash_generate_test_case_7),
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_zuc_hash_generate_test_case_8),
8660 /** ZUC alg-chain (EEA3/EIA3) */
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_zuc_cipher_auth_test_case_1),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_zuc_cipher_auth_test_case_2),
8666 /** HMAC_MD5 Authentication */
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_MD5_HMAC_generate_case_1),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_MD5_HMAC_verify_case_1),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_MD5_HMAC_generate_case_2),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_MD5_HMAC_verify_case_2),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_null_auth_only_operation),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_null_cipher_only_operation),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_null_cipher_auth_operation),
8683 TEST_CASE_ST(ut_setup, ut_teardown,
8684 test_null_auth_cipher_operation),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_kasumi_hash_generate_test_case_1),
8689 TEST_CASE_ST(ut_setup, ut_teardown,
8690 test_kasumi_hash_generate_test_case_2),
8691 TEST_CASE_ST(ut_setup, ut_teardown,
8692 test_kasumi_hash_generate_test_case_3),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_kasumi_hash_generate_test_case_4),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_kasumi_hash_generate_test_case_5),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_kasumi_hash_generate_test_case_6),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_kasumi_hash_verify_test_case_1),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_kasumi_hash_verify_test_case_2),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_kasumi_hash_verify_test_case_3),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_kasumi_hash_verify_test_case_4),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_kasumi_hash_verify_test_case_5),
8711 TEST_CASE_ST(ut_setup, ut_teardown,
8712 test_kasumi_encryption_test_case_1),
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_kasumi_encryption_test_case_3),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_kasumi_auth_cipher_test_case_1),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_kasumi_cipher_auth_test_case_1),
8720 /** Negative tests */
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 authentication_verify_AES128_GMAC_fail_data_corrupt),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8734 TEST_CASES_END() /**< NULL terminate unit test array */
8738 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8739 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8740 .setup = testsuite_setup,
8741 .teardown = testsuite_teardown,
8742 .unit_test_cases = {
8743 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8744 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8745 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8746 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_DES_cipheronly_mb_all),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_DES_docsis_mb_all),
8752 TEST_CASES_END() /**< NULL terminate unit test array */
8756 static struct unit_test_suite cryptodev_openssl_testsuite = {
8757 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8758 .setup = testsuite_setup,
8759 .teardown = testsuite_teardown,
8760 .unit_test_cases = {
8761 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_multi_session_random_usage),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_chain_openssl_all),
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_cipheronly_openssl_all),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_3DES_chain_openssl_all),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_3DES_cipheronly_openssl_all),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_DES_cipheronly_openssl_all),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_DES_docsis_openssl_all),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_authonly_openssl_all),
8779 /** AES GCM Authenticated Encryption */
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_authenticated_encryption_test_case_1),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_authenticated_encryption_test_case_2),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_authenticated_encryption_test_case_3),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_authenticated_encryption_test_case_4),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_authenticated_encryption_test_case_5),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_authenticated_encryption_test_case_6),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_authenticated_encryption_test_case_7),
8795 /** AES GCM Authenticated Decryption */
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_authenticated_decryption_test_case_1),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_authenticated_decryption_test_case_2),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_authenticated_decryption_test_case_3),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_authenticated_decryption_test_case_4),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_AES_GCM_authenticated_decryption_test_case_5),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_authenticated_decryption_test_case_6),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_authenticated_decryption_test_case_7),
8812 /** AES GCM Authenticated Encryption 192 bits key */
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_AES_GCM_auth_encryption_test_case_192_1),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_encryption_test_case_192_2),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_encryption_test_case_192_3),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_encryption_test_case_192_4),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_AES_GCM_auth_encryption_test_case_192_5),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_encryption_test_case_192_6),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_AES_GCM_auth_encryption_test_case_192_7),
8828 /** AES GCM Authenticated Decryption 192 bits key */
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_AES_GCM_auth_decryption_test_case_192_1),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_decryption_test_case_192_2),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_decryption_test_case_192_3),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_decryption_test_case_192_4),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_AES_GCM_auth_decryption_test_case_192_5),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_AES_GCM_auth_decryption_test_case_192_6),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_AES_GCM_auth_decryption_test_case_192_7),
8844 /** AES GCM Authenticated Encryption 256 bits key */
8845 TEST_CASE_ST(ut_setup, ut_teardown,
8846 test_AES_GCM_auth_encryption_test_case_256_1),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GCM_auth_encryption_test_case_256_2),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GCM_auth_encryption_test_case_256_3),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_AES_GCM_auth_encryption_test_case_256_4),
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_AES_GCM_auth_encryption_test_case_256_5),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_AES_GCM_auth_encryption_test_case_256_6),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_AES_GCM_auth_encryption_test_case_256_7),
8860 /** AES GCM Authenticated Decryption 256 bits key */
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_AES_GCM_auth_decryption_test_case_256_1),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_AES_GCM_auth_decryption_test_case_256_2),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_AES_GCM_auth_decryption_test_case_256_3),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_GCM_auth_decryption_test_case_256_4),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_GCM_auth_decryption_test_case_256_5),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_AES_GCM_auth_decryption_test_case_256_6),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_AES_GCM_auth_decryption_test_case_256_7),
8876 /** AES GMAC Authentication */
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_GMAC_authentication_test_case_1),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_AES_GMAC_authentication_verify_test_case_1),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_GMAC_authentication_test_case_2),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_GMAC_authentication_verify_test_case_2),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_GMAC_authentication_test_case_3),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_AES_GMAC_authentication_verify_test_case_3),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_GMAC_authentication_test_case_4),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_GMAC_authentication_verify_test_case_4),
8894 /** AES CCM Authenticated Encryption 128 bits key */
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_AES_CCM_authenticated_encryption_test_case_128_1),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_CCM_authenticated_encryption_test_case_128_2),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_CCM_authenticated_encryption_test_case_128_3),
8902 /** AES CCM Authenticated Decryption 128 bits key*/
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_AES_CCM_authenticated_decryption_test_case_128_1),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_CCM_authenticated_decryption_test_case_128_2),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_CCM_authenticated_decryption_test_case_128_3),
8910 /** AES CCM Authenticated Encryption 192 bits key */
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_AES_CCM_authenticated_encryption_test_case_192_1),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_CCM_authenticated_encryption_test_case_192_2),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_AES_CCM_authenticated_encryption_test_case_192_3),
8918 /** AES CCM Authenticated Decryption 192 bits key*/
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_AES_CCM_authenticated_decryption_test_case_192_1),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_CCM_authenticated_decryption_test_case_192_2),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_CCM_authenticated_decryption_test_case_192_3),
8926 /** AES CCM Authenticated Encryption 256 bits key */
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_AES_CCM_authenticated_encryption_test_case_256_1),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_AES_CCM_authenticated_encryption_test_case_256_2),
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_AES_CCM_authenticated_encryption_test_case_256_3),
8934 /** AES CCM Authenticated Decryption 256 bits key*/
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_AES_CCM_authenticated_decryption_test_case_256_1),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_AES_CCM_authenticated_decryption_test_case_256_2),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_AES_CCM_authenticated_decryption_test_case_256_3),
8942 /** Scatter-Gather */
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8946 /** Negative tests */
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 authentication_verify_AES128_GMAC_fail_data_corrupt),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8960 TEST_CASES_END() /**< NULL terminate unit test array */
8964 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8965 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8966 .setup = testsuite_setup,
8967 .teardown = testsuite_teardown,
8968 .unit_test_cases = {
8969 /** AES GCM Authenticated Encryption */
8970 TEST_CASE_ST(ut_setup, ut_teardown,
8971 test_AES_GCM_authenticated_encryption_test_case_1),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_authenticated_encryption_test_case_2),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_authenticated_encryption_test_case_3),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_AES_GCM_authenticated_encryption_test_case_4),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_encryption_test_case_5),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_encryption_test_case_6),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 test_AES_GCM_authenticated_encryption_test_case_7),
8985 /** AES GCM Authenticated Decryption */
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_AES_GCM_authenticated_decryption_test_case_1),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_authenticated_decryption_test_case_2),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_authenticated_decryption_test_case_3),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_AES_GCM_authenticated_decryption_test_case_4),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_GCM_authenticated_decryption_test_case_5),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_GCM_authenticated_decryption_test_case_6),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_GCM_authenticated_decryption_test_case_7),
9001 /** AES GCM Authenticated Encryption 192 bits key */
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_GCM_auth_encryption_test_case_192_1),
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_auth_encryption_test_case_192_2),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_auth_encryption_test_case_192_3),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_GCM_auth_encryption_test_case_192_4),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_encryption_test_case_192_5),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_encryption_test_case_192_6),
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_auth_encryption_test_case_192_7),
9017 /** AES GCM Authenticated Decryption 192 bits key */
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_auth_decryption_test_case_192_1),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_decryption_test_case_192_2),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_decryption_test_case_192_3),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_auth_decryption_test_case_192_4),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_decryption_test_case_192_5),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_decryption_test_case_192_6),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_auth_decryption_test_case_192_7),
9033 /** AES GCM Authenticated Encryption 256 bits key */
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_AES_GCM_auth_encryption_test_case_256_1),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_encryption_test_case_256_2),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_encryption_test_case_256_3),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_auth_encryption_test_case_256_4),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_encryption_test_case_256_5),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_encryption_test_case_256_6),
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_auth_encryption_test_case_256_7),
9049 /** AES GCM Authenticated Decryption 256 bits key */
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_auth_decryption_test_case_256_1),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_decryption_test_case_256_2),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_decryption_test_case_256_3),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_auth_decryption_test_case_256_4),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_decryption_test_case_256_5),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_auth_decryption_test_case_256_6),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GCM_auth_decryption_test_case_256_7),
9065 /** AES GCM Authenticated Encryption big aad size */
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GCM_auth_encryption_test_case_aad_1),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_auth_encryption_test_case_aad_2),
9071 /** AES GCM Authenticated Decryption big aad size */
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_auth_decryption_test_case_aad_1),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GCM_auth_decryption_test_case_aad_2),
9077 /** AES GMAC Authentication */
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GMAC_authentication_test_case_1),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GMAC_authentication_verify_test_case_1),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GMAC_authentication_test_case_3),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GMAC_authentication_verify_test_case_3),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GMAC_authentication_test_case_4),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GMAC_authentication_verify_test_case_4),
9091 /** Negative tests */
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 authentication_verify_AES128_GMAC_fail_data_corrupt),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9097 /** Out of place tests */
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9103 /** Session-less tests */
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9109 /** Scatter-Gather */
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9113 TEST_CASES_END() /**< NULL terminate unit test array */
9117 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9118 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9119 .setup = testsuite_setup,
9120 .teardown = testsuite_teardown,
9121 .unit_test_cases = {
9122 /** KASUMI encrypt only (UEA1) */
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_kasumi_encryption_test_case_1),
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_kasumi_encryption_test_case_1_sgl),
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_kasumi_encryption_test_case_2),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_kasumi_encryption_test_case_3),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_kasumi_encryption_test_case_4),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_kasumi_encryption_test_case_5),
9135 /** KASUMI decrypt only (UEA1) */
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_kasumi_decryption_test_case_1),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_kasumi_decryption_test_case_2),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_kasumi_decryption_test_case_3),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_kasumi_decryption_test_case_4),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_kasumi_decryption_test_case_5),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_kasumi_encryption_test_case_1_oop),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_kasumi_encryption_test_case_1_oop_sgl),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_kasumi_decryption_test_case_1_oop),
9156 /** KASUMI hash only (UIA1) */
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_kasumi_hash_generate_test_case_1),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_kasumi_hash_generate_test_case_2),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_kasumi_hash_generate_test_case_3),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_kasumi_hash_generate_test_case_4),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_kasumi_hash_generate_test_case_5),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_kasumi_hash_generate_test_case_6),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_kasumi_hash_verify_test_case_1),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_kasumi_hash_verify_test_case_2),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_kasumi_hash_verify_test_case_3),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_kasumi_hash_verify_test_case_4),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_kasumi_hash_verify_test_case_5),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_kasumi_auth_cipher_test_case_1),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_kasumi_cipher_auth_test_case_1),
9183 TEST_CASES_END() /**< NULL terminate unit test array */
9186 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9187 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9188 .setup = testsuite_setup,
9189 .teardown = testsuite_teardown,
9190 .unit_test_cases = {
9191 /** SNOW 3G encrypt only (UEA2) */
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_snow3g_encryption_test_case_1),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_snow3g_encryption_test_case_2),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_snow3g_encryption_test_case_3),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_snow3g_encryption_test_case_4),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_snow3g_encryption_test_case_5),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_snow3g_encryption_test_case_1_oop),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_snow3g_encryption_test_case_1_oop_sgl),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_snow3g_decryption_test_case_1_oop),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_snow3g_encryption_test_case_1_offset_oop),
9213 /** SNOW 3G decrypt only (UEA2) */
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_snow3g_decryption_test_case_1),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_snow3g_decryption_test_case_2),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_snow3g_decryption_test_case_3),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_snow3g_decryption_test_case_4),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_snow3g_decryption_test_case_5),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_snow3g_hash_generate_test_case_1),
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_snow3g_hash_generate_test_case_2),
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 test_snow3g_hash_generate_test_case_3),
9230 /* Tests with buffers which length is not byte-aligned */
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_snow3g_hash_generate_test_case_4),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_snow3g_hash_generate_test_case_5),
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_snow3g_hash_generate_test_case_6),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_snow3g_hash_verify_test_case_1),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_snow3g_hash_verify_test_case_2),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_snow3g_hash_verify_test_case_3),
9243 /* Tests with buffers which length is not byte-aligned */
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_snow3g_hash_verify_test_case_4),
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 test_snow3g_hash_verify_test_case_5),
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_snow3g_hash_verify_test_case_6),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_snow3g_cipher_auth_test_case_1),
9252 TEST_CASE_ST(ut_setup, ut_teardown,
9253 test_snow3g_auth_cipher_test_case_1),
9255 TEST_CASES_END() /**< NULL terminate unit test array */
9259 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9260 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9261 .setup = testsuite_setup,
9262 .teardown = testsuite_teardown,
9263 .unit_test_cases = {
9264 /** ZUC encrypt only (EEA3) */
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_zuc_encryption_test_case_1),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_zuc_encryption_test_case_2),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_zuc_encryption_test_case_3),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_zuc_encryption_test_case_4),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_zuc_encryption_test_case_5),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_zuc_hash_generate_test_case_1),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_zuc_hash_generate_test_case_2),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_zuc_hash_generate_test_case_3),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_zuc_hash_generate_test_case_4),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_zuc_hash_generate_test_case_5),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_zuc_encryption_test_case_6_sgl),
9287 TEST_CASES_END() /**< NULL terminate unit test array */
9291 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9292 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9293 .setup = testsuite_setup,
9294 .teardown = testsuite_teardown,
9295 .unit_test_cases = {
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_device_configure_invalid_dev_id),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_multi_session),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_chain_dpaa_sec_all),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_3DES_chain_dpaa_sec_all),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_cipheronly_dpaa_sec_all),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_3DES_cipheronly_dpaa_sec_all),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_authonly_dpaa_sec_all),
9312 /** AES GCM Authenticated Encryption */
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_AES_GCM_authenticated_encryption_test_case_1),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_authenticated_encryption_test_case_2),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_authenticated_encryption_test_case_3),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_authenticated_encryption_test_case_4),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_authenticated_encryption_test_case_5),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_authenticated_encryption_test_case_6),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_authenticated_encryption_test_case_7),
9328 /** AES GCM Authenticated Decryption */
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_AES_GCM_authenticated_decryption_test_case_1),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_authenticated_decryption_test_case_2),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_authenticated_decryption_test_case_3),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_authenticated_decryption_test_case_4),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_authenticated_decryption_test_case_5),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_authenticated_decryption_test_case_6),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_authenticated_decryption_test_case_7),
9344 /** AES GCM Authenticated Encryption 256 bits key */
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_GCM_auth_encryption_test_case_256_1),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_encryption_test_case_256_2),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_encryption_test_case_256_3),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_encryption_test_case_256_4),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_AES_GCM_auth_encryption_test_case_256_5),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_encryption_test_case_256_6),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_auth_encryption_test_case_256_7),
9360 /** AES GCM Authenticated Decryption 256 bits key */
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GCM_auth_decryption_test_case_256_1),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_auth_decryption_test_case_256_2),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_auth_decryption_test_case_256_3),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GCM_auth_decryption_test_case_256_4),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GCM_auth_decryption_test_case_256_5),
9371 TEST_CASE_ST(ut_setup, ut_teardown,
9372 test_AES_GCM_auth_decryption_test_case_256_6),
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 test_AES_GCM_auth_decryption_test_case_256_7),
9376 /** Out of place tests */
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9382 TEST_CASES_END() /**< NULL terminate unit test array */
9386 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9387 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9388 .setup = testsuite_setup,
9389 .teardown = testsuite_teardown,
9390 .unit_test_cases = {
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_device_configure_invalid_dev_id),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_multi_session),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_chain_dpaa2_sec_all),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_3DES_chain_dpaa2_sec_all),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_cipheronly_dpaa2_sec_all),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_3DES_cipheronly_dpaa2_sec_all),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_authonly_dpaa2_sec_all),
9407 /** AES GCM Authenticated Encryption */
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_AES_GCM_authenticated_encryption_test_case_1),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_authenticated_encryption_test_case_2),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_encryption_test_case_3),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_encryption_test_case_4),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_encryption_test_case_5),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_authenticated_encryption_test_case_6),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_encryption_test_case_7),
9423 /** AES GCM Authenticated Decryption */
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_AES_GCM_authenticated_decryption_test_case_1),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_authenticated_decryption_test_case_2),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_authenticated_decryption_test_case_3),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_authenticated_decryption_test_case_4),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_authenticated_decryption_test_case_5),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_authenticated_decryption_test_case_6),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_authenticated_decryption_test_case_7),
9439 /** AES GCM Authenticated Encryption 192 bits key */
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_AES_GCM_auth_encryption_test_case_192_1),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_encryption_test_case_192_2),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_encryption_test_case_192_3),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_encryption_test_case_192_4),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_encryption_test_case_192_5),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_encryption_test_case_192_6),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_auth_encryption_test_case_192_7),
9455 /** AES GCM Authenticated Decryption 192 bits key */
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GCM_auth_decryption_test_case_192_1),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_decryption_test_case_192_2),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_auth_decryption_test_case_192_3),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_decryption_test_case_192_4),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_decryption_test_case_192_5),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_decryption_test_case_192_6),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_auth_decryption_test_case_192_7),
9471 /** AES GCM Authenticated Encryption 256 bits key */
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_AES_GCM_auth_encryption_test_case_256_1),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_auth_encryption_test_case_256_2),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_auth_encryption_test_case_256_3),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_auth_encryption_test_case_256_4),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_auth_encryption_test_case_256_5),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_auth_encryption_test_case_256_6),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_GCM_auth_encryption_test_case_256_7),
9487 /** AES GCM Authenticated Decryption 256 bits key */
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_GCM_auth_decryption_test_case_256_1),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_auth_decryption_test_case_256_2),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_GCM_auth_decryption_test_case_256_3),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_AES_GCM_auth_decryption_test_case_256_4),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GCM_auth_decryption_test_case_256_5),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GCM_auth_decryption_test_case_256_6),
9500 TEST_CASE_ST(ut_setup, ut_teardown,
9501 test_AES_GCM_auth_decryption_test_case_256_7),
9503 /** Out of place tests */
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9509 TEST_CASES_END() /**< NULL terminate unit test array */
9513 static struct unit_test_suite cryptodev_null_testsuite = {
9514 .suite_name = "Crypto Device NULL Unit Test Suite",
9515 .setup = testsuite_setup,
9516 .teardown = testsuite_teardown,
9517 .unit_test_cases = {
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_null_auth_only_operation),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_null_cipher_only_operation),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_null_cipher_auth_operation),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_null_auth_cipher_operation),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_null_invalid_operation),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_null_burst_operation),
9531 TEST_CASES_END() /**< NULL terminate unit test array */
9535 static struct unit_test_suite cryptodev_armv8_testsuite = {
9536 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9537 .setup = testsuite_setup,
9538 .teardown = testsuite_teardown,
9539 .unit_test_cases = {
9540 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9542 /** Negative tests */
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9548 TEST_CASES_END() /**< NULL terminate unit test array */
9552 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9553 .suite_name = "Crypto Device Marvell Component Test Suite",
9554 .setup = testsuite_setup,
9555 .teardown = testsuite_teardown,
9556 .unit_test_cases = {
9557 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_multi_session_random_usage),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_chain_mrvl_all),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_AES_cipheronly_mrvl_all),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_authonly_mrvl_all),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_3DES_chain_mrvl_all),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_3DES_cipheronly_mrvl_all),
9571 /** Negative tests */
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9581 TEST_CASES_END() /**< NULL terminate unit test array */
9587 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9589 gbl_driver_id = rte_cryptodev_driver_id_get(
9590 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9592 if (gbl_driver_id == -1) {
9593 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9594 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9595 "in config file to run this testsuite.\n");
9599 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9603 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9605 gbl_driver_id = rte_cryptodev_driver_id_get(
9606 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9608 if (gbl_driver_id == -1) {
9609 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9610 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9611 "in config file to run this testsuite.\n");
9615 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9619 test_cryptodev_openssl(void)
9621 gbl_driver_id = rte_cryptodev_driver_id_get(
9622 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9624 if (gbl_driver_id == -1) {
9625 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9626 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9627 "in config file to run this testsuite.\n");
9631 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9635 test_cryptodev_aesni_gcm(void)
9637 gbl_driver_id = rte_cryptodev_driver_id_get(
9638 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9640 if (gbl_driver_id == -1) {
9641 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9642 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9643 "in config file to run this testsuite.\n");
9647 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9651 test_cryptodev_null(void)
9653 gbl_driver_id = rte_cryptodev_driver_id_get(
9654 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9656 if (gbl_driver_id == -1) {
9657 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9658 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9659 "in config file to run this testsuite.\n");
9663 return unit_test_suite_runner(&cryptodev_null_testsuite);
9667 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9669 gbl_driver_id = rte_cryptodev_driver_id_get(
9670 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9672 if (gbl_driver_id == -1) {
9673 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9674 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9675 "in config file to run this testsuite.\n");
9679 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9683 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9685 gbl_driver_id = rte_cryptodev_driver_id_get(
9686 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9688 if (gbl_driver_id == -1) {
9689 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9690 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9691 "in config file to run this testsuite.\n");
9695 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9699 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9701 gbl_driver_id = rte_cryptodev_driver_id_get(
9702 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9704 if (gbl_driver_id == -1) {
9705 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9706 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9707 "in config file to run this testsuite.\n");
9711 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9715 test_cryptodev_armv8(void)
9717 gbl_driver_id = rte_cryptodev_driver_id_get(
9718 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9720 if (gbl_driver_id == -1) {
9721 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9722 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9723 "in config file to run this testsuite.\n");
9727 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9731 test_cryptodev_mrvl(void)
9733 gbl_driver_id = rte_cryptodev_driver_id_get(
9734 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9736 if (gbl_driver_id == -1) {
9737 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9738 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9739 "in config file to run this testsuite.\n");
9743 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9746 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9749 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9751 gbl_driver_id = rte_cryptodev_driver_id_get(
9752 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9754 if (gbl_driver_id == -1) {
9755 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9756 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9757 "in config file to run this testsuite.\n");
9761 if (rte_cryptodev_driver_id_get(
9762 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9763 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9764 " enabled in config file to run this testsuite.\n");
9767 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9770 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9775 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9777 gbl_driver_id = rte_cryptodev_driver_id_get(
9778 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9780 if (gbl_driver_id == -1) {
9781 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9782 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9783 "in config file to run this testsuite.\n");
9787 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9791 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9793 gbl_driver_id = rte_cryptodev_driver_id_get(
9794 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9796 if (gbl_driver_id == -1) {
9797 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9798 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9799 "in config file to run this testsuite.\n");
9803 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9806 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9807 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9808 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9809 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9810 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9811 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9812 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9813 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9814 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9815 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9816 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9817 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);