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_mempool *slave_session_mpool;
72 struct rte_cryptodev_config conf;
73 struct rte_cryptodev_qp_conf qp_conf;
75 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
76 uint8_t valid_dev_count;
79 struct crypto_unittest_params {
80 struct rte_crypto_sym_xform cipher_xform;
81 struct rte_crypto_sym_xform auth_xform;
82 struct rte_crypto_sym_xform aead_xform;
84 struct rte_cryptodev_sym_session *sess;
86 struct rte_crypto_op *op;
88 struct rte_mbuf *obuf, *ibuf;
93 #define ALIGN_POW2_ROUNDUP(num, align) \
94 (((num) + (align) - 1) & ~((align) - 1))
97 * Forward declarations.
100 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
101 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
105 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
106 struct crypto_unittest_params *ut_params,
107 struct crypto_testsuite_params *ts_param,
108 const uint8_t *cipher,
109 const uint8_t *digest,
112 static struct rte_mbuf *
113 setup_test_string(struct rte_mempool *mpool,
114 const char *string, size_t len, uint8_t blocksize)
116 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
117 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
119 memset(m->buf_addr, 0, m->buf_len);
121 char *dst = rte_pktmbuf_append(m, t_len);
128 rte_memcpy(dst, string, t_len);
130 memset(dst, 0, t_len);
136 /* Get number of bytes in X bits (rounding up) */
138 ceil_byte_length(uint32_t num_bits)
141 return ((num_bits >> 3) + 1);
143 return (num_bits >> 3);
146 static struct rte_crypto_op *
147 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
149 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
150 printf("Error sending packet for encryption");
156 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
162 static struct crypto_testsuite_params testsuite_params = { NULL };
163 static struct crypto_unittest_params unittest_params;
166 testsuite_setup(void)
168 struct crypto_testsuite_params *ts_params = &testsuite_params;
169 struct rte_cryptodev_info info;
170 uint32_t i = 0, nb_devs, dev_id;
174 memset(ts_params, 0, sizeof(*ts_params));
176 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
177 if (ts_params->mbuf_pool == NULL) {
178 /* Not already created so create */
179 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
181 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
183 if (ts_params->mbuf_pool == NULL) {
184 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
189 ts_params->large_mbuf_pool = rte_mempool_lookup(
190 "CRYPTO_LARGE_MBUFPOOL");
191 if (ts_params->large_mbuf_pool == NULL) {
192 /* Not already created so create */
193 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
194 "CRYPTO_LARGE_MBUFPOOL",
197 if (ts_params->large_mbuf_pool == NULL) {
199 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
204 ts_params->op_mpool = rte_crypto_op_pool_create(
205 "MBUF_CRYPTO_SYM_OP_POOL",
206 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
207 NUM_MBUFS, MBUF_CACHE_SIZE,
209 sizeof(struct rte_crypto_sym_xform) +
212 if (ts_params->op_mpool == NULL) {
213 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
217 /* Create an AESNI MB device if required */
218 if (gbl_driver_id == rte_cryptodev_driver_id_get(
219 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
220 nb_devs = rte_cryptodev_device_count_by_driver(
221 rte_cryptodev_driver_id_get(
222 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
225 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 TEST_ASSERT(ret == 0,
228 "Failed to create instance of"
230 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
234 /* Create an AESNI GCM device if required */
235 if (gbl_driver_id == rte_cryptodev_driver_id_get(
236 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
237 nb_devs = rte_cryptodev_device_count_by_driver(
238 rte_cryptodev_driver_id_get(
239 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
241 TEST_ASSERT_SUCCESS(rte_vdev_init(
242 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
243 "Failed to create instance of"
245 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
249 /* Create a SNOW 3G device if required */
250 if (gbl_driver_id == rte_cryptodev_driver_id_get(
251 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
252 nb_devs = rte_cryptodev_device_count_by_driver(
253 rte_cryptodev_driver_id_get(
254 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
256 TEST_ASSERT_SUCCESS(rte_vdev_init(
257 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
258 "Failed to create instance of"
260 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
264 /* Create a KASUMI device if required */
265 if (gbl_driver_id == rte_cryptodev_driver_id_get(
266 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
267 nb_devs = rte_cryptodev_device_count_by_driver(
268 rte_cryptodev_driver_id_get(
269 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
271 TEST_ASSERT_SUCCESS(rte_vdev_init(
272 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
273 "Failed to create instance of"
275 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
279 /* Create a ZUC device if required */
280 if (gbl_driver_id == rte_cryptodev_driver_id_get(
281 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
282 nb_devs = rte_cryptodev_device_count_by_driver(
283 rte_cryptodev_driver_id_get(
284 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
286 TEST_ASSERT_SUCCESS(rte_vdev_init(
287 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
288 "Failed to create instance of"
290 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
294 /* Create a NULL device if required */
295 if (gbl_driver_id == rte_cryptodev_driver_id_get(
296 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
297 nb_devs = rte_cryptodev_device_count_by_driver(
298 rte_cryptodev_driver_id_get(
299 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
302 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
304 TEST_ASSERT(ret == 0,
305 "Failed to create instance of"
307 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
311 /* Create an OPENSSL device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
319 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
322 TEST_ASSERT(ret == 0, "Failed to create "
323 "instance of pmd : %s",
324 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
328 /* Create a ARMv8 device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
336 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
339 TEST_ASSERT(ret == 0, "Failed to create "
340 "instance of pmd : %s",
341 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
345 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
346 if (gbl_driver_id == rte_cryptodev_driver_id_get(
347 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
354 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
357 TEST_ASSERT(ret == 0,
358 "Failed to create instance %u of"
360 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
363 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
365 nb_devs = rte_cryptodev_count();
367 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
371 /* Create list of valid crypto devs */
372 for (i = 0; i < nb_devs; i++) {
373 rte_cryptodev_info_get(i, &info);
374 if (info.driver_id == gbl_driver_id)
375 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
378 if (ts_params->valid_dev_count < 1)
381 /* Set up all the qps on the first of the valid devices found */
383 dev_id = ts_params->valid_devs[0];
385 rte_cryptodev_info_get(dev_id, &info);
387 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
388 ts_params->conf.socket_id = SOCKET_ID_ANY;
390 unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
391 rte_cryptodev_get_private_session_size(dev_id);
393 ts_params->session_mpool = rte_mempool_create(
395 info.sym.max_nb_sessions,
397 0, 0, NULL, NULL, NULL,
401 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
402 "session mempool allocation failed");
404 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
405 &ts_params->conf, ts_params->session_mpool),
406 "Failed to configure cryptodev %u with %u qps",
407 dev_id, ts_params->conf.nb_queue_pairs);
409 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
411 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
412 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
413 dev_id, qp_id, &ts_params->qp_conf,
414 rte_cryptodev_socket_id(dev_id)),
415 "Failed to setup queue pair %u on cryptodev %u",
423 testsuite_teardown(void)
425 struct crypto_testsuite_params *ts_params = &testsuite_params;
427 if (ts_params->mbuf_pool != NULL) {
428 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
429 rte_mempool_avail_count(ts_params->mbuf_pool));
432 if (ts_params->op_mpool != NULL) {
433 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
434 rte_mempool_avail_count(ts_params->op_mpool));
437 /* Free session mempools */
438 if (ts_params->session_mpool != NULL) {
439 rte_mempool_free(ts_params->session_mpool);
440 ts_params->session_mpool = NULL;
443 if (ts_params->slave_session_mpool != NULL) {
444 rte_mempool_free(ts_params->slave_session_mpool);
445 ts_params->slave_session_mpool = NULL;
452 struct crypto_testsuite_params *ts_params = &testsuite_params;
453 struct crypto_unittest_params *ut_params = &unittest_params;
457 /* Clear unit test parameters before running test */
458 memset(ut_params, 0, sizeof(*ut_params));
460 /* Reconfigure device to default parameters */
461 ts_params->conf.socket_id = SOCKET_ID_ANY;
463 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
464 &ts_params->conf, ts_params->session_mpool),
465 "Failed to configure cryptodev %u",
466 ts_params->valid_devs[0]);
468 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
469 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
470 ts_params->valid_devs[0], qp_id,
472 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
473 "Failed to setup queue pair %u on cryptodev %u",
474 qp_id, ts_params->valid_devs[0]);
478 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
480 /* Start the device */
481 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
482 "Failed to start cryptodev %u",
483 ts_params->valid_devs[0]);
491 struct crypto_testsuite_params *ts_params = &testsuite_params;
492 struct crypto_unittest_params *ut_params = &unittest_params;
493 struct rte_cryptodev_stats stats;
495 /* free crypto session structure */
496 if (ut_params->sess) {
497 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
499 ut_params->sess = NULL;
502 /* free crypto operation structure */
504 rte_crypto_op_free(ut_params->op);
507 * free mbuf - both obuf and ibuf are usually the same,
508 * so check if they point at the same address is necessary,
509 * to avoid freeing the mbuf twice.
511 if (ut_params->obuf) {
512 rte_pktmbuf_free(ut_params->obuf);
513 if (ut_params->ibuf == ut_params->obuf)
517 if (ut_params->ibuf) {
518 rte_pktmbuf_free(ut_params->ibuf);
522 if (ts_params->mbuf_pool != NULL)
523 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
524 rte_mempool_avail_count(ts_params->mbuf_pool));
526 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
528 /* Stop the device */
529 rte_cryptodev_stop(ts_params->valid_devs[0]);
533 test_device_configure_invalid_dev_id(void)
535 struct crypto_testsuite_params *ts_params = &testsuite_params;
536 uint16_t dev_id, num_devs = 0;
538 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
539 "Need at least %d devices for test", 1);
541 /* valid dev_id values */
542 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
544 /* Stop the device in case it's started so it can be configured */
545 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
547 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
548 ts_params->session_mpool),
549 "Failed test for rte_cryptodev_configure: "
550 "invalid dev_num %u", dev_id);
552 /* invalid dev_id values */
555 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
556 ts_params->session_mpool),
557 "Failed test for rte_cryptodev_configure: "
558 "invalid dev_num %u", dev_id);
562 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
563 ts_params->session_mpool),
564 "Failed test for rte_cryptodev_configure:"
565 "invalid dev_num %u", dev_id);
571 test_device_configure_invalid_queue_pair_ids(void)
573 struct crypto_testsuite_params *ts_params = &testsuite_params;
574 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
576 /* Stop the device in case it's started so it can be configured */
577 rte_cryptodev_stop(ts_params->valid_devs[0]);
579 /* valid - one queue pairs */
580 ts_params->conf.nb_queue_pairs = 1;
582 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
583 &ts_params->conf, ts_params->session_mpool),
584 "Failed to configure cryptodev: dev_id %u, qp_id %u",
585 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
588 /* valid - max value queue pairs */
589 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
591 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
592 &ts_params->conf, ts_params->session_mpool),
593 "Failed to configure cryptodev: dev_id %u, qp_id %u",
594 ts_params->valid_devs[0],
595 ts_params->conf.nb_queue_pairs);
598 /* invalid - zero queue pairs */
599 ts_params->conf.nb_queue_pairs = 0;
601 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
602 &ts_params->conf, ts_params->session_mpool),
603 "Failed test for rte_cryptodev_configure, dev_id %u,"
605 ts_params->valid_devs[0],
606 ts_params->conf.nb_queue_pairs);
609 /* invalid - max value supported by field queue pairs */
610 ts_params->conf.nb_queue_pairs = UINT16_MAX;
612 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
613 &ts_params->conf, ts_params->session_mpool),
614 "Failed test for rte_cryptodev_configure, dev_id %u,"
616 ts_params->valid_devs[0],
617 ts_params->conf.nb_queue_pairs);
620 /* invalid - max value + 1 queue pairs */
621 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
623 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
624 &ts_params->conf, ts_params->session_mpool),
625 "Failed test for rte_cryptodev_configure, dev_id %u,"
627 ts_params->valid_devs[0],
628 ts_params->conf.nb_queue_pairs);
630 /* revert to original testsuite value */
631 ts_params->conf.nb_queue_pairs = orig_nb_qps;
637 test_queue_pair_descriptor_setup(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
640 struct rte_cryptodev_info dev_info;
641 struct rte_cryptodev_qp_conf qp_conf = {
642 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
647 /* Stop the device in case it's started so it can be configured */
648 rte_cryptodev_stop(ts_params->valid_devs[0]);
651 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
653 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
654 &ts_params->conf, ts_params->session_mpool),
655 "Failed to configure cryptodev %u",
656 ts_params->valid_devs[0]);
659 * Test various ring sizes on this device. memzones can't be
660 * freed so are re-used if ring is released and re-created.
662 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
664 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
665 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
666 ts_params->valid_devs[0], qp_id, &qp_conf,
667 rte_cryptodev_socket_id(
668 ts_params->valid_devs[0])),
670 "rte_cryptodev_queue_pair_setup: num_inflights "
671 "%u on qp %u on cryptodev %u",
672 qp_conf.nb_descriptors, qp_id,
673 ts_params->valid_devs[0]);
676 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
678 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
679 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
680 ts_params->valid_devs[0], qp_id, &qp_conf,
681 rte_cryptodev_socket_id(
682 ts_params->valid_devs[0])),
684 " rte_cryptodev_queue_pair_setup: num_inflights"
685 " %u on qp %u on cryptodev %u",
686 qp_conf.nb_descriptors, qp_id,
687 ts_params->valid_devs[0]);
690 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
692 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
693 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
694 ts_params->valid_devs[0], qp_id, &qp_conf,
695 rte_cryptodev_socket_id(
696 ts_params->valid_devs[0])),
698 "rte_cryptodev_queue_pair_setup: num_inflights"
699 " %u on qp %u on cryptodev %u",
700 qp_conf.nb_descriptors, qp_id,
701 ts_params->valid_devs[0]);
704 /* invalid number of descriptors - max supported + 2 */
705 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
707 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
708 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
709 ts_params->valid_devs[0], qp_id, &qp_conf,
710 rte_cryptodev_socket_id(
711 ts_params->valid_devs[0])),
712 "Unexpectedly passed test for "
713 "rte_cryptodev_queue_pair_setup:"
714 "num_inflights %u on qp %u on cryptodev %u",
715 qp_conf.nb_descriptors, qp_id,
716 ts_params->valid_devs[0]);
719 /* invalid number of descriptors - max value of parameter */
720 qp_conf.nb_descriptors = UINT32_MAX-1;
722 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
723 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
724 ts_params->valid_devs[0], qp_id, &qp_conf,
725 rte_cryptodev_socket_id(
726 ts_params->valid_devs[0])),
727 "Unexpectedly passed test for "
728 "rte_cryptodev_queue_pair_setup:"
729 "num_inflights %u on qp %u on cryptodev %u",
730 qp_conf.nb_descriptors, qp_id,
731 ts_params->valid_devs[0]);
734 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
736 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
737 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
738 ts_params->valid_devs[0], qp_id, &qp_conf,
739 rte_cryptodev_socket_id(
740 ts_params->valid_devs[0])),
742 " rte_cryptodev_queue_pair_setup:"
743 "num_inflights %u on qp %u on cryptodev %u",
744 qp_conf.nb_descriptors, qp_id,
745 ts_params->valid_devs[0]);
748 /* invalid number of descriptors - max supported + 1 */
749 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
751 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
752 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
753 ts_params->valid_devs[0], qp_id, &qp_conf,
754 rte_cryptodev_socket_id(
755 ts_params->valid_devs[0])),
756 "Unexpectedly passed test for "
757 "rte_cryptodev_queue_pair_setup:"
758 "num_inflights %u on qp %u on cryptodev %u",
759 qp_conf.nb_descriptors, qp_id,
760 ts_params->valid_devs[0]);
763 /* test invalid queue pair id */
764 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
766 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
768 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
769 ts_params->valid_devs[0],
771 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
772 "Failed test for rte_cryptodev_queue_pair_setup:"
773 "invalid qp %u on cryptodev %u",
774 qp_id, ts_params->valid_devs[0]);
776 qp_id = 0xffff; /*invalid*/
778 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
779 ts_params->valid_devs[0],
781 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
782 "Failed test for rte_cryptodev_queue_pair_setup:"
783 "invalid qp %u on cryptodev %u",
784 qp_id, ts_params->valid_devs[0]);
789 /* ***** Plaintext data for tests ***** */
791 const char catch_22_quote_1[] =
792 "There was only one catch and that was Catch-22, which "
793 "specified that a concern for one's safety in the face of "
794 "dangers that were real and immediate was the process of a "
795 "rational mind. Orr was crazy and could be grounded. All he "
796 "had to do was ask; and as soon as he did, he would no longer "
797 "be crazy and would have to fly more missions. Orr would be "
798 "crazy to fly more missions and sane if he didn't, but if he "
799 "was sane he had to fly them. If he flew them he was crazy "
800 "and didn't have to; but if he didn't want to he was sane and "
801 "had to. Yossarian was moved very deeply by the absolute "
802 "simplicity of this clause of Catch-22 and let out a "
803 "respectful whistle. \"That's some catch, that Catch-22\", he "
804 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
806 const char catch_22_quote[] =
807 "What a lousy earth! He wondered how many people were "
808 "destitute that same night even in his own prosperous country, "
809 "how many homes were shanties, how many husbands were drunk "
810 "and wives socked, and how many children were bullied, abused, "
811 "or abandoned. How many families hungered for food they could "
812 "not afford to buy? How many hearts were broken? How many "
813 "suicides would take place that same night, how many people "
814 "would go insane? How many cockroaches and landlords would "
815 "triumph? How many winners were losers, successes failures, "
816 "and rich men poor men? How many wise guys were stupid? How "
817 "many happy endings were unhappy endings? How many honest men "
818 "were liars, brave men cowards, loyal men traitors, how many "
819 "sainted men were corrupt, how many people in positions of "
820 "trust had sold their souls to bodyguards, how many had never "
821 "had souls? How many straight-and-narrow paths were crooked "
822 "paths? How many best families were worst families and how "
823 "many good people were bad people? When you added them all up "
824 "and then subtracted, you might be left with only the children, "
825 "and perhaps with Albert Einstein and an old violinist or "
826 "sculptor somewhere.";
828 #define QUOTE_480_BYTES (480)
829 #define QUOTE_512_BYTES (512)
830 #define QUOTE_768_BYTES (768)
831 #define QUOTE_1024_BYTES (1024)
835 /* ***** SHA1 Hash Tests ***** */
837 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
839 static uint8_t hmac_sha1_key[] = {
840 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
841 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
842 0xDE, 0xF4, 0xDE, 0xAD };
844 /* ***** SHA224 Hash Tests ***** */
846 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
849 /* ***** AES-CBC Cipher Tests ***** */
851 #define CIPHER_KEY_LENGTH_AES_CBC (16)
852 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
854 static uint8_t aes_cbc_key[] = {
855 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
856 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
858 static uint8_t aes_cbc_iv[] = {
859 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
860 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
863 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
865 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
866 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
867 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
868 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
869 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
870 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
871 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
872 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
873 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
874 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
875 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
876 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
877 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
878 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
879 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
880 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
881 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
882 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
883 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
884 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
885 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
886 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
887 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
888 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
889 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
890 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
891 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
892 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
893 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
894 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
895 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
896 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
897 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
898 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
899 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
900 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
901 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
902 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
903 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
904 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
905 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
906 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
907 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
908 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
909 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
910 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
911 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
912 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
913 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
914 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
915 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
916 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
917 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
918 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
919 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
920 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
921 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
922 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
923 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
924 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
925 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
926 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
927 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
928 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
929 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
932 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
933 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
934 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
935 0x18, 0x8c, 0x1d, 0x32
939 /* Multisession Vector context Test */
941 static uint8_t ms_aes_cbc_key0[] = {
942 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
943 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
946 static uint8_t ms_aes_cbc_iv0[] = {
947 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
948 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
951 static const uint8_t ms_aes_cbc_cipher0[] = {
952 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
953 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
954 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
955 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
956 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
957 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
958 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
959 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
960 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
961 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
962 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
963 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
964 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
965 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
966 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
967 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
968 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
969 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
970 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
971 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
972 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
973 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
974 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
975 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
976 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
977 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
978 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
979 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
980 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
981 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
982 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
983 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
984 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
985 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
986 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
987 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
988 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
989 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
990 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
991 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
992 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
993 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
994 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
995 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
996 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
997 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
998 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
999 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1000 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1001 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1002 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1003 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1004 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1005 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1006 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1007 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1008 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1009 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1010 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1011 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1012 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1013 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1014 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1015 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1019 static uint8_t ms_hmac_key0[] = {
1020 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1021 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1022 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1023 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1024 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1025 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1026 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1027 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1030 static const uint8_t ms_hmac_digest0[] = {
1031 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1032 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1033 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1034 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1035 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1036 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1037 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1038 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1042 /* Begin session 1 */
1044 static uint8_t ms_aes_cbc_key1[] = {
1045 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1049 static uint8_t ms_aes_cbc_iv1[] = {
1050 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static const uint8_t ms_aes_cbc_cipher1[] = {
1055 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1056 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1057 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1058 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1059 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1060 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1061 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1062 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1063 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1064 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1065 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1066 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1067 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1068 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1069 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1070 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1071 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1072 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1073 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1074 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1075 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1076 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1077 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1078 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1079 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1080 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1081 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1082 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1083 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1084 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1085 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1086 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1087 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1088 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1089 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1090 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1091 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1092 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1093 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1094 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1095 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1096 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1097 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1098 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1099 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1100 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1101 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1102 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1103 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1104 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1105 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1106 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1107 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1108 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1109 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1110 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1111 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1112 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1113 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1114 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1115 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1116 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1117 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1118 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1122 static uint8_t ms_hmac_key1[] = {
1123 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1124 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1125 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1126 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1127 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1128 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1129 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1130 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1133 static const uint8_t ms_hmac_digest1[] = {
1134 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1135 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1136 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1137 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1138 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1139 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1140 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1141 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1144 /* Begin Session 2 */
1145 static uint8_t ms_aes_cbc_key2[] = {
1146 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1147 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1150 static uint8_t ms_aes_cbc_iv2[] = {
1151 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1152 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 static const uint8_t ms_aes_cbc_cipher2[] = {
1156 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1157 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1158 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1159 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1160 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1161 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1162 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1163 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1164 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1165 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1166 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1167 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1168 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1169 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1170 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1171 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1172 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1173 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1174 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1175 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1176 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1177 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1178 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1179 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1180 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1181 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1182 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1183 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1184 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1185 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1186 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1187 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1188 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1189 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1190 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1191 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1192 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1193 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1194 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1195 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1196 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1197 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1198 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1199 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1200 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1201 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1202 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1203 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1204 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1205 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1206 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1207 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1208 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1209 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1210 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1211 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1212 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1213 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1214 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1215 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1216 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1217 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1218 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1219 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1222 static uint8_t ms_hmac_key2[] = {
1223 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1224 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1225 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1226 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1227 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1228 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1229 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1230 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1233 static const uint8_t ms_hmac_digest2[] = {
1234 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1235 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1236 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1237 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1238 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1239 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1240 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1241 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1248 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1250 struct crypto_testsuite_params *ts_params = &testsuite_params;
1251 struct crypto_unittest_params *ut_params = &unittest_params;
1253 /* Generate test mbuf data and space for digest */
1254 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1255 catch_22_quote, QUOTE_512_BYTES, 0);
1257 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1258 DIGEST_BYTE_LENGTH_SHA1);
1259 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1261 /* Setup Cipher Parameters */
1262 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1263 ut_params->cipher_xform.next = &ut_params->auth_xform;
1265 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1266 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1267 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1268 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1269 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1270 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1272 /* Setup HMAC Parameters */
1273 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1275 ut_params->auth_xform.next = NULL;
1277 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1278 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1279 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1280 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1281 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1283 /* Create crypto session*/
1284 ut_params->sess = rte_cryptodev_sym_session_create(
1285 ts_params->valid_devs[0],
1286 &ut_params->cipher_xform);
1287 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1289 /* Generate crypto op data structure */
1290 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1291 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1292 TEST_ASSERT_NOT_NULL(ut_params->op,
1293 "Failed to allocate symmetric crypto operation struct");
1295 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1297 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1299 /* set crypto operation source mbuf */
1300 sym_op->m_src = ut_params->ibuf;
1302 /* Set crypto operation authentication parameters */
1303 sym_op->auth.digest.data = ut_params->digest;
1304 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1305 ut_params->ibuf, QUOTE_512_BYTES);
1307 sym_op->auth.data.offset = 0;
1308 sym_op->auth.data.length = QUOTE_512_BYTES;
1310 /* Copy IV at the end of the crypto operation */
1311 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1312 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1314 /* Set crypto operation cipher parameters */
1315 sym_op->cipher.data.offset = 0;
1316 sym_op->cipher.data.length = QUOTE_512_BYTES;
1318 /* Process crypto operation */
1319 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1320 ut_params->op), "failed to process sym crypto op");
1322 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1323 "crypto op processing failed");
1326 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1329 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1330 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1332 "ciphertext data not as expected");
1334 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1336 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1337 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1338 gbl_driver_id == rte_cryptodev_driver_id_get(
1339 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1340 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1341 DIGEST_BYTE_LENGTH_SHA1,
1342 "Generated digest data not as expected");
1344 return TEST_SUCCESS;
1347 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1349 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1351 static uint8_t hmac_sha512_key[] = {
1352 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1353 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1354 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1355 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1356 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1357 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1358 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1359 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1361 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1362 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1363 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1364 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1365 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1366 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1367 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1368 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1369 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1374 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1375 struct crypto_unittest_params *ut_params,
1376 uint8_t *cipher_key,
1380 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1381 struct crypto_unittest_params *ut_params,
1382 struct crypto_testsuite_params *ts_params,
1383 const uint8_t *cipher,
1384 const uint8_t *digest,
1389 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1390 struct crypto_unittest_params *ut_params,
1391 uint8_t *cipher_key,
1395 /* Setup Cipher Parameters */
1396 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1397 ut_params->cipher_xform.next = NULL;
1399 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1400 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1401 ut_params->cipher_xform.cipher.key.data = cipher_key;
1402 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1403 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1404 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1406 /* Setup HMAC Parameters */
1407 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1408 ut_params->auth_xform.next = &ut_params->cipher_xform;
1410 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1411 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1412 ut_params->auth_xform.auth.key.data = hmac_key;
1413 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1414 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1416 return TEST_SUCCESS;
1421 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1422 struct crypto_unittest_params *ut_params,
1423 struct crypto_testsuite_params *ts_params,
1424 const uint8_t *cipher,
1425 const uint8_t *digest,
1428 /* Generate test mbuf data and digest */
1429 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1432 QUOTE_512_BYTES, 0);
1434 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1435 DIGEST_BYTE_LENGTH_SHA512);
1436 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1438 rte_memcpy(ut_params->digest,
1440 DIGEST_BYTE_LENGTH_SHA512);
1442 /* Generate Crypto op data structure */
1443 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1444 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1445 TEST_ASSERT_NOT_NULL(ut_params->op,
1446 "Failed to allocate symmetric crypto operation struct");
1448 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1450 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1452 /* set crypto operation source mbuf */
1453 sym_op->m_src = ut_params->ibuf;
1455 sym_op->auth.digest.data = ut_params->digest;
1456 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1457 ut_params->ibuf, QUOTE_512_BYTES);
1459 sym_op->auth.data.offset = 0;
1460 sym_op->auth.data.length = QUOTE_512_BYTES;
1462 /* Copy IV at the end of the crypto operation */
1463 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1464 iv, CIPHER_IV_LENGTH_AES_CBC);
1466 sym_op->cipher.data.offset = 0;
1467 sym_op->cipher.data.length = QUOTE_512_BYTES;
1469 /* Process crypto operation */
1470 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1471 ut_params->op), "failed to process sym crypto op");
1473 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1474 "crypto op processing failed");
1476 ut_params->obuf = ut_params->op->sym->m_src;
1479 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1480 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1483 "Plaintext data not as expected");
1486 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1487 "Digest verification failed");
1489 return TEST_SUCCESS;
1493 test_AES_cipheronly_mb_all(void)
1495 struct crypto_testsuite_params *ts_params = &testsuite_params;
1498 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1499 ts_params->op_mpool, ts_params->valid_devs[0],
1500 rte_cryptodev_driver_id_get(
1501 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1502 BLKCIPHER_AES_CIPHERONLY_TYPE);
1504 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1506 return TEST_SUCCESS;
1510 test_AES_docsis_mb_all(void)
1512 struct crypto_testsuite_params *ts_params = &testsuite_params;
1515 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1516 ts_params->op_mpool, ts_params->valid_devs[0],
1517 rte_cryptodev_driver_id_get(
1518 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1519 BLKCIPHER_AES_DOCSIS_TYPE);
1521 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1523 return TEST_SUCCESS;
1527 test_AES_docsis_qat_all(void)
1529 struct crypto_testsuite_params *ts_params = &testsuite_params;
1532 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1533 ts_params->op_mpool, ts_params->valid_devs[0],
1534 rte_cryptodev_driver_id_get(
1535 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1536 BLKCIPHER_AES_DOCSIS_TYPE);
1538 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1540 return TEST_SUCCESS;
1544 test_DES_docsis_qat_all(void)
1546 struct crypto_testsuite_params *ts_params = &testsuite_params;
1549 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1550 ts_params->op_mpool, ts_params->valid_devs[0],
1551 rte_cryptodev_driver_id_get(
1552 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1553 BLKCIPHER_DES_DOCSIS_TYPE);
1555 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1557 return TEST_SUCCESS;
1561 test_authonly_mb_all(void)
1563 struct crypto_testsuite_params *ts_params = &testsuite_params;
1566 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1567 ts_params->op_mpool, ts_params->valid_devs[0],
1568 rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1570 BLKCIPHER_AUTHONLY_TYPE);
1572 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1574 return TEST_SUCCESS;
1578 test_AES_chain_mb_all(void)
1580 struct crypto_testsuite_params *ts_params = &testsuite_params;
1583 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1584 ts_params->op_mpool, ts_params->valid_devs[0],
1585 rte_cryptodev_driver_id_get(
1586 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1587 BLKCIPHER_AES_CHAIN_TYPE);
1589 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1591 return TEST_SUCCESS;
1594 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1597 test_AES_cipheronly_scheduler_all(void)
1599 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1603 ts_params->op_mpool, ts_params->valid_devs[0],
1604 rte_cryptodev_driver_id_get(
1605 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1606 BLKCIPHER_AES_CIPHERONLY_TYPE);
1608 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1610 return TEST_SUCCESS;
1614 test_AES_chain_scheduler_all(void)
1616 struct crypto_testsuite_params *ts_params = &testsuite_params;
1619 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1620 ts_params->op_mpool, ts_params->valid_devs[0],
1621 rte_cryptodev_driver_id_get(
1622 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1623 BLKCIPHER_AES_CHAIN_TYPE);
1625 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1627 return TEST_SUCCESS;
1631 test_authonly_scheduler_all(void)
1633 struct crypto_testsuite_params *ts_params = &testsuite_params;
1636 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1637 ts_params->op_mpool, ts_params->valid_devs[0],
1638 rte_cryptodev_driver_id_get(
1639 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1640 BLKCIPHER_AUTHONLY_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1647 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1650 test_AES_chain_openssl_all(void)
1652 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1656 ts_params->op_mpool, ts_params->valid_devs[0],
1657 rte_cryptodev_driver_id_get(
1658 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1659 BLKCIPHER_AES_CHAIN_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1667 test_AES_cipheronly_openssl_all(void)
1669 struct crypto_testsuite_params *ts_params = &testsuite_params;
1672 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1673 ts_params->op_mpool, ts_params->valid_devs[0],
1674 rte_cryptodev_driver_id_get(
1675 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1676 BLKCIPHER_AES_CIPHERONLY_TYPE);
1678 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1680 return TEST_SUCCESS;
1684 test_AES_chain_qat_all(void)
1686 struct crypto_testsuite_params *ts_params = &testsuite_params;
1689 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1690 ts_params->op_mpool, ts_params->valid_devs[0],
1691 rte_cryptodev_driver_id_get(
1692 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1693 BLKCIPHER_AES_CHAIN_TYPE);
1695 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1697 return TEST_SUCCESS;
1701 test_AES_cipheronly_qat_all(void)
1703 struct crypto_testsuite_params *ts_params = &testsuite_params;
1706 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1707 ts_params->op_mpool, ts_params->valid_devs[0],
1708 rte_cryptodev_driver_id_get(
1709 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1710 BLKCIPHER_AES_CIPHERONLY_TYPE);
1712 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1714 return TEST_SUCCESS;
1718 test_AES_chain_dpaa2_sec_all(void)
1720 struct crypto_testsuite_params *ts_params = &testsuite_params;
1723 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1724 ts_params->op_mpool, ts_params->valid_devs[0],
1725 rte_cryptodev_driver_id_get(
1726 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1727 BLKCIPHER_AES_CHAIN_TYPE);
1729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1731 return TEST_SUCCESS;
1735 test_AES_cipheronly_dpaa2_sec_all(void)
1737 struct crypto_testsuite_params *ts_params = &testsuite_params;
1740 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1741 ts_params->op_mpool, ts_params->valid_devs[0],
1742 rte_cryptodev_driver_id_get(
1743 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1744 BLKCIPHER_AES_CIPHERONLY_TYPE);
1746 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1748 return TEST_SUCCESS;
1752 test_authonly_dpaa2_sec_all(void)
1754 struct crypto_testsuite_params *ts_params = &testsuite_params;
1757 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1758 ts_params->op_mpool, ts_params->valid_devs[0],
1759 rte_cryptodev_driver_id_get(
1760 RTE_STR(RTE_CRYPTODEV_DPAA2_SEC_PMD)),
1761 BLKCIPHER_AUTHONLY_TYPE);
1763 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1765 return TEST_SUCCESS;
1769 test_authonly_openssl_all(void)
1771 struct crypto_testsuite_params *ts_params = &testsuite_params;
1774 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1775 ts_params->op_mpool, ts_params->valid_devs[0],
1776 rte_cryptodev_driver_id_get(
1777 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1778 BLKCIPHER_AUTHONLY_TYPE);
1780 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1782 return TEST_SUCCESS;
1786 test_AES_chain_armv8_all(void)
1788 struct crypto_testsuite_params *ts_params = &testsuite_params;
1791 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1792 ts_params->op_mpool, ts_params->valid_devs[0],
1793 rte_cryptodev_driver_id_get(
1794 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1795 BLKCIPHER_AES_CHAIN_TYPE);
1797 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1799 return TEST_SUCCESS;
1802 /* ***** SNOW 3G Tests ***** */
1804 create_wireless_algo_hash_session(uint8_t dev_id,
1805 const uint8_t *key, const uint8_t key_len,
1806 const uint8_t iv_len, const uint8_t auth_len,
1807 enum rte_crypto_auth_operation op,
1808 enum rte_crypto_auth_algorithm algo)
1810 uint8_t hash_key[key_len];
1812 struct crypto_unittest_params *ut_params = &unittest_params;
1814 memcpy(hash_key, key, key_len);
1816 TEST_HEXDUMP(stdout, "key:", key, key_len);
1818 /* Setup Authentication Parameters */
1819 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1820 ut_params->auth_xform.next = NULL;
1822 ut_params->auth_xform.auth.op = op;
1823 ut_params->auth_xform.auth.algo = algo;
1824 ut_params->auth_xform.auth.key.length = key_len;
1825 ut_params->auth_xform.auth.key.data = hash_key;
1826 ut_params->auth_xform.auth.digest_length = auth_len;
1827 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1828 ut_params->auth_xform.auth.iv.length = iv_len;
1829 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1830 &ut_params->auth_xform);
1831 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1836 create_wireless_algo_cipher_session(uint8_t dev_id,
1837 enum rte_crypto_cipher_operation op,
1838 enum rte_crypto_cipher_algorithm algo,
1839 const uint8_t *key, const uint8_t key_len,
1842 uint8_t cipher_key[key_len];
1844 struct crypto_unittest_params *ut_params = &unittest_params;
1846 memcpy(cipher_key, key, key_len);
1848 /* Setup Cipher Parameters */
1849 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1850 ut_params->cipher_xform.next = NULL;
1852 ut_params->cipher_xform.cipher.algo = algo;
1853 ut_params->cipher_xform.cipher.op = op;
1854 ut_params->cipher_xform.cipher.key.data = cipher_key;
1855 ut_params->cipher_xform.cipher.key.length = key_len;
1856 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1857 ut_params->cipher_xform.cipher.iv.length = iv_len;
1859 TEST_HEXDUMP(stdout, "key:", key, key_len);
1861 /* Create Crypto session */
1862 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1865 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1870 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1871 unsigned int cipher_len,
1872 unsigned int cipher_offset)
1874 struct crypto_testsuite_params *ts_params = &testsuite_params;
1875 struct crypto_unittest_params *ut_params = &unittest_params;
1877 /* Generate Crypto op data structure */
1878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1880 TEST_ASSERT_NOT_NULL(ut_params->op,
1881 "Failed to allocate pktmbuf offload");
1883 /* Set crypto operation data parameters */
1884 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1886 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1888 /* set crypto operation source mbuf */
1889 sym_op->m_src = ut_params->ibuf;
1892 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1894 sym_op->cipher.data.length = cipher_len;
1895 sym_op->cipher.data.offset = cipher_offset;
1900 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1901 unsigned int cipher_len,
1902 unsigned int cipher_offset)
1904 struct crypto_testsuite_params *ts_params = &testsuite_params;
1905 struct crypto_unittest_params *ut_params = &unittest_params;
1907 /* Generate Crypto op data structure */
1908 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1909 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1910 TEST_ASSERT_NOT_NULL(ut_params->op,
1911 "Failed to allocate pktmbuf offload");
1913 /* Set crypto operation data parameters */
1914 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1916 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1918 /* set crypto operation source mbuf */
1919 sym_op->m_src = ut_params->ibuf;
1920 sym_op->m_dst = ut_params->obuf;
1923 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1925 sym_op->cipher.data.length = cipher_len;
1926 sym_op->cipher.data.offset = cipher_offset;
1931 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1932 enum rte_crypto_cipher_operation cipher_op,
1933 enum rte_crypto_auth_operation auth_op,
1934 enum rte_crypto_auth_algorithm auth_algo,
1935 enum rte_crypto_cipher_algorithm cipher_algo,
1936 const uint8_t *key, uint8_t key_len,
1937 uint8_t auth_iv_len, uint8_t auth_len,
1938 uint8_t cipher_iv_len)
1941 uint8_t cipher_auth_key[key_len];
1943 struct crypto_unittest_params *ut_params = &unittest_params;
1945 memcpy(cipher_auth_key, key, key_len);
1947 /* Setup Authentication Parameters */
1948 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1949 ut_params->auth_xform.next = NULL;
1951 ut_params->auth_xform.auth.op = auth_op;
1952 ut_params->auth_xform.auth.algo = auth_algo;
1953 ut_params->auth_xform.auth.key.length = key_len;
1954 /* Hash key = cipher key */
1955 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1956 ut_params->auth_xform.auth.digest_length = auth_len;
1957 /* Auth IV will be after cipher IV */
1958 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1959 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1961 /* Setup Cipher Parameters */
1962 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1963 ut_params->cipher_xform.next = &ut_params->auth_xform;
1965 ut_params->cipher_xform.cipher.algo = cipher_algo;
1966 ut_params->cipher_xform.cipher.op = cipher_op;
1967 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1968 ut_params->cipher_xform.cipher.key.length = key_len;
1969 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1970 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1972 TEST_HEXDUMP(stdout, "key:", key, key_len);
1974 /* Create Crypto session*/
1975 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1976 &ut_params->cipher_xform);
1978 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1983 create_wireless_cipher_auth_session(uint8_t dev_id,
1984 enum rte_crypto_cipher_operation cipher_op,
1985 enum rte_crypto_auth_operation auth_op,
1986 enum rte_crypto_auth_algorithm auth_algo,
1987 enum rte_crypto_cipher_algorithm cipher_algo,
1988 const struct wireless_test_data *tdata)
1990 const uint8_t key_len = tdata->key.len;
1991 uint8_t cipher_auth_key[key_len];
1993 struct crypto_unittest_params *ut_params = &unittest_params;
1994 const uint8_t *key = tdata->key.data;
1995 const uint8_t auth_len = tdata->digest.len;
1996 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1997 uint8_t auth_iv_len = tdata->auth_iv.len;
1999 memcpy(cipher_auth_key, key, key_len);
2001 /* Setup Authentication Parameters */
2002 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2003 ut_params->auth_xform.next = NULL;
2005 ut_params->auth_xform.auth.op = auth_op;
2006 ut_params->auth_xform.auth.algo = auth_algo;
2007 ut_params->auth_xform.auth.key.length = key_len;
2008 /* Hash key = cipher key */
2009 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2010 ut_params->auth_xform.auth.digest_length = auth_len;
2011 /* Auth IV will be after cipher IV */
2012 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2013 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2015 /* Setup Cipher Parameters */
2016 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2017 ut_params->cipher_xform.next = &ut_params->auth_xform;
2019 ut_params->cipher_xform.cipher.algo = cipher_algo;
2020 ut_params->cipher_xform.cipher.op = cipher_op;
2021 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2022 ut_params->cipher_xform.cipher.key.length = key_len;
2023 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2024 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2027 TEST_HEXDUMP(stdout, "key:", key, key_len);
2029 /* Create Crypto session*/
2030 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2031 &ut_params->cipher_xform);
2033 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2038 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2039 const struct wireless_test_data *tdata)
2041 return create_wireless_cipher_auth_session(dev_id,
2042 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2043 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2044 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2048 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2049 enum rte_crypto_cipher_operation cipher_op,
2050 enum rte_crypto_auth_operation auth_op,
2051 enum rte_crypto_auth_algorithm auth_algo,
2052 enum rte_crypto_cipher_algorithm cipher_algo,
2053 const uint8_t *key, const uint8_t key_len,
2054 uint8_t auth_iv_len, uint8_t auth_len,
2055 uint8_t cipher_iv_len)
2057 uint8_t auth_cipher_key[key_len];
2059 struct crypto_unittest_params *ut_params = &unittest_params;
2061 memcpy(auth_cipher_key, key, key_len);
2063 /* Setup Authentication Parameters */
2064 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2065 ut_params->auth_xform.auth.op = auth_op;
2066 ut_params->auth_xform.next = &ut_params->cipher_xform;
2067 ut_params->auth_xform.auth.algo = auth_algo;
2068 ut_params->auth_xform.auth.key.length = key_len;
2069 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2070 ut_params->auth_xform.auth.digest_length = auth_len;
2071 /* Auth IV will be after cipher IV */
2072 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2073 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2075 /* Setup Cipher Parameters */
2076 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2077 ut_params->cipher_xform.next = NULL;
2078 ut_params->cipher_xform.cipher.algo = cipher_algo;
2079 ut_params->cipher_xform.cipher.op = cipher_op;
2080 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2081 ut_params->cipher_xform.cipher.key.length = key_len;
2082 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2083 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2085 TEST_HEXDUMP(stdout, "key:", key, key_len);
2087 /* Create Crypto session*/
2088 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2089 &ut_params->auth_xform);
2091 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2097 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2098 unsigned int auth_tag_len,
2099 const uint8_t *iv, unsigned int iv_len,
2100 unsigned int data_pad_len,
2101 enum rte_crypto_auth_operation op,
2102 unsigned int auth_len, unsigned int auth_offset)
2104 struct crypto_testsuite_params *ts_params = &testsuite_params;
2106 struct crypto_unittest_params *ut_params = &unittest_params;
2108 /* Generate Crypto op data structure */
2109 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2110 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2111 TEST_ASSERT_NOT_NULL(ut_params->op,
2112 "Failed to allocate pktmbuf offload");
2114 /* Set crypto operation data parameters */
2115 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2117 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2119 /* set crypto operation source mbuf */
2120 sym_op->m_src = ut_params->ibuf;
2123 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2126 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2127 ut_params->ibuf, auth_tag_len);
2129 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2130 "no room to append auth tag");
2131 ut_params->digest = sym_op->auth.digest.data;
2132 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2133 ut_params->ibuf, data_pad_len);
2134 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2135 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2137 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2139 TEST_HEXDUMP(stdout, "digest:",
2140 sym_op->auth.digest.data,
2143 sym_op->auth.data.length = auth_len;
2144 sym_op->auth.data.offset = auth_offset;
2150 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2151 enum rte_crypto_auth_operation op)
2153 struct crypto_testsuite_params *ts_params = &testsuite_params;
2154 struct crypto_unittest_params *ut_params = &unittest_params;
2156 const uint8_t *auth_tag = tdata->digest.data;
2157 const unsigned int auth_tag_len = tdata->digest.len;
2158 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2159 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2161 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2162 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2163 const uint8_t *auth_iv = tdata->auth_iv.data;
2164 const uint8_t auth_iv_len = tdata->auth_iv.len;
2165 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2166 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2168 /* Generate Crypto op data structure */
2169 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2170 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2171 TEST_ASSERT_NOT_NULL(ut_params->op,
2172 "Failed to allocate pktmbuf offload");
2173 /* Set crypto operation data parameters */
2174 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2176 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2178 /* set crypto operation source mbuf */
2179 sym_op->m_src = ut_params->ibuf;
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 /* Copy cipher and auth IVs at the end of the crypto operation */
2200 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2202 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2203 iv_ptr += cipher_iv_len;
2204 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2206 sym_op->cipher.data.length = cipher_len;
2207 sym_op->cipher.data.offset = 0;
2208 sym_op->auth.data.length = auth_len;
2209 sym_op->auth.data.offset = 0;
2215 create_zuc_cipher_hash_generate_operation(
2216 const struct wireless_test_data *tdata)
2218 return create_wireless_cipher_hash_operation(tdata,
2219 RTE_CRYPTO_AUTH_OP_GENERATE);
2223 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2224 const unsigned auth_tag_len,
2225 const uint8_t *auth_iv, uint8_t auth_iv_len,
2226 unsigned data_pad_len,
2227 enum rte_crypto_auth_operation op,
2228 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2229 const unsigned cipher_len, const unsigned cipher_offset,
2230 const unsigned auth_len, const unsigned auth_offset)
2232 struct crypto_testsuite_params *ts_params = &testsuite_params;
2233 struct crypto_unittest_params *ut_params = &unittest_params;
2235 /* Generate Crypto op data structure */
2236 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2237 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2238 TEST_ASSERT_NOT_NULL(ut_params->op,
2239 "Failed to allocate pktmbuf offload");
2240 /* Set crypto operation data parameters */
2241 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2243 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2245 /* set crypto operation source mbuf */
2246 sym_op->m_src = ut_params->ibuf;
2249 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2250 ut_params->ibuf, auth_tag_len);
2252 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2253 "no room to append auth tag");
2254 ut_params->digest = sym_op->auth.digest.data;
2255 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2256 ut_params->ibuf, data_pad_len);
2257 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2258 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2260 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2262 TEST_HEXDUMP(stdout, "digest:",
2263 sym_op->auth.digest.data,
2266 /* Copy cipher and auth IVs at the end of the crypto operation */
2267 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2269 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2270 iv_ptr += cipher_iv_len;
2271 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2273 sym_op->cipher.data.length = cipher_len;
2274 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2275 sym_op->auth.data.length = auth_len;
2276 sym_op->auth.data.offset = auth_offset + cipher_offset;
2282 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2283 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2284 const uint8_t *auth_iv, uint8_t auth_iv_len,
2285 unsigned int data_pad_len,
2286 unsigned int cipher_len, unsigned int cipher_offset,
2287 unsigned int auth_len, unsigned int auth_offset)
2289 struct crypto_testsuite_params *ts_params = &testsuite_params;
2290 struct crypto_unittest_params *ut_params = &unittest_params;
2292 /* Generate Crypto op data structure */
2293 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2294 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2295 TEST_ASSERT_NOT_NULL(ut_params->op,
2296 "Failed to allocate pktmbuf offload");
2298 /* Set crypto operation data parameters */
2299 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2301 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2303 /* set crypto operation source mbuf */
2304 sym_op->m_src = ut_params->ibuf;
2307 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2308 ut_params->ibuf, auth_tag_len);
2310 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2311 "no room to append auth tag");
2313 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2314 ut_params->ibuf, data_pad_len);
2316 memset(sym_op->auth.digest.data, 0, 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 = auth_offset + cipher_offset;
2332 sym_op->auth.data.length = auth_len;
2333 sym_op->auth.data.offset = auth_offset + cipher_offset;
2339 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2341 struct crypto_testsuite_params *ts_params = &testsuite_params;
2342 struct crypto_unittest_params *ut_params = &unittest_params;
2345 unsigned plaintext_pad_len;
2346 unsigned plaintext_len;
2349 /* Create SNOW 3G session */
2350 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2351 tdata->key.data, tdata->key.len,
2352 tdata->auth_iv.len, tdata->digest.len,
2353 RTE_CRYPTO_AUTH_OP_GENERATE,
2354 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2358 /* alloc mbuf and set payload */
2359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2361 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2362 rte_pktmbuf_tailroom(ut_params->ibuf));
2364 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2365 /* Append data which is padded to a multiple of */
2366 /* the algorithms block size */
2367 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2368 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2370 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2372 /* Create SNOW 3G operation */
2373 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2374 tdata->auth_iv.data, tdata->auth_iv.len,
2375 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2376 tdata->validAuthLenInBits.len,
2381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2383 ut_params->obuf = ut_params->op->sym->m_src;
2384 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2385 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2386 + plaintext_pad_len;
2389 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2392 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2393 "SNOW 3G Generated auth tag not as expected");
2399 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2401 struct crypto_testsuite_params *ts_params = &testsuite_params;
2402 struct crypto_unittest_params *ut_params = &unittest_params;
2405 unsigned plaintext_pad_len;
2406 unsigned plaintext_len;
2409 /* Create SNOW 3G session */
2410 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2411 tdata->key.data, tdata->key.len,
2412 tdata->auth_iv.len, tdata->digest.len,
2413 RTE_CRYPTO_AUTH_OP_VERIFY,
2414 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2417 /* alloc mbuf and set payload */
2418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2420 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2421 rte_pktmbuf_tailroom(ut_params->ibuf));
2423 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2424 /* Append data which is padded to a multiple of */
2425 /* the algorithms block size */
2426 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2429 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2431 /* Create SNOW 3G operation */
2432 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2434 tdata->auth_iv.data, tdata->auth_iv.len,
2436 RTE_CRYPTO_AUTH_OP_VERIFY,
2437 tdata->validAuthLenInBits.len,
2442 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2444 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2445 ut_params->obuf = ut_params->op->sym->m_src;
2446 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2447 + plaintext_pad_len;
2450 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2459 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2461 struct crypto_testsuite_params *ts_params = &testsuite_params;
2462 struct crypto_unittest_params *ut_params = &unittest_params;
2465 unsigned plaintext_pad_len;
2466 unsigned plaintext_len;
2469 /* Create KASUMI session */
2470 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2471 tdata->key.data, tdata->key.len,
2472 tdata->auth_iv.len, tdata->digest.len,
2473 RTE_CRYPTO_AUTH_OP_GENERATE,
2474 RTE_CRYPTO_AUTH_KASUMI_F9);
2478 /* alloc mbuf and set payload */
2479 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2481 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2482 rte_pktmbuf_tailroom(ut_params->ibuf));
2484 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2485 /* Append data which is padded to a multiple of */
2486 /* the algorithms block size */
2487 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2488 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2490 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2492 /* Create KASUMI operation */
2493 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2494 tdata->auth_iv.data, tdata->auth_iv.len,
2495 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2496 tdata->validAuthLenInBits.len,
2501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2503 ut_params->obuf = ut_params->op->sym->m_src;
2504 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2505 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2506 + plaintext_pad_len;
2509 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2512 DIGEST_BYTE_LENGTH_KASUMI_F9,
2513 "KASUMI Generated auth tag not as expected");
2519 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2521 struct crypto_testsuite_params *ts_params = &testsuite_params;
2522 struct crypto_unittest_params *ut_params = &unittest_params;
2525 unsigned plaintext_pad_len;
2526 unsigned plaintext_len;
2529 /* Create KASUMI session */
2530 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2531 tdata->key.data, tdata->key.len,
2532 tdata->auth_iv.len, tdata->digest.len,
2533 RTE_CRYPTO_AUTH_OP_VERIFY,
2534 RTE_CRYPTO_AUTH_KASUMI_F9);
2537 /* alloc mbuf and set payload */
2538 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2540 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2541 rte_pktmbuf_tailroom(ut_params->ibuf));
2543 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2544 /* Append data which is padded to a multiple */
2545 /* of the algorithms block size */
2546 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2547 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2549 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2551 /* Create KASUMI operation */
2552 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2554 tdata->auth_iv.data, tdata->auth_iv.len,
2556 RTE_CRYPTO_AUTH_OP_VERIFY,
2557 tdata->validAuthLenInBits.len,
2562 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2564 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2565 ut_params->obuf = ut_params->op->sym->m_src;
2566 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2567 + plaintext_pad_len;
2570 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2579 test_snow3g_hash_generate_test_case_1(void)
2581 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2585 test_snow3g_hash_generate_test_case_2(void)
2587 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2591 test_snow3g_hash_generate_test_case_3(void)
2593 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2597 test_snow3g_hash_generate_test_case_4(void)
2599 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2603 test_snow3g_hash_generate_test_case_5(void)
2605 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2609 test_snow3g_hash_generate_test_case_6(void)
2611 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2615 test_snow3g_hash_verify_test_case_1(void)
2617 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2622 test_snow3g_hash_verify_test_case_2(void)
2624 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2628 test_snow3g_hash_verify_test_case_3(void)
2630 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2634 test_snow3g_hash_verify_test_case_4(void)
2636 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2640 test_snow3g_hash_verify_test_case_5(void)
2642 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2646 test_snow3g_hash_verify_test_case_6(void)
2648 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2652 test_kasumi_hash_generate_test_case_1(void)
2654 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2658 test_kasumi_hash_generate_test_case_2(void)
2660 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2664 test_kasumi_hash_generate_test_case_3(void)
2666 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2670 test_kasumi_hash_generate_test_case_4(void)
2672 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2676 test_kasumi_hash_generate_test_case_5(void)
2678 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2682 test_kasumi_hash_generate_test_case_6(void)
2684 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2688 test_kasumi_hash_verify_test_case_1(void)
2690 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2694 test_kasumi_hash_verify_test_case_2(void)
2696 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2700 test_kasumi_hash_verify_test_case_3(void)
2702 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2706 test_kasumi_hash_verify_test_case_4(void)
2708 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2712 test_kasumi_hash_verify_test_case_5(void)
2714 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2718 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2720 struct crypto_testsuite_params *ts_params = &testsuite_params;
2721 struct crypto_unittest_params *ut_params = &unittest_params;
2724 uint8_t *plaintext, *ciphertext;
2725 unsigned plaintext_pad_len;
2726 unsigned plaintext_len;
2728 /* Create KASUMI session */
2729 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2730 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2731 RTE_CRYPTO_CIPHER_KASUMI_F8,
2732 tdata->key.data, tdata->key.len,
2733 tdata->cipher_iv.len);
2737 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2739 /* Clear mbuf payload */
2740 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2741 rte_pktmbuf_tailroom(ut_params->ibuf));
2743 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2744 /* Append data which is padded to a multiple */
2745 /* of the algorithms block size */
2746 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2747 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2749 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2751 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2753 /* Create KASUMI operation */
2754 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2755 tdata->cipher_iv.len,
2756 tdata->plaintext.len,
2761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2763 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2765 ut_params->obuf = ut_params->op->sym->m_dst;
2766 if (ut_params->obuf)
2767 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2769 ciphertext = plaintext;
2771 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2774 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2776 tdata->ciphertext.data,
2777 tdata->validCipherLenInBits.len,
2778 "KASUMI Ciphertext data not as expected");
2783 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2785 struct crypto_testsuite_params *ts_params = &testsuite_params;
2786 struct crypto_unittest_params *ut_params = &unittest_params;
2790 unsigned int plaintext_pad_len;
2791 unsigned int plaintext_len;
2793 uint8_t buffer[10000];
2794 const uint8_t *ciphertext;
2796 struct rte_cryptodev_info dev_info;
2798 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2799 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2800 printf("Device doesn't support scatter-gather. "
2805 /* Create KASUMI session */
2806 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2807 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2808 RTE_CRYPTO_CIPHER_KASUMI_F8,
2809 tdata->key.data, tdata->key.len,
2810 tdata->cipher_iv.len);
2814 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2817 /* Append data which is padded to a multiple */
2818 /* of the algorithms block size */
2819 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2821 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2822 plaintext_pad_len, 10, 0);
2824 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2826 /* Create KASUMI operation */
2827 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2828 tdata->cipher_iv.len,
2829 tdata->plaintext.len,
2834 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2836 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2838 ut_params->obuf = ut_params->op->sym->m_dst;
2840 if (ut_params->obuf)
2841 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2842 plaintext_len, buffer);
2844 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2845 plaintext_len, buffer);
2848 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2851 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2853 tdata->ciphertext.data,
2854 tdata->validCipherLenInBits.len,
2855 "KASUMI Ciphertext data not as expected");
2860 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2862 struct crypto_testsuite_params *ts_params = &testsuite_params;
2863 struct crypto_unittest_params *ut_params = &unittest_params;
2866 uint8_t *plaintext, *ciphertext;
2867 unsigned plaintext_pad_len;
2868 unsigned plaintext_len;
2870 /* Create KASUMI session */
2871 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2872 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2873 RTE_CRYPTO_CIPHER_KASUMI_F8,
2874 tdata->key.data, tdata->key.len,
2875 tdata->cipher_iv.len);
2879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2880 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2882 /* Clear mbuf payload */
2883 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2884 rte_pktmbuf_tailroom(ut_params->ibuf));
2886 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2887 /* Append data which is padded to a multiple */
2888 /* of the algorithms block size */
2889 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2890 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2892 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2893 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2895 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2897 /* Create KASUMI operation */
2898 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2899 tdata->cipher_iv.len,
2900 tdata->plaintext.len,
2905 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2907 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2909 ut_params->obuf = ut_params->op->sym->m_dst;
2910 if (ut_params->obuf)
2911 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2913 ciphertext = plaintext;
2915 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2918 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2920 tdata->ciphertext.data,
2921 tdata->validCipherLenInBits.len,
2922 "KASUMI Ciphertext data not as expected");
2927 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2929 struct crypto_testsuite_params *ts_params = &testsuite_params;
2930 struct crypto_unittest_params *ut_params = &unittest_params;
2933 unsigned int plaintext_pad_len;
2934 unsigned int plaintext_len;
2936 const uint8_t *ciphertext;
2937 uint8_t buffer[2048];
2939 struct rte_cryptodev_info dev_info;
2941 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2942 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2943 printf("Device doesn't support scatter-gather. "
2948 /* Create KASUMI session */
2949 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2950 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2951 RTE_CRYPTO_CIPHER_KASUMI_F8,
2952 tdata->key.data, tdata->key.len,
2953 tdata->cipher_iv.len);
2957 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2958 /* Append data which is padded to a multiple */
2959 /* of the algorithms block size */
2960 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2962 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2963 plaintext_pad_len, 10, 0);
2964 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2965 plaintext_pad_len, 3, 0);
2967 /* Append data which is padded to a multiple */
2968 /* of the algorithms block size */
2969 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2971 /* Create KASUMI operation */
2972 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2973 tdata->cipher_iv.len,
2974 tdata->plaintext.len,
2979 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2983 ut_params->obuf = ut_params->op->sym->m_dst;
2984 if (ut_params->obuf)
2985 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2986 plaintext_pad_len, buffer);
2988 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2989 plaintext_pad_len, buffer);
2992 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2994 tdata->ciphertext.data,
2995 tdata->validCipherLenInBits.len,
2996 "KASUMI Ciphertext data not as expected");
3002 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3004 struct crypto_testsuite_params *ts_params = &testsuite_params;
3005 struct crypto_unittest_params *ut_params = &unittest_params;
3008 uint8_t *ciphertext, *plaintext;
3009 unsigned ciphertext_pad_len;
3010 unsigned ciphertext_len;
3012 /* Create KASUMI session */
3013 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3014 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3015 RTE_CRYPTO_CIPHER_KASUMI_F8,
3016 tdata->key.data, tdata->key.len,
3017 tdata->cipher_iv.len);
3021 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3022 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3024 /* Clear mbuf payload */
3025 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3026 rte_pktmbuf_tailroom(ut_params->ibuf));
3028 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3029 /* Append data which is padded to a multiple */
3030 /* of the algorithms block size */
3031 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3032 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3033 ciphertext_pad_len);
3034 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3035 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3037 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3039 /* Create KASUMI operation */
3040 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3041 tdata->cipher_iv.len,
3042 tdata->ciphertext.len,
3047 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3049 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3051 ut_params->obuf = ut_params->op->sym->m_dst;
3052 if (ut_params->obuf)
3053 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3055 plaintext = ciphertext;
3057 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3060 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3062 tdata->plaintext.data,
3063 tdata->validCipherLenInBits.len,
3064 "KASUMI Plaintext data not as expected");
3069 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3071 struct crypto_testsuite_params *ts_params = &testsuite_params;
3072 struct crypto_unittest_params *ut_params = &unittest_params;
3075 uint8_t *ciphertext, *plaintext;
3076 unsigned ciphertext_pad_len;
3077 unsigned ciphertext_len;
3079 /* Create KASUMI session */
3080 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3081 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3082 RTE_CRYPTO_CIPHER_KASUMI_F8,
3083 tdata->key.data, tdata->key.len,
3084 tdata->cipher_iv.len);
3088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3090 /* Clear mbuf payload */
3091 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3092 rte_pktmbuf_tailroom(ut_params->ibuf));
3094 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3095 /* Append data which is padded to a multiple */
3096 /* of the algorithms block size */
3097 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3098 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3099 ciphertext_pad_len);
3100 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3102 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3104 /* Create KASUMI operation */
3105 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3106 tdata->cipher_iv.len,
3107 tdata->ciphertext.len,
3112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3114 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3116 ut_params->obuf = ut_params->op->sym->m_dst;
3117 if (ut_params->obuf)
3118 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3120 plaintext = ciphertext;
3122 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3125 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3127 tdata->plaintext.data,
3128 tdata->validCipherLenInBits.len,
3129 "KASUMI Plaintext data not as expected");
3134 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3136 struct crypto_testsuite_params *ts_params = &testsuite_params;
3137 struct crypto_unittest_params *ut_params = &unittest_params;
3140 uint8_t *plaintext, *ciphertext;
3141 unsigned plaintext_pad_len;
3142 unsigned plaintext_len;
3144 /* Create SNOW 3G session */
3145 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3146 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3147 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3148 tdata->key.data, tdata->key.len,
3149 tdata->cipher_iv.len);
3153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3155 /* Clear mbuf payload */
3156 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3157 rte_pktmbuf_tailroom(ut_params->ibuf));
3159 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3160 /* Append data which is padded to a multiple of */
3161 /* the algorithms block size */
3162 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3167 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3169 /* Create SNOW 3G operation */
3170 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3171 tdata->cipher_iv.len,
3172 tdata->validCipherLenInBits.len,
3177 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3179 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3181 ut_params->obuf = ut_params->op->sym->m_dst;
3182 if (ut_params->obuf)
3183 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3185 ciphertext = plaintext;
3187 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3190 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3192 tdata->ciphertext.data,
3193 tdata->validDataLenInBits.len,
3194 "SNOW 3G Ciphertext data not as expected");
3200 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3202 struct crypto_testsuite_params *ts_params = &testsuite_params;
3203 struct crypto_unittest_params *ut_params = &unittest_params;
3204 uint8_t *plaintext, *ciphertext;
3207 unsigned plaintext_pad_len;
3208 unsigned plaintext_len;
3210 /* Create SNOW 3G session */
3211 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3212 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3213 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3214 tdata->key.data, tdata->key.len,
3215 tdata->cipher_iv.len);
3219 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3220 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3222 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3223 "Failed to allocate input buffer in mempool");
3224 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3225 "Failed to allocate output buffer in mempool");
3227 /* Clear mbuf payload */
3228 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3229 rte_pktmbuf_tailroom(ut_params->ibuf));
3231 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3232 /* Append data which is padded to a multiple of */
3233 /* the algorithms block size */
3234 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3235 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3237 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3238 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3240 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3242 /* Create SNOW 3G operation */
3243 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3244 tdata->cipher_iv.len,
3245 tdata->validCipherLenInBits.len,
3250 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3252 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3254 ut_params->obuf = ut_params->op->sym->m_dst;
3255 if (ut_params->obuf)
3256 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3258 ciphertext = plaintext;
3260 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3263 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3265 tdata->ciphertext.data,
3266 tdata->validDataLenInBits.len,
3267 "SNOW 3G Ciphertext data not as expected");
3272 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3274 struct crypto_testsuite_params *ts_params = &testsuite_params;
3275 struct crypto_unittest_params *ut_params = &unittest_params;
3278 unsigned int plaintext_pad_len;
3279 unsigned int plaintext_len;
3280 uint8_t buffer[10000];
3281 const uint8_t *ciphertext;
3283 struct rte_cryptodev_info dev_info;
3285 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3286 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3287 printf("Device doesn't support scatter-gather. "
3292 /* Create SNOW 3G session */
3293 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3294 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3295 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3296 tdata->key.data, tdata->key.len,
3297 tdata->cipher_iv.len);
3301 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3302 /* Append data which is padded to a multiple of */
3303 /* the algorithms block size */
3304 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3306 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3307 plaintext_pad_len, 10, 0);
3308 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3309 plaintext_pad_len, 3, 0);
3311 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3312 "Failed to allocate input buffer in mempool");
3313 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3314 "Failed to allocate output buffer in mempool");
3316 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3318 /* Create SNOW 3G operation */
3319 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3320 tdata->cipher_iv.len,
3321 tdata->validCipherLenInBits.len,
3326 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3328 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3330 ut_params->obuf = ut_params->op->sym->m_dst;
3331 if (ut_params->obuf)
3332 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3333 plaintext_len, buffer);
3335 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3336 plaintext_len, buffer);
3338 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3341 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3343 tdata->ciphertext.data,
3344 tdata->validDataLenInBits.len,
3345 "SNOW 3G Ciphertext data not as expected");
3350 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3352 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3354 uint8_t curr_byte, prev_byte;
3355 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3356 uint8_t lower_byte_mask = (1 << offset) - 1;
3359 prev_byte = buffer[0];
3360 buffer[0] >>= offset;
3362 for (i = 1; i < length_in_bytes; i++) {
3363 curr_byte = buffer[i];
3364 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3365 (curr_byte >> offset);
3366 prev_byte = curr_byte;
3371 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3373 struct crypto_testsuite_params *ts_params = &testsuite_params;
3374 struct crypto_unittest_params *ut_params = &unittest_params;
3375 uint8_t *plaintext, *ciphertext;
3377 uint32_t plaintext_len;
3378 uint32_t plaintext_pad_len;
3379 uint8_t extra_offset = 4;
3380 uint8_t *expected_ciphertext_shifted;
3382 /* Create SNOW 3G session */
3383 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3384 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3385 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3386 tdata->key.data, tdata->key.len,
3387 tdata->cipher_iv.len);
3391 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3392 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3394 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3395 "Failed to allocate input buffer in mempool");
3396 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3397 "Failed to allocate output buffer in mempool");
3399 /* Clear mbuf payload */
3400 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3401 rte_pktmbuf_tailroom(ut_params->ibuf));
3403 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3405 * Append data which is padded to a
3406 * multiple of the algorithms block size
3408 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3410 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3413 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3415 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3416 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3418 #ifdef RTE_APP_TEST_DEBUG
3419 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3421 /* Create SNOW 3G operation */
3422 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3423 tdata->cipher_iv.len,
3424 tdata->validCipherLenInBits.len,
3429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3433 ut_params->obuf = ut_params->op->sym->m_dst;
3434 if (ut_params->obuf)
3435 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3437 ciphertext = plaintext;
3439 #ifdef RTE_APP_TEST_DEBUG
3440 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3443 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3445 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3446 "failed to reserve memory for ciphertext shifted\n");
3448 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3449 ceil_byte_length(tdata->ciphertext.len));
3450 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3453 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3455 expected_ciphertext_shifted,
3456 tdata->validDataLenInBits.len,
3458 "SNOW 3G Ciphertext data not as expected");
3462 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3464 struct crypto_testsuite_params *ts_params = &testsuite_params;
3465 struct crypto_unittest_params *ut_params = &unittest_params;
3469 uint8_t *plaintext, *ciphertext;
3470 unsigned ciphertext_pad_len;
3471 unsigned ciphertext_len;
3473 /* Create SNOW 3G session */
3474 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3475 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3476 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3477 tdata->key.data, tdata->key.len,
3478 tdata->cipher_iv.len);
3482 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3484 /* Clear mbuf payload */
3485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3486 rte_pktmbuf_tailroom(ut_params->ibuf));
3488 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3489 /* Append data which is padded to a multiple of */
3490 /* the algorithms block size */
3491 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3492 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3493 ciphertext_pad_len);
3494 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3496 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3498 /* Create SNOW 3G operation */
3499 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3500 tdata->cipher_iv.len,
3501 tdata->validCipherLenInBits.len,
3506 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3509 ut_params->obuf = ut_params->op->sym->m_dst;
3510 if (ut_params->obuf)
3511 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3513 plaintext = ciphertext;
3515 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3518 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3519 tdata->plaintext.data,
3520 tdata->validDataLenInBits.len,
3521 "SNOW 3G Plaintext data not as expected");
3525 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3527 struct crypto_testsuite_params *ts_params = &testsuite_params;
3528 struct crypto_unittest_params *ut_params = &unittest_params;
3532 uint8_t *plaintext, *ciphertext;
3533 unsigned ciphertext_pad_len;
3534 unsigned ciphertext_len;
3536 /* Create SNOW 3G session */
3537 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3538 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3539 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3540 tdata->key.data, tdata->key.len,
3541 tdata->cipher_iv.len);
3545 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3546 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3548 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3549 "Failed to allocate input buffer");
3550 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3551 "Failed to allocate output buffer");
3553 /* Clear mbuf payload */
3554 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3555 rte_pktmbuf_tailroom(ut_params->ibuf));
3557 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3558 rte_pktmbuf_tailroom(ut_params->obuf));
3560 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3561 /* Append data which is padded to a multiple of */
3562 /* the algorithms block size */
3563 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3564 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3565 ciphertext_pad_len);
3566 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3567 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3569 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3571 /* Create SNOW 3G operation */
3572 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3573 tdata->cipher_iv.len,
3574 tdata->validCipherLenInBits.len,
3579 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3581 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3582 ut_params->obuf = ut_params->op->sym->m_dst;
3583 if (ut_params->obuf)
3584 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3586 plaintext = ciphertext;
3588 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3591 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3592 tdata->plaintext.data,
3593 tdata->validDataLenInBits.len,
3594 "SNOW 3G Plaintext data not as expected");
3599 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3601 struct crypto_testsuite_params *ts_params = &testsuite_params;
3602 struct crypto_unittest_params *ut_params = &unittest_params;
3606 uint8_t *plaintext, *ciphertext;
3607 unsigned int plaintext_pad_len;
3608 unsigned int plaintext_len;
3610 struct rte_cryptodev_sym_capability_idx cap_idx;
3612 /* Check if device supports ZUC EEA3 */
3613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3614 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3616 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3620 /* Check if device supports ZUC EIA3 */
3621 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3622 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3624 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3628 /* Create ZUC session */
3629 retval = create_zuc_cipher_auth_encrypt_generate_session(
3630 ts_params->valid_devs[0],
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3636 /* clear mbuf payload */
3637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3638 rte_pktmbuf_tailroom(ut_params->ibuf));
3640 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3641 /* Append data which is padded to a multiple of */
3642 /* the algorithms block size */
3643 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3644 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3648 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3650 /* Create ZUC operation */
3651 retval = create_zuc_cipher_hash_generate_operation(tdata);
3655 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3658 ut_params->obuf = ut_params->op->sym->m_src;
3659 if (ut_params->obuf)
3660 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3662 ciphertext = plaintext;
3664 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3666 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3668 tdata->ciphertext.data,
3669 tdata->validDataLenInBits.len,
3670 "ZUC Ciphertext data not as expected");
3672 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3673 + plaintext_pad_len;
3676 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3680 "ZUC Generated auth tag not as expected");
3685 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3687 struct crypto_testsuite_params *ts_params = &testsuite_params;
3688 struct crypto_unittest_params *ut_params = &unittest_params;
3692 uint8_t *plaintext, *ciphertext;
3693 unsigned plaintext_pad_len;
3694 unsigned plaintext_len;
3696 /* Create SNOW 3G session */
3697 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3698 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3699 RTE_CRYPTO_AUTH_OP_GENERATE,
3700 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3701 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3702 tdata->key.data, tdata->key.len,
3703 tdata->auth_iv.len, tdata->digest.len,
3704 tdata->cipher_iv.len);
3707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3709 /* clear mbuf payload */
3710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3711 rte_pktmbuf_tailroom(ut_params->ibuf));
3713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3714 /* Append data which is padded to a multiple of */
3715 /* the algorithms block size */
3716 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3717 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3719 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3721 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3723 /* Create SNOW 3G operation */
3724 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3725 tdata->digest.len, tdata->auth_iv.data,
3727 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3728 tdata->cipher_iv.data, tdata->cipher_iv.len,
3729 tdata->validCipherLenInBits.len,
3731 tdata->validAuthLenInBits.len,
3737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3740 ut_params->obuf = ut_params->op->sym->m_src;
3741 if (ut_params->obuf)
3742 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3744 ciphertext = plaintext;
3746 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3748 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3750 tdata->ciphertext.data,
3751 tdata->validDataLenInBits.len,
3752 "SNOW 3G Ciphertext data not as expected");
3754 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3755 + plaintext_pad_len;
3758 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3761 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3762 "SNOW 3G Generated auth tag not as expected");
3766 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3768 struct crypto_testsuite_params *ts_params = &testsuite_params;
3769 struct crypto_unittest_params *ut_params = &unittest_params;
3773 uint8_t *plaintext, *ciphertext;
3774 unsigned plaintext_pad_len;
3775 unsigned plaintext_len;
3777 /* Create SNOW 3G session */
3778 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3779 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3780 RTE_CRYPTO_AUTH_OP_GENERATE,
3781 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3782 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3783 tdata->key.data, tdata->key.len,
3784 tdata->auth_iv.len, tdata->digest.len,
3785 tdata->cipher_iv.len);
3789 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 /* clear mbuf payload */
3792 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3793 rte_pktmbuf_tailroom(ut_params->ibuf));
3795 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3796 /* Append data which is padded to a multiple of */
3797 /* the algorithms block size */
3798 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3799 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3801 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3803 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3805 /* Create SNOW 3G operation */
3806 retval = create_wireless_algo_auth_cipher_operation(
3808 tdata->cipher_iv.data, tdata->cipher_iv.len,
3809 tdata->auth_iv.data, tdata->auth_iv.len,
3811 tdata->validCipherLenInBits.len,
3813 tdata->validAuthLenInBits.len,
3819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3822 ut_params->obuf = ut_params->op->sym->m_src;
3823 if (ut_params->obuf)
3824 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3826 ciphertext = plaintext;
3828 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3829 + plaintext_pad_len;
3830 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3833 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3835 tdata->ciphertext.data,
3836 tdata->validDataLenInBits.len,
3837 "SNOW 3G Ciphertext data not as expected");
3840 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3843 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3844 "SNOW 3G Generated auth tag not as expected");
3849 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3851 struct crypto_testsuite_params *ts_params = &testsuite_params;
3852 struct crypto_unittest_params *ut_params = &unittest_params;
3856 uint8_t *plaintext, *ciphertext;
3857 unsigned plaintext_pad_len;
3858 unsigned plaintext_len;
3860 /* Create KASUMI session */
3861 retval = create_wireless_algo_auth_cipher_session(
3862 ts_params->valid_devs[0],
3863 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3864 RTE_CRYPTO_AUTH_OP_GENERATE,
3865 RTE_CRYPTO_AUTH_KASUMI_F9,
3866 RTE_CRYPTO_CIPHER_KASUMI_F8,
3867 tdata->key.data, tdata->key.len,
3868 tdata->auth_iv.len, tdata->digest.len,
3869 tdata->cipher_iv.len);
3872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3874 /* clear mbuf payload */
3875 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3876 rte_pktmbuf_tailroom(ut_params->ibuf));
3878 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3879 /* Append data which is padded to a multiple of */
3880 /* the algorithms block size */
3881 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3882 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3886 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3888 /* Create KASUMI operation */
3889 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3890 tdata->cipher_iv.data, tdata->cipher_iv.len,
3891 tdata->auth_iv.data, tdata->auth_iv.len,
3893 tdata->validCipherLenInBits.len,
3895 tdata->validAuthLenInBits.len,
3902 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3904 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3905 ut_params->obuf = ut_params->op->sym->m_src;
3906 if (ut_params->obuf)
3907 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3909 ciphertext = plaintext;
3912 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3914 tdata->ciphertext.data,
3915 tdata->validCipherLenInBits.len,
3916 "KASUMI Ciphertext data not as expected");
3917 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3918 + plaintext_pad_len;
3921 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3924 DIGEST_BYTE_LENGTH_KASUMI_F9,
3925 "KASUMI Generated auth tag not as expected");
3930 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3932 struct crypto_testsuite_params *ts_params = &testsuite_params;
3933 struct crypto_unittest_params *ut_params = &unittest_params;
3937 uint8_t *plaintext, *ciphertext;
3938 unsigned plaintext_pad_len;
3939 unsigned plaintext_len;
3941 /* Create KASUMI session */
3942 retval = create_wireless_algo_cipher_auth_session(
3943 ts_params->valid_devs[0],
3944 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3945 RTE_CRYPTO_AUTH_OP_GENERATE,
3946 RTE_CRYPTO_AUTH_KASUMI_F9,
3947 RTE_CRYPTO_CIPHER_KASUMI_F8,
3948 tdata->key.data, tdata->key.len,
3949 tdata->auth_iv.len, tdata->digest.len,
3950 tdata->cipher_iv.len);
3954 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3956 /* clear mbuf payload */
3957 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3958 rte_pktmbuf_tailroom(ut_params->ibuf));
3960 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3961 /* Append data which is padded to a multiple of */
3962 /* the algorithms block size */
3963 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3964 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3966 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3968 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3970 /* Create KASUMI operation */
3971 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3972 tdata->digest.len, tdata->auth_iv.data,
3974 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3975 tdata->cipher_iv.data, tdata->cipher_iv.len,
3976 tdata->validCipherLenInBits.len,
3978 tdata->validAuthLenInBits.len,
3984 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3986 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3987 ut_params->obuf = ut_params->op->sym->m_src;
3988 if (ut_params->obuf)
3989 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3991 ciphertext = plaintext;
3993 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3994 + plaintext_pad_len;
3997 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3999 tdata->ciphertext.data,
4000 tdata->validCipherLenInBits.len,
4001 "KASUMI Ciphertext data not as expected");
4004 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4007 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4008 "KASUMI Generated auth tag not as expected");
4013 test_zuc_encryption(const struct wireless_test_data *tdata)
4015 struct crypto_testsuite_params *ts_params = &testsuite_params;
4016 struct crypto_unittest_params *ut_params = &unittest_params;
4019 uint8_t *plaintext, *ciphertext;
4020 unsigned plaintext_pad_len;
4021 unsigned plaintext_len;
4023 struct rte_cryptodev_sym_capability_idx cap_idx;
4025 /* Check if device supports ZUC EEA3 */
4026 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4027 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4029 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4033 /* Create ZUC session */
4034 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4035 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4036 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4037 tdata->key.data, tdata->key.len,
4038 tdata->cipher_iv.len);
4042 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4044 /* Clear mbuf payload */
4045 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4046 rte_pktmbuf_tailroom(ut_params->ibuf));
4048 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4049 /* Append data which is padded to a multiple */
4050 /* of the algorithms block size */
4051 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4052 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4054 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4056 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4058 /* Create ZUC operation */
4059 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4060 tdata->cipher_iv.len,
4061 tdata->plaintext.len,
4066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4070 ut_params->obuf = ut_params->op->sym->m_dst;
4071 if (ut_params->obuf)
4072 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4074 ciphertext = plaintext;
4076 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4079 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4081 tdata->ciphertext.data,
4082 tdata->validCipherLenInBits.len,
4083 "ZUC Ciphertext data not as expected");
4088 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4090 struct crypto_testsuite_params *ts_params = &testsuite_params;
4091 struct crypto_unittest_params *ut_params = &unittest_params;
4095 unsigned int plaintext_pad_len;
4096 unsigned int plaintext_len;
4097 const uint8_t *ciphertext;
4098 uint8_t ciphertext_buffer[2048];
4099 struct rte_cryptodev_info dev_info;
4101 struct rte_cryptodev_sym_capability_idx cap_idx;
4103 /* Check if device supports ZUC EEA3 */
4104 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4105 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4111 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4112 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4113 printf("Device doesn't support scatter-gather. "
4118 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4120 /* Append data which is padded to a multiple */
4121 /* of the algorithms block size */
4122 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4124 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4125 plaintext_pad_len, 10, 0);
4127 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4128 tdata->plaintext.data);
4130 /* Create ZUC session */
4131 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4132 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4133 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4134 tdata->key.data, tdata->key.len,
4135 tdata->cipher_iv.len);
4139 /* Clear mbuf payload */
4141 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4143 /* Create ZUC operation */
4144 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4145 tdata->cipher_iv.len, tdata->plaintext.len,
4150 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4152 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4154 ut_params->obuf = ut_params->op->sym->m_dst;
4155 if (ut_params->obuf)
4156 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4157 0, plaintext_len, ciphertext_buffer);
4159 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4160 0, plaintext_len, ciphertext_buffer);
4163 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4168 tdata->ciphertext.data,
4169 tdata->validCipherLenInBits.len,
4170 "ZUC Ciphertext data not as expected");
4176 test_zuc_authentication(const struct wireless_test_data *tdata)
4178 struct crypto_testsuite_params *ts_params = &testsuite_params;
4179 struct crypto_unittest_params *ut_params = &unittest_params;
4182 unsigned plaintext_pad_len;
4183 unsigned plaintext_len;
4186 struct rte_cryptodev_sym_capability_idx cap_idx;
4188 /* Check if device supports ZUC EIA3 */
4189 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4190 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4192 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4196 /* Create ZUC session */
4197 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4198 tdata->key.data, tdata->key.len,
4199 tdata->auth_iv.len, tdata->digest.len,
4200 RTE_CRYPTO_AUTH_OP_GENERATE,
4201 RTE_CRYPTO_AUTH_ZUC_EIA3);
4205 /* alloc mbuf and set payload */
4206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4208 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4209 rte_pktmbuf_tailroom(ut_params->ibuf));
4211 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4212 /* Append data which is padded to a multiple of */
4213 /* the algorithms block size */
4214 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4215 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4217 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4219 /* Create ZUC operation */
4220 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4221 tdata->auth_iv.data, tdata->auth_iv.len,
4222 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4223 tdata->validAuthLenInBits.len,
4228 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4230 ut_params->obuf = ut_params->op->sym->m_src;
4231 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4232 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4233 + plaintext_pad_len;
4236 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4239 DIGEST_BYTE_LENGTH_KASUMI_F9,
4240 "ZUC Generated auth tag not as expected");
4246 test_kasumi_encryption_test_case_1(void)
4248 return test_kasumi_encryption(&kasumi_test_case_1);
4252 test_kasumi_encryption_test_case_1_sgl(void)
4254 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4258 test_kasumi_encryption_test_case_1_oop(void)
4260 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4264 test_kasumi_encryption_test_case_1_oop_sgl(void)
4266 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4270 test_kasumi_encryption_test_case_2(void)
4272 return test_kasumi_encryption(&kasumi_test_case_2);
4276 test_kasumi_encryption_test_case_3(void)
4278 return test_kasumi_encryption(&kasumi_test_case_3);
4282 test_kasumi_encryption_test_case_4(void)
4284 return test_kasumi_encryption(&kasumi_test_case_4);
4288 test_kasumi_encryption_test_case_5(void)
4290 return test_kasumi_encryption(&kasumi_test_case_5);
4294 test_kasumi_decryption_test_case_1(void)
4296 return test_kasumi_decryption(&kasumi_test_case_1);
4300 test_kasumi_decryption_test_case_1_oop(void)
4302 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4306 test_kasumi_decryption_test_case_2(void)
4308 return test_kasumi_decryption(&kasumi_test_case_2);
4312 test_kasumi_decryption_test_case_3(void)
4314 return test_kasumi_decryption(&kasumi_test_case_3);
4318 test_kasumi_decryption_test_case_4(void)
4320 return test_kasumi_decryption(&kasumi_test_case_4);
4324 test_kasumi_decryption_test_case_5(void)
4326 return test_kasumi_decryption(&kasumi_test_case_5);
4329 test_snow3g_encryption_test_case_1(void)
4331 return test_snow3g_encryption(&snow3g_test_case_1);
4335 test_snow3g_encryption_test_case_1_oop(void)
4337 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4341 test_snow3g_encryption_test_case_1_oop_sgl(void)
4343 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4348 test_snow3g_encryption_test_case_1_offset_oop(void)
4350 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4354 test_snow3g_encryption_test_case_2(void)
4356 return test_snow3g_encryption(&snow3g_test_case_2);
4360 test_snow3g_encryption_test_case_3(void)
4362 return test_snow3g_encryption(&snow3g_test_case_3);
4366 test_snow3g_encryption_test_case_4(void)
4368 return test_snow3g_encryption(&snow3g_test_case_4);
4372 test_snow3g_encryption_test_case_5(void)
4374 return test_snow3g_encryption(&snow3g_test_case_5);
4378 test_snow3g_decryption_test_case_1(void)
4380 return test_snow3g_decryption(&snow3g_test_case_1);
4384 test_snow3g_decryption_test_case_1_oop(void)
4386 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4390 test_snow3g_decryption_test_case_2(void)
4392 return test_snow3g_decryption(&snow3g_test_case_2);
4396 test_snow3g_decryption_test_case_3(void)
4398 return test_snow3g_decryption(&snow3g_test_case_3);
4402 test_snow3g_decryption_test_case_4(void)
4404 return test_snow3g_decryption(&snow3g_test_case_4);
4408 test_snow3g_decryption_test_case_5(void)
4410 return test_snow3g_decryption(&snow3g_test_case_5);
4413 test_snow3g_cipher_auth_test_case_1(void)
4415 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4419 test_snow3g_auth_cipher_test_case_1(void)
4421 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4425 test_kasumi_auth_cipher_test_case_1(void)
4427 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4431 test_kasumi_cipher_auth_test_case_1(void)
4433 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4437 test_zuc_encryption_test_case_1(void)
4439 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4443 test_zuc_encryption_test_case_2(void)
4445 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4449 test_zuc_encryption_test_case_3(void)
4451 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4455 test_zuc_encryption_test_case_4(void)
4457 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4461 test_zuc_encryption_test_case_5(void)
4463 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4467 test_zuc_encryption_test_case_6_sgl(void)
4469 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4473 test_zuc_hash_generate_test_case_1(void)
4475 return test_zuc_authentication(&zuc_test_case_auth_1b);
4479 test_zuc_hash_generate_test_case_2(void)
4481 return test_zuc_authentication(&zuc_test_case_auth_90b);
4485 test_zuc_hash_generate_test_case_3(void)
4487 return test_zuc_authentication(&zuc_test_case_auth_577b);
4491 test_zuc_hash_generate_test_case_4(void)
4493 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4497 test_zuc_hash_generate_test_case_5(void)
4499 return test_zuc_authentication(&zuc_test_auth_5670b);
4503 test_zuc_hash_generate_test_case_6(void)
4505 return test_zuc_authentication(&zuc_test_case_auth_128b);
4509 test_zuc_hash_generate_test_case_7(void)
4511 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4515 test_zuc_hash_generate_test_case_8(void)
4517 return test_zuc_authentication(&zuc_test_case_auth_584b);
4521 test_zuc_cipher_auth_test_case_1(void)
4523 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4527 test_zuc_cipher_auth_test_case_2(void)
4529 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4533 test_3DES_chain_qat_all(void)
4535 struct crypto_testsuite_params *ts_params = &testsuite_params;
4538 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4539 ts_params->op_mpool, ts_params->valid_devs[0],
4540 rte_cryptodev_driver_id_get(
4541 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4542 BLKCIPHER_3DES_CHAIN_TYPE);
4544 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4546 return TEST_SUCCESS;
4550 test_DES_cipheronly_qat_all(void)
4552 struct crypto_testsuite_params *ts_params = &testsuite_params;
4555 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4556 ts_params->op_mpool, ts_params->valid_devs[0],
4557 rte_cryptodev_driver_id_get(
4558 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4559 BLKCIPHER_DES_CIPHERONLY_TYPE);
4561 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4563 return TEST_SUCCESS;
4567 test_DES_docsis_openssl_all(void)
4569 struct crypto_testsuite_params *ts_params = &testsuite_params;
4572 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4573 ts_params->op_mpool, ts_params->valid_devs[0],
4574 rte_cryptodev_driver_id_get(
4575 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4576 BLKCIPHER_DES_DOCSIS_TYPE);
4578 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4580 return TEST_SUCCESS;
4584 test_3DES_chain_dpaa2_sec_all(void)
4586 struct crypto_testsuite_params *ts_params = &testsuite_params;
4589 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4590 ts_params->op_mpool, ts_params->valid_devs[0],
4591 rte_cryptodev_driver_id_get(
4592 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4593 BLKCIPHER_3DES_CHAIN_TYPE);
4595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4597 return TEST_SUCCESS;
4601 test_3DES_cipheronly_dpaa2_sec_all(void)
4603 struct crypto_testsuite_params *ts_params = &testsuite_params;
4606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4607 ts_params->op_mpool, ts_params->valid_devs[0],
4608 rte_cryptodev_driver_id_get(
4609 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4610 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4612 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4614 return TEST_SUCCESS;
4618 test_3DES_cipheronly_qat_all(void)
4620 struct crypto_testsuite_params *ts_params = &testsuite_params;
4623 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4624 ts_params->op_mpool, ts_params->valid_devs[0],
4625 rte_cryptodev_driver_id_get(
4626 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4627 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4629 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4631 return TEST_SUCCESS;
4635 test_3DES_chain_openssl_all(void)
4637 struct crypto_testsuite_params *ts_params = &testsuite_params;
4640 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4641 ts_params->op_mpool, ts_params->valid_devs[0],
4642 rte_cryptodev_driver_id_get(
4643 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4644 BLKCIPHER_3DES_CHAIN_TYPE);
4646 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4648 return TEST_SUCCESS;
4652 test_3DES_cipheronly_openssl_all(void)
4654 struct crypto_testsuite_params *ts_params = &testsuite_params;
4657 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4658 ts_params->op_mpool, ts_params->valid_devs[0],
4659 rte_cryptodev_driver_id_get(
4660 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4661 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4663 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4665 return TEST_SUCCESS;
4668 /* ***** AES-GCM Tests ***** */
4671 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4672 const uint8_t *key, const uint8_t key_len,
4673 const uint16_t aad_len, const uint8_t auth_len,
4676 uint8_t aead_key[key_len];
4678 struct crypto_unittest_params *ut_params = &unittest_params;
4680 memcpy(aead_key, key, key_len);
4682 /* Setup AEAD Parameters */
4683 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4684 ut_params->aead_xform.next = NULL;
4685 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4686 ut_params->aead_xform.aead.op = op;
4687 ut_params->aead_xform.aead.key.data = aead_key;
4688 ut_params->aead_xform.aead.key.length = key_len;
4689 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4690 ut_params->aead_xform.aead.iv.length = iv_len;
4691 ut_params->aead_xform.aead.digest_length = auth_len;
4692 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4694 TEST_HEXDUMP(stdout, "key:", key, key_len);
4696 /* Create Crypto session*/
4697 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4698 &ut_params->aead_xform);
4700 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4706 create_gcm_xforms(struct rte_crypto_op *op,
4707 enum rte_crypto_aead_operation aead_op,
4708 uint8_t *key, const uint8_t key_len,
4709 const uint8_t aad_len, const uint8_t auth_len,
4712 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4713 "failed to allocate space for crypto transform");
4715 struct rte_crypto_sym_op *sym_op = op->sym;
4717 /* Setup AEAD Parameters */
4718 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4719 sym_op->xform->next = NULL;
4720 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4721 sym_op->xform->aead.op = aead_op;
4722 sym_op->xform->aead.key.data = key;
4723 sym_op->xform->aead.key.length = key_len;
4724 sym_op->xform->aead.iv.offset = IV_OFFSET;
4725 sym_op->xform->aead.iv.length = iv_len;
4726 sym_op->xform->aead.digest_length = auth_len;
4727 sym_op->xform->aead.add_auth_data_length = aad_len;
4729 TEST_HEXDUMP(stdout, "key:", key, key_len);
4735 create_gcm_operation(enum rte_crypto_aead_operation op,
4736 const struct gcm_test_data *tdata)
4738 struct crypto_testsuite_params *ts_params = &testsuite_params;
4739 struct crypto_unittest_params *ut_params = &unittest_params;
4741 uint8_t *plaintext, *ciphertext;
4742 unsigned int aad_pad_len, plaintext_pad_len;
4744 /* Generate Crypto op data structure */
4745 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4746 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4747 TEST_ASSERT_NOT_NULL(ut_params->op,
4748 "Failed to allocate symmetric crypto operation struct");
4750 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4752 /* Append aad data */
4753 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4754 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4756 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4757 "no room to append aad");
4759 sym_op->aead.aad.phys_addr =
4760 rte_pktmbuf_mtophys(ut_params->ibuf);
4761 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4762 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4765 /* Append IV at the end of the crypto operation*/
4766 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4767 uint8_t *, IV_OFFSET);
4769 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4770 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4773 /* Append plaintext/ciphertext */
4774 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4775 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4776 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4778 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4780 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4781 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4782 tdata->plaintext.len);
4784 if (ut_params->obuf) {
4785 ciphertext = (uint8_t *)rte_pktmbuf_append(
4787 plaintext_pad_len + aad_pad_len);
4788 TEST_ASSERT_NOT_NULL(ciphertext,
4789 "no room to append ciphertext");
4791 memset(ciphertext + aad_pad_len, 0,
4792 tdata->ciphertext.len);
4795 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4796 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4798 TEST_ASSERT_NOT_NULL(ciphertext,
4799 "no room to append ciphertext");
4801 memcpy(ciphertext, tdata->ciphertext.data,
4802 tdata->ciphertext.len);
4803 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4804 tdata->ciphertext.len);
4806 if (ut_params->obuf) {
4807 plaintext = (uint8_t *)rte_pktmbuf_append(
4809 plaintext_pad_len + aad_pad_len);
4810 TEST_ASSERT_NOT_NULL(plaintext,
4811 "no room to append plaintext");
4813 memset(plaintext + aad_pad_len, 0,
4814 tdata->plaintext.len);
4818 /* Append digest data */
4819 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4820 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4821 ut_params->obuf ? ut_params->obuf :
4823 tdata->auth_tag.len);
4824 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4825 "no room to append digest");
4826 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4827 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4828 ut_params->obuf ? ut_params->obuf :
4833 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4834 ut_params->ibuf, tdata->auth_tag.len);
4835 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4836 "no room to append digest");
4837 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4839 plaintext_pad_len + aad_pad_len);
4841 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4842 tdata->auth_tag.len);
4843 TEST_HEXDUMP(stdout, "digest:",
4844 sym_op->aead.digest.data,
4845 tdata->auth_tag.len);
4848 sym_op->aead.data.length = tdata->plaintext.len;
4849 sym_op->aead.data.offset = aad_pad_len;
4855 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4857 struct crypto_testsuite_params *ts_params = &testsuite_params;
4858 struct crypto_unittest_params *ut_params = &unittest_params;
4861 uint8_t *ciphertext, *auth_tag;
4862 uint16_t plaintext_pad_len;
4865 /* Create GCM session */
4866 retval = create_gcm_session(ts_params->valid_devs[0],
4867 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4868 tdata->key.data, tdata->key.len,
4869 tdata->aad.len, tdata->auth_tag.len,
4874 if (tdata->aad.len > MBUF_SIZE) {
4875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4876 /* Populate full size of add data */
4877 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4878 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4880 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4882 /* clear mbuf payload */
4883 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4884 rte_pktmbuf_tailroom(ut_params->ibuf));
4886 /* Create GCM operation */
4887 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4893 ut_params->op->sym->m_src = ut_params->ibuf;
4895 /* Process crypto operation */
4896 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4897 ut_params->op), "failed to process sym crypto op");
4899 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4900 "crypto op processing failed");
4902 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4904 if (ut_params->op->sym->m_dst) {
4905 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4907 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4908 uint8_t *, plaintext_pad_len);
4910 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4912 ut_params->op->sym->cipher.data.offset);
4913 auth_tag = ciphertext + plaintext_pad_len;
4916 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4917 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4922 tdata->ciphertext.data,
4923 tdata->ciphertext.len,
4924 "GCM Ciphertext data not as expected");
4926 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4928 tdata->auth_tag.data,
4929 tdata->auth_tag.len,
4930 "GCM Generated auth tag not as expected");
4937 test_AES_GCM_authenticated_encryption_test_case_1(void)
4939 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4943 test_AES_GCM_authenticated_encryption_test_case_2(void)
4945 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4949 test_AES_GCM_authenticated_encryption_test_case_3(void)
4951 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4955 test_AES_GCM_authenticated_encryption_test_case_4(void)
4957 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4961 test_AES_GCM_authenticated_encryption_test_case_5(void)
4963 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4967 test_AES_GCM_authenticated_encryption_test_case_6(void)
4969 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4973 test_AES_GCM_authenticated_encryption_test_case_7(void)
4975 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4979 test_AES_GCM_auth_encryption_test_case_192_1(void)
4981 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
4985 test_AES_GCM_auth_encryption_test_case_192_2(void)
4987 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
4991 test_AES_GCM_auth_encryption_test_case_192_3(void)
4993 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
4997 test_AES_GCM_auth_encryption_test_case_192_4(void)
4999 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
5003 test_AES_GCM_auth_encryption_test_case_192_5(void)
5005 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
5009 test_AES_GCM_auth_encryption_test_case_192_6(void)
5011 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
5015 test_AES_GCM_auth_encryption_test_case_192_7(void)
5017 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
5021 test_AES_GCM_auth_encryption_test_case_256_1(void)
5023 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5027 test_AES_GCM_auth_encryption_test_case_256_2(void)
5029 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5033 test_AES_GCM_auth_encryption_test_case_256_3(void)
5035 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5039 test_AES_GCM_auth_encryption_test_case_256_4(void)
5041 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5045 test_AES_GCM_auth_encryption_test_case_256_5(void)
5047 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5051 test_AES_GCM_auth_encryption_test_case_256_6(void)
5053 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5057 test_AES_GCM_auth_encryption_test_case_256_7(void)
5059 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5063 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5065 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5069 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5071 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5075 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5077 struct crypto_testsuite_params *ts_params = &testsuite_params;
5078 struct crypto_unittest_params *ut_params = &unittest_params;
5084 /* Create GCM session */
5085 retval = create_gcm_session(ts_params->valid_devs[0],
5086 RTE_CRYPTO_AEAD_OP_DECRYPT,
5087 tdata->key.data, tdata->key.len,
5088 tdata->aad.len, tdata->auth_tag.len,
5093 /* alloc mbuf and set payload */
5094 if (tdata->aad.len > MBUF_SIZE) {
5095 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5096 /* Populate full size of add data */
5097 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5098 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5103 rte_pktmbuf_tailroom(ut_params->ibuf));
5105 /* Create GCM operation */
5106 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5110 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5112 ut_params->op->sym->m_src = ut_params->ibuf;
5114 /* Process crypto operation */
5115 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5116 ut_params->op), "failed to process sym crypto op");
5118 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5119 "crypto op processing failed");
5121 if (ut_params->op->sym->m_dst)
5122 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5125 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5127 ut_params->op->sym->cipher.data.offset);
5129 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5132 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5134 tdata->plaintext.data,
5135 tdata->plaintext.len,
5136 "GCM plaintext data not as expected");
5138 TEST_ASSERT_EQUAL(ut_params->op->status,
5139 RTE_CRYPTO_OP_STATUS_SUCCESS,
5140 "GCM authentication failed");
5145 test_AES_GCM_authenticated_decryption_test_case_1(void)
5147 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5151 test_AES_GCM_authenticated_decryption_test_case_2(void)
5153 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5157 test_AES_GCM_authenticated_decryption_test_case_3(void)
5159 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5163 test_AES_GCM_authenticated_decryption_test_case_4(void)
5165 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5169 test_AES_GCM_authenticated_decryption_test_case_5(void)
5171 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5175 test_AES_GCM_authenticated_decryption_test_case_6(void)
5177 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5181 test_AES_GCM_authenticated_decryption_test_case_7(void)
5183 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5187 test_AES_GCM_auth_decryption_test_case_192_1(void)
5189 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5193 test_AES_GCM_auth_decryption_test_case_192_2(void)
5195 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5199 test_AES_GCM_auth_decryption_test_case_192_3(void)
5201 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5205 test_AES_GCM_auth_decryption_test_case_192_4(void)
5207 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5211 test_AES_GCM_auth_decryption_test_case_192_5(void)
5213 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5217 test_AES_GCM_auth_decryption_test_case_192_6(void)
5219 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5223 test_AES_GCM_auth_decryption_test_case_192_7(void)
5225 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5229 test_AES_GCM_auth_decryption_test_case_256_1(void)
5231 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5235 test_AES_GCM_auth_decryption_test_case_256_2(void)
5237 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5241 test_AES_GCM_auth_decryption_test_case_256_3(void)
5243 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5247 test_AES_GCM_auth_decryption_test_case_256_4(void)
5249 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5253 test_AES_GCM_auth_decryption_test_case_256_5(void)
5255 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5259 test_AES_GCM_auth_decryption_test_case_256_6(void)
5261 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5265 test_AES_GCM_auth_decryption_test_case_256_7(void)
5267 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5271 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5273 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5277 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5279 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5283 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5285 struct crypto_testsuite_params *ts_params = &testsuite_params;
5286 struct crypto_unittest_params *ut_params = &unittest_params;
5289 uint8_t *ciphertext, *auth_tag;
5290 uint16_t plaintext_pad_len;
5292 /* Create GCM session */
5293 retval = create_gcm_session(ts_params->valid_devs[0],
5294 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5295 tdata->key.data, tdata->key.len,
5296 tdata->aad.len, tdata->auth_tag.len,
5301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5302 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5304 /* clear mbuf payload */
5305 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5306 rte_pktmbuf_tailroom(ut_params->ibuf));
5307 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5308 rte_pktmbuf_tailroom(ut_params->obuf));
5310 /* Create GCM operation */
5311 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5315 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5317 ut_params->op->sym->m_src = ut_params->ibuf;
5318 ut_params->op->sym->m_dst = ut_params->obuf;
5320 /* Process crypto operation */
5321 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5322 ut_params->op), "failed to process sym crypto op");
5324 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5325 "crypto op processing failed");
5327 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5329 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5330 ut_params->op->sym->cipher.data.offset);
5331 auth_tag = ciphertext + plaintext_pad_len;
5333 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5334 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5337 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5339 tdata->ciphertext.data,
5340 tdata->ciphertext.len,
5341 "GCM Ciphertext data not as expected");
5343 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5345 tdata->auth_tag.data,
5346 tdata->auth_tag.len,
5347 "GCM Generated auth tag not as expected");
5354 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5356 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5360 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5362 struct crypto_testsuite_params *ts_params = &testsuite_params;
5363 struct crypto_unittest_params *ut_params = &unittest_params;
5368 /* Create GCM session */
5369 retval = create_gcm_session(ts_params->valid_devs[0],
5370 RTE_CRYPTO_AEAD_OP_DECRYPT,
5371 tdata->key.data, tdata->key.len,
5372 tdata->aad.len, tdata->auth_tag.len,
5377 /* alloc mbuf and set payload */
5378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5379 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
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_DECRYPT, 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 = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5404 ut_params->op->sym->cipher.data.offset);
5406 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5409 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5411 tdata->plaintext.data,
5412 tdata->plaintext.len,
5413 "GCM plaintext data not as expected");
5415 TEST_ASSERT_EQUAL(ut_params->op->status,
5416 RTE_CRYPTO_OP_STATUS_SUCCESS,
5417 "GCM authentication failed");
5422 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5424 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5428 test_AES_GCM_authenticated_encryption_sessionless(
5429 const struct gcm_test_data *tdata)
5431 struct crypto_testsuite_params *ts_params = &testsuite_params;
5432 struct crypto_unittest_params *ut_params = &unittest_params;
5435 uint8_t *ciphertext, *auth_tag;
5436 uint16_t plaintext_pad_len;
5437 uint8_t key[tdata->key.len + 1];
5439 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5441 /* clear mbuf payload */
5442 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5443 rte_pktmbuf_tailroom(ut_params->ibuf));
5445 /* Create GCM operation */
5446 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5450 /* Create GCM xforms */
5451 memcpy(key, tdata->key.data, tdata->key.len);
5452 retval = create_gcm_xforms(ut_params->op,
5453 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5454 key, tdata->key.len,
5455 tdata->aad.len, tdata->auth_tag.len,
5460 ut_params->op->sym->m_src = ut_params->ibuf;
5462 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5463 RTE_CRYPTO_OP_SESSIONLESS,
5464 "crypto op session type not sessionless");
5466 /* Process crypto operation */
5467 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5468 ut_params->op), "failed to process sym crypto op");
5470 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5472 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5473 "crypto op status not success");
5475 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5477 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5478 ut_params->op->sym->cipher.data.offset);
5479 auth_tag = ciphertext + plaintext_pad_len;
5481 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5482 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5487 tdata->ciphertext.data,
5488 tdata->ciphertext.len,
5489 "GCM Ciphertext data not as expected");
5491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5493 tdata->auth_tag.data,
5494 tdata->auth_tag.len,
5495 "GCM Generated auth tag not as expected");
5502 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5504 return test_AES_GCM_authenticated_encryption_sessionless(
5509 test_AES_GCM_authenticated_decryption_sessionless(
5510 const struct gcm_test_data *tdata)
5512 struct crypto_testsuite_params *ts_params = &testsuite_params;
5513 struct crypto_unittest_params *ut_params = &unittest_params;
5517 uint8_t key[tdata->key.len + 1];
5519 /* alloc mbuf and set payload */
5520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5523 rte_pktmbuf_tailroom(ut_params->ibuf));
5525 /* Create GCM operation */
5526 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5530 /* Create GCM xforms */
5531 memcpy(key, tdata->key.data, tdata->key.len);
5532 retval = create_gcm_xforms(ut_params->op,
5533 RTE_CRYPTO_AEAD_OP_DECRYPT,
5534 key, tdata->key.len,
5535 tdata->aad.len, tdata->auth_tag.len,
5540 ut_params->op->sym->m_src = ut_params->ibuf;
5542 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5543 RTE_CRYPTO_OP_SESSIONLESS,
5544 "crypto op session type not sessionless");
5546 /* Process crypto operation */
5547 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5548 ut_params->op), "failed to process sym crypto op");
5550 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5553 "crypto op status not success");
5555 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5556 ut_params->op->sym->cipher.data.offset);
5558 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5561 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5563 tdata->plaintext.data,
5564 tdata->plaintext.len,
5565 "GCM plaintext data not as expected");
5567 TEST_ASSERT_EQUAL(ut_params->op->status,
5568 RTE_CRYPTO_OP_STATUS_SUCCESS,
5569 "GCM authentication failed");
5574 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5576 return test_AES_GCM_authenticated_decryption_sessionless(
5583 struct crypto_testsuite_params *ts_params = &testsuite_params;
5584 struct rte_cryptodev_stats stats;
5585 struct rte_cryptodev *dev;
5586 cryptodev_stats_get_t temp_pfn;
5588 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5589 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5590 &stats) == -ENODEV),
5591 "rte_cryptodev_stats_get invalid dev failed");
5592 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5593 "rte_cryptodev_stats_get invalid Param failed");
5594 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5595 temp_pfn = dev->dev_ops->stats_get;
5596 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5597 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5599 "rte_cryptodev_stats_get invalid Param failed");
5600 dev->dev_ops->stats_get = temp_pfn;
5602 /* Test expected values */
5604 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5606 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5608 "rte_cryptodev_stats_get failed");
5609 TEST_ASSERT((stats.enqueued_count == 1),
5610 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5611 TEST_ASSERT((stats.dequeued_count == 1),
5612 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5613 TEST_ASSERT((stats.enqueue_err_count == 0),
5614 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5615 TEST_ASSERT((stats.dequeue_err_count == 0),
5616 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5618 /* invalid device but should ignore and not reset device stats*/
5619 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5620 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5622 "rte_cryptodev_stats_get failed");
5623 TEST_ASSERT((stats.enqueued_count == 1),
5624 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5626 /* check that a valid reset clears stats */
5627 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5628 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5630 "rte_cryptodev_stats_get failed");
5631 TEST_ASSERT((stats.enqueued_count == 0),
5632 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5633 TEST_ASSERT((stats.dequeued_count == 0),
5634 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5636 return TEST_SUCCESS;
5639 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5640 struct crypto_unittest_params *ut_params,
5641 enum rte_crypto_auth_operation op,
5642 const struct HMAC_MD5_vector *test_case)
5646 memcpy(key, test_case->key.data, test_case->key.len);
5648 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5649 ut_params->auth_xform.next = NULL;
5650 ut_params->auth_xform.auth.op = op;
5652 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5654 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5655 ut_params->auth_xform.auth.key.length = test_case->key.len;
5656 ut_params->auth_xform.auth.key.data = key;
5658 ut_params->sess = rte_cryptodev_sym_session_create(
5659 ts_params->valid_devs[0], &ut_params->auth_xform);
5661 if (ut_params->sess == NULL)
5664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5667 rte_pktmbuf_tailroom(ut_params->ibuf));
5672 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5673 const struct HMAC_MD5_vector *test_case,
5674 uint8_t **plaintext)
5676 uint16_t plaintext_pad_len;
5678 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5680 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5683 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5685 memcpy(*plaintext, test_case->plaintext.data,
5686 test_case->plaintext.len);
5688 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5689 ut_params->ibuf, MD5_DIGEST_LEN);
5690 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5691 "no room to append digest");
5692 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5693 ut_params->ibuf, plaintext_pad_len);
5695 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5696 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5697 test_case->auth_tag.len);
5700 sym_op->auth.data.offset = 0;
5701 sym_op->auth.data.length = test_case->plaintext.len;
5703 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5704 ut_params->op->sym->m_src = ut_params->ibuf;
5710 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5712 uint16_t plaintext_pad_len;
5713 uint8_t *plaintext, *auth_tag;
5715 struct crypto_testsuite_params *ts_params = &testsuite_params;
5716 struct crypto_unittest_params *ut_params = &unittest_params;
5718 if (MD5_HMAC_create_session(ts_params, ut_params,
5719 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5722 /* Generate Crypto op data structure */
5723 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5724 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5725 TEST_ASSERT_NOT_NULL(ut_params->op,
5726 "Failed to allocate symmetric crypto operation struct");
5728 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5731 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5734 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5735 ut_params->op), "failed to process sym crypto op");
5737 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5738 "crypto op processing failed");
5740 if (ut_params->op->sym->m_dst) {
5741 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5742 uint8_t *, plaintext_pad_len);
5744 auth_tag = plaintext + plaintext_pad_len;
5747 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5749 test_case->auth_tag.data,
5750 test_case->auth_tag.len,
5751 "HMAC_MD5 generated tag not as expected");
5753 return TEST_SUCCESS;
5757 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5761 struct crypto_testsuite_params *ts_params = &testsuite_params;
5762 struct crypto_unittest_params *ut_params = &unittest_params;
5764 if (MD5_HMAC_create_session(ts_params, ut_params,
5765 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5769 /* Generate Crypto op data structure */
5770 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5771 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5772 TEST_ASSERT_NOT_NULL(ut_params->op,
5773 "Failed to allocate symmetric crypto operation struct");
5775 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5778 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5779 ut_params->op), "failed to process sym crypto op");
5781 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5782 "HMAC_MD5 crypto op processing failed");
5784 return TEST_SUCCESS;
5788 test_MD5_HMAC_generate_case_1(void)
5790 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5794 test_MD5_HMAC_verify_case_1(void)
5796 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5800 test_MD5_HMAC_generate_case_2(void)
5802 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5806 test_MD5_HMAC_verify_case_2(void)
5808 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5812 test_multi_session(void)
5814 struct crypto_testsuite_params *ts_params = &testsuite_params;
5815 struct crypto_unittest_params *ut_params = &unittest_params;
5817 struct rte_cryptodev_info dev_info;
5818 struct rte_cryptodev_sym_session **sessions;
5822 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5823 aes_cbc_key, hmac_sha512_key);
5826 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5828 sessions = rte_malloc(NULL,
5829 (sizeof(struct rte_cryptodev_sym_session *) *
5830 dev_info.sym.max_nb_sessions) + 1, 0);
5832 /* Create multiple crypto sessions*/
5833 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5834 sessions[i] = rte_cryptodev_sym_session_create(
5835 ts_params->valid_devs[0],
5836 &ut_params->auth_xform);
5837 TEST_ASSERT_NOT_NULL(sessions[i],
5838 "Session creation failed at session number %u",
5841 /* Attempt to send a request on each session */
5842 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5846 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5847 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5849 "Failed to perform decrypt on request number %u.", i);
5850 /* free crypto operation structure */
5852 rte_crypto_op_free(ut_params->op);
5855 * free mbuf - both obuf and ibuf are usually the same,
5856 * so check if they point at the same address is necessary,
5857 * to avoid freeing the mbuf twice.
5859 if (ut_params->obuf) {
5860 rte_pktmbuf_free(ut_params->obuf);
5861 if (ut_params->ibuf == ut_params->obuf)
5862 ut_params->ibuf = 0;
5863 ut_params->obuf = 0;
5865 if (ut_params->ibuf) {
5866 rte_pktmbuf_free(ut_params->ibuf);
5867 ut_params->ibuf = 0;
5871 /* Next session create should fail */
5872 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5873 &ut_params->auth_xform);
5874 TEST_ASSERT_NULL(sessions[i],
5875 "Session creation succeeded unexpectedly!");
5877 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5878 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5883 return TEST_SUCCESS;
5886 struct multi_session_params {
5887 struct crypto_unittest_params ut_params;
5888 uint8_t *cipher_key;
5890 const uint8_t *cipher;
5891 const uint8_t *digest;
5895 #define MB_SESSION_NUMBER 3
5898 test_multi_session_random_usage(void)
5900 struct crypto_testsuite_params *ts_params = &testsuite_params;
5901 struct rte_cryptodev_info dev_info;
5902 struct rte_cryptodev_sym_session **sessions;
5904 struct multi_session_params ut_paramz[] = {
5907 .cipher_key = ms_aes_cbc_key0,
5908 .hmac_key = ms_hmac_key0,
5909 .cipher = ms_aes_cbc_cipher0,
5910 .digest = ms_hmac_digest0,
5911 .iv = ms_aes_cbc_iv0
5914 .cipher_key = ms_aes_cbc_key1,
5915 .hmac_key = ms_hmac_key1,
5916 .cipher = ms_aes_cbc_cipher1,
5917 .digest = ms_hmac_digest1,
5918 .iv = ms_aes_cbc_iv1
5921 .cipher_key = ms_aes_cbc_key2,
5922 .hmac_key = ms_hmac_key2,
5923 .cipher = ms_aes_cbc_cipher2,
5924 .digest = ms_hmac_digest2,
5925 .iv = ms_aes_cbc_iv2
5930 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5932 sessions = rte_malloc(NULL,
5933 (sizeof(struct rte_cryptodev_sym_session *)
5934 * dev_info.sym.max_nb_sessions) + 1, 0);
5936 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5937 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5938 sizeof(struct crypto_unittest_params));
5940 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5941 &ut_paramz[i].ut_params,
5942 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5944 /* Create multiple crypto sessions*/
5945 sessions[i] = rte_cryptodev_sym_session_create(
5946 ts_params->valid_devs[0],
5947 &ut_paramz[i].ut_params.auth_xform);
5949 TEST_ASSERT_NOT_NULL(sessions[i],
5950 "Session creation failed at session number %u",
5956 for (i = 0; i < 40000; i++) {
5958 j = rand() % MB_SESSION_NUMBER;
5960 TEST_ASSERT_SUCCESS(
5961 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5963 &ut_paramz[j].ut_params,
5964 ts_params, ut_paramz[j].cipher,
5965 ut_paramz[j].digest,
5967 "Failed to perform decrypt on request number %u.", i);
5969 if (ut_paramz[j].ut_params.op)
5970 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5973 * free mbuf - both obuf and ibuf are usually the same,
5974 * so check if they point at the same address is necessary,
5975 * to avoid freeing the mbuf twice.
5977 if (ut_paramz[j].ut_params.obuf) {
5978 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5979 if (ut_paramz[j].ut_params.ibuf
5980 == ut_paramz[j].ut_params.obuf)
5981 ut_paramz[j].ut_params.ibuf = 0;
5982 ut_paramz[j].ut_params.obuf = 0;
5984 if (ut_paramz[j].ut_params.ibuf) {
5985 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5986 ut_paramz[j].ut_params.ibuf = 0;
5990 for (i = 0; i < MB_SESSION_NUMBER; i++)
5991 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5996 return TEST_SUCCESS;
6000 test_null_cipher_only_operation(void)
6002 struct crypto_testsuite_params *ts_params = &testsuite_params;
6003 struct crypto_unittest_params *ut_params = &unittest_params;
6005 /* Generate test mbuf data and space for digest */
6006 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6007 catch_22_quote, QUOTE_512_BYTES, 0);
6009 /* Setup Cipher Parameters */
6010 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6011 ut_params->cipher_xform.next = NULL;
6013 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6014 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6016 /* Create Crypto session*/
6017 ut_params->sess = rte_cryptodev_sym_session_create(
6018 ts_params->valid_devs[0], &ut_params->cipher_xform);
6019 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6021 /* Generate Crypto op data structure */
6022 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6023 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6024 TEST_ASSERT_NOT_NULL(ut_params->op,
6025 "Failed to allocate symmetric crypto operation struct");
6027 /* Set crypto operation data parameters */
6028 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6030 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6032 /* set crypto operation source mbuf */
6033 sym_op->m_src = ut_params->ibuf;
6035 sym_op->cipher.data.offset = 0;
6036 sym_op->cipher.data.length = QUOTE_512_BYTES;
6038 /* Process crypto operation */
6039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6041 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6043 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6044 "crypto operation processing failed");
6047 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6048 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6051 "Ciphertext data not as expected");
6053 return TEST_SUCCESS;
6057 test_null_auth_only_operation(void)
6059 struct crypto_testsuite_params *ts_params = &testsuite_params;
6060 struct crypto_unittest_params *ut_params = &unittest_params;
6062 /* Generate test mbuf data and space for digest */
6063 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6064 catch_22_quote, QUOTE_512_BYTES, 0);
6066 /* Setup HMAC Parameters */
6067 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6068 ut_params->auth_xform.next = NULL;
6070 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6071 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6073 /* Create Crypto session*/
6074 ut_params->sess = rte_cryptodev_sym_session_create(
6075 ts_params->valid_devs[0], &ut_params->auth_xform);
6076 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6078 /* Generate Crypto op data structure */
6079 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6080 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6081 TEST_ASSERT_NOT_NULL(ut_params->op,
6082 "Failed to allocate symmetric crypto operation struct");
6084 /* Set crypto operation data parameters */
6085 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6087 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6089 sym_op->m_src = ut_params->ibuf;
6091 sym_op->auth.data.offset = 0;
6092 sym_op->auth.data.length = QUOTE_512_BYTES;
6094 /* Process crypto operation */
6095 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6097 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6099 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6100 "crypto operation processing failed");
6102 return TEST_SUCCESS;
6106 test_null_cipher_auth_operation(void)
6108 struct crypto_testsuite_params *ts_params = &testsuite_params;
6109 struct crypto_unittest_params *ut_params = &unittest_params;
6111 /* Generate test mbuf data and space for digest */
6112 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6113 catch_22_quote, QUOTE_512_BYTES, 0);
6115 /* Setup Cipher Parameters */
6116 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6117 ut_params->cipher_xform.next = &ut_params->auth_xform;
6119 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6120 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6122 /* Setup HMAC Parameters */
6123 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6124 ut_params->auth_xform.next = NULL;
6126 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6127 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6129 /* Create Crypto session*/
6130 ut_params->sess = rte_cryptodev_sym_session_create(
6131 ts_params->valid_devs[0], &ut_params->cipher_xform);
6132 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6134 /* Generate Crypto op data structure */
6135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6137 TEST_ASSERT_NOT_NULL(ut_params->op,
6138 "Failed to allocate symmetric crypto operation struct");
6140 /* Set crypto operation data parameters */
6141 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6145 sym_op->m_src = ut_params->ibuf;
6147 sym_op->cipher.data.offset = 0;
6148 sym_op->cipher.data.length = QUOTE_512_BYTES;
6150 sym_op->auth.data.offset = 0;
6151 sym_op->auth.data.length = QUOTE_512_BYTES;
6153 /* Process crypto operation */
6154 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6156 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6158 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6159 "crypto operation processing failed");
6162 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6163 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6166 "Ciphertext data not as expected");
6168 return TEST_SUCCESS;
6172 test_null_auth_cipher_operation(void)
6174 struct crypto_testsuite_params *ts_params = &testsuite_params;
6175 struct crypto_unittest_params *ut_params = &unittest_params;
6177 /* Generate test mbuf data and space for digest */
6178 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6179 catch_22_quote, QUOTE_512_BYTES, 0);
6181 /* Setup Cipher Parameters */
6182 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6183 ut_params->cipher_xform.next = NULL;
6185 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6186 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6188 /* Setup HMAC Parameters */
6189 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6190 ut_params->auth_xform.next = &ut_params->cipher_xform;
6192 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6193 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6195 /* Create Crypto session*/
6196 ut_params->sess = rte_cryptodev_sym_session_create(
6197 ts_params->valid_devs[0], &ut_params->cipher_xform);
6198 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6200 /* Generate Crypto op data structure */
6201 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6202 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6203 TEST_ASSERT_NOT_NULL(ut_params->op,
6204 "Failed to allocate symmetric crypto operation struct");
6206 /* Set crypto operation data parameters */
6207 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6209 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6211 sym_op->m_src = ut_params->ibuf;
6213 sym_op->cipher.data.offset = 0;
6214 sym_op->cipher.data.length = QUOTE_512_BYTES;
6216 sym_op->auth.data.offset = 0;
6217 sym_op->auth.data.length = QUOTE_512_BYTES;
6219 /* Process crypto operation */
6220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6222 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6224 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6225 "crypto operation processing failed");
6228 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6229 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6232 "Ciphertext data not as expected");
6234 return TEST_SUCCESS;
6239 test_null_invalid_operation(void)
6241 struct crypto_testsuite_params *ts_params = &testsuite_params;
6242 struct crypto_unittest_params *ut_params = &unittest_params;
6244 /* Setup Cipher Parameters */
6245 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6246 ut_params->cipher_xform.next = NULL;
6248 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6249 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6251 /* Create Crypto session*/
6252 ut_params->sess = rte_cryptodev_sym_session_create(
6253 ts_params->valid_devs[0], &ut_params->cipher_xform);
6254 TEST_ASSERT_NULL(ut_params->sess,
6255 "Session creation succeeded unexpectedly");
6258 /* Setup HMAC Parameters */
6259 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6260 ut_params->auth_xform.next = NULL;
6262 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6263 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6265 /* Create Crypto session*/
6266 ut_params->sess = rte_cryptodev_sym_session_create(
6267 ts_params->valid_devs[0], &ut_params->auth_xform);
6268 TEST_ASSERT_NULL(ut_params->sess,
6269 "Session creation succeeded unexpectedly");
6271 return TEST_SUCCESS;
6275 #define NULL_BURST_LENGTH (32)
6278 test_null_burst_operation(void)
6280 struct crypto_testsuite_params *ts_params = &testsuite_params;
6281 struct crypto_unittest_params *ut_params = &unittest_params;
6283 unsigned i, burst_len = NULL_BURST_LENGTH;
6285 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6286 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6288 /* Setup Cipher Parameters */
6289 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6290 ut_params->cipher_xform.next = &ut_params->auth_xform;
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 = NULL;
6299 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6300 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6302 /* Create Crypto session*/
6303 ut_params->sess = rte_cryptodev_sym_session_create(
6304 ts_params->valid_devs[0], &ut_params->cipher_xform);
6305 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6307 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6308 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6309 burst_len, "failed to generate burst of crypto ops");
6311 /* Generate an operation for each mbuf in burst */
6312 for (i = 0; i < burst_len; i++) {
6313 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6315 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6317 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6321 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6323 burst[i]->sym->m_src = m;
6326 /* Process crypto operation */
6327 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6328 0, burst, burst_len),
6330 "Error enqueuing burst");
6332 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6333 0, burst_dequeued, burst_len),
6335 "Error dequeuing burst");
6338 for (i = 0; i < burst_len; i++) {
6340 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6341 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6343 "data not as expected");
6345 rte_pktmbuf_free(burst[i]->sym->m_src);
6346 rte_crypto_op_free(burst[i]);
6349 return TEST_SUCCESS;
6353 generate_gmac_large_plaintext(uint8_t *data)
6357 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6358 memcpy(&data[i], &data[0], 32);
6362 create_gmac_operation(enum rte_crypto_auth_operation op,
6363 const struct gmac_test_data *tdata)
6365 struct crypto_testsuite_params *ts_params = &testsuite_params;
6366 struct crypto_unittest_params *ut_params = &unittest_params;
6367 struct rte_crypto_sym_op *sym_op;
6369 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6371 /* Generate Crypto op data structure */
6372 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6373 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6374 TEST_ASSERT_NOT_NULL(ut_params->op,
6375 "Failed to allocate symmetric crypto operation struct");
6377 sym_op = ut_params->op->sym;
6379 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6380 ut_params->ibuf, tdata->gmac_tag.len);
6381 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6382 "no room to append digest");
6384 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6385 ut_params->ibuf, plaintext_pad_len);
6387 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6388 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6389 tdata->gmac_tag.len);
6390 TEST_HEXDUMP(stdout, "digest:",
6391 sym_op->auth.digest.data,
6392 tdata->gmac_tag.len);
6395 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6396 uint8_t *, IV_OFFSET);
6398 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6400 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6402 sym_op->cipher.data.length = 0;
6403 sym_op->cipher.data.offset = 0;
6405 sym_op->auth.data.offset = 0;
6406 sym_op->auth.data.length = tdata->plaintext.len;
6411 static int create_gmac_session(uint8_t dev_id,
6412 const struct gmac_test_data *tdata,
6413 enum rte_crypto_auth_operation auth_op)
6415 uint8_t auth_key[tdata->key.len];
6417 struct crypto_unittest_params *ut_params = &unittest_params;
6419 memcpy(auth_key, tdata->key.data, tdata->key.len);
6421 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6422 ut_params->auth_xform.next = NULL;
6424 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6425 ut_params->auth_xform.auth.op = auth_op;
6426 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6427 ut_params->auth_xform.auth.key.length = tdata->key.len;
6428 ut_params->auth_xform.auth.key.data = auth_key;
6429 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6430 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6433 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6434 &ut_params->auth_xform);
6436 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6442 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6444 struct crypto_testsuite_params *ts_params = &testsuite_params;
6445 struct crypto_unittest_params *ut_params = &unittest_params;
6449 uint8_t *auth_tag, *plaintext;
6450 uint16_t plaintext_pad_len;
6452 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6453 "No GMAC length in the source data");
6455 retval = create_gmac_session(ts_params->valid_devs[0],
6456 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6461 if (tdata->plaintext.len > MBUF_SIZE)
6462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6464 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6465 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6466 "Failed to allocate input buffer in mempool");
6468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6469 rte_pktmbuf_tailroom(ut_params->ibuf));
6471 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6473 * Runtime generate the large plain text instead of use hard code
6474 * plain text vector. It is done to avoid create huge source file
6475 * with the test vector.
6477 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6478 generate_gmac_large_plaintext(tdata->plaintext.data);
6480 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6482 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6484 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6485 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6486 tdata->plaintext.len);
6488 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6494 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6496 ut_params->op->sym->m_src = ut_params->ibuf;
6498 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6499 ut_params->op), "failed to process sym crypto op");
6501 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6502 "crypto op processing failed");
6504 if (ut_params->op->sym->m_dst) {
6505 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6506 uint8_t *, plaintext_pad_len);
6508 auth_tag = plaintext + plaintext_pad_len;
6511 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6513 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6515 tdata->gmac_tag.data,
6516 tdata->gmac_tag.len,
6517 "GMAC Generated auth tag not as expected");
6523 test_AES_GMAC_authentication_test_case_1(void)
6525 return test_AES_GMAC_authentication(&gmac_test_case_1);
6529 test_AES_GMAC_authentication_test_case_2(void)
6531 return test_AES_GMAC_authentication(&gmac_test_case_2);
6535 test_AES_GMAC_authentication_test_case_3(void)
6537 return test_AES_GMAC_authentication(&gmac_test_case_3);
6541 test_AES_GMAC_authentication_test_case_4(void)
6543 return test_AES_GMAC_authentication(&gmac_test_case_4);
6547 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6549 struct crypto_testsuite_params *ts_params = &testsuite_params;
6550 struct crypto_unittest_params *ut_params = &unittest_params;
6552 uint32_t plaintext_pad_len;
6555 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6556 "No GMAC length in the source data");
6558 retval = create_gmac_session(ts_params->valid_devs[0],
6559 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6564 if (tdata->plaintext.len > MBUF_SIZE)
6565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6567 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6568 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6569 "Failed to allocate input buffer in mempool");
6571 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6572 rte_pktmbuf_tailroom(ut_params->ibuf));
6574 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6577 * Runtime generate the large plain text instead of use hard code
6578 * plain text vector. It is done to avoid create huge source file
6579 * with the test vector.
6581 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6582 generate_gmac_large_plaintext(tdata->plaintext.data);
6584 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6586 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6588 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6589 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6590 tdata->plaintext.len);
6592 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6598 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6600 ut_params->op->sym->m_src = ut_params->ibuf;
6602 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6603 ut_params->op), "failed to process sym crypto op");
6605 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6606 "crypto op processing failed");
6613 test_AES_GMAC_authentication_verify_test_case_1(void)
6615 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6619 test_AES_GMAC_authentication_verify_test_case_2(void)
6621 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6625 test_AES_GMAC_authentication_verify_test_case_3(void)
6627 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6631 test_AES_GMAC_authentication_verify_test_case_4(void)
6633 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6636 struct test_crypto_vector {
6637 enum rte_crypto_cipher_algorithm crypto_algo;
6650 const uint8_t *data;
6655 const uint8_t *data;
6659 enum rte_crypto_auth_algorithm auth_algo;
6667 const uint8_t *data;
6677 static const struct test_crypto_vector
6678 hmac_sha1_test_crypto_vector = {
6679 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6681 .data = plaintext_hash,
6686 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6687 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6688 0xDE, 0xF4, 0xDE, 0xAD
6694 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6695 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6696 0x3F, 0x91, 0x64, 0x59
6702 static const struct test_crypto_vector
6703 aes128_gmac_test_vector = {
6704 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6706 .data = plaintext_hash,
6711 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6712 0x08, 0x09, 0x0A, 0x0B
6718 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6719 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6725 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6726 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6732 static const struct test_crypto_vector
6733 aes128cbc_hmac_sha1_test_vector = {
6734 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6737 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6738 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6744 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6745 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6750 .data = plaintext_hash,
6754 .data = ciphertext512_aes128cbc,
6757 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6760 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6761 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6762 0xDE, 0xF4, 0xDE, 0xAD
6768 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6769 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6770 0x18, 0x8C, 0x1D, 0x32
6777 data_corruption(uint8_t *data)
6783 tag_corruption(uint8_t *data, unsigned int tag_offset)
6785 data[tag_offset] += 1;
6789 create_auth_session(struct crypto_unittest_params *ut_params,
6791 const struct test_crypto_vector *reference,
6792 enum rte_crypto_auth_operation auth_op)
6794 uint8_t auth_key[reference->auth_key.len + 1];
6796 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6798 /* Setup Authentication Parameters */
6799 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6800 ut_params->auth_xform.auth.op = auth_op;
6801 ut_params->auth_xform.next = NULL;
6802 ut_params->auth_xform.auth.algo = reference->auth_algo;
6803 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6804 ut_params->auth_xform.auth.key.data = auth_key;
6805 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6807 /* Create Crypto session*/
6808 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6809 &ut_params->auth_xform);
6811 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6817 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6819 const struct test_crypto_vector *reference,
6820 enum rte_crypto_auth_operation auth_op,
6821 enum rte_crypto_cipher_operation cipher_op)
6823 uint8_t cipher_key[reference->cipher_key.len + 1];
6824 uint8_t auth_key[reference->auth_key.len + 1];
6826 memcpy(cipher_key, reference->cipher_key.data,
6827 reference->cipher_key.len);
6828 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6830 /* Setup Authentication Parameters */
6831 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6832 ut_params->auth_xform.auth.op = auth_op;
6833 ut_params->auth_xform.auth.algo = reference->auth_algo;
6834 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6835 ut_params->auth_xform.auth.key.data = auth_key;
6836 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6838 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6839 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6840 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6842 ut_params->auth_xform.next = &ut_params->cipher_xform;
6844 /* Setup Cipher Parameters */
6845 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6846 ut_params->cipher_xform.next = NULL;
6847 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6848 ut_params->cipher_xform.cipher.op = cipher_op;
6849 ut_params->cipher_xform.cipher.key.data = cipher_key;
6850 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6851 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6852 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6855 /* Create Crypto session*/
6856 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6857 &ut_params->auth_xform);
6859 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6865 create_auth_operation(struct crypto_testsuite_params *ts_params,
6866 struct crypto_unittest_params *ut_params,
6867 const struct test_crypto_vector *reference,
6868 unsigned int auth_generate)
6870 /* Generate Crypto op data structure */
6871 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6872 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6873 TEST_ASSERT_NOT_NULL(ut_params->op,
6874 "Failed to allocate pktmbuf offload");
6876 /* Set crypto operation data parameters */
6877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6881 /* set crypto operation source mbuf */
6882 sym_op->m_src = ut_params->ibuf;
6885 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6886 ut_params->ibuf, reference->digest.len);
6888 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6889 "no room to append auth tag");
6891 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6892 ut_params->ibuf, reference->plaintext.len);
6895 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6897 memcpy(sym_op->auth.digest.data,
6898 reference->digest.data,
6899 reference->digest.len);
6901 TEST_HEXDUMP(stdout, "digest:",
6902 sym_op->auth.digest.data,
6903 reference->digest.len);
6905 sym_op->auth.data.length = reference->plaintext.len;
6906 sym_op->auth.data.offset = 0;
6912 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6913 struct crypto_unittest_params *ut_params,
6914 const struct test_crypto_vector *reference,
6915 unsigned int auth_generate)
6917 /* Generate Crypto op data structure */
6918 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6919 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6920 TEST_ASSERT_NOT_NULL(ut_params->op,
6921 "Failed to allocate pktmbuf offload");
6923 /* Set crypto operation data parameters */
6924 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6926 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6928 /* set crypto operation source mbuf */
6929 sym_op->m_src = ut_params->ibuf;
6932 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6933 ut_params->ibuf, reference->digest.len);
6935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6936 "no room to append auth tag");
6938 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6939 ut_params->ibuf, reference->ciphertext.len);
6942 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6944 memcpy(sym_op->auth.digest.data,
6945 reference->digest.data,
6946 reference->digest.len);
6948 TEST_HEXDUMP(stdout, "digest:",
6949 sym_op->auth.digest.data,
6950 reference->digest.len);
6952 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6953 reference->iv.data, reference->iv.len);
6955 sym_op->cipher.data.length = 0;
6956 sym_op->cipher.data.offset = 0;
6958 sym_op->auth.data.length = reference->plaintext.len;
6959 sym_op->auth.data.offset = 0;
6965 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6966 struct crypto_unittest_params *ut_params,
6967 const struct test_crypto_vector *reference,
6968 unsigned int auth_generate)
6970 /* Generate Crypto op data structure */
6971 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6972 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6973 TEST_ASSERT_NOT_NULL(ut_params->op,
6974 "Failed to allocate pktmbuf offload");
6976 /* Set crypto operation data parameters */
6977 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6979 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6981 /* set crypto operation source mbuf */
6982 sym_op->m_src = ut_params->ibuf;
6985 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6986 ut_params->ibuf, reference->digest.len);
6988 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6989 "no room to append auth tag");
6991 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6992 ut_params->ibuf, reference->ciphertext.len);
6995 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6997 memcpy(sym_op->auth.digest.data,
6998 reference->digest.data,
6999 reference->digest.len);
7001 TEST_HEXDUMP(stdout, "digest:",
7002 sym_op->auth.digest.data,
7003 reference->digest.len);
7005 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7006 reference->iv.data, reference->iv.len);
7008 sym_op->cipher.data.length = reference->ciphertext.len;
7009 sym_op->cipher.data.offset = 0;
7011 sym_op->auth.data.length = reference->ciphertext.len;
7012 sym_op->auth.data.offset = 0;
7018 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7019 struct crypto_unittest_params *ut_params,
7020 const struct test_crypto_vector *reference)
7022 return create_auth_operation(ts_params, ut_params, reference, 0);
7026 create_auth_verify_GMAC_operation(
7027 struct crypto_testsuite_params *ts_params,
7028 struct crypto_unittest_params *ut_params,
7029 const struct test_crypto_vector *reference)
7031 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7035 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7036 struct crypto_unittest_params *ut_params,
7037 const struct test_crypto_vector *reference)
7039 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7043 test_authentication_verify_fail_when_data_corruption(
7044 struct crypto_testsuite_params *ts_params,
7045 struct crypto_unittest_params *ut_params,
7046 const struct test_crypto_vector *reference,
7047 unsigned int data_corrupted)
7053 /* Create session */
7054 retval = create_auth_session(ut_params,
7055 ts_params->valid_devs[0],
7057 RTE_CRYPTO_AUTH_OP_VERIFY);
7061 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7062 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7063 "Failed to allocate input buffer in mempool");
7065 /* clear mbuf payload */
7066 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7067 rte_pktmbuf_tailroom(ut_params->ibuf));
7069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7070 reference->plaintext.len);
7071 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7072 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7074 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7076 /* Create operation */
7077 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7083 data_corruption(plaintext);
7085 tag_corruption(plaintext, reference->plaintext.len);
7087 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7089 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7090 TEST_ASSERT_EQUAL(ut_params->op->status,
7091 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7092 "authentication not failed");
7094 ut_params->obuf = ut_params->op->sym->m_src;
7095 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7101 test_authentication_verify_GMAC_fail_when_corruption(
7102 struct crypto_testsuite_params *ts_params,
7103 struct crypto_unittest_params *ut_params,
7104 const struct test_crypto_vector *reference,
7105 unsigned int data_corrupted)
7110 /* Create session */
7111 retval = create_auth_cipher_session(ut_params,
7112 ts_params->valid_devs[0],
7114 RTE_CRYPTO_AUTH_OP_VERIFY,
7115 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7119 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7120 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7121 "Failed to allocate input buffer in mempool");
7123 /* clear mbuf payload */
7124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7125 rte_pktmbuf_tailroom(ut_params->ibuf));
7127 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7128 reference->plaintext.len);
7129 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7130 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7132 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7134 /* Create operation */
7135 retval = create_auth_verify_GMAC_operation(ts_params,
7143 data_corruption(plaintext);
7145 tag_corruption(plaintext, reference->aad.len);
7147 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7149 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7150 TEST_ASSERT_EQUAL(ut_params->op->status,
7151 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7152 "authentication not failed");
7154 ut_params->obuf = ut_params->op->sym->m_src;
7155 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7161 test_authenticated_decryption_fail_when_corruption(
7162 struct crypto_testsuite_params *ts_params,
7163 struct crypto_unittest_params *ut_params,
7164 const struct test_crypto_vector *reference,
7165 unsigned int data_corrupted)
7169 uint8_t *ciphertext;
7171 /* Create session */
7172 retval = create_auth_cipher_session(ut_params,
7173 ts_params->valid_devs[0],
7175 RTE_CRYPTO_AUTH_OP_VERIFY,
7176 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7180 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7181 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7182 "Failed to allocate input buffer in mempool");
7184 /* clear mbuf payload */
7185 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7186 rte_pktmbuf_tailroom(ut_params->ibuf));
7188 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7189 reference->ciphertext.len);
7190 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7191 memcpy(ciphertext, reference->ciphertext.data,
7192 reference->ciphertext.len);
7194 /* Create operation */
7195 retval = create_cipher_auth_verify_operation(ts_params,
7203 data_corruption(ciphertext);
7205 tag_corruption(ciphertext, reference->ciphertext.len);
7207 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7210 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7211 TEST_ASSERT_EQUAL(ut_params->op->status,
7212 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7213 "authentication not failed");
7215 ut_params->obuf = ut_params->op->sym->m_src;
7216 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7222 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7223 const struct gcm_test_data *tdata,
7224 void *digest_mem, uint64_t digest_phys)
7226 struct crypto_testsuite_params *ts_params = &testsuite_params;
7227 struct crypto_unittest_params *ut_params = &unittest_params;
7229 const unsigned int auth_tag_len = tdata->auth_tag.len;
7230 const unsigned int iv_len = tdata->iv.len;
7231 const unsigned int aad_len = tdata->aad.len;
7233 /* Generate Crypto op data structure */
7234 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7235 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7236 TEST_ASSERT_NOT_NULL(ut_params->op,
7237 "Failed to allocate symmetric crypto operation struct");
7239 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7241 sym_op->aead.digest.data = digest_mem;
7243 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7244 "no room to append digest");
7246 sym_op->aead.digest.phys_addr = digest_phys;
7248 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7249 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7251 TEST_HEXDUMP(stdout, "digest:",
7252 sym_op->aead.digest.data,
7256 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7257 uint8_t *, IV_OFFSET);
7259 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7261 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7262 ut_params->ibuf, aad_len);
7263 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7264 "no room to prepend aad");
7265 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7268 memset(sym_op->aead.aad.data, 0, aad_len);
7269 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7271 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7272 TEST_HEXDUMP(stdout, "aad:",
7273 sym_op->aead.aad.data, aad_len);
7275 sym_op->aead.data.length = tdata->plaintext.len;
7276 sym_op->aead.data.offset = aad_len;
7281 #define SGL_MAX_NO 16
7284 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7285 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7287 struct crypto_testsuite_params *ts_params = &testsuite_params;
7288 struct crypto_unittest_params *ut_params = &unittest_params;
7289 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7292 int to_trn_tbl[SGL_MAX_NO];
7294 unsigned int trn_data = 0;
7295 uint8_t *plaintext, *ciphertext, *auth_tag;
7297 if (fragsz > tdata->plaintext.len)
7298 fragsz = tdata->plaintext.len;
7300 uint16_t plaintext_len = fragsz;
7301 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7303 if (fragsz_oop > tdata->plaintext.len)
7304 frag_size_oop = tdata->plaintext.len;
7307 void *digest_mem = NULL;
7309 uint32_t prepend_len = tdata->aad.len;
7311 if (tdata->plaintext.len % fragsz != 0) {
7312 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7315 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7320 * For out-op-place we need to alloc another mbuf
7323 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7324 rte_pktmbuf_append(ut_params->obuf,
7325 frag_size_oop + prepend_len);
7326 buf_oop = ut_params->obuf;
7329 /* Create GCM session */
7330 retval = create_gcm_session(ts_params->valid_devs[0],
7331 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7332 tdata->key.data, tdata->key.len,
7333 tdata->aad.len, tdata->auth_tag.len,
7338 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7340 /* clear mbuf payload */
7341 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7342 rte_pktmbuf_tailroom(ut_params->ibuf));
7344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7347 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7349 trn_data += plaintext_len;
7351 buf = ut_params->ibuf;
7354 * Loop until no more fragments
7357 while (trn_data < tdata->plaintext.len) {
7359 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7360 (tdata->plaintext.len - trn_data) : fragsz;
7362 to_trn_tbl[ecx++] = to_trn;
7364 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7367 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7368 rte_pktmbuf_tailroom(buf));
7371 if (oop && !fragsz_oop) {
7372 buf_last_oop = buf_oop->next =
7373 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7374 buf_oop = buf_oop->next;
7375 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7376 0, rte_pktmbuf_tailroom(buf_oop));
7377 rte_pktmbuf_append(buf_oop, to_trn);
7380 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7383 memcpy(plaintext, tdata->plaintext.data + trn_data,
7386 if (trn_data == tdata->plaintext.len) {
7389 digest_mem = rte_pktmbuf_append(buf_oop,
7390 tdata->auth_tag.len);
7392 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7393 tdata->auth_tag.len);
7397 uint64_t digest_phys = 0;
7399 ut_params->ibuf->nb_segs = segs;
7402 if (fragsz_oop && oop) {
7406 if (frag_size_oop == tdata->plaintext.len) {
7407 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7408 tdata->auth_tag.len);
7410 digest_phys = rte_pktmbuf_mtophys_offset(
7412 tdata->plaintext.len + prepend_len);
7415 trn_data = frag_size_oop;
7416 while (trn_data < tdata->plaintext.len) {
7419 (tdata->plaintext.len - trn_data <
7421 (tdata->plaintext.len - trn_data) :
7424 to_trn_tbl[ecx++] = to_trn;
7426 buf_last_oop = buf_oop->next =
7427 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7428 buf_oop = buf_oop->next;
7429 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7430 0, rte_pktmbuf_tailroom(buf_oop));
7431 rte_pktmbuf_append(buf_oop, to_trn);
7435 if (trn_data == tdata->plaintext.len) {
7436 digest_mem = rte_pktmbuf_append(buf_oop,
7437 tdata->auth_tag.len);
7441 ut_params->obuf->nb_segs = segs;
7445 * Place digest at the end of the last buffer
7448 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7449 if (oop && buf_last_oop)
7450 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7452 if (!digest_mem && !oop) {
7453 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7454 + tdata->auth_tag.len);
7455 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7456 tdata->plaintext.len);
7459 /* Create GCM opertaion */
7460 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7461 tdata, digest_mem, digest_phys);
7466 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7468 ut_params->op->sym->m_src = ut_params->ibuf;
7470 ut_params->op->sym->m_dst = ut_params->obuf;
7472 /* Process crypto operation */
7473 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7474 ut_params->op), "failed to process sym crypto op");
7476 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7477 "crypto op processing failed");
7480 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7481 uint8_t *, prepend_len);
7483 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7484 uint8_t *, prepend_len);
7488 fragsz = fragsz_oop;
7490 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7492 tdata->ciphertext.data,
7494 "GCM Ciphertext data not as expected");
7496 buf = ut_params->op->sym->m_src->next;
7498 buf = ut_params->op->sym->m_dst->next;
7500 unsigned int off = fragsz;
7504 ciphertext = rte_pktmbuf_mtod(buf,
7507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7509 tdata->ciphertext.data + off,
7511 "GCM Ciphertext data not as expected");
7513 off += to_trn_tbl[ecx++];
7517 auth_tag = digest_mem;
7518 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7520 tdata->auth_tag.data,
7521 tdata->auth_tag.len,
7522 "GCM Generated auth tag not as expected");
7528 #define OUT_OF_PLACE 1
7531 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7533 return test_AES_GCM_authenticated_encryption_SGL(
7534 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7538 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7540 return test_AES_GCM_authenticated_encryption_SGL(
7541 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7545 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7547 return test_AES_GCM_authenticated_encryption_SGL(
7548 &gcm_test_case_8, OUT_OF_PLACE, 400,
7549 gcm_test_case_8.plaintext.len);
7553 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7556 return test_AES_GCM_authenticated_encryption_SGL(
7557 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7561 test_authentication_verify_fail_when_data_corrupted(
7562 struct crypto_testsuite_params *ts_params,
7563 struct crypto_unittest_params *ut_params,
7564 const struct test_crypto_vector *reference)
7566 return test_authentication_verify_fail_when_data_corruption(
7567 ts_params, ut_params, reference, 1);
7571 test_authentication_verify_fail_when_tag_corrupted(
7572 struct crypto_testsuite_params *ts_params,
7573 struct crypto_unittest_params *ut_params,
7574 const struct test_crypto_vector *reference)
7576 return test_authentication_verify_fail_when_data_corruption(
7577 ts_params, ut_params, reference, 0);
7581 test_authentication_verify_GMAC_fail_when_data_corrupted(
7582 struct crypto_testsuite_params *ts_params,
7583 struct crypto_unittest_params *ut_params,
7584 const struct test_crypto_vector *reference)
7586 return test_authentication_verify_GMAC_fail_when_corruption(
7587 ts_params, ut_params, reference, 1);
7591 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7592 struct crypto_testsuite_params *ts_params,
7593 struct crypto_unittest_params *ut_params,
7594 const struct test_crypto_vector *reference)
7596 return test_authentication_verify_GMAC_fail_when_corruption(
7597 ts_params, ut_params, reference, 0);
7601 test_authenticated_decryption_fail_when_data_corrupted(
7602 struct crypto_testsuite_params *ts_params,
7603 struct crypto_unittest_params *ut_params,
7604 const struct test_crypto_vector *reference)
7606 return test_authenticated_decryption_fail_when_corruption(
7607 ts_params, ut_params, reference, 1);
7611 test_authenticated_decryption_fail_when_tag_corrupted(
7612 struct crypto_testsuite_params *ts_params,
7613 struct crypto_unittest_params *ut_params,
7614 const struct test_crypto_vector *reference)
7616 return test_authenticated_decryption_fail_when_corruption(
7617 ts_params, ut_params, reference, 0);
7621 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7623 return test_authentication_verify_fail_when_data_corrupted(
7624 &testsuite_params, &unittest_params,
7625 &hmac_sha1_test_crypto_vector);
7629 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7631 return test_authentication_verify_fail_when_tag_corrupted(
7632 &testsuite_params, &unittest_params,
7633 &hmac_sha1_test_crypto_vector);
7637 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7639 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7640 &testsuite_params, &unittest_params,
7641 &aes128_gmac_test_vector);
7645 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7647 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7648 &testsuite_params, &unittest_params,
7649 &aes128_gmac_test_vector);
7653 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7655 return test_authenticated_decryption_fail_when_data_corrupted(
7658 &aes128cbc_hmac_sha1_test_vector);
7662 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7664 return test_authenticated_decryption_fail_when_tag_corrupted(
7667 &aes128cbc_hmac_sha1_test_vector);
7670 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7672 /* global AESNI slave IDs for the scheduler test */
7673 uint8_t aesni_ids[2];
7676 test_scheduler_attach_slave_op(void)
7678 struct crypto_testsuite_params *ts_params = &testsuite_params;
7679 uint8_t sched_id = ts_params->valid_devs[0];
7680 uint32_t nb_devs, i, nb_devs_attached = 0;
7684 /* create 2 AESNI_MB if necessary */
7685 nb_devs = rte_cryptodev_device_count_by_driver(
7686 rte_cryptodev_driver_id_get(
7687 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
7689 for (i = nb_devs; i < 2; i++) {
7690 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7691 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7693 ret = rte_vdev_init(vdev_name, NULL);
7695 TEST_ASSERT(ret == 0,
7696 "Failed to create instance %u of"
7698 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7702 /* attach 2 AESNI_MB cdevs */
7703 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7705 struct rte_cryptodev_info info;
7707 rte_cryptodev_info_get(i, &info);
7708 if (info.driver_id != rte_cryptodev_driver_id_get(
7709 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
7713 * Create a separate mempool for the slaves, as they need different
7714 * session size and then configure them to store the pointer
7717 unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
7718 rte_cryptodev_get_private_session_size(i);
7720 if (ts_params->slave_session_mpool == NULL) {
7721 ts_params->slave_session_mpool = rte_mempool_create(
7722 "test_slave_sess_mp",
7723 info.sym.max_nb_sessions,
7725 0, 0, NULL, NULL, NULL, NULL,
7728 TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
7729 "session mempool allocation failed");
7732 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
7733 &ts_params->conf, ts_params->slave_session_mpool),
7734 "Failed to configure cryptodev %u with %u qps",
7735 i, ts_params->conf.nb_queue_pairs);
7737 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7740 TEST_ASSERT(ret == 0,
7741 "Failed to attach device %u of pmd : %s", i,
7742 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7744 aesni_ids[nb_devs_attached] = (uint8_t)i;
7753 test_scheduler_detach_slave_op(void)
7755 struct crypto_testsuite_params *ts_params = &testsuite_params;
7756 uint8_t sched_id = ts_params->valid_devs[0];
7760 for (i = 0; i < 2; i++) {
7761 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7763 TEST_ASSERT(ret == 0,
7764 "Failed to detach device %u", aesni_ids[i]);
7771 test_scheduler_mode_op(void)
7773 struct crypto_testsuite_params *ts_params = &testsuite_params;
7774 uint8_t sched_id = ts_params->valid_devs[0];
7775 struct rte_cryptodev_scheduler_ops op = {0};
7776 struct rte_cryptodev_scheduler dummy_scheduler = {
7777 .description = "dummy scheduler to test mode",
7778 .name = "dummy scheduler",
7779 .mode = CDEV_SCHED_MODE_USERDEFINED,
7784 /* set user defined mode */
7785 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7787 TEST_ASSERT(ret == 0,
7788 "Failed to set cdev %u to user defined mode", sched_id);
7790 /* set round robin mode */
7791 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7792 CDEV_SCHED_MODE_ROUNDROBIN);
7793 TEST_ASSERT(ret == 0,
7794 "Failed to set cdev %u to round-robin mode", sched_id);
7795 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7796 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7802 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7803 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7804 .setup = testsuite_setup,
7805 .teardown = testsuite_teardown,
7806 .unit_test_cases = {
7807 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7808 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7809 TEST_CASE_ST(ut_setup, ut_teardown,
7810 test_AES_chain_scheduler_all),
7811 TEST_CASE_ST(ut_setup, ut_teardown,
7812 test_AES_cipheronly_scheduler_all),
7813 TEST_CASE_ST(ut_setup, ut_teardown,
7814 test_authonly_scheduler_all),
7815 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7816 TEST_CASES_END() /**< NULL terminate unit test array */
7820 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7822 static struct unit_test_suite cryptodev_qat_testsuite = {
7823 .suite_name = "Crypto QAT Unit Test Suite",
7824 .setup = testsuite_setup,
7825 .teardown = testsuite_teardown,
7826 .unit_test_cases = {
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_device_configure_invalid_dev_id),
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_device_configure_invalid_queue_pair_ids),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_queue_pair_descriptor_setup),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_multi_session),
7836 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_AES_cipheronly_qat_all),
7839 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_3DES_cipheronly_qat_all),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_DES_cipheronly_qat_all),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_AES_docsis_qat_all),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_DES_docsis_qat_all),
7848 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7850 /** AES GCM Authenticated Encryption */
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_AES_GCM_authenticated_encryption_test_case_1),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_AES_GCM_authenticated_encryption_test_case_2),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_AES_GCM_authenticated_encryption_test_case_3),
7863 TEST_CASE_ST(ut_setup, ut_teardown,
7864 test_AES_GCM_authenticated_encryption_test_case_4),
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 test_AES_GCM_authenticated_encryption_test_case_5),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 test_AES_GCM_authenticated_encryption_test_case_6),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 test_AES_GCM_authenticated_encryption_test_case_7),
7872 /** AES GCM Authenticated Decryption */
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_AES_GCM_authenticated_decryption_test_case_1),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_AES_GCM_authenticated_decryption_test_case_2),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_AES_GCM_authenticated_decryption_test_case_3),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_AES_GCM_authenticated_decryption_test_case_4),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_AES_GCM_authenticated_decryption_test_case_5),
7883 TEST_CASE_ST(ut_setup, ut_teardown,
7884 test_AES_GCM_authenticated_decryption_test_case_6),
7885 TEST_CASE_ST(ut_setup, ut_teardown,
7886 test_AES_GCM_authenticated_decryption_test_case_7),
7888 /** AES GCM Authenticated Encryption 192 bits key */
7889 TEST_CASE_ST(ut_setup, ut_teardown,
7890 test_AES_GCM_auth_encryption_test_case_192_1),
7891 TEST_CASE_ST(ut_setup, ut_teardown,
7892 test_AES_GCM_auth_encryption_test_case_192_2),
7893 TEST_CASE_ST(ut_setup, ut_teardown,
7894 test_AES_GCM_auth_encryption_test_case_192_3),
7895 TEST_CASE_ST(ut_setup, ut_teardown,
7896 test_AES_GCM_auth_encryption_test_case_192_4),
7897 TEST_CASE_ST(ut_setup, ut_teardown,
7898 test_AES_GCM_auth_encryption_test_case_192_5),
7899 TEST_CASE_ST(ut_setup, ut_teardown,
7900 test_AES_GCM_auth_encryption_test_case_192_6),
7901 TEST_CASE_ST(ut_setup, ut_teardown,
7902 test_AES_GCM_auth_encryption_test_case_192_7),
7904 /** AES GCM Authenticated Decryption 192 bits key */
7905 TEST_CASE_ST(ut_setup, ut_teardown,
7906 test_AES_GCM_auth_decryption_test_case_192_1),
7907 TEST_CASE_ST(ut_setup, ut_teardown,
7908 test_AES_GCM_auth_decryption_test_case_192_2),
7909 TEST_CASE_ST(ut_setup, ut_teardown,
7910 test_AES_GCM_auth_decryption_test_case_192_3),
7911 TEST_CASE_ST(ut_setup, ut_teardown,
7912 test_AES_GCM_auth_decryption_test_case_192_4),
7913 TEST_CASE_ST(ut_setup, ut_teardown,
7914 test_AES_GCM_auth_decryption_test_case_192_5),
7915 TEST_CASE_ST(ut_setup, ut_teardown,
7916 test_AES_GCM_auth_decryption_test_case_192_6),
7917 TEST_CASE_ST(ut_setup, ut_teardown,
7918 test_AES_GCM_auth_decryption_test_case_192_7),
7920 /** AES GCM Authenticated Encryption 256 bits key */
7921 TEST_CASE_ST(ut_setup, ut_teardown,
7922 test_AES_GCM_auth_encryption_test_case_256_1),
7923 TEST_CASE_ST(ut_setup, ut_teardown,
7924 test_AES_GCM_auth_encryption_test_case_256_2),
7925 TEST_CASE_ST(ut_setup, ut_teardown,
7926 test_AES_GCM_auth_encryption_test_case_256_3),
7927 TEST_CASE_ST(ut_setup, ut_teardown,
7928 test_AES_GCM_auth_encryption_test_case_256_4),
7929 TEST_CASE_ST(ut_setup, ut_teardown,
7930 test_AES_GCM_auth_encryption_test_case_256_5),
7931 TEST_CASE_ST(ut_setup, ut_teardown,
7932 test_AES_GCM_auth_encryption_test_case_256_6),
7933 TEST_CASE_ST(ut_setup, ut_teardown,
7934 test_AES_GCM_auth_encryption_test_case_256_7),
7936 /** AES GMAC Authentication */
7937 TEST_CASE_ST(ut_setup, ut_teardown,
7938 test_AES_GMAC_authentication_test_case_1),
7939 TEST_CASE_ST(ut_setup, ut_teardown,
7940 test_AES_GMAC_authentication_verify_test_case_1),
7941 TEST_CASE_ST(ut_setup, ut_teardown,
7942 test_AES_GMAC_authentication_test_case_2),
7943 TEST_CASE_ST(ut_setup, ut_teardown,
7944 test_AES_GMAC_authentication_verify_test_case_2),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_AES_GMAC_authentication_test_case_3),
7947 TEST_CASE_ST(ut_setup, ut_teardown,
7948 test_AES_GMAC_authentication_verify_test_case_3),
7950 /** SNOW 3G encrypt only (UEA2) */
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_snow3g_encryption_test_case_1),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_snow3g_encryption_test_case_2),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_snow3g_encryption_test_case_3),
7957 TEST_CASE_ST(ut_setup, ut_teardown,
7958 test_snow3g_encryption_test_case_4),
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 test_snow3g_encryption_test_case_5),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_snow3g_encryption_test_case_1_oop),
7964 TEST_CASE_ST(ut_setup, ut_teardown,
7965 test_snow3g_decryption_test_case_1_oop),
7967 /** SNOW 3G decrypt only (UEA2) */
7968 TEST_CASE_ST(ut_setup, ut_teardown,
7969 test_snow3g_decryption_test_case_1),
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 test_snow3g_decryption_test_case_2),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 test_snow3g_decryption_test_case_3),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 test_snow3g_decryption_test_case_4),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 test_snow3g_decryption_test_case_5),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 test_snow3g_hash_generate_test_case_1),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 test_snow3g_hash_generate_test_case_2),
7982 TEST_CASE_ST(ut_setup, ut_teardown,
7983 test_snow3g_hash_generate_test_case_3),
7984 TEST_CASE_ST(ut_setup, ut_teardown,
7985 test_snow3g_hash_verify_test_case_1),
7986 TEST_CASE_ST(ut_setup, ut_teardown,
7987 test_snow3g_hash_verify_test_case_2),
7988 TEST_CASE_ST(ut_setup, ut_teardown,
7989 test_snow3g_hash_verify_test_case_3),
7990 TEST_CASE_ST(ut_setup, ut_teardown,
7991 test_snow3g_cipher_auth_test_case_1),
7992 TEST_CASE_ST(ut_setup, ut_teardown,
7993 test_snow3g_auth_cipher_test_case_1),
7995 /** ZUC encrypt only (EEA3) */
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_zuc_encryption_test_case_1),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_zuc_encryption_test_case_2),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_zuc_encryption_test_case_3),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_zuc_encryption_test_case_4),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_zuc_encryption_test_case_5),
8007 /** ZUC authenticate (EIA3) */
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_zuc_hash_generate_test_case_6),
8010 TEST_CASE_ST(ut_setup, ut_teardown,
8011 test_zuc_hash_generate_test_case_7),
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_zuc_hash_generate_test_case_8),
8015 /** ZUC alg-chain (EEA3/EIA3) */
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_zuc_cipher_auth_test_case_1),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_zuc_cipher_auth_test_case_2),
8021 /** HMAC_MD5 Authentication */
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_MD5_HMAC_generate_case_1),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 test_MD5_HMAC_verify_case_1),
8026 TEST_CASE_ST(ut_setup, ut_teardown,
8027 test_MD5_HMAC_generate_case_2),
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_MD5_HMAC_verify_case_2),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_null_auth_only_operation),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_null_cipher_only_operation),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_null_cipher_auth_operation),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_null_auth_cipher_operation),
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_kasumi_hash_generate_test_case_6),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_kasumi_encryption_test_case_1),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_kasumi_encryption_test_case_3),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_kasumi_auth_cipher_test_case_1),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_kasumi_cipher_auth_test_case_1),
8054 /** Negative tests */
8055 TEST_CASE_ST(ut_setup, ut_teardown,
8056 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 authentication_verify_AES128_GMAC_fail_data_corrupt),
8061 TEST_CASE_ST(ut_setup, ut_teardown,
8062 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8068 TEST_CASES_END() /**< NULL terminate unit test array */
8072 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8073 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8074 .setup = testsuite_setup,
8075 .teardown = testsuite_teardown,
8076 .unit_test_cases = {
8077 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8078 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8079 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8080 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8082 TEST_CASES_END() /**< NULL terminate unit test array */
8086 static struct unit_test_suite cryptodev_openssl_testsuite = {
8087 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8088 .setup = testsuite_setup,
8089 .teardown = testsuite_teardown,
8090 .unit_test_cases = {
8091 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8092 TEST_CASE_ST(ut_setup, ut_teardown,
8093 test_multi_session_random_usage),
8094 TEST_CASE_ST(ut_setup, ut_teardown,
8095 test_AES_chain_openssl_all),
8096 TEST_CASE_ST(ut_setup, ut_teardown,
8097 test_AES_cipheronly_openssl_all),
8098 TEST_CASE_ST(ut_setup, ut_teardown,
8099 test_3DES_chain_openssl_all),
8100 TEST_CASE_ST(ut_setup, ut_teardown,
8101 test_3DES_cipheronly_openssl_all),
8102 TEST_CASE_ST(ut_setup, ut_teardown,
8103 test_DES_docsis_openssl_all),
8104 TEST_CASE_ST(ut_setup, ut_teardown,
8105 test_authonly_openssl_all),
8107 /** AES GCM Authenticated Encryption */
8108 TEST_CASE_ST(ut_setup, ut_teardown,
8109 test_AES_GCM_authenticated_encryption_test_case_1),
8110 TEST_CASE_ST(ut_setup, ut_teardown,
8111 test_AES_GCM_authenticated_encryption_test_case_2),
8112 TEST_CASE_ST(ut_setup, ut_teardown,
8113 test_AES_GCM_authenticated_encryption_test_case_3),
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_AES_GCM_authenticated_encryption_test_case_4),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_AES_GCM_authenticated_encryption_test_case_5),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_AES_GCM_authenticated_encryption_test_case_6),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_AES_GCM_authenticated_encryption_test_case_7),
8123 /** AES GCM Authenticated Decryption */
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_AES_GCM_authenticated_decryption_test_case_1),
8126 TEST_CASE_ST(ut_setup, ut_teardown,
8127 test_AES_GCM_authenticated_decryption_test_case_2),
8128 TEST_CASE_ST(ut_setup, ut_teardown,
8129 test_AES_GCM_authenticated_decryption_test_case_3),
8130 TEST_CASE_ST(ut_setup, ut_teardown,
8131 test_AES_GCM_authenticated_decryption_test_case_4),
8132 TEST_CASE_ST(ut_setup, ut_teardown,
8133 test_AES_GCM_authenticated_decryption_test_case_5),
8134 TEST_CASE_ST(ut_setup, ut_teardown,
8135 test_AES_GCM_authenticated_decryption_test_case_6),
8136 TEST_CASE_ST(ut_setup, ut_teardown,
8137 test_AES_GCM_authenticated_decryption_test_case_7),
8140 /** AES GCM Authenticated Encryption 192 bits key */
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_AES_GCM_auth_encryption_test_case_192_1),
8143 TEST_CASE_ST(ut_setup, ut_teardown,
8144 test_AES_GCM_auth_encryption_test_case_192_2),
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_AES_GCM_auth_encryption_test_case_192_3),
8147 TEST_CASE_ST(ut_setup, ut_teardown,
8148 test_AES_GCM_auth_encryption_test_case_192_4),
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_AES_GCM_auth_encryption_test_case_192_5),
8151 TEST_CASE_ST(ut_setup, ut_teardown,
8152 test_AES_GCM_auth_encryption_test_case_192_6),
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_AES_GCM_auth_encryption_test_case_192_7),
8156 /** AES GCM Authenticated Decryption 192 bits key */
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_AES_GCM_auth_decryption_test_case_192_1),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_AES_GCM_auth_decryption_test_case_192_2),
8161 TEST_CASE_ST(ut_setup, ut_teardown,
8162 test_AES_GCM_auth_decryption_test_case_192_3),
8163 TEST_CASE_ST(ut_setup, ut_teardown,
8164 test_AES_GCM_auth_decryption_test_case_192_4),
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_AES_GCM_auth_decryption_test_case_192_5),
8167 TEST_CASE_ST(ut_setup, ut_teardown,
8168 test_AES_GCM_auth_decryption_test_case_192_6),
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_AES_GCM_auth_decryption_test_case_192_7),
8172 /** AES GCM Authenticated Encryption 256 bits key */
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_AES_GCM_auth_encryption_test_case_256_1),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_AES_GCM_auth_encryption_test_case_256_2),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_AES_GCM_auth_encryption_test_case_256_3),
8179 TEST_CASE_ST(ut_setup, ut_teardown,
8180 test_AES_GCM_auth_encryption_test_case_256_4),
8181 TEST_CASE_ST(ut_setup, ut_teardown,
8182 test_AES_GCM_auth_encryption_test_case_256_5),
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_AES_GCM_auth_encryption_test_case_256_6),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_AES_GCM_auth_encryption_test_case_256_7),
8188 /** AES GCM Authenticated Decryption 256 bits key */
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_AES_GCM_auth_decryption_test_case_256_1),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_AES_GCM_auth_decryption_test_case_256_2),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_AES_GCM_auth_decryption_test_case_256_3),
8195 TEST_CASE_ST(ut_setup, ut_teardown,
8196 test_AES_GCM_auth_decryption_test_case_256_4),
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_AES_GCM_auth_decryption_test_case_256_5),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_AES_GCM_auth_decryption_test_case_256_6),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_AES_GCM_auth_decryption_test_case_256_7),
8204 /** AES GMAC Authentication */
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_AES_GMAC_authentication_test_case_1),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_AES_GMAC_authentication_verify_test_case_1),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_AES_GMAC_authentication_test_case_2),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_AES_GMAC_authentication_verify_test_case_2),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_AES_GMAC_authentication_test_case_3),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_AES_GMAC_authentication_verify_test_case_3),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_AES_GMAC_authentication_test_case_4),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_AES_GMAC_authentication_verify_test_case_4),
8222 /** Scatter-Gather */
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8226 /** Negative tests */
8227 TEST_CASE_ST(ut_setup, ut_teardown,
8228 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8231 TEST_CASE_ST(ut_setup, ut_teardown,
8232 authentication_verify_AES128_GMAC_fail_data_corrupt),
8233 TEST_CASE_ST(ut_setup, ut_teardown,
8234 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8240 TEST_CASES_END() /**< NULL terminate unit test array */
8244 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8245 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8246 .setup = testsuite_setup,
8247 .teardown = testsuite_teardown,
8248 .unit_test_cases = {
8249 /** AES GCM Authenticated Encryption */
8250 TEST_CASE_ST(ut_setup, ut_teardown,
8251 test_AES_GCM_authenticated_encryption_test_case_1),
8252 TEST_CASE_ST(ut_setup, ut_teardown,
8253 test_AES_GCM_authenticated_encryption_test_case_2),
8254 TEST_CASE_ST(ut_setup, ut_teardown,
8255 test_AES_GCM_authenticated_encryption_test_case_3),
8256 TEST_CASE_ST(ut_setup, ut_teardown,
8257 test_AES_GCM_authenticated_encryption_test_case_4),
8258 TEST_CASE_ST(ut_setup, ut_teardown,
8259 test_AES_GCM_authenticated_encryption_test_case_5),
8260 TEST_CASE_ST(ut_setup, ut_teardown,
8261 test_AES_GCM_authenticated_encryption_test_case_6),
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_AES_GCM_authenticated_encryption_test_case_7),
8265 /** AES GCM Authenticated Decryption */
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_AES_GCM_authenticated_decryption_test_case_1),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_AES_GCM_authenticated_decryption_test_case_2),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_AES_GCM_authenticated_decryption_test_case_3),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_AES_GCM_authenticated_decryption_test_case_4),
8274 TEST_CASE_ST(ut_setup, ut_teardown,
8275 test_AES_GCM_authenticated_decryption_test_case_5),
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_AES_GCM_authenticated_decryption_test_case_6),
8278 TEST_CASE_ST(ut_setup, ut_teardown,
8279 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 GCM Authenticated Encryption big aad size */
8346 TEST_CASE_ST(ut_setup, ut_teardown,
8347 test_AES_GCM_auth_encryption_test_case_aad_1),
8348 TEST_CASE_ST(ut_setup, ut_teardown,
8349 test_AES_GCM_auth_encryption_test_case_aad_2),
8351 /** AES GCM Authenticated Decryption big aad size */
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_AES_GCM_auth_decryption_test_case_aad_1),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_AES_GCM_auth_decryption_test_case_aad_2),
8357 /** AES GMAC Authentication */
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_AES_GMAC_authentication_test_case_1),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_AES_GMAC_authentication_verify_test_case_1),
8362 TEST_CASE_ST(ut_setup, ut_teardown,
8363 test_AES_GMAC_authentication_test_case_3),
8364 TEST_CASE_ST(ut_setup, ut_teardown,
8365 test_AES_GMAC_authentication_verify_test_case_3),
8366 TEST_CASE_ST(ut_setup, ut_teardown,
8367 test_AES_GMAC_authentication_test_case_4),
8368 TEST_CASE_ST(ut_setup, ut_teardown,
8369 test_AES_GMAC_authentication_verify_test_case_4),
8371 /** Negative tests */
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),
8377 /** Out of place tests */
8378 TEST_CASE_ST(ut_setup, ut_teardown,
8379 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8380 TEST_CASE_ST(ut_setup, ut_teardown,
8381 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8383 /** Session-less tests */
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8389 /** Scatter-Gather */
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8393 TEST_CASES_END() /**< NULL terminate unit test array */
8397 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8398 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8399 .setup = testsuite_setup,
8400 .teardown = testsuite_teardown,
8401 .unit_test_cases = {
8402 /** KASUMI encrypt only (UEA1) */
8403 TEST_CASE_ST(ut_setup, ut_teardown,
8404 test_kasumi_encryption_test_case_1),
8405 TEST_CASE_ST(ut_setup, ut_teardown,
8406 test_kasumi_encryption_test_case_1_sgl),
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_kasumi_encryption_test_case_2),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_kasumi_encryption_test_case_3),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_kasumi_encryption_test_case_4),
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 test_kasumi_encryption_test_case_5),
8415 /** KASUMI decrypt only (UEA1) */
8416 TEST_CASE_ST(ut_setup, ut_teardown,
8417 test_kasumi_decryption_test_case_1),
8418 TEST_CASE_ST(ut_setup, ut_teardown,
8419 test_kasumi_decryption_test_case_2),
8420 TEST_CASE_ST(ut_setup, ut_teardown,
8421 test_kasumi_decryption_test_case_3),
8422 TEST_CASE_ST(ut_setup, ut_teardown,
8423 test_kasumi_decryption_test_case_4),
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_kasumi_decryption_test_case_5),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_kasumi_encryption_test_case_1_oop),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_kasumi_encryption_test_case_1_oop_sgl),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_kasumi_decryption_test_case_1_oop),
8436 /** KASUMI hash only (UIA1) */
8437 TEST_CASE_ST(ut_setup, ut_teardown,
8438 test_kasumi_hash_generate_test_case_1),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_kasumi_hash_generate_test_case_2),
8441 TEST_CASE_ST(ut_setup, ut_teardown,
8442 test_kasumi_hash_generate_test_case_3),
8443 TEST_CASE_ST(ut_setup, ut_teardown,
8444 test_kasumi_hash_generate_test_case_4),
8445 TEST_CASE_ST(ut_setup, ut_teardown,
8446 test_kasumi_hash_generate_test_case_5),
8447 TEST_CASE_ST(ut_setup, ut_teardown,
8448 test_kasumi_hash_generate_test_case_6),
8449 TEST_CASE_ST(ut_setup, ut_teardown,
8450 test_kasumi_hash_verify_test_case_1),
8451 TEST_CASE_ST(ut_setup, ut_teardown,
8452 test_kasumi_hash_verify_test_case_2),
8453 TEST_CASE_ST(ut_setup, ut_teardown,
8454 test_kasumi_hash_verify_test_case_3),
8455 TEST_CASE_ST(ut_setup, ut_teardown,
8456 test_kasumi_hash_verify_test_case_4),
8457 TEST_CASE_ST(ut_setup, ut_teardown,
8458 test_kasumi_hash_verify_test_case_5),
8459 TEST_CASE_ST(ut_setup, ut_teardown,
8460 test_kasumi_auth_cipher_test_case_1),
8461 TEST_CASE_ST(ut_setup, ut_teardown,
8462 test_kasumi_cipher_auth_test_case_1),
8463 TEST_CASES_END() /**< NULL terminate unit test array */
8466 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8467 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8468 .setup = testsuite_setup,
8469 .teardown = testsuite_teardown,
8470 .unit_test_cases = {
8471 /** SNOW 3G encrypt only (UEA2) */
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_snow3g_encryption_test_case_1),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_snow3g_encryption_test_case_2),
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_snow3g_encryption_test_case_3),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_snow3g_encryption_test_case_4),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_snow3g_encryption_test_case_5),
8483 TEST_CASE_ST(ut_setup, ut_teardown,
8484 test_snow3g_encryption_test_case_1_oop),
8485 TEST_CASE_ST(ut_setup, ut_teardown,
8486 test_snow3g_encryption_test_case_1_oop_sgl),
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_snow3g_decryption_test_case_1_oop),
8490 TEST_CASE_ST(ut_setup, ut_teardown,
8491 test_snow3g_encryption_test_case_1_offset_oop),
8493 /** SNOW 3G decrypt only (UEA2) */
8494 TEST_CASE_ST(ut_setup, ut_teardown,
8495 test_snow3g_decryption_test_case_1),
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_snow3g_decryption_test_case_2),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_snow3g_decryption_test_case_3),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_snow3g_decryption_test_case_4),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_snow3g_decryption_test_case_5),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_snow3g_hash_generate_test_case_1),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_snow3g_hash_generate_test_case_2),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_snow3g_hash_generate_test_case_3),
8510 /* Tests with buffers which length is not byte-aligned */
8511 TEST_CASE_ST(ut_setup, ut_teardown,
8512 test_snow3g_hash_generate_test_case_4),
8513 TEST_CASE_ST(ut_setup, ut_teardown,
8514 test_snow3g_hash_generate_test_case_5),
8515 TEST_CASE_ST(ut_setup, ut_teardown,
8516 test_snow3g_hash_generate_test_case_6),
8517 TEST_CASE_ST(ut_setup, ut_teardown,
8518 test_snow3g_hash_verify_test_case_1),
8519 TEST_CASE_ST(ut_setup, ut_teardown,
8520 test_snow3g_hash_verify_test_case_2),
8521 TEST_CASE_ST(ut_setup, ut_teardown,
8522 test_snow3g_hash_verify_test_case_3),
8523 /* Tests with buffers which length is not byte-aligned */
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_snow3g_hash_verify_test_case_4),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_snow3g_hash_verify_test_case_5),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_snow3g_hash_verify_test_case_6),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_snow3g_cipher_auth_test_case_1),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_snow3g_auth_cipher_test_case_1),
8535 TEST_CASES_END() /**< NULL terminate unit test array */
8539 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8540 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8541 .setup = testsuite_setup,
8542 .teardown = testsuite_teardown,
8543 .unit_test_cases = {
8544 /** ZUC encrypt only (EEA3) */
8545 TEST_CASE_ST(ut_setup, ut_teardown,
8546 test_zuc_encryption_test_case_1),
8547 TEST_CASE_ST(ut_setup, ut_teardown,
8548 test_zuc_encryption_test_case_2),
8549 TEST_CASE_ST(ut_setup, ut_teardown,
8550 test_zuc_encryption_test_case_3),
8551 TEST_CASE_ST(ut_setup, ut_teardown,
8552 test_zuc_encryption_test_case_4),
8553 TEST_CASE_ST(ut_setup, ut_teardown,
8554 test_zuc_encryption_test_case_5),
8555 TEST_CASE_ST(ut_setup, ut_teardown,
8556 test_zuc_hash_generate_test_case_1),
8557 TEST_CASE_ST(ut_setup, ut_teardown,
8558 test_zuc_hash_generate_test_case_2),
8559 TEST_CASE_ST(ut_setup, ut_teardown,
8560 test_zuc_hash_generate_test_case_3),
8561 TEST_CASE_ST(ut_setup, ut_teardown,
8562 test_zuc_hash_generate_test_case_4),
8563 TEST_CASE_ST(ut_setup, ut_teardown,
8564 test_zuc_hash_generate_test_case_5),
8565 TEST_CASE_ST(ut_setup, ut_teardown,
8566 test_zuc_encryption_test_case_6_sgl),
8567 TEST_CASES_END() /**< NULL terminate unit test array */
8571 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8572 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8573 .setup = testsuite_setup,
8574 .teardown = testsuite_teardown,
8575 .unit_test_cases = {
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_device_configure_invalid_dev_id),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_multi_session),
8581 TEST_CASE_ST(ut_setup, ut_teardown,
8582 test_AES_chain_dpaa2_sec_all),
8583 TEST_CASE_ST(ut_setup, ut_teardown,
8584 test_3DES_chain_dpaa2_sec_all),
8585 TEST_CASE_ST(ut_setup, ut_teardown,
8586 test_AES_cipheronly_dpaa2_sec_all),
8587 TEST_CASE_ST(ut_setup, ut_teardown,
8588 test_3DES_cipheronly_dpaa2_sec_all),
8589 TEST_CASE_ST(ut_setup, ut_teardown,
8590 test_authonly_dpaa2_sec_all),
8592 /** AES GCM Authenticated Encryption */
8593 TEST_CASE_ST(ut_setup, ut_teardown,
8594 test_AES_GCM_authenticated_encryption_test_case_1),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_AES_GCM_authenticated_encryption_test_case_2),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_AES_GCM_authenticated_encryption_test_case_3),
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_AES_GCM_authenticated_encryption_test_case_4),
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 test_AES_GCM_authenticated_encryption_test_case_5),
8603 TEST_CASE_ST(ut_setup, ut_teardown,
8604 test_AES_GCM_authenticated_encryption_test_case_6),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 test_AES_GCM_authenticated_encryption_test_case_7),
8608 /** AES GCM Authenticated Decryption */
8609 TEST_CASE_ST(ut_setup, ut_teardown,
8610 test_AES_GCM_authenticated_decryption_test_case_1),
8611 TEST_CASE_ST(ut_setup, ut_teardown,
8612 test_AES_GCM_authenticated_decryption_test_case_2),
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_AES_GCM_authenticated_decryption_test_case_3),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_AES_GCM_authenticated_decryption_test_case_4),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_AES_GCM_authenticated_decryption_test_case_5),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_AES_GCM_authenticated_decryption_test_case_6),
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_AES_GCM_authenticated_decryption_test_case_7),
8624 /** AES GCM Authenticated Encryption 192 bits key */
8625 TEST_CASE_ST(ut_setup, ut_teardown,
8626 test_AES_GCM_auth_encryption_test_case_192_1),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_AES_GCM_auth_encryption_test_case_192_2),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_AES_GCM_auth_encryption_test_case_192_3),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_AES_GCM_auth_encryption_test_case_192_4),
8633 TEST_CASE_ST(ut_setup, ut_teardown,
8634 test_AES_GCM_auth_encryption_test_case_192_5),
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_AES_GCM_auth_encryption_test_case_192_6),
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_AES_GCM_auth_encryption_test_case_192_7),
8640 /** AES GCM Authenticated Decryption 192 bits key */
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_AES_GCM_auth_decryption_test_case_192_1),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_AES_GCM_auth_decryption_test_case_192_2),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_AES_GCM_auth_decryption_test_case_192_3),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_AES_GCM_auth_decryption_test_case_192_4),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_AES_GCM_auth_decryption_test_case_192_5),
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_AES_GCM_auth_decryption_test_case_192_6),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_AES_GCM_auth_decryption_test_case_192_7),
8656 /** AES GCM Authenticated Encryption 256 bits key */
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_AES_GCM_auth_encryption_test_case_256_1),
8659 TEST_CASE_ST(ut_setup, ut_teardown,
8660 test_AES_GCM_auth_encryption_test_case_256_2),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_AES_GCM_auth_encryption_test_case_256_3),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_AES_GCM_auth_encryption_test_case_256_4),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_AES_GCM_auth_encryption_test_case_256_5),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_AES_GCM_auth_encryption_test_case_256_6),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_AES_GCM_auth_encryption_test_case_256_7),
8672 /** AES GCM Authenticated Decryption 256 bits key */
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_AES_GCM_auth_decryption_test_case_256_1),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_AES_GCM_auth_decryption_test_case_256_2),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_AES_GCM_auth_decryption_test_case_256_3),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_AES_GCM_auth_decryption_test_case_256_4),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_AES_GCM_auth_decryption_test_case_256_5),
8683 TEST_CASE_ST(ut_setup, ut_teardown,
8684 test_AES_GCM_auth_decryption_test_case_256_6),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_AES_GCM_auth_decryption_test_case_256_7),
8688 TEST_CASES_END() /**< NULL terminate unit test array */
8692 static struct unit_test_suite cryptodev_null_testsuite = {
8693 .suite_name = "Crypto Device NULL Unit Test Suite",
8694 .setup = testsuite_setup,
8695 .teardown = testsuite_teardown,
8696 .unit_test_cases = {
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_null_auth_only_operation),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_null_cipher_only_operation),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_null_cipher_auth_operation),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_null_auth_cipher_operation),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_null_invalid_operation),
8707 TEST_CASE_ST(ut_setup, ut_teardown,
8708 test_null_burst_operation),
8710 TEST_CASES_END() /**< NULL terminate unit test array */
8714 static struct unit_test_suite cryptodev_armv8_testsuite = {
8715 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8716 .setup = testsuite_setup,
8717 .teardown = testsuite_teardown,
8718 .unit_test_cases = {
8719 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8721 /** Negative tests */
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8727 TEST_CASES_END() /**< NULL terminate unit test array */
8732 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8734 gbl_driver_id = rte_cryptodev_driver_id_get(
8735 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
8737 if (gbl_driver_id == -1) {
8738 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
8739 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
8740 "in config file to run this testsuite.\n");
8744 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8748 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8750 gbl_driver_id = rte_cryptodev_driver_id_get(
8751 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8753 if (gbl_driver_id == -1) {
8754 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8755 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8756 "in config file to run this testsuite.\n");
8760 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8764 test_cryptodev_openssl(void)
8766 gbl_driver_id = rte_cryptodev_driver_id_get(
8767 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
8769 if (gbl_driver_id == -1) {
8770 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
8771 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
8772 "in config file to run this testsuite.\n");
8776 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8780 test_cryptodev_aesni_gcm(void)
8782 gbl_driver_id = rte_cryptodev_driver_id_get(
8783 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
8785 if (gbl_driver_id == -1) {
8786 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
8787 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
8788 "in config file to run this testsuite.\n");
8792 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8796 test_cryptodev_null(void)
8798 gbl_driver_id = rte_cryptodev_driver_id_get(
8799 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
8801 if (gbl_driver_id == -1) {
8802 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
8803 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
8804 "in config file to run this testsuite.\n");
8808 return unit_test_suite_runner(&cryptodev_null_testsuite);
8812 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8814 gbl_driver_id = rte_cryptodev_driver_id_get(
8815 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
8817 if (gbl_driver_id == -1) {
8818 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
8819 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
8820 "in config file to run this testsuite.\n");
8824 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8828 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8830 gbl_driver_id = rte_cryptodev_driver_id_get(
8831 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
8833 if (gbl_driver_id == -1) {
8834 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8835 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
8836 "in config file to run this testsuite.\n");
8840 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8844 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8846 gbl_driver_id = rte_cryptodev_driver_id_get(
8847 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
8849 if (gbl_driver_id == -1) {
8850 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
8851 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
8852 "in config file to run this testsuite.\n");
8856 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8860 test_cryptodev_armv8(void)
8862 gbl_driver_id = rte_cryptodev_driver_id_get(
8863 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
8865 if (gbl_driver_id == -1) {
8866 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
8867 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
8868 "in config file to run this testsuite.\n");
8872 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8875 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8878 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8880 gbl_driver_id = rte_cryptodev_driver_id_get(
8881 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
8883 if (gbl_driver_id == -1) {
8884 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
8885 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
8886 "in config file to run this testsuite.\n");
8890 if (rte_cryptodev_driver_id_get(
8891 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
8892 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
8893 " enabled in config file to run this testsuite.\n");
8896 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8899 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8904 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8906 gbl_driver_id = rte_cryptodev_driver_id_get(
8907 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
8909 if (gbl_driver_id == -1) {
8910 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
8911 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
8912 "in config file to run this testsuite.\n");
8916 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8919 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8920 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8921 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8922 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8923 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8924 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8925 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8926 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8927 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8928 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);