4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static int gbl_driver_id;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
80 struct rte_crypto_sym_xform aead_xform;
82 struct rte_cryptodev_sym_session *sess;
84 struct rte_crypto_op *op;
86 struct rte_mbuf *obuf, *ibuf;
91 #define ALIGN_POW2_ROUNDUP(num, align) \
92 (((num) + (align) - 1) & ~((align) - 1))
95 * Forward declarations.
98 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
99 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
103 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
104 struct crypto_unittest_params *ut_params,
105 struct crypto_testsuite_params *ts_param,
106 const uint8_t *cipher,
107 const uint8_t *digest,
110 static struct rte_mbuf *
111 setup_test_string(struct rte_mempool *mpool,
112 const char *string, size_t len, uint8_t blocksize)
114 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
115 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
117 memset(m->buf_addr, 0, m->buf_len);
119 char *dst = rte_pktmbuf_append(m, t_len);
126 rte_memcpy(dst, string, t_len);
128 memset(dst, 0, t_len);
134 /* Get number of bytes in X bits (rounding up) */
136 ceil_byte_length(uint32_t num_bits)
139 return ((num_bits >> 3) + 1);
141 return (num_bits >> 3);
144 static struct rte_crypto_op *
145 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
147 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
148 printf("Error sending packet for encryption");
154 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
160 static struct crypto_testsuite_params testsuite_params = { NULL };
161 static struct crypto_unittest_params unittest_params;
164 testsuite_setup(void)
166 struct crypto_testsuite_params *ts_params = &testsuite_params;
167 struct rte_cryptodev_info info;
168 uint32_t i = 0, nb_devs, dev_id;
172 memset(ts_params, 0, sizeof(*ts_params));
174 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
175 if (ts_params->mbuf_pool == NULL) {
176 /* Not already created so create */
177 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
179 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
181 if (ts_params->mbuf_pool == NULL) {
182 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
187 ts_params->large_mbuf_pool = rte_mempool_lookup(
188 "CRYPTO_LARGE_MBUFPOOL");
189 if (ts_params->large_mbuf_pool == NULL) {
190 /* Not already created so create */
191 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
192 "CRYPTO_LARGE_MBUFPOOL",
195 if (ts_params->large_mbuf_pool == NULL) {
197 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
202 ts_params->op_mpool = rte_crypto_op_pool_create(
203 "MBUF_CRYPTO_SYM_OP_POOL",
204 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
205 NUM_MBUFS, MBUF_CACHE_SIZE,
207 sizeof(struct rte_crypto_sym_xform) +
210 if (ts_params->op_mpool == NULL) {
211 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
215 /* Create an AESNI MB device if required */
216 if (gbl_driver_id == rte_cryptodev_driver_id_get(
217 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
218 nb_devs = rte_cryptodev_device_count_by_driver(
219 rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
225 TEST_ASSERT(ret == 0,
226 "Failed to create instance of"
228 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
232 /* Create an AESNI GCM device if required */
233 if (gbl_driver_id == rte_cryptodev_driver_id_get(
234 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
235 nb_devs = rte_cryptodev_device_count_by_driver(
236 rte_cryptodev_driver_id_get(
237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
239 TEST_ASSERT_SUCCESS(rte_vdev_init(
240 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
241 "Failed to create instance of"
243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
247 /* Create a SNOW 3G device if required */
248 if (gbl_driver_id == rte_cryptodev_driver_id_get(
249 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
250 nb_devs = rte_cryptodev_device_count_by_driver(
251 rte_cryptodev_driver_id_get(
252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
254 TEST_ASSERT_SUCCESS(rte_vdev_init(
255 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
256 "Failed to create instance of"
258 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
262 /* Create a KASUMI device if required */
263 if (gbl_driver_id == rte_cryptodev_driver_id_get(
264 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
265 nb_devs = rte_cryptodev_device_count_by_driver(
266 rte_cryptodev_driver_id_get(
267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
269 TEST_ASSERT_SUCCESS(rte_vdev_init(
270 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
271 "Failed to create instance of"
273 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
277 /* Create a ZUC device if required */
278 if (gbl_driver_id == rte_cryptodev_driver_id_get(
279 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
280 nb_devs = rte_cryptodev_device_count_by_driver(
281 rte_cryptodev_driver_id_get(
282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
284 TEST_ASSERT_SUCCESS(rte_vdev_init(
285 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
286 "Failed to create instance of"
288 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
292 /* Create a NULL device if required */
293 if (gbl_driver_id == rte_cryptodev_driver_id_get(
294 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
295 nb_devs = rte_cryptodev_device_count_by_driver(
296 rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
300 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
302 TEST_ASSERT(ret == 0,
303 "Failed to create instance of"
305 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
309 /* Create an OPENSSL device if required */
310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
312 nb_devs = rte_cryptodev_device_count_by_driver(
313 rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
317 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
320 TEST_ASSERT(ret == 0, "Failed to create "
321 "instance of pmd : %s",
322 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
326 /* Create a ARMv8 device if required */
327 if (gbl_driver_id == rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
329 nb_devs = rte_cryptodev_device_count_by_driver(
330 rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
334 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
337 TEST_ASSERT(ret == 0, "Failed to create "
338 "instance of pmd : %s",
339 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
343 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
347 nb_devs = rte_cryptodev_device_count_by_driver(
348 rte_cryptodev_driver_id_get(
349 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
352 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
355 TEST_ASSERT(ret == 0,
356 "Failed to create instance %u of"
358 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
361 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
363 nb_devs = rte_cryptodev_count();
365 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
369 /* Create list of valid crypto devs */
370 for (i = 0; i < nb_devs; i++) {
371 rte_cryptodev_info_get(i, &info);
372 if (info.driver_id == gbl_driver_id)
373 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
376 if (ts_params->valid_dev_count < 1)
379 /* Set up all the qps on the first of the valid devices found */
381 dev_id = ts_params->valid_devs[0];
383 rte_cryptodev_info_get(dev_id, &info);
385 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
386 ts_params->conf.socket_id = SOCKET_ID_ANY;
387 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
389 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
391 "Failed to configure cryptodev %u with %u qps",
392 dev_id, ts_params->conf.nb_queue_pairs);
394 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
396 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
397 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
398 dev_id, qp_id, &ts_params->qp_conf,
399 rte_cryptodev_socket_id(dev_id)),
400 "Failed to setup queue pair %u on cryptodev %u",
408 testsuite_teardown(void)
410 struct crypto_testsuite_params *ts_params = &testsuite_params;
412 if (ts_params->mbuf_pool != NULL) {
413 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
414 rte_mempool_avail_count(ts_params->mbuf_pool));
417 if (ts_params->op_mpool != NULL) {
418 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
419 rte_mempool_avail_count(ts_params->op_mpool));
427 struct crypto_testsuite_params *ts_params = &testsuite_params;
428 struct crypto_unittest_params *ut_params = &unittest_params;
432 /* Clear unit test parameters before running test */
433 memset(ut_params, 0, sizeof(*ut_params));
435 /* Reconfigure device to default parameters */
436 ts_params->conf.socket_id = SOCKET_ID_ANY;
437 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
439 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
441 "Failed to configure cryptodev %u",
442 ts_params->valid_devs[0]);
444 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
445 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
446 ts_params->valid_devs[0], qp_id,
448 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
449 "Failed to setup queue pair %u on cryptodev %u",
450 qp_id, ts_params->valid_devs[0]);
454 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
456 /* Start the device */
457 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
458 "Failed to start cryptodev %u",
459 ts_params->valid_devs[0]);
467 struct crypto_testsuite_params *ts_params = &testsuite_params;
468 struct crypto_unittest_params *ut_params = &unittest_params;
469 struct rte_cryptodev_stats stats;
471 /* free crypto session structure */
472 if (ut_params->sess) {
473 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
475 ut_params->sess = NULL;
478 /* free crypto operation structure */
480 rte_crypto_op_free(ut_params->op);
483 * free mbuf - both obuf and ibuf are usually the same,
484 * so check if they point at the same address is necessary,
485 * to avoid freeing the mbuf twice.
487 if (ut_params->obuf) {
488 rte_pktmbuf_free(ut_params->obuf);
489 if (ut_params->ibuf == ut_params->obuf)
493 if (ut_params->ibuf) {
494 rte_pktmbuf_free(ut_params->ibuf);
498 if (ts_params->mbuf_pool != NULL)
499 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
500 rte_mempool_avail_count(ts_params->mbuf_pool));
502 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
504 /* Stop the device */
505 rte_cryptodev_stop(ts_params->valid_devs[0]);
509 test_device_configure_invalid_dev_id(void)
511 struct crypto_testsuite_params *ts_params = &testsuite_params;
512 uint16_t dev_id, num_devs = 0;
514 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
515 "Need at least %d devices for test", 1);
517 /* valid dev_id values */
518 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
520 /* Stop the device in case it's started so it can be configured */
521 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
523 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
524 "Failed test for rte_cryptodev_configure: "
525 "invalid dev_num %u", dev_id);
527 /* invalid dev_id values */
530 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
531 "Failed test for rte_cryptodev_configure: "
532 "invalid dev_num %u", dev_id);
536 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
537 "Failed test for rte_cryptodev_configure:"
538 "invalid dev_num %u", dev_id);
544 test_device_configure_invalid_queue_pair_ids(void)
546 struct crypto_testsuite_params *ts_params = &testsuite_params;
547 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
549 /* Stop the device in case it's started so it can be configured */
550 rte_cryptodev_stop(ts_params->valid_devs[0]);
552 /* valid - one queue pairs */
553 ts_params->conf.nb_queue_pairs = 1;
555 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
557 "Failed to configure cryptodev: dev_id %u, qp_id %u",
558 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
561 /* valid - max value queue pairs */
562 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
564 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
566 "Failed to configure cryptodev: dev_id %u, qp_id %u",
567 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
570 /* invalid - zero queue pairs */
571 ts_params->conf.nb_queue_pairs = 0;
573 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
575 "Failed test for rte_cryptodev_configure, dev_id %u,"
577 ts_params->valid_devs[0],
578 ts_params->conf.nb_queue_pairs);
581 /* invalid - max value supported by field queue pairs */
582 ts_params->conf.nb_queue_pairs = UINT16_MAX;
584 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
586 "Failed test for rte_cryptodev_configure, dev_id %u,"
588 ts_params->valid_devs[0],
589 ts_params->conf.nb_queue_pairs);
592 /* invalid - max value + 1 queue pairs */
593 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
595 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed test for rte_cryptodev_configure, dev_id %u,"
599 ts_params->valid_devs[0],
600 ts_params->conf.nb_queue_pairs);
602 /* revert to original testsuite value */
603 ts_params->conf.nb_queue_pairs = orig_nb_qps;
609 test_queue_pair_descriptor_setup(void)
611 struct crypto_testsuite_params *ts_params = &testsuite_params;
612 struct rte_cryptodev_info dev_info;
613 struct rte_cryptodev_qp_conf qp_conf = {
614 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
619 /* Stop the device in case it's started so it can be configured */
620 rte_cryptodev_stop(ts_params->valid_devs[0]);
623 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
625 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
627 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
628 &ts_params->conf), "Failed to configure cryptodev %u",
629 ts_params->valid_devs[0]);
633 * Test various ring sizes on this device. memzones can't be
634 * freed so are re-used if ring is released and re-created.
636 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
638 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
639 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
640 ts_params->valid_devs[0], qp_id, &qp_conf,
641 rte_cryptodev_socket_id(
642 ts_params->valid_devs[0])),
644 "rte_cryptodev_queue_pair_setup: num_inflights "
645 "%u on qp %u on cryptodev %u",
646 qp_conf.nb_descriptors, qp_id,
647 ts_params->valid_devs[0]);
650 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
652 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
653 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
654 ts_params->valid_devs[0], qp_id, &qp_conf,
655 rte_cryptodev_socket_id(
656 ts_params->valid_devs[0])),
658 " rte_cryptodev_queue_pair_setup: num_inflights"
659 " %u on qp %u on cryptodev %u",
660 qp_conf.nb_descriptors, qp_id,
661 ts_params->valid_devs[0]);
664 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
666 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
667 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
668 ts_params->valid_devs[0], qp_id, &qp_conf,
669 rte_cryptodev_socket_id(
670 ts_params->valid_devs[0])),
672 "rte_cryptodev_queue_pair_setup: num_inflights"
673 " %u on qp %u on cryptodev %u",
674 qp_conf.nb_descriptors, qp_id,
675 ts_params->valid_devs[0]);
678 /* invalid number of descriptors - max supported + 2 */
679 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
681 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
682 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
683 ts_params->valid_devs[0], qp_id, &qp_conf,
684 rte_cryptodev_socket_id(
685 ts_params->valid_devs[0])),
686 "Unexpectedly passed test for "
687 "rte_cryptodev_queue_pair_setup:"
688 "num_inflights %u on qp %u on cryptodev %u",
689 qp_conf.nb_descriptors, qp_id,
690 ts_params->valid_devs[0]);
693 /* invalid number of descriptors - max value of parameter */
694 qp_conf.nb_descriptors = UINT32_MAX-1;
696 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
697 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
698 ts_params->valid_devs[0], qp_id, &qp_conf,
699 rte_cryptodev_socket_id(
700 ts_params->valid_devs[0])),
701 "Unexpectedly passed test for "
702 "rte_cryptodev_queue_pair_setup:"
703 "num_inflights %u on qp %u on cryptodev %u",
704 qp_conf.nb_descriptors, qp_id,
705 ts_params->valid_devs[0]);
708 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
710 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
711 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
712 ts_params->valid_devs[0], qp_id, &qp_conf,
713 rte_cryptodev_socket_id(
714 ts_params->valid_devs[0])),
716 " rte_cryptodev_queue_pair_setup:"
717 "num_inflights %u on qp %u on cryptodev %u",
718 qp_conf.nb_descriptors, qp_id,
719 ts_params->valid_devs[0]);
722 /* invalid number of descriptors - max supported + 1 */
723 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
725 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
726 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
727 ts_params->valid_devs[0], qp_id, &qp_conf,
728 rte_cryptodev_socket_id(
729 ts_params->valid_devs[0])),
730 "Unexpectedly passed test for "
731 "rte_cryptodev_queue_pair_setup:"
732 "num_inflights %u on qp %u on cryptodev %u",
733 qp_conf.nb_descriptors, qp_id,
734 ts_params->valid_devs[0]);
737 /* test invalid queue pair id */
738 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
740 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
742 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
743 ts_params->valid_devs[0],
745 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
746 "Failed test for rte_cryptodev_queue_pair_setup:"
747 "invalid qp %u on cryptodev %u",
748 qp_id, ts_params->valid_devs[0]);
750 qp_id = 0xffff; /*invalid*/
752 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
753 ts_params->valid_devs[0],
755 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
756 "Failed test for rte_cryptodev_queue_pair_setup:"
757 "invalid qp %u on cryptodev %u",
758 qp_id, ts_params->valid_devs[0]);
763 /* ***** Plaintext data for tests ***** */
765 const char catch_22_quote_1[] =
766 "There was only one catch and that was Catch-22, which "
767 "specified that a concern for one's safety in the face of "
768 "dangers that were real and immediate was the process of a "
769 "rational mind. Orr was crazy and could be grounded. All he "
770 "had to do was ask; and as soon as he did, he would no longer "
771 "be crazy and would have to fly more missions. Orr would be "
772 "crazy to fly more missions and sane if he didn't, but if he "
773 "was sane he had to fly them. If he flew them he was crazy "
774 "and didn't have to; but if he didn't want to he was sane and "
775 "had to. Yossarian was moved very deeply by the absolute "
776 "simplicity of this clause of Catch-22 and let out a "
777 "respectful whistle. \"That's some catch, that Catch-22\", he "
778 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
780 const char catch_22_quote[] =
781 "What a lousy earth! He wondered how many people were "
782 "destitute that same night even in his own prosperous country, "
783 "how many homes were shanties, how many husbands were drunk "
784 "and wives socked, and how many children were bullied, abused, "
785 "or abandoned. How many families hungered for food they could "
786 "not afford to buy? How many hearts were broken? How many "
787 "suicides would take place that same night, how many people "
788 "would go insane? How many cockroaches and landlords would "
789 "triumph? How many winners were losers, successes failures, "
790 "and rich men poor men? How many wise guys were stupid? How "
791 "many happy endings were unhappy endings? How many honest men "
792 "were liars, brave men cowards, loyal men traitors, how many "
793 "sainted men were corrupt, how many people in positions of "
794 "trust had sold their souls to bodyguards, how many had never "
795 "had souls? How many straight-and-narrow paths were crooked "
796 "paths? How many best families were worst families and how "
797 "many good people were bad people? When you added them all up "
798 "and then subtracted, you might be left with only the children, "
799 "and perhaps with Albert Einstein and an old violinist or "
800 "sculptor somewhere.";
802 #define QUOTE_480_BYTES (480)
803 #define QUOTE_512_BYTES (512)
804 #define QUOTE_768_BYTES (768)
805 #define QUOTE_1024_BYTES (1024)
809 /* ***** SHA1 Hash Tests ***** */
811 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
813 static uint8_t hmac_sha1_key[] = {
814 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
815 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
816 0xDE, 0xF4, 0xDE, 0xAD };
818 /* ***** SHA224 Hash Tests ***** */
820 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
823 /* ***** AES-CBC Cipher Tests ***** */
825 #define CIPHER_KEY_LENGTH_AES_CBC (16)
826 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
828 static uint8_t aes_cbc_key[] = {
829 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
830 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
832 static uint8_t aes_cbc_iv[] = {
833 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
834 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
837 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
839 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
840 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
841 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
842 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
843 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
844 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
845 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
846 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
847 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
848 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
849 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
850 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
851 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
852 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
853 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
854 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
855 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
856 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
857 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
858 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
859 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
860 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
861 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
862 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
863 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
864 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
865 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
866 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
867 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
868 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
869 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
870 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
871 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
872 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
873 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
874 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
875 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
876 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
877 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
878 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
879 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
880 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
881 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
882 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
883 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
884 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
885 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
886 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
887 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
888 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
889 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
890 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
891 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
892 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
893 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
894 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
895 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
896 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
897 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
898 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
899 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
900 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
901 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
902 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
903 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
906 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
907 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
908 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
909 0x18, 0x8c, 0x1d, 0x32
913 /* Multisession Vector context Test */
915 static uint8_t ms_aes_cbc_key0[] = {
916 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
917 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
920 static uint8_t ms_aes_cbc_iv0[] = {
921 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
922 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
925 static const uint8_t ms_aes_cbc_cipher0[] = {
926 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
927 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
928 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
929 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
930 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
931 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
932 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
933 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
934 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
935 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
936 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
937 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
938 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
939 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
940 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
941 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
942 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
943 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
944 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
945 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
946 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
947 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
948 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
949 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
950 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
951 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
952 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
953 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
954 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
955 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
956 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
957 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
958 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
959 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
960 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
961 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
962 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
963 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
964 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
965 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
966 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
967 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
968 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
969 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
970 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
971 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
972 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
973 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
974 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
975 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
976 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
977 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
978 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
979 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
980 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
981 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
982 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
983 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
984 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
985 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
986 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
987 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
988 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
989 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
993 static uint8_t ms_hmac_key0[] = {
994 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
995 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
996 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
997 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
998 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
999 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1000 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1001 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1004 static const uint8_t ms_hmac_digest0[] = {
1005 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1006 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1007 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1008 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1009 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1010 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1011 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1012 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1016 /* Begin session 1 */
1018 static uint8_t ms_aes_cbc_key1[] = {
1019 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1020 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1023 static uint8_t ms_aes_cbc_iv1[] = {
1024 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1025 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1028 static const uint8_t ms_aes_cbc_cipher1[] = {
1029 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1030 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1031 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1032 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1033 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1034 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1035 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1036 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1037 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1038 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1039 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1040 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1041 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1042 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1043 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1044 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1045 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1046 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1047 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1048 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1049 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1050 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1051 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1052 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1053 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1054 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1055 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1056 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1057 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1058 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1059 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1060 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1061 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1062 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1063 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1064 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1065 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1066 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1067 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1068 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1069 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1070 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1071 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1072 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1073 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1074 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1075 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1076 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1077 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1078 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1079 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1080 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1081 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1082 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1083 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1084 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1085 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1086 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1087 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1088 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1089 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1090 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1091 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1092 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1096 static uint8_t ms_hmac_key1[] = {
1097 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1098 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1099 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1100 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1101 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1102 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1103 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1104 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1107 static const uint8_t ms_hmac_digest1[] = {
1108 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1109 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1110 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1111 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1112 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1113 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1114 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1115 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1118 /* Begin Session 2 */
1119 static uint8_t ms_aes_cbc_key2[] = {
1120 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1121 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1124 static uint8_t ms_aes_cbc_iv2[] = {
1125 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1126 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1129 static const uint8_t ms_aes_cbc_cipher2[] = {
1130 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1131 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1132 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1133 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1134 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1135 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1136 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1137 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1138 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1139 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1140 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1141 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1142 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1143 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1144 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1145 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1146 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1147 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1148 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1149 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1150 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1151 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1152 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1153 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1154 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1155 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1156 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1157 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1158 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1159 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1160 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1161 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1162 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1163 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1164 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1165 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1166 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1167 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1168 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1169 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1170 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1171 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1172 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1173 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1174 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1175 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1176 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1177 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1178 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1179 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1180 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1181 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1182 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1183 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1184 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1185 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1186 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1187 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1188 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1189 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1190 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1191 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1192 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1193 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1196 static uint8_t ms_hmac_key2[] = {
1197 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1198 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1199 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1200 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1201 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1202 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1203 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1204 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1207 static const uint8_t ms_hmac_digest2[] = {
1208 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1209 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1210 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1211 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1212 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1213 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1214 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1215 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1222 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1224 struct crypto_testsuite_params *ts_params = &testsuite_params;
1225 struct crypto_unittest_params *ut_params = &unittest_params;
1227 /* Generate test mbuf data and space for digest */
1228 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1229 catch_22_quote, QUOTE_512_BYTES, 0);
1231 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1232 DIGEST_BYTE_LENGTH_SHA1);
1233 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1235 /* Setup Cipher Parameters */
1236 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1237 ut_params->cipher_xform.next = &ut_params->auth_xform;
1239 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1240 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1241 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1242 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1243 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1244 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1246 /* Setup HMAC Parameters */
1247 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1249 ut_params->auth_xform.next = NULL;
1251 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1252 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1253 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1254 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1255 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1257 /* Create crypto session*/
1258 ut_params->sess = rte_cryptodev_sym_session_create(
1259 ts_params->valid_devs[0],
1260 &ut_params->cipher_xform);
1261 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1263 /* Generate crypto op data structure */
1264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1266 TEST_ASSERT_NOT_NULL(ut_params->op,
1267 "Failed to allocate symmetric crypto operation struct");
1269 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1273 /* set crypto operation source mbuf */
1274 sym_op->m_src = ut_params->ibuf;
1276 /* Set crypto operation authentication parameters */
1277 sym_op->auth.digest.data = ut_params->digest;
1278 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1279 ut_params->ibuf, QUOTE_512_BYTES);
1281 sym_op->auth.data.offset = 0;
1282 sym_op->auth.data.length = QUOTE_512_BYTES;
1284 /* Copy IV at the end of the crypto operation */
1285 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1286 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1288 /* Set crypto operation cipher parameters */
1289 sym_op->cipher.data.offset = 0;
1290 sym_op->cipher.data.length = QUOTE_512_BYTES;
1292 /* Process crypto operation */
1293 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1294 ut_params->op), "failed to process sym crypto op");
1296 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1297 "crypto op processing failed");
1300 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1303 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1304 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1306 "ciphertext data not as expected");
1308 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1310 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1311 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1312 gbl_driver_id == rte_cryptodev_driver_id_get(
1313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1314 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1315 DIGEST_BYTE_LENGTH_SHA1,
1316 "Generated digest data not as expected");
1318 return TEST_SUCCESS;
1321 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1323 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1325 static uint8_t hmac_sha512_key[] = {
1326 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1327 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1330 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1331 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1333 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1335 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1336 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1337 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1338 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1339 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1340 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1341 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1342 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1343 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1348 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1349 struct crypto_unittest_params *ut_params,
1350 uint8_t *cipher_key,
1354 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1355 struct crypto_unittest_params *ut_params,
1356 struct crypto_testsuite_params *ts_params,
1357 const uint8_t *cipher,
1358 const uint8_t *digest,
1363 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1364 struct crypto_unittest_params *ut_params,
1365 uint8_t *cipher_key,
1369 /* Setup Cipher Parameters */
1370 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1371 ut_params->cipher_xform.next = NULL;
1373 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1374 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1375 ut_params->cipher_xform.cipher.key.data = cipher_key;
1376 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1377 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1378 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1380 /* Setup HMAC Parameters */
1381 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1382 ut_params->auth_xform.next = &ut_params->cipher_xform;
1384 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1385 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1386 ut_params->auth_xform.auth.key.data = hmac_key;
1387 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1388 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1390 return TEST_SUCCESS;
1395 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1396 struct crypto_unittest_params *ut_params,
1397 struct crypto_testsuite_params *ts_params,
1398 const uint8_t *cipher,
1399 const uint8_t *digest,
1402 /* Generate test mbuf data and digest */
1403 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1406 QUOTE_512_BYTES, 0);
1408 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1409 DIGEST_BYTE_LENGTH_SHA512);
1410 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1412 rte_memcpy(ut_params->digest,
1414 DIGEST_BYTE_LENGTH_SHA512);
1416 /* Generate Crypto op data structure */
1417 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1418 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1419 TEST_ASSERT_NOT_NULL(ut_params->op,
1420 "Failed to allocate symmetric crypto operation struct");
1422 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1424 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1426 /* set crypto operation source mbuf */
1427 sym_op->m_src = ut_params->ibuf;
1429 sym_op->auth.digest.data = ut_params->digest;
1430 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1431 ut_params->ibuf, QUOTE_512_BYTES);
1433 sym_op->auth.data.offset = 0;
1434 sym_op->auth.data.length = QUOTE_512_BYTES;
1436 /* Copy IV at the end of the crypto operation */
1437 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1438 iv, CIPHER_IV_LENGTH_AES_CBC);
1440 sym_op->cipher.data.offset = 0;
1441 sym_op->cipher.data.length = QUOTE_512_BYTES;
1443 /* Process crypto operation */
1444 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1445 ut_params->op), "failed to process sym crypto op");
1447 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1448 "crypto op processing failed");
1450 ut_params->obuf = ut_params->op->sym->m_src;
1453 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1454 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1457 "Plaintext data not as expected");
1460 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1461 "Digest verification failed");
1463 return TEST_SUCCESS;
1467 test_AES_cipheronly_mb_all(void)
1469 struct crypto_testsuite_params *ts_params = &testsuite_params;
1472 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1473 ts_params->op_mpool, ts_params->valid_devs[0],
1474 rte_cryptodev_driver_id_get(
1475 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1476 BLKCIPHER_AES_CIPHERONLY_TYPE);
1478 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1480 return TEST_SUCCESS;
1484 test_AES_docsis_mb_all(void)
1486 struct crypto_testsuite_params *ts_params = &testsuite_params;
1489 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1490 ts_params->op_mpool, ts_params->valid_devs[0],
1491 rte_cryptodev_driver_id_get(
1492 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1493 BLKCIPHER_AES_DOCSIS_TYPE);
1495 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1497 return TEST_SUCCESS;
1501 test_AES_docsis_qat_all(void)
1503 struct crypto_testsuite_params *ts_params = &testsuite_params;
1506 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1507 ts_params->op_mpool, ts_params->valid_devs[0],
1508 rte_cryptodev_driver_id_get(
1509 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1510 BLKCIPHER_AES_DOCSIS_TYPE);
1512 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1514 return TEST_SUCCESS;
1518 test_DES_docsis_qat_all(void)
1520 struct crypto_testsuite_params *ts_params = &testsuite_params;
1523 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1524 ts_params->op_mpool, ts_params->valid_devs[0],
1525 rte_cryptodev_driver_id_get(
1526 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1527 BLKCIPHER_DES_DOCSIS_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_authonly_mb_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool, ts_params->valid_devs[0],
1542 rte_cryptodev_driver_id_get(
1543 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1544 BLKCIPHER_AUTHONLY_TYPE);
1546 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1548 return TEST_SUCCESS;
1552 test_AES_chain_mb_all(void)
1554 struct crypto_testsuite_params *ts_params = &testsuite_params;
1557 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1558 ts_params->op_mpool, ts_params->valid_devs[0],
1559 rte_cryptodev_driver_id_get(
1560 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1561 BLKCIPHER_AES_CHAIN_TYPE);
1563 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1565 return TEST_SUCCESS;
1568 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1571 test_AES_cipheronly_scheduler_all(void)
1573 struct crypto_testsuite_params *ts_params = &testsuite_params;
1576 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1577 ts_params->op_mpool, ts_params->valid_devs[0],
1578 rte_cryptodev_driver_id_get(
1579 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1580 BLKCIPHER_AES_CIPHERONLY_TYPE);
1582 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1584 return TEST_SUCCESS;
1588 test_AES_chain_scheduler_all(void)
1590 struct crypto_testsuite_params *ts_params = &testsuite_params;
1593 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1594 ts_params->op_mpool, ts_params->valid_devs[0],
1595 rte_cryptodev_driver_id_get(
1596 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1597 BLKCIPHER_AES_CHAIN_TYPE);
1599 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1601 return TEST_SUCCESS;
1605 test_authonly_scheduler_all(void)
1607 struct crypto_testsuite_params *ts_params = &testsuite_params;
1610 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1611 ts_params->op_mpool, ts_params->valid_devs[0],
1612 rte_cryptodev_driver_id_get(
1613 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1614 BLKCIPHER_AUTHONLY_TYPE);
1616 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1618 return TEST_SUCCESS;
1621 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1624 test_AES_chain_openssl_all(void)
1626 struct crypto_testsuite_params *ts_params = &testsuite_params;
1629 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1630 ts_params->op_mpool, ts_params->valid_devs[0],
1631 rte_cryptodev_driver_id_get(
1632 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1633 BLKCIPHER_AES_CHAIN_TYPE);
1635 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1637 return TEST_SUCCESS;
1641 test_AES_cipheronly_openssl_all(void)
1643 struct crypto_testsuite_params *ts_params = &testsuite_params;
1646 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1647 ts_params->op_mpool, ts_params->valid_devs[0],
1648 rte_cryptodev_driver_id_get(
1649 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1650 BLKCIPHER_AES_CIPHERONLY_TYPE);
1652 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1654 return TEST_SUCCESS;
1658 test_AES_chain_qat_all(void)
1660 struct crypto_testsuite_params *ts_params = &testsuite_params;
1663 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1664 ts_params->op_mpool, ts_params->valid_devs[0],
1665 rte_cryptodev_driver_id_get(
1666 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1667 BLKCIPHER_AES_CHAIN_TYPE);
1669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1671 return TEST_SUCCESS;
1675 test_AES_cipheronly_qat_all(void)
1677 struct crypto_testsuite_params *ts_params = &testsuite_params;
1680 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1681 ts_params->op_mpool, ts_params->valid_devs[0],
1682 rte_cryptodev_driver_id_get(
1683 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1684 BLKCIPHER_AES_CIPHERONLY_TYPE);
1686 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1688 return TEST_SUCCESS;
1692 test_AES_chain_dpaa2_sec_all(void)
1694 struct crypto_testsuite_params *ts_params = &testsuite_params;
1697 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1698 ts_params->op_mpool, ts_params->valid_devs[0],
1699 rte_cryptodev_driver_id_get(
1700 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1701 BLKCIPHER_AES_CHAIN_TYPE);
1703 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1705 return TEST_SUCCESS;
1709 test_AES_cipheronly_dpaa2_sec_all(void)
1711 struct crypto_testsuite_params *ts_params = &testsuite_params;
1714 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1715 ts_params->op_mpool, ts_params->valid_devs[0],
1716 rte_cryptodev_driver_id_get(
1717 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1718 BLKCIPHER_AES_CIPHERONLY_TYPE);
1720 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1722 return TEST_SUCCESS;
1726 test_authonly_dpaa2_sec_all(void)
1728 struct crypto_testsuite_params *ts_params = &testsuite_params;
1731 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1732 ts_params->op_mpool, ts_params->valid_devs[0],
1733 rte_cryptodev_driver_id_get(
1734 RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
1735 BLKCIPHER_AUTHONLY_TYPE);
1737 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1739 return TEST_SUCCESS;
1743 test_authonly_openssl_all(void)
1745 struct crypto_testsuite_params *ts_params = &testsuite_params;
1748 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1749 ts_params->op_mpool, ts_params->valid_devs[0],
1750 rte_cryptodev_driver_id_get(
1751 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1752 BLKCIPHER_AUTHONLY_TYPE);
1754 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1756 return TEST_SUCCESS;
1760 test_AES_chain_armv8_all(void)
1762 struct crypto_testsuite_params *ts_params = &testsuite_params;
1765 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1766 ts_params->op_mpool, ts_params->valid_devs[0],
1767 rte_cryptodev_driver_id_get(
1768 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1769 BLKCIPHER_AES_CHAIN_TYPE);
1771 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1773 return TEST_SUCCESS;
1776 /* ***** SNOW 3G Tests ***** */
1778 create_wireless_algo_hash_session(uint8_t dev_id,
1779 const uint8_t *key, const uint8_t key_len,
1780 const uint8_t iv_len, const uint8_t auth_len,
1781 enum rte_crypto_auth_operation op,
1782 enum rte_crypto_auth_algorithm algo)
1784 uint8_t hash_key[key_len];
1786 struct crypto_unittest_params *ut_params = &unittest_params;
1788 memcpy(hash_key, key, key_len);
1790 TEST_HEXDUMP(stdout, "key:", key, key_len);
1792 /* Setup Authentication Parameters */
1793 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1794 ut_params->auth_xform.next = NULL;
1796 ut_params->auth_xform.auth.op = op;
1797 ut_params->auth_xform.auth.algo = algo;
1798 ut_params->auth_xform.auth.key.length = key_len;
1799 ut_params->auth_xform.auth.key.data = hash_key;
1800 ut_params->auth_xform.auth.digest_length = auth_len;
1801 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1802 ut_params->auth_xform.auth.iv.length = iv_len;
1803 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1804 &ut_params->auth_xform);
1805 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1810 create_wireless_algo_cipher_session(uint8_t dev_id,
1811 enum rte_crypto_cipher_operation op,
1812 enum rte_crypto_cipher_algorithm algo,
1813 const uint8_t *key, const uint8_t key_len,
1816 uint8_t cipher_key[key_len];
1818 struct crypto_unittest_params *ut_params = &unittest_params;
1820 memcpy(cipher_key, key, key_len);
1822 /* Setup Cipher Parameters */
1823 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1824 ut_params->cipher_xform.next = NULL;
1826 ut_params->cipher_xform.cipher.algo = algo;
1827 ut_params->cipher_xform.cipher.op = op;
1828 ut_params->cipher_xform.cipher.key.data = cipher_key;
1829 ut_params->cipher_xform.cipher.key.length = key_len;
1830 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1831 ut_params->cipher_xform.cipher.iv.length = iv_len;
1833 TEST_HEXDUMP(stdout, "key:", key, key_len);
1835 /* Create Crypto session */
1836 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1839 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1844 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1845 unsigned int cipher_len,
1846 unsigned int cipher_offset)
1848 struct crypto_testsuite_params *ts_params = &testsuite_params;
1849 struct crypto_unittest_params *ut_params = &unittest_params;
1851 /* Generate Crypto op data structure */
1852 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1853 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1854 TEST_ASSERT_NOT_NULL(ut_params->op,
1855 "Failed to allocate pktmbuf offload");
1857 /* Set crypto operation data parameters */
1858 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1860 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1862 /* set crypto operation source mbuf */
1863 sym_op->m_src = ut_params->ibuf;
1866 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1868 sym_op->cipher.data.length = cipher_len;
1869 sym_op->cipher.data.offset = cipher_offset;
1874 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1875 unsigned int cipher_len,
1876 unsigned int cipher_offset)
1878 struct crypto_testsuite_params *ts_params = &testsuite_params;
1879 struct crypto_unittest_params *ut_params = &unittest_params;
1881 /* Generate Crypto op data structure */
1882 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1883 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1884 TEST_ASSERT_NOT_NULL(ut_params->op,
1885 "Failed to allocate pktmbuf offload");
1887 /* Set crypto operation data parameters */
1888 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1890 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1892 /* set crypto operation source mbuf */
1893 sym_op->m_src = ut_params->ibuf;
1894 sym_op->m_dst = ut_params->obuf;
1897 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1899 sym_op->cipher.data.length = cipher_len;
1900 sym_op->cipher.data.offset = cipher_offset;
1905 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1906 enum rte_crypto_cipher_operation cipher_op,
1907 enum rte_crypto_auth_operation auth_op,
1908 enum rte_crypto_auth_algorithm auth_algo,
1909 enum rte_crypto_cipher_algorithm cipher_algo,
1910 const uint8_t *key, uint8_t key_len,
1911 uint8_t auth_iv_len, uint8_t auth_len,
1912 uint8_t cipher_iv_len)
1915 uint8_t cipher_auth_key[key_len];
1917 struct crypto_unittest_params *ut_params = &unittest_params;
1919 memcpy(cipher_auth_key, key, key_len);
1921 /* Setup Authentication Parameters */
1922 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1923 ut_params->auth_xform.next = NULL;
1925 ut_params->auth_xform.auth.op = auth_op;
1926 ut_params->auth_xform.auth.algo = auth_algo;
1927 ut_params->auth_xform.auth.key.length = key_len;
1928 /* Hash key = cipher key */
1929 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1930 ut_params->auth_xform.auth.digest_length = auth_len;
1931 /* Auth IV will be after cipher IV */
1932 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1933 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1935 /* Setup Cipher Parameters */
1936 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1937 ut_params->cipher_xform.next = &ut_params->auth_xform;
1939 ut_params->cipher_xform.cipher.algo = cipher_algo;
1940 ut_params->cipher_xform.cipher.op = cipher_op;
1941 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1942 ut_params->cipher_xform.cipher.key.length = key_len;
1943 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1944 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1946 TEST_HEXDUMP(stdout, "key:", key, key_len);
1948 /* Create Crypto session*/
1949 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1950 &ut_params->cipher_xform);
1952 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1957 create_wireless_cipher_auth_session(uint8_t dev_id,
1958 enum rte_crypto_cipher_operation cipher_op,
1959 enum rte_crypto_auth_operation auth_op,
1960 enum rte_crypto_auth_algorithm auth_algo,
1961 enum rte_crypto_cipher_algorithm cipher_algo,
1962 const struct wireless_test_data *tdata)
1964 const uint8_t key_len = tdata->key.len;
1965 uint8_t cipher_auth_key[key_len];
1967 struct crypto_unittest_params *ut_params = &unittest_params;
1968 const uint8_t *key = tdata->key.data;
1969 const uint8_t auth_len = tdata->digest.len;
1970 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1971 uint8_t auth_iv_len = tdata->auth_iv.len;
1973 memcpy(cipher_auth_key, key, key_len);
1975 /* Setup Authentication Parameters */
1976 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1977 ut_params->auth_xform.next = NULL;
1979 ut_params->auth_xform.auth.op = auth_op;
1980 ut_params->auth_xform.auth.algo = auth_algo;
1981 ut_params->auth_xform.auth.key.length = key_len;
1982 /* Hash key = cipher key */
1983 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1984 ut_params->auth_xform.auth.digest_length = auth_len;
1985 /* Auth IV will be after cipher IV */
1986 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1987 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1989 /* Setup Cipher Parameters */
1990 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1991 ut_params->cipher_xform.next = &ut_params->auth_xform;
1993 ut_params->cipher_xform.cipher.algo = cipher_algo;
1994 ut_params->cipher_xform.cipher.op = cipher_op;
1995 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1996 ut_params->cipher_xform.cipher.key.length = key_len;
1997 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1998 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2001 TEST_HEXDUMP(stdout, "key:", key, key_len);
2003 /* Create Crypto session*/
2004 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2005 &ut_params->cipher_xform);
2007 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2012 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2013 const struct wireless_test_data *tdata)
2015 return create_wireless_cipher_auth_session(dev_id,
2016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2017 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2018 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2022 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2023 enum rte_crypto_cipher_operation cipher_op,
2024 enum rte_crypto_auth_operation auth_op,
2025 enum rte_crypto_auth_algorithm auth_algo,
2026 enum rte_crypto_cipher_algorithm cipher_algo,
2027 const uint8_t *key, const uint8_t key_len,
2028 uint8_t auth_iv_len, uint8_t auth_len,
2029 uint8_t cipher_iv_len)
2031 uint8_t auth_cipher_key[key_len];
2033 struct crypto_unittest_params *ut_params = &unittest_params;
2035 memcpy(auth_cipher_key, key, key_len);
2037 /* Setup Authentication Parameters */
2038 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2039 ut_params->auth_xform.auth.op = auth_op;
2040 ut_params->auth_xform.next = &ut_params->cipher_xform;
2041 ut_params->auth_xform.auth.algo = auth_algo;
2042 ut_params->auth_xform.auth.key.length = key_len;
2043 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2044 ut_params->auth_xform.auth.digest_length = auth_len;
2045 /* Auth IV will be after cipher IV */
2046 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2047 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2049 /* Setup Cipher Parameters */
2050 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2051 ut_params->cipher_xform.next = NULL;
2052 ut_params->cipher_xform.cipher.algo = cipher_algo;
2053 ut_params->cipher_xform.cipher.op = cipher_op;
2054 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2055 ut_params->cipher_xform.cipher.key.length = key_len;
2056 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2057 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2059 TEST_HEXDUMP(stdout, "key:", key, key_len);
2061 /* Create Crypto session*/
2062 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2063 &ut_params->auth_xform);
2065 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2071 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2072 unsigned int auth_tag_len,
2073 const uint8_t *iv, unsigned int iv_len,
2074 unsigned int data_pad_len,
2075 enum rte_crypto_auth_operation op,
2076 unsigned int auth_len, unsigned int auth_offset)
2078 struct crypto_testsuite_params *ts_params = &testsuite_params;
2080 struct crypto_unittest_params *ut_params = &unittest_params;
2082 /* Generate Crypto op data structure */
2083 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2084 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2085 TEST_ASSERT_NOT_NULL(ut_params->op,
2086 "Failed to allocate pktmbuf offload");
2088 /* Set crypto operation data parameters */
2089 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2091 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2093 /* set crypto operation source mbuf */
2094 sym_op->m_src = ut_params->ibuf;
2097 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2100 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2101 ut_params->ibuf, auth_tag_len);
2103 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2104 "no room to append auth tag");
2105 ut_params->digest = sym_op->auth.digest.data;
2106 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2107 ut_params->ibuf, data_pad_len);
2108 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2109 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2111 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2113 TEST_HEXDUMP(stdout, "digest:",
2114 sym_op->auth.digest.data,
2117 sym_op->auth.data.length = auth_len;
2118 sym_op->auth.data.offset = auth_offset;
2124 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2125 enum rte_crypto_auth_operation op)
2127 struct crypto_testsuite_params *ts_params = &testsuite_params;
2128 struct crypto_unittest_params *ut_params = &unittest_params;
2130 const uint8_t *auth_tag = tdata->digest.data;
2131 const unsigned int auth_tag_len = tdata->digest.len;
2132 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2133 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2135 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2136 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2137 const uint8_t *auth_iv = tdata->auth_iv.data;
2138 const uint8_t auth_iv_len = tdata->auth_iv.len;
2139 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2140 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2142 /* Generate Crypto op data structure */
2143 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2144 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2145 TEST_ASSERT_NOT_NULL(ut_params->op,
2146 "Failed to allocate pktmbuf offload");
2147 /* Set crypto operation data parameters */
2148 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2150 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2152 /* set crypto operation source mbuf */
2153 sym_op->m_src = ut_params->ibuf;
2156 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2157 ut_params->ibuf, auth_tag_len);
2159 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2160 "no room to append auth tag");
2161 ut_params->digest = sym_op->auth.digest.data;
2162 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2163 ut_params->ibuf, data_pad_len);
2164 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2165 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2167 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2169 TEST_HEXDUMP(stdout, "digest:",
2170 sym_op->auth.digest.data,
2173 /* Copy cipher and auth IVs at the end of the crypto operation */
2174 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2176 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2177 iv_ptr += cipher_iv_len;
2178 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2180 sym_op->cipher.data.length = cipher_len;
2181 sym_op->cipher.data.offset = 0;
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = 0;
2189 create_zuc_cipher_hash_generate_operation(
2190 const struct wireless_test_data *tdata)
2192 return create_wireless_cipher_hash_operation(tdata,
2193 RTE_CRYPTO_AUTH_OP_GENERATE);
2197 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2198 const unsigned auth_tag_len,
2199 const uint8_t *auth_iv, uint8_t auth_iv_len,
2200 unsigned data_pad_len,
2201 enum rte_crypto_auth_operation op,
2202 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2203 const unsigned cipher_len, const unsigned cipher_offset,
2204 const unsigned auth_len, const unsigned auth_offset)
2206 struct crypto_testsuite_params *ts_params = &testsuite_params;
2207 struct crypto_unittest_params *ut_params = &unittest_params;
2209 /* Generate Crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate pktmbuf offload");
2214 /* Set crypto operation data parameters */
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2223 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2224 ut_params->ibuf, auth_tag_len);
2226 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2227 "no room to append auth tag");
2228 ut_params->digest = sym_op->auth.digest.data;
2229 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2230 ut_params->ibuf, data_pad_len);
2231 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2232 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2234 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2236 TEST_HEXDUMP(stdout, "digest:",
2237 sym_op->auth.digest.data,
2240 /* Copy cipher and auth IVs at the end of the crypto operation */
2241 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2243 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2244 iv_ptr += cipher_iv_len;
2245 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2247 sym_op->cipher.data.length = cipher_len;
2248 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2249 sym_op->auth.data.length = auth_len;
2250 sym_op->auth.data.offset = auth_offset + cipher_offset;
2256 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2257 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2258 const uint8_t *auth_iv, uint8_t auth_iv_len,
2259 unsigned int data_pad_len,
2260 unsigned int cipher_len, unsigned int cipher_offset,
2261 unsigned int auth_len, unsigned int auth_offset)
2263 struct crypto_testsuite_params *ts_params = &testsuite_params;
2264 struct crypto_unittest_params *ut_params = &unittest_params;
2266 /* Generate Crypto op data structure */
2267 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2268 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2269 TEST_ASSERT_NOT_NULL(ut_params->op,
2270 "Failed to allocate pktmbuf offload");
2272 /* Set crypto operation data parameters */
2273 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2275 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2277 /* set crypto operation source mbuf */
2278 sym_op->m_src = ut_params->ibuf;
2281 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2282 ut_params->ibuf, auth_tag_len);
2284 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2285 "no room to append auth tag");
2287 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2288 ut_params->ibuf, data_pad_len);
2290 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2292 TEST_HEXDUMP(stdout, "digest:",
2293 sym_op->auth.digest.data,
2296 /* Copy cipher and auth IVs at the end of the crypto operation */
2297 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2299 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2300 iv_ptr += cipher_iv_len;
2301 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2303 sym_op->cipher.data.length = cipher_len;
2304 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2306 sym_op->auth.data.length = auth_len;
2307 sym_op->auth.data.offset = auth_offset + cipher_offset;
2313 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2315 struct crypto_testsuite_params *ts_params = &testsuite_params;
2316 struct crypto_unittest_params *ut_params = &unittest_params;
2319 unsigned plaintext_pad_len;
2320 unsigned plaintext_len;
2323 /* Create SNOW 3G session */
2324 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2325 tdata->key.data, tdata->key.len,
2326 tdata->auth_iv.len, tdata->digest.len,
2327 RTE_CRYPTO_AUTH_OP_GENERATE,
2328 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2332 /* alloc mbuf and set payload */
2333 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2335 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2336 rte_pktmbuf_tailroom(ut_params->ibuf));
2338 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2339 /* Append data which is padded to a multiple of */
2340 /* the algorithms block size */
2341 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2342 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2344 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2346 /* Create SNOW 3G operation */
2347 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2348 tdata->auth_iv.data, tdata->auth_iv.len,
2349 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2350 tdata->validAuthLenInBits.len,
2355 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2357 ut_params->obuf = ut_params->op->sym->m_src;
2358 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2359 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2360 + plaintext_pad_len;
2363 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2366 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2367 "SNOW 3G Generated auth tag not as expected");
2373 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2375 struct crypto_testsuite_params *ts_params = &testsuite_params;
2376 struct crypto_unittest_params *ut_params = &unittest_params;
2379 unsigned plaintext_pad_len;
2380 unsigned plaintext_len;
2383 /* Create SNOW 3G session */
2384 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2385 tdata->key.data, tdata->key.len,
2386 tdata->auth_iv.len, tdata->digest.len,
2387 RTE_CRYPTO_AUTH_OP_VERIFY,
2388 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2391 /* alloc mbuf and set payload */
2392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2394 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2395 rte_pktmbuf_tailroom(ut_params->ibuf));
2397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2398 /* Append data which is padded to a multiple of */
2399 /* the algorithms block size */
2400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2401 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2403 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2405 /* Create SNOW 3G operation */
2406 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2408 tdata->auth_iv.data, tdata->auth_iv.len,
2410 RTE_CRYPTO_AUTH_OP_VERIFY,
2411 tdata->validAuthLenInBits.len,
2416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2419 ut_params->obuf = ut_params->op->sym->m_src;
2420 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2421 + plaintext_pad_len;
2424 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2433 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2435 struct crypto_testsuite_params *ts_params = &testsuite_params;
2436 struct crypto_unittest_params *ut_params = &unittest_params;
2439 unsigned plaintext_pad_len;
2440 unsigned plaintext_len;
2443 /* Create KASUMI session */
2444 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2445 tdata->key.data, tdata->key.len,
2446 tdata->auth_iv.len, tdata->digest.len,
2447 RTE_CRYPTO_AUTH_OP_GENERATE,
2448 RTE_CRYPTO_AUTH_KASUMI_F9);
2452 /* alloc mbuf and set payload */
2453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2455 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2456 rte_pktmbuf_tailroom(ut_params->ibuf));
2458 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2459 /* Append data which is padded to a multiple of */
2460 /* the algorithms block size */
2461 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2462 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2464 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2466 /* Create KASUMI operation */
2467 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2468 tdata->auth_iv.data, tdata->auth_iv.len,
2469 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2470 tdata->validAuthLenInBits.len,
2475 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2477 ut_params->obuf = ut_params->op->sym->m_src;
2478 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2479 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2480 + plaintext_pad_len;
2483 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2486 DIGEST_BYTE_LENGTH_KASUMI_F9,
2487 "KASUMI Generated auth tag not as expected");
2493 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2495 struct crypto_testsuite_params *ts_params = &testsuite_params;
2496 struct crypto_unittest_params *ut_params = &unittest_params;
2499 unsigned plaintext_pad_len;
2500 unsigned plaintext_len;
2503 /* Create KASUMI session */
2504 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2505 tdata->key.data, tdata->key.len,
2506 tdata->auth_iv.len, tdata->digest.len,
2507 RTE_CRYPTO_AUTH_OP_VERIFY,
2508 RTE_CRYPTO_AUTH_KASUMI_F9);
2511 /* alloc mbuf and set payload */
2512 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2514 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2515 rte_pktmbuf_tailroom(ut_params->ibuf));
2517 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2518 /* Append data which is padded to a multiple */
2519 /* of the algorithms block size */
2520 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2521 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2523 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2525 /* Create KASUMI operation */
2526 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2528 tdata->auth_iv.data, tdata->auth_iv.len,
2530 RTE_CRYPTO_AUTH_OP_VERIFY,
2531 tdata->validAuthLenInBits.len,
2536 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2538 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2539 ut_params->obuf = ut_params->op->sym->m_src;
2540 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2541 + plaintext_pad_len;
2544 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2553 test_snow3g_hash_generate_test_case_1(void)
2555 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2559 test_snow3g_hash_generate_test_case_2(void)
2561 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2565 test_snow3g_hash_generate_test_case_3(void)
2567 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2571 test_snow3g_hash_generate_test_case_4(void)
2573 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2577 test_snow3g_hash_generate_test_case_5(void)
2579 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2583 test_snow3g_hash_generate_test_case_6(void)
2585 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2589 test_snow3g_hash_verify_test_case_1(void)
2591 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2596 test_snow3g_hash_verify_test_case_2(void)
2598 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2602 test_snow3g_hash_verify_test_case_3(void)
2604 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2608 test_snow3g_hash_verify_test_case_4(void)
2610 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2614 test_snow3g_hash_verify_test_case_5(void)
2616 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2620 test_snow3g_hash_verify_test_case_6(void)
2622 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2626 test_kasumi_hash_generate_test_case_1(void)
2628 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2632 test_kasumi_hash_generate_test_case_2(void)
2634 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2638 test_kasumi_hash_generate_test_case_3(void)
2640 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2644 test_kasumi_hash_generate_test_case_4(void)
2646 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2650 test_kasumi_hash_generate_test_case_5(void)
2652 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2656 test_kasumi_hash_generate_test_case_6(void)
2658 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2662 test_kasumi_hash_verify_test_case_1(void)
2664 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2668 test_kasumi_hash_verify_test_case_2(void)
2670 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2674 test_kasumi_hash_verify_test_case_3(void)
2676 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2680 test_kasumi_hash_verify_test_case_4(void)
2682 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2686 test_kasumi_hash_verify_test_case_5(void)
2688 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2692 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2694 struct crypto_testsuite_params *ts_params = &testsuite_params;
2695 struct crypto_unittest_params *ut_params = &unittest_params;
2698 uint8_t *plaintext, *ciphertext;
2699 unsigned plaintext_pad_len;
2700 unsigned plaintext_len;
2702 /* Create KASUMI session */
2703 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2704 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2705 RTE_CRYPTO_CIPHER_KASUMI_F8,
2706 tdata->key.data, tdata->key.len,
2707 tdata->cipher_iv.len);
2711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2713 /* Clear mbuf payload */
2714 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2715 rte_pktmbuf_tailroom(ut_params->ibuf));
2717 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2718 /* Append data which is padded to a multiple */
2719 /* of the algorithms block size */
2720 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2721 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2723 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2725 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2727 /* Create KASUMI operation */
2728 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2729 tdata->cipher_iv.len,
2730 tdata->plaintext.len,
2735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2739 ut_params->obuf = ut_params->op->sym->m_dst;
2740 if (ut_params->obuf)
2741 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2743 ciphertext = plaintext;
2745 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2748 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2750 tdata->ciphertext.data,
2751 tdata->validCipherLenInBits.len,
2752 "KASUMI Ciphertext data not as expected");
2757 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2759 struct crypto_testsuite_params *ts_params = &testsuite_params;
2760 struct crypto_unittest_params *ut_params = &unittest_params;
2764 unsigned int plaintext_pad_len;
2765 unsigned int plaintext_len;
2767 uint8_t buffer[10000];
2768 const uint8_t *ciphertext;
2770 struct rte_cryptodev_info dev_info;
2772 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2773 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2774 printf("Device doesn't support scatter-gather. "
2779 /* Create KASUMI session */
2780 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2781 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2782 RTE_CRYPTO_CIPHER_KASUMI_F8,
2783 tdata->key.data, tdata->key.len,
2784 tdata->cipher_iv.len);
2788 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2791 /* Append data which is padded to a multiple */
2792 /* of the algorithms block size */
2793 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2795 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2796 plaintext_pad_len, 10, 0);
2798 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2800 /* Create KASUMI operation */
2801 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2802 tdata->cipher_iv.len,
2803 tdata->plaintext.len,
2808 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2810 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2812 ut_params->obuf = ut_params->op->sym->m_dst;
2814 if (ut_params->obuf)
2815 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2816 plaintext_len, buffer);
2818 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2819 plaintext_len, buffer);
2822 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2825 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2827 tdata->ciphertext.data,
2828 tdata->validCipherLenInBits.len,
2829 "KASUMI Ciphertext data not as expected");
2834 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2836 struct crypto_testsuite_params *ts_params = &testsuite_params;
2837 struct crypto_unittest_params *ut_params = &unittest_params;
2840 uint8_t *plaintext, *ciphertext;
2841 unsigned plaintext_pad_len;
2842 unsigned plaintext_len;
2844 /* Create KASUMI session */
2845 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2846 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2847 RTE_CRYPTO_CIPHER_KASUMI_F8,
2848 tdata->key.data, tdata->key.len,
2849 tdata->cipher_iv.len);
2853 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2854 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2856 /* Clear mbuf payload */
2857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2858 rte_pktmbuf_tailroom(ut_params->ibuf));
2860 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2861 /* Append data which is padded to a multiple */
2862 /* of the algorithms block size */
2863 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2864 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2866 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2867 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2869 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2871 /* Create KASUMI operation */
2872 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2873 tdata->cipher_iv.len,
2874 tdata->plaintext.len,
2879 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2881 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2883 ut_params->obuf = ut_params->op->sym->m_dst;
2884 if (ut_params->obuf)
2885 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2887 ciphertext = plaintext;
2889 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2894 tdata->ciphertext.data,
2895 tdata->validCipherLenInBits.len,
2896 "KASUMI Ciphertext data not as expected");
2901 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2903 struct crypto_testsuite_params *ts_params = &testsuite_params;
2904 struct crypto_unittest_params *ut_params = &unittest_params;
2907 unsigned int plaintext_pad_len;
2908 unsigned int plaintext_len;
2910 const uint8_t *ciphertext;
2911 uint8_t buffer[2048];
2913 struct rte_cryptodev_info dev_info;
2915 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2916 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2917 printf("Device doesn't support scatter-gather. "
2922 /* Create KASUMI session */
2923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2924 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2925 RTE_CRYPTO_CIPHER_KASUMI_F8,
2926 tdata->key.data, tdata->key.len,
2927 tdata->cipher_iv.len);
2931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2932 /* Append data which is padded to a multiple */
2933 /* of the algorithms block size */
2934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2936 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2937 plaintext_pad_len, 10, 0);
2938 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2939 plaintext_pad_len, 3, 0);
2941 /* Append data which is padded to a multiple */
2942 /* of the algorithms block size */
2943 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2945 /* Create KASUMI operation */
2946 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2947 tdata->cipher_iv.len,
2948 tdata->plaintext.len,
2953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2957 ut_params->obuf = ut_params->op->sym->m_dst;
2958 if (ut_params->obuf)
2959 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2960 plaintext_pad_len, buffer);
2962 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2963 plaintext_pad_len, buffer);
2966 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2968 tdata->ciphertext.data,
2969 tdata->validCipherLenInBits.len,
2970 "KASUMI Ciphertext data not as expected");
2976 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2978 struct crypto_testsuite_params *ts_params = &testsuite_params;
2979 struct crypto_unittest_params *ut_params = &unittest_params;
2982 uint8_t *ciphertext, *plaintext;
2983 unsigned ciphertext_pad_len;
2984 unsigned ciphertext_len;
2986 /* Create KASUMI session */
2987 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2988 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2989 RTE_CRYPTO_CIPHER_KASUMI_F8,
2990 tdata->key.data, tdata->key.len,
2991 tdata->cipher_iv.len);
2995 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2996 ut_params->obuf = 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 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3003 /* Append data which is padded to a multiple */
3004 /* of the algorithms block size */
3005 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3006 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3007 ciphertext_pad_len);
3008 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3009 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3011 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3013 /* Create KASUMI operation */
3014 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3015 tdata->cipher_iv.len,
3016 tdata->ciphertext.len,
3021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3025 ut_params->obuf = ut_params->op->sym->m_dst;
3026 if (ut_params->obuf)
3027 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3029 plaintext = ciphertext;
3031 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3034 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3036 tdata->plaintext.data,
3037 tdata->validCipherLenInBits.len,
3038 "KASUMI Plaintext data not as expected");
3043 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3045 struct crypto_testsuite_params *ts_params = &testsuite_params;
3046 struct crypto_unittest_params *ut_params = &unittest_params;
3049 uint8_t *ciphertext, *plaintext;
3050 unsigned ciphertext_pad_len;
3051 unsigned ciphertext_len;
3053 /* Create KASUMI session */
3054 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3055 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3056 RTE_CRYPTO_CIPHER_KASUMI_F8,
3057 tdata->key.data, tdata->key.len,
3058 tdata->cipher_iv.len);
3062 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3064 /* Clear mbuf payload */
3065 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3066 rte_pktmbuf_tailroom(ut_params->ibuf));
3068 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3069 /* Append data which is padded to a multiple */
3070 /* of the algorithms block size */
3071 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3072 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3073 ciphertext_pad_len);
3074 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3076 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3078 /* Create KASUMI operation */
3079 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3080 tdata->cipher_iv.len,
3081 tdata->ciphertext.len,
3086 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3088 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3090 ut_params->obuf = ut_params->op->sym->m_dst;
3091 if (ut_params->obuf)
3092 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3094 plaintext = ciphertext;
3096 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3099 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3101 tdata->plaintext.data,
3102 tdata->validCipherLenInBits.len,
3103 "KASUMI Plaintext data not as expected");
3108 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3110 struct crypto_testsuite_params *ts_params = &testsuite_params;
3111 struct crypto_unittest_params *ut_params = &unittest_params;
3114 uint8_t *plaintext, *ciphertext;
3115 unsigned plaintext_pad_len;
3116 unsigned plaintext_len;
3118 /* Create SNOW 3G session */
3119 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3120 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3121 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3122 tdata->key.data, tdata->key.len,
3123 tdata->cipher_iv.len);
3127 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3129 /* Clear mbuf payload */
3130 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3131 rte_pktmbuf_tailroom(ut_params->ibuf));
3133 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3134 /* Append data which is padded to a multiple of */
3135 /* the algorithms block size */
3136 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3137 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3139 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3141 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3143 /* Create SNOW 3G operation */
3144 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3145 tdata->cipher_iv.len,
3146 tdata->validCipherLenInBits.len,
3151 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3153 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3155 ut_params->obuf = ut_params->op->sym->m_dst;
3156 if (ut_params->obuf)
3157 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3159 ciphertext = plaintext;
3161 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3164 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3166 tdata->ciphertext.data,
3167 tdata->validDataLenInBits.len,
3168 "SNOW 3G Ciphertext data not as expected");
3174 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3176 struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 struct crypto_unittest_params *ut_params = &unittest_params;
3178 uint8_t *plaintext, *ciphertext;
3181 unsigned plaintext_pad_len;
3182 unsigned plaintext_len;
3184 /* Create SNOW 3G session */
3185 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3186 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3187 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3188 tdata->key.data, tdata->key.len,
3189 tdata->cipher_iv.len);
3193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3194 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3197 "Failed to allocate input buffer in mempool");
3198 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3199 "Failed to allocate output buffer in mempool");
3201 /* Clear mbuf payload */
3202 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3203 rte_pktmbuf_tailroom(ut_params->ibuf));
3205 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3206 /* Append data which is padded to a multiple of */
3207 /* the algorithms block size */
3208 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3209 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3211 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3212 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3214 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3216 /* Create SNOW 3G operation */
3217 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3218 tdata->cipher_iv.len,
3219 tdata->validCipherLenInBits.len,
3224 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3226 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3228 ut_params->obuf = ut_params->op->sym->m_dst;
3229 if (ut_params->obuf)
3230 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3232 ciphertext = plaintext;
3234 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3237 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3239 tdata->ciphertext.data,
3240 tdata->validDataLenInBits.len,
3241 "SNOW 3G Ciphertext data not as expected");
3246 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3248 struct crypto_testsuite_params *ts_params = &testsuite_params;
3249 struct crypto_unittest_params *ut_params = &unittest_params;
3252 unsigned int plaintext_pad_len;
3253 unsigned int plaintext_len;
3254 uint8_t buffer[10000];
3255 const uint8_t *ciphertext;
3257 struct rte_cryptodev_info dev_info;
3259 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3260 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3261 printf("Device doesn't support scatter-gather. "
3266 /* Create SNOW 3G session */
3267 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3268 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3269 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3270 tdata->key.data, tdata->key.len,
3271 tdata->cipher_iv.len);
3275 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3276 /* Append data which is padded to a multiple of */
3277 /* the algorithms block size */
3278 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3280 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3281 plaintext_pad_len, 10, 0);
3282 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3283 plaintext_pad_len, 3, 0);
3285 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3286 "Failed to allocate input buffer in mempool");
3287 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3288 "Failed to allocate output buffer in mempool");
3290 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3292 /* Create SNOW 3G operation */
3293 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3294 tdata->cipher_iv.len,
3295 tdata->validCipherLenInBits.len,
3300 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3302 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3304 ut_params->obuf = ut_params->op->sym->m_dst;
3305 if (ut_params->obuf)
3306 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3307 plaintext_len, buffer);
3309 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3310 plaintext_len, buffer);
3312 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3315 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3317 tdata->ciphertext.data,
3318 tdata->validDataLenInBits.len,
3319 "SNOW 3G Ciphertext data not as expected");
3324 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3326 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3328 uint8_t curr_byte, prev_byte;
3329 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3330 uint8_t lower_byte_mask = (1 << offset) - 1;
3333 prev_byte = buffer[0];
3334 buffer[0] >>= offset;
3336 for (i = 1; i < length_in_bytes; i++) {
3337 curr_byte = buffer[i];
3338 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3339 (curr_byte >> offset);
3340 prev_byte = curr_byte;
3345 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3347 struct crypto_testsuite_params *ts_params = &testsuite_params;
3348 struct crypto_unittest_params *ut_params = &unittest_params;
3349 uint8_t *plaintext, *ciphertext;
3351 uint32_t plaintext_len;
3352 uint32_t plaintext_pad_len;
3353 uint8_t extra_offset = 4;
3354 uint8_t *expected_ciphertext_shifted;
3356 /* Create SNOW 3G session */
3357 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3358 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3359 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3360 tdata->key.data, tdata->key.len,
3361 tdata->cipher_iv.len);
3365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3366 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3368 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3369 "Failed to allocate input buffer in mempool");
3370 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3371 "Failed to allocate output buffer in mempool");
3373 /* Clear mbuf payload */
3374 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3375 rte_pktmbuf_tailroom(ut_params->ibuf));
3377 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3379 * Append data which is padded to a
3380 * multiple of the algorithms block size
3382 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3384 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3387 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3389 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3390 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3392 #ifdef RTE_APP_TEST_DEBUG
3393 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3395 /* Create SNOW 3G operation */
3396 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3397 tdata->cipher_iv.len,
3398 tdata->validCipherLenInBits.len,
3403 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3407 ut_params->obuf = ut_params->op->sym->m_dst;
3408 if (ut_params->obuf)
3409 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3411 ciphertext = plaintext;
3413 #ifdef RTE_APP_TEST_DEBUG
3414 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3417 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3419 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3420 "failed to reserve memory for ciphertext shifted\n");
3422 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3423 ceil_byte_length(tdata->ciphertext.len));
3424 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3429 expected_ciphertext_shifted,
3430 tdata->validDataLenInBits.len,
3432 "SNOW 3G Ciphertext data not as expected");
3436 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3438 struct crypto_testsuite_params *ts_params = &testsuite_params;
3439 struct crypto_unittest_params *ut_params = &unittest_params;
3443 uint8_t *plaintext, *ciphertext;
3444 unsigned ciphertext_pad_len;
3445 unsigned ciphertext_len;
3447 /* Create SNOW 3G session */
3448 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3449 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3450 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3451 tdata->key.data, tdata->key.len,
3452 tdata->cipher_iv.len);
3456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3458 /* Clear mbuf payload */
3459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3460 rte_pktmbuf_tailroom(ut_params->ibuf));
3462 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3463 /* Append data which is padded to a multiple of */
3464 /* the algorithms block size */
3465 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3466 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3467 ciphertext_pad_len);
3468 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3470 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3472 /* Create SNOW 3G operation */
3473 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3474 tdata->cipher_iv.len,
3475 tdata->validCipherLenInBits.len,
3480 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3482 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3483 ut_params->obuf = ut_params->op->sym->m_dst;
3484 if (ut_params->obuf)
3485 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3487 plaintext = ciphertext;
3489 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3492 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3493 tdata->plaintext.data,
3494 tdata->validDataLenInBits.len,
3495 "SNOW 3G Plaintext data not as expected");
3499 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3501 struct crypto_testsuite_params *ts_params = &testsuite_params;
3502 struct crypto_unittest_params *ut_params = &unittest_params;
3506 uint8_t *plaintext, *ciphertext;
3507 unsigned ciphertext_pad_len;
3508 unsigned ciphertext_len;
3510 /* Create SNOW 3G session */
3511 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3512 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3513 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3514 tdata->key.data, tdata->key.len,
3515 tdata->cipher_iv.len);
3519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3520 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3522 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3523 "Failed to allocate input buffer");
3524 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3525 "Failed to allocate output buffer");
3527 /* Clear mbuf payload */
3528 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3529 rte_pktmbuf_tailroom(ut_params->ibuf));
3531 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3532 rte_pktmbuf_tailroom(ut_params->obuf));
3534 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3535 /* Append data which is padded to a multiple of */
3536 /* the algorithms block size */
3537 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3538 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3539 ciphertext_pad_len);
3540 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3541 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3543 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3545 /* Create SNOW 3G operation */
3546 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3547 tdata->cipher_iv.len,
3548 tdata->validCipherLenInBits.len,
3553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3556 ut_params->obuf = ut_params->op->sym->m_dst;
3557 if (ut_params->obuf)
3558 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3560 plaintext = ciphertext;
3562 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3565 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3566 tdata->plaintext.data,
3567 tdata->validDataLenInBits.len,
3568 "SNOW 3G Plaintext data not as expected");
3573 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3575 struct crypto_testsuite_params *ts_params = &testsuite_params;
3576 struct crypto_unittest_params *ut_params = &unittest_params;
3580 uint8_t *plaintext, *ciphertext;
3581 unsigned int plaintext_pad_len;
3582 unsigned int plaintext_len;
3584 struct rte_cryptodev_sym_capability_idx cap_idx;
3586 /* Check if device supports ZUC EEA3 */
3587 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3588 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3590 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3594 /* Check if device supports ZUC EIA3 */
3595 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3596 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3598 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3602 /* Create ZUC session */
3603 retval = create_zuc_cipher_auth_encrypt_generate_session(
3604 ts_params->valid_devs[0],
3608 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3610 /* clear mbuf payload */
3611 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3612 rte_pktmbuf_tailroom(ut_params->ibuf));
3614 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3615 /* Append data which is padded to a multiple of */
3616 /* the algorithms block size */
3617 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3618 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3620 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3622 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3624 /* Create ZUC operation */
3625 retval = create_zuc_cipher_hash_generate_operation(tdata);
3629 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3631 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3632 ut_params->obuf = ut_params->op->sym->m_src;
3633 if (ut_params->obuf)
3634 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3636 ciphertext = plaintext;
3638 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3640 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3642 tdata->ciphertext.data,
3643 tdata->validDataLenInBits.len,
3644 "ZUC Ciphertext data not as expected");
3646 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3647 + plaintext_pad_len;
3650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3654 "ZUC Generated auth tag not as expected");
3659 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3661 struct crypto_testsuite_params *ts_params = &testsuite_params;
3662 struct crypto_unittest_params *ut_params = &unittest_params;
3666 uint8_t *plaintext, *ciphertext;
3667 unsigned plaintext_pad_len;
3668 unsigned plaintext_len;
3670 /* Create SNOW 3G session */
3671 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3672 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3673 RTE_CRYPTO_AUTH_OP_GENERATE,
3674 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3675 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3676 tdata->key.data, tdata->key.len,
3677 tdata->auth_iv.len, tdata->digest.len,
3678 tdata->cipher_iv.len);
3681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3683 /* clear mbuf payload */
3684 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3685 rte_pktmbuf_tailroom(ut_params->ibuf));
3687 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3688 /* Append data which is padded to a multiple of */
3689 /* the algorithms block size */
3690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3691 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3693 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3695 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3697 /* Create SNOW 3G operation */
3698 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3699 tdata->digest.len, tdata->auth_iv.data,
3701 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3702 tdata->cipher_iv.data, tdata->cipher_iv.len,
3703 tdata->validCipherLenInBits.len,
3705 tdata->validAuthLenInBits.len,
3711 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3713 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3714 ut_params->obuf = ut_params->op->sym->m_src;
3715 if (ut_params->obuf)
3716 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3718 ciphertext = plaintext;
3720 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3722 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3724 tdata->ciphertext.data,
3725 tdata->validDataLenInBits.len,
3726 "SNOW 3G Ciphertext data not as expected");
3728 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3729 + plaintext_pad_len;
3732 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3735 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3736 "SNOW 3G Generated auth tag not as expected");
3740 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3742 struct crypto_testsuite_params *ts_params = &testsuite_params;
3743 struct crypto_unittest_params *ut_params = &unittest_params;
3747 uint8_t *plaintext, *ciphertext;
3748 unsigned plaintext_pad_len;
3749 unsigned plaintext_len;
3751 /* Create SNOW 3G session */
3752 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3753 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3754 RTE_CRYPTO_AUTH_OP_GENERATE,
3755 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3756 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3757 tdata->key.data, tdata->key.len,
3758 tdata->auth_iv.len, tdata->digest.len,
3759 tdata->cipher_iv.len);
3763 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3765 /* clear mbuf payload */
3766 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3767 rte_pktmbuf_tailroom(ut_params->ibuf));
3769 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3770 /* Append data which is padded to a multiple of */
3771 /* the algorithms block size */
3772 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3773 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3775 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3777 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3779 /* Create SNOW 3G operation */
3780 retval = create_wireless_algo_auth_cipher_operation(
3782 tdata->cipher_iv.data, tdata->cipher_iv.len,
3783 tdata->auth_iv.data, tdata->auth_iv.len,
3785 tdata->validCipherLenInBits.len,
3787 tdata->validAuthLenInBits.len,
3793 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3795 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3796 ut_params->obuf = ut_params->op->sym->m_src;
3797 if (ut_params->obuf)
3798 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3800 ciphertext = plaintext;
3802 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3803 + plaintext_pad_len;
3804 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3807 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3809 tdata->ciphertext.data,
3810 tdata->validDataLenInBits.len,
3811 "SNOW 3G Ciphertext data not as expected");
3814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3817 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3818 "SNOW 3G Generated auth tag not as expected");
3823 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3825 struct crypto_testsuite_params *ts_params = &testsuite_params;
3826 struct crypto_unittest_params *ut_params = &unittest_params;
3830 uint8_t *plaintext, *ciphertext;
3831 unsigned plaintext_pad_len;
3832 unsigned plaintext_len;
3834 /* Create KASUMI session */
3835 retval = create_wireless_algo_auth_cipher_session(
3836 ts_params->valid_devs[0],
3837 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3838 RTE_CRYPTO_AUTH_OP_GENERATE,
3839 RTE_CRYPTO_AUTH_KASUMI_F9,
3840 RTE_CRYPTO_CIPHER_KASUMI_F8,
3841 tdata->key.data, tdata->key.len,
3842 tdata->auth_iv.len, tdata->digest.len,
3843 tdata->cipher_iv.len);
3846 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3848 /* clear mbuf payload */
3849 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3850 rte_pktmbuf_tailroom(ut_params->ibuf));
3852 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3853 /* Append data which is padded to a multiple of */
3854 /* the algorithms block size */
3855 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3856 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3858 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3860 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3862 /* Create KASUMI operation */
3863 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3864 tdata->cipher_iv.data, tdata->cipher_iv.len,
3865 tdata->auth_iv.data, tdata->auth_iv.len,
3867 tdata->validCipherLenInBits.len,
3869 tdata->validAuthLenInBits.len,
3876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3878 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3879 ut_params->obuf = ut_params->op->sym->m_src;
3880 if (ut_params->obuf)
3881 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3883 ciphertext = plaintext;
3886 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3888 tdata->ciphertext.data,
3889 tdata->validCipherLenInBits.len,
3890 "KASUMI Ciphertext data not as expected");
3891 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3892 + plaintext_pad_len;
3895 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3898 DIGEST_BYTE_LENGTH_KASUMI_F9,
3899 "KASUMI Generated auth tag not as expected");
3904 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3906 struct crypto_testsuite_params *ts_params = &testsuite_params;
3907 struct crypto_unittest_params *ut_params = &unittest_params;
3911 uint8_t *plaintext, *ciphertext;
3912 unsigned plaintext_pad_len;
3913 unsigned plaintext_len;
3915 /* Create KASUMI session */
3916 retval = create_wireless_algo_cipher_auth_session(
3917 ts_params->valid_devs[0],
3918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3919 RTE_CRYPTO_AUTH_OP_GENERATE,
3920 RTE_CRYPTO_AUTH_KASUMI_F9,
3921 RTE_CRYPTO_CIPHER_KASUMI_F8,
3922 tdata->key.data, tdata->key.len,
3923 tdata->auth_iv.len, tdata->digest.len,
3924 tdata->cipher_iv.len);
3928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3930 /* clear mbuf payload */
3931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3932 rte_pktmbuf_tailroom(ut_params->ibuf));
3934 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3935 /* Append data which is padded to a multiple of */
3936 /* the algorithms block size */
3937 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3940 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3942 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3944 /* Create KASUMI operation */
3945 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3946 tdata->digest.len, tdata->auth_iv.data,
3948 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3949 tdata->cipher_iv.data, tdata->cipher_iv.len,
3950 tdata->validCipherLenInBits.len,
3952 tdata->validAuthLenInBits.len,
3958 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3960 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3961 ut_params->obuf = ut_params->op->sym->m_src;
3962 if (ut_params->obuf)
3963 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3965 ciphertext = plaintext;
3967 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3968 + plaintext_pad_len;
3971 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3973 tdata->ciphertext.data,
3974 tdata->validCipherLenInBits.len,
3975 "KASUMI Ciphertext data not as expected");
3978 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3981 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3982 "KASUMI Generated auth tag not as expected");
3987 test_zuc_encryption(const struct wireless_test_data *tdata)
3989 struct crypto_testsuite_params *ts_params = &testsuite_params;
3990 struct crypto_unittest_params *ut_params = &unittest_params;
3993 uint8_t *plaintext, *ciphertext;
3994 unsigned plaintext_pad_len;
3995 unsigned plaintext_len;
3997 struct rte_cryptodev_sym_capability_idx cap_idx;
3999 /* Check if device supports ZUC EEA3 */
4000 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4001 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4003 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4007 /* Create ZUC session */
4008 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4009 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4010 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4011 tdata->key.data, tdata->key.len,
4012 tdata->cipher_iv.len);
4016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4018 /* Clear mbuf payload */
4019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4020 rte_pktmbuf_tailroom(ut_params->ibuf));
4022 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4023 /* Append data which is padded to a multiple */
4024 /* of the algorithms block size */
4025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4026 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4028 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4030 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4032 /* Create ZUC operation */
4033 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4034 tdata->cipher_iv.len,
4035 tdata->plaintext.len,
4040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4042 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_dst;
4045 if (ut_params->obuf)
4046 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 ciphertext = plaintext;
4050 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4055 tdata->ciphertext.data,
4056 tdata->validCipherLenInBits.len,
4057 "ZUC Ciphertext data not as expected");
4062 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4064 struct crypto_testsuite_params *ts_params = &testsuite_params;
4065 struct crypto_unittest_params *ut_params = &unittest_params;
4069 unsigned int plaintext_pad_len;
4070 unsigned int plaintext_len;
4071 const uint8_t *ciphertext;
4072 uint8_t ciphertext_buffer[2048];
4073 struct rte_cryptodev_info dev_info;
4075 struct rte_cryptodev_sym_capability_idx cap_idx;
4077 /* Check if device supports ZUC EEA3 */
4078 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4079 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4081 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4085 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4086 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4087 printf("Device doesn't support scatter-gather. "
4092 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4094 /* Append data which is padded to a multiple */
4095 /* of the algorithms block size */
4096 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4098 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4099 plaintext_pad_len, 10, 0);
4101 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4102 tdata->plaintext.data);
4104 /* Create ZUC session */
4105 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4106 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4107 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4108 tdata->key.data, tdata->key.len,
4109 tdata->cipher_iv.len);
4113 /* Clear mbuf payload */
4115 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4117 /* Create ZUC operation */
4118 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4119 tdata->cipher_iv.len, tdata->plaintext.len,
4124 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4126 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4128 ut_params->obuf = ut_params->op->sym->m_dst;
4129 if (ut_params->obuf)
4130 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4131 0, plaintext_len, ciphertext_buffer);
4133 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4134 0, plaintext_len, ciphertext_buffer);
4137 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4140 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4142 tdata->ciphertext.data,
4143 tdata->validCipherLenInBits.len,
4144 "ZUC Ciphertext data not as expected");
4150 test_zuc_authentication(const struct wireless_test_data *tdata)
4152 struct crypto_testsuite_params *ts_params = &testsuite_params;
4153 struct crypto_unittest_params *ut_params = &unittest_params;
4156 unsigned plaintext_pad_len;
4157 unsigned plaintext_len;
4160 struct rte_cryptodev_sym_capability_idx cap_idx;
4162 /* Check if device supports ZUC EIA3 */
4163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4164 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4166 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4170 /* Create ZUC session */
4171 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4172 tdata->key.data, tdata->key.len,
4173 tdata->auth_iv.len, tdata->digest.len,
4174 RTE_CRYPTO_AUTH_OP_GENERATE,
4175 RTE_CRYPTO_AUTH_ZUC_EIA3);
4179 /* alloc mbuf and set payload */
4180 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4182 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4183 rte_pktmbuf_tailroom(ut_params->ibuf));
4185 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4186 /* Append data which is padded to a multiple of */
4187 /* the algorithms block size */
4188 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4189 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4191 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4193 /* Create ZUC operation */
4194 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4195 tdata->auth_iv.data, tdata->auth_iv.len,
4196 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4197 tdata->validAuthLenInBits.len,
4202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4204 ut_params->obuf = ut_params->op->sym->m_src;
4205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4206 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4207 + plaintext_pad_len;
4210 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4213 DIGEST_BYTE_LENGTH_KASUMI_F9,
4214 "ZUC Generated auth tag not as expected");
4220 test_kasumi_encryption_test_case_1(void)
4222 return test_kasumi_encryption(&kasumi_test_case_1);
4226 test_kasumi_encryption_test_case_1_sgl(void)
4228 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4232 test_kasumi_encryption_test_case_1_oop(void)
4234 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4238 test_kasumi_encryption_test_case_1_oop_sgl(void)
4240 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4244 test_kasumi_encryption_test_case_2(void)
4246 return test_kasumi_encryption(&kasumi_test_case_2);
4250 test_kasumi_encryption_test_case_3(void)
4252 return test_kasumi_encryption(&kasumi_test_case_3);
4256 test_kasumi_encryption_test_case_4(void)
4258 return test_kasumi_encryption(&kasumi_test_case_4);
4262 test_kasumi_encryption_test_case_5(void)
4264 return test_kasumi_encryption(&kasumi_test_case_5);
4268 test_kasumi_decryption_test_case_1(void)
4270 return test_kasumi_decryption(&kasumi_test_case_1);
4274 test_kasumi_decryption_test_case_1_oop(void)
4276 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4280 test_kasumi_decryption_test_case_2(void)
4282 return test_kasumi_decryption(&kasumi_test_case_2);
4286 test_kasumi_decryption_test_case_3(void)
4288 return test_kasumi_decryption(&kasumi_test_case_3);
4292 test_kasumi_decryption_test_case_4(void)
4294 return test_kasumi_decryption(&kasumi_test_case_4);
4298 test_kasumi_decryption_test_case_5(void)
4300 return test_kasumi_decryption(&kasumi_test_case_5);
4303 test_snow3g_encryption_test_case_1(void)
4305 return test_snow3g_encryption(&snow3g_test_case_1);
4309 test_snow3g_encryption_test_case_1_oop(void)
4311 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4315 test_snow3g_encryption_test_case_1_oop_sgl(void)
4317 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4322 test_snow3g_encryption_test_case_1_offset_oop(void)
4324 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4328 test_snow3g_encryption_test_case_2(void)
4330 return test_snow3g_encryption(&snow3g_test_case_2);
4334 test_snow3g_encryption_test_case_3(void)
4336 return test_snow3g_encryption(&snow3g_test_case_3);
4340 test_snow3g_encryption_test_case_4(void)
4342 return test_snow3g_encryption(&snow3g_test_case_4);
4346 test_snow3g_encryption_test_case_5(void)
4348 return test_snow3g_encryption(&snow3g_test_case_5);
4352 test_snow3g_decryption_test_case_1(void)
4354 return test_snow3g_decryption(&snow3g_test_case_1);
4358 test_snow3g_decryption_test_case_1_oop(void)
4360 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4364 test_snow3g_decryption_test_case_2(void)
4366 return test_snow3g_decryption(&snow3g_test_case_2);
4370 test_snow3g_decryption_test_case_3(void)
4372 return test_snow3g_decryption(&snow3g_test_case_3);
4376 test_snow3g_decryption_test_case_4(void)
4378 return test_snow3g_decryption(&snow3g_test_case_4);
4382 test_snow3g_decryption_test_case_5(void)
4384 return test_snow3g_decryption(&snow3g_test_case_5);
4387 test_snow3g_cipher_auth_test_case_1(void)
4389 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4393 test_snow3g_auth_cipher_test_case_1(void)
4395 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4399 test_kasumi_auth_cipher_test_case_1(void)
4401 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4405 test_kasumi_cipher_auth_test_case_1(void)
4407 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4411 test_zuc_encryption_test_case_1(void)
4413 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4417 test_zuc_encryption_test_case_2(void)
4419 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4423 test_zuc_encryption_test_case_3(void)
4425 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4429 test_zuc_encryption_test_case_4(void)
4431 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4435 test_zuc_encryption_test_case_5(void)
4437 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4441 test_zuc_encryption_test_case_6_sgl(void)
4443 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4447 test_zuc_hash_generate_test_case_1(void)
4449 return test_zuc_authentication(&zuc_test_case_auth_1b);
4453 test_zuc_hash_generate_test_case_2(void)
4455 return test_zuc_authentication(&zuc_test_case_auth_90b);
4459 test_zuc_hash_generate_test_case_3(void)
4461 return test_zuc_authentication(&zuc_test_case_auth_577b);
4465 test_zuc_hash_generate_test_case_4(void)
4467 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4471 test_zuc_hash_generate_test_case_5(void)
4473 return test_zuc_authentication(&zuc_test_auth_5670b);
4477 test_zuc_hash_generate_test_case_6(void)
4479 return test_zuc_authentication(&zuc_test_case_auth_128b);
4483 test_zuc_hash_generate_test_case_7(void)
4485 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4489 test_zuc_hash_generate_test_case_8(void)
4491 return test_zuc_authentication(&zuc_test_case_auth_584b);
4495 test_zuc_cipher_auth_test_case_1(void)
4497 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4501 test_zuc_cipher_auth_test_case_2(void)
4503 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4507 test_3DES_chain_qat_all(void)
4509 struct crypto_testsuite_params *ts_params = &testsuite_params;
4512 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4513 ts_params->op_mpool, ts_params->valid_devs[0],
4514 rte_cryptodev_driver_id_get(
4515 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4516 BLKCIPHER_3DES_CHAIN_TYPE);
4518 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4520 return TEST_SUCCESS;
4524 test_DES_cipheronly_qat_all(void)
4526 struct crypto_testsuite_params *ts_params = &testsuite_params;
4529 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4530 ts_params->op_mpool, ts_params->valid_devs[0],
4531 rte_cryptodev_driver_id_get(
4532 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4533 BLKCIPHER_DES_CIPHERONLY_TYPE);
4535 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4537 return TEST_SUCCESS;
4541 test_DES_docsis_openssl_all(void)
4543 struct crypto_testsuite_params *ts_params = &testsuite_params;
4546 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4547 ts_params->op_mpool, ts_params->valid_devs[0],
4548 rte_cryptodev_driver_id_get(
4549 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4550 BLKCIPHER_DES_DOCSIS_TYPE);
4552 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4554 return TEST_SUCCESS;
4558 test_3DES_chain_dpaa2_sec_all(void)
4560 struct crypto_testsuite_params *ts_params = &testsuite_params;
4563 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4564 ts_params->op_mpool, ts_params->valid_devs[0],
4565 rte_cryptodev_driver_id_get(
4566 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4567 BLKCIPHER_3DES_CHAIN_TYPE);
4569 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4571 return TEST_SUCCESS;
4575 test_3DES_cipheronly_dpaa2_sec_all(void)
4577 struct crypto_testsuite_params *ts_params = &testsuite_params;
4580 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4581 ts_params->op_mpool, ts_params->valid_devs[0],
4582 rte_cryptodev_driver_id_get(
4583 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4584 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4588 return TEST_SUCCESS;
4592 test_3DES_cipheronly_qat_all(void)
4594 struct crypto_testsuite_params *ts_params = &testsuite_params;
4597 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4598 ts_params->op_mpool, ts_params->valid_devs[0],
4599 rte_cryptodev_driver_id_get(
4600 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4601 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4603 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4605 return TEST_SUCCESS;
4609 test_3DES_chain_openssl_all(void)
4611 struct crypto_testsuite_params *ts_params = &testsuite_params;
4614 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4615 ts_params->op_mpool, ts_params->valid_devs[0],
4616 rte_cryptodev_driver_id_get(
4617 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4618 BLKCIPHER_3DES_CHAIN_TYPE);
4620 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4622 return TEST_SUCCESS;
4626 test_3DES_cipheronly_openssl_all(void)
4628 struct crypto_testsuite_params *ts_params = &testsuite_params;
4631 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4632 ts_params->op_mpool, ts_params->valid_devs[0],
4633 rte_cryptodev_driver_id_get(
4634 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4635 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4639 return TEST_SUCCESS;
4642 /* ***** AES-GCM Tests ***** */
4645 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4646 const uint8_t *key, const uint8_t key_len,
4647 const uint16_t aad_len, const uint8_t auth_len,
4650 uint8_t aead_key[key_len];
4652 struct crypto_unittest_params *ut_params = &unittest_params;
4654 memcpy(aead_key, key, key_len);
4656 /* Setup AEAD Parameters */
4657 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4658 ut_params->aead_xform.next = NULL;
4659 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4660 ut_params->aead_xform.aead.op = op;
4661 ut_params->aead_xform.aead.key.data = aead_key;
4662 ut_params->aead_xform.aead.key.length = key_len;
4663 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4664 ut_params->aead_xform.aead.iv.length = iv_len;
4665 ut_params->aead_xform.aead.digest_length = auth_len;
4666 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4668 TEST_HEXDUMP(stdout, "key:", key, key_len);
4670 /* Create Crypto session*/
4671 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4672 &ut_params->aead_xform);
4674 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4680 create_gcm_xforms(struct rte_crypto_op *op,
4681 enum rte_crypto_aead_operation aead_op,
4682 uint8_t *key, const uint8_t key_len,
4683 const uint8_t aad_len, const uint8_t auth_len,
4686 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4687 "failed to allocate space for crypto transform");
4689 struct rte_crypto_sym_op *sym_op = op->sym;
4691 /* Setup AEAD Parameters */
4692 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4693 sym_op->xform->next = NULL;
4694 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4695 sym_op->xform->aead.op = aead_op;
4696 sym_op->xform->aead.key.data = key;
4697 sym_op->xform->aead.key.length = key_len;
4698 sym_op->xform->aead.iv.offset = IV_OFFSET;
4699 sym_op->xform->aead.iv.length = iv_len;
4700 sym_op->xform->aead.digest_length = auth_len;
4701 sym_op->xform->aead.add_auth_data_length = aad_len;
4703 TEST_HEXDUMP(stdout, "key:", key, key_len);
4709 create_gcm_operation(enum rte_crypto_aead_operation op,
4710 const struct gcm_test_data *tdata)
4712 struct crypto_testsuite_params *ts_params = &testsuite_params;
4713 struct crypto_unittest_params *ut_params = &unittest_params;
4715 uint8_t *plaintext, *ciphertext;
4716 unsigned int aad_pad_len, plaintext_pad_len;
4718 /* Generate Crypto op data structure */
4719 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4720 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4721 TEST_ASSERT_NOT_NULL(ut_params->op,
4722 "Failed to allocate symmetric crypto operation struct");
4724 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4726 /* Append aad data */
4727 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4728 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4730 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4731 "no room to append aad");
4733 sym_op->aead.aad.phys_addr =
4734 rte_pktmbuf_mtophys(ut_params->ibuf);
4735 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4736 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4739 /* Append IV at the end of the crypto operation*/
4740 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4741 uint8_t *, IV_OFFSET);
4743 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4744 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4747 /* Append plaintext/ciphertext */
4748 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4749 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4750 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4752 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4754 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4755 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4756 tdata->plaintext.len);
4758 if (ut_params->obuf) {
4759 ciphertext = (uint8_t *)rte_pktmbuf_append(
4761 plaintext_pad_len + aad_pad_len);
4762 TEST_ASSERT_NOT_NULL(ciphertext,
4763 "no room to append ciphertext");
4765 memset(ciphertext + aad_pad_len, 0,
4766 tdata->ciphertext.len);
4769 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4770 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4772 TEST_ASSERT_NOT_NULL(ciphertext,
4773 "no room to append ciphertext");
4775 memcpy(ciphertext, tdata->ciphertext.data,
4776 tdata->ciphertext.len);
4777 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4778 tdata->ciphertext.len);
4780 if (ut_params->obuf) {
4781 plaintext = (uint8_t *)rte_pktmbuf_append(
4783 plaintext_pad_len + aad_pad_len);
4784 TEST_ASSERT_NOT_NULL(plaintext,
4785 "no room to append plaintext");
4787 memset(plaintext + aad_pad_len, 0,
4788 tdata->plaintext.len);
4792 /* Append digest data */
4793 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4794 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4795 ut_params->obuf ? ut_params->obuf :
4797 tdata->auth_tag.len);
4798 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4799 "no room to append digest");
4800 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4801 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4802 ut_params->obuf ? ut_params->obuf :
4807 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4808 ut_params->ibuf, tdata->auth_tag.len);
4809 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4810 "no room to append digest");
4811 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4813 plaintext_pad_len + aad_pad_len);
4815 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4816 tdata->auth_tag.len);
4817 TEST_HEXDUMP(stdout, "digest:",
4818 sym_op->aead.digest.data,
4819 tdata->auth_tag.len);
4822 sym_op->aead.data.length = tdata->plaintext.len;
4823 sym_op->aead.data.offset = aad_pad_len;
4829 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4831 struct crypto_testsuite_params *ts_params = &testsuite_params;
4832 struct crypto_unittest_params *ut_params = &unittest_params;
4835 uint8_t *ciphertext, *auth_tag;
4836 uint16_t plaintext_pad_len;
4839 /* Create GCM session */
4840 retval = create_gcm_session(ts_params->valid_devs[0],
4841 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4842 tdata->key.data, tdata->key.len,
4843 tdata->aad.len, tdata->auth_tag.len,
4848 if (tdata->aad.len > MBUF_SIZE) {
4849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4850 /* Populate full size of add data */
4851 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4852 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4856 /* clear mbuf payload */
4857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4858 rte_pktmbuf_tailroom(ut_params->ibuf));
4860 /* Create GCM operation */
4861 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4865 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4867 ut_params->op->sym->m_src = ut_params->ibuf;
4869 /* Process crypto operation */
4870 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4871 ut_params->op), "failed to process sym crypto op");
4873 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4874 "crypto op processing failed");
4876 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4878 if (ut_params->op->sym->m_dst) {
4879 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4881 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4882 uint8_t *, plaintext_pad_len);
4884 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4886 ut_params->op->sym->cipher.data.offset);
4887 auth_tag = ciphertext + plaintext_pad_len;
4890 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4891 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4896 tdata->ciphertext.data,
4897 tdata->ciphertext.len,
4898 "GCM Ciphertext data not as expected");
4900 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4902 tdata->auth_tag.data,
4903 tdata->auth_tag.len,
4904 "GCM Generated auth tag not as expected");
4911 test_AES_GCM_authenticated_encryption_test_case_1(void)
4913 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4917 test_AES_GCM_authenticated_encryption_test_case_2(void)
4919 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4923 test_AES_GCM_authenticated_encryption_test_case_3(void)
4925 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4929 test_AES_GCM_authenticated_encryption_test_case_4(void)
4931 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4935 test_AES_GCM_authenticated_encryption_test_case_5(void)
4937 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4941 test_AES_GCM_authenticated_encryption_test_case_6(void)
4943 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4947 test_AES_GCM_authenticated_encryption_test_case_7(void)
4949 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4953 test_AES_GCM_auth_encryption_test_case_192_1(void)
4955 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
4959 test_AES_GCM_auth_encryption_test_case_192_2(void)
4961 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
4965 test_AES_GCM_auth_encryption_test_case_192_3(void)
4967 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
4971 test_AES_GCM_auth_encryption_test_case_192_4(void)
4973 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
4977 test_AES_GCM_auth_encryption_test_case_192_5(void)
4979 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
4983 test_AES_GCM_auth_encryption_test_case_192_6(void)
4985 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
4989 test_AES_GCM_auth_encryption_test_case_192_7(void)
4991 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
4995 test_AES_GCM_auth_encryption_test_case_256_1(void)
4997 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5001 test_AES_GCM_auth_encryption_test_case_256_2(void)
5003 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5007 test_AES_GCM_auth_encryption_test_case_256_3(void)
5009 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5013 test_AES_GCM_auth_encryption_test_case_256_4(void)
5015 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5019 test_AES_GCM_auth_encryption_test_case_256_5(void)
5021 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5025 test_AES_GCM_auth_encryption_test_case_256_6(void)
5027 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5031 test_AES_GCM_auth_encryption_test_case_256_7(void)
5033 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5037 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5039 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5043 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5045 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5049 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5051 struct crypto_testsuite_params *ts_params = &testsuite_params;
5052 struct crypto_unittest_params *ut_params = &unittest_params;
5058 /* Create GCM session */
5059 retval = create_gcm_session(ts_params->valid_devs[0],
5060 RTE_CRYPTO_AEAD_OP_DECRYPT,
5061 tdata->key.data, tdata->key.len,
5062 tdata->aad.len, tdata->auth_tag.len,
5067 /* alloc mbuf and set payload */
5068 if (tdata->aad.len > MBUF_SIZE) {
5069 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5070 /* Populate full size of add data */
5071 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5072 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5076 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5077 rte_pktmbuf_tailroom(ut_params->ibuf));
5079 /* Create GCM operation */
5080 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5084 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5086 ut_params->op->sym->m_src = ut_params->ibuf;
5088 /* Process crypto operation */
5089 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5090 ut_params->op), "failed to process sym crypto op");
5092 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5093 "crypto op processing failed");
5095 if (ut_params->op->sym->m_dst)
5096 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5099 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5101 ut_params->op->sym->cipher.data.offset);
5103 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5106 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5108 tdata->plaintext.data,
5109 tdata->plaintext.len,
5110 "GCM plaintext data not as expected");
5112 TEST_ASSERT_EQUAL(ut_params->op->status,
5113 RTE_CRYPTO_OP_STATUS_SUCCESS,
5114 "GCM authentication failed");
5119 test_AES_GCM_authenticated_decryption_test_case_1(void)
5121 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5125 test_AES_GCM_authenticated_decryption_test_case_2(void)
5127 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5131 test_AES_GCM_authenticated_decryption_test_case_3(void)
5133 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5137 test_AES_GCM_authenticated_decryption_test_case_4(void)
5139 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5143 test_AES_GCM_authenticated_decryption_test_case_5(void)
5145 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5149 test_AES_GCM_authenticated_decryption_test_case_6(void)
5151 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5155 test_AES_GCM_authenticated_decryption_test_case_7(void)
5157 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5161 test_AES_GCM_auth_decryption_test_case_192_1(void)
5163 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5167 test_AES_GCM_auth_decryption_test_case_192_2(void)
5169 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5173 test_AES_GCM_auth_decryption_test_case_192_3(void)
5175 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5179 test_AES_GCM_auth_decryption_test_case_192_4(void)
5181 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5185 test_AES_GCM_auth_decryption_test_case_192_5(void)
5187 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5191 test_AES_GCM_auth_decryption_test_case_192_6(void)
5193 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5197 test_AES_GCM_auth_decryption_test_case_192_7(void)
5199 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5203 test_AES_GCM_auth_decryption_test_case_256_1(void)
5205 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5209 test_AES_GCM_auth_decryption_test_case_256_2(void)
5211 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5215 test_AES_GCM_auth_decryption_test_case_256_3(void)
5217 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5221 test_AES_GCM_auth_decryption_test_case_256_4(void)
5223 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5227 test_AES_GCM_auth_decryption_test_case_256_5(void)
5229 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5233 test_AES_GCM_auth_decryption_test_case_256_6(void)
5235 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5239 test_AES_GCM_auth_decryption_test_case_256_7(void)
5241 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5245 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5247 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5251 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5253 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5257 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5259 struct crypto_testsuite_params *ts_params = &testsuite_params;
5260 struct crypto_unittest_params *ut_params = &unittest_params;
5263 uint8_t *ciphertext, *auth_tag;
5264 uint16_t plaintext_pad_len;
5266 /* Create GCM session */
5267 retval = create_gcm_session(ts_params->valid_devs[0],
5268 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5269 tdata->key.data, tdata->key.len,
5270 tdata->aad.len, tdata->auth_tag.len,
5275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5276 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5278 /* clear mbuf payload */
5279 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5280 rte_pktmbuf_tailroom(ut_params->ibuf));
5281 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5282 rte_pktmbuf_tailroom(ut_params->obuf));
5284 /* Create GCM operation */
5285 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5289 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5291 ut_params->op->sym->m_src = ut_params->ibuf;
5292 ut_params->op->sym->m_dst = ut_params->obuf;
5294 /* Process crypto operation */
5295 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5296 ut_params->op), "failed to process sym crypto op");
5298 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5299 "crypto op processing failed");
5301 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5303 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5304 ut_params->op->sym->cipher.data.offset);
5305 auth_tag = ciphertext + plaintext_pad_len;
5307 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5308 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5313 tdata->ciphertext.data,
5314 tdata->ciphertext.len,
5315 "GCM Ciphertext data not as expected");
5317 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5319 tdata->auth_tag.data,
5320 tdata->auth_tag.len,
5321 "GCM Generated auth tag not as expected");
5328 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5330 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5334 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5336 struct crypto_testsuite_params *ts_params = &testsuite_params;
5337 struct crypto_unittest_params *ut_params = &unittest_params;
5342 /* Create GCM session */
5343 retval = create_gcm_session(ts_params->valid_devs[0],
5344 RTE_CRYPTO_AEAD_OP_DECRYPT,
5345 tdata->key.data, tdata->key.len,
5346 tdata->aad.len, tdata->auth_tag.len,
5351 /* alloc mbuf and set payload */
5352 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5353 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5356 rte_pktmbuf_tailroom(ut_params->ibuf));
5357 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5358 rte_pktmbuf_tailroom(ut_params->obuf));
5360 /* Create GCM operation */
5361 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5365 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5367 ut_params->op->sym->m_src = ut_params->ibuf;
5368 ut_params->op->sym->m_dst = ut_params->obuf;
5370 /* Process crypto operation */
5371 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5372 ut_params->op), "failed to process sym crypto op");
5374 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5375 "crypto op processing failed");
5377 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5378 ut_params->op->sym->cipher.data.offset);
5380 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5383 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5385 tdata->plaintext.data,
5386 tdata->plaintext.len,
5387 "GCM plaintext data not as expected");
5389 TEST_ASSERT_EQUAL(ut_params->op->status,
5390 RTE_CRYPTO_OP_STATUS_SUCCESS,
5391 "GCM authentication failed");
5396 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5398 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5402 test_AES_GCM_authenticated_encryption_sessionless(
5403 const struct gcm_test_data *tdata)
5405 struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 struct crypto_unittest_params *ut_params = &unittest_params;
5409 uint8_t *ciphertext, *auth_tag;
5410 uint16_t plaintext_pad_len;
5411 uint8_t key[tdata->key.len + 1];
5413 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5415 /* clear mbuf payload */
5416 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5417 rte_pktmbuf_tailroom(ut_params->ibuf));
5419 /* Create GCM operation */
5420 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5424 /* Create GCM xforms */
5425 memcpy(key, tdata->key.data, tdata->key.len);
5426 retval = create_gcm_xforms(ut_params->op,
5427 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5428 key, tdata->key.len,
5429 tdata->aad.len, tdata->auth_tag.len,
5434 ut_params->op->sym->m_src = ut_params->ibuf;
5436 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5437 RTE_CRYPTO_OP_SESSIONLESS,
5438 "crypto op session type not sessionless");
5440 /* Process crypto operation */
5441 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5442 ut_params->op), "failed to process sym crypto op");
5444 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5446 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5447 "crypto op status not success");
5449 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5451 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5452 ut_params->op->sym->cipher.data.offset);
5453 auth_tag = ciphertext + plaintext_pad_len;
5455 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5456 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5459 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5461 tdata->ciphertext.data,
5462 tdata->ciphertext.len,
5463 "GCM Ciphertext data not as expected");
5465 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5467 tdata->auth_tag.data,
5468 tdata->auth_tag.len,
5469 "GCM Generated auth tag not as expected");
5476 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5478 return test_AES_GCM_authenticated_encryption_sessionless(
5483 test_AES_GCM_authenticated_decryption_sessionless(
5484 const struct gcm_test_data *tdata)
5486 struct crypto_testsuite_params *ts_params = &testsuite_params;
5487 struct crypto_unittest_params *ut_params = &unittest_params;
5491 uint8_t key[tdata->key.len + 1];
5493 /* alloc mbuf and set payload */
5494 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5497 rte_pktmbuf_tailroom(ut_params->ibuf));
5499 /* Create GCM operation */
5500 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5504 /* Create GCM xforms */
5505 memcpy(key, tdata->key.data, tdata->key.len);
5506 retval = create_gcm_xforms(ut_params->op,
5507 RTE_CRYPTO_AEAD_OP_DECRYPT,
5508 key, tdata->key.len,
5509 tdata->aad.len, tdata->auth_tag.len,
5514 ut_params->op->sym->m_src = ut_params->ibuf;
5516 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5517 RTE_CRYPTO_OP_SESSIONLESS,
5518 "crypto op session type not sessionless");
5520 /* Process crypto operation */
5521 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5522 ut_params->op), "failed to process sym crypto op");
5524 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5526 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5527 "crypto op status not success");
5529 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5530 ut_params->op->sym->cipher.data.offset);
5532 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5537 tdata->plaintext.data,
5538 tdata->plaintext.len,
5539 "GCM plaintext data not as expected");
5541 TEST_ASSERT_EQUAL(ut_params->op->status,
5542 RTE_CRYPTO_OP_STATUS_SUCCESS,
5543 "GCM authentication failed");
5548 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5550 return test_AES_GCM_authenticated_decryption_sessionless(
5557 struct crypto_testsuite_params *ts_params = &testsuite_params;
5558 struct rte_cryptodev_stats stats;
5559 struct rte_cryptodev *dev;
5560 cryptodev_stats_get_t temp_pfn;
5562 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5563 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5564 &stats) == -ENODEV),
5565 "rte_cryptodev_stats_get invalid dev failed");
5566 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5567 "rte_cryptodev_stats_get invalid Param failed");
5568 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5569 temp_pfn = dev->dev_ops->stats_get;
5570 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5571 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5573 "rte_cryptodev_stats_get invalid Param failed");
5574 dev->dev_ops->stats_get = temp_pfn;
5576 /* Test expected values */
5578 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5580 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5582 "rte_cryptodev_stats_get failed");
5583 TEST_ASSERT((stats.enqueued_count == 1),
5584 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5585 TEST_ASSERT((stats.dequeued_count == 1),
5586 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5587 TEST_ASSERT((stats.enqueue_err_count == 0),
5588 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5589 TEST_ASSERT((stats.dequeue_err_count == 0),
5590 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5592 /* invalid device but should ignore and not reset device stats*/
5593 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5594 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5596 "rte_cryptodev_stats_get failed");
5597 TEST_ASSERT((stats.enqueued_count == 1),
5598 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5600 /* check that a valid reset clears stats */
5601 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5602 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5604 "rte_cryptodev_stats_get failed");
5605 TEST_ASSERT((stats.enqueued_count == 0),
5606 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5607 TEST_ASSERT((stats.dequeued_count == 0),
5608 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5610 return TEST_SUCCESS;
5613 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5614 struct crypto_unittest_params *ut_params,
5615 enum rte_crypto_auth_operation op,
5616 const struct HMAC_MD5_vector *test_case)
5620 memcpy(key, test_case->key.data, test_case->key.len);
5622 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5623 ut_params->auth_xform.next = NULL;
5624 ut_params->auth_xform.auth.op = op;
5626 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5628 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5629 ut_params->auth_xform.auth.key.length = test_case->key.len;
5630 ut_params->auth_xform.auth.key.data = key;
5632 ut_params->sess = rte_cryptodev_sym_session_create(
5633 ts_params->valid_devs[0], &ut_params->auth_xform);
5635 if (ut_params->sess == NULL)
5638 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5640 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5641 rte_pktmbuf_tailroom(ut_params->ibuf));
5646 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5647 const struct HMAC_MD5_vector *test_case,
5648 uint8_t **plaintext)
5650 uint16_t plaintext_pad_len;
5652 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5654 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5657 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5659 memcpy(*plaintext, test_case->plaintext.data,
5660 test_case->plaintext.len);
5662 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5663 ut_params->ibuf, MD5_DIGEST_LEN);
5664 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5665 "no room to append digest");
5666 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5667 ut_params->ibuf, plaintext_pad_len);
5669 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5670 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5671 test_case->auth_tag.len);
5674 sym_op->auth.data.offset = 0;
5675 sym_op->auth.data.length = test_case->plaintext.len;
5677 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5678 ut_params->op->sym->m_src = ut_params->ibuf;
5684 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5686 uint16_t plaintext_pad_len;
5687 uint8_t *plaintext, *auth_tag;
5689 struct crypto_testsuite_params *ts_params = &testsuite_params;
5690 struct crypto_unittest_params *ut_params = &unittest_params;
5692 if (MD5_HMAC_create_session(ts_params, ut_params,
5693 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5696 /* Generate Crypto op data structure */
5697 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5698 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5699 TEST_ASSERT_NOT_NULL(ut_params->op,
5700 "Failed to allocate symmetric crypto operation struct");
5702 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5705 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5708 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5709 ut_params->op), "failed to process sym crypto op");
5711 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5712 "crypto op processing failed");
5714 if (ut_params->op->sym->m_dst) {
5715 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5716 uint8_t *, plaintext_pad_len);
5718 auth_tag = plaintext + plaintext_pad_len;
5721 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5723 test_case->auth_tag.data,
5724 test_case->auth_tag.len,
5725 "HMAC_MD5 generated tag not as expected");
5727 return TEST_SUCCESS;
5731 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5735 struct crypto_testsuite_params *ts_params = &testsuite_params;
5736 struct crypto_unittest_params *ut_params = &unittest_params;
5738 if (MD5_HMAC_create_session(ts_params, ut_params,
5739 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5743 /* Generate Crypto op data structure */
5744 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5745 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5746 TEST_ASSERT_NOT_NULL(ut_params->op,
5747 "Failed to allocate symmetric crypto operation struct");
5749 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5752 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5753 ut_params->op), "failed to process sym crypto op");
5755 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5756 "HMAC_MD5 crypto op processing failed");
5758 return TEST_SUCCESS;
5762 test_MD5_HMAC_generate_case_1(void)
5764 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5768 test_MD5_HMAC_verify_case_1(void)
5770 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5774 test_MD5_HMAC_generate_case_2(void)
5776 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5780 test_MD5_HMAC_verify_case_2(void)
5782 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5786 test_multi_session(void)
5788 struct crypto_testsuite_params *ts_params = &testsuite_params;
5789 struct crypto_unittest_params *ut_params = &unittest_params;
5791 struct rte_cryptodev_info dev_info;
5792 struct rte_cryptodev_sym_session **sessions;
5796 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5797 aes_cbc_key, hmac_sha512_key);
5800 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5802 sessions = rte_malloc(NULL,
5803 (sizeof(struct rte_cryptodev_sym_session *) *
5804 dev_info.sym.max_nb_sessions) + 1, 0);
5806 /* Create multiple crypto sessions*/
5807 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5808 sessions[i] = rte_cryptodev_sym_session_create(
5809 ts_params->valid_devs[0],
5810 &ut_params->auth_xform);
5811 TEST_ASSERT_NOT_NULL(sessions[i],
5812 "Session creation failed at session number %u",
5815 /* Attempt to send a request on each session */
5816 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5820 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5821 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5823 "Failed to perform decrypt on request number %u.", i);
5824 /* free crypto operation structure */
5826 rte_crypto_op_free(ut_params->op);
5829 * free mbuf - both obuf and ibuf are usually the same,
5830 * so check if they point at the same address is necessary,
5831 * to avoid freeing the mbuf twice.
5833 if (ut_params->obuf) {
5834 rte_pktmbuf_free(ut_params->obuf);
5835 if (ut_params->ibuf == ut_params->obuf)
5836 ut_params->ibuf = 0;
5837 ut_params->obuf = 0;
5839 if (ut_params->ibuf) {
5840 rte_pktmbuf_free(ut_params->ibuf);
5841 ut_params->ibuf = 0;
5845 /* Next session create should fail */
5846 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5847 &ut_params->auth_xform);
5848 TEST_ASSERT_NULL(sessions[i],
5849 "Session creation succeeded unexpectedly!");
5851 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5852 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5857 return TEST_SUCCESS;
5860 struct multi_session_params {
5861 struct crypto_unittest_params ut_params;
5862 uint8_t *cipher_key;
5864 const uint8_t *cipher;
5865 const uint8_t *digest;
5869 #define MB_SESSION_NUMBER 3
5872 test_multi_session_random_usage(void)
5874 struct crypto_testsuite_params *ts_params = &testsuite_params;
5875 struct rte_cryptodev_info dev_info;
5876 struct rte_cryptodev_sym_session **sessions;
5878 struct multi_session_params ut_paramz[] = {
5881 .cipher_key = ms_aes_cbc_key0,
5882 .hmac_key = ms_hmac_key0,
5883 .cipher = ms_aes_cbc_cipher0,
5884 .digest = ms_hmac_digest0,
5885 .iv = ms_aes_cbc_iv0
5888 .cipher_key = ms_aes_cbc_key1,
5889 .hmac_key = ms_hmac_key1,
5890 .cipher = ms_aes_cbc_cipher1,
5891 .digest = ms_hmac_digest1,
5892 .iv = ms_aes_cbc_iv1
5895 .cipher_key = ms_aes_cbc_key2,
5896 .hmac_key = ms_hmac_key2,
5897 .cipher = ms_aes_cbc_cipher2,
5898 .digest = ms_hmac_digest2,
5899 .iv = ms_aes_cbc_iv2
5904 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5906 sessions = rte_malloc(NULL,
5907 (sizeof(struct rte_cryptodev_sym_session *)
5908 * dev_info.sym.max_nb_sessions) + 1, 0);
5910 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5911 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5912 sizeof(struct crypto_unittest_params));
5914 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5915 &ut_paramz[i].ut_params,
5916 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5918 /* Create multiple crypto sessions*/
5919 sessions[i] = rte_cryptodev_sym_session_create(
5920 ts_params->valid_devs[0],
5921 &ut_paramz[i].ut_params.auth_xform);
5923 TEST_ASSERT_NOT_NULL(sessions[i],
5924 "Session creation failed at session number %u",
5930 for (i = 0; i < 40000; i++) {
5932 j = rand() % MB_SESSION_NUMBER;
5934 TEST_ASSERT_SUCCESS(
5935 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5937 &ut_paramz[j].ut_params,
5938 ts_params, ut_paramz[j].cipher,
5939 ut_paramz[j].digest,
5941 "Failed to perform decrypt on request number %u.", i);
5943 if (ut_paramz[j].ut_params.op)
5944 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5947 * free mbuf - both obuf and ibuf are usually the same,
5948 * so check if they point at the same address is necessary,
5949 * to avoid freeing the mbuf twice.
5951 if (ut_paramz[j].ut_params.obuf) {
5952 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5953 if (ut_paramz[j].ut_params.ibuf
5954 == ut_paramz[j].ut_params.obuf)
5955 ut_paramz[j].ut_params.ibuf = 0;
5956 ut_paramz[j].ut_params.obuf = 0;
5958 if (ut_paramz[j].ut_params.ibuf) {
5959 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5960 ut_paramz[j].ut_params.ibuf = 0;
5964 for (i = 0; i < MB_SESSION_NUMBER; i++)
5965 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5970 return TEST_SUCCESS;
5974 test_null_cipher_only_operation(void)
5976 struct crypto_testsuite_params *ts_params = &testsuite_params;
5977 struct crypto_unittest_params *ut_params = &unittest_params;
5979 /* Generate test mbuf data and space for digest */
5980 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5981 catch_22_quote, QUOTE_512_BYTES, 0);
5983 /* Setup Cipher Parameters */
5984 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5985 ut_params->cipher_xform.next = NULL;
5987 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5988 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5990 /* Create Crypto session*/
5991 ut_params->sess = rte_cryptodev_sym_session_create(
5992 ts_params->valid_devs[0], &ut_params->cipher_xform);
5993 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5995 /* Generate Crypto op data structure */
5996 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5997 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5998 TEST_ASSERT_NOT_NULL(ut_params->op,
5999 "Failed to allocate symmetric crypto operation struct");
6001 /* Set crypto operation data parameters */
6002 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6004 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6006 /* set crypto operation source mbuf */
6007 sym_op->m_src = ut_params->ibuf;
6009 sym_op->cipher.data.offset = 0;
6010 sym_op->cipher.data.length = QUOTE_512_BYTES;
6012 /* Process crypto operation */
6013 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6015 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6017 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6018 "crypto operation processing failed");
6021 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6022 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6025 "Ciphertext data not as expected");
6027 return TEST_SUCCESS;
6031 test_null_auth_only_operation(void)
6033 struct crypto_testsuite_params *ts_params = &testsuite_params;
6034 struct crypto_unittest_params *ut_params = &unittest_params;
6036 /* Generate test mbuf data and space for digest */
6037 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6038 catch_22_quote, QUOTE_512_BYTES, 0);
6040 /* Setup HMAC Parameters */
6041 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6042 ut_params->auth_xform.next = NULL;
6044 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6045 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6047 /* Create Crypto session*/
6048 ut_params->sess = rte_cryptodev_sym_session_create(
6049 ts_params->valid_devs[0], &ut_params->auth_xform);
6050 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6052 /* Generate Crypto op data structure */
6053 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6054 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6055 TEST_ASSERT_NOT_NULL(ut_params->op,
6056 "Failed to allocate symmetric crypto operation struct");
6058 /* Set crypto operation data parameters */
6059 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6061 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6063 sym_op->m_src = ut_params->ibuf;
6065 sym_op->auth.data.offset = 0;
6066 sym_op->auth.data.length = QUOTE_512_BYTES;
6068 /* Process crypto operation */
6069 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6071 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6073 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6074 "crypto operation processing failed");
6076 return TEST_SUCCESS;
6080 test_null_cipher_auth_operation(void)
6082 struct crypto_testsuite_params *ts_params = &testsuite_params;
6083 struct crypto_unittest_params *ut_params = &unittest_params;
6085 /* Generate test mbuf data and space for digest */
6086 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6087 catch_22_quote, QUOTE_512_BYTES, 0);
6089 /* Setup Cipher Parameters */
6090 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6091 ut_params->cipher_xform.next = &ut_params->auth_xform;
6093 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6094 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6096 /* Setup HMAC Parameters */
6097 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6098 ut_params->auth_xform.next = NULL;
6100 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6101 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6103 /* Create Crypto session*/
6104 ut_params->sess = rte_cryptodev_sym_session_create(
6105 ts_params->valid_devs[0], &ut_params->cipher_xform);
6106 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6108 /* Generate Crypto op data structure */
6109 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6110 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6111 TEST_ASSERT_NOT_NULL(ut_params->op,
6112 "Failed to allocate symmetric crypto operation struct");
6114 /* Set crypto operation data parameters */
6115 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6117 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6119 sym_op->m_src = ut_params->ibuf;
6121 sym_op->cipher.data.offset = 0;
6122 sym_op->cipher.data.length = QUOTE_512_BYTES;
6124 sym_op->auth.data.offset = 0;
6125 sym_op->auth.data.length = QUOTE_512_BYTES;
6127 /* Process crypto operation */
6128 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6130 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6132 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6133 "crypto operation processing failed");
6136 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6137 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6140 "Ciphertext data not as expected");
6142 return TEST_SUCCESS;
6146 test_null_auth_cipher_operation(void)
6148 struct crypto_testsuite_params *ts_params = &testsuite_params;
6149 struct crypto_unittest_params *ut_params = &unittest_params;
6151 /* Generate test mbuf data and space for digest */
6152 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6153 catch_22_quote, QUOTE_512_BYTES, 0);
6155 /* Setup Cipher Parameters */
6156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6157 ut_params->cipher_xform.next = NULL;
6159 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6160 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6162 /* Setup HMAC Parameters */
6163 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6164 ut_params->auth_xform.next = &ut_params->cipher_xform;
6166 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6167 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6169 /* Create Crypto session*/
6170 ut_params->sess = rte_cryptodev_sym_session_create(
6171 ts_params->valid_devs[0], &ut_params->cipher_xform);
6172 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6174 /* Generate Crypto op data structure */
6175 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6176 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6177 TEST_ASSERT_NOT_NULL(ut_params->op,
6178 "Failed to allocate symmetric crypto operation struct");
6180 /* Set crypto operation data parameters */
6181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6183 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6185 sym_op->m_src = ut_params->ibuf;
6187 sym_op->cipher.data.offset = 0;
6188 sym_op->cipher.data.length = QUOTE_512_BYTES;
6190 sym_op->auth.data.offset = 0;
6191 sym_op->auth.data.length = QUOTE_512_BYTES;
6193 /* Process crypto operation */
6194 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6196 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6198 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6199 "crypto operation processing failed");
6202 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6203 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6206 "Ciphertext data not as expected");
6208 return TEST_SUCCESS;
6213 test_null_invalid_operation(void)
6215 struct crypto_testsuite_params *ts_params = &testsuite_params;
6216 struct crypto_unittest_params *ut_params = &unittest_params;
6218 /* Setup Cipher Parameters */
6219 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6220 ut_params->cipher_xform.next = NULL;
6222 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6223 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6225 /* Create Crypto session*/
6226 ut_params->sess = rte_cryptodev_sym_session_create(
6227 ts_params->valid_devs[0], &ut_params->cipher_xform);
6228 TEST_ASSERT_NULL(ut_params->sess,
6229 "Session creation succeeded unexpectedly");
6232 /* Setup HMAC Parameters */
6233 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6234 ut_params->auth_xform.next = NULL;
6236 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6237 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6239 /* Create Crypto session*/
6240 ut_params->sess = rte_cryptodev_sym_session_create(
6241 ts_params->valid_devs[0], &ut_params->auth_xform);
6242 TEST_ASSERT_NULL(ut_params->sess,
6243 "Session creation succeeded unexpectedly");
6245 return TEST_SUCCESS;
6249 #define NULL_BURST_LENGTH (32)
6252 test_null_burst_operation(void)
6254 struct crypto_testsuite_params *ts_params = &testsuite_params;
6255 struct crypto_unittest_params *ut_params = &unittest_params;
6257 unsigned i, burst_len = NULL_BURST_LENGTH;
6259 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6260 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6262 /* Setup Cipher Parameters */
6263 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6264 ut_params->cipher_xform.next = &ut_params->auth_xform;
6266 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6267 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6269 /* Setup HMAC Parameters */
6270 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6271 ut_params->auth_xform.next = NULL;
6273 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6274 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6276 /* Create Crypto session*/
6277 ut_params->sess = rte_cryptodev_sym_session_create(
6278 ts_params->valid_devs[0], &ut_params->cipher_xform);
6279 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6281 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6282 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6283 burst_len, "failed to generate burst of crypto ops");
6285 /* Generate an operation for each mbuf in burst */
6286 for (i = 0; i < burst_len; i++) {
6287 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6289 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6291 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6295 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6297 burst[i]->sym->m_src = m;
6300 /* Process crypto operation */
6301 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6302 0, burst, burst_len),
6304 "Error enqueuing burst");
6306 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6307 0, burst_dequeued, burst_len),
6309 "Error dequeuing burst");
6312 for (i = 0; i < burst_len; i++) {
6314 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6315 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6317 "data not as expected");
6319 rte_pktmbuf_free(burst[i]->sym->m_src);
6320 rte_crypto_op_free(burst[i]);
6323 return TEST_SUCCESS;
6327 generate_gmac_large_plaintext(uint8_t *data)
6331 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6332 memcpy(&data[i], &data[0], 32);
6336 create_gmac_operation(enum rte_crypto_auth_operation op,
6337 const struct gmac_test_data *tdata)
6339 struct crypto_testsuite_params *ts_params = &testsuite_params;
6340 struct crypto_unittest_params *ut_params = &unittest_params;
6341 struct rte_crypto_sym_op *sym_op;
6343 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6345 /* Generate Crypto op data structure */
6346 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6347 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6348 TEST_ASSERT_NOT_NULL(ut_params->op,
6349 "Failed to allocate symmetric crypto operation struct");
6351 sym_op = ut_params->op->sym;
6353 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6354 ut_params->ibuf, tdata->gmac_tag.len);
6355 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6356 "no room to append digest");
6358 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6359 ut_params->ibuf, plaintext_pad_len);
6361 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6362 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6363 tdata->gmac_tag.len);
6364 TEST_HEXDUMP(stdout, "digest:",
6365 sym_op->auth.digest.data,
6366 tdata->gmac_tag.len);
6369 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6370 uint8_t *, IV_OFFSET);
6372 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6374 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6376 sym_op->cipher.data.length = 0;
6377 sym_op->cipher.data.offset = 0;
6379 sym_op->auth.data.offset = 0;
6380 sym_op->auth.data.length = tdata->plaintext.len;
6385 static int create_gmac_session(uint8_t dev_id,
6386 const struct gmac_test_data *tdata,
6387 enum rte_crypto_auth_operation auth_op)
6389 uint8_t auth_key[tdata->key.len];
6391 struct crypto_unittest_params *ut_params = &unittest_params;
6393 memcpy(auth_key, tdata->key.data, tdata->key.len);
6395 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6396 ut_params->auth_xform.next = NULL;
6398 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6399 ut_params->auth_xform.auth.op = auth_op;
6400 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6401 ut_params->auth_xform.auth.key.length = tdata->key.len;
6402 ut_params->auth_xform.auth.key.data = auth_key;
6403 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6404 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6407 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6408 &ut_params->auth_xform);
6410 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6416 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6418 struct crypto_testsuite_params *ts_params = &testsuite_params;
6419 struct crypto_unittest_params *ut_params = &unittest_params;
6423 uint8_t *auth_tag, *plaintext;
6424 uint16_t plaintext_pad_len;
6426 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6427 "No GMAC length in the source data");
6429 retval = create_gmac_session(ts_params->valid_devs[0],
6430 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6435 if (tdata->plaintext.len > MBUF_SIZE)
6436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6438 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6439 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6440 "Failed to allocate input buffer in mempool");
6442 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6443 rte_pktmbuf_tailroom(ut_params->ibuf));
6445 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6447 * Runtime generate the large plain text instead of use hard code
6448 * plain text vector. It is done to avoid create huge source file
6449 * with the test vector.
6451 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6452 generate_gmac_large_plaintext(tdata->plaintext.data);
6454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6456 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6458 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6459 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6460 tdata->plaintext.len);
6462 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6468 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6470 ut_params->op->sym->m_src = ut_params->ibuf;
6472 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6473 ut_params->op), "failed to process sym crypto op");
6475 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6476 "crypto op processing failed");
6478 if (ut_params->op->sym->m_dst) {
6479 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6480 uint8_t *, plaintext_pad_len);
6482 auth_tag = plaintext + plaintext_pad_len;
6485 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6487 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6489 tdata->gmac_tag.data,
6490 tdata->gmac_tag.len,
6491 "GMAC Generated auth tag not as expected");
6497 test_AES_GMAC_authentication_test_case_1(void)
6499 return test_AES_GMAC_authentication(&gmac_test_case_1);
6503 test_AES_GMAC_authentication_test_case_2(void)
6505 return test_AES_GMAC_authentication(&gmac_test_case_2);
6509 test_AES_GMAC_authentication_test_case_3(void)
6511 return test_AES_GMAC_authentication(&gmac_test_case_3);
6515 test_AES_GMAC_authentication_test_case_4(void)
6517 return test_AES_GMAC_authentication(&gmac_test_case_4);
6521 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6523 struct crypto_testsuite_params *ts_params = &testsuite_params;
6524 struct crypto_unittest_params *ut_params = &unittest_params;
6526 uint32_t plaintext_pad_len;
6529 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6530 "No GMAC length in the source data");
6532 retval = create_gmac_session(ts_params->valid_devs[0],
6533 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6538 if (tdata->plaintext.len > MBUF_SIZE)
6539 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6541 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6542 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6543 "Failed to allocate input buffer in mempool");
6545 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6546 rte_pktmbuf_tailroom(ut_params->ibuf));
6548 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6551 * Runtime generate the large plain text instead of use hard code
6552 * plain text vector. It is done to avoid create huge source file
6553 * with the test vector.
6555 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6556 generate_gmac_large_plaintext(tdata->plaintext.data);
6558 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6560 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6562 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6563 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6564 tdata->plaintext.len);
6566 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6572 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6574 ut_params->op->sym->m_src = ut_params->ibuf;
6576 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6577 ut_params->op), "failed to process sym crypto op");
6579 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6580 "crypto op processing failed");
6587 test_AES_GMAC_authentication_verify_test_case_1(void)
6589 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6593 test_AES_GMAC_authentication_verify_test_case_2(void)
6595 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6599 test_AES_GMAC_authentication_verify_test_case_3(void)
6601 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6605 test_AES_GMAC_authentication_verify_test_case_4(void)
6607 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6610 struct test_crypto_vector {
6611 enum rte_crypto_cipher_algorithm crypto_algo;
6624 const uint8_t *data;
6629 const uint8_t *data;
6633 enum rte_crypto_auth_algorithm auth_algo;
6641 const uint8_t *data;
6651 static const struct test_crypto_vector
6652 hmac_sha1_test_crypto_vector = {
6653 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6655 .data = plaintext_hash,
6660 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6661 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6662 0xDE, 0xF4, 0xDE, 0xAD
6668 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6669 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6670 0x3F, 0x91, 0x64, 0x59
6676 static const struct test_crypto_vector
6677 aes128_gmac_test_vector = {
6678 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6680 .data = plaintext_hash,
6685 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6686 0x08, 0x09, 0x0A, 0x0B
6692 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6693 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6699 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6700 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6706 static const struct test_crypto_vector
6707 aes128cbc_hmac_sha1_test_vector = {
6708 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6711 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6712 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6718 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6719 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6724 .data = plaintext_hash,
6728 .data = ciphertext512_aes128cbc,
6731 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6734 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6735 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6736 0xDE, 0xF4, 0xDE, 0xAD
6742 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6743 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6744 0x18, 0x8C, 0x1D, 0x32
6751 data_corruption(uint8_t *data)
6757 tag_corruption(uint8_t *data, unsigned int tag_offset)
6759 data[tag_offset] += 1;
6763 create_auth_session(struct crypto_unittest_params *ut_params,
6765 const struct test_crypto_vector *reference,
6766 enum rte_crypto_auth_operation auth_op)
6768 uint8_t auth_key[reference->auth_key.len + 1];
6770 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6772 /* Setup Authentication Parameters */
6773 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6774 ut_params->auth_xform.auth.op = auth_op;
6775 ut_params->auth_xform.next = NULL;
6776 ut_params->auth_xform.auth.algo = reference->auth_algo;
6777 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6778 ut_params->auth_xform.auth.key.data = auth_key;
6779 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6781 /* Create Crypto session*/
6782 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6783 &ut_params->auth_xform);
6785 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6791 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6793 const struct test_crypto_vector *reference,
6794 enum rte_crypto_auth_operation auth_op,
6795 enum rte_crypto_cipher_operation cipher_op)
6797 uint8_t cipher_key[reference->cipher_key.len + 1];
6798 uint8_t auth_key[reference->auth_key.len + 1];
6800 memcpy(cipher_key, reference->cipher_key.data,
6801 reference->cipher_key.len);
6802 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6804 /* Setup Authentication Parameters */
6805 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6806 ut_params->auth_xform.auth.op = auth_op;
6807 ut_params->auth_xform.auth.algo = reference->auth_algo;
6808 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6809 ut_params->auth_xform.auth.key.data = auth_key;
6810 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6812 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6813 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6814 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6816 ut_params->auth_xform.next = &ut_params->cipher_xform;
6818 /* Setup Cipher Parameters */
6819 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6820 ut_params->cipher_xform.next = NULL;
6821 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6822 ut_params->cipher_xform.cipher.op = cipher_op;
6823 ut_params->cipher_xform.cipher.key.data = cipher_key;
6824 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6825 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6826 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6829 /* Create Crypto session*/
6830 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6831 &ut_params->auth_xform);
6833 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6839 create_auth_operation(struct crypto_testsuite_params *ts_params,
6840 struct crypto_unittest_params *ut_params,
6841 const struct test_crypto_vector *reference,
6842 unsigned int auth_generate)
6844 /* Generate Crypto op data structure */
6845 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6846 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6847 TEST_ASSERT_NOT_NULL(ut_params->op,
6848 "Failed to allocate pktmbuf offload");
6850 /* Set crypto operation data parameters */
6851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6853 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6855 /* set crypto operation source mbuf */
6856 sym_op->m_src = ut_params->ibuf;
6859 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6860 ut_params->ibuf, reference->digest.len);
6862 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6863 "no room to append auth tag");
6865 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6866 ut_params->ibuf, reference->plaintext.len);
6869 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6871 memcpy(sym_op->auth.digest.data,
6872 reference->digest.data,
6873 reference->digest.len);
6875 TEST_HEXDUMP(stdout, "digest:",
6876 sym_op->auth.digest.data,
6877 reference->digest.len);
6879 sym_op->auth.data.length = reference->plaintext.len;
6880 sym_op->auth.data.offset = 0;
6886 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6887 struct crypto_unittest_params *ut_params,
6888 const struct test_crypto_vector *reference,
6889 unsigned int auth_generate)
6891 /* Generate Crypto op data structure */
6892 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6893 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6894 TEST_ASSERT_NOT_NULL(ut_params->op,
6895 "Failed to allocate pktmbuf offload");
6897 /* Set crypto operation data parameters */
6898 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6900 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6902 /* set crypto operation source mbuf */
6903 sym_op->m_src = ut_params->ibuf;
6906 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6907 ut_params->ibuf, reference->digest.len);
6909 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6910 "no room to append auth tag");
6912 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6913 ut_params->ibuf, reference->ciphertext.len);
6916 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6918 memcpy(sym_op->auth.digest.data,
6919 reference->digest.data,
6920 reference->digest.len);
6922 TEST_HEXDUMP(stdout, "digest:",
6923 sym_op->auth.digest.data,
6924 reference->digest.len);
6926 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6927 reference->iv.data, reference->iv.len);
6929 sym_op->cipher.data.length = 0;
6930 sym_op->cipher.data.offset = 0;
6932 sym_op->auth.data.length = reference->plaintext.len;
6933 sym_op->auth.data.offset = 0;
6939 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6940 struct crypto_unittest_params *ut_params,
6941 const struct test_crypto_vector *reference,
6942 unsigned int auth_generate)
6944 /* Generate Crypto op data structure */
6945 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6946 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6947 TEST_ASSERT_NOT_NULL(ut_params->op,
6948 "Failed to allocate pktmbuf offload");
6950 /* Set crypto operation data parameters */
6951 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6953 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6955 /* set crypto operation source mbuf */
6956 sym_op->m_src = ut_params->ibuf;
6959 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6960 ut_params->ibuf, reference->digest.len);
6962 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6963 "no room to append auth tag");
6965 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6966 ut_params->ibuf, reference->ciphertext.len);
6969 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6971 memcpy(sym_op->auth.digest.data,
6972 reference->digest.data,
6973 reference->digest.len);
6975 TEST_HEXDUMP(stdout, "digest:",
6976 sym_op->auth.digest.data,
6977 reference->digest.len);
6979 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6980 reference->iv.data, reference->iv.len);
6982 sym_op->cipher.data.length = reference->ciphertext.len;
6983 sym_op->cipher.data.offset = 0;
6985 sym_op->auth.data.length = reference->ciphertext.len;
6986 sym_op->auth.data.offset = 0;
6992 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6993 struct crypto_unittest_params *ut_params,
6994 const struct test_crypto_vector *reference)
6996 return create_auth_operation(ts_params, ut_params, reference, 0);
7000 create_auth_verify_GMAC_operation(
7001 struct crypto_testsuite_params *ts_params,
7002 struct crypto_unittest_params *ut_params,
7003 const struct test_crypto_vector *reference)
7005 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7009 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7010 struct crypto_unittest_params *ut_params,
7011 const struct test_crypto_vector *reference)
7013 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7017 test_authentication_verify_fail_when_data_corruption(
7018 struct crypto_testsuite_params *ts_params,
7019 struct crypto_unittest_params *ut_params,
7020 const struct test_crypto_vector *reference,
7021 unsigned int data_corrupted)
7027 /* Create session */
7028 retval = create_auth_session(ut_params,
7029 ts_params->valid_devs[0],
7031 RTE_CRYPTO_AUTH_OP_VERIFY);
7035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7036 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7037 "Failed to allocate input buffer in mempool");
7039 /* clear mbuf payload */
7040 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7041 rte_pktmbuf_tailroom(ut_params->ibuf));
7043 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7044 reference->plaintext.len);
7045 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7046 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7048 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7050 /* Create operation */
7051 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7057 data_corruption(plaintext);
7059 tag_corruption(plaintext, reference->plaintext.len);
7061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7063 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7064 TEST_ASSERT_EQUAL(ut_params->op->status,
7065 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7066 "authentication not failed");
7068 ut_params->obuf = ut_params->op->sym->m_src;
7069 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7075 test_authentication_verify_GMAC_fail_when_corruption(
7076 struct crypto_testsuite_params *ts_params,
7077 struct crypto_unittest_params *ut_params,
7078 const struct test_crypto_vector *reference,
7079 unsigned int data_corrupted)
7084 /* Create session */
7085 retval = create_auth_cipher_session(ut_params,
7086 ts_params->valid_devs[0],
7088 RTE_CRYPTO_AUTH_OP_VERIFY,
7089 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7093 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7094 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7095 "Failed to allocate input buffer in mempool");
7097 /* clear mbuf payload */
7098 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7099 rte_pktmbuf_tailroom(ut_params->ibuf));
7101 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7102 reference->plaintext.len);
7103 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7104 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7106 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7108 /* Create operation */
7109 retval = create_auth_verify_GMAC_operation(ts_params,
7117 data_corruption(plaintext);
7119 tag_corruption(plaintext, reference->aad.len);
7121 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7124 TEST_ASSERT_EQUAL(ut_params->op->status,
7125 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7126 "authentication not failed");
7128 ut_params->obuf = ut_params->op->sym->m_src;
7129 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7135 test_authenticated_decryption_fail_when_corruption(
7136 struct crypto_testsuite_params *ts_params,
7137 struct crypto_unittest_params *ut_params,
7138 const struct test_crypto_vector *reference,
7139 unsigned int data_corrupted)
7143 uint8_t *ciphertext;
7145 /* Create session */
7146 retval = create_auth_cipher_session(ut_params,
7147 ts_params->valid_devs[0],
7149 RTE_CRYPTO_AUTH_OP_VERIFY,
7150 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7155 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7156 "Failed to allocate input buffer in mempool");
7158 /* clear mbuf payload */
7159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7160 rte_pktmbuf_tailroom(ut_params->ibuf));
7162 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7163 reference->ciphertext.len);
7164 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7165 memcpy(ciphertext, reference->ciphertext.data,
7166 reference->ciphertext.len);
7168 /* Create operation */
7169 retval = create_cipher_auth_verify_operation(ts_params,
7177 data_corruption(ciphertext);
7179 tag_corruption(ciphertext, reference->ciphertext.len);
7181 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7184 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7185 TEST_ASSERT_EQUAL(ut_params->op->status,
7186 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7187 "authentication not failed");
7189 ut_params->obuf = ut_params->op->sym->m_src;
7190 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7196 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7197 const struct gcm_test_data *tdata,
7198 void *digest_mem, uint64_t digest_phys)
7200 struct crypto_testsuite_params *ts_params = &testsuite_params;
7201 struct crypto_unittest_params *ut_params = &unittest_params;
7203 const unsigned int auth_tag_len = tdata->auth_tag.len;
7204 const unsigned int iv_len = tdata->iv.len;
7205 const unsigned int aad_len = tdata->aad.len;
7207 /* Generate Crypto op data structure */
7208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7210 TEST_ASSERT_NOT_NULL(ut_params->op,
7211 "Failed to allocate symmetric crypto operation struct");
7213 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7215 sym_op->aead.digest.data = digest_mem;
7217 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7218 "no room to append digest");
7220 sym_op->aead.digest.phys_addr = digest_phys;
7222 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7223 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7225 TEST_HEXDUMP(stdout, "digest:",
7226 sym_op->aead.digest.data,
7230 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7231 uint8_t *, IV_OFFSET);
7233 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7235 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7236 ut_params->ibuf, aad_len);
7237 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7238 "no room to prepend aad");
7239 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7242 memset(sym_op->aead.aad.data, 0, aad_len);
7243 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7245 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7246 TEST_HEXDUMP(stdout, "aad:",
7247 sym_op->aead.aad.data, aad_len);
7249 sym_op->aead.data.length = tdata->plaintext.len;
7250 sym_op->aead.data.offset = aad_len;
7255 #define SGL_MAX_NO 16
7258 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7259 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7261 struct crypto_testsuite_params *ts_params = &testsuite_params;
7262 struct crypto_unittest_params *ut_params = &unittest_params;
7263 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7266 int to_trn_tbl[SGL_MAX_NO];
7268 unsigned int trn_data = 0;
7269 uint8_t *plaintext, *ciphertext, *auth_tag;
7271 if (fragsz > tdata->plaintext.len)
7272 fragsz = tdata->plaintext.len;
7274 uint16_t plaintext_len = fragsz;
7275 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7277 if (fragsz_oop > tdata->plaintext.len)
7278 frag_size_oop = tdata->plaintext.len;
7281 void *digest_mem = NULL;
7283 uint32_t prepend_len = tdata->aad.len;
7285 if (tdata->plaintext.len % fragsz != 0) {
7286 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7289 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7294 * For out-op-place we need to alloc another mbuf
7297 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7298 rte_pktmbuf_append(ut_params->obuf,
7299 frag_size_oop + prepend_len);
7300 buf_oop = ut_params->obuf;
7303 /* Create GCM session */
7304 retval = create_gcm_session(ts_params->valid_devs[0],
7305 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7306 tdata->key.data, tdata->key.len,
7307 tdata->aad.len, tdata->auth_tag.len,
7312 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7314 /* clear mbuf payload */
7315 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7316 rte_pktmbuf_tailroom(ut_params->ibuf));
7318 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7321 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7323 trn_data += plaintext_len;
7325 buf = ut_params->ibuf;
7328 * Loop until no more fragments
7331 while (trn_data < tdata->plaintext.len) {
7333 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7334 (tdata->plaintext.len - trn_data) : fragsz;
7336 to_trn_tbl[ecx++] = to_trn;
7338 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7341 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7342 rte_pktmbuf_tailroom(buf));
7345 if (oop && !fragsz_oop) {
7346 buf_last_oop = buf_oop->next =
7347 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7348 buf_oop = buf_oop->next;
7349 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7350 0, rte_pktmbuf_tailroom(buf_oop));
7351 rte_pktmbuf_append(buf_oop, to_trn);
7354 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7357 memcpy(plaintext, tdata->plaintext.data + trn_data,
7360 if (trn_data == tdata->plaintext.len) {
7363 digest_mem = rte_pktmbuf_append(buf_oop,
7364 tdata->auth_tag.len);
7366 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7367 tdata->auth_tag.len);
7371 uint64_t digest_phys = 0;
7373 ut_params->ibuf->nb_segs = segs;
7376 if (fragsz_oop && oop) {
7380 if (frag_size_oop == tdata->plaintext.len) {
7381 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7382 tdata->auth_tag.len);
7384 digest_phys = rte_pktmbuf_mtophys_offset(
7386 tdata->plaintext.len + prepend_len);
7389 trn_data = frag_size_oop;
7390 while (trn_data < tdata->plaintext.len) {
7393 (tdata->plaintext.len - trn_data <
7395 (tdata->plaintext.len - trn_data) :
7398 to_trn_tbl[ecx++] = to_trn;
7400 buf_last_oop = buf_oop->next =
7401 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7402 buf_oop = buf_oop->next;
7403 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7404 0, rte_pktmbuf_tailroom(buf_oop));
7405 rte_pktmbuf_append(buf_oop, to_trn);
7409 if (trn_data == tdata->plaintext.len) {
7410 digest_mem = rte_pktmbuf_append(buf_oop,
7411 tdata->auth_tag.len);
7415 ut_params->obuf->nb_segs = segs;
7419 * Place digest at the end of the last buffer
7422 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7423 if (oop && buf_last_oop)
7424 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7426 if (!digest_mem && !oop) {
7427 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7428 + tdata->auth_tag.len);
7429 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7430 tdata->plaintext.len);
7433 /* Create GCM opertaion */
7434 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7435 tdata, digest_mem, digest_phys);
7440 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7442 ut_params->op->sym->m_src = ut_params->ibuf;
7444 ut_params->op->sym->m_dst = ut_params->obuf;
7446 /* Process crypto operation */
7447 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7448 ut_params->op), "failed to process sym crypto op");
7450 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7451 "crypto op processing failed");
7454 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7455 uint8_t *, prepend_len);
7457 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7458 uint8_t *, prepend_len);
7462 fragsz = fragsz_oop;
7464 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7466 tdata->ciphertext.data,
7468 "GCM Ciphertext data not as expected");
7470 buf = ut_params->op->sym->m_src->next;
7472 buf = ut_params->op->sym->m_dst->next;
7474 unsigned int off = fragsz;
7478 ciphertext = rte_pktmbuf_mtod(buf,
7481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7483 tdata->ciphertext.data + off,
7485 "GCM Ciphertext data not as expected");
7487 off += to_trn_tbl[ecx++];
7491 auth_tag = digest_mem;
7492 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7494 tdata->auth_tag.data,
7495 tdata->auth_tag.len,
7496 "GCM Generated auth tag not as expected");
7502 #define OUT_OF_PLACE 1
7505 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7507 return test_AES_GCM_authenticated_encryption_SGL(
7508 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7512 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7514 return test_AES_GCM_authenticated_encryption_SGL(
7515 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7519 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7521 return test_AES_GCM_authenticated_encryption_SGL(
7522 &gcm_test_case_8, OUT_OF_PLACE, 400,
7523 gcm_test_case_8.plaintext.len);
7527 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7530 return test_AES_GCM_authenticated_encryption_SGL(
7531 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7535 test_authentication_verify_fail_when_data_corrupted(
7536 struct crypto_testsuite_params *ts_params,
7537 struct crypto_unittest_params *ut_params,
7538 const struct test_crypto_vector *reference)
7540 return test_authentication_verify_fail_when_data_corruption(
7541 ts_params, ut_params, reference, 1);
7545 test_authentication_verify_fail_when_tag_corrupted(
7546 struct crypto_testsuite_params *ts_params,
7547 struct crypto_unittest_params *ut_params,
7548 const struct test_crypto_vector *reference)
7550 return test_authentication_verify_fail_when_data_corruption(
7551 ts_params, ut_params, reference, 0);
7555 test_authentication_verify_GMAC_fail_when_data_corrupted(
7556 struct crypto_testsuite_params *ts_params,
7557 struct crypto_unittest_params *ut_params,
7558 const struct test_crypto_vector *reference)
7560 return test_authentication_verify_GMAC_fail_when_corruption(
7561 ts_params, ut_params, reference, 1);
7565 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7566 struct crypto_testsuite_params *ts_params,
7567 struct crypto_unittest_params *ut_params,
7568 const struct test_crypto_vector *reference)
7570 return test_authentication_verify_GMAC_fail_when_corruption(
7571 ts_params, ut_params, reference, 0);
7575 test_authenticated_decryption_fail_when_data_corrupted(
7576 struct crypto_testsuite_params *ts_params,
7577 struct crypto_unittest_params *ut_params,
7578 const struct test_crypto_vector *reference)
7580 return test_authenticated_decryption_fail_when_corruption(
7581 ts_params, ut_params, reference, 1);
7585 test_authenticated_decryption_fail_when_tag_corrupted(
7586 struct crypto_testsuite_params *ts_params,
7587 struct crypto_unittest_params *ut_params,
7588 const struct test_crypto_vector *reference)
7590 return test_authenticated_decryption_fail_when_corruption(
7591 ts_params, ut_params, reference, 0);
7595 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7597 return test_authentication_verify_fail_when_data_corrupted(
7598 &testsuite_params, &unittest_params,
7599 &hmac_sha1_test_crypto_vector);
7603 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7605 return test_authentication_verify_fail_when_tag_corrupted(
7606 &testsuite_params, &unittest_params,
7607 &hmac_sha1_test_crypto_vector);
7611 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7613 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7614 &testsuite_params, &unittest_params,
7615 &aes128_gmac_test_vector);
7619 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7621 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7622 &testsuite_params, &unittest_params,
7623 &aes128_gmac_test_vector);
7627 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7629 return test_authenticated_decryption_fail_when_data_corrupted(
7632 &aes128cbc_hmac_sha1_test_vector);
7636 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7638 return test_authenticated_decryption_fail_when_tag_corrupted(
7641 &aes128cbc_hmac_sha1_test_vector);
7644 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7646 /* global AESNI slave IDs for the scheduler test */
7647 uint8_t aesni_ids[2];
7650 test_scheduler_attach_slave_op(void)
7652 struct crypto_testsuite_params *ts_params = &testsuite_params;
7653 uint8_t sched_id = ts_params->valid_devs[0];
7654 uint32_t nb_devs, i, nb_devs_attached = 0;
7658 /* create 2 AESNI_MB if necessary */
7659 nb_devs = rte_cryptodev_device_count_by_driver(
7660 rte_cryptodev_driver_id_get(
7661 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
7663 for (i = nb_devs; i < 2; i++) {
7664 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7665 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7667 ret = rte_vdev_init(vdev_name, NULL);
7669 TEST_ASSERT(ret == 0,
7670 "Failed to create instance %u of"
7672 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7676 /* attach 2 AESNI_MB cdevs */
7677 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7679 struct rte_cryptodev_info info;
7681 rte_cryptodev_info_get(i, &info);
7682 if (info.driver_id != rte_cryptodev_driver_id_get(
7683 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
7686 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7689 TEST_ASSERT(ret == 0,
7690 "Failed to attach device %u of pmd : %s", i,
7691 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7693 aesni_ids[nb_devs_attached] = (uint8_t)i;
7702 test_scheduler_detach_slave_op(void)
7704 struct crypto_testsuite_params *ts_params = &testsuite_params;
7705 uint8_t sched_id = ts_params->valid_devs[0];
7709 for (i = 0; i < 2; i++) {
7710 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7712 TEST_ASSERT(ret == 0,
7713 "Failed to detach device %u", aesni_ids[i]);
7720 test_scheduler_mode_op(void)
7722 struct crypto_testsuite_params *ts_params = &testsuite_params;
7723 uint8_t sched_id = ts_params->valid_devs[0];
7724 struct rte_cryptodev_scheduler_ops op = {0};
7725 struct rte_cryptodev_scheduler dummy_scheduler = {
7726 .description = "dummy scheduler to test mode",
7727 .name = "dummy scheduler",
7728 .mode = CDEV_SCHED_MODE_USERDEFINED,
7733 /* set user defined mode */
7734 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7736 TEST_ASSERT(ret == 0,
7737 "Failed to set cdev %u to user defined mode", sched_id);
7739 /* set round robin mode */
7740 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7741 CDEV_SCHED_MODE_ROUNDROBIN);
7742 TEST_ASSERT(ret == 0,
7743 "Failed to set cdev %u to round-robin mode", sched_id);
7744 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7745 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7751 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7752 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7753 .setup = testsuite_setup,
7754 .teardown = testsuite_teardown,
7755 .unit_test_cases = {
7756 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7757 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7758 TEST_CASE_ST(ut_setup, ut_teardown,
7759 test_AES_chain_scheduler_all),
7760 TEST_CASE_ST(ut_setup, ut_teardown,
7761 test_AES_cipheronly_scheduler_all),
7762 TEST_CASE_ST(ut_setup, ut_teardown,
7763 test_authonly_scheduler_all),
7764 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7765 TEST_CASES_END() /**< NULL terminate unit test array */
7769 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7771 static struct unit_test_suite cryptodev_qat_testsuite = {
7772 .suite_name = "Crypto QAT Unit Test Suite",
7773 .setup = testsuite_setup,
7774 .teardown = testsuite_teardown,
7775 .unit_test_cases = {
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_device_configure_invalid_dev_id),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_device_configure_invalid_queue_pair_ids),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_queue_pair_descriptor_setup),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_multi_session),
7785 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 test_AES_cipheronly_qat_all),
7788 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7789 TEST_CASE_ST(ut_setup, ut_teardown,
7790 test_3DES_cipheronly_qat_all),
7791 TEST_CASE_ST(ut_setup, ut_teardown,
7792 test_DES_cipheronly_qat_all),
7793 TEST_CASE_ST(ut_setup, ut_teardown,
7794 test_AES_docsis_qat_all),
7795 TEST_CASE_ST(ut_setup, ut_teardown,
7796 test_DES_docsis_qat_all),
7797 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7799 /** AES GCM Authenticated Encryption */
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7802 TEST_CASE_ST(ut_setup, ut_teardown,
7803 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_AES_GCM_authenticated_encryption_test_case_1),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_AES_GCM_authenticated_encryption_test_case_2),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_AES_GCM_authenticated_encryption_test_case_3),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_AES_GCM_authenticated_encryption_test_case_4),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_AES_GCM_authenticated_encryption_test_case_5),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_AES_GCM_authenticated_encryption_test_case_6),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_AES_GCM_authenticated_encryption_test_case_7),
7821 /** AES GCM Authenticated Decryption */
7822 TEST_CASE_ST(ut_setup, ut_teardown,
7823 test_AES_GCM_authenticated_decryption_test_case_1),
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_AES_GCM_authenticated_decryption_test_case_2),
7826 TEST_CASE_ST(ut_setup, ut_teardown,
7827 test_AES_GCM_authenticated_decryption_test_case_3),
7828 TEST_CASE_ST(ut_setup, ut_teardown,
7829 test_AES_GCM_authenticated_decryption_test_case_4),
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 test_AES_GCM_authenticated_decryption_test_case_5),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 test_AES_GCM_authenticated_decryption_test_case_6),
7834 TEST_CASE_ST(ut_setup, ut_teardown,
7835 test_AES_GCM_authenticated_decryption_test_case_7),
7837 /** AES GCM Authenticated Encryption 192 bits key */
7838 TEST_CASE_ST(ut_setup, ut_teardown,
7839 test_AES_GCM_auth_encryption_test_case_192_1),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_AES_GCM_auth_encryption_test_case_192_2),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_AES_GCM_auth_encryption_test_case_192_3),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_AES_GCM_auth_encryption_test_case_192_4),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_AES_GCM_auth_encryption_test_case_192_5),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_AES_GCM_auth_encryption_test_case_192_6),
7850 TEST_CASE_ST(ut_setup, ut_teardown,
7851 test_AES_GCM_auth_encryption_test_case_192_7),
7853 /** AES GCM Authenticated Decryption 192 bits key */
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_AES_GCM_auth_decryption_test_case_192_1),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_AES_GCM_auth_decryption_test_case_192_2),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_AES_GCM_auth_decryption_test_case_192_3),
7860 TEST_CASE_ST(ut_setup, ut_teardown,
7861 test_AES_GCM_auth_decryption_test_case_192_4),
7862 TEST_CASE_ST(ut_setup, ut_teardown,
7863 test_AES_GCM_auth_decryption_test_case_192_5),
7864 TEST_CASE_ST(ut_setup, ut_teardown,
7865 test_AES_GCM_auth_decryption_test_case_192_6),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_AES_GCM_auth_decryption_test_case_192_7),
7869 /** AES GCM Authenticated Encryption 256 bits key */
7870 TEST_CASE_ST(ut_setup, ut_teardown,
7871 test_AES_GCM_auth_encryption_test_case_256_1),
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_AES_GCM_auth_encryption_test_case_256_2),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_AES_GCM_auth_encryption_test_case_256_3),
7876 TEST_CASE_ST(ut_setup, ut_teardown,
7877 test_AES_GCM_auth_encryption_test_case_256_4),
7878 TEST_CASE_ST(ut_setup, ut_teardown,
7879 test_AES_GCM_auth_encryption_test_case_256_5),
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_AES_GCM_auth_encryption_test_case_256_6),
7882 TEST_CASE_ST(ut_setup, ut_teardown,
7883 test_AES_GCM_auth_encryption_test_case_256_7),
7885 /** AES GMAC Authentication */
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_AES_GMAC_authentication_test_case_1),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_AES_GMAC_authentication_verify_test_case_1),
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_AES_GMAC_authentication_test_case_2),
7892 TEST_CASE_ST(ut_setup, ut_teardown,
7893 test_AES_GMAC_authentication_verify_test_case_2),
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_AES_GMAC_authentication_test_case_3),
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 test_AES_GMAC_authentication_verify_test_case_3),
7899 /** SNOW 3G encrypt only (UEA2) */
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_snow3g_encryption_test_case_1),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_snow3g_encryption_test_case_2),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_snow3g_encryption_test_case_3),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_snow3g_encryption_test_case_4),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_snow3g_encryption_test_case_5),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_snow3g_encryption_test_case_1_oop),
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 test_snow3g_decryption_test_case_1_oop),
7916 /** SNOW 3G decrypt only (UEA2) */
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_snow3g_decryption_test_case_1),
7919 TEST_CASE_ST(ut_setup, ut_teardown,
7920 test_snow3g_decryption_test_case_2),
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_snow3g_decryption_test_case_3),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_snow3g_decryption_test_case_4),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_snow3g_decryption_test_case_5),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_snow3g_hash_generate_test_case_1),
7929 TEST_CASE_ST(ut_setup, ut_teardown,
7930 test_snow3g_hash_generate_test_case_2),
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_snow3g_hash_generate_test_case_3),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_snow3g_hash_verify_test_case_1),
7935 TEST_CASE_ST(ut_setup, ut_teardown,
7936 test_snow3g_hash_verify_test_case_2),
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_snow3g_hash_verify_test_case_3),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_snow3g_cipher_auth_test_case_1),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_snow3g_auth_cipher_test_case_1),
7944 /** ZUC encrypt only (EEA3) */
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_zuc_encryption_test_case_1),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_zuc_encryption_test_case_2),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_zuc_encryption_test_case_3),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_zuc_encryption_test_case_4),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_zuc_encryption_test_case_5),
7956 /** ZUC authenticate (EIA3) */
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_zuc_hash_generate_test_case_6),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_zuc_hash_generate_test_case_7),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 test_zuc_hash_generate_test_case_8),
7964 /** ZUC alg-chain (EEA3/EIA3) */
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 test_zuc_cipher_auth_test_case_1),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 test_zuc_cipher_auth_test_case_2),
7970 /** HMAC_MD5 Authentication */
7971 TEST_CASE_ST(ut_setup, ut_teardown,
7972 test_MD5_HMAC_generate_case_1),
7973 TEST_CASE_ST(ut_setup, ut_teardown,
7974 test_MD5_HMAC_verify_case_1),
7975 TEST_CASE_ST(ut_setup, ut_teardown,
7976 test_MD5_HMAC_generate_case_2),
7977 TEST_CASE_ST(ut_setup, ut_teardown,
7978 test_MD5_HMAC_verify_case_2),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_null_auth_only_operation),
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_null_cipher_only_operation),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_null_cipher_auth_operation),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_null_auth_cipher_operation),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_kasumi_hash_generate_test_case_6),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_kasumi_encryption_test_case_1),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_kasumi_encryption_test_case_3),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_kasumi_auth_cipher_test_case_1),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_kasumi_cipher_auth_test_case_1),
8003 /** Negative tests */
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 authentication_verify_AES128_GMAC_fail_data_corrupt),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8017 TEST_CASES_END() /**< NULL terminate unit test array */
8021 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8022 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8023 .setup = testsuite_setup,
8024 .teardown = testsuite_teardown,
8025 .unit_test_cases = {
8026 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8027 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8028 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8029 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8031 TEST_CASES_END() /**< NULL terminate unit test array */
8035 static struct unit_test_suite cryptodev_openssl_testsuite = {
8036 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8037 .setup = testsuite_setup,
8038 .teardown = testsuite_teardown,
8039 .unit_test_cases = {
8040 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_multi_session_random_usage),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_AES_chain_openssl_all),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_AES_cipheronly_openssl_all),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_3DES_chain_openssl_all),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_3DES_cipheronly_openssl_all),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_DES_docsis_openssl_all),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_authonly_openssl_all),
8056 /** AES GCM Authenticated Encryption */
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_AES_GCM_authenticated_encryption_test_case_1),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_AES_GCM_authenticated_encryption_test_case_2),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 test_AES_GCM_authenticated_encryption_test_case_3),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_AES_GCM_authenticated_encryption_test_case_4),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_AES_GCM_authenticated_encryption_test_case_5),
8067 TEST_CASE_ST(ut_setup, ut_teardown,
8068 test_AES_GCM_authenticated_encryption_test_case_6),
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_AES_GCM_authenticated_encryption_test_case_7),
8072 /** AES GCM Authenticated Decryption */
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_AES_GCM_authenticated_decryption_test_case_1),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_AES_GCM_authenticated_decryption_test_case_2),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_AES_GCM_authenticated_decryption_test_case_3),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_AES_GCM_authenticated_decryption_test_case_4),
8081 TEST_CASE_ST(ut_setup, ut_teardown,
8082 test_AES_GCM_authenticated_decryption_test_case_5),
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 test_AES_GCM_authenticated_decryption_test_case_6),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 test_AES_GCM_authenticated_decryption_test_case_7),
8089 /** AES GCM Authenticated Encryption 192 bits key */
8090 TEST_CASE_ST(ut_setup, ut_teardown,
8091 test_AES_GCM_auth_encryption_test_case_192_1),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_AES_GCM_auth_encryption_test_case_192_2),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_AES_GCM_auth_encryption_test_case_192_3),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_AES_GCM_auth_encryption_test_case_192_4),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_AES_GCM_auth_encryption_test_case_192_5),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_AES_GCM_auth_encryption_test_case_192_6),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_AES_GCM_auth_encryption_test_case_192_7),
8105 /** AES GCM Authenticated Decryption 192 bits key */
8106 TEST_CASE_ST(ut_setup, ut_teardown,
8107 test_AES_GCM_auth_decryption_test_case_192_1),
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_AES_GCM_auth_decryption_test_case_192_2),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_AES_GCM_auth_decryption_test_case_192_3),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_AES_GCM_auth_decryption_test_case_192_4),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_AES_GCM_auth_decryption_test_case_192_5),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_AES_GCM_auth_decryption_test_case_192_6),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_AES_GCM_auth_decryption_test_case_192_7),
8121 /** AES GCM Authenticated Encryption 256 bits key */
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_AES_GCM_auth_encryption_test_case_256_1),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_AES_GCM_auth_encryption_test_case_256_2),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_AES_GCM_auth_encryption_test_case_256_3),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_AES_GCM_auth_encryption_test_case_256_4),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_AES_GCM_auth_encryption_test_case_256_5),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_AES_GCM_auth_encryption_test_case_256_6),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_AES_GCM_auth_encryption_test_case_256_7),
8137 /** AES GCM Authenticated Decryption 256 bits key */
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_AES_GCM_auth_decryption_test_case_256_1),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_AES_GCM_auth_decryption_test_case_256_2),
8142 TEST_CASE_ST(ut_setup, ut_teardown,
8143 test_AES_GCM_auth_decryption_test_case_256_3),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_AES_GCM_auth_decryption_test_case_256_4),
8146 TEST_CASE_ST(ut_setup, ut_teardown,
8147 test_AES_GCM_auth_decryption_test_case_256_5),
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_AES_GCM_auth_decryption_test_case_256_6),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_AES_GCM_auth_decryption_test_case_256_7),
8153 /** AES GMAC Authentication */
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_AES_GMAC_authentication_test_case_1),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_AES_GMAC_authentication_verify_test_case_1),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_AES_GMAC_authentication_test_case_2),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_AES_GMAC_authentication_verify_test_case_2),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_AES_GMAC_authentication_test_case_3),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_AES_GMAC_authentication_verify_test_case_3),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_AES_GMAC_authentication_test_case_4),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_AES_GMAC_authentication_verify_test_case_4),
8171 /** Scatter-Gather */
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8175 /** Negative tests */
8176 TEST_CASE_ST(ut_setup, ut_teardown,
8177 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8178 TEST_CASE_ST(ut_setup, ut_teardown,
8179 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8180 TEST_CASE_ST(ut_setup, ut_teardown,
8181 authentication_verify_AES128_GMAC_fail_data_corrupt),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8184 TEST_CASE_ST(ut_setup, ut_teardown,
8185 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8189 TEST_CASES_END() /**< NULL terminate unit test array */
8193 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8194 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8195 .setup = testsuite_setup,
8196 .teardown = testsuite_teardown,
8197 .unit_test_cases = {
8198 /** AES GCM Authenticated Encryption */
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_AES_GCM_authenticated_encryption_test_case_1),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_AES_GCM_authenticated_encryption_test_case_2),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_AES_GCM_authenticated_encryption_test_case_3),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_AES_GCM_authenticated_encryption_test_case_4),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_AES_GCM_authenticated_encryption_test_case_5),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_AES_GCM_authenticated_encryption_test_case_6),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_AES_GCM_authenticated_encryption_test_case_7),
8214 /** AES GCM Authenticated Decryption */
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_AES_GCM_authenticated_decryption_test_case_1),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_AES_GCM_authenticated_decryption_test_case_2),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_AES_GCM_authenticated_decryption_test_case_3),
8221 TEST_CASE_ST(ut_setup, ut_teardown,
8222 test_AES_GCM_authenticated_decryption_test_case_4),
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_AES_GCM_authenticated_decryption_test_case_5),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_AES_GCM_authenticated_decryption_test_case_6),
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 test_AES_GCM_authenticated_decryption_test_case_7),
8230 /** AES GCM Authenticated Encryption 192 bits key */
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 test_AES_GCM_auth_encryption_test_case_192_1),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_AES_GCM_auth_encryption_test_case_192_2),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_AES_GCM_auth_encryption_test_case_192_3),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_AES_GCM_auth_encryption_test_case_192_4),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_AES_GCM_auth_encryption_test_case_192_5),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 test_AES_GCM_auth_encryption_test_case_192_6),
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_AES_GCM_auth_encryption_test_case_192_7),
8246 /** AES GCM Authenticated Decryption 192 bits key */
8247 TEST_CASE_ST(ut_setup, ut_teardown,
8248 test_AES_GCM_auth_decryption_test_case_192_1),
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_AES_GCM_auth_decryption_test_case_192_2),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_AES_GCM_auth_decryption_test_case_192_3),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_AES_GCM_auth_decryption_test_case_192_4),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_AES_GCM_auth_decryption_test_case_192_5),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_AES_GCM_auth_decryption_test_case_192_6),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_AES_GCM_auth_decryption_test_case_192_7),
8262 /** AES GCM Authenticated Encryption 256 bits key */
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_AES_GCM_auth_encryption_test_case_256_1),
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_AES_GCM_auth_encryption_test_case_256_2),
8267 TEST_CASE_ST(ut_setup, ut_teardown,
8268 test_AES_GCM_auth_encryption_test_case_256_3),
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 test_AES_GCM_auth_encryption_test_case_256_4),
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_AES_GCM_auth_encryption_test_case_256_5),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_AES_GCM_auth_encryption_test_case_256_6),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_AES_GCM_auth_encryption_test_case_256_7),
8278 /** AES GCM Authenticated Decryption 256 bits key */
8279 TEST_CASE_ST(ut_setup, ut_teardown,
8280 test_AES_GCM_auth_decryption_test_case_256_1),
8281 TEST_CASE_ST(ut_setup, ut_teardown,
8282 test_AES_GCM_auth_decryption_test_case_256_2),
8283 TEST_CASE_ST(ut_setup, ut_teardown,
8284 test_AES_GCM_auth_decryption_test_case_256_3),
8285 TEST_CASE_ST(ut_setup, ut_teardown,
8286 test_AES_GCM_auth_decryption_test_case_256_4),
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 test_AES_GCM_auth_decryption_test_case_256_5),
8289 TEST_CASE_ST(ut_setup, ut_teardown,
8290 test_AES_GCM_auth_decryption_test_case_256_6),
8291 TEST_CASE_ST(ut_setup, ut_teardown,
8292 test_AES_GCM_auth_decryption_test_case_256_7),
8294 /** AES GCM Authenticated Encryption big aad size */
8295 TEST_CASE_ST(ut_setup, ut_teardown,
8296 test_AES_GCM_auth_encryption_test_case_aad_1),
8297 TEST_CASE_ST(ut_setup, ut_teardown,
8298 test_AES_GCM_auth_encryption_test_case_aad_2),
8300 /** AES GCM Authenticated Decryption big aad size */
8301 TEST_CASE_ST(ut_setup, ut_teardown,
8302 test_AES_GCM_auth_decryption_test_case_aad_1),
8303 TEST_CASE_ST(ut_setup, ut_teardown,
8304 test_AES_GCM_auth_decryption_test_case_aad_2),
8306 /** AES GMAC Authentication */
8307 TEST_CASE_ST(ut_setup, ut_teardown,
8308 test_AES_GMAC_authentication_test_case_1),
8309 TEST_CASE_ST(ut_setup, ut_teardown,
8310 test_AES_GMAC_authentication_verify_test_case_1),
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_AES_GMAC_authentication_test_case_3),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_AES_GMAC_authentication_verify_test_case_3),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_AES_GMAC_authentication_test_case_4),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_AES_GMAC_authentication_verify_test_case_4),
8320 /** Negative tests */
8321 TEST_CASE_ST(ut_setup, ut_teardown,
8322 authentication_verify_AES128_GMAC_fail_data_corrupt),
8323 TEST_CASE_ST(ut_setup, ut_teardown,
8324 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8326 /** Out of place tests */
8327 TEST_CASE_ST(ut_setup, ut_teardown,
8328 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8332 /** Session-less tests */
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8335 TEST_CASE_ST(ut_setup, ut_teardown,
8336 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8338 /** Scatter-Gather */
8339 TEST_CASE_ST(ut_setup, ut_teardown,
8340 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8342 TEST_CASES_END() /**< NULL terminate unit test array */
8346 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8347 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8348 .setup = testsuite_setup,
8349 .teardown = testsuite_teardown,
8350 .unit_test_cases = {
8351 /** KASUMI encrypt only (UEA1) */
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_kasumi_encryption_test_case_1),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_kasumi_encryption_test_case_1_sgl),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_kasumi_encryption_test_case_2),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_kasumi_encryption_test_case_3),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_kasumi_encryption_test_case_4),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_kasumi_encryption_test_case_5),
8364 /** KASUMI decrypt only (UEA1) */
8365 TEST_CASE_ST(ut_setup, ut_teardown,
8366 test_kasumi_decryption_test_case_1),
8367 TEST_CASE_ST(ut_setup, ut_teardown,
8368 test_kasumi_decryption_test_case_2),
8369 TEST_CASE_ST(ut_setup, ut_teardown,
8370 test_kasumi_decryption_test_case_3),
8371 TEST_CASE_ST(ut_setup, ut_teardown,
8372 test_kasumi_decryption_test_case_4),
8373 TEST_CASE_ST(ut_setup, ut_teardown,
8374 test_kasumi_decryption_test_case_5),
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 test_kasumi_encryption_test_case_1_oop),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_kasumi_encryption_test_case_1_oop_sgl),
8382 TEST_CASE_ST(ut_setup, ut_teardown,
8383 test_kasumi_decryption_test_case_1_oop),
8385 /** KASUMI hash only (UIA1) */
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 test_kasumi_hash_generate_test_case_1),
8388 TEST_CASE_ST(ut_setup, ut_teardown,
8389 test_kasumi_hash_generate_test_case_2),
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_kasumi_hash_generate_test_case_3),
8392 TEST_CASE_ST(ut_setup, ut_teardown,
8393 test_kasumi_hash_generate_test_case_4),
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 test_kasumi_hash_generate_test_case_5),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 test_kasumi_hash_generate_test_case_6),
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_kasumi_hash_verify_test_case_1),
8400 TEST_CASE_ST(ut_setup, ut_teardown,
8401 test_kasumi_hash_verify_test_case_2),
8402 TEST_CASE_ST(ut_setup, ut_teardown,
8403 test_kasumi_hash_verify_test_case_3),
8404 TEST_CASE_ST(ut_setup, ut_teardown,
8405 test_kasumi_hash_verify_test_case_4),
8406 TEST_CASE_ST(ut_setup, ut_teardown,
8407 test_kasumi_hash_verify_test_case_5),
8408 TEST_CASE_ST(ut_setup, ut_teardown,
8409 test_kasumi_auth_cipher_test_case_1),
8410 TEST_CASE_ST(ut_setup, ut_teardown,
8411 test_kasumi_cipher_auth_test_case_1),
8412 TEST_CASES_END() /**< NULL terminate unit test array */
8415 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8416 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8417 .setup = testsuite_setup,
8418 .teardown = testsuite_teardown,
8419 .unit_test_cases = {
8420 /** SNOW 3G encrypt only (UEA2) */
8421 TEST_CASE_ST(ut_setup, ut_teardown,
8422 test_snow3g_encryption_test_case_1),
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_snow3g_encryption_test_case_2),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_snow3g_encryption_test_case_3),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_snow3g_encryption_test_case_4),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_snow3g_encryption_test_case_5),
8432 TEST_CASE_ST(ut_setup, ut_teardown,
8433 test_snow3g_encryption_test_case_1_oop),
8434 TEST_CASE_ST(ut_setup, ut_teardown,
8435 test_snow3g_encryption_test_case_1_oop_sgl),
8436 TEST_CASE_ST(ut_setup, ut_teardown,
8437 test_snow3g_decryption_test_case_1_oop),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_snow3g_encryption_test_case_1_offset_oop),
8442 /** SNOW 3G decrypt only (UEA2) */
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_snow3g_decryption_test_case_1),
8445 TEST_CASE_ST(ut_setup, ut_teardown,
8446 test_snow3g_decryption_test_case_2),
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_snow3g_decryption_test_case_3),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_snow3g_decryption_test_case_4),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_snow3g_decryption_test_case_5),
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_snow3g_hash_generate_test_case_1),
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_snow3g_hash_generate_test_case_2),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_snow3g_hash_generate_test_case_3),
8459 /* Tests with buffers which length is not byte-aligned */
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_snow3g_hash_generate_test_case_4),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_snow3g_hash_generate_test_case_5),
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_snow3g_hash_generate_test_case_6),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_snow3g_hash_verify_test_case_1),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_snow3g_hash_verify_test_case_2),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_snow3g_hash_verify_test_case_3),
8472 /* Tests with buffers which length is not byte-aligned */
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_snow3g_hash_verify_test_case_4),
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_snow3g_hash_verify_test_case_5),
8477 TEST_CASE_ST(ut_setup, ut_teardown,
8478 test_snow3g_hash_verify_test_case_6),
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_snow3g_cipher_auth_test_case_1),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_snow3g_auth_cipher_test_case_1),
8484 TEST_CASES_END() /**< NULL terminate unit test array */
8488 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8489 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8490 .setup = testsuite_setup,
8491 .teardown = testsuite_teardown,
8492 .unit_test_cases = {
8493 /** ZUC encrypt only (EEA3) */
8494 TEST_CASE_ST(ut_setup, ut_teardown,
8495 test_zuc_encryption_test_case_1),
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_zuc_encryption_test_case_2),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_zuc_encryption_test_case_3),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_zuc_encryption_test_case_4),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_zuc_encryption_test_case_5),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_zuc_hash_generate_test_case_1),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_zuc_hash_generate_test_case_2),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_zuc_hash_generate_test_case_3),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_zuc_hash_generate_test_case_4),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_zuc_hash_generate_test_case_5),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_zuc_encryption_test_case_6_sgl),
8516 TEST_CASES_END() /**< NULL terminate unit test array */
8520 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8521 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8522 .setup = testsuite_setup,
8523 .teardown = testsuite_teardown,
8524 .unit_test_cases = {
8525 TEST_CASE_ST(ut_setup, ut_teardown,
8526 test_device_configure_invalid_dev_id),
8527 TEST_CASE_ST(ut_setup, ut_teardown,
8528 test_multi_session),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_chain_dpaa2_sec_all),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_3DES_chain_dpaa2_sec_all),
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_cipheronly_dpaa2_sec_all),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_3DES_cipheronly_dpaa2_sec_all),
8538 TEST_CASE_ST(ut_setup, ut_teardown,
8539 test_authonly_dpaa2_sec_all),
8541 /** AES GCM Authenticated Encryption */
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_authenticated_encryption_test_case_1),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_authenticated_encryption_test_case_2),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_authenticated_encryption_test_case_3),
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_AES_GCM_authenticated_encryption_test_case_4),
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_authenticated_encryption_test_case_5),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_authenticated_encryption_test_case_6),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_AES_GCM_authenticated_encryption_test_case_7),
8557 /** AES GCM Authenticated Decryption */
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GCM_authenticated_decryption_test_case_1),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GCM_authenticated_decryption_test_case_2),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GCM_authenticated_decryption_test_case_3),
8564 TEST_CASE_ST(ut_setup, ut_teardown,
8565 test_AES_GCM_authenticated_decryption_test_case_4),
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GCM_authenticated_decryption_test_case_5),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_AES_GCM_authenticated_decryption_test_case_6),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_AES_GCM_authenticated_decryption_test_case_7),
8573 /** AES GCM Authenticated Encryption 192 bits key */
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_AES_GCM_auth_encryption_test_case_192_1),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_AES_GCM_auth_encryption_test_case_192_2),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_AES_GCM_auth_encryption_test_case_192_3),
8580 TEST_CASE_ST(ut_setup, ut_teardown,
8581 test_AES_GCM_auth_encryption_test_case_192_4),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_AES_GCM_auth_encryption_test_case_192_5),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_AES_GCM_auth_encryption_test_case_192_6),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_AES_GCM_auth_encryption_test_case_192_7),
8589 /** AES GCM Authenticated Decryption 192 bits key */
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_AES_GCM_auth_decryption_test_case_192_1),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_AES_GCM_auth_decryption_test_case_192_2),
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_AES_GCM_auth_decryption_test_case_192_3),
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_AES_GCM_auth_decryption_test_case_192_4),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_AES_GCM_auth_decryption_test_case_192_5),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_AES_GCM_auth_decryption_test_case_192_6),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_AES_GCM_auth_decryption_test_case_192_7),
8605 /** AES GCM Authenticated Encryption 256 bits key */
8606 TEST_CASE_ST(ut_setup, ut_teardown,
8607 test_AES_GCM_auth_encryption_test_case_256_1),
8608 TEST_CASE_ST(ut_setup, ut_teardown,
8609 test_AES_GCM_auth_encryption_test_case_256_2),
8610 TEST_CASE_ST(ut_setup, ut_teardown,
8611 test_AES_GCM_auth_encryption_test_case_256_3),
8612 TEST_CASE_ST(ut_setup, ut_teardown,
8613 test_AES_GCM_auth_encryption_test_case_256_4),
8614 TEST_CASE_ST(ut_setup, ut_teardown,
8615 test_AES_GCM_auth_encryption_test_case_256_5),
8616 TEST_CASE_ST(ut_setup, ut_teardown,
8617 test_AES_GCM_auth_encryption_test_case_256_6),
8618 TEST_CASE_ST(ut_setup, ut_teardown,
8619 test_AES_GCM_auth_encryption_test_case_256_7),
8621 /** AES GCM Authenticated Decryption 256 bits key */
8622 TEST_CASE_ST(ut_setup, ut_teardown,
8623 test_AES_GCM_auth_decryption_test_case_256_1),
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_AES_GCM_auth_decryption_test_case_256_2),
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_AES_GCM_auth_decryption_test_case_256_3),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_AES_GCM_auth_decryption_test_case_256_4),
8630 TEST_CASE_ST(ut_setup, ut_teardown,
8631 test_AES_GCM_auth_decryption_test_case_256_5),
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_AES_GCM_auth_decryption_test_case_256_6),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_AES_GCM_auth_decryption_test_case_256_7),
8637 TEST_CASES_END() /**< NULL terminate unit test array */
8641 static struct unit_test_suite cryptodev_null_testsuite = {
8642 .suite_name = "Crypto Device NULL Unit Test Suite",
8643 .setup = testsuite_setup,
8644 .teardown = testsuite_teardown,
8645 .unit_test_cases = {
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 test_null_auth_only_operation),
8648 TEST_CASE_ST(ut_setup, ut_teardown,
8649 test_null_cipher_only_operation),
8650 TEST_CASE_ST(ut_setup, ut_teardown,
8651 test_null_cipher_auth_operation),
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_null_auth_cipher_operation),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_null_invalid_operation),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_null_burst_operation),
8659 TEST_CASES_END() /**< NULL terminate unit test array */
8663 static struct unit_test_suite cryptodev_armv8_testsuite = {
8664 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8665 .setup = testsuite_setup,
8666 .teardown = testsuite_teardown,
8667 .unit_test_cases = {
8668 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8670 /** Negative tests */
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8676 TEST_CASES_END() /**< NULL terminate unit test array */
8681 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8683 gbl_driver_id = rte_cryptodev_driver_id_get(
8684 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
8686 if (gbl_driver_id == -1) {
8687 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
8688 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
8689 "in config file to run this testsuite.\n");
8693 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8697 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8699 gbl_driver_id = rte_cryptodev_driver_id_get(
8700 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8702 if (gbl_driver_id == -1) {
8703 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8704 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8705 "in config file to run this testsuite.\n");
8709 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8713 test_cryptodev_openssl(void)
8715 gbl_driver_id = rte_cryptodev_driver_id_get(
8716 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
8718 if (gbl_driver_id == -1) {
8719 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8720 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8721 "in config file to run this testsuite.\n");
8725 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8729 test_cryptodev_aesni_gcm(void)
8731 gbl_driver_id = rte_cryptodev_driver_id_get(
8732 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
8734 if (gbl_driver_id == -1) {
8735 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
8736 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
8737 "in config file to run this testsuite.\n");
8741 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8745 test_cryptodev_null(void)
8747 gbl_driver_id = rte_cryptodev_driver_id_get(
8748 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
8750 if (gbl_driver_id == -1) {
8751 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
8752 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
8753 "in config file to run this testsuite.\n");
8757 return unit_test_suite_runner(&cryptodev_null_testsuite);
8761 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8763 gbl_driver_id = rte_cryptodev_driver_id_get(
8764 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
8766 if (gbl_driver_id == -1) {
8767 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
8768 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
8769 "in config file to run this testsuite.\n");
8773 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8777 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8779 gbl_driver_id = rte_cryptodev_driver_id_get(
8780 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
8782 if (gbl_driver_id == -1) {
8783 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8784 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
8785 "in config file to run this testsuite.\n");
8789 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8793 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8795 gbl_driver_id = rte_cryptodev_driver_id_get(
8796 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
8798 if (gbl_driver_id == -1) {
8799 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8800 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
8801 "in config file to run this testsuite.\n");
8805 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8809 test_cryptodev_armv8(void)
8811 gbl_driver_id = rte_cryptodev_driver_id_get(
8812 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
8814 if (gbl_driver_id == -1) {
8815 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
8816 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
8817 "in config file to run this testsuite.\n");
8821 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8824 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8827 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8829 gbl_driver_id = rte_cryptodev_driver_id_get(
8830 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
8832 if (gbl_driver_id == -1) {
8833 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
8834 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
8835 "in config file to run this testsuite.\n");
8839 if (rte_cryptodev_driver_id_get(
8840 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
8841 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
8842 " enabled in config file to run this testsuite.\n");
8845 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8848 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8853 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8855 gbl_driver_id = rte_cryptodev_driver_id_get(
8856 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
8858 if (gbl_driver_id == -1) {
8859 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
8860 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
8861 "in config file to run this testsuite.\n");
8865 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8868 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8869 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8870 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8871 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8872 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8873 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8874 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8875 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8876 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8877 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);