4 * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_pause.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
44 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
45 #include <rte_cryptodev_scheduler.h>
46 #include <rte_cryptodev_scheduler_operations.h>
50 #include "test_cryptodev.h"
52 #include "test_cryptodev_blockcipher.h"
53 #include "test_cryptodev_aes_test_vectors.h"
54 #include "test_cryptodev_des_test_vectors.h"
55 #include "test_cryptodev_hash_test_vectors.h"
56 #include "test_cryptodev_kasumi_test_vectors.h"
57 #include "test_cryptodev_kasumi_hash_test_vectors.h"
58 #include "test_cryptodev_snow3g_test_vectors.h"
59 #include "test_cryptodev_snow3g_hash_test_vectors.h"
60 #include "test_cryptodev_zuc_test_vectors.h"
61 #include "test_cryptodev_gcm_test_vectors.h"
62 #include "test_cryptodev_hmac_test_vectors.h"
64 static int gbl_driver_id;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_mempool *session_mpool;
71 struct rte_cryptodev_config conf;
72 struct rte_cryptodev_qp_conf qp_conf;
74 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
75 uint8_t valid_dev_count;
78 struct crypto_unittest_params {
79 struct rte_crypto_sym_xform cipher_xform;
80 struct rte_crypto_sym_xform auth_xform;
81 struct rte_crypto_sym_xform aead_xform;
83 struct rte_cryptodev_sym_session *sess;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
145 static struct rte_crypto_op *
146 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
148 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
149 printf("Error sending packet for encryption");
155 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
161 static struct crypto_testsuite_params testsuite_params = { NULL };
162 static struct crypto_unittest_params unittest_params;
165 testsuite_setup(void)
167 struct crypto_testsuite_params *ts_params = &testsuite_params;
168 struct rte_cryptodev_info info;
169 uint32_t i = 0, nb_devs, dev_id;
173 memset(ts_params, 0, sizeof(*ts_params));
175 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
176 if (ts_params->mbuf_pool == NULL) {
177 /* Not already created so create */
178 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
180 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
182 if (ts_params->mbuf_pool == NULL) {
183 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
188 ts_params->large_mbuf_pool = rte_mempool_lookup(
189 "CRYPTO_LARGE_MBUFPOOL");
190 if (ts_params->large_mbuf_pool == NULL) {
191 /* Not already created so create */
192 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
193 "CRYPTO_LARGE_MBUFPOOL",
196 if (ts_params->large_mbuf_pool == NULL) {
198 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
203 ts_params->op_mpool = rte_crypto_op_pool_create(
204 "MBUF_CRYPTO_SYM_OP_POOL",
205 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
206 NUM_MBUFS, MBUF_CACHE_SIZE,
208 sizeof(struct rte_crypto_sym_xform) +
211 if (ts_params->op_mpool == NULL) {
212 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
216 /* Create an AESNI MB device if required */
217 if (gbl_driver_id == rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
219 nb_devs = rte_cryptodev_device_count_by_driver(
220 rte_cryptodev_driver_id_get(
221 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
226 TEST_ASSERT(ret == 0,
227 "Failed to create instance of"
229 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
233 /* Create an AESNI GCM device if required */
234 if (gbl_driver_id == rte_cryptodev_driver_id_get(
235 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
236 nb_devs = rte_cryptodev_device_count_by_driver(
237 rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
240 TEST_ASSERT_SUCCESS(rte_vdev_init(
241 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
242 "Failed to create instance of"
244 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
248 /* Create a SNOW 3G device if required */
249 if (gbl_driver_id == rte_cryptodev_driver_id_get(
250 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
251 nb_devs = rte_cryptodev_device_count_by_driver(
252 rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
255 TEST_ASSERT_SUCCESS(rte_vdev_init(
256 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
257 "Failed to create instance of"
259 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
263 /* Create a KASUMI device if required */
264 if (gbl_driver_id == rte_cryptodev_driver_id_get(
265 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
266 nb_devs = rte_cryptodev_device_count_by_driver(
267 rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
270 TEST_ASSERT_SUCCESS(rte_vdev_init(
271 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
272 "Failed to create instance of"
274 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
278 /* Create a ZUC device if required */
279 if (gbl_driver_id == rte_cryptodev_driver_id_get(
280 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
281 nb_devs = rte_cryptodev_device_count_by_driver(
282 rte_cryptodev_driver_id_get(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
285 TEST_ASSERT_SUCCESS(rte_vdev_init(
286 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
287 "Failed to create instance of"
289 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
293 /* Create a NULL device if required */
294 if (gbl_driver_id == rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
296 nb_devs = rte_cryptodev_device_count_by_driver(
297 rte_cryptodev_driver_id_get(
298 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
301 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
303 TEST_ASSERT(ret == 0,
304 "Failed to create instance of"
306 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
310 /* Create an OPENSSL device if required */
311 if (gbl_driver_id == rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
313 nb_devs = rte_cryptodev_device_count_by_driver(
314 rte_cryptodev_driver_id_get(
315 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
318 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
321 TEST_ASSERT(ret == 0, "Failed to create "
322 "instance of pmd : %s",
323 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
327 /* Create a ARMv8 device if required */
328 if (gbl_driver_id == rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
330 nb_devs = rte_cryptodev_device_count_by_driver(
331 rte_cryptodev_driver_id_get(
332 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
335 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
338 TEST_ASSERT(ret == 0, "Failed to create "
339 "instance of pmd : %s",
340 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
344 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
345 if (gbl_driver_id == rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
348 nb_devs = rte_cryptodev_device_count_by_driver(
349 rte_cryptodev_driver_id_get(
350 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
353 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
356 TEST_ASSERT(ret == 0,
357 "Failed to create instance %u of"
359 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
362 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
364 nb_devs = rte_cryptodev_count();
366 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
370 /* Create list of valid crypto devs */
371 for (i = 0; i < nb_devs; i++) {
372 rte_cryptodev_info_get(i, &info);
373 if (info.driver_id == gbl_driver_id)
374 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
377 if (ts_params->valid_dev_count < 1)
380 /* Set up all the qps on the first of the valid devices found */
382 dev_id = ts_params->valid_devs[0];
384 rte_cryptodev_info_get(dev_id, &info);
386 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
387 ts_params->conf.socket_id = SOCKET_ID_ANY;
389 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
392 * Create mempool with maximum number of sessions * 2,
393 * to include the session headers
395 ts_params->session_mpool = rte_mempool_create(
397 info.sym.max_nb_sessions * 2,
399 0, 0, NULL, NULL, NULL,
403 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
404 "session mempool allocation failed");
406 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
407 &ts_params->conf, ts_params->session_mpool),
408 "Failed to configure cryptodev %u with %u qps",
409 dev_id, ts_params->conf.nb_queue_pairs);
411 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
413 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
414 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
415 dev_id, qp_id, &ts_params->qp_conf,
416 rte_cryptodev_socket_id(dev_id)),
417 "Failed to setup queue pair %u on cryptodev %u",
425 testsuite_teardown(void)
427 struct crypto_testsuite_params *ts_params = &testsuite_params;
429 if (ts_params->mbuf_pool != NULL) {
430 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
431 rte_mempool_avail_count(ts_params->mbuf_pool));
434 if (ts_params->op_mpool != NULL) {
435 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
436 rte_mempool_avail_count(ts_params->op_mpool));
439 /* Free session mempools */
440 if (ts_params->session_mpool != NULL) {
441 rte_mempool_free(ts_params->session_mpool);
442 ts_params->session_mpool = NULL;
449 struct crypto_testsuite_params *ts_params = &testsuite_params;
450 struct crypto_unittest_params *ut_params = &unittest_params;
454 /* Clear unit test parameters before running test */
455 memset(ut_params, 0, sizeof(*ut_params));
457 /* Reconfigure device to default parameters */
458 ts_params->conf.socket_id = SOCKET_ID_ANY;
460 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
461 &ts_params->conf, ts_params->session_mpool),
462 "Failed to configure cryptodev %u",
463 ts_params->valid_devs[0]);
465 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
466 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
467 ts_params->valid_devs[0], qp_id,
469 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
470 "Failed to setup queue pair %u on cryptodev %u",
471 qp_id, ts_params->valid_devs[0]);
475 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
477 /* Start the device */
478 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
479 "Failed to start cryptodev %u",
480 ts_params->valid_devs[0]);
488 struct crypto_testsuite_params *ts_params = &testsuite_params;
489 struct crypto_unittest_params *ut_params = &unittest_params;
490 struct rte_cryptodev_stats stats;
492 /* free crypto session structure */
493 if (ut_params->sess) {
494 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
496 rte_cryptodev_sym_session_free(ut_params->sess);
497 ut_params->sess = NULL;
500 /* free crypto operation structure */
502 rte_crypto_op_free(ut_params->op);
505 * free mbuf - both obuf and ibuf are usually the same,
506 * so check if they point at the same address is necessary,
507 * to avoid freeing the mbuf twice.
509 if (ut_params->obuf) {
510 rte_pktmbuf_free(ut_params->obuf);
511 if (ut_params->ibuf == ut_params->obuf)
515 if (ut_params->ibuf) {
516 rte_pktmbuf_free(ut_params->ibuf);
520 if (ts_params->mbuf_pool != NULL)
521 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
522 rte_mempool_avail_count(ts_params->mbuf_pool));
524 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
526 /* Stop the device */
527 rte_cryptodev_stop(ts_params->valid_devs[0]);
531 test_device_configure_invalid_dev_id(void)
533 struct crypto_testsuite_params *ts_params = &testsuite_params;
534 uint16_t dev_id, num_devs = 0;
536 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
537 "Need at least %d devices for test", 1);
539 /* valid dev_id values */
540 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
542 /* Stop the device in case it's started so it can be configured */
543 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
545 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
546 ts_params->session_mpool),
547 "Failed test for rte_cryptodev_configure: "
548 "invalid dev_num %u", dev_id);
550 /* invalid dev_id values */
553 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
554 ts_params->session_mpool),
555 "Failed test for rte_cryptodev_configure: "
556 "invalid dev_num %u", dev_id);
560 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
561 ts_params->session_mpool),
562 "Failed test for rte_cryptodev_configure:"
563 "invalid dev_num %u", dev_id);
569 test_device_configure_invalid_queue_pair_ids(void)
571 struct crypto_testsuite_params *ts_params = &testsuite_params;
572 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
574 /* Stop the device in case it's started so it can be configured */
575 rte_cryptodev_stop(ts_params->valid_devs[0]);
577 /* valid - one queue pairs */
578 ts_params->conf.nb_queue_pairs = 1;
580 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
581 &ts_params->conf, ts_params->session_mpool),
582 "Failed to configure cryptodev: dev_id %u, qp_id %u",
583 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
586 /* valid - max value queue pairs */
587 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
589 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
590 &ts_params->conf, ts_params->session_mpool),
591 "Failed to configure cryptodev: dev_id %u, qp_id %u",
592 ts_params->valid_devs[0],
593 ts_params->conf.nb_queue_pairs);
596 /* invalid - zero queue pairs */
597 ts_params->conf.nb_queue_pairs = 0;
599 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
600 &ts_params->conf, ts_params->session_mpool),
601 "Failed test for rte_cryptodev_configure, dev_id %u,"
603 ts_params->valid_devs[0],
604 ts_params->conf.nb_queue_pairs);
607 /* invalid - max value supported by field queue pairs */
608 ts_params->conf.nb_queue_pairs = UINT16_MAX;
610 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
611 &ts_params->conf, ts_params->session_mpool),
612 "Failed test for rte_cryptodev_configure, dev_id %u,"
614 ts_params->valid_devs[0],
615 ts_params->conf.nb_queue_pairs);
618 /* invalid - max value + 1 queue pairs */
619 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
621 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
622 &ts_params->conf, ts_params->session_mpool),
623 "Failed test for rte_cryptodev_configure, dev_id %u,"
625 ts_params->valid_devs[0],
626 ts_params->conf.nb_queue_pairs);
628 /* revert to original testsuite value */
629 ts_params->conf.nb_queue_pairs = orig_nb_qps;
635 test_queue_pair_descriptor_setup(void)
637 struct crypto_testsuite_params *ts_params = &testsuite_params;
638 struct rte_cryptodev_info dev_info;
639 struct rte_cryptodev_qp_conf qp_conf = {
640 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
645 /* Stop the device in case it's started so it can be configured */
646 rte_cryptodev_stop(ts_params->valid_devs[0]);
649 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
652 &ts_params->conf, ts_params->session_mpool),
653 "Failed to configure cryptodev %u",
654 ts_params->valid_devs[0]);
657 * Test various ring sizes on this device. memzones can't be
658 * freed so are re-used if ring is released and re-created.
660 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
662 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
663 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
664 ts_params->valid_devs[0], qp_id, &qp_conf,
665 rte_cryptodev_socket_id(
666 ts_params->valid_devs[0])),
668 "rte_cryptodev_queue_pair_setup: num_inflights "
669 "%u on qp %u on cryptodev %u",
670 qp_conf.nb_descriptors, qp_id,
671 ts_params->valid_devs[0]);
674 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
676 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
677 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
678 ts_params->valid_devs[0], qp_id, &qp_conf,
679 rte_cryptodev_socket_id(
680 ts_params->valid_devs[0])),
682 " rte_cryptodev_queue_pair_setup: num_inflights"
683 " %u on qp %u on cryptodev %u",
684 qp_conf.nb_descriptors, qp_id,
685 ts_params->valid_devs[0]);
688 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
690 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
691 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
692 ts_params->valid_devs[0], qp_id, &qp_conf,
693 rte_cryptodev_socket_id(
694 ts_params->valid_devs[0])),
696 "rte_cryptodev_queue_pair_setup: num_inflights"
697 " %u on qp %u on cryptodev %u",
698 qp_conf.nb_descriptors, qp_id,
699 ts_params->valid_devs[0]);
702 /* invalid number of descriptors - max supported + 2 */
703 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
705 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
706 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
707 ts_params->valid_devs[0], qp_id, &qp_conf,
708 rte_cryptodev_socket_id(
709 ts_params->valid_devs[0])),
710 "Unexpectedly passed test for "
711 "rte_cryptodev_queue_pair_setup:"
712 "num_inflights %u on qp %u on cryptodev %u",
713 qp_conf.nb_descriptors, qp_id,
714 ts_params->valid_devs[0]);
717 /* invalid number of descriptors - max value of parameter */
718 qp_conf.nb_descriptors = UINT32_MAX-1;
720 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
721 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
722 ts_params->valid_devs[0], qp_id, &qp_conf,
723 rte_cryptodev_socket_id(
724 ts_params->valid_devs[0])),
725 "Unexpectedly passed test for "
726 "rte_cryptodev_queue_pair_setup:"
727 "num_inflights %u on qp %u on cryptodev %u",
728 qp_conf.nb_descriptors, qp_id,
729 ts_params->valid_devs[0]);
732 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
734 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
735 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
736 ts_params->valid_devs[0], qp_id, &qp_conf,
737 rte_cryptodev_socket_id(
738 ts_params->valid_devs[0])),
740 " rte_cryptodev_queue_pair_setup:"
741 "num_inflights %u on qp %u on cryptodev %u",
742 qp_conf.nb_descriptors, qp_id,
743 ts_params->valid_devs[0]);
746 /* invalid number of descriptors - max supported + 1 */
747 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
749 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
750 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
751 ts_params->valid_devs[0], qp_id, &qp_conf,
752 rte_cryptodev_socket_id(
753 ts_params->valid_devs[0])),
754 "Unexpectedly passed test for "
755 "rte_cryptodev_queue_pair_setup:"
756 "num_inflights %u on qp %u on cryptodev %u",
757 qp_conf.nb_descriptors, qp_id,
758 ts_params->valid_devs[0]);
761 /* test invalid queue pair id */
762 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
764 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
766 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
767 ts_params->valid_devs[0],
769 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
770 "Failed test for rte_cryptodev_queue_pair_setup:"
771 "invalid qp %u on cryptodev %u",
772 qp_id, ts_params->valid_devs[0]);
774 qp_id = 0xffff; /*invalid*/
776 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
777 ts_params->valid_devs[0],
779 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
780 "Failed test for rte_cryptodev_queue_pair_setup:"
781 "invalid qp %u on cryptodev %u",
782 qp_id, ts_params->valid_devs[0]);
787 /* ***** Plaintext data for tests ***** */
789 const char catch_22_quote_1[] =
790 "There was only one catch and that was Catch-22, which "
791 "specified that a concern for one's safety in the face of "
792 "dangers that were real and immediate was the process of a "
793 "rational mind. Orr was crazy and could be grounded. All he "
794 "had to do was ask; and as soon as he did, he would no longer "
795 "be crazy and would have to fly more missions. Orr would be "
796 "crazy to fly more missions and sane if he didn't, but if he "
797 "was sane he had to fly them. If he flew them he was crazy "
798 "and didn't have to; but if he didn't want to he was sane and "
799 "had to. Yossarian was moved very deeply by the absolute "
800 "simplicity of this clause of Catch-22 and let out a "
801 "respectful whistle. \"That's some catch, that Catch-22\", he "
802 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
804 const char catch_22_quote[] =
805 "What a lousy earth! He wondered how many people were "
806 "destitute that same night even in his own prosperous country, "
807 "how many homes were shanties, how many husbands were drunk "
808 "and wives socked, and how many children were bullied, abused, "
809 "or abandoned. How many families hungered for food they could "
810 "not afford to buy? How many hearts were broken? How many "
811 "suicides would take place that same night, how many people "
812 "would go insane? How many cockroaches and landlords would "
813 "triumph? How many winners were losers, successes failures, "
814 "and rich men poor men? How many wise guys were stupid? How "
815 "many happy endings were unhappy endings? How many honest men "
816 "were liars, brave men cowards, loyal men traitors, how many "
817 "sainted men were corrupt, how many people in positions of "
818 "trust had sold their souls to bodyguards, how many had never "
819 "had souls? How many straight-and-narrow paths were crooked "
820 "paths? How many best families were worst families and how "
821 "many good people were bad people? When you added them all up "
822 "and then subtracted, you might be left with only the children, "
823 "and perhaps with Albert Einstein and an old violinist or "
824 "sculptor somewhere.";
826 #define QUOTE_480_BYTES (480)
827 #define QUOTE_512_BYTES (512)
828 #define QUOTE_768_BYTES (768)
829 #define QUOTE_1024_BYTES (1024)
833 /* ***** SHA1 Hash Tests ***** */
835 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
837 static uint8_t hmac_sha1_key[] = {
838 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
839 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
840 0xDE, 0xF4, 0xDE, 0xAD };
842 /* ***** SHA224 Hash Tests ***** */
844 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
847 /* ***** AES-CBC Cipher Tests ***** */
849 #define CIPHER_KEY_LENGTH_AES_CBC (16)
850 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
852 static uint8_t aes_cbc_key[] = {
853 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
854 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
856 static uint8_t aes_cbc_iv[] = {
857 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
858 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
861 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
863 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
864 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
865 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
866 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
867 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
868 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
869 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
870 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
871 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
872 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
873 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
874 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
875 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
876 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
877 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
878 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
879 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
880 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
881 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
882 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
883 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
884 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
885 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
886 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
887 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
888 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
889 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
890 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
891 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
892 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
893 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
894 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
895 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
896 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
897 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
898 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
899 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
900 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
901 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
902 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
903 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
904 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
905 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
906 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
907 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
908 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
909 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
910 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
911 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
912 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
913 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
914 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
915 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
916 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
917 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
918 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
919 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
920 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
921 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
922 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
923 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
924 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
925 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
926 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
927 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
930 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
931 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
932 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
933 0x18, 0x8c, 0x1d, 0x32
937 /* Multisession Vector context Test */
939 static uint8_t ms_aes_cbc_key0[] = {
940 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
941 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
944 static uint8_t ms_aes_cbc_iv0[] = {
945 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
946 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
949 static const uint8_t ms_aes_cbc_cipher0[] = {
950 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
951 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
952 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
953 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
954 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
955 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
956 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
957 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
958 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
959 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
960 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
961 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
962 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
963 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
964 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
965 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
966 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
967 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
968 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
969 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
970 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
971 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
972 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
973 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
974 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
975 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
976 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
977 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
978 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
979 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
980 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
981 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
982 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
983 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
984 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
985 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
986 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
987 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
988 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
989 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
990 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
991 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
992 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
993 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
994 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
995 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
996 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
997 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
998 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
999 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1000 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1001 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1002 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1003 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1004 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1005 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1006 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1007 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1008 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1009 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1010 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1011 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1012 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1013 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1017 static uint8_t ms_hmac_key0[] = {
1018 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1019 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1020 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1021 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1022 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1023 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1024 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1025 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1028 static const uint8_t ms_hmac_digest0[] = {
1029 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1030 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1031 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1032 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1033 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1034 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1035 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1036 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1040 /* Begin session 1 */
1042 static uint8_t ms_aes_cbc_key1[] = {
1043 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1044 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1047 static uint8_t ms_aes_cbc_iv1[] = {
1048 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1049 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1052 static const uint8_t ms_aes_cbc_cipher1[] = {
1053 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1054 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1055 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1056 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1057 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1058 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1059 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1060 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1061 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1062 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1063 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1064 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1065 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1066 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1067 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1068 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1069 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1070 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1071 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1072 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1073 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1074 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1075 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1076 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1077 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1078 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1079 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1080 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1081 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1082 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1083 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1084 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1085 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1086 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1087 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1088 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1089 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1090 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1091 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1092 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1093 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1094 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1095 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1096 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1097 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1098 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1099 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1100 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1101 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1102 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1103 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1104 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1105 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1106 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1107 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1108 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1109 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1110 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1111 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1112 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1113 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1114 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1115 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1116 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1120 static uint8_t ms_hmac_key1[] = {
1121 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1122 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1123 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1124 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1125 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1126 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1127 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1128 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1131 static const uint8_t ms_hmac_digest1[] = {
1132 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1133 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1134 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1135 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1136 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1137 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1138 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1139 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1142 /* Begin Session 2 */
1143 static uint8_t ms_aes_cbc_key2[] = {
1144 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1145 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1148 static uint8_t ms_aes_cbc_iv2[] = {
1149 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1150 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1153 static const uint8_t ms_aes_cbc_cipher2[] = {
1154 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1155 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1156 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1157 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1158 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1159 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1160 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1161 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1162 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1163 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1164 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1165 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1166 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1167 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1168 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1169 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1170 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1171 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1172 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1173 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1174 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1175 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1176 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1177 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1178 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1179 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1180 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1181 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1182 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1183 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1184 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1185 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1186 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1187 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1188 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1189 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1190 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1191 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1192 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1193 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1194 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1195 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1196 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1197 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1198 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1199 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1200 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1201 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1202 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1203 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1204 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1205 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1206 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1207 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1208 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1209 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1210 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1211 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1212 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1213 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1214 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1215 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1216 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1217 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1220 static uint8_t ms_hmac_key2[] = {
1221 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1222 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1223 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1224 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1225 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1226 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1227 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1228 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1231 static const uint8_t ms_hmac_digest2[] = {
1232 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1233 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1234 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1235 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1236 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1237 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1238 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1239 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1246 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1248 struct crypto_testsuite_params *ts_params = &testsuite_params;
1249 struct crypto_unittest_params *ut_params = &unittest_params;
1251 /* Generate test mbuf data and space for digest */
1252 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1253 catch_22_quote, QUOTE_512_BYTES, 0);
1255 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1256 DIGEST_BYTE_LENGTH_SHA1);
1257 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1259 /* Setup Cipher Parameters */
1260 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1261 ut_params->cipher_xform.next = &ut_params->auth_xform;
1263 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1264 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1265 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1266 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1267 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1268 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1270 /* Setup HMAC Parameters */
1271 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1273 ut_params->auth_xform.next = NULL;
1275 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1276 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1277 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1278 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1279 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1281 ut_params->sess = rte_cryptodev_sym_session_create(
1282 ts_params->session_mpool);
1284 /* Create crypto session*/
1285 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1286 ut_params->sess, &ut_params->cipher_xform,
1287 ts_params->session_mpool);
1288 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1290 /* Generate crypto op data structure */
1291 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1292 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1293 TEST_ASSERT_NOT_NULL(ut_params->op,
1294 "Failed to allocate symmetric crypto operation struct");
1296 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1298 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1300 /* set crypto operation source mbuf */
1301 sym_op->m_src = ut_params->ibuf;
1303 /* Set crypto operation authentication parameters */
1304 sym_op->auth.digest.data = ut_params->digest;
1305 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1306 ut_params->ibuf, QUOTE_512_BYTES);
1308 sym_op->auth.data.offset = 0;
1309 sym_op->auth.data.length = QUOTE_512_BYTES;
1311 /* Copy IV at the end of the crypto operation */
1312 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1313 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1315 /* Set crypto operation cipher parameters */
1316 sym_op->cipher.data.offset = 0;
1317 sym_op->cipher.data.length = QUOTE_512_BYTES;
1319 /* Process crypto operation */
1320 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1321 ut_params->op), "failed to process sym crypto op");
1323 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1324 "crypto op processing failed");
1327 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1330 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1331 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1333 "ciphertext data not as expected");
1335 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1337 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1338 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1339 gbl_driver_id == rte_cryptodev_driver_id_get(
1340 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1341 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1342 DIGEST_BYTE_LENGTH_SHA1,
1343 "Generated digest data not as expected");
1345 return TEST_SUCCESS;
1348 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1350 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1352 static uint8_t hmac_sha512_key[] = {
1353 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1354 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1355 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1356 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1357 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1358 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1359 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1360 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1362 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1363 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1364 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1365 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1366 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1367 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1368 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1369 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1370 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1375 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1376 struct crypto_unittest_params *ut_params,
1377 uint8_t *cipher_key,
1381 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1382 struct crypto_unittest_params *ut_params,
1383 struct crypto_testsuite_params *ts_params,
1384 const uint8_t *cipher,
1385 const uint8_t *digest,
1390 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1391 struct crypto_unittest_params *ut_params,
1392 uint8_t *cipher_key,
1396 /* Setup Cipher Parameters */
1397 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1398 ut_params->cipher_xform.next = NULL;
1400 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1401 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1402 ut_params->cipher_xform.cipher.key.data = cipher_key;
1403 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1404 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1405 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1407 /* Setup HMAC Parameters */
1408 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1409 ut_params->auth_xform.next = &ut_params->cipher_xform;
1411 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1412 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1413 ut_params->auth_xform.auth.key.data = hmac_key;
1414 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1415 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1417 return TEST_SUCCESS;
1422 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1423 struct crypto_unittest_params *ut_params,
1424 struct crypto_testsuite_params *ts_params,
1425 const uint8_t *cipher,
1426 const uint8_t *digest,
1429 /* Generate test mbuf data and digest */
1430 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1433 QUOTE_512_BYTES, 0);
1435 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1436 DIGEST_BYTE_LENGTH_SHA512);
1437 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1439 rte_memcpy(ut_params->digest,
1441 DIGEST_BYTE_LENGTH_SHA512);
1443 /* Generate Crypto op data structure */
1444 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1445 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1446 TEST_ASSERT_NOT_NULL(ut_params->op,
1447 "Failed to allocate symmetric crypto operation struct");
1449 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1451 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1453 /* set crypto operation source mbuf */
1454 sym_op->m_src = ut_params->ibuf;
1456 sym_op->auth.digest.data = ut_params->digest;
1457 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1458 ut_params->ibuf, QUOTE_512_BYTES);
1460 sym_op->auth.data.offset = 0;
1461 sym_op->auth.data.length = QUOTE_512_BYTES;
1463 /* Copy IV at the end of the crypto operation */
1464 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1465 iv, CIPHER_IV_LENGTH_AES_CBC);
1467 sym_op->cipher.data.offset = 0;
1468 sym_op->cipher.data.length = QUOTE_512_BYTES;
1470 /* Process crypto operation */
1471 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1472 ut_params->op), "failed to process sym crypto op");
1474 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1475 "crypto op processing failed");
1477 ut_params->obuf = ut_params->op->sym->m_src;
1480 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1481 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1484 "Plaintext data not as expected");
1487 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1488 "Digest verification failed");
1490 return TEST_SUCCESS;
1494 test_AES_cipheronly_mb_all(void)
1496 struct crypto_testsuite_params *ts_params = &testsuite_params;
1499 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1500 ts_params->op_mpool,
1501 ts_params->session_mpool,
1502 ts_params->valid_devs[0],
1503 rte_cryptodev_driver_id_get(
1504 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1505 BLKCIPHER_AES_CIPHERONLY_TYPE);
1507 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1509 return TEST_SUCCESS;
1513 test_AES_docsis_mb_all(void)
1515 struct crypto_testsuite_params *ts_params = &testsuite_params;
1518 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1519 ts_params->op_mpool,
1520 ts_params->session_mpool,
1521 ts_params->valid_devs[0],
1522 rte_cryptodev_driver_id_get(
1523 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1524 BLKCIPHER_AES_DOCSIS_TYPE);
1526 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1528 return TEST_SUCCESS;
1532 test_AES_docsis_qat_all(void)
1534 struct crypto_testsuite_params *ts_params = &testsuite_params;
1537 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1538 ts_params->op_mpool,
1539 ts_params->session_mpool,
1540 ts_params->valid_devs[0],
1541 rte_cryptodev_driver_id_get(
1542 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1543 BLKCIPHER_AES_DOCSIS_TYPE);
1545 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1547 return TEST_SUCCESS;
1551 test_DES_docsis_qat_all(void)
1553 struct crypto_testsuite_params *ts_params = &testsuite_params;
1556 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1557 ts_params->op_mpool,
1558 ts_params->session_mpool,
1559 ts_params->valid_devs[0],
1560 rte_cryptodev_driver_id_get(
1561 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1562 BLKCIPHER_DES_DOCSIS_TYPE);
1564 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1566 return TEST_SUCCESS;
1570 test_authonly_mb_all(void)
1572 struct crypto_testsuite_params *ts_params = &testsuite_params;
1575 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1576 ts_params->op_mpool,
1577 ts_params->session_mpool,
1578 ts_params->valid_devs[0],
1579 rte_cryptodev_driver_id_get(
1580 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1581 BLKCIPHER_AUTHONLY_TYPE);
1583 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1585 return TEST_SUCCESS;
1589 test_AES_chain_mb_all(void)
1591 struct crypto_testsuite_params *ts_params = &testsuite_params;
1594 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1595 ts_params->op_mpool,
1596 ts_params->session_mpool,
1597 ts_params->valid_devs[0],
1598 rte_cryptodev_driver_id_get(
1599 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1600 BLKCIPHER_AES_CHAIN_TYPE);
1602 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1604 return TEST_SUCCESS;
1607 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1610 test_AES_cipheronly_scheduler_all(void)
1612 struct crypto_testsuite_params *ts_params = &testsuite_params;
1615 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1616 ts_params->op_mpool,
1617 ts_params->session_mpool,
1618 ts_params->valid_devs[0],
1619 rte_cryptodev_driver_id_get(
1620 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1621 BLKCIPHER_AES_CIPHERONLY_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1629 test_AES_chain_scheduler_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool,
1636 ts_params->session_mpool,
1637 ts_params->valid_devs[0],
1638 rte_cryptodev_driver_id_get(
1639 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1640 BLKCIPHER_AES_CHAIN_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1648 test_authonly_scheduler_all(void)
1650 struct crypto_testsuite_params *ts_params = &testsuite_params;
1653 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1654 ts_params->op_mpool,
1655 ts_params->session_mpool,
1656 ts_params->valid_devs[0],
1657 rte_cryptodev_driver_id_get(
1658 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1659 BLKCIPHER_AUTHONLY_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1666 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1669 test_AES_chain_openssl_all(void)
1671 struct crypto_testsuite_params *ts_params = &testsuite_params;
1674 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1675 ts_params->op_mpool,
1676 ts_params->session_mpool,
1677 ts_params->valid_devs[0],
1678 rte_cryptodev_driver_id_get(
1679 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1680 BLKCIPHER_AES_CHAIN_TYPE);
1682 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1684 return TEST_SUCCESS;
1688 test_AES_cipheronly_openssl_all(void)
1690 struct crypto_testsuite_params *ts_params = &testsuite_params;
1693 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1694 ts_params->op_mpool,
1695 ts_params->session_mpool,
1696 ts_params->valid_devs[0],
1697 rte_cryptodev_driver_id_get(
1698 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1699 BLKCIPHER_AES_CIPHERONLY_TYPE);
1701 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1703 return TEST_SUCCESS;
1707 test_AES_chain_qat_all(void)
1709 struct crypto_testsuite_params *ts_params = &testsuite_params;
1712 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1713 ts_params->op_mpool,
1714 ts_params->session_mpool,
1715 ts_params->valid_devs[0],
1716 rte_cryptodev_driver_id_get(
1717 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1718 BLKCIPHER_AES_CHAIN_TYPE);
1720 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1722 return TEST_SUCCESS;
1726 test_AES_cipheronly_qat_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,
1733 ts_params->session_mpool,
1734 ts_params->valid_devs[0],
1735 rte_cryptodev_driver_id_get(
1736 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1737 BLKCIPHER_AES_CIPHERONLY_TYPE);
1739 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1741 return TEST_SUCCESS;
1745 test_AES_chain_dpaa2_sec_all(void)
1747 struct crypto_testsuite_params *ts_params = &testsuite_params;
1750 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1751 ts_params->op_mpool,
1752 ts_params->session_mpool,
1753 ts_params->valid_devs[0],
1754 rte_cryptodev_driver_id_get(
1755 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1756 BLKCIPHER_AES_CHAIN_TYPE);
1758 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1760 return TEST_SUCCESS;
1764 test_AES_cipheronly_dpaa2_sec_all(void)
1766 struct crypto_testsuite_params *ts_params = &testsuite_params;
1769 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1770 ts_params->op_mpool,
1771 ts_params->session_mpool,
1772 ts_params->valid_devs[0],
1773 rte_cryptodev_driver_id_get(
1774 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1775 BLKCIPHER_AES_CIPHERONLY_TYPE);
1777 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1779 return TEST_SUCCESS;
1783 test_authonly_dpaa2_sec_all(void)
1785 struct crypto_testsuite_params *ts_params = &testsuite_params;
1788 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1789 ts_params->op_mpool,
1790 ts_params->session_mpool,
1791 ts_params->valid_devs[0],
1792 rte_cryptodev_driver_id_get(
1793 RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
1794 BLKCIPHER_AUTHONLY_TYPE);
1796 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1798 return TEST_SUCCESS;
1802 test_authonly_openssl_all(void)
1804 struct crypto_testsuite_params *ts_params = &testsuite_params;
1807 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1808 ts_params->op_mpool,
1809 ts_params->session_mpool,
1810 ts_params->valid_devs[0],
1811 rte_cryptodev_driver_id_get(
1812 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1813 BLKCIPHER_AUTHONLY_TYPE);
1815 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1817 return TEST_SUCCESS;
1821 test_AES_chain_armv8_all(void)
1823 struct crypto_testsuite_params *ts_params = &testsuite_params;
1826 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1827 ts_params->op_mpool,
1828 ts_params->session_mpool,
1829 ts_params->valid_devs[0],
1830 rte_cryptodev_driver_id_get(
1831 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1832 BLKCIPHER_AES_CHAIN_TYPE);
1834 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1836 return TEST_SUCCESS;
1839 /* ***** SNOW 3G Tests ***** */
1841 create_wireless_algo_hash_session(uint8_t dev_id,
1842 const uint8_t *key, const uint8_t key_len,
1843 const uint8_t iv_len, const uint8_t auth_len,
1844 enum rte_crypto_auth_operation op,
1845 enum rte_crypto_auth_algorithm algo)
1847 uint8_t hash_key[key_len];
1849 struct crypto_testsuite_params *ts_params = &testsuite_params;
1850 struct crypto_unittest_params *ut_params = &unittest_params;
1852 memcpy(hash_key, key, key_len);
1854 TEST_HEXDUMP(stdout, "key:", key, key_len);
1856 /* Setup Authentication Parameters */
1857 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1858 ut_params->auth_xform.next = NULL;
1860 ut_params->auth_xform.auth.op = op;
1861 ut_params->auth_xform.auth.algo = algo;
1862 ut_params->auth_xform.auth.key.length = key_len;
1863 ut_params->auth_xform.auth.key.data = hash_key;
1864 ut_params->auth_xform.auth.digest_length = auth_len;
1865 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1866 ut_params->auth_xform.auth.iv.length = iv_len;
1867 ut_params->sess = rte_cryptodev_sym_session_create(
1868 ts_params->session_mpool);
1870 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1871 &ut_params->auth_xform, ts_params->session_mpool);
1872 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1877 create_wireless_algo_cipher_session(uint8_t dev_id,
1878 enum rte_crypto_cipher_operation op,
1879 enum rte_crypto_cipher_algorithm algo,
1880 const uint8_t *key, const uint8_t key_len,
1883 uint8_t cipher_key[key_len];
1885 struct crypto_testsuite_params *ts_params = &testsuite_params;
1886 struct crypto_unittest_params *ut_params = &unittest_params;
1888 memcpy(cipher_key, key, key_len);
1890 /* Setup Cipher Parameters */
1891 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1892 ut_params->cipher_xform.next = NULL;
1894 ut_params->cipher_xform.cipher.algo = algo;
1895 ut_params->cipher_xform.cipher.op = op;
1896 ut_params->cipher_xform.cipher.key.data = cipher_key;
1897 ut_params->cipher_xform.cipher.key.length = key_len;
1898 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1899 ut_params->cipher_xform.cipher.iv.length = iv_len;
1901 TEST_HEXDUMP(stdout, "key:", key, key_len);
1903 /* Create Crypto session */
1904 ut_params->sess = rte_cryptodev_sym_session_create(
1905 ts_params->session_mpool);
1907 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1908 &ut_params->cipher_xform, ts_params->session_mpool);
1909 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1914 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1915 unsigned int cipher_len,
1916 unsigned int cipher_offset)
1918 struct crypto_testsuite_params *ts_params = &testsuite_params;
1919 struct crypto_unittest_params *ut_params = &unittest_params;
1921 /* Generate Crypto op data structure */
1922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1923 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1924 TEST_ASSERT_NOT_NULL(ut_params->op,
1925 "Failed to allocate pktmbuf offload");
1927 /* Set crypto operation data parameters */
1928 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1930 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1932 /* set crypto operation source mbuf */
1933 sym_op->m_src = ut_params->ibuf;
1936 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1938 sym_op->cipher.data.length = cipher_len;
1939 sym_op->cipher.data.offset = cipher_offset;
1944 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1945 unsigned int cipher_len,
1946 unsigned int cipher_offset)
1948 struct crypto_testsuite_params *ts_params = &testsuite_params;
1949 struct crypto_unittest_params *ut_params = &unittest_params;
1951 /* Generate Crypto op data structure */
1952 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1953 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1954 TEST_ASSERT_NOT_NULL(ut_params->op,
1955 "Failed to allocate pktmbuf offload");
1957 /* Set crypto operation data parameters */
1958 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1960 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1962 /* set crypto operation source mbuf */
1963 sym_op->m_src = ut_params->ibuf;
1964 sym_op->m_dst = ut_params->obuf;
1967 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1969 sym_op->cipher.data.length = cipher_len;
1970 sym_op->cipher.data.offset = cipher_offset;
1975 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1976 enum rte_crypto_cipher_operation cipher_op,
1977 enum rte_crypto_auth_operation auth_op,
1978 enum rte_crypto_auth_algorithm auth_algo,
1979 enum rte_crypto_cipher_algorithm cipher_algo,
1980 const uint8_t *key, uint8_t key_len,
1981 uint8_t auth_iv_len, uint8_t auth_len,
1982 uint8_t cipher_iv_len)
1985 uint8_t cipher_auth_key[key_len];
1987 struct crypto_testsuite_params *ts_params = &testsuite_params;
1988 struct crypto_unittest_params *ut_params = &unittest_params;
1990 memcpy(cipher_auth_key, key, key_len);
1992 /* Setup Authentication Parameters */
1993 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1994 ut_params->auth_xform.next = NULL;
1996 ut_params->auth_xform.auth.op = auth_op;
1997 ut_params->auth_xform.auth.algo = auth_algo;
1998 ut_params->auth_xform.auth.key.length = key_len;
1999 /* Hash key = cipher key */
2000 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2001 ut_params->auth_xform.auth.digest_length = auth_len;
2002 /* Auth IV will be after cipher IV */
2003 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2004 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2006 /* Setup Cipher Parameters */
2007 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2008 ut_params->cipher_xform.next = &ut_params->auth_xform;
2010 ut_params->cipher_xform.cipher.algo = cipher_algo;
2011 ut_params->cipher_xform.cipher.op = cipher_op;
2012 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2013 ut_params->cipher_xform.cipher.key.length = key_len;
2014 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2015 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2017 TEST_HEXDUMP(stdout, "key:", key, key_len);
2019 /* Create Crypto session*/
2020 ut_params->sess = rte_cryptodev_sym_session_create(
2021 ts_params->session_mpool);
2023 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2024 &ut_params->cipher_xform, ts_params->session_mpool);
2026 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2031 create_wireless_cipher_auth_session(uint8_t dev_id,
2032 enum rte_crypto_cipher_operation cipher_op,
2033 enum rte_crypto_auth_operation auth_op,
2034 enum rte_crypto_auth_algorithm auth_algo,
2035 enum rte_crypto_cipher_algorithm cipher_algo,
2036 const struct wireless_test_data *tdata)
2038 const uint8_t key_len = tdata->key.len;
2039 uint8_t cipher_auth_key[key_len];
2041 struct crypto_testsuite_params *ts_params = &testsuite_params;
2042 struct crypto_unittest_params *ut_params = &unittest_params;
2043 const uint8_t *key = tdata->key.data;
2044 const uint8_t auth_len = tdata->digest.len;
2045 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2046 uint8_t auth_iv_len = tdata->auth_iv.len;
2048 memcpy(cipher_auth_key, key, key_len);
2050 /* Setup Authentication Parameters */
2051 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2052 ut_params->auth_xform.next = NULL;
2054 ut_params->auth_xform.auth.op = auth_op;
2055 ut_params->auth_xform.auth.algo = auth_algo;
2056 ut_params->auth_xform.auth.key.length = key_len;
2057 /* Hash key = cipher key */
2058 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2059 ut_params->auth_xform.auth.digest_length = auth_len;
2060 /* Auth IV will be after cipher IV */
2061 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2062 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2064 /* Setup Cipher Parameters */
2065 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2066 ut_params->cipher_xform.next = &ut_params->auth_xform;
2068 ut_params->cipher_xform.cipher.algo = cipher_algo;
2069 ut_params->cipher_xform.cipher.op = cipher_op;
2070 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2071 ut_params->cipher_xform.cipher.key.length = key_len;
2072 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2073 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2076 TEST_HEXDUMP(stdout, "key:", key, key_len);
2078 /* Create Crypto session*/
2079 ut_params->sess = rte_cryptodev_sym_session_create(
2080 ts_params->session_mpool);
2082 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2083 &ut_params->cipher_xform, ts_params->session_mpool);
2085 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2090 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2091 const struct wireless_test_data *tdata)
2093 return create_wireless_cipher_auth_session(dev_id,
2094 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2095 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2096 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2100 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2101 enum rte_crypto_cipher_operation cipher_op,
2102 enum rte_crypto_auth_operation auth_op,
2103 enum rte_crypto_auth_algorithm auth_algo,
2104 enum rte_crypto_cipher_algorithm cipher_algo,
2105 const uint8_t *key, const uint8_t key_len,
2106 uint8_t auth_iv_len, uint8_t auth_len,
2107 uint8_t cipher_iv_len)
2109 uint8_t auth_cipher_key[key_len];
2111 struct crypto_testsuite_params *ts_params = &testsuite_params;
2112 struct crypto_unittest_params *ut_params = &unittest_params;
2114 memcpy(auth_cipher_key, key, key_len);
2116 /* Setup Authentication Parameters */
2117 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2118 ut_params->auth_xform.auth.op = auth_op;
2119 ut_params->auth_xform.next = &ut_params->cipher_xform;
2120 ut_params->auth_xform.auth.algo = auth_algo;
2121 ut_params->auth_xform.auth.key.length = key_len;
2122 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2123 ut_params->auth_xform.auth.digest_length = auth_len;
2124 /* Auth IV will be after cipher IV */
2125 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2126 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2128 /* Setup Cipher Parameters */
2129 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2130 ut_params->cipher_xform.next = NULL;
2131 ut_params->cipher_xform.cipher.algo = cipher_algo;
2132 ut_params->cipher_xform.cipher.op = cipher_op;
2133 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2134 ut_params->cipher_xform.cipher.key.length = key_len;
2135 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2136 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2138 TEST_HEXDUMP(stdout, "key:", key, key_len);
2140 /* Create Crypto session*/
2141 ut_params->sess = rte_cryptodev_sym_session_create(
2142 ts_params->session_mpool);
2144 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2145 &ut_params->auth_xform, ts_params->session_mpool);
2147 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2153 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2154 unsigned int auth_tag_len,
2155 const uint8_t *iv, unsigned int iv_len,
2156 unsigned int data_pad_len,
2157 enum rte_crypto_auth_operation op,
2158 unsigned int auth_len, unsigned int auth_offset)
2160 struct crypto_testsuite_params *ts_params = &testsuite_params;
2162 struct crypto_unittest_params *ut_params = &unittest_params;
2164 /* Generate Crypto op data structure */
2165 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2166 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2167 TEST_ASSERT_NOT_NULL(ut_params->op,
2168 "Failed to allocate pktmbuf offload");
2170 /* Set crypto operation data parameters */
2171 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2173 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2175 /* set crypto operation source mbuf */
2176 sym_op->m_src = ut_params->ibuf;
2179 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2182 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2183 ut_params->ibuf, auth_tag_len);
2185 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2186 "no room to append auth tag");
2187 ut_params->digest = sym_op->auth.digest.data;
2188 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2189 ut_params->ibuf, data_pad_len);
2190 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2191 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2193 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2195 TEST_HEXDUMP(stdout, "digest:",
2196 sym_op->auth.digest.data,
2199 sym_op->auth.data.length = auth_len;
2200 sym_op->auth.data.offset = auth_offset;
2206 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2207 enum rte_crypto_auth_operation op)
2209 struct crypto_testsuite_params *ts_params = &testsuite_params;
2210 struct crypto_unittest_params *ut_params = &unittest_params;
2212 const uint8_t *auth_tag = tdata->digest.data;
2213 const unsigned int auth_tag_len = tdata->digest.len;
2214 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2215 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2217 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2218 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2219 const uint8_t *auth_iv = tdata->auth_iv.data;
2220 const uint8_t auth_iv_len = tdata->auth_iv.len;
2221 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2222 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2224 /* Generate Crypto op data structure */
2225 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2226 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2227 TEST_ASSERT_NOT_NULL(ut_params->op,
2228 "Failed to allocate pktmbuf offload");
2229 /* Set crypto operation data parameters */
2230 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2232 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2234 /* set crypto operation source mbuf */
2235 sym_op->m_src = ut_params->ibuf;
2238 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2239 ut_params->ibuf, auth_tag_len);
2241 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2242 "no room to append auth tag");
2243 ut_params->digest = sym_op->auth.digest.data;
2244 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2245 ut_params->ibuf, data_pad_len);
2246 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2247 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2249 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2251 TEST_HEXDUMP(stdout, "digest:",
2252 sym_op->auth.digest.data,
2255 /* Copy cipher and auth IVs at the end of the crypto operation */
2256 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2258 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2259 iv_ptr += cipher_iv_len;
2260 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2262 sym_op->cipher.data.length = cipher_len;
2263 sym_op->cipher.data.offset = 0;
2264 sym_op->auth.data.length = auth_len;
2265 sym_op->auth.data.offset = 0;
2271 create_zuc_cipher_hash_generate_operation(
2272 const struct wireless_test_data *tdata)
2274 return create_wireless_cipher_hash_operation(tdata,
2275 RTE_CRYPTO_AUTH_OP_GENERATE);
2279 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2280 const unsigned auth_tag_len,
2281 const uint8_t *auth_iv, uint8_t auth_iv_len,
2282 unsigned data_pad_len,
2283 enum rte_crypto_auth_operation op,
2284 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2285 const unsigned cipher_len, const unsigned cipher_offset,
2286 const unsigned auth_len, const unsigned auth_offset)
2288 struct crypto_testsuite_params *ts_params = &testsuite_params;
2289 struct crypto_unittest_params *ut_params = &unittest_params;
2291 /* Generate Crypto op data structure */
2292 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2293 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2294 TEST_ASSERT_NOT_NULL(ut_params->op,
2295 "Failed to allocate pktmbuf offload");
2296 /* Set crypto operation data parameters */
2297 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2299 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2301 /* set crypto operation source mbuf */
2302 sym_op->m_src = ut_params->ibuf;
2305 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2306 ut_params->ibuf, auth_tag_len);
2308 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2309 "no room to append auth tag");
2310 ut_params->digest = sym_op->auth.digest.data;
2311 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2312 ut_params->ibuf, data_pad_len);
2313 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2314 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2316 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2318 TEST_HEXDUMP(stdout, "digest:",
2319 sym_op->auth.digest.data,
2322 /* Copy cipher and auth IVs at the end of the crypto operation */
2323 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2325 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2326 iv_ptr += cipher_iv_len;
2327 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2329 sym_op->cipher.data.length = cipher_len;
2330 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2331 sym_op->auth.data.length = auth_len;
2332 sym_op->auth.data.offset = auth_offset + cipher_offset;
2338 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2339 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2340 const uint8_t *auth_iv, uint8_t auth_iv_len,
2341 unsigned int data_pad_len,
2342 unsigned int cipher_len, unsigned int cipher_offset,
2343 unsigned int auth_len, unsigned int auth_offset)
2345 struct crypto_testsuite_params *ts_params = &testsuite_params;
2346 struct crypto_unittest_params *ut_params = &unittest_params;
2348 /* Generate Crypto op data structure */
2349 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2350 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2351 TEST_ASSERT_NOT_NULL(ut_params->op,
2352 "Failed to allocate pktmbuf offload");
2354 /* Set crypto operation data parameters */
2355 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2357 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2359 /* set crypto operation source mbuf */
2360 sym_op->m_src = ut_params->ibuf;
2363 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2364 ut_params->ibuf, auth_tag_len);
2366 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2367 "no room to append auth tag");
2369 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2370 ut_params->ibuf, data_pad_len);
2372 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2374 TEST_HEXDUMP(stdout, "digest:",
2375 sym_op->auth.digest.data,
2378 /* Copy cipher and auth IVs at the end of the crypto operation */
2379 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2381 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2382 iv_ptr += cipher_iv_len;
2383 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2385 sym_op->cipher.data.length = cipher_len;
2386 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2388 sym_op->auth.data.length = auth_len;
2389 sym_op->auth.data.offset = auth_offset + cipher_offset;
2395 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2397 struct crypto_testsuite_params *ts_params = &testsuite_params;
2398 struct crypto_unittest_params *ut_params = &unittest_params;
2401 unsigned plaintext_pad_len;
2402 unsigned plaintext_len;
2405 /* Create SNOW 3G session */
2406 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2407 tdata->key.data, tdata->key.len,
2408 tdata->auth_iv.len, tdata->digest.len,
2409 RTE_CRYPTO_AUTH_OP_GENERATE,
2410 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2414 /* alloc mbuf and set payload */
2415 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2417 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2418 rte_pktmbuf_tailroom(ut_params->ibuf));
2420 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2421 /* Append data which is padded to a multiple of */
2422 /* the algorithms block size */
2423 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2424 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2426 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2428 /* Create SNOW 3G operation */
2429 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2430 tdata->auth_iv.data, tdata->auth_iv.len,
2431 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2432 tdata->validAuthLenInBits.len,
2437 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2439 ut_params->obuf = ut_params->op->sym->m_src;
2440 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2441 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2442 + plaintext_pad_len;
2445 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2448 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2449 "SNOW 3G Generated auth tag not as expected");
2455 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2461 unsigned plaintext_pad_len;
2462 unsigned plaintext_len;
2465 /* Create SNOW 3G session */
2466 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2467 tdata->key.data, tdata->key.len,
2468 tdata->auth_iv.len, tdata->digest.len,
2469 RTE_CRYPTO_AUTH_OP_VERIFY,
2470 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2473 /* alloc mbuf and set payload */
2474 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2476 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2477 rte_pktmbuf_tailroom(ut_params->ibuf));
2479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2480 /* Append data which is padded to a multiple of */
2481 /* the algorithms block size */
2482 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2483 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2485 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2487 /* Create SNOW 3G operation */
2488 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2490 tdata->auth_iv.data, tdata->auth_iv.len,
2492 RTE_CRYPTO_AUTH_OP_VERIFY,
2493 tdata->validAuthLenInBits.len,
2498 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2500 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2501 ut_params->obuf = ut_params->op->sym->m_src;
2502 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2503 + plaintext_pad_len;
2506 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2515 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2517 struct crypto_testsuite_params *ts_params = &testsuite_params;
2518 struct crypto_unittest_params *ut_params = &unittest_params;
2521 unsigned plaintext_pad_len;
2522 unsigned plaintext_len;
2525 /* Create KASUMI session */
2526 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2527 tdata->key.data, tdata->key.len,
2528 tdata->auth_iv.len, tdata->digest.len,
2529 RTE_CRYPTO_AUTH_OP_GENERATE,
2530 RTE_CRYPTO_AUTH_KASUMI_F9);
2534 /* alloc mbuf and set payload */
2535 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2537 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2538 rte_pktmbuf_tailroom(ut_params->ibuf));
2540 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2541 /* Append data which is padded to a multiple of */
2542 /* the algorithms block size */
2543 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2544 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2546 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2548 /* Create KASUMI operation */
2549 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2550 tdata->auth_iv.data, tdata->auth_iv.len,
2551 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2552 tdata->validAuthLenInBits.len,
2557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2559 ut_params->obuf = ut_params->op->sym->m_src;
2560 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2561 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2562 + plaintext_pad_len;
2565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2568 DIGEST_BYTE_LENGTH_KASUMI_F9,
2569 "KASUMI Generated auth tag not as expected");
2575 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2577 struct crypto_testsuite_params *ts_params = &testsuite_params;
2578 struct crypto_unittest_params *ut_params = &unittest_params;
2581 unsigned plaintext_pad_len;
2582 unsigned plaintext_len;
2585 /* Create KASUMI session */
2586 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2587 tdata->key.data, tdata->key.len,
2588 tdata->auth_iv.len, tdata->digest.len,
2589 RTE_CRYPTO_AUTH_OP_VERIFY,
2590 RTE_CRYPTO_AUTH_KASUMI_F9);
2593 /* alloc mbuf and set payload */
2594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2596 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2597 rte_pktmbuf_tailroom(ut_params->ibuf));
2599 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2600 /* Append data which is padded to a multiple */
2601 /* of the algorithms block size */
2602 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2603 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2605 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2607 /* Create KASUMI operation */
2608 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2610 tdata->auth_iv.data, tdata->auth_iv.len,
2612 RTE_CRYPTO_AUTH_OP_VERIFY,
2613 tdata->validAuthLenInBits.len,
2618 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2620 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2621 ut_params->obuf = ut_params->op->sym->m_src;
2622 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2623 + plaintext_pad_len;
2626 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2635 test_snow3g_hash_generate_test_case_1(void)
2637 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2641 test_snow3g_hash_generate_test_case_2(void)
2643 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2647 test_snow3g_hash_generate_test_case_3(void)
2649 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2653 test_snow3g_hash_generate_test_case_4(void)
2655 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2659 test_snow3g_hash_generate_test_case_5(void)
2661 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2665 test_snow3g_hash_generate_test_case_6(void)
2667 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2671 test_snow3g_hash_verify_test_case_1(void)
2673 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2678 test_snow3g_hash_verify_test_case_2(void)
2680 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2684 test_snow3g_hash_verify_test_case_3(void)
2686 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2690 test_snow3g_hash_verify_test_case_4(void)
2692 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2696 test_snow3g_hash_verify_test_case_5(void)
2698 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2702 test_snow3g_hash_verify_test_case_6(void)
2704 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2708 test_kasumi_hash_generate_test_case_1(void)
2710 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2714 test_kasumi_hash_generate_test_case_2(void)
2716 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2720 test_kasumi_hash_generate_test_case_3(void)
2722 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2726 test_kasumi_hash_generate_test_case_4(void)
2728 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2732 test_kasumi_hash_generate_test_case_5(void)
2734 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2738 test_kasumi_hash_generate_test_case_6(void)
2740 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2744 test_kasumi_hash_verify_test_case_1(void)
2746 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2750 test_kasumi_hash_verify_test_case_2(void)
2752 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2756 test_kasumi_hash_verify_test_case_3(void)
2758 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2762 test_kasumi_hash_verify_test_case_4(void)
2764 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2768 test_kasumi_hash_verify_test_case_5(void)
2770 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2774 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2776 struct crypto_testsuite_params *ts_params = &testsuite_params;
2777 struct crypto_unittest_params *ut_params = &unittest_params;
2780 uint8_t *plaintext, *ciphertext;
2781 unsigned plaintext_pad_len;
2782 unsigned plaintext_len;
2784 /* Create KASUMI session */
2785 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2786 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2787 RTE_CRYPTO_CIPHER_KASUMI_F8,
2788 tdata->key.data, tdata->key.len,
2789 tdata->cipher_iv.len);
2793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2795 /* Clear mbuf payload */
2796 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2797 rte_pktmbuf_tailroom(ut_params->ibuf));
2799 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2800 /* Append data which is padded to a multiple */
2801 /* of the algorithms block size */
2802 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2803 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2805 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2807 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2809 /* Create KASUMI operation */
2810 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2811 tdata->cipher_iv.len,
2812 tdata->plaintext.len,
2817 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2819 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2821 ut_params->obuf = ut_params->op->sym->m_dst;
2822 if (ut_params->obuf)
2823 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2825 ciphertext = plaintext;
2827 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2830 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2832 tdata->ciphertext.data,
2833 tdata->validCipherLenInBits.len,
2834 "KASUMI Ciphertext data not as expected");
2839 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2841 struct crypto_testsuite_params *ts_params = &testsuite_params;
2842 struct crypto_unittest_params *ut_params = &unittest_params;
2846 unsigned int plaintext_pad_len;
2847 unsigned int plaintext_len;
2849 uint8_t buffer[10000];
2850 const uint8_t *ciphertext;
2852 struct rte_cryptodev_info dev_info;
2854 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2855 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2856 printf("Device doesn't support scatter-gather. "
2861 /* Create KASUMI session */
2862 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2863 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2864 RTE_CRYPTO_CIPHER_KASUMI_F8,
2865 tdata->key.data, tdata->key.len,
2866 tdata->cipher_iv.len);
2870 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2873 /* Append data which is padded to a multiple */
2874 /* of the algorithms block size */
2875 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2877 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2878 plaintext_pad_len, 10, 0);
2880 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2882 /* Create KASUMI operation */
2883 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2884 tdata->cipher_iv.len,
2885 tdata->plaintext.len,
2890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2894 ut_params->obuf = ut_params->op->sym->m_dst;
2896 if (ut_params->obuf)
2897 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2898 plaintext_len, buffer);
2900 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2901 plaintext_len, buffer);
2904 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2907 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2909 tdata->ciphertext.data,
2910 tdata->validCipherLenInBits.len,
2911 "KASUMI Ciphertext data not as expected");
2916 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2918 struct crypto_testsuite_params *ts_params = &testsuite_params;
2919 struct crypto_unittest_params *ut_params = &unittest_params;
2922 uint8_t *plaintext, *ciphertext;
2923 unsigned plaintext_pad_len;
2924 unsigned plaintext_len;
2926 /* Create KASUMI session */
2927 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2928 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2929 RTE_CRYPTO_CIPHER_KASUMI_F8,
2930 tdata->key.data, tdata->key.len,
2931 tdata->cipher_iv.len);
2935 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2936 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2938 /* Clear mbuf payload */
2939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2940 rte_pktmbuf_tailroom(ut_params->ibuf));
2942 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2943 /* Append data which is padded to a multiple */
2944 /* of the algorithms block size */
2945 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2946 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2948 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2949 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2951 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2953 /* Create KASUMI operation */
2954 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2955 tdata->cipher_iv.len,
2956 tdata->plaintext.len,
2961 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2963 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2965 ut_params->obuf = ut_params->op->sym->m_dst;
2966 if (ut_params->obuf)
2967 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2969 ciphertext = plaintext;
2971 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2974 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2976 tdata->ciphertext.data,
2977 tdata->validCipherLenInBits.len,
2978 "KASUMI Ciphertext data not as expected");
2983 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2985 struct crypto_testsuite_params *ts_params = &testsuite_params;
2986 struct crypto_unittest_params *ut_params = &unittest_params;
2989 unsigned int plaintext_pad_len;
2990 unsigned int plaintext_len;
2992 const uint8_t *ciphertext;
2993 uint8_t buffer[2048];
2995 struct rte_cryptodev_info dev_info;
2997 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2998 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2999 printf("Device doesn't support scatter-gather. "
3004 /* Create KASUMI session */
3005 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3006 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3007 RTE_CRYPTO_CIPHER_KASUMI_F8,
3008 tdata->key.data, tdata->key.len,
3009 tdata->cipher_iv.len);
3013 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3014 /* Append data which is padded to a multiple */
3015 /* of the algorithms block size */
3016 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3018 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3019 plaintext_pad_len, 10, 0);
3020 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3021 plaintext_pad_len, 3, 0);
3023 /* Append data which is padded to a multiple */
3024 /* of the algorithms block size */
3025 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3027 /* Create KASUMI operation */
3028 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3029 tdata->cipher_iv.len,
3030 tdata->plaintext.len,
3035 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3037 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3039 ut_params->obuf = ut_params->op->sym->m_dst;
3040 if (ut_params->obuf)
3041 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3042 plaintext_pad_len, buffer);
3044 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3045 plaintext_pad_len, buffer);
3048 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3050 tdata->ciphertext.data,
3051 tdata->validCipherLenInBits.len,
3052 "KASUMI Ciphertext data not as expected");
3058 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3060 struct crypto_testsuite_params *ts_params = &testsuite_params;
3061 struct crypto_unittest_params *ut_params = &unittest_params;
3064 uint8_t *ciphertext, *plaintext;
3065 unsigned ciphertext_pad_len;
3066 unsigned ciphertext_len;
3068 /* Create KASUMI session */
3069 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3070 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3071 RTE_CRYPTO_CIPHER_KASUMI_F8,
3072 tdata->key.data, tdata->key.len,
3073 tdata->cipher_iv.len);
3077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3080 /* Clear mbuf payload */
3081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3082 rte_pktmbuf_tailroom(ut_params->ibuf));
3084 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3085 /* Append data which is padded to a multiple */
3086 /* of the algorithms block size */
3087 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3088 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3089 ciphertext_pad_len);
3090 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3091 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3093 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3095 /* Create KASUMI operation */
3096 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3097 tdata->cipher_iv.len,
3098 tdata->ciphertext.len,
3103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3107 ut_params->obuf = ut_params->op->sym->m_dst;
3108 if (ut_params->obuf)
3109 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3111 plaintext = ciphertext;
3113 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3116 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3118 tdata->plaintext.data,
3119 tdata->validCipherLenInBits.len,
3120 "KASUMI Plaintext data not as expected");
3125 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3127 struct crypto_testsuite_params *ts_params = &testsuite_params;
3128 struct crypto_unittest_params *ut_params = &unittest_params;
3131 uint8_t *ciphertext, *plaintext;
3132 unsigned ciphertext_pad_len;
3133 unsigned ciphertext_len;
3135 /* Create KASUMI session */
3136 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3137 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3138 RTE_CRYPTO_CIPHER_KASUMI_F8,
3139 tdata->key.data, tdata->key.len,
3140 tdata->cipher_iv.len);
3144 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3146 /* Clear mbuf payload */
3147 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3148 rte_pktmbuf_tailroom(ut_params->ibuf));
3150 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3151 /* Append data which is padded to a multiple */
3152 /* of the algorithms block size */
3153 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3154 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3155 ciphertext_pad_len);
3156 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3158 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3160 /* Create KASUMI operation */
3161 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3162 tdata->cipher_iv.len,
3163 tdata->ciphertext.len,
3168 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3170 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3172 ut_params->obuf = ut_params->op->sym->m_dst;
3173 if (ut_params->obuf)
3174 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3176 plaintext = ciphertext;
3178 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3181 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3183 tdata->plaintext.data,
3184 tdata->validCipherLenInBits.len,
3185 "KASUMI Plaintext data not as expected");
3190 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3192 struct crypto_testsuite_params *ts_params = &testsuite_params;
3193 struct crypto_unittest_params *ut_params = &unittest_params;
3196 uint8_t *plaintext, *ciphertext;
3197 unsigned plaintext_pad_len;
3198 unsigned plaintext_len;
3200 /* Create SNOW 3G session */
3201 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3202 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3203 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3204 tdata->key.data, tdata->key.len,
3205 tdata->cipher_iv.len);
3209 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3211 /* Clear mbuf payload */
3212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3213 rte_pktmbuf_tailroom(ut_params->ibuf));
3215 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3216 /* Append data which is padded to a multiple of */
3217 /* the algorithms block size */
3218 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3219 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3221 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3223 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3225 /* Create SNOW 3G operation */
3226 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3227 tdata->cipher_iv.len,
3228 tdata->validCipherLenInBits.len,
3233 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3235 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3237 ut_params->obuf = ut_params->op->sym->m_dst;
3238 if (ut_params->obuf)
3239 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3241 ciphertext = plaintext;
3243 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3246 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3248 tdata->ciphertext.data,
3249 tdata->validDataLenInBits.len,
3250 "SNOW 3G Ciphertext data not as expected");
3256 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3258 struct crypto_testsuite_params *ts_params = &testsuite_params;
3259 struct crypto_unittest_params *ut_params = &unittest_params;
3260 uint8_t *plaintext, *ciphertext;
3263 unsigned plaintext_pad_len;
3264 unsigned plaintext_len;
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 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3276 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3278 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3279 "Failed to allocate input buffer in mempool");
3280 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3281 "Failed to allocate output buffer in mempool");
3283 /* Clear mbuf payload */
3284 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3285 rte_pktmbuf_tailroom(ut_params->ibuf));
3287 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3288 /* Append data which is padded to a multiple of */
3289 /* the algorithms block size */
3290 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3291 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3293 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3294 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3296 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3298 /* Create SNOW 3G operation */
3299 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3300 tdata->cipher_iv.len,
3301 tdata->validCipherLenInBits.len,
3306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3308 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3310 ut_params->obuf = ut_params->op->sym->m_dst;
3311 if (ut_params->obuf)
3312 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3314 ciphertext = plaintext;
3316 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3319 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3321 tdata->ciphertext.data,
3322 tdata->validDataLenInBits.len,
3323 "SNOW 3G Ciphertext data not as expected");
3328 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3330 struct crypto_testsuite_params *ts_params = &testsuite_params;
3331 struct crypto_unittest_params *ut_params = &unittest_params;
3334 unsigned int plaintext_pad_len;
3335 unsigned int plaintext_len;
3336 uint8_t buffer[10000];
3337 const uint8_t *ciphertext;
3339 struct rte_cryptodev_info dev_info;
3341 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3342 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3343 printf("Device doesn't support scatter-gather. "
3348 /* Create SNOW 3G session */
3349 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3350 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3351 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3352 tdata->key.data, tdata->key.len,
3353 tdata->cipher_iv.len);
3357 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3358 /* Append data which is padded to a multiple of */
3359 /* the algorithms block size */
3360 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3362 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3363 plaintext_pad_len, 10, 0);
3364 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3365 plaintext_pad_len, 3, 0);
3367 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3368 "Failed to allocate input buffer in mempool");
3369 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3370 "Failed to allocate output buffer in mempool");
3372 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3374 /* Create SNOW 3G operation */
3375 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3376 tdata->cipher_iv.len,
3377 tdata->validCipherLenInBits.len,
3382 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3384 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3386 ut_params->obuf = ut_params->op->sym->m_dst;
3387 if (ut_params->obuf)
3388 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3389 plaintext_len, buffer);
3391 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3392 plaintext_len, buffer);
3394 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3397 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3399 tdata->ciphertext.data,
3400 tdata->validDataLenInBits.len,
3401 "SNOW 3G Ciphertext data not as expected");
3406 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3408 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3410 uint8_t curr_byte, prev_byte;
3411 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3412 uint8_t lower_byte_mask = (1 << offset) - 1;
3415 prev_byte = buffer[0];
3416 buffer[0] >>= offset;
3418 for (i = 1; i < length_in_bytes; i++) {
3419 curr_byte = buffer[i];
3420 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3421 (curr_byte >> offset);
3422 prev_byte = curr_byte;
3427 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3429 struct crypto_testsuite_params *ts_params = &testsuite_params;
3430 struct crypto_unittest_params *ut_params = &unittest_params;
3431 uint8_t *plaintext, *ciphertext;
3433 uint32_t plaintext_len;
3434 uint32_t plaintext_pad_len;
3435 uint8_t extra_offset = 4;
3436 uint8_t *expected_ciphertext_shifted;
3438 /* Create SNOW 3G session */
3439 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3440 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3441 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3442 tdata->key.data, tdata->key.len,
3443 tdata->cipher_iv.len);
3447 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3448 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3450 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3451 "Failed to allocate input buffer in mempool");
3452 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3453 "Failed to allocate output buffer in mempool");
3455 /* Clear mbuf payload */
3456 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3457 rte_pktmbuf_tailroom(ut_params->ibuf));
3459 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3461 * Append data which is padded to a
3462 * multiple of the algorithms block size
3464 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3466 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3469 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3471 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3472 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3474 #ifdef RTE_APP_TEST_DEBUG
3475 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3477 /* Create SNOW 3G operation */
3478 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3479 tdata->cipher_iv.len,
3480 tdata->validCipherLenInBits.len,
3485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3489 ut_params->obuf = ut_params->op->sym->m_dst;
3490 if (ut_params->obuf)
3491 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3493 ciphertext = plaintext;
3495 #ifdef RTE_APP_TEST_DEBUG
3496 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3499 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3501 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3502 "failed to reserve memory for ciphertext shifted\n");
3504 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3505 ceil_byte_length(tdata->ciphertext.len));
3506 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3509 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3511 expected_ciphertext_shifted,
3512 tdata->validDataLenInBits.len,
3514 "SNOW 3G Ciphertext data not as expected");
3518 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3520 struct crypto_testsuite_params *ts_params = &testsuite_params;
3521 struct crypto_unittest_params *ut_params = &unittest_params;
3525 uint8_t *plaintext, *ciphertext;
3526 unsigned ciphertext_pad_len;
3527 unsigned ciphertext_len;
3529 /* Create SNOW 3G session */
3530 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3531 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3532 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3533 tdata->key.data, tdata->key.len,
3534 tdata->cipher_iv.len);
3538 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3540 /* Clear mbuf payload */
3541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3542 rte_pktmbuf_tailroom(ut_params->ibuf));
3544 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3545 /* Append data which is padded to a multiple of */
3546 /* the algorithms block size */
3547 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3548 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3549 ciphertext_pad_len);
3550 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3552 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3554 /* Create SNOW 3G operation */
3555 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3556 tdata->cipher_iv.len,
3557 tdata->validCipherLenInBits.len,
3562 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3564 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3565 ut_params->obuf = ut_params->op->sym->m_dst;
3566 if (ut_params->obuf)
3567 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3569 plaintext = ciphertext;
3571 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3575 tdata->plaintext.data,
3576 tdata->validDataLenInBits.len,
3577 "SNOW 3G Plaintext data not as expected");
3581 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3583 struct crypto_testsuite_params *ts_params = &testsuite_params;
3584 struct crypto_unittest_params *ut_params = &unittest_params;
3588 uint8_t *plaintext, *ciphertext;
3589 unsigned ciphertext_pad_len;
3590 unsigned ciphertext_len;
3592 /* Create SNOW 3G session */
3593 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3594 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3595 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3596 tdata->key.data, tdata->key.len,
3597 tdata->cipher_iv.len);
3601 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3602 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3604 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3605 "Failed to allocate input buffer");
3606 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3607 "Failed to allocate output buffer");
3609 /* Clear mbuf payload */
3610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3611 rte_pktmbuf_tailroom(ut_params->ibuf));
3613 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3614 rte_pktmbuf_tailroom(ut_params->obuf));
3616 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3617 /* Append data which is padded to a multiple of */
3618 /* the algorithms block size */
3619 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3620 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3621 ciphertext_pad_len);
3622 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3623 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3625 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3627 /* Create SNOW 3G operation */
3628 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3629 tdata->cipher_iv.len,
3630 tdata->validCipherLenInBits.len,
3635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3637 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3638 ut_params->obuf = ut_params->op->sym->m_dst;
3639 if (ut_params->obuf)
3640 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3642 plaintext = ciphertext;
3644 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3647 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3648 tdata->plaintext.data,
3649 tdata->validDataLenInBits.len,
3650 "SNOW 3G Plaintext data not as expected");
3655 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3657 struct crypto_testsuite_params *ts_params = &testsuite_params;
3658 struct crypto_unittest_params *ut_params = &unittest_params;
3662 uint8_t *plaintext, *ciphertext;
3663 unsigned int plaintext_pad_len;
3664 unsigned int plaintext_len;
3666 struct rte_cryptodev_sym_capability_idx cap_idx;
3668 /* Check if device supports ZUC EEA3 */
3669 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3670 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3672 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3676 /* Check if device supports ZUC EIA3 */
3677 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3678 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3680 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3684 /* Create ZUC session */
3685 retval = create_zuc_cipher_auth_encrypt_generate_session(
3686 ts_params->valid_devs[0],
3690 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3692 /* clear mbuf payload */
3693 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3694 rte_pktmbuf_tailroom(ut_params->ibuf));
3696 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3697 /* Append data which is padded to a multiple of */
3698 /* the algorithms block size */
3699 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3700 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3702 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3704 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3706 /* Create ZUC operation */
3707 retval = create_zuc_cipher_hash_generate_operation(tdata);
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 "ZUC 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(
3736 "ZUC Generated auth tag not as expected");
3741 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3743 struct crypto_testsuite_params *ts_params = &testsuite_params;
3744 struct crypto_unittest_params *ut_params = &unittest_params;
3748 uint8_t *plaintext, *ciphertext;
3749 unsigned plaintext_pad_len;
3750 unsigned plaintext_len;
3752 /* Create SNOW 3G session */
3753 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3754 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3755 RTE_CRYPTO_AUTH_OP_GENERATE,
3756 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3757 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3758 tdata->key.data, tdata->key.len,
3759 tdata->auth_iv.len, tdata->digest.len,
3760 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_cipher_hash_operation(tdata->digest.data,
3781 tdata->digest.len, tdata->auth_iv.data,
3783 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3784 tdata->cipher_iv.data, tdata->cipher_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 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3804 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3806 tdata->ciphertext.data,
3807 tdata->validDataLenInBits.len,
3808 "SNOW 3G Ciphertext data not as expected");
3810 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3811 + plaintext_pad_len;
3814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3817 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3818 "SNOW 3G Generated auth tag not as expected");
3822 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3824 struct crypto_testsuite_params *ts_params = &testsuite_params;
3825 struct crypto_unittest_params *ut_params = &unittest_params;
3829 uint8_t *plaintext, *ciphertext;
3830 unsigned plaintext_pad_len;
3831 unsigned plaintext_len;
3833 /* Create SNOW 3G session */
3834 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3835 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3836 RTE_CRYPTO_AUTH_OP_GENERATE,
3837 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3838 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3839 tdata->key.data, tdata->key.len,
3840 tdata->auth_iv.len, tdata->digest.len,
3841 tdata->cipher_iv.len);
3845 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3847 /* clear mbuf payload */
3848 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3849 rte_pktmbuf_tailroom(ut_params->ibuf));
3851 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3852 /* Append data which is padded to a multiple of */
3853 /* the algorithms block size */
3854 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3855 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3857 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3859 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3861 /* Create SNOW 3G operation */
3862 retval = create_wireless_algo_auth_cipher_operation(
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,
3875 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3877 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3878 ut_params->obuf = ut_params->op->sym->m_src;
3879 if (ut_params->obuf)
3880 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3882 ciphertext = plaintext;
3884 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3885 + plaintext_pad_len;
3886 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3889 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3891 tdata->ciphertext.data,
3892 tdata->validDataLenInBits.len,
3893 "SNOW 3G Ciphertext data not as expected");
3896 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3899 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3900 "SNOW 3G Generated auth tag not as expected");
3905 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3907 struct crypto_testsuite_params *ts_params = &testsuite_params;
3908 struct crypto_unittest_params *ut_params = &unittest_params;
3912 uint8_t *plaintext, *ciphertext;
3913 unsigned plaintext_pad_len;
3914 unsigned plaintext_len;
3916 /* Create KASUMI session */
3917 retval = create_wireless_algo_auth_cipher_session(
3918 ts_params->valid_devs[0],
3919 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3920 RTE_CRYPTO_AUTH_OP_GENERATE,
3921 RTE_CRYPTO_AUTH_KASUMI_F9,
3922 RTE_CRYPTO_CIPHER_KASUMI_F8,
3923 tdata->key.data, tdata->key.len,
3924 tdata->auth_iv.len, tdata->digest.len,
3925 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_auth_cipher_operation(tdata->digest.len,
3946 tdata->cipher_iv.data, tdata->cipher_iv.len,
3947 tdata->auth_iv.data, tdata->auth_iv.len,
3949 tdata->validCipherLenInBits.len,
3951 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;
3968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3970 tdata->ciphertext.data,
3971 tdata->validCipherLenInBits.len,
3972 "KASUMI Ciphertext data not as expected");
3973 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3974 + plaintext_pad_len;
3977 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3980 DIGEST_BYTE_LENGTH_KASUMI_F9,
3981 "KASUMI Generated auth tag not as expected");
3986 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3988 struct crypto_testsuite_params *ts_params = &testsuite_params;
3989 struct crypto_unittest_params *ut_params = &unittest_params;
3993 uint8_t *plaintext, *ciphertext;
3994 unsigned plaintext_pad_len;
3995 unsigned plaintext_len;
3997 /* Create KASUMI session */
3998 retval = create_wireless_algo_cipher_auth_session(
3999 ts_params->valid_devs[0],
4000 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4001 RTE_CRYPTO_AUTH_OP_GENERATE,
4002 RTE_CRYPTO_AUTH_KASUMI_F9,
4003 RTE_CRYPTO_CIPHER_KASUMI_F8,
4004 tdata->key.data, tdata->key.len,
4005 tdata->auth_iv.len, tdata->digest.len,
4006 tdata->cipher_iv.len);
4010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4012 /* clear mbuf payload */
4013 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4014 rte_pktmbuf_tailroom(ut_params->ibuf));
4016 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4017 /* Append data which is padded to a multiple of */
4018 /* the algorithms block size */
4019 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4020 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4022 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4024 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4026 /* Create KASUMI operation */
4027 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4028 tdata->digest.len, tdata->auth_iv.data,
4030 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4031 tdata->cipher_iv.data, tdata->cipher_iv.len,
4032 tdata->validCipherLenInBits.len,
4034 tdata->validAuthLenInBits.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");
4043 ut_params->obuf = ut_params->op->sym->m_src;
4044 if (ut_params->obuf)
4045 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4047 ciphertext = plaintext;
4049 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4050 + plaintext_pad_len;
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4055 tdata->ciphertext.data,
4056 tdata->validCipherLenInBits.len,
4057 "KASUMI Ciphertext data not as expected");
4060 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4063 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4064 "KASUMI Generated auth tag not as expected");
4069 test_zuc_encryption(const struct wireless_test_data *tdata)
4071 struct crypto_testsuite_params *ts_params = &testsuite_params;
4072 struct crypto_unittest_params *ut_params = &unittest_params;
4075 uint8_t *plaintext, *ciphertext;
4076 unsigned plaintext_pad_len;
4077 unsigned plaintext_len;
4079 struct rte_cryptodev_sym_capability_idx cap_idx;
4081 /* Check if device supports ZUC EEA3 */
4082 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4083 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4085 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4089 /* Create ZUC session */
4090 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4091 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4092 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4093 tdata->key.data, tdata->key.len,
4094 tdata->cipher_iv.len);
4098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4100 /* Clear mbuf payload */
4101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4102 rte_pktmbuf_tailroom(ut_params->ibuf));
4104 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4105 /* Append data which is padded to a multiple */
4106 /* of the algorithms block size */
4107 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4108 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4110 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4112 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4114 /* Create ZUC operation */
4115 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4116 tdata->cipher_iv.len,
4117 tdata->plaintext.len,
4122 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4124 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4126 ut_params->obuf = ut_params->op->sym->m_dst;
4127 if (ut_params->obuf)
4128 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4130 ciphertext = plaintext;
4132 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4135 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4137 tdata->ciphertext.data,
4138 tdata->validCipherLenInBits.len,
4139 "ZUC Ciphertext data not as expected");
4144 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4146 struct crypto_testsuite_params *ts_params = &testsuite_params;
4147 struct crypto_unittest_params *ut_params = &unittest_params;
4151 unsigned int plaintext_pad_len;
4152 unsigned int plaintext_len;
4153 const uint8_t *ciphertext;
4154 uint8_t ciphertext_buffer[2048];
4155 struct rte_cryptodev_info dev_info;
4157 struct rte_cryptodev_sym_capability_idx cap_idx;
4159 /* Check if device supports ZUC EEA3 */
4160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4161 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4168 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4169 printf("Device doesn't support scatter-gather. "
4174 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4176 /* Append data which is padded to a multiple */
4177 /* of the algorithms block size */
4178 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4180 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4181 plaintext_pad_len, 10, 0);
4183 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4184 tdata->plaintext.data);
4186 /* Create ZUC session */
4187 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4188 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4189 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4190 tdata->key.data, tdata->key.len,
4191 tdata->cipher_iv.len);
4195 /* Clear mbuf payload */
4197 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4199 /* Create ZUC operation */
4200 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4201 tdata->cipher_iv.len, tdata->plaintext.len,
4206 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4208 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4210 ut_params->obuf = ut_params->op->sym->m_dst;
4211 if (ut_params->obuf)
4212 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4213 0, plaintext_len, ciphertext_buffer);
4215 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4216 0, plaintext_len, ciphertext_buffer);
4219 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4222 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4224 tdata->ciphertext.data,
4225 tdata->validCipherLenInBits.len,
4226 "ZUC Ciphertext data not as expected");
4232 test_zuc_authentication(const struct wireless_test_data *tdata)
4234 struct crypto_testsuite_params *ts_params = &testsuite_params;
4235 struct crypto_unittest_params *ut_params = &unittest_params;
4238 unsigned plaintext_pad_len;
4239 unsigned plaintext_len;
4242 struct rte_cryptodev_sym_capability_idx cap_idx;
4244 /* Check if device supports ZUC EIA3 */
4245 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4246 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4248 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4252 /* Create ZUC session */
4253 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4254 tdata->key.data, tdata->key.len,
4255 tdata->auth_iv.len, tdata->digest.len,
4256 RTE_CRYPTO_AUTH_OP_GENERATE,
4257 RTE_CRYPTO_AUTH_ZUC_EIA3);
4261 /* alloc mbuf and set payload */
4262 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4264 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4265 rte_pktmbuf_tailroom(ut_params->ibuf));
4267 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4268 /* Append data which is padded to a multiple of */
4269 /* the algorithms block size */
4270 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4271 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4273 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4275 /* Create ZUC operation */
4276 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4277 tdata->auth_iv.data, tdata->auth_iv.len,
4278 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4279 tdata->validAuthLenInBits.len,
4284 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4286 ut_params->obuf = ut_params->op->sym->m_src;
4287 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4288 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4289 + plaintext_pad_len;
4292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4295 DIGEST_BYTE_LENGTH_KASUMI_F9,
4296 "ZUC Generated auth tag not as expected");
4302 test_kasumi_encryption_test_case_1(void)
4304 return test_kasumi_encryption(&kasumi_test_case_1);
4308 test_kasumi_encryption_test_case_1_sgl(void)
4310 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4314 test_kasumi_encryption_test_case_1_oop(void)
4316 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4320 test_kasumi_encryption_test_case_1_oop_sgl(void)
4322 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4326 test_kasumi_encryption_test_case_2(void)
4328 return test_kasumi_encryption(&kasumi_test_case_2);
4332 test_kasumi_encryption_test_case_3(void)
4334 return test_kasumi_encryption(&kasumi_test_case_3);
4338 test_kasumi_encryption_test_case_4(void)
4340 return test_kasumi_encryption(&kasumi_test_case_4);
4344 test_kasumi_encryption_test_case_5(void)
4346 return test_kasumi_encryption(&kasumi_test_case_5);
4350 test_kasumi_decryption_test_case_1(void)
4352 return test_kasumi_decryption(&kasumi_test_case_1);
4356 test_kasumi_decryption_test_case_1_oop(void)
4358 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4362 test_kasumi_decryption_test_case_2(void)
4364 return test_kasumi_decryption(&kasumi_test_case_2);
4368 test_kasumi_decryption_test_case_3(void)
4370 return test_kasumi_decryption(&kasumi_test_case_3);
4374 test_kasumi_decryption_test_case_4(void)
4376 return test_kasumi_decryption(&kasumi_test_case_4);
4380 test_kasumi_decryption_test_case_5(void)
4382 return test_kasumi_decryption(&kasumi_test_case_5);
4385 test_snow3g_encryption_test_case_1(void)
4387 return test_snow3g_encryption(&snow3g_test_case_1);
4391 test_snow3g_encryption_test_case_1_oop(void)
4393 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4397 test_snow3g_encryption_test_case_1_oop_sgl(void)
4399 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4404 test_snow3g_encryption_test_case_1_offset_oop(void)
4406 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4410 test_snow3g_encryption_test_case_2(void)
4412 return test_snow3g_encryption(&snow3g_test_case_2);
4416 test_snow3g_encryption_test_case_3(void)
4418 return test_snow3g_encryption(&snow3g_test_case_3);
4422 test_snow3g_encryption_test_case_4(void)
4424 return test_snow3g_encryption(&snow3g_test_case_4);
4428 test_snow3g_encryption_test_case_5(void)
4430 return test_snow3g_encryption(&snow3g_test_case_5);
4434 test_snow3g_decryption_test_case_1(void)
4436 return test_snow3g_decryption(&snow3g_test_case_1);
4440 test_snow3g_decryption_test_case_1_oop(void)
4442 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4446 test_snow3g_decryption_test_case_2(void)
4448 return test_snow3g_decryption(&snow3g_test_case_2);
4452 test_snow3g_decryption_test_case_3(void)
4454 return test_snow3g_decryption(&snow3g_test_case_3);
4458 test_snow3g_decryption_test_case_4(void)
4460 return test_snow3g_decryption(&snow3g_test_case_4);
4464 test_snow3g_decryption_test_case_5(void)
4466 return test_snow3g_decryption(&snow3g_test_case_5);
4469 test_snow3g_cipher_auth_test_case_1(void)
4471 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4475 test_snow3g_auth_cipher_test_case_1(void)
4477 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4481 test_kasumi_auth_cipher_test_case_1(void)
4483 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4487 test_kasumi_cipher_auth_test_case_1(void)
4489 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4493 test_zuc_encryption_test_case_1(void)
4495 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4499 test_zuc_encryption_test_case_2(void)
4501 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4505 test_zuc_encryption_test_case_3(void)
4507 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4511 test_zuc_encryption_test_case_4(void)
4513 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4517 test_zuc_encryption_test_case_5(void)
4519 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4523 test_zuc_encryption_test_case_6_sgl(void)
4525 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4529 test_zuc_hash_generate_test_case_1(void)
4531 return test_zuc_authentication(&zuc_test_case_auth_1b);
4535 test_zuc_hash_generate_test_case_2(void)
4537 return test_zuc_authentication(&zuc_test_case_auth_90b);
4541 test_zuc_hash_generate_test_case_3(void)
4543 return test_zuc_authentication(&zuc_test_case_auth_577b);
4547 test_zuc_hash_generate_test_case_4(void)
4549 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4553 test_zuc_hash_generate_test_case_5(void)
4555 return test_zuc_authentication(&zuc_test_auth_5670b);
4559 test_zuc_hash_generate_test_case_6(void)
4561 return test_zuc_authentication(&zuc_test_case_auth_128b);
4565 test_zuc_hash_generate_test_case_7(void)
4567 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4571 test_zuc_hash_generate_test_case_8(void)
4573 return test_zuc_authentication(&zuc_test_case_auth_584b);
4577 test_zuc_cipher_auth_test_case_1(void)
4579 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4583 test_zuc_cipher_auth_test_case_2(void)
4585 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4589 test_3DES_chain_qat_all(void)
4591 struct crypto_testsuite_params *ts_params = &testsuite_params;
4594 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4595 ts_params->op_mpool,
4596 ts_params->session_mpool,
4597 ts_params->valid_devs[0],
4598 rte_cryptodev_driver_id_get(
4599 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4600 BLKCIPHER_3DES_CHAIN_TYPE);
4602 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4604 return TEST_SUCCESS;
4608 test_DES_cipheronly_qat_all(void)
4610 struct crypto_testsuite_params *ts_params = &testsuite_params;
4613 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4614 ts_params->op_mpool,
4615 ts_params->session_mpool,
4616 ts_params->valid_devs[0],
4617 rte_cryptodev_driver_id_get(
4618 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4619 BLKCIPHER_DES_CIPHERONLY_TYPE);
4621 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4623 return TEST_SUCCESS;
4627 test_DES_docsis_openssl_all(void)
4629 struct crypto_testsuite_params *ts_params = &testsuite_params;
4632 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4633 ts_params->op_mpool,
4634 ts_params->session_mpool,
4635 ts_params->valid_devs[0],
4636 rte_cryptodev_driver_id_get(
4637 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4638 BLKCIPHER_DES_DOCSIS_TYPE);
4640 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4642 return TEST_SUCCESS;
4646 test_3DES_chain_dpaa2_sec_all(void)
4648 struct crypto_testsuite_params *ts_params = &testsuite_params;
4651 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4652 ts_params->op_mpool,
4653 ts_params->session_mpool,
4654 ts_params->valid_devs[0],
4655 rte_cryptodev_driver_id_get(
4656 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4657 BLKCIPHER_3DES_CHAIN_TYPE);
4659 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4661 return TEST_SUCCESS;
4665 test_3DES_cipheronly_dpaa2_sec_all(void)
4667 struct crypto_testsuite_params *ts_params = &testsuite_params;
4670 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4671 ts_params->op_mpool,
4672 ts_params->session_mpool,
4673 ts_params->valid_devs[0],
4674 rte_cryptodev_driver_id_get(
4675 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4676 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4678 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4680 return TEST_SUCCESS;
4684 test_3DES_cipheronly_qat_all(void)
4686 struct crypto_testsuite_params *ts_params = &testsuite_params;
4689 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4690 ts_params->op_mpool,
4691 ts_params->session_mpool,
4692 ts_params->valid_devs[0],
4693 rte_cryptodev_driver_id_get(
4694 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4695 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4697 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4699 return TEST_SUCCESS;
4703 test_3DES_chain_openssl_all(void)
4705 struct crypto_testsuite_params *ts_params = &testsuite_params;
4708 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4709 ts_params->op_mpool,
4710 ts_params->session_mpool,
4711 ts_params->valid_devs[0],
4712 rte_cryptodev_driver_id_get(
4713 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4714 BLKCIPHER_3DES_CHAIN_TYPE);
4716 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4718 return TEST_SUCCESS;
4722 test_3DES_cipheronly_openssl_all(void)
4724 struct crypto_testsuite_params *ts_params = &testsuite_params;
4727 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4728 ts_params->op_mpool,
4729 ts_params->session_mpool,
4730 ts_params->valid_devs[0],
4731 rte_cryptodev_driver_id_get(
4732 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4733 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4735 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4737 return TEST_SUCCESS;
4740 /* ***** AES-GCM Tests ***** */
4743 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4744 const uint8_t *key, const uint8_t key_len,
4745 const uint16_t aad_len, const uint8_t auth_len,
4748 uint8_t aead_key[key_len];
4750 struct crypto_testsuite_params *ts_params = &testsuite_params;
4751 struct crypto_unittest_params *ut_params = &unittest_params;
4753 memcpy(aead_key, key, key_len);
4755 /* Setup AEAD Parameters */
4756 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4757 ut_params->aead_xform.next = NULL;
4758 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4759 ut_params->aead_xform.aead.op = op;
4760 ut_params->aead_xform.aead.key.data = aead_key;
4761 ut_params->aead_xform.aead.key.length = key_len;
4762 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4763 ut_params->aead_xform.aead.iv.length = iv_len;
4764 ut_params->aead_xform.aead.digest_length = auth_len;
4765 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4767 TEST_HEXDUMP(stdout, "key:", key, key_len);
4769 /* Create Crypto session*/
4770 ut_params->sess = rte_cryptodev_sym_session_create(
4771 ts_params->session_mpool);
4773 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
4774 &ut_params->aead_xform, ts_params->session_mpool);
4776 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4782 create_gcm_xforms(struct rte_crypto_op *op,
4783 enum rte_crypto_aead_operation aead_op,
4784 uint8_t *key, const uint8_t key_len,
4785 const uint8_t aad_len, const uint8_t auth_len,
4788 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4789 "failed to allocate space for crypto transform");
4791 struct rte_crypto_sym_op *sym_op = op->sym;
4793 /* Setup AEAD Parameters */
4794 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4795 sym_op->xform->next = NULL;
4796 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4797 sym_op->xform->aead.op = aead_op;
4798 sym_op->xform->aead.key.data = key;
4799 sym_op->xform->aead.key.length = key_len;
4800 sym_op->xform->aead.iv.offset = IV_OFFSET;
4801 sym_op->xform->aead.iv.length = iv_len;
4802 sym_op->xform->aead.digest_length = auth_len;
4803 sym_op->xform->aead.add_auth_data_length = aad_len;
4805 TEST_HEXDUMP(stdout, "key:", key, key_len);
4811 create_gcm_operation(enum rte_crypto_aead_operation op,
4812 const struct gcm_test_data *tdata)
4814 struct crypto_testsuite_params *ts_params = &testsuite_params;
4815 struct crypto_unittest_params *ut_params = &unittest_params;
4817 uint8_t *plaintext, *ciphertext;
4818 unsigned int aad_pad_len, plaintext_pad_len;
4820 /* Generate Crypto op data structure */
4821 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4822 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4823 TEST_ASSERT_NOT_NULL(ut_params->op,
4824 "Failed to allocate symmetric crypto operation struct");
4826 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4828 /* Append aad data */
4829 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4830 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4832 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4833 "no room to append aad");
4835 sym_op->aead.aad.phys_addr =
4836 rte_pktmbuf_mtophys(ut_params->ibuf);
4837 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4838 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4841 /* Append IV at the end of the crypto operation*/
4842 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4843 uint8_t *, IV_OFFSET);
4845 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4846 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4849 /* Append plaintext/ciphertext */
4850 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4851 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4854 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4856 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4857 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4858 tdata->plaintext.len);
4860 if (ut_params->obuf) {
4861 ciphertext = (uint8_t *)rte_pktmbuf_append(
4863 plaintext_pad_len + aad_pad_len);
4864 TEST_ASSERT_NOT_NULL(ciphertext,
4865 "no room to append ciphertext");
4867 memset(ciphertext + aad_pad_len, 0,
4868 tdata->ciphertext.len);
4871 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4872 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4874 TEST_ASSERT_NOT_NULL(ciphertext,
4875 "no room to append ciphertext");
4877 memcpy(ciphertext, tdata->ciphertext.data,
4878 tdata->ciphertext.len);
4879 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4880 tdata->ciphertext.len);
4882 if (ut_params->obuf) {
4883 plaintext = (uint8_t *)rte_pktmbuf_append(
4885 plaintext_pad_len + aad_pad_len);
4886 TEST_ASSERT_NOT_NULL(plaintext,
4887 "no room to append plaintext");
4889 memset(plaintext + aad_pad_len, 0,
4890 tdata->plaintext.len);
4894 /* Append digest data */
4895 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4896 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4897 ut_params->obuf ? ut_params->obuf :
4899 tdata->auth_tag.len);
4900 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4901 "no room to append digest");
4902 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4903 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4904 ut_params->obuf ? ut_params->obuf :
4909 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4910 ut_params->ibuf, tdata->auth_tag.len);
4911 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4912 "no room to append digest");
4913 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4915 plaintext_pad_len + aad_pad_len);
4917 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4918 tdata->auth_tag.len);
4919 TEST_HEXDUMP(stdout, "digest:",
4920 sym_op->aead.digest.data,
4921 tdata->auth_tag.len);
4924 sym_op->aead.data.length = tdata->plaintext.len;
4925 sym_op->aead.data.offset = aad_pad_len;
4931 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4933 struct crypto_testsuite_params *ts_params = &testsuite_params;
4934 struct crypto_unittest_params *ut_params = &unittest_params;
4937 uint8_t *ciphertext, *auth_tag;
4938 uint16_t plaintext_pad_len;
4941 /* Create GCM session */
4942 retval = create_gcm_session(ts_params->valid_devs[0],
4943 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4944 tdata->key.data, tdata->key.len,
4945 tdata->aad.len, tdata->auth_tag.len,
4950 if (tdata->aad.len > MBUF_SIZE) {
4951 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4952 /* Populate full size of add data */
4953 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4954 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4958 /* clear mbuf payload */
4959 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4960 rte_pktmbuf_tailroom(ut_params->ibuf));
4962 /* Create GCM operation */
4963 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4967 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4969 ut_params->op->sym->m_src = ut_params->ibuf;
4971 /* Process crypto operation */
4972 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4973 ut_params->op), "failed to process sym crypto op");
4975 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4976 "crypto op processing failed");
4978 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4980 if (ut_params->op->sym->m_dst) {
4981 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4983 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4984 uint8_t *, plaintext_pad_len);
4986 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4988 ut_params->op->sym->cipher.data.offset);
4989 auth_tag = ciphertext + plaintext_pad_len;
4992 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4993 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4996 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4998 tdata->ciphertext.data,
4999 tdata->ciphertext.len,
5000 "GCM Ciphertext data not as expected");
5002 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5004 tdata->auth_tag.data,
5005 tdata->auth_tag.len,
5006 "GCM Generated auth tag not as expected");
5013 test_AES_GCM_authenticated_encryption_test_case_1(void)
5015 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
5019 test_AES_GCM_authenticated_encryption_test_case_2(void)
5021 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
5025 test_AES_GCM_authenticated_encryption_test_case_3(void)
5027 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
5031 test_AES_GCM_authenticated_encryption_test_case_4(void)
5033 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
5037 test_AES_GCM_authenticated_encryption_test_case_5(void)
5039 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
5043 test_AES_GCM_authenticated_encryption_test_case_6(void)
5045 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
5049 test_AES_GCM_authenticated_encryption_test_case_7(void)
5051 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
5055 test_AES_GCM_auth_encryption_test_case_192_1(void)
5057 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
5061 test_AES_GCM_auth_encryption_test_case_192_2(void)
5063 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
5067 test_AES_GCM_auth_encryption_test_case_192_3(void)
5069 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
5073 test_AES_GCM_auth_encryption_test_case_192_4(void)
5075 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
5079 test_AES_GCM_auth_encryption_test_case_192_5(void)
5081 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
5085 test_AES_GCM_auth_encryption_test_case_192_6(void)
5087 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
5091 test_AES_GCM_auth_encryption_test_case_192_7(void)
5093 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
5097 test_AES_GCM_auth_encryption_test_case_256_1(void)
5099 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5103 test_AES_GCM_auth_encryption_test_case_256_2(void)
5105 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5109 test_AES_GCM_auth_encryption_test_case_256_3(void)
5111 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5115 test_AES_GCM_auth_encryption_test_case_256_4(void)
5117 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5121 test_AES_GCM_auth_encryption_test_case_256_5(void)
5123 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5127 test_AES_GCM_auth_encryption_test_case_256_6(void)
5129 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5133 test_AES_GCM_auth_encryption_test_case_256_7(void)
5135 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5139 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5141 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5145 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5147 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5151 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5153 struct crypto_testsuite_params *ts_params = &testsuite_params;
5154 struct crypto_unittest_params *ut_params = &unittest_params;
5160 /* Create GCM session */
5161 retval = create_gcm_session(ts_params->valid_devs[0],
5162 RTE_CRYPTO_AEAD_OP_DECRYPT,
5163 tdata->key.data, tdata->key.len,
5164 tdata->aad.len, tdata->auth_tag.len,
5169 /* alloc mbuf and set payload */
5170 if (tdata->aad.len > MBUF_SIZE) {
5171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5172 /* Populate full size of add data */
5173 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5174 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5179 rte_pktmbuf_tailroom(ut_params->ibuf));
5181 /* Create GCM operation */
5182 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5186 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5188 ut_params->op->sym->m_src = ut_params->ibuf;
5190 /* Process crypto operation */
5191 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5192 ut_params->op), "failed to process sym crypto op");
5194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5195 "crypto op processing failed");
5197 if (ut_params->op->sym->m_dst)
5198 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5201 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5203 ut_params->op->sym->cipher.data.offset);
5205 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5210 tdata->plaintext.data,
5211 tdata->plaintext.len,
5212 "GCM plaintext data not as expected");
5214 TEST_ASSERT_EQUAL(ut_params->op->status,
5215 RTE_CRYPTO_OP_STATUS_SUCCESS,
5216 "GCM authentication failed");
5221 test_AES_GCM_authenticated_decryption_test_case_1(void)
5223 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5227 test_AES_GCM_authenticated_decryption_test_case_2(void)
5229 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5233 test_AES_GCM_authenticated_decryption_test_case_3(void)
5235 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5239 test_AES_GCM_authenticated_decryption_test_case_4(void)
5241 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5245 test_AES_GCM_authenticated_decryption_test_case_5(void)
5247 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5251 test_AES_GCM_authenticated_decryption_test_case_6(void)
5253 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5257 test_AES_GCM_authenticated_decryption_test_case_7(void)
5259 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5263 test_AES_GCM_auth_decryption_test_case_192_1(void)
5265 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5269 test_AES_GCM_auth_decryption_test_case_192_2(void)
5271 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5275 test_AES_GCM_auth_decryption_test_case_192_3(void)
5277 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5281 test_AES_GCM_auth_decryption_test_case_192_4(void)
5283 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5287 test_AES_GCM_auth_decryption_test_case_192_5(void)
5289 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5293 test_AES_GCM_auth_decryption_test_case_192_6(void)
5295 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5299 test_AES_GCM_auth_decryption_test_case_192_7(void)
5301 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5305 test_AES_GCM_auth_decryption_test_case_256_1(void)
5307 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5311 test_AES_GCM_auth_decryption_test_case_256_2(void)
5313 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5317 test_AES_GCM_auth_decryption_test_case_256_3(void)
5319 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5323 test_AES_GCM_auth_decryption_test_case_256_4(void)
5325 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5329 test_AES_GCM_auth_decryption_test_case_256_5(void)
5331 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5335 test_AES_GCM_auth_decryption_test_case_256_6(void)
5337 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5341 test_AES_GCM_auth_decryption_test_case_256_7(void)
5343 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5347 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5349 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5353 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5355 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5359 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5361 struct crypto_testsuite_params *ts_params = &testsuite_params;
5362 struct crypto_unittest_params *ut_params = &unittest_params;
5365 uint8_t *ciphertext, *auth_tag;
5366 uint16_t plaintext_pad_len;
5368 /* Create GCM session */
5369 retval = create_gcm_session(ts_params->valid_devs[0],
5370 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5371 tdata->key.data, tdata->key.len,
5372 tdata->aad.len, tdata->auth_tag.len,
5377 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5378 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5380 /* clear mbuf payload */
5381 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5382 rte_pktmbuf_tailroom(ut_params->ibuf));
5383 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5384 rte_pktmbuf_tailroom(ut_params->obuf));
5386 /* Create GCM operation */
5387 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5391 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5393 ut_params->op->sym->m_src = ut_params->ibuf;
5394 ut_params->op->sym->m_dst = ut_params->obuf;
5396 /* Process crypto operation */
5397 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5398 ut_params->op), "failed to process sym crypto op");
5400 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5401 "crypto op processing failed");
5403 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5405 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5406 ut_params->op->sym->cipher.data.offset);
5407 auth_tag = ciphertext + plaintext_pad_len;
5409 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5410 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5413 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5415 tdata->ciphertext.data,
5416 tdata->ciphertext.len,
5417 "GCM Ciphertext data not as expected");
5419 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5421 tdata->auth_tag.data,
5422 tdata->auth_tag.len,
5423 "GCM Generated auth tag not as expected");
5430 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5432 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5436 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5438 struct crypto_testsuite_params *ts_params = &testsuite_params;
5439 struct crypto_unittest_params *ut_params = &unittest_params;
5444 /* Create GCM session */
5445 retval = create_gcm_session(ts_params->valid_devs[0],
5446 RTE_CRYPTO_AEAD_OP_DECRYPT,
5447 tdata->key.data, tdata->key.len,
5448 tdata->aad.len, tdata->auth_tag.len,
5453 /* alloc mbuf and set payload */
5454 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5455 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5458 rte_pktmbuf_tailroom(ut_params->ibuf));
5459 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5460 rte_pktmbuf_tailroom(ut_params->obuf));
5462 /* Create GCM operation */
5463 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5467 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5469 ut_params->op->sym->m_src = ut_params->ibuf;
5470 ut_params->op->sym->m_dst = ut_params->obuf;
5472 /* Process crypto operation */
5473 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5474 ut_params->op), "failed to process sym crypto op");
5476 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5477 "crypto op processing failed");
5479 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5480 ut_params->op->sym->cipher.data.offset);
5482 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5487 tdata->plaintext.data,
5488 tdata->plaintext.len,
5489 "GCM plaintext data not as expected");
5491 TEST_ASSERT_EQUAL(ut_params->op->status,
5492 RTE_CRYPTO_OP_STATUS_SUCCESS,
5493 "GCM authentication failed");
5498 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5500 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5504 test_AES_GCM_authenticated_encryption_sessionless(
5505 const struct gcm_test_data *tdata)
5507 struct crypto_testsuite_params *ts_params = &testsuite_params;
5508 struct crypto_unittest_params *ut_params = &unittest_params;
5511 uint8_t *ciphertext, *auth_tag;
5512 uint16_t plaintext_pad_len;
5513 uint8_t key[tdata->key.len + 1];
5515 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5517 /* clear mbuf payload */
5518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5519 rte_pktmbuf_tailroom(ut_params->ibuf));
5521 /* Create GCM operation */
5522 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5526 /* Create GCM xforms */
5527 memcpy(key, tdata->key.data, tdata->key.len);
5528 retval = create_gcm_xforms(ut_params->op,
5529 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5530 key, tdata->key.len,
5531 tdata->aad.len, tdata->auth_tag.len,
5536 ut_params->op->sym->m_src = ut_params->ibuf;
5538 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5539 RTE_CRYPTO_OP_SESSIONLESS,
5540 "crypto op session type not sessionless");
5542 /* Process crypto operation */
5543 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5544 ut_params->op), "failed to process sym crypto op");
5546 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5549 "crypto op status not success");
5551 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5553 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5554 ut_params->op->sym->cipher.data.offset);
5555 auth_tag = ciphertext + plaintext_pad_len;
5557 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5558 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5561 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5563 tdata->ciphertext.data,
5564 tdata->ciphertext.len,
5565 "GCM Ciphertext data not as expected");
5567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5569 tdata->auth_tag.data,
5570 tdata->auth_tag.len,
5571 "GCM Generated auth tag not as expected");
5578 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5580 return test_AES_GCM_authenticated_encryption_sessionless(
5585 test_AES_GCM_authenticated_decryption_sessionless(
5586 const struct gcm_test_data *tdata)
5588 struct crypto_testsuite_params *ts_params = &testsuite_params;
5589 struct crypto_unittest_params *ut_params = &unittest_params;
5593 uint8_t key[tdata->key.len + 1];
5595 /* alloc mbuf and set payload */
5596 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5598 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5599 rte_pktmbuf_tailroom(ut_params->ibuf));
5601 /* Create GCM operation */
5602 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5606 /* Create GCM xforms */
5607 memcpy(key, tdata->key.data, tdata->key.len);
5608 retval = create_gcm_xforms(ut_params->op,
5609 RTE_CRYPTO_AEAD_OP_DECRYPT,
5610 key, tdata->key.len,
5611 tdata->aad.len, tdata->auth_tag.len,
5616 ut_params->op->sym->m_src = ut_params->ibuf;
5618 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5619 RTE_CRYPTO_OP_SESSIONLESS,
5620 "crypto op session type not sessionless");
5622 /* Process crypto operation */
5623 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5624 ut_params->op), "failed to process sym crypto op");
5626 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5628 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5629 "crypto op status not success");
5631 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5632 ut_params->op->sym->cipher.data.offset);
5634 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5637 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5639 tdata->plaintext.data,
5640 tdata->plaintext.len,
5641 "GCM plaintext data not as expected");
5643 TEST_ASSERT_EQUAL(ut_params->op->status,
5644 RTE_CRYPTO_OP_STATUS_SUCCESS,
5645 "GCM authentication failed");
5650 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5652 return test_AES_GCM_authenticated_decryption_sessionless(
5659 struct crypto_testsuite_params *ts_params = &testsuite_params;
5660 struct rte_cryptodev_stats stats;
5661 struct rte_cryptodev *dev;
5662 cryptodev_stats_get_t temp_pfn;
5664 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5665 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5666 &stats) == -ENODEV),
5667 "rte_cryptodev_stats_get invalid dev failed");
5668 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5669 "rte_cryptodev_stats_get invalid Param failed");
5670 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5671 temp_pfn = dev->dev_ops->stats_get;
5672 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5673 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5675 "rte_cryptodev_stats_get invalid Param failed");
5676 dev->dev_ops->stats_get = temp_pfn;
5678 /* Test expected values */
5680 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5682 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5684 "rte_cryptodev_stats_get failed");
5685 TEST_ASSERT((stats.enqueued_count == 1),
5686 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5687 TEST_ASSERT((stats.dequeued_count == 1),
5688 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5689 TEST_ASSERT((stats.enqueue_err_count == 0),
5690 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5691 TEST_ASSERT((stats.dequeue_err_count == 0),
5692 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5694 /* invalid device but should ignore and not reset device stats*/
5695 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5696 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5698 "rte_cryptodev_stats_get failed");
5699 TEST_ASSERT((stats.enqueued_count == 1),
5700 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5702 /* check that a valid reset clears stats */
5703 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5704 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5706 "rte_cryptodev_stats_get failed");
5707 TEST_ASSERT((stats.enqueued_count == 0),
5708 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5709 TEST_ASSERT((stats.dequeued_count == 0),
5710 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5712 return TEST_SUCCESS;
5715 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5716 struct crypto_unittest_params *ut_params,
5717 enum rte_crypto_auth_operation op,
5718 const struct HMAC_MD5_vector *test_case)
5722 memcpy(key, test_case->key.data, test_case->key.len);
5724 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5725 ut_params->auth_xform.next = NULL;
5726 ut_params->auth_xform.auth.op = op;
5728 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5730 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5731 ut_params->auth_xform.auth.key.length = test_case->key.len;
5732 ut_params->auth_xform.auth.key.data = key;
5734 ut_params->sess = rte_cryptodev_sym_session_create(
5735 ts_params->session_mpool);
5737 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5738 ut_params->sess, &ut_params->auth_xform,
5739 ts_params->session_mpool);
5741 if (ut_params->sess == NULL)
5744 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5746 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5747 rte_pktmbuf_tailroom(ut_params->ibuf));
5752 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5753 const struct HMAC_MD5_vector *test_case,
5754 uint8_t **plaintext)
5756 uint16_t plaintext_pad_len;
5758 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5760 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5763 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5765 memcpy(*plaintext, test_case->plaintext.data,
5766 test_case->plaintext.len);
5768 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5769 ut_params->ibuf, MD5_DIGEST_LEN);
5770 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5771 "no room to append digest");
5772 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5773 ut_params->ibuf, plaintext_pad_len);
5775 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5776 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5777 test_case->auth_tag.len);
5780 sym_op->auth.data.offset = 0;
5781 sym_op->auth.data.length = test_case->plaintext.len;
5783 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5784 ut_params->op->sym->m_src = ut_params->ibuf;
5790 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5792 uint16_t plaintext_pad_len;
5793 uint8_t *plaintext, *auth_tag;
5795 struct crypto_testsuite_params *ts_params = &testsuite_params;
5796 struct crypto_unittest_params *ut_params = &unittest_params;
5798 if (MD5_HMAC_create_session(ts_params, ut_params,
5799 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5802 /* Generate Crypto op data structure */
5803 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5804 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5805 TEST_ASSERT_NOT_NULL(ut_params->op,
5806 "Failed to allocate symmetric crypto operation struct");
5808 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5811 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5814 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5815 ut_params->op), "failed to process sym crypto op");
5817 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5818 "crypto op processing failed");
5820 if (ut_params->op->sym->m_dst) {
5821 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5822 uint8_t *, plaintext_pad_len);
5824 auth_tag = plaintext + plaintext_pad_len;
5827 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5829 test_case->auth_tag.data,
5830 test_case->auth_tag.len,
5831 "HMAC_MD5 generated tag not as expected");
5833 return TEST_SUCCESS;
5837 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5841 struct crypto_testsuite_params *ts_params = &testsuite_params;
5842 struct crypto_unittest_params *ut_params = &unittest_params;
5844 if (MD5_HMAC_create_session(ts_params, ut_params,
5845 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5849 /* Generate Crypto op data structure */
5850 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5851 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5852 TEST_ASSERT_NOT_NULL(ut_params->op,
5853 "Failed to allocate symmetric crypto operation struct");
5855 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5858 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5859 ut_params->op), "failed to process sym crypto op");
5861 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5862 "HMAC_MD5 crypto op processing failed");
5864 return TEST_SUCCESS;
5868 test_MD5_HMAC_generate_case_1(void)
5870 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5874 test_MD5_HMAC_verify_case_1(void)
5876 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5880 test_MD5_HMAC_generate_case_2(void)
5882 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5886 test_MD5_HMAC_verify_case_2(void)
5888 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5892 test_multi_session(void)
5894 struct crypto_testsuite_params *ts_params = &testsuite_params;
5895 struct crypto_unittest_params *ut_params = &unittest_params;
5897 struct rte_cryptodev_info dev_info;
5898 struct rte_cryptodev_sym_session **sessions;
5902 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5903 aes_cbc_key, hmac_sha512_key);
5906 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5908 sessions = rte_malloc(NULL,
5909 (sizeof(struct rte_cryptodev_sym_session *) *
5910 dev_info.sym.max_nb_sessions) + 1, 0);
5912 /* Create multiple crypto sessions*/
5913 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5915 sessions[i] = rte_cryptodev_sym_session_create(
5916 ts_params->session_mpool);
5918 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5919 sessions[i], &ut_params->auth_xform,
5920 ts_params->session_mpool);
5921 TEST_ASSERT_NOT_NULL(sessions[i],
5922 "Session creation failed at session number %u",
5925 /* Attempt to send a request on each session */
5926 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5930 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5931 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5933 "Failed to perform decrypt on request number %u.", i);
5934 /* free crypto operation structure */
5936 rte_crypto_op_free(ut_params->op);
5939 * free mbuf - both obuf and ibuf are usually the same,
5940 * so check if they point at the same address is necessary,
5941 * to avoid freeing the mbuf twice.
5943 if (ut_params->obuf) {
5944 rte_pktmbuf_free(ut_params->obuf);
5945 if (ut_params->ibuf == ut_params->obuf)
5946 ut_params->ibuf = 0;
5947 ut_params->obuf = 0;
5949 if (ut_params->ibuf) {
5950 rte_pktmbuf_free(ut_params->ibuf);
5951 ut_params->ibuf = 0;
5955 /* Next session create should fail */
5956 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
5957 sessions[i], &ut_params->auth_xform,
5958 ts_params->session_mpool);
5959 TEST_ASSERT_NULL(sessions[i],
5960 "Session creation succeeded unexpectedly!");
5962 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5963 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
5965 rte_cryptodev_sym_session_free(sessions[i]);
5970 return TEST_SUCCESS;
5973 struct multi_session_params {
5974 struct crypto_unittest_params ut_params;
5975 uint8_t *cipher_key;
5977 const uint8_t *cipher;
5978 const uint8_t *digest;
5982 #define MB_SESSION_NUMBER 3
5985 test_multi_session_random_usage(void)
5987 struct crypto_testsuite_params *ts_params = &testsuite_params;
5988 struct rte_cryptodev_info dev_info;
5989 struct rte_cryptodev_sym_session **sessions;
5991 struct multi_session_params ut_paramz[] = {
5994 .cipher_key = ms_aes_cbc_key0,
5995 .hmac_key = ms_hmac_key0,
5996 .cipher = ms_aes_cbc_cipher0,
5997 .digest = ms_hmac_digest0,
5998 .iv = ms_aes_cbc_iv0
6001 .cipher_key = ms_aes_cbc_key1,
6002 .hmac_key = ms_hmac_key1,
6003 .cipher = ms_aes_cbc_cipher1,
6004 .digest = ms_hmac_digest1,
6005 .iv = ms_aes_cbc_iv1
6008 .cipher_key = ms_aes_cbc_key2,
6009 .hmac_key = ms_hmac_key2,
6010 .cipher = ms_aes_cbc_cipher2,
6011 .digest = ms_hmac_digest2,
6012 .iv = ms_aes_cbc_iv2
6017 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6019 sessions = rte_malloc(NULL,
6020 (sizeof(struct rte_cryptodev_sym_session *)
6021 * dev_info.sym.max_nb_sessions) + 1, 0);
6023 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6024 sessions[i] = rte_cryptodev_sym_session_create(
6025 ts_params->session_mpool);
6027 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6028 sizeof(struct crypto_unittest_params));
6030 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6031 &ut_paramz[i].ut_params,
6032 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6034 /* Create multiple crypto sessions*/
6035 rte_cryptodev_sym_session_init(
6036 ts_params->valid_devs[0],
6038 &ut_paramz[i].ut_params.auth_xform,
6039 ts_params->session_mpool);
6041 TEST_ASSERT_NOT_NULL(sessions[i],
6042 "Session creation failed at session number %u",
6048 for (i = 0; i < 40000; i++) {
6050 j = rand() % MB_SESSION_NUMBER;
6052 TEST_ASSERT_SUCCESS(
6053 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6055 &ut_paramz[j].ut_params,
6056 ts_params, ut_paramz[j].cipher,
6057 ut_paramz[j].digest,
6059 "Failed to perform decrypt on request number %u.", i);
6061 if (ut_paramz[j].ut_params.op)
6062 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6065 * free mbuf - both obuf and ibuf are usually the same,
6066 * so check if they point at the same address is necessary,
6067 * to avoid freeing the mbuf twice.
6069 if (ut_paramz[j].ut_params.obuf) {
6070 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6071 if (ut_paramz[j].ut_params.ibuf
6072 == ut_paramz[j].ut_params.obuf)
6073 ut_paramz[j].ut_params.ibuf = 0;
6074 ut_paramz[j].ut_params.obuf = 0;
6076 if (ut_paramz[j].ut_params.ibuf) {
6077 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6078 ut_paramz[j].ut_params.ibuf = 0;
6082 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6083 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6085 rte_cryptodev_sym_session_free(sessions[i]);
6090 return TEST_SUCCESS;
6094 test_null_cipher_only_operation(void)
6096 struct crypto_testsuite_params *ts_params = &testsuite_params;
6097 struct crypto_unittest_params *ut_params = &unittest_params;
6099 /* Generate test mbuf data and space for digest */
6100 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6101 catch_22_quote, QUOTE_512_BYTES, 0);
6103 /* Setup Cipher Parameters */
6104 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6105 ut_params->cipher_xform.next = NULL;
6107 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6108 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6110 ut_params->sess = rte_cryptodev_sym_session_create(
6111 ts_params->session_mpool);
6113 /* Create Crypto session*/
6114 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6116 &ut_params->cipher_xform,
6117 ts_params->session_mpool);
6118 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6120 /* Generate Crypto op data structure */
6121 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6122 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6123 TEST_ASSERT_NOT_NULL(ut_params->op,
6124 "Failed to allocate symmetric crypto operation struct");
6126 /* Set crypto operation data parameters */
6127 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6129 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6131 /* set crypto operation source mbuf */
6132 sym_op->m_src = ut_params->ibuf;
6134 sym_op->cipher.data.offset = 0;
6135 sym_op->cipher.data.length = QUOTE_512_BYTES;
6137 /* Process crypto operation */
6138 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6140 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6142 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6143 "crypto operation processing failed");
6146 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6147 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6150 "Ciphertext data not as expected");
6152 return TEST_SUCCESS;
6156 test_null_auth_only_operation(void)
6158 struct crypto_testsuite_params *ts_params = &testsuite_params;
6159 struct crypto_unittest_params *ut_params = &unittest_params;
6161 /* Generate test mbuf data and space for digest */
6162 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6163 catch_22_quote, QUOTE_512_BYTES, 0);
6165 /* Setup HMAC Parameters */
6166 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6167 ut_params->auth_xform.next = NULL;
6169 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6170 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6172 ut_params->sess = rte_cryptodev_sym_session_create(
6173 ts_params->session_mpool);
6175 /* Create Crypto session*/
6176 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6177 ut_params->sess, &ut_params->auth_xform,
6178 ts_params->session_mpool);
6179 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6181 /* Generate Crypto op data structure */
6182 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6183 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6184 TEST_ASSERT_NOT_NULL(ut_params->op,
6185 "Failed to allocate symmetric crypto operation struct");
6187 /* Set crypto operation data parameters */
6188 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6190 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6192 sym_op->m_src = ut_params->ibuf;
6194 sym_op->auth.data.offset = 0;
6195 sym_op->auth.data.length = QUOTE_512_BYTES;
6197 /* Process crypto operation */
6198 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6200 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6202 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6203 "crypto operation processing failed");
6205 return TEST_SUCCESS;
6209 test_null_cipher_auth_operation(void)
6211 struct crypto_testsuite_params *ts_params = &testsuite_params;
6212 struct crypto_unittest_params *ut_params = &unittest_params;
6214 /* Generate test mbuf data and space for digest */
6215 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6216 catch_22_quote, QUOTE_512_BYTES, 0);
6218 /* Setup Cipher Parameters */
6219 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6220 ut_params->cipher_xform.next = &ut_params->auth_xform;
6222 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6223 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6225 /* Setup HMAC Parameters */
6226 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6227 ut_params->auth_xform.next = NULL;
6229 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6230 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6232 ut_params->sess = rte_cryptodev_sym_session_create(
6233 ts_params->session_mpool);
6235 /* Create Crypto session*/
6236 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6237 ut_params->sess, &ut_params->cipher_xform,
6238 ts_params->session_mpool);
6239 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6241 /* Generate Crypto op data structure */
6242 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6243 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6244 TEST_ASSERT_NOT_NULL(ut_params->op,
6245 "Failed to allocate symmetric crypto operation struct");
6247 /* Set crypto operation data parameters */
6248 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6250 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6252 sym_op->m_src = ut_params->ibuf;
6254 sym_op->cipher.data.offset = 0;
6255 sym_op->cipher.data.length = QUOTE_512_BYTES;
6257 sym_op->auth.data.offset = 0;
6258 sym_op->auth.data.length = QUOTE_512_BYTES;
6260 /* Process crypto operation */
6261 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6263 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6265 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6266 "crypto operation processing failed");
6269 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6270 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6273 "Ciphertext data not as expected");
6275 return TEST_SUCCESS;
6279 test_null_auth_cipher_operation(void)
6281 struct crypto_testsuite_params *ts_params = &testsuite_params;
6282 struct crypto_unittest_params *ut_params = &unittest_params;
6284 /* Generate test mbuf data and space for digest */
6285 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6286 catch_22_quote, QUOTE_512_BYTES, 0);
6288 /* Setup Cipher Parameters */
6289 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6290 ut_params->cipher_xform.next = NULL;
6292 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6293 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6295 /* Setup HMAC Parameters */
6296 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6297 ut_params->auth_xform.next = &ut_params->cipher_xform;
6299 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6300 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6302 ut_params->sess = rte_cryptodev_sym_session_create(
6303 ts_params->session_mpool);
6305 /* Create Crypto session*/
6306 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6307 ut_params->sess, &ut_params->cipher_xform,
6308 ts_params->session_mpool);
6309 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6311 /* Generate Crypto op data structure */
6312 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6313 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6314 TEST_ASSERT_NOT_NULL(ut_params->op,
6315 "Failed to allocate symmetric crypto operation struct");
6317 /* Set crypto operation data parameters */
6318 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6322 sym_op->m_src = ut_params->ibuf;
6324 sym_op->cipher.data.offset = 0;
6325 sym_op->cipher.data.length = QUOTE_512_BYTES;
6327 sym_op->auth.data.offset = 0;
6328 sym_op->auth.data.length = QUOTE_512_BYTES;
6330 /* Process crypto operation */
6331 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6333 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6335 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6336 "crypto operation processing failed");
6339 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6340 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6343 "Ciphertext data not as expected");
6345 return TEST_SUCCESS;
6350 test_null_invalid_operation(void)
6352 struct crypto_testsuite_params *ts_params = &testsuite_params;
6353 struct crypto_unittest_params *ut_params = &unittest_params;
6356 /* Setup Cipher Parameters */
6357 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6358 ut_params->cipher_xform.next = NULL;
6360 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6361 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6363 ut_params->sess = rte_cryptodev_sym_session_create(
6364 ts_params->session_mpool);
6366 /* Create Crypto session*/
6367 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6368 ut_params->sess, &ut_params->cipher_xform,
6369 ts_params->session_mpool);
6370 TEST_ASSERT(ret == -1,
6371 "Session creation succeeded unexpectedly");
6374 /* Setup HMAC Parameters */
6375 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6376 ut_params->auth_xform.next = NULL;
6378 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6379 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6381 ut_params->sess = rte_cryptodev_sym_session_create(
6382 ts_params->session_mpool);
6384 /* Create Crypto session*/
6385 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6386 ut_params->sess, &ut_params->auth_xform,
6387 ts_params->session_mpool);
6388 TEST_ASSERT(ret == -1,
6389 "Session creation succeeded unexpectedly");
6391 return TEST_SUCCESS;
6395 #define NULL_BURST_LENGTH (32)
6398 test_null_burst_operation(void)
6400 struct crypto_testsuite_params *ts_params = &testsuite_params;
6401 struct crypto_unittest_params *ut_params = &unittest_params;
6403 unsigned i, burst_len = NULL_BURST_LENGTH;
6405 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6406 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6408 /* Setup Cipher Parameters */
6409 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6410 ut_params->cipher_xform.next = &ut_params->auth_xform;
6412 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6413 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6415 /* Setup HMAC Parameters */
6416 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6417 ut_params->auth_xform.next = NULL;
6419 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6420 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6422 ut_params->sess = rte_cryptodev_sym_session_create(
6423 ts_params->session_mpool);
6425 /* Create Crypto session*/
6426 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6427 ut_params->sess, &ut_params->cipher_xform,
6428 ts_params->session_mpool);
6429 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6431 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6432 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6433 burst_len, "failed to generate burst of crypto ops");
6435 /* Generate an operation for each mbuf in burst */
6436 for (i = 0; i < burst_len; i++) {
6437 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6439 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6441 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6445 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6447 burst[i]->sym->m_src = m;
6450 /* Process crypto operation */
6451 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6452 0, burst, burst_len),
6454 "Error enqueuing burst");
6456 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6457 0, burst_dequeued, burst_len),
6459 "Error dequeuing burst");
6462 for (i = 0; i < burst_len; i++) {
6464 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6465 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6467 "data not as expected");
6469 rte_pktmbuf_free(burst[i]->sym->m_src);
6470 rte_crypto_op_free(burst[i]);
6473 return TEST_SUCCESS;
6477 generate_gmac_large_plaintext(uint8_t *data)
6481 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6482 memcpy(&data[i], &data[0], 32);
6486 create_gmac_operation(enum rte_crypto_auth_operation op,
6487 const struct gmac_test_data *tdata)
6489 struct crypto_testsuite_params *ts_params = &testsuite_params;
6490 struct crypto_unittest_params *ut_params = &unittest_params;
6491 struct rte_crypto_sym_op *sym_op;
6493 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6495 /* Generate Crypto op data structure */
6496 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6497 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6498 TEST_ASSERT_NOT_NULL(ut_params->op,
6499 "Failed to allocate symmetric crypto operation struct");
6501 sym_op = ut_params->op->sym;
6503 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6504 ut_params->ibuf, tdata->gmac_tag.len);
6505 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6506 "no room to append digest");
6508 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6509 ut_params->ibuf, plaintext_pad_len);
6511 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6512 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6513 tdata->gmac_tag.len);
6514 TEST_HEXDUMP(stdout, "digest:",
6515 sym_op->auth.digest.data,
6516 tdata->gmac_tag.len);
6519 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6520 uint8_t *, IV_OFFSET);
6522 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6524 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6526 sym_op->cipher.data.length = 0;
6527 sym_op->cipher.data.offset = 0;
6529 sym_op->auth.data.offset = 0;
6530 sym_op->auth.data.length = tdata->plaintext.len;
6535 static int create_gmac_session(uint8_t dev_id,
6536 const struct gmac_test_data *tdata,
6537 enum rte_crypto_auth_operation auth_op)
6539 uint8_t auth_key[tdata->key.len];
6541 struct crypto_testsuite_params *ts_params = &testsuite_params;
6542 struct crypto_unittest_params *ut_params = &unittest_params;
6544 memcpy(auth_key, tdata->key.data, tdata->key.len);
6546 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6547 ut_params->auth_xform.next = NULL;
6549 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6550 ut_params->auth_xform.auth.op = auth_op;
6551 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6552 ut_params->auth_xform.auth.key.length = tdata->key.len;
6553 ut_params->auth_xform.auth.key.data = auth_key;
6554 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6555 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6558 ut_params->sess = rte_cryptodev_sym_session_create(
6559 ts_params->session_mpool);
6561 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6562 &ut_params->auth_xform,
6563 ts_params->session_mpool);
6565 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6571 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6573 struct crypto_testsuite_params *ts_params = &testsuite_params;
6574 struct crypto_unittest_params *ut_params = &unittest_params;
6578 uint8_t *auth_tag, *plaintext;
6579 uint16_t plaintext_pad_len;
6581 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6582 "No GMAC length in the source data");
6584 retval = create_gmac_session(ts_params->valid_devs[0],
6585 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6590 if (tdata->plaintext.len > MBUF_SIZE)
6591 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6593 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6594 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6595 "Failed to allocate input buffer in mempool");
6597 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6598 rte_pktmbuf_tailroom(ut_params->ibuf));
6600 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6602 * Runtime generate the large plain text instead of use hard code
6603 * plain text vector. It is done to avoid create huge source file
6604 * with the test vector.
6606 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6607 generate_gmac_large_plaintext(tdata->plaintext.data);
6609 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6611 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6613 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6614 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6615 tdata->plaintext.len);
6617 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6623 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6625 ut_params->op->sym->m_src = ut_params->ibuf;
6627 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6628 ut_params->op), "failed to process sym crypto op");
6630 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6631 "crypto op processing failed");
6633 if (ut_params->op->sym->m_dst) {
6634 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6635 uint8_t *, plaintext_pad_len);
6637 auth_tag = plaintext + plaintext_pad_len;
6640 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6642 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6644 tdata->gmac_tag.data,
6645 tdata->gmac_tag.len,
6646 "GMAC Generated auth tag not as expected");
6652 test_AES_GMAC_authentication_test_case_1(void)
6654 return test_AES_GMAC_authentication(&gmac_test_case_1);
6658 test_AES_GMAC_authentication_test_case_2(void)
6660 return test_AES_GMAC_authentication(&gmac_test_case_2);
6664 test_AES_GMAC_authentication_test_case_3(void)
6666 return test_AES_GMAC_authentication(&gmac_test_case_3);
6670 test_AES_GMAC_authentication_test_case_4(void)
6672 return test_AES_GMAC_authentication(&gmac_test_case_4);
6676 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6678 struct crypto_testsuite_params *ts_params = &testsuite_params;
6679 struct crypto_unittest_params *ut_params = &unittest_params;
6681 uint32_t plaintext_pad_len;
6684 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6685 "No GMAC length in the source data");
6687 retval = create_gmac_session(ts_params->valid_devs[0],
6688 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6693 if (tdata->plaintext.len > MBUF_SIZE)
6694 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6697 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6698 "Failed to allocate input buffer in mempool");
6700 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6701 rte_pktmbuf_tailroom(ut_params->ibuf));
6703 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6706 * Runtime generate the large plain text instead of use hard code
6707 * plain text vector. It is done to avoid create huge source file
6708 * with the test vector.
6710 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6711 generate_gmac_large_plaintext(tdata->plaintext.data);
6713 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6715 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6717 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6718 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6719 tdata->plaintext.len);
6721 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6727 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6729 ut_params->op->sym->m_src = ut_params->ibuf;
6731 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6732 ut_params->op), "failed to process sym crypto op");
6734 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6735 "crypto op processing failed");
6742 test_AES_GMAC_authentication_verify_test_case_1(void)
6744 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6748 test_AES_GMAC_authentication_verify_test_case_2(void)
6750 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6754 test_AES_GMAC_authentication_verify_test_case_3(void)
6756 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6760 test_AES_GMAC_authentication_verify_test_case_4(void)
6762 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6765 struct test_crypto_vector {
6766 enum rte_crypto_cipher_algorithm crypto_algo;
6779 const uint8_t *data;
6784 const uint8_t *data;
6788 enum rte_crypto_auth_algorithm auth_algo;
6796 const uint8_t *data;
6806 static const struct test_crypto_vector
6807 hmac_sha1_test_crypto_vector = {
6808 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6810 .data = plaintext_hash,
6815 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6816 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6817 0xDE, 0xF4, 0xDE, 0xAD
6823 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6824 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6825 0x3F, 0x91, 0x64, 0x59
6831 static const struct test_crypto_vector
6832 aes128_gmac_test_vector = {
6833 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6835 .data = plaintext_hash,
6840 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6841 0x08, 0x09, 0x0A, 0x0B
6847 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6848 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6854 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6855 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6861 static const struct test_crypto_vector
6862 aes128cbc_hmac_sha1_test_vector = {
6863 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6866 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6867 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6873 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6874 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6879 .data = plaintext_hash,
6883 .data = ciphertext512_aes128cbc,
6886 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6889 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6890 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6891 0xDE, 0xF4, 0xDE, 0xAD
6897 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6898 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6899 0x18, 0x8C, 0x1D, 0x32
6906 data_corruption(uint8_t *data)
6912 tag_corruption(uint8_t *data, unsigned int tag_offset)
6914 data[tag_offset] += 1;
6918 create_auth_session(struct crypto_unittest_params *ut_params,
6920 const struct test_crypto_vector *reference,
6921 enum rte_crypto_auth_operation auth_op)
6923 struct crypto_testsuite_params *ts_params = &testsuite_params;
6924 uint8_t auth_key[reference->auth_key.len + 1];
6926 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6928 /* Setup Authentication Parameters */
6929 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6930 ut_params->auth_xform.auth.op = auth_op;
6931 ut_params->auth_xform.next = NULL;
6932 ut_params->auth_xform.auth.algo = reference->auth_algo;
6933 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6934 ut_params->auth_xform.auth.key.data = auth_key;
6935 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6937 /* Create Crypto session*/
6938 ut_params->sess = rte_cryptodev_sym_session_create(
6939 ts_params->session_mpool);
6941 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6942 &ut_params->auth_xform,
6943 ts_params->session_mpool);
6945 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6951 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6953 const struct test_crypto_vector *reference,
6954 enum rte_crypto_auth_operation auth_op,
6955 enum rte_crypto_cipher_operation cipher_op)
6957 struct crypto_testsuite_params *ts_params = &testsuite_params;
6958 uint8_t cipher_key[reference->cipher_key.len + 1];
6959 uint8_t auth_key[reference->auth_key.len + 1];
6961 memcpy(cipher_key, reference->cipher_key.data,
6962 reference->cipher_key.len);
6963 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6965 /* Setup Authentication Parameters */
6966 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6967 ut_params->auth_xform.auth.op = auth_op;
6968 ut_params->auth_xform.auth.algo = reference->auth_algo;
6969 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6970 ut_params->auth_xform.auth.key.data = auth_key;
6971 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6973 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6974 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6975 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6977 ut_params->auth_xform.next = &ut_params->cipher_xform;
6979 /* Setup Cipher Parameters */
6980 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6981 ut_params->cipher_xform.next = NULL;
6982 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6983 ut_params->cipher_xform.cipher.op = cipher_op;
6984 ut_params->cipher_xform.cipher.key.data = cipher_key;
6985 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6986 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6987 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6990 /* Create Crypto session*/
6991 ut_params->sess = rte_cryptodev_sym_session_create(
6992 ts_params->session_mpool);
6994 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6995 &ut_params->auth_xform,
6996 ts_params->session_mpool);
6998 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7004 create_auth_operation(struct crypto_testsuite_params *ts_params,
7005 struct crypto_unittest_params *ut_params,
7006 const struct test_crypto_vector *reference,
7007 unsigned int auth_generate)
7009 /* Generate Crypto op data structure */
7010 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7011 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7012 TEST_ASSERT_NOT_NULL(ut_params->op,
7013 "Failed to allocate pktmbuf offload");
7015 /* Set crypto operation data parameters */
7016 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7018 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7020 /* set crypto operation source mbuf */
7021 sym_op->m_src = ut_params->ibuf;
7024 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7025 ut_params->ibuf, reference->digest.len);
7027 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7028 "no room to append auth tag");
7030 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7031 ut_params->ibuf, reference->plaintext.len);
7034 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7036 memcpy(sym_op->auth.digest.data,
7037 reference->digest.data,
7038 reference->digest.len);
7040 TEST_HEXDUMP(stdout, "digest:",
7041 sym_op->auth.digest.data,
7042 reference->digest.len);
7044 sym_op->auth.data.length = reference->plaintext.len;
7045 sym_op->auth.data.offset = 0;
7051 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7052 struct crypto_unittest_params *ut_params,
7053 const struct test_crypto_vector *reference,
7054 unsigned int auth_generate)
7056 /* Generate Crypto op data structure */
7057 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7058 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7059 TEST_ASSERT_NOT_NULL(ut_params->op,
7060 "Failed to allocate pktmbuf offload");
7062 /* Set crypto operation data parameters */
7063 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7065 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7067 /* set crypto operation source mbuf */
7068 sym_op->m_src = ut_params->ibuf;
7071 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7072 ut_params->ibuf, reference->digest.len);
7074 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7075 "no room to append auth tag");
7077 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7078 ut_params->ibuf, reference->ciphertext.len);
7081 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7083 memcpy(sym_op->auth.digest.data,
7084 reference->digest.data,
7085 reference->digest.len);
7087 TEST_HEXDUMP(stdout, "digest:",
7088 sym_op->auth.digest.data,
7089 reference->digest.len);
7091 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7092 reference->iv.data, reference->iv.len);
7094 sym_op->cipher.data.length = 0;
7095 sym_op->cipher.data.offset = 0;
7097 sym_op->auth.data.length = reference->plaintext.len;
7098 sym_op->auth.data.offset = 0;
7104 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7105 struct crypto_unittest_params *ut_params,
7106 const struct test_crypto_vector *reference,
7107 unsigned int auth_generate)
7109 /* Generate Crypto op data structure */
7110 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7111 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7112 TEST_ASSERT_NOT_NULL(ut_params->op,
7113 "Failed to allocate pktmbuf offload");
7115 /* Set crypto operation data parameters */
7116 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7118 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7120 /* set crypto operation source mbuf */
7121 sym_op->m_src = ut_params->ibuf;
7124 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7125 ut_params->ibuf, reference->digest.len);
7127 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7128 "no room to append auth tag");
7130 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
7131 ut_params->ibuf, reference->ciphertext.len);
7134 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7136 memcpy(sym_op->auth.digest.data,
7137 reference->digest.data,
7138 reference->digest.len);
7140 TEST_HEXDUMP(stdout, "digest:",
7141 sym_op->auth.digest.data,
7142 reference->digest.len);
7144 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7145 reference->iv.data, reference->iv.len);
7147 sym_op->cipher.data.length = reference->ciphertext.len;
7148 sym_op->cipher.data.offset = 0;
7150 sym_op->auth.data.length = reference->ciphertext.len;
7151 sym_op->auth.data.offset = 0;
7157 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7158 struct crypto_unittest_params *ut_params,
7159 const struct test_crypto_vector *reference)
7161 return create_auth_operation(ts_params, ut_params, reference, 0);
7165 create_auth_verify_GMAC_operation(
7166 struct crypto_testsuite_params *ts_params,
7167 struct crypto_unittest_params *ut_params,
7168 const struct test_crypto_vector *reference)
7170 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7174 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7175 struct crypto_unittest_params *ut_params,
7176 const struct test_crypto_vector *reference)
7178 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7182 test_authentication_verify_fail_when_data_corruption(
7183 struct crypto_testsuite_params *ts_params,
7184 struct crypto_unittest_params *ut_params,
7185 const struct test_crypto_vector *reference,
7186 unsigned int data_corrupted)
7192 /* Create session */
7193 retval = create_auth_session(ut_params,
7194 ts_params->valid_devs[0],
7196 RTE_CRYPTO_AUTH_OP_VERIFY);
7200 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7201 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7202 "Failed to allocate input buffer in mempool");
7204 /* clear mbuf payload */
7205 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7206 rte_pktmbuf_tailroom(ut_params->ibuf));
7208 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7209 reference->plaintext.len);
7210 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7211 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7213 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7215 /* Create operation */
7216 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7222 data_corruption(plaintext);
7224 tag_corruption(plaintext, reference->plaintext.len);
7226 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7229 TEST_ASSERT_EQUAL(ut_params->op->status,
7230 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7231 "authentication not failed");
7233 ut_params->obuf = ut_params->op->sym->m_src;
7234 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7240 test_authentication_verify_GMAC_fail_when_corruption(
7241 struct crypto_testsuite_params *ts_params,
7242 struct crypto_unittest_params *ut_params,
7243 const struct test_crypto_vector *reference,
7244 unsigned int data_corrupted)
7249 /* Create session */
7250 retval = create_auth_cipher_session(ut_params,
7251 ts_params->valid_devs[0],
7253 RTE_CRYPTO_AUTH_OP_VERIFY,
7254 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7258 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7259 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7260 "Failed to allocate input buffer in mempool");
7262 /* clear mbuf payload */
7263 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7264 rte_pktmbuf_tailroom(ut_params->ibuf));
7266 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7267 reference->plaintext.len);
7268 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7269 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7271 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7273 /* Create operation */
7274 retval = create_auth_verify_GMAC_operation(ts_params,
7282 data_corruption(plaintext);
7284 tag_corruption(plaintext, reference->aad.len);
7286 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7288 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7289 TEST_ASSERT_EQUAL(ut_params->op->status,
7290 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7291 "authentication not failed");
7293 ut_params->obuf = ut_params->op->sym->m_src;
7294 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7300 test_authenticated_decryption_fail_when_corruption(
7301 struct crypto_testsuite_params *ts_params,
7302 struct crypto_unittest_params *ut_params,
7303 const struct test_crypto_vector *reference,
7304 unsigned int data_corrupted)
7308 uint8_t *ciphertext;
7310 /* Create session */
7311 retval = create_auth_cipher_session(ut_params,
7312 ts_params->valid_devs[0],
7314 RTE_CRYPTO_AUTH_OP_VERIFY,
7315 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7319 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7320 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7321 "Failed to allocate input buffer in mempool");
7323 /* clear mbuf payload */
7324 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7325 rte_pktmbuf_tailroom(ut_params->ibuf));
7327 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7328 reference->ciphertext.len);
7329 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7330 memcpy(ciphertext, reference->ciphertext.data,
7331 reference->ciphertext.len);
7333 /* Create operation */
7334 retval = create_cipher_auth_verify_operation(ts_params,
7342 data_corruption(ciphertext);
7344 tag_corruption(ciphertext, reference->ciphertext.len);
7346 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7350 TEST_ASSERT_EQUAL(ut_params->op->status,
7351 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7352 "authentication not failed");
7354 ut_params->obuf = ut_params->op->sym->m_src;
7355 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7361 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7362 const struct gcm_test_data *tdata,
7363 void *digest_mem, uint64_t digest_phys)
7365 struct crypto_testsuite_params *ts_params = &testsuite_params;
7366 struct crypto_unittest_params *ut_params = &unittest_params;
7368 const unsigned int auth_tag_len = tdata->auth_tag.len;
7369 const unsigned int iv_len = tdata->iv.len;
7370 const unsigned int aad_len = tdata->aad.len;
7372 /* Generate Crypto op data structure */
7373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7375 TEST_ASSERT_NOT_NULL(ut_params->op,
7376 "Failed to allocate symmetric crypto operation struct");
7378 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7380 sym_op->aead.digest.data = digest_mem;
7382 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7383 "no room to append digest");
7385 sym_op->aead.digest.phys_addr = digest_phys;
7387 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7388 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7390 TEST_HEXDUMP(stdout, "digest:",
7391 sym_op->aead.digest.data,
7395 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7396 uint8_t *, IV_OFFSET);
7398 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7400 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7401 ut_params->ibuf, aad_len);
7402 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7403 "no room to prepend aad");
7404 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7407 memset(sym_op->aead.aad.data, 0, aad_len);
7408 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7410 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7411 TEST_HEXDUMP(stdout, "aad:",
7412 sym_op->aead.aad.data, aad_len);
7414 sym_op->aead.data.length = tdata->plaintext.len;
7415 sym_op->aead.data.offset = aad_len;
7420 #define SGL_MAX_NO 16
7423 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7424 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7426 struct crypto_testsuite_params *ts_params = &testsuite_params;
7427 struct crypto_unittest_params *ut_params = &unittest_params;
7428 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7431 int to_trn_tbl[SGL_MAX_NO];
7433 unsigned int trn_data = 0;
7434 uint8_t *plaintext, *ciphertext, *auth_tag;
7436 if (fragsz > tdata->plaintext.len)
7437 fragsz = tdata->plaintext.len;
7439 uint16_t plaintext_len = fragsz;
7440 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7442 if (fragsz_oop > tdata->plaintext.len)
7443 frag_size_oop = tdata->plaintext.len;
7446 void *digest_mem = NULL;
7448 uint32_t prepend_len = tdata->aad.len;
7450 if (tdata->plaintext.len % fragsz != 0) {
7451 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7454 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7459 * For out-op-place we need to alloc another mbuf
7462 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7463 rte_pktmbuf_append(ut_params->obuf,
7464 frag_size_oop + prepend_len);
7465 buf_oop = ut_params->obuf;
7468 /* Create GCM session */
7469 retval = create_gcm_session(ts_params->valid_devs[0],
7470 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7471 tdata->key.data, tdata->key.len,
7472 tdata->aad.len, tdata->auth_tag.len,
7477 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7479 /* clear mbuf payload */
7480 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7481 rte_pktmbuf_tailroom(ut_params->ibuf));
7483 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7486 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7488 trn_data += plaintext_len;
7490 buf = ut_params->ibuf;
7493 * Loop until no more fragments
7496 while (trn_data < tdata->plaintext.len) {
7498 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7499 (tdata->plaintext.len - trn_data) : fragsz;
7501 to_trn_tbl[ecx++] = to_trn;
7503 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7506 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7507 rte_pktmbuf_tailroom(buf));
7510 if (oop && !fragsz_oop) {
7511 buf_last_oop = buf_oop->next =
7512 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7513 buf_oop = buf_oop->next;
7514 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7515 0, rte_pktmbuf_tailroom(buf_oop));
7516 rte_pktmbuf_append(buf_oop, to_trn);
7519 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7522 memcpy(plaintext, tdata->plaintext.data + trn_data,
7525 if (trn_data == tdata->plaintext.len) {
7528 digest_mem = rte_pktmbuf_append(buf_oop,
7529 tdata->auth_tag.len);
7531 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7532 tdata->auth_tag.len);
7536 uint64_t digest_phys = 0;
7538 ut_params->ibuf->nb_segs = segs;
7541 if (fragsz_oop && oop) {
7545 if (frag_size_oop == tdata->plaintext.len) {
7546 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7547 tdata->auth_tag.len);
7549 digest_phys = rte_pktmbuf_mtophys_offset(
7551 tdata->plaintext.len + prepend_len);
7554 trn_data = frag_size_oop;
7555 while (trn_data < tdata->plaintext.len) {
7558 (tdata->plaintext.len - trn_data <
7560 (tdata->plaintext.len - trn_data) :
7563 to_trn_tbl[ecx++] = to_trn;
7565 buf_last_oop = buf_oop->next =
7566 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7567 buf_oop = buf_oop->next;
7568 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7569 0, rte_pktmbuf_tailroom(buf_oop));
7570 rte_pktmbuf_append(buf_oop, to_trn);
7574 if (trn_data == tdata->plaintext.len) {
7575 digest_mem = rte_pktmbuf_append(buf_oop,
7576 tdata->auth_tag.len);
7580 ut_params->obuf->nb_segs = segs;
7584 * Place digest at the end of the last buffer
7587 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7588 if (oop && buf_last_oop)
7589 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7591 if (!digest_mem && !oop) {
7592 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7593 + tdata->auth_tag.len);
7594 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7595 tdata->plaintext.len);
7598 /* Create GCM opertaion */
7599 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7600 tdata, digest_mem, digest_phys);
7605 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7607 ut_params->op->sym->m_src = ut_params->ibuf;
7609 ut_params->op->sym->m_dst = ut_params->obuf;
7611 /* Process crypto operation */
7612 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7613 ut_params->op), "failed to process sym crypto op");
7615 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7616 "crypto op processing failed");
7619 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7620 uint8_t *, prepend_len);
7622 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7623 uint8_t *, prepend_len);
7627 fragsz = fragsz_oop;
7629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7631 tdata->ciphertext.data,
7633 "GCM Ciphertext data not as expected");
7635 buf = ut_params->op->sym->m_src->next;
7637 buf = ut_params->op->sym->m_dst->next;
7639 unsigned int off = fragsz;
7643 ciphertext = rte_pktmbuf_mtod(buf,
7646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7648 tdata->ciphertext.data + off,
7650 "GCM Ciphertext data not as expected");
7652 off += to_trn_tbl[ecx++];
7656 auth_tag = digest_mem;
7657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7659 tdata->auth_tag.data,
7660 tdata->auth_tag.len,
7661 "GCM Generated auth tag not as expected");
7667 #define OUT_OF_PLACE 1
7670 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7672 return test_AES_GCM_authenticated_encryption_SGL(
7673 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7677 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7679 return test_AES_GCM_authenticated_encryption_SGL(
7680 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7684 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7686 return test_AES_GCM_authenticated_encryption_SGL(
7687 &gcm_test_case_8, OUT_OF_PLACE, 400,
7688 gcm_test_case_8.plaintext.len);
7692 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7695 return test_AES_GCM_authenticated_encryption_SGL(
7696 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7700 test_authentication_verify_fail_when_data_corrupted(
7701 struct crypto_testsuite_params *ts_params,
7702 struct crypto_unittest_params *ut_params,
7703 const struct test_crypto_vector *reference)
7705 return test_authentication_verify_fail_when_data_corruption(
7706 ts_params, ut_params, reference, 1);
7710 test_authentication_verify_fail_when_tag_corrupted(
7711 struct crypto_testsuite_params *ts_params,
7712 struct crypto_unittest_params *ut_params,
7713 const struct test_crypto_vector *reference)
7715 return test_authentication_verify_fail_when_data_corruption(
7716 ts_params, ut_params, reference, 0);
7720 test_authentication_verify_GMAC_fail_when_data_corrupted(
7721 struct crypto_testsuite_params *ts_params,
7722 struct crypto_unittest_params *ut_params,
7723 const struct test_crypto_vector *reference)
7725 return test_authentication_verify_GMAC_fail_when_corruption(
7726 ts_params, ut_params, reference, 1);
7730 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7731 struct crypto_testsuite_params *ts_params,
7732 struct crypto_unittest_params *ut_params,
7733 const struct test_crypto_vector *reference)
7735 return test_authentication_verify_GMAC_fail_when_corruption(
7736 ts_params, ut_params, reference, 0);
7740 test_authenticated_decryption_fail_when_data_corrupted(
7741 struct crypto_testsuite_params *ts_params,
7742 struct crypto_unittest_params *ut_params,
7743 const struct test_crypto_vector *reference)
7745 return test_authenticated_decryption_fail_when_corruption(
7746 ts_params, ut_params, reference, 1);
7750 test_authenticated_decryption_fail_when_tag_corrupted(
7751 struct crypto_testsuite_params *ts_params,
7752 struct crypto_unittest_params *ut_params,
7753 const struct test_crypto_vector *reference)
7755 return test_authenticated_decryption_fail_when_corruption(
7756 ts_params, ut_params, reference, 0);
7760 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7762 return test_authentication_verify_fail_when_data_corrupted(
7763 &testsuite_params, &unittest_params,
7764 &hmac_sha1_test_crypto_vector);
7768 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7770 return test_authentication_verify_fail_when_tag_corrupted(
7771 &testsuite_params, &unittest_params,
7772 &hmac_sha1_test_crypto_vector);
7776 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7778 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7779 &testsuite_params, &unittest_params,
7780 &aes128_gmac_test_vector);
7784 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7786 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7787 &testsuite_params, &unittest_params,
7788 &aes128_gmac_test_vector);
7792 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7794 return test_authenticated_decryption_fail_when_data_corrupted(
7797 &aes128cbc_hmac_sha1_test_vector);
7801 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7803 return test_authenticated_decryption_fail_when_tag_corrupted(
7806 &aes128cbc_hmac_sha1_test_vector);
7809 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7811 /* global AESNI slave IDs for the scheduler test */
7812 uint8_t aesni_ids[2];
7815 test_scheduler_attach_slave_op(void)
7817 struct crypto_testsuite_params *ts_params = &testsuite_params;
7818 uint8_t sched_id = ts_params->valid_devs[0];
7819 uint32_t nb_devs, i, nb_devs_attached = 0;
7823 /* create 2 AESNI_MB if necessary */
7824 nb_devs = rte_cryptodev_device_count_by_driver(
7825 rte_cryptodev_driver_id_get(
7826 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
7828 for (i = nb_devs; i < 2; i++) {
7829 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7830 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7832 ret = rte_vdev_init(vdev_name, NULL);
7834 TEST_ASSERT(ret == 0,
7835 "Failed to create instance %u of"
7837 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7841 /* attach 2 AESNI_MB cdevs */
7842 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7844 struct rte_cryptodev_info info;
7846 rte_cryptodev_info_get(i, &info);
7847 if (info.driver_id != rte_cryptodev_driver_id_get(
7848 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
7852 * Create the session mempool again, since now there are new devices
7853 * to use the mempool.
7855 if (ts_params->session_mpool) {
7856 rte_mempool_free(ts_params->session_mpool);
7857 ts_params->session_mpool = NULL;
7859 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
7862 * Create mempool with maximum number of sessions * 2,
7863 * to include the session headers
7865 if (ts_params->session_mpool == NULL) {
7866 ts_params->session_mpool = rte_mempool_create(
7868 info.sym.max_nb_sessions * 2,
7870 0, 0, NULL, NULL, NULL,
7871 NULL, SOCKET_ID_ANY,
7874 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
7875 "session mempool allocation failed");
7878 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7881 TEST_ASSERT(ret == 0,
7882 "Failed to attach device %u of pmd : %s", i,
7883 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7885 aesni_ids[nb_devs_attached] = (uint8_t)i;
7894 test_scheduler_detach_slave_op(void)
7896 struct crypto_testsuite_params *ts_params = &testsuite_params;
7897 uint8_t sched_id = ts_params->valid_devs[0];
7901 for (i = 0; i < 2; i++) {
7902 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7904 TEST_ASSERT(ret == 0,
7905 "Failed to detach device %u", aesni_ids[i]);
7912 test_scheduler_mode_op(void)
7914 struct crypto_testsuite_params *ts_params = &testsuite_params;
7915 uint8_t sched_id = ts_params->valid_devs[0];
7916 struct rte_cryptodev_scheduler_ops op = {0};
7917 struct rte_cryptodev_scheduler dummy_scheduler = {
7918 .description = "dummy scheduler to test mode",
7919 .name = "dummy scheduler",
7920 .mode = CDEV_SCHED_MODE_USERDEFINED,
7925 /* set user defined mode */
7926 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7928 TEST_ASSERT(ret == 0,
7929 "Failed to set cdev %u to user defined mode", sched_id);
7931 /* set round robin mode */
7932 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7933 CDEV_SCHED_MODE_ROUNDROBIN);
7934 TEST_ASSERT(ret == 0,
7935 "Failed to set cdev %u to round-robin mode", sched_id);
7936 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7937 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7943 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7944 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7945 .setup = testsuite_setup,
7946 .teardown = testsuite_teardown,
7947 .unit_test_cases = {
7948 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7949 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_AES_chain_scheduler_all),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_AES_cipheronly_scheduler_all),
7954 TEST_CASE_ST(ut_setup, ut_teardown,
7955 test_authonly_scheduler_all),
7956 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7957 TEST_CASES_END() /**< NULL terminate unit test array */
7961 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7963 static struct unit_test_suite cryptodev_qat_testsuite = {
7964 .suite_name = "Crypto QAT Unit Test Suite",
7965 .setup = testsuite_setup,
7966 .teardown = testsuite_teardown,
7967 .unit_test_cases = {
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_device_configure_invalid_dev_id),
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_device_configure_invalid_queue_pair_ids),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_queue_pair_descriptor_setup),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_multi_session),
7977 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_AES_cipheronly_qat_all),
7980 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7981 TEST_CASE_ST(ut_setup, ut_teardown,
7982 test_3DES_cipheronly_qat_all),
7983 TEST_CASE_ST(ut_setup, ut_teardown,
7984 test_DES_cipheronly_qat_all),
7985 TEST_CASE_ST(ut_setup, ut_teardown,
7986 test_AES_docsis_qat_all),
7987 TEST_CASE_ST(ut_setup, ut_teardown,
7988 test_DES_docsis_qat_all),
7989 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7991 /** AES GCM Authenticated Encryption */
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7994 TEST_CASE_ST(ut_setup, ut_teardown,
7995 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_AES_GCM_authenticated_encryption_test_case_1),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_AES_GCM_authenticated_encryption_test_case_2),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_AES_GCM_authenticated_encryption_test_case_3),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_AES_GCM_authenticated_encryption_test_case_4),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_AES_GCM_authenticated_encryption_test_case_5),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_AES_GCM_authenticated_encryption_test_case_6),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_AES_GCM_authenticated_encryption_test_case_7),
8013 /** AES GCM Authenticated Decryption */
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_AES_GCM_authenticated_decryption_test_case_1),
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_AES_GCM_authenticated_decryption_test_case_2),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_AES_GCM_authenticated_decryption_test_case_3),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 test_AES_GCM_authenticated_decryption_test_case_4),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_AES_GCM_authenticated_decryption_test_case_5),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 test_AES_GCM_authenticated_decryption_test_case_6),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_AES_GCM_authenticated_decryption_test_case_7),
8029 /** AES GCM Authenticated Encryption 192 bits key */
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_AES_GCM_auth_encryption_test_case_192_1),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_AES_GCM_auth_encryption_test_case_192_2),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_AES_GCM_auth_encryption_test_case_192_3),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_AES_GCM_auth_encryption_test_case_192_4),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_AES_GCM_auth_encryption_test_case_192_5),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_AES_GCM_auth_encryption_test_case_192_6),
8042 TEST_CASE_ST(ut_setup, ut_teardown,
8043 test_AES_GCM_auth_encryption_test_case_192_7),
8045 /** AES GCM Authenticated Decryption 192 bits key */
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_AES_GCM_auth_decryption_test_case_192_1),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_AES_GCM_auth_decryption_test_case_192_2),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_AES_GCM_auth_decryption_test_case_192_3),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_AES_GCM_auth_decryption_test_case_192_4),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_AES_GCM_auth_decryption_test_case_192_5),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_AES_GCM_auth_decryption_test_case_192_6),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_AES_GCM_auth_decryption_test_case_192_7),
8061 /** AES GCM Authenticated Encryption 256 bits key */
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_AES_GCM_auth_encryption_test_case_256_1),
8064 TEST_CASE_ST(ut_setup, ut_teardown,
8065 test_AES_GCM_auth_encryption_test_case_256_2),
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 test_AES_GCM_auth_encryption_test_case_256_3),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 test_AES_GCM_auth_encryption_test_case_256_4),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 test_AES_GCM_auth_encryption_test_case_256_5),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 test_AES_GCM_auth_encryption_test_case_256_6),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 test_AES_GCM_auth_encryption_test_case_256_7),
8077 /** AES GMAC Authentication */
8078 TEST_CASE_ST(ut_setup, ut_teardown,
8079 test_AES_GMAC_authentication_test_case_1),
8080 TEST_CASE_ST(ut_setup, ut_teardown,
8081 test_AES_GMAC_authentication_verify_test_case_1),
8082 TEST_CASE_ST(ut_setup, ut_teardown,
8083 test_AES_GMAC_authentication_test_case_2),
8084 TEST_CASE_ST(ut_setup, ut_teardown,
8085 test_AES_GMAC_authentication_verify_test_case_2),
8086 TEST_CASE_ST(ut_setup, ut_teardown,
8087 test_AES_GMAC_authentication_test_case_3),
8088 TEST_CASE_ST(ut_setup, ut_teardown,
8089 test_AES_GMAC_authentication_verify_test_case_3),
8091 /** SNOW 3G encrypt only (UEA2) */
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_snow3g_encryption_test_case_1),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_snow3g_encryption_test_case_2),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_snow3g_encryption_test_case_3),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_snow3g_encryption_test_case_4),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_snow3g_encryption_test_case_5),
8103 TEST_CASE_ST(ut_setup, ut_teardown,
8104 test_snow3g_encryption_test_case_1_oop),
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 test_snow3g_decryption_test_case_1_oop),
8108 /** SNOW 3G decrypt only (UEA2) */
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 test_snow3g_decryption_test_case_1),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 test_snow3g_decryption_test_case_2),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_snow3g_decryption_test_case_3),
8115 TEST_CASE_ST(ut_setup, ut_teardown,
8116 test_snow3g_decryption_test_case_4),
8117 TEST_CASE_ST(ut_setup, ut_teardown,
8118 test_snow3g_decryption_test_case_5),
8119 TEST_CASE_ST(ut_setup, ut_teardown,
8120 test_snow3g_hash_generate_test_case_1),
8121 TEST_CASE_ST(ut_setup, ut_teardown,
8122 test_snow3g_hash_generate_test_case_2),
8123 TEST_CASE_ST(ut_setup, ut_teardown,
8124 test_snow3g_hash_generate_test_case_3),
8125 TEST_CASE_ST(ut_setup, ut_teardown,
8126 test_snow3g_hash_verify_test_case_1),
8127 TEST_CASE_ST(ut_setup, ut_teardown,
8128 test_snow3g_hash_verify_test_case_2),
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 test_snow3g_hash_verify_test_case_3),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 test_snow3g_cipher_auth_test_case_1),
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 test_snow3g_auth_cipher_test_case_1),
8136 /** ZUC encrypt only (EEA3) */
8137 TEST_CASE_ST(ut_setup, ut_teardown,
8138 test_zuc_encryption_test_case_1),
8139 TEST_CASE_ST(ut_setup, ut_teardown,
8140 test_zuc_encryption_test_case_2),
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_zuc_encryption_test_case_3),
8143 TEST_CASE_ST(ut_setup, ut_teardown,
8144 test_zuc_encryption_test_case_4),
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_zuc_encryption_test_case_5),
8148 /** ZUC authenticate (EIA3) */
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_zuc_hash_generate_test_case_6),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_zuc_hash_generate_test_case_7),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_zuc_hash_generate_test_case_8),
8156 /** ZUC alg-chain (EEA3/EIA3) */
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_zuc_cipher_auth_test_case_1),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_zuc_cipher_auth_test_case_2),
8162 /** HMAC_MD5 Authentication */
8163 TEST_CASE_ST(ut_setup, ut_teardown,
8164 test_MD5_HMAC_generate_case_1),
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_MD5_HMAC_verify_case_1),
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_MD5_HMAC_generate_case_2),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_MD5_HMAC_verify_case_2),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_null_auth_only_operation),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_null_cipher_only_operation),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_null_cipher_auth_operation),
8179 TEST_CASE_ST(ut_setup, ut_teardown,
8180 test_null_auth_cipher_operation),
8182 TEST_CASE_ST(ut_setup, ut_teardown,
8183 test_kasumi_hash_generate_test_case_6),
8186 TEST_CASE_ST(ut_setup, ut_teardown,
8187 test_kasumi_encryption_test_case_1),
8188 TEST_CASE_ST(ut_setup, ut_teardown,
8189 test_kasumi_encryption_test_case_3),
8190 TEST_CASE_ST(ut_setup, ut_teardown,
8191 test_kasumi_auth_cipher_test_case_1),
8192 TEST_CASE_ST(ut_setup, ut_teardown,
8193 test_kasumi_cipher_auth_test_case_1),
8195 /** Negative tests */
8196 TEST_CASE_ST(ut_setup, ut_teardown,
8197 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8200 TEST_CASE_ST(ut_setup, ut_teardown,
8201 authentication_verify_AES128_GMAC_fail_data_corrupt),
8202 TEST_CASE_ST(ut_setup, ut_teardown,
8203 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8204 TEST_CASE_ST(ut_setup, ut_teardown,
8205 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8206 TEST_CASE_ST(ut_setup, ut_teardown,
8207 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8209 TEST_CASES_END() /**< NULL terminate unit test array */
8213 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8214 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8215 .setup = testsuite_setup,
8216 .teardown = testsuite_teardown,
8217 .unit_test_cases = {
8218 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8219 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8220 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8221 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8223 TEST_CASES_END() /**< NULL terminate unit test array */
8227 static struct unit_test_suite cryptodev_openssl_testsuite = {
8228 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8229 .setup = testsuite_setup,
8230 .teardown = testsuite_teardown,
8231 .unit_test_cases = {
8232 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 test_multi_session_random_usage),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_AES_chain_openssl_all),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_AES_cipheronly_openssl_all),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_3DES_chain_openssl_all),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 test_3DES_cipheronly_openssl_all),
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_DES_docsis_openssl_all),
8245 TEST_CASE_ST(ut_setup, ut_teardown,
8246 test_authonly_openssl_all),
8248 /** AES GCM Authenticated Encryption */
8249 TEST_CASE_ST(ut_setup, ut_teardown,
8250 test_AES_GCM_authenticated_encryption_test_case_1),
8251 TEST_CASE_ST(ut_setup, ut_teardown,
8252 test_AES_GCM_authenticated_encryption_test_case_2),
8253 TEST_CASE_ST(ut_setup, ut_teardown,
8254 test_AES_GCM_authenticated_encryption_test_case_3),
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_AES_GCM_authenticated_encryption_test_case_4),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_AES_GCM_authenticated_encryption_test_case_5),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_AES_GCM_authenticated_encryption_test_case_6),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_AES_GCM_authenticated_encryption_test_case_7),
8264 /** AES GCM Authenticated Decryption */
8265 TEST_CASE_ST(ut_setup, ut_teardown,
8266 test_AES_GCM_authenticated_decryption_test_case_1),
8267 TEST_CASE_ST(ut_setup, ut_teardown,
8268 test_AES_GCM_authenticated_decryption_test_case_2),
8269 TEST_CASE_ST(ut_setup, ut_teardown,
8270 test_AES_GCM_authenticated_decryption_test_case_3),
8271 TEST_CASE_ST(ut_setup, ut_teardown,
8272 test_AES_GCM_authenticated_decryption_test_case_4),
8273 TEST_CASE_ST(ut_setup, ut_teardown,
8274 test_AES_GCM_authenticated_decryption_test_case_5),
8275 TEST_CASE_ST(ut_setup, ut_teardown,
8276 test_AES_GCM_authenticated_decryption_test_case_6),
8277 TEST_CASE_ST(ut_setup, ut_teardown,
8278 test_AES_GCM_authenticated_decryption_test_case_7),
8281 /** AES GCM Authenticated Encryption 192 bits key */
8282 TEST_CASE_ST(ut_setup, ut_teardown,
8283 test_AES_GCM_auth_encryption_test_case_192_1),
8284 TEST_CASE_ST(ut_setup, ut_teardown,
8285 test_AES_GCM_auth_encryption_test_case_192_2),
8286 TEST_CASE_ST(ut_setup, ut_teardown,
8287 test_AES_GCM_auth_encryption_test_case_192_3),
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_AES_GCM_auth_encryption_test_case_192_4),
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_AES_GCM_auth_encryption_test_case_192_5),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_AES_GCM_auth_encryption_test_case_192_6),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_AES_GCM_auth_encryption_test_case_192_7),
8297 /** AES GCM Authenticated Decryption 192 bits key */
8298 TEST_CASE_ST(ut_setup, ut_teardown,
8299 test_AES_GCM_auth_decryption_test_case_192_1),
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_AES_GCM_auth_decryption_test_case_192_2),
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_AES_GCM_auth_decryption_test_case_192_3),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_AES_GCM_auth_decryption_test_case_192_4),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_AES_GCM_auth_decryption_test_case_192_5),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_AES_GCM_auth_decryption_test_case_192_6),
8310 TEST_CASE_ST(ut_setup, ut_teardown,
8311 test_AES_GCM_auth_decryption_test_case_192_7),
8313 /** AES GCM Authenticated Encryption 256 bits key */
8314 TEST_CASE_ST(ut_setup, ut_teardown,
8315 test_AES_GCM_auth_encryption_test_case_256_1),
8316 TEST_CASE_ST(ut_setup, ut_teardown,
8317 test_AES_GCM_auth_encryption_test_case_256_2),
8318 TEST_CASE_ST(ut_setup, ut_teardown,
8319 test_AES_GCM_auth_encryption_test_case_256_3),
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_AES_GCM_auth_encryption_test_case_256_4),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_AES_GCM_auth_encryption_test_case_256_5),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_AES_GCM_auth_encryption_test_case_256_6),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_AES_GCM_auth_encryption_test_case_256_7),
8329 /** AES GCM Authenticated Decryption 256 bits key */
8330 TEST_CASE_ST(ut_setup, ut_teardown,
8331 test_AES_GCM_auth_decryption_test_case_256_1),
8332 TEST_CASE_ST(ut_setup, ut_teardown,
8333 test_AES_GCM_auth_decryption_test_case_256_2),
8334 TEST_CASE_ST(ut_setup, ut_teardown,
8335 test_AES_GCM_auth_decryption_test_case_256_3),
8336 TEST_CASE_ST(ut_setup, ut_teardown,
8337 test_AES_GCM_auth_decryption_test_case_256_4),
8338 TEST_CASE_ST(ut_setup, ut_teardown,
8339 test_AES_GCM_auth_decryption_test_case_256_5),
8340 TEST_CASE_ST(ut_setup, ut_teardown,
8341 test_AES_GCM_auth_decryption_test_case_256_6),
8342 TEST_CASE_ST(ut_setup, ut_teardown,
8343 test_AES_GCM_auth_decryption_test_case_256_7),
8345 /** AES GMAC Authentication */
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_AES_GMAC_authentication_test_case_1),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_AES_GMAC_authentication_verify_test_case_1),
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_AES_GMAC_authentication_test_case_2),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_AES_GMAC_authentication_verify_test_case_2),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_AES_GMAC_authentication_test_case_3),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_AES_GMAC_authentication_verify_test_case_3),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_AES_GMAC_authentication_test_case_4),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_AES_GMAC_authentication_verify_test_case_4),
8363 /** Scatter-Gather */
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8367 /** Negative tests */
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8370 TEST_CASE_ST(ut_setup, ut_teardown,
8371 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8372 TEST_CASE_ST(ut_setup, ut_teardown,
8373 authentication_verify_AES128_GMAC_fail_data_corrupt),
8374 TEST_CASE_ST(ut_setup, ut_teardown,
8375 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8376 TEST_CASE_ST(ut_setup, ut_teardown,
8377 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8381 TEST_CASES_END() /**< NULL terminate unit test array */
8385 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8386 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8387 .setup = testsuite_setup,
8388 .teardown = testsuite_teardown,
8389 .unit_test_cases = {
8390 /** AES GCM Authenticated Encryption */
8391 TEST_CASE_ST(ut_setup, ut_teardown,
8392 test_AES_GCM_authenticated_encryption_test_case_1),
8393 TEST_CASE_ST(ut_setup, ut_teardown,
8394 test_AES_GCM_authenticated_encryption_test_case_2),
8395 TEST_CASE_ST(ut_setup, ut_teardown,
8396 test_AES_GCM_authenticated_encryption_test_case_3),
8397 TEST_CASE_ST(ut_setup, ut_teardown,
8398 test_AES_GCM_authenticated_encryption_test_case_4),
8399 TEST_CASE_ST(ut_setup, ut_teardown,
8400 test_AES_GCM_authenticated_encryption_test_case_5),
8401 TEST_CASE_ST(ut_setup, ut_teardown,
8402 test_AES_GCM_authenticated_encryption_test_case_6),
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_AES_GCM_authenticated_encryption_test_case_7),
8406 /** AES GCM Authenticated Decryption */
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_AES_GCM_authenticated_decryption_test_case_1),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_AES_GCM_authenticated_decryption_test_case_2),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_AES_GCM_authenticated_decryption_test_case_3),
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 test_AES_GCM_authenticated_decryption_test_case_4),
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_AES_GCM_authenticated_decryption_test_case_5),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_AES_GCM_authenticated_decryption_test_case_6),
8419 TEST_CASE_ST(ut_setup, ut_teardown,
8420 test_AES_GCM_authenticated_decryption_test_case_7),
8422 /** AES GCM Authenticated Encryption 192 bits key */
8423 TEST_CASE_ST(ut_setup, ut_teardown,
8424 test_AES_GCM_auth_encryption_test_case_192_1),
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_AES_GCM_auth_encryption_test_case_192_2),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_AES_GCM_auth_encryption_test_case_192_3),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_AES_GCM_auth_encryption_test_case_192_4),
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_AES_GCM_auth_encryption_test_case_192_5),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_AES_GCM_auth_encryption_test_case_192_6),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_AES_GCM_auth_encryption_test_case_192_7),
8438 /** AES GCM Authenticated Decryption 192 bits key */
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_AES_GCM_auth_decryption_test_case_192_1),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_AES_GCM_auth_decryption_test_case_192_2),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_AES_GCM_auth_decryption_test_case_192_3),
8445 TEST_CASE_ST(ut_setup, ut_teardown,
8446 test_AES_GCM_auth_decryption_test_case_192_4),
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_AES_GCM_auth_decryption_test_case_192_5),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_AES_GCM_auth_decryption_test_case_192_6),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_AES_GCM_auth_decryption_test_case_192_7),
8454 /** AES GCM Authenticated Encryption 256 bits key */
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_AES_GCM_auth_encryption_test_case_256_1),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_AES_GCM_auth_encryption_test_case_256_2),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_AES_GCM_auth_encryption_test_case_256_3),
8461 TEST_CASE_ST(ut_setup, ut_teardown,
8462 test_AES_GCM_auth_encryption_test_case_256_4),
8463 TEST_CASE_ST(ut_setup, ut_teardown,
8464 test_AES_GCM_auth_encryption_test_case_256_5),
8465 TEST_CASE_ST(ut_setup, ut_teardown,
8466 test_AES_GCM_auth_encryption_test_case_256_6),
8467 TEST_CASE_ST(ut_setup, ut_teardown,
8468 test_AES_GCM_auth_encryption_test_case_256_7),
8470 /** AES GCM Authenticated Decryption 256 bits key */
8471 TEST_CASE_ST(ut_setup, ut_teardown,
8472 test_AES_GCM_auth_decryption_test_case_256_1),
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_AES_GCM_auth_decryption_test_case_256_2),
8475 TEST_CASE_ST(ut_setup, ut_teardown,
8476 test_AES_GCM_auth_decryption_test_case_256_3),
8477 TEST_CASE_ST(ut_setup, ut_teardown,
8478 test_AES_GCM_auth_decryption_test_case_256_4),
8479 TEST_CASE_ST(ut_setup, ut_teardown,
8480 test_AES_GCM_auth_decryption_test_case_256_5),
8481 TEST_CASE_ST(ut_setup, ut_teardown,
8482 test_AES_GCM_auth_decryption_test_case_256_6),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_AES_GCM_auth_decryption_test_case_256_7),
8486 /** AES GCM Authenticated Encryption big aad size */
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_AES_GCM_auth_encryption_test_case_aad_1),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_AES_GCM_auth_encryption_test_case_aad_2),
8492 /** AES GCM Authenticated Decryption big aad size */
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_AES_GCM_auth_decryption_test_case_aad_1),
8495 TEST_CASE_ST(ut_setup, ut_teardown,
8496 test_AES_GCM_auth_decryption_test_case_aad_2),
8498 /** AES GMAC Authentication */
8499 TEST_CASE_ST(ut_setup, ut_teardown,
8500 test_AES_GMAC_authentication_test_case_1),
8501 TEST_CASE_ST(ut_setup, ut_teardown,
8502 test_AES_GMAC_authentication_verify_test_case_1),
8503 TEST_CASE_ST(ut_setup, ut_teardown,
8504 test_AES_GMAC_authentication_test_case_3),
8505 TEST_CASE_ST(ut_setup, ut_teardown,
8506 test_AES_GMAC_authentication_verify_test_case_3),
8507 TEST_CASE_ST(ut_setup, ut_teardown,
8508 test_AES_GMAC_authentication_test_case_4),
8509 TEST_CASE_ST(ut_setup, ut_teardown,
8510 test_AES_GMAC_authentication_verify_test_case_4),
8512 /** Negative tests */
8513 TEST_CASE_ST(ut_setup, ut_teardown,
8514 authentication_verify_AES128_GMAC_fail_data_corrupt),
8515 TEST_CASE_ST(ut_setup, ut_teardown,
8516 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8518 /** Out of place tests */
8519 TEST_CASE_ST(ut_setup, ut_teardown,
8520 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8521 TEST_CASE_ST(ut_setup, ut_teardown,
8522 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8524 /** Session-less tests */
8525 TEST_CASE_ST(ut_setup, ut_teardown,
8526 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8527 TEST_CASE_ST(ut_setup, ut_teardown,
8528 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8530 /** Scatter-Gather */
8531 TEST_CASE_ST(ut_setup, ut_teardown,
8532 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8534 TEST_CASES_END() /**< NULL terminate unit test array */
8538 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8539 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8540 .setup = testsuite_setup,
8541 .teardown = testsuite_teardown,
8542 .unit_test_cases = {
8543 /** KASUMI encrypt only (UEA1) */
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_kasumi_encryption_test_case_1),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_kasumi_encryption_test_case_1_sgl),
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_kasumi_encryption_test_case_2),
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_kasumi_encryption_test_case_3),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_kasumi_encryption_test_case_4),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_kasumi_encryption_test_case_5),
8556 /** KASUMI decrypt only (UEA1) */
8557 TEST_CASE_ST(ut_setup, ut_teardown,
8558 test_kasumi_decryption_test_case_1),
8559 TEST_CASE_ST(ut_setup, ut_teardown,
8560 test_kasumi_decryption_test_case_2),
8561 TEST_CASE_ST(ut_setup, ut_teardown,
8562 test_kasumi_decryption_test_case_3),
8563 TEST_CASE_ST(ut_setup, ut_teardown,
8564 test_kasumi_decryption_test_case_4),
8565 TEST_CASE_ST(ut_setup, ut_teardown,
8566 test_kasumi_decryption_test_case_5),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_kasumi_encryption_test_case_1_oop),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_kasumi_encryption_test_case_1_oop_sgl),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_kasumi_decryption_test_case_1_oop),
8577 /** KASUMI hash only (UIA1) */
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_kasumi_hash_generate_test_case_1),
8580 TEST_CASE_ST(ut_setup, ut_teardown,
8581 test_kasumi_hash_generate_test_case_2),
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_kasumi_hash_generate_test_case_3),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_kasumi_hash_generate_test_case_4),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_kasumi_hash_generate_test_case_5),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_kasumi_hash_generate_test_case_6),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_kasumi_hash_verify_test_case_1),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_kasumi_hash_verify_test_case_2),
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_kasumi_hash_verify_test_case_3),
8596 TEST_CASE_ST(ut_setup, ut_teardown,
8597 test_kasumi_hash_verify_test_case_4),
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_kasumi_hash_verify_test_case_5),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_kasumi_auth_cipher_test_case_1),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_kasumi_cipher_auth_test_case_1),
8604 TEST_CASES_END() /**< NULL terminate unit test array */
8607 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8608 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8609 .setup = testsuite_setup,
8610 .teardown = testsuite_teardown,
8611 .unit_test_cases = {
8612 /** SNOW 3G encrypt only (UEA2) */
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_snow3g_encryption_test_case_1),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_snow3g_encryption_test_case_2),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_snow3g_encryption_test_case_3),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_snow3g_encryption_test_case_4),
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_snow3g_encryption_test_case_5),
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_snow3g_encryption_test_case_1_oop),
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_snow3g_encryption_test_case_1_oop_sgl),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_snow3g_decryption_test_case_1_oop),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_snow3g_encryption_test_case_1_offset_oop),
8634 /** SNOW 3G decrypt only (UEA2) */
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_snow3g_decryption_test_case_1),
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_snow3g_decryption_test_case_2),
8639 TEST_CASE_ST(ut_setup, ut_teardown,
8640 test_snow3g_decryption_test_case_3),
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_snow3g_decryption_test_case_4),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_snow3g_decryption_test_case_5),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_snow3g_hash_generate_test_case_1),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_snow3g_hash_generate_test_case_2),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_snow3g_hash_generate_test_case_3),
8651 /* Tests with buffers which length is not byte-aligned */
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_snow3g_hash_generate_test_case_4),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_snow3g_hash_generate_test_case_5),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_snow3g_hash_generate_test_case_6),
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_snow3g_hash_verify_test_case_1),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_snow3g_hash_verify_test_case_2),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_snow3g_hash_verify_test_case_3),
8664 /* Tests with buffers which length is not byte-aligned */
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_snow3g_hash_verify_test_case_4),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_snow3g_hash_verify_test_case_5),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_snow3g_hash_verify_test_case_6),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_snow3g_cipher_auth_test_case_1),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_snow3g_auth_cipher_test_case_1),
8676 TEST_CASES_END() /**< NULL terminate unit test array */
8680 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8681 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8682 .setup = testsuite_setup,
8683 .teardown = testsuite_teardown,
8684 .unit_test_cases = {
8685 /** ZUC encrypt only (EEA3) */
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_zuc_encryption_test_case_1),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_zuc_encryption_test_case_2),
8690 TEST_CASE_ST(ut_setup, ut_teardown,
8691 test_zuc_encryption_test_case_3),
8692 TEST_CASE_ST(ut_setup, ut_teardown,
8693 test_zuc_encryption_test_case_4),
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_zuc_encryption_test_case_5),
8696 TEST_CASE_ST(ut_setup, ut_teardown,
8697 test_zuc_hash_generate_test_case_1),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_zuc_hash_generate_test_case_2),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_zuc_hash_generate_test_case_3),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_zuc_hash_generate_test_case_4),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_zuc_hash_generate_test_case_5),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_zuc_encryption_test_case_6_sgl),
8708 TEST_CASES_END() /**< NULL terminate unit test array */
8712 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8713 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8714 .setup = testsuite_setup,
8715 .teardown = testsuite_teardown,
8716 .unit_test_cases = {
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_device_configure_invalid_dev_id),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_multi_session),
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 test_AES_chain_dpaa2_sec_all),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 test_3DES_chain_dpaa2_sec_all),
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 test_AES_cipheronly_dpaa2_sec_all),
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 test_3DES_cipheronly_dpaa2_sec_all),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_authonly_dpaa2_sec_all),
8733 /** AES GCM Authenticated Encryption */
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_GCM_authenticated_encryption_test_case_1),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_AES_GCM_authenticated_encryption_test_case_2),
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_AES_GCM_authenticated_encryption_test_case_3),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_AES_GCM_authenticated_encryption_test_case_4),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_AES_GCM_authenticated_encryption_test_case_5),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_GCM_authenticated_encryption_test_case_6),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_AES_GCM_authenticated_encryption_test_case_7),
8749 /** AES GCM Authenticated Decryption */
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GCM_authenticated_decryption_test_case_1),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_GCM_authenticated_decryption_test_case_2),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_GCM_authenticated_decryption_test_case_3),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_AES_GCM_authenticated_decryption_test_case_4),
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_AES_GCM_authenticated_decryption_test_case_5),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_GCM_authenticated_decryption_test_case_6),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_GCM_authenticated_decryption_test_case_7),
8765 /** AES GCM Authenticated Encryption 192 bits key */
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_auth_encryption_test_case_192_1),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_auth_encryption_test_case_192_2),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_auth_encryption_test_case_192_3),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_GCM_auth_encryption_test_case_192_4),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_auth_encryption_test_case_192_5),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_auth_encryption_test_case_192_6),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_auth_encryption_test_case_192_7),
8781 /** AES GCM Authenticated Decryption 192 bits key */
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_auth_decryption_test_case_192_1),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_auth_decryption_test_case_192_2),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_auth_decryption_test_case_192_3),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_auth_decryption_test_case_192_4),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_auth_decryption_test_case_192_5),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_auth_decryption_test_case_192_6),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_auth_decryption_test_case_192_7),
8797 /** AES GCM Authenticated Encryption 256 bits key */
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_auth_encryption_test_case_256_1),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_auth_encryption_test_case_256_2),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_auth_encryption_test_case_256_3),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_AES_GCM_auth_encryption_test_case_256_4),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_auth_encryption_test_case_256_5),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_auth_encryption_test_case_256_6),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_256_7),
8813 /** AES GCM Authenticated Decryption 256 bits key */
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_decryption_test_case_256_1),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_decryption_test_case_256_2),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_decryption_test_case_256_3),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_AES_GCM_auth_decryption_test_case_256_4),
8822 TEST_CASE_ST(ut_setup, ut_teardown,
8823 test_AES_GCM_auth_decryption_test_case_256_5),
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GCM_auth_decryption_test_case_256_6),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_auth_decryption_test_case_256_7),
8829 TEST_CASES_END() /**< NULL terminate unit test array */
8833 static struct unit_test_suite cryptodev_null_testsuite = {
8834 .suite_name = "Crypto Device NULL Unit Test Suite",
8835 .setup = testsuite_setup,
8836 .teardown = testsuite_teardown,
8837 .unit_test_cases = {
8838 TEST_CASE_ST(ut_setup, ut_teardown,
8839 test_null_auth_only_operation),
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_null_cipher_only_operation),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_null_cipher_auth_operation),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_null_auth_cipher_operation),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_null_invalid_operation),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_null_burst_operation),
8851 TEST_CASES_END() /**< NULL terminate unit test array */
8855 static struct unit_test_suite cryptodev_armv8_testsuite = {
8856 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8857 .setup = testsuite_setup,
8858 .teardown = testsuite_teardown,
8859 .unit_test_cases = {
8860 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8862 /** Negative tests */
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8868 TEST_CASES_END() /**< NULL terminate unit test array */
8873 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8875 gbl_driver_id = rte_cryptodev_driver_id_get(
8876 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
8878 if (gbl_driver_id == -1) {
8879 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
8880 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
8881 "in config file to run this testsuite.\n");
8885 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8889 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8891 gbl_driver_id = rte_cryptodev_driver_id_get(
8892 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8894 if (gbl_driver_id == -1) {
8895 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8896 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8897 "in config file to run this testsuite.\n");
8901 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8905 test_cryptodev_openssl(void)
8907 gbl_driver_id = rte_cryptodev_driver_id_get(
8908 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
8910 if (gbl_driver_id == -1) {
8911 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8912 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8913 "in config file to run this testsuite.\n");
8917 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8921 test_cryptodev_aesni_gcm(void)
8923 gbl_driver_id = rte_cryptodev_driver_id_get(
8924 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
8926 if (gbl_driver_id == -1) {
8927 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
8928 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
8929 "in config file to run this testsuite.\n");
8933 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8937 test_cryptodev_null(void)
8939 gbl_driver_id = rte_cryptodev_driver_id_get(
8940 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
8942 if (gbl_driver_id == -1) {
8943 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
8944 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
8945 "in config file to run this testsuite.\n");
8949 return unit_test_suite_runner(&cryptodev_null_testsuite);
8953 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8955 gbl_driver_id = rte_cryptodev_driver_id_get(
8956 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
8958 if (gbl_driver_id == -1) {
8959 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
8960 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
8961 "in config file to run this testsuite.\n");
8965 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8969 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8971 gbl_driver_id = rte_cryptodev_driver_id_get(
8972 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
8974 if (gbl_driver_id == -1) {
8975 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8976 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
8977 "in config file to run this testsuite.\n");
8981 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8985 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8987 gbl_driver_id = rte_cryptodev_driver_id_get(
8988 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
8990 if (gbl_driver_id == -1) {
8991 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8992 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
8993 "in config file to run this testsuite.\n");
8997 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9001 test_cryptodev_armv8(void)
9003 gbl_driver_id = rte_cryptodev_driver_id_get(
9004 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9006 if (gbl_driver_id == -1) {
9007 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9008 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9009 "in config file to run this testsuite.\n");
9013 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9016 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9019 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9021 gbl_driver_id = rte_cryptodev_driver_id_get(
9022 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9024 if (gbl_driver_id == -1) {
9025 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9026 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9027 "in config file to run this testsuite.\n");
9031 if (rte_cryptodev_driver_id_get(
9032 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9033 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9034 " enabled in config file to run this testsuite.\n");
9037 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9040 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9045 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9047 gbl_driver_id = rte_cryptodev_driver_id_get(
9048 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9050 if (gbl_driver_id == -1) {
9051 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9052 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9053 "in config file to run this testsuite.\n");
9057 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9060 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9061 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9062 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9063 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9064 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9065 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9066 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9067 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9068 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9069 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);