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 enum rte_cryptodev_type gbl_cryptodev_type;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_cryptodev_config conf;
71 struct rte_cryptodev_qp_conf qp_conf;
73 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
74 uint8_t valid_dev_count;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
80 struct rte_crypto_sym_xform aead_xform;
82 struct rte_cryptodev_sym_session *sess;
84 struct rte_crypto_op *op;
86 struct rte_mbuf *obuf, *ibuf;
91 #define ALIGN_POW2_ROUNDUP(num, align) \
92 (((num) + (align) - 1) & ~((align) - 1))
95 * Forward declarations.
98 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
99 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
103 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
104 struct crypto_unittest_params *ut_params,
105 struct crypto_testsuite_params *ts_param,
106 const uint8_t *cipher,
107 const uint8_t *digest,
110 static struct rte_mbuf *
111 setup_test_string(struct rte_mempool *mpool,
112 const char *string, size_t len, uint8_t blocksize)
114 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
115 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
117 memset(m->buf_addr, 0, m->buf_len);
119 char *dst = rte_pktmbuf_append(m, t_len);
126 rte_memcpy(dst, string, t_len);
128 memset(dst, 0, t_len);
134 /* Get number of bytes in X bits (rounding up) */
136 ceil_byte_length(uint32_t num_bits)
139 return ((num_bits >> 3) + 1);
141 return (num_bits >> 3);
144 static struct rte_crypto_op *
145 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
147 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
148 printf("Error sending packet for encryption");
154 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
160 static struct crypto_testsuite_params testsuite_params = { NULL };
161 static struct crypto_unittest_params unittest_params;
164 testsuite_setup(void)
166 struct crypto_testsuite_params *ts_params = &testsuite_params;
167 struct rte_cryptodev_info info;
168 uint32_t i = 0, nb_devs, dev_id;
172 memset(ts_params, 0, sizeof(*ts_params));
174 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
175 if (ts_params->mbuf_pool == NULL) {
176 /* Not already created so create */
177 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
179 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
181 if (ts_params->mbuf_pool == NULL) {
182 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
187 ts_params->large_mbuf_pool = rte_mempool_lookup(
188 "CRYPTO_LARGE_MBUFPOOL");
189 if (ts_params->large_mbuf_pool == NULL) {
190 /* Not already created so create */
191 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
192 "CRYPTO_LARGE_MBUFPOOL",
195 if (ts_params->large_mbuf_pool == NULL) {
197 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
202 ts_params->op_mpool = rte_crypto_op_pool_create(
203 "MBUF_CRYPTO_SYM_OP_POOL",
204 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
205 NUM_MBUFS, MBUF_CACHE_SIZE,
207 sizeof(struct rte_crypto_sym_xform) +
210 if (ts_params->op_mpool == NULL) {
211 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
215 /* Create an AESNI MB device if required */
216 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
217 #ifndef RTE_LIBRTE_PMD_AESNI_MB
218 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
219 " enabled in config file to run this testsuite.\n");
222 nb_devs = rte_cryptodev_count_devtype(
223 RTE_CRYPTODEV_AESNI_MB_PMD);
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
228 TEST_ASSERT(ret == 0,
229 "Failed to create instance of"
231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create an AESNI GCM device if required */
236 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
237 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
238 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
239 " enabled in config file to run this testsuite.\n");
242 nb_devs = rte_cryptodev_count_devtype(
243 RTE_CRYPTODEV_AESNI_GCM_PMD);
245 TEST_ASSERT_SUCCESS(rte_vdev_init(
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
247 "Failed to create instance of"
249 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
253 /* Create a SNOW 3G device if required */
254 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
255 #ifndef RTE_LIBRTE_PMD_SNOW3G
256 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
257 " enabled in config file to run this testsuite.\n");
260 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
262 TEST_ASSERT_SUCCESS(rte_vdev_init(
263 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
264 "Failed to create instance of"
266 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
270 /* Create a KASUMI device if required */
271 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
272 #ifndef RTE_LIBRTE_PMD_KASUMI
273 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
274 " enabled in config file to run this testsuite.\n");
277 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
279 TEST_ASSERT_SUCCESS(rte_vdev_init(
280 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
281 "Failed to create instance of"
283 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
287 /* Create a ZUC device if required */
288 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
289 #ifndef RTE_LIBRTE_PMD_ZUC
290 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
291 " enabled in config file to run this testsuite.\n");
294 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
296 TEST_ASSERT_SUCCESS(rte_vdev_init(
297 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
298 "Failed to create instance of"
300 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
304 /* Create a NULL device if required */
305 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
306 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
307 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
308 " enabled in config file to run this testsuite.\n");
311 nb_devs = rte_cryptodev_count_devtype(
312 RTE_CRYPTODEV_NULL_PMD);
315 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
317 TEST_ASSERT(ret == 0,
318 "Failed to create instance of"
320 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
324 /* Create an OPENSSL device if required */
325 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
326 #ifndef RTE_LIBRTE_PMD_OPENSSL
327 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
328 " enabled in config file to run this testsuite.\n");
331 nb_devs = rte_cryptodev_count_devtype(
332 RTE_CRYPTODEV_OPENSSL_PMD);
335 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
338 TEST_ASSERT(ret == 0, "Failed to create "
339 "instance of pmd : %s",
340 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
344 /* Create a ARMv8 device if required */
345 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
346 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
347 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
348 " enabled in config file to run this testsuite.\n");
351 nb_devs = rte_cryptodev_count_devtype(
352 RTE_CRYPTODEV_ARMV8_PMD);
355 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
358 TEST_ASSERT(ret == 0, "Failed to create "
359 "instance of pmd : %s",
360 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
364 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
365 if (gbl_cryptodev_type == RTE_CRYPTODEV_SCHEDULER_PMD) {
367 #ifndef RTE_LIBRTE_PMD_AESNI_MB
368 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
369 " enabled in config file to run this testsuite.\n");
372 nb_devs = rte_cryptodev_count_devtype(
373 RTE_CRYPTODEV_SCHEDULER_PMD);
376 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
379 TEST_ASSERT(ret == 0,
380 "Failed to create instance %u of"
382 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
385 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
387 #ifndef RTE_LIBRTE_PMD_QAT
388 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
389 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
390 "in config file to run this testsuite.\n");
395 nb_devs = rte_cryptodev_count();
397 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
401 /* Create list of valid crypto devs */
402 for (i = 0; i < nb_devs; i++) {
403 rte_cryptodev_info_get(i, &info);
404 if (info.dev_type == gbl_cryptodev_type)
405 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
408 if (ts_params->valid_dev_count < 1)
411 /* Set up all the qps on the first of the valid devices found */
413 dev_id = ts_params->valid_devs[0];
415 rte_cryptodev_info_get(dev_id, &info);
417 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
418 ts_params->conf.socket_id = SOCKET_ID_ANY;
419 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
421 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
423 "Failed to configure cryptodev %u with %u qps",
424 dev_id, ts_params->conf.nb_queue_pairs);
426 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
428 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
429 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
430 dev_id, qp_id, &ts_params->qp_conf,
431 rte_cryptodev_socket_id(dev_id)),
432 "Failed to setup queue pair %u on cryptodev %u",
440 testsuite_teardown(void)
442 struct crypto_testsuite_params *ts_params = &testsuite_params;
444 if (ts_params->mbuf_pool != NULL) {
445 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
446 rte_mempool_avail_count(ts_params->mbuf_pool));
449 if (ts_params->op_mpool != NULL) {
450 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
451 rte_mempool_avail_count(ts_params->op_mpool));
459 struct crypto_testsuite_params *ts_params = &testsuite_params;
460 struct crypto_unittest_params *ut_params = &unittest_params;
464 /* Clear unit test parameters before running test */
465 memset(ut_params, 0, sizeof(*ut_params));
467 /* Reconfigure device to default parameters */
468 ts_params->conf.socket_id = SOCKET_ID_ANY;
469 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
471 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
473 "Failed to configure cryptodev %u",
474 ts_params->valid_devs[0]);
476 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
477 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
478 ts_params->valid_devs[0], qp_id,
480 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
481 "Failed to setup queue pair %u on cryptodev %u",
482 qp_id, ts_params->valid_devs[0]);
486 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
488 /* Start the device */
489 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
490 "Failed to start cryptodev %u",
491 ts_params->valid_devs[0]);
499 struct crypto_testsuite_params *ts_params = &testsuite_params;
500 struct crypto_unittest_params *ut_params = &unittest_params;
501 struct rte_cryptodev_stats stats;
503 /* free crypto session structure */
504 if (ut_params->sess) {
505 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
507 ut_params->sess = NULL;
510 /* free crypto operation structure */
512 rte_crypto_op_free(ut_params->op);
515 * free mbuf - both obuf and ibuf are usually the same,
516 * so check if they point at the same address is necessary,
517 * to avoid freeing the mbuf twice.
519 if (ut_params->obuf) {
520 rte_pktmbuf_free(ut_params->obuf);
521 if (ut_params->ibuf == ut_params->obuf)
525 if (ut_params->ibuf) {
526 rte_pktmbuf_free(ut_params->ibuf);
530 if (ts_params->mbuf_pool != NULL)
531 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
532 rte_mempool_avail_count(ts_params->mbuf_pool));
534 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
536 /* Stop the device */
537 rte_cryptodev_stop(ts_params->valid_devs[0]);
541 test_device_configure_invalid_dev_id(void)
543 struct crypto_testsuite_params *ts_params = &testsuite_params;
544 uint16_t dev_id, num_devs = 0;
546 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
547 "Need at least %d devices for test", 1);
549 /* valid dev_id values */
550 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
552 /* Stop the device in case it's started so it can be configured */
553 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
555 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
556 "Failed test for rte_cryptodev_configure: "
557 "invalid dev_num %u", dev_id);
559 /* invalid dev_id values */
562 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
563 "Failed test for rte_cryptodev_configure: "
564 "invalid dev_num %u", dev_id);
568 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
569 "Failed test for rte_cryptodev_configure:"
570 "invalid dev_num %u", dev_id);
576 test_device_configure_invalid_queue_pair_ids(void)
578 struct crypto_testsuite_params *ts_params = &testsuite_params;
579 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
581 /* Stop the device in case it's started so it can be configured */
582 rte_cryptodev_stop(ts_params->valid_devs[0]);
584 /* valid - one queue pairs */
585 ts_params->conf.nb_queue_pairs = 1;
587 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
589 "Failed to configure cryptodev: dev_id %u, qp_id %u",
590 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
593 /* valid - max value queue pairs */
594 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
596 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
598 "Failed to configure cryptodev: dev_id %u, qp_id %u",
599 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
602 /* invalid - zero queue pairs */
603 ts_params->conf.nb_queue_pairs = 0;
605 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
607 "Failed test for rte_cryptodev_configure, dev_id %u,"
609 ts_params->valid_devs[0],
610 ts_params->conf.nb_queue_pairs);
613 /* invalid - max value supported by field queue pairs */
614 ts_params->conf.nb_queue_pairs = UINT16_MAX;
616 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
618 "Failed test for rte_cryptodev_configure, dev_id %u,"
620 ts_params->valid_devs[0],
621 ts_params->conf.nb_queue_pairs);
624 /* invalid - max value + 1 queue pairs */
625 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
627 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
629 "Failed test for rte_cryptodev_configure, dev_id %u,"
631 ts_params->valid_devs[0],
632 ts_params->conf.nb_queue_pairs);
634 /* revert to original testsuite value */
635 ts_params->conf.nb_queue_pairs = orig_nb_qps;
641 test_queue_pair_descriptor_setup(void)
643 struct crypto_testsuite_params *ts_params = &testsuite_params;
644 struct rte_cryptodev_info dev_info;
645 struct rte_cryptodev_qp_conf qp_conf = {
646 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
651 /* Stop the device in case it's started so it can be configured */
652 rte_cryptodev_stop(ts_params->valid_devs[0]);
655 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
657 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
660 &ts_params->conf), "Failed to configure cryptodev %u",
661 ts_params->valid_devs[0]);
665 * Test various ring sizes on this device. memzones can't be
666 * freed so are re-used if ring is released and re-created.
668 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
670 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
671 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
672 ts_params->valid_devs[0], qp_id, &qp_conf,
673 rte_cryptodev_socket_id(
674 ts_params->valid_devs[0])),
676 "rte_cryptodev_queue_pair_setup: num_inflights "
677 "%u on qp %u on cryptodev %u",
678 qp_conf.nb_descriptors, qp_id,
679 ts_params->valid_devs[0]);
682 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
684 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
685 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
686 ts_params->valid_devs[0], qp_id, &qp_conf,
687 rte_cryptodev_socket_id(
688 ts_params->valid_devs[0])),
690 " rte_cryptodev_queue_pair_setup: num_inflights"
691 " %u on qp %u on cryptodev %u",
692 qp_conf.nb_descriptors, qp_id,
693 ts_params->valid_devs[0]);
696 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
698 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
699 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
700 ts_params->valid_devs[0], qp_id, &qp_conf,
701 rte_cryptodev_socket_id(
702 ts_params->valid_devs[0])),
704 "rte_cryptodev_queue_pair_setup: num_inflights"
705 " %u on qp %u on cryptodev %u",
706 qp_conf.nb_descriptors, qp_id,
707 ts_params->valid_devs[0]);
710 /* invalid number of descriptors - max supported + 2 */
711 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
713 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
714 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
715 ts_params->valid_devs[0], qp_id, &qp_conf,
716 rte_cryptodev_socket_id(
717 ts_params->valid_devs[0])),
718 "Unexpectedly passed test for "
719 "rte_cryptodev_queue_pair_setup:"
720 "num_inflights %u on qp %u on cryptodev %u",
721 qp_conf.nb_descriptors, qp_id,
722 ts_params->valid_devs[0]);
725 /* invalid number of descriptors - max value of parameter */
726 qp_conf.nb_descriptors = UINT32_MAX-1;
728 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
729 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
730 ts_params->valid_devs[0], qp_id, &qp_conf,
731 rte_cryptodev_socket_id(
732 ts_params->valid_devs[0])),
733 "Unexpectedly passed test for "
734 "rte_cryptodev_queue_pair_setup:"
735 "num_inflights %u on qp %u on cryptodev %u",
736 qp_conf.nb_descriptors, qp_id,
737 ts_params->valid_devs[0]);
740 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
742 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
743 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
744 ts_params->valid_devs[0], qp_id, &qp_conf,
745 rte_cryptodev_socket_id(
746 ts_params->valid_devs[0])),
748 " rte_cryptodev_queue_pair_setup:"
749 "num_inflights %u on qp %u on cryptodev %u",
750 qp_conf.nb_descriptors, qp_id,
751 ts_params->valid_devs[0]);
754 /* invalid number of descriptors - max supported + 1 */
755 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
757 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
758 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
759 ts_params->valid_devs[0], qp_id, &qp_conf,
760 rte_cryptodev_socket_id(
761 ts_params->valid_devs[0])),
762 "Unexpectedly passed test for "
763 "rte_cryptodev_queue_pair_setup:"
764 "num_inflights %u on qp %u on cryptodev %u",
765 qp_conf.nb_descriptors, qp_id,
766 ts_params->valid_devs[0]);
769 /* test invalid queue pair id */
770 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
772 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
774 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
775 ts_params->valid_devs[0],
777 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
778 "Failed test for rte_cryptodev_queue_pair_setup:"
779 "invalid qp %u on cryptodev %u",
780 qp_id, ts_params->valid_devs[0]);
782 qp_id = 0xffff; /*invalid*/
784 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
785 ts_params->valid_devs[0],
787 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
788 "Failed test for rte_cryptodev_queue_pair_setup:"
789 "invalid qp %u on cryptodev %u",
790 qp_id, ts_params->valid_devs[0]);
795 /* ***** Plaintext data for tests ***** */
797 const char catch_22_quote_1[] =
798 "There was only one catch and that was Catch-22, which "
799 "specified that a concern for one's safety in the face of "
800 "dangers that were real and immediate was the process of a "
801 "rational mind. Orr was crazy and could be grounded. All he "
802 "had to do was ask; and as soon as he did, he would no longer "
803 "be crazy and would have to fly more missions. Orr would be "
804 "crazy to fly more missions and sane if he didn't, but if he "
805 "was sane he had to fly them. If he flew them he was crazy "
806 "and didn't have to; but if he didn't want to he was sane and "
807 "had to. Yossarian was moved very deeply by the absolute "
808 "simplicity of this clause of Catch-22 and let out a "
809 "respectful whistle. \"That's some catch, that Catch-22\", he "
810 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
812 const char catch_22_quote[] =
813 "What a lousy earth! He wondered how many people were "
814 "destitute that same night even in his own prosperous country, "
815 "how many homes were shanties, how many husbands were drunk "
816 "and wives socked, and how many children were bullied, abused, "
817 "or abandoned. How many families hungered for food they could "
818 "not afford to buy? How many hearts were broken? How many "
819 "suicides would take place that same night, how many people "
820 "would go insane? How many cockroaches and landlords would "
821 "triumph? How many winners were losers, successes failures, "
822 "and rich men poor men? How many wise guys were stupid? How "
823 "many happy endings were unhappy endings? How many honest men "
824 "were liars, brave men cowards, loyal men traitors, how many "
825 "sainted men were corrupt, how many people in positions of "
826 "trust had sold their souls to bodyguards, how many had never "
827 "had souls? How many straight-and-narrow paths were crooked "
828 "paths? How many best families were worst families and how "
829 "many good people were bad people? When you added them all up "
830 "and then subtracted, you might be left with only the children, "
831 "and perhaps with Albert Einstein and an old violinist or "
832 "sculptor somewhere.";
834 #define QUOTE_480_BYTES (480)
835 #define QUOTE_512_BYTES (512)
836 #define QUOTE_768_BYTES (768)
837 #define QUOTE_1024_BYTES (1024)
841 /* ***** SHA1 Hash Tests ***** */
843 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
845 static uint8_t hmac_sha1_key[] = {
846 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
847 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
848 0xDE, 0xF4, 0xDE, 0xAD };
850 /* ***** SHA224 Hash Tests ***** */
852 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
855 /* ***** AES-CBC Cipher Tests ***** */
857 #define CIPHER_KEY_LENGTH_AES_CBC (16)
858 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
860 static uint8_t aes_cbc_key[] = {
861 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
862 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
864 static uint8_t aes_cbc_iv[] = {
865 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
866 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
869 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
871 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
872 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
873 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
874 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
875 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
876 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
877 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
878 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
879 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
880 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
881 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
882 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
883 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
884 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
885 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
886 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
887 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
888 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
889 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
890 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
891 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
892 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
893 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
894 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
895 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
896 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
897 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
898 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
899 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
900 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
901 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
902 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
903 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
904 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
905 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
906 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
907 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
908 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
909 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
910 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
911 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
912 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
913 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
914 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
915 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
916 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
917 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
918 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
919 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
920 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
921 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
922 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
923 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
924 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
925 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
926 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
927 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
928 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
929 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
930 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
931 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
932 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
933 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
934 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
935 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
938 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
939 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
940 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
941 0x18, 0x8c, 0x1d, 0x32
945 /* Multisession Vector context Test */
947 static uint8_t ms_aes_cbc_key0[] = {
948 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
952 static uint8_t ms_aes_cbc_iv0[] = {
953 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
954 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
957 static const uint8_t ms_aes_cbc_cipher0[] = {
958 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
959 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
960 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
961 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
962 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
963 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
964 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
965 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
966 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
967 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
968 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
969 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
970 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
971 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
972 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
973 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
974 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
975 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
976 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
977 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
978 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
979 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
980 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
981 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
982 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
983 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
984 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
985 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
986 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
987 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
988 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
989 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
990 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
991 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
992 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
993 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
994 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
995 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
996 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
997 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
998 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
999 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1000 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1001 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1002 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1003 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1004 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1005 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1006 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1007 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1008 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1009 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1010 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1011 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1012 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1013 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1014 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1015 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1016 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1017 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1018 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1019 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1020 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1021 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1025 static uint8_t ms_hmac_key0[] = {
1026 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1027 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1028 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1029 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1030 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1031 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1032 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1033 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1036 static const uint8_t ms_hmac_digest0[] = {
1037 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1038 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1039 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1040 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1041 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1042 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1043 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1044 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1048 /* Begin session 1 */
1050 static uint8_t ms_aes_cbc_key1[] = {
1051 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1052 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1055 static uint8_t ms_aes_cbc_iv1[] = {
1056 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1057 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1060 static const uint8_t ms_aes_cbc_cipher1[] = {
1061 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1062 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1063 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1064 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1065 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1066 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1067 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1068 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1069 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1070 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1071 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1072 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1073 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1074 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1075 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1076 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1077 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1078 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1079 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1080 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1081 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1082 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1083 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1084 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1085 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1086 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1087 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1088 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1089 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1090 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1091 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1092 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1093 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1094 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1095 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1096 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1097 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1098 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1099 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1100 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1101 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1102 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1103 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1104 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1105 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1106 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1107 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1108 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1109 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1110 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1111 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1112 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1113 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1114 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1115 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1116 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1117 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1118 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1119 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1120 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1121 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1122 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1123 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1124 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1128 static uint8_t ms_hmac_key1[] = {
1129 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1130 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1131 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1132 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1133 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1134 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1135 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1136 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1139 static const uint8_t ms_hmac_digest1[] = {
1140 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1141 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1142 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1143 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1144 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1145 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1146 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1147 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1150 /* Begin Session 2 */
1151 static uint8_t ms_aes_cbc_key2[] = {
1152 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1153 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1156 static uint8_t ms_aes_cbc_iv2[] = {
1157 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1158 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1161 static const uint8_t ms_aes_cbc_cipher2[] = {
1162 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1163 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1164 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1165 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1166 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1167 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1168 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1169 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1170 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1171 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1172 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1173 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1174 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1175 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1176 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1177 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1178 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1179 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1180 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1181 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1182 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1183 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1184 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1185 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1186 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1187 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1188 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1189 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1190 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1191 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1192 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1193 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1194 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1195 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1196 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1197 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1198 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1199 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1200 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1201 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1202 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1203 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1204 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1205 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1206 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1207 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1208 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1209 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1210 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1211 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1212 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1213 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1214 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1215 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1216 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1217 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1218 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1219 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1220 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1221 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1222 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1223 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1224 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1225 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1228 static uint8_t ms_hmac_key2[] = {
1229 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1230 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1231 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1232 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1233 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1234 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1235 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1236 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1239 static const uint8_t ms_hmac_digest2[] = {
1240 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1241 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1242 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1243 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1244 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1245 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1246 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1247 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1254 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1256 struct crypto_testsuite_params *ts_params = &testsuite_params;
1257 struct crypto_unittest_params *ut_params = &unittest_params;
1259 /* Generate test mbuf data and space for digest */
1260 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1261 catch_22_quote, QUOTE_512_BYTES, 0);
1263 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1264 DIGEST_BYTE_LENGTH_SHA1);
1265 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1267 /* Setup Cipher Parameters */
1268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1269 ut_params->cipher_xform.next = &ut_params->auth_xform;
1271 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1272 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1273 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1274 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1275 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1276 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1278 /* Setup HMAC Parameters */
1279 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1281 ut_params->auth_xform.next = NULL;
1283 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1284 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1285 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1286 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1287 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1289 /* Create crypto session*/
1290 ut_params->sess = rte_cryptodev_sym_session_create(
1291 ts_params->valid_devs[0],
1292 &ut_params->cipher_xform);
1293 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1295 /* Generate crypto op data structure */
1296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1298 TEST_ASSERT_NOT_NULL(ut_params->op,
1299 "Failed to allocate symmetric crypto operation struct");
1301 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1303 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1305 /* set crypto operation source mbuf */
1306 sym_op->m_src = ut_params->ibuf;
1308 /* Set crypto operation authentication parameters */
1309 sym_op->auth.digest.data = ut_params->digest;
1310 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1311 ut_params->ibuf, QUOTE_512_BYTES);
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1345 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1346 DIGEST_BYTE_LENGTH_SHA1,
1347 "Generated digest data not as expected");
1349 return TEST_SUCCESS;
1352 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1354 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1356 static uint8_t hmac_sha512_key[] = {
1357 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1358 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1359 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1360 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1361 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1362 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1363 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1364 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1366 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1367 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1368 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1369 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1370 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1371 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1372 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1373 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1374 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1379 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1380 struct crypto_unittest_params *ut_params,
1381 uint8_t *cipher_key,
1385 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1386 struct crypto_unittest_params *ut_params,
1387 struct crypto_testsuite_params *ts_params,
1388 const uint8_t *cipher,
1389 const uint8_t *digest,
1394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1395 struct crypto_unittest_params *ut_params,
1396 uint8_t *cipher_key,
1400 /* Setup Cipher Parameters */
1401 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1402 ut_params->cipher_xform.next = NULL;
1404 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1405 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1406 ut_params->cipher_xform.cipher.key.data = cipher_key;
1407 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1408 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1409 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1411 /* Setup HMAC Parameters */
1412 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1413 ut_params->auth_xform.next = &ut_params->cipher_xform;
1415 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1416 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1417 ut_params->auth_xform.auth.key.data = hmac_key;
1418 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1419 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1421 return TEST_SUCCESS;
1426 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1427 struct crypto_unittest_params *ut_params,
1428 struct crypto_testsuite_params *ts_params,
1429 const uint8_t *cipher,
1430 const uint8_t *digest,
1433 /* Generate test mbuf data and digest */
1434 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA512);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 rte_memcpy(ut_params->digest,
1445 DIGEST_BYTE_LENGTH_SHA512);
1447 /* Generate Crypto op data structure */
1448 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1449 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1450 TEST_ASSERT_NOT_NULL(ut_params->op,
1451 "Failed to allocate symmetric crypto operation struct");
1453 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1455 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1457 /* set crypto operation source mbuf */
1458 sym_op->m_src = ut_params->ibuf;
1460 sym_op->auth.digest.data = ut_params->digest;
1461 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1462 ut_params->ibuf, QUOTE_512_BYTES);
1464 sym_op->auth.data.offset = 0;
1465 sym_op->auth.data.length = QUOTE_512_BYTES;
1467 /* Copy IV at the end of the crypto operation */
1468 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1469 iv, CIPHER_IV_LENGTH_AES_CBC);
1471 sym_op->cipher.data.offset = 0;
1472 sym_op->cipher.data.length = QUOTE_512_BYTES;
1474 /* Process crypto operation */
1475 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1476 ut_params->op), "failed to process sym crypto op");
1478 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1479 "crypto op processing failed");
1481 ut_params->obuf = ut_params->op->sym->m_src;
1484 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1485 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1488 "Plaintext data not as expected");
1491 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1492 "Digest verification failed");
1494 return TEST_SUCCESS;
1498 test_AES_cipheronly_mb_all(void)
1500 struct crypto_testsuite_params *ts_params = &testsuite_params;
1503 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1504 ts_params->op_mpool, ts_params->valid_devs[0],
1505 RTE_CRYPTODEV_AESNI_MB_PMD,
1506 BLKCIPHER_AES_CIPHERONLY_TYPE);
1508 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1510 return TEST_SUCCESS;
1514 test_AES_docsis_mb_all(void)
1516 struct crypto_testsuite_params *ts_params = &testsuite_params;
1519 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1520 ts_params->op_mpool, ts_params->valid_devs[0],
1521 RTE_CRYPTODEV_AESNI_MB_PMD,
1522 BLKCIPHER_AES_DOCSIS_TYPE);
1524 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1526 return TEST_SUCCESS;
1530 test_AES_docsis_qat_all(void)
1532 struct crypto_testsuite_params *ts_params = &testsuite_params;
1535 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1536 ts_params->op_mpool, ts_params->valid_devs[0],
1537 RTE_CRYPTODEV_QAT_SYM_PMD,
1538 BLKCIPHER_AES_DOCSIS_TYPE);
1540 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1542 return TEST_SUCCESS;
1546 test_DES_docsis_qat_all(void)
1548 struct crypto_testsuite_params *ts_params = &testsuite_params;
1551 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1552 ts_params->op_mpool, ts_params->valid_devs[0],
1553 RTE_CRYPTODEV_QAT_SYM_PMD,
1554 BLKCIPHER_DES_DOCSIS_TYPE);
1556 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1558 return TEST_SUCCESS;
1562 test_authonly_mb_all(void)
1564 struct crypto_testsuite_params *ts_params = &testsuite_params;
1567 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1568 ts_params->op_mpool, ts_params->valid_devs[0],
1569 RTE_CRYPTODEV_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_AESNI_MB_PMD,
1586 BLKCIPHER_AES_CHAIN_TYPE);
1588 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1590 return TEST_SUCCESS;
1593 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1596 test_AES_cipheronly_scheduler_all(void)
1598 struct crypto_testsuite_params *ts_params = &testsuite_params;
1601 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1602 ts_params->op_mpool, ts_params->valid_devs[0],
1603 RTE_CRYPTODEV_SCHEDULER_PMD,
1604 BLKCIPHER_AES_CIPHERONLY_TYPE);
1606 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1608 return TEST_SUCCESS;
1612 test_AES_chain_scheduler_all(void)
1614 struct crypto_testsuite_params *ts_params = &testsuite_params;
1617 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1618 ts_params->op_mpool, ts_params->valid_devs[0],
1619 RTE_CRYPTODEV_SCHEDULER_PMD,
1620 BLKCIPHER_AES_CHAIN_TYPE);
1622 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1624 return TEST_SUCCESS;
1628 test_authonly_scheduler_all(void)
1630 struct crypto_testsuite_params *ts_params = &testsuite_params;
1633 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1634 ts_params->op_mpool, ts_params->valid_devs[0],
1635 RTE_CRYPTODEV_SCHEDULER_PMD,
1636 BLKCIPHER_AUTHONLY_TYPE);
1638 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1640 return TEST_SUCCESS;
1643 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1646 test_AES_chain_openssl_all(void)
1648 struct crypto_testsuite_params *ts_params = &testsuite_params;
1651 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1652 ts_params->op_mpool, ts_params->valid_devs[0],
1653 RTE_CRYPTODEV_OPENSSL_PMD,
1654 BLKCIPHER_AES_CHAIN_TYPE);
1656 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1658 return TEST_SUCCESS;
1662 test_AES_cipheronly_openssl_all(void)
1664 struct crypto_testsuite_params *ts_params = &testsuite_params;
1667 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1668 ts_params->op_mpool, ts_params->valid_devs[0],
1669 RTE_CRYPTODEV_OPENSSL_PMD,
1670 BLKCIPHER_AES_CIPHERONLY_TYPE);
1672 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1674 return TEST_SUCCESS;
1678 test_AES_chain_qat_all(void)
1680 struct crypto_testsuite_params *ts_params = &testsuite_params;
1683 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1684 ts_params->op_mpool, ts_params->valid_devs[0],
1685 RTE_CRYPTODEV_QAT_SYM_PMD,
1686 BLKCIPHER_AES_CHAIN_TYPE);
1688 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1690 return TEST_SUCCESS;
1694 test_AES_cipheronly_qat_all(void)
1696 struct crypto_testsuite_params *ts_params = &testsuite_params;
1699 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 ts_params->op_mpool, ts_params->valid_devs[0],
1701 RTE_CRYPTODEV_QAT_SYM_PMD,
1702 BLKCIPHER_AES_CIPHERONLY_TYPE);
1704 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1706 return TEST_SUCCESS;
1710 test_AES_chain_dpaa2_sec_all(void)
1712 struct crypto_testsuite_params *ts_params = &testsuite_params;
1715 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1716 ts_params->op_mpool, ts_params->valid_devs[0],
1717 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1718 BLKCIPHER_AES_CHAIN_TYPE);
1720 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1722 return TEST_SUCCESS;
1726 test_AES_cipheronly_dpaa2_sec_all(void)
1728 struct crypto_testsuite_params *ts_params = &testsuite_params;
1731 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1732 ts_params->op_mpool, ts_params->valid_devs[0],
1733 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1734 BLKCIPHER_AES_CIPHERONLY_TYPE);
1736 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1738 return TEST_SUCCESS;
1742 test_authonly_dpaa2_sec_all(void)
1744 struct crypto_testsuite_params *ts_params = &testsuite_params;
1747 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1748 ts_params->op_mpool, ts_params->valid_devs[0],
1749 RTE_CRYPTODEV_DPAA2_SEC_PMD,
1750 BLKCIPHER_AUTHONLY_TYPE);
1752 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1754 return TEST_SUCCESS;
1758 test_authonly_openssl_all(void)
1760 struct crypto_testsuite_params *ts_params = &testsuite_params;
1763 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764 ts_params->op_mpool, ts_params->valid_devs[0],
1765 RTE_CRYPTODEV_OPENSSL_PMD,
1766 BLKCIPHER_AUTHONLY_TYPE);
1768 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1770 return TEST_SUCCESS;
1774 test_AES_chain_armv8_all(void)
1776 struct crypto_testsuite_params *ts_params = &testsuite_params;
1779 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1780 ts_params->op_mpool, ts_params->valid_devs[0],
1781 RTE_CRYPTODEV_ARMV8_PMD,
1782 BLKCIPHER_AES_CHAIN_TYPE);
1784 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1786 return TEST_SUCCESS;
1789 /* ***** SNOW 3G Tests ***** */
1791 create_wireless_algo_hash_session(uint8_t dev_id,
1792 const uint8_t *key, const uint8_t key_len,
1793 const uint8_t iv_len, const uint8_t auth_len,
1794 enum rte_crypto_auth_operation op,
1795 enum rte_crypto_auth_algorithm algo)
1797 uint8_t hash_key[key_len];
1799 struct crypto_unittest_params *ut_params = &unittest_params;
1801 memcpy(hash_key, key, key_len);
1803 TEST_HEXDUMP(stdout, "key:", key, key_len);
1805 /* Setup Authentication Parameters */
1806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1807 ut_params->auth_xform.next = NULL;
1809 ut_params->auth_xform.auth.op = op;
1810 ut_params->auth_xform.auth.algo = algo;
1811 ut_params->auth_xform.auth.key.length = key_len;
1812 ut_params->auth_xform.auth.key.data = hash_key;
1813 ut_params->auth_xform.auth.digest_length = auth_len;
1814 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1815 ut_params->auth_xform.auth.iv.length = iv_len;
1816 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1817 &ut_params->auth_xform);
1818 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1823 create_wireless_algo_cipher_session(uint8_t dev_id,
1824 enum rte_crypto_cipher_operation op,
1825 enum rte_crypto_cipher_algorithm algo,
1826 const uint8_t *key, const uint8_t key_len,
1829 uint8_t cipher_key[key_len];
1831 struct crypto_unittest_params *ut_params = &unittest_params;
1833 memcpy(cipher_key, key, key_len);
1835 /* Setup Cipher Parameters */
1836 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1837 ut_params->cipher_xform.next = NULL;
1839 ut_params->cipher_xform.cipher.algo = algo;
1840 ut_params->cipher_xform.cipher.op = op;
1841 ut_params->cipher_xform.cipher.key.data = cipher_key;
1842 ut_params->cipher_xform.cipher.key.length = key_len;
1843 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1844 ut_params->cipher_xform.cipher.iv.length = iv_len;
1846 TEST_HEXDUMP(stdout, "key:", key, key_len);
1848 /* Create Crypto session */
1849 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1852 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1857 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1858 unsigned int cipher_len,
1859 unsigned int cipher_offset)
1861 struct crypto_testsuite_params *ts_params = &testsuite_params;
1862 struct crypto_unittest_params *ut_params = &unittest_params;
1864 /* Generate Crypto op data structure */
1865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1867 TEST_ASSERT_NOT_NULL(ut_params->op,
1868 "Failed to allocate pktmbuf offload");
1870 /* Set crypto operation data parameters */
1871 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1873 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1875 /* set crypto operation source mbuf */
1876 sym_op->m_src = ut_params->ibuf;
1879 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1881 sym_op->cipher.data.length = cipher_len;
1882 sym_op->cipher.data.offset = cipher_offset;
1887 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1888 unsigned int cipher_len,
1889 unsigned int cipher_offset)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1892 struct crypto_unittest_params *ut_params = &unittest_params;
1894 /* Generate Crypto op data structure */
1895 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1896 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1897 TEST_ASSERT_NOT_NULL(ut_params->op,
1898 "Failed to allocate pktmbuf offload");
1900 /* Set crypto operation data parameters */
1901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1903 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1905 /* set crypto operation source mbuf */
1906 sym_op->m_src = ut_params->ibuf;
1907 sym_op->m_dst = ut_params->obuf;
1910 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1912 sym_op->cipher.data.length = cipher_len;
1913 sym_op->cipher.data.offset = cipher_offset;
1918 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1919 enum rte_crypto_cipher_operation cipher_op,
1920 enum rte_crypto_auth_operation auth_op,
1921 enum rte_crypto_auth_algorithm auth_algo,
1922 enum rte_crypto_cipher_algorithm cipher_algo,
1923 const uint8_t *key, uint8_t key_len,
1924 uint8_t auth_iv_len, uint8_t auth_len,
1925 uint8_t cipher_iv_len)
1928 uint8_t cipher_auth_key[key_len];
1930 struct crypto_unittest_params *ut_params = &unittest_params;
1932 memcpy(cipher_auth_key, key, key_len);
1934 /* Setup Authentication Parameters */
1935 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1936 ut_params->auth_xform.next = NULL;
1938 ut_params->auth_xform.auth.op = auth_op;
1939 ut_params->auth_xform.auth.algo = auth_algo;
1940 ut_params->auth_xform.auth.key.length = key_len;
1941 /* Hash key = cipher key */
1942 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1943 ut_params->auth_xform.auth.digest_length = auth_len;
1944 /* Auth IV will be after cipher IV */
1945 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1946 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1948 /* Setup Cipher Parameters */
1949 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1950 ut_params->cipher_xform.next = &ut_params->auth_xform;
1952 ut_params->cipher_xform.cipher.algo = cipher_algo;
1953 ut_params->cipher_xform.cipher.op = cipher_op;
1954 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1955 ut_params->cipher_xform.cipher.key.length = key_len;
1956 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1957 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1959 TEST_HEXDUMP(stdout, "key:", key, key_len);
1961 /* Create Crypto session*/
1962 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1963 &ut_params->cipher_xform);
1965 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1970 create_wireless_cipher_auth_session(uint8_t dev_id,
1971 enum rte_crypto_cipher_operation cipher_op,
1972 enum rte_crypto_auth_operation auth_op,
1973 enum rte_crypto_auth_algorithm auth_algo,
1974 enum rte_crypto_cipher_algorithm cipher_algo,
1975 const struct wireless_test_data *tdata)
1977 const uint8_t key_len = tdata->key.len;
1978 uint8_t cipher_auth_key[key_len];
1980 struct crypto_unittest_params *ut_params = &unittest_params;
1981 const uint8_t *key = tdata->key.data;
1982 const uint8_t auth_len = tdata->digest.len;
1983 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1984 uint8_t auth_iv_len = tdata->auth_iv.len;
1986 memcpy(cipher_auth_key, key, key_len);
1988 /* Setup Authentication Parameters */
1989 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1990 ut_params->auth_xform.next = NULL;
1992 ut_params->auth_xform.auth.op = auth_op;
1993 ut_params->auth_xform.auth.algo = auth_algo;
1994 ut_params->auth_xform.auth.key.length = key_len;
1995 /* Hash key = cipher key */
1996 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1997 ut_params->auth_xform.auth.digest_length = auth_len;
1998 /* Auth IV will be after cipher IV */
1999 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2000 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2002 /* Setup Cipher Parameters */
2003 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2004 ut_params->cipher_xform.next = &ut_params->auth_xform;
2006 ut_params->cipher_xform.cipher.algo = cipher_algo;
2007 ut_params->cipher_xform.cipher.op = cipher_op;
2008 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2009 ut_params->cipher_xform.cipher.key.length = key_len;
2010 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2011 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2014 TEST_HEXDUMP(stdout, "key:", key, key_len);
2016 /* Create Crypto session*/
2017 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2018 &ut_params->cipher_xform);
2020 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2025 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2026 const struct wireless_test_data *tdata)
2028 return create_wireless_cipher_auth_session(dev_id,
2029 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2030 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2031 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2035 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2036 enum rte_crypto_cipher_operation cipher_op,
2037 enum rte_crypto_auth_operation auth_op,
2038 enum rte_crypto_auth_algorithm auth_algo,
2039 enum rte_crypto_cipher_algorithm cipher_algo,
2040 const uint8_t *key, const uint8_t key_len,
2041 uint8_t auth_iv_len, uint8_t auth_len,
2042 uint8_t cipher_iv_len)
2044 uint8_t auth_cipher_key[key_len];
2046 struct crypto_unittest_params *ut_params = &unittest_params;
2048 memcpy(auth_cipher_key, key, key_len);
2050 /* Setup Authentication Parameters */
2051 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2052 ut_params->auth_xform.auth.op = auth_op;
2053 ut_params->auth_xform.next = &ut_params->cipher_xform;
2054 ut_params->auth_xform.auth.algo = auth_algo;
2055 ut_params->auth_xform.auth.key.length = key_len;
2056 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2057 ut_params->auth_xform.auth.digest_length = auth_len;
2058 /* Auth IV will be after cipher IV */
2059 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2060 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2062 /* Setup Cipher Parameters */
2063 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2064 ut_params->cipher_xform.next = NULL;
2065 ut_params->cipher_xform.cipher.algo = cipher_algo;
2066 ut_params->cipher_xform.cipher.op = cipher_op;
2067 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2068 ut_params->cipher_xform.cipher.key.length = key_len;
2069 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2070 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2072 TEST_HEXDUMP(stdout, "key:", key, key_len);
2074 /* Create Crypto session*/
2075 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2076 &ut_params->auth_xform);
2078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2084 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2085 unsigned int auth_tag_len,
2086 const uint8_t *iv, unsigned int iv_len,
2087 unsigned int data_pad_len,
2088 enum rte_crypto_auth_operation op,
2089 unsigned int auth_len, unsigned int auth_offset)
2091 struct crypto_testsuite_params *ts_params = &testsuite_params;
2093 struct crypto_unittest_params *ut_params = &unittest_params;
2095 /* Generate Crypto op data structure */
2096 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2097 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2098 TEST_ASSERT_NOT_NULL(ut_params->op,
2099 "Failed to allocate pktmbuf offload");
2101 /* Set crypto operation data parameters */
2102 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2104 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2106 /* set crypto operation source mbuf */
2107 sym_op->m_src = ut_params->ibuf;
2110 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2113 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2114 ut_params->ibuf, auth_tag_len);
2116 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2117 "no room to append auth tag");
2118 ut_params->digest = sym_op->auth.digest.data;
2119 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2120 ut_params->ibuf, data_pad_len);
2121 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2122 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2124 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2126 TEST_HEXDUMP(stdout, "digest:",
2127 sym_op->auth.digest.data,
2130 sym_op->auth.data.length = auth_len;
2131 sym_op->auth.data.offset = auth_offset;
2137 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2138 enum rte_crypto_auth_operation op)
2140 struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 struct crypto_unittest_params *ut_params = &unittest_params;
2143 const uint8_t *auth_tag = tdata->digest.data;
2144 const unsigned int auth_tag_len = tdata->digest.len;
2145 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2146 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2148 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2149 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2150 const uint8_t *auth_iv = tdata->auth_iv.data;
2151 const uint8_t auth_iv_len = tdata->auth_iv.len;
2152 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2153 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2155 /* Generate Crypto op data structure */
2156 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2157 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2158 TEST_ASSERT_NOT_NULL(ut_params->op,
2159 "Failed to allocate pktmbuf offload");
2160 /* Set crypto operation data parameters */
2161 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2163 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2165 /* set crypto operation source mbuf */
2166 sym_op->m_src = ut_params->ibuf;
2169 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2170 ut_params->ibuf, auth_tag_len);
2172 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2173 "no room to append auth tag");
2174 ut_params->digest = sym_op->auth.digest.data;
2175 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2176 ut_params->ibuf, data_pad_len);
2177 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2178 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2180 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2182 TEST_HEXDUMP(stdout, "digest:",
2183 sym_op->auth.digest.data,
2186 /* Copy cipher and auth IVs at the end of the crypto operation */
2187 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2189 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2190 iv_ptr += cipher_iv_len;
2191 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2193 sym_op->cipher.data.length = cipher_len;
2194 sym_op->cipher.data.offset = 0;
2195 sym_op->auth.data.length = auth_len;
2196 sym_op->auth.data.offset = 0;
2202 create_zuc_cipher_hash_generate_operation(
2203 const struct wireless_test_data *tdata)
2205 return create_wireless_cipher_hash_operation(tdata,
2206 RTE_CRYPTO_AUTH_OP_GENERATE);
2210 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2211 const unsigned auth_tag_len,
2212 const uint8_t *auth_iv, uint8_t auth_iv_len,
2213 unsigned data_pad_len,
2214 enum rte_crypto_auth_operation op,
2215 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2216 const unsigned cipher_len, const unsigned cipher_offset,
2217 const unsigned auth_len, const unsigned auth_offset)
2219 struct crypto_testsuite_params *ts_params = &testsuite_params;
2220 struct crypto_unittest_params *ut_params = &unittest_params;
2222 /* Generate Crypto op data structure */
2223 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2224 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2225 TEST_ASSERT_NOT_NULL(ut_params->op,
2226 "Failed to allocate pktmbuf offload");
2227 /* Set crypto operation data parameters */
2228 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2230 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2232 /* set crypto operation source mbuf */
2233 sym_op->m_src = ut_params->ibuf;
2236 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2237 ut_params->ibuf, auth_tag_len);
2239 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2240 "no room to append auth tag");
2241 ut_params->digest = sym_op->auth.digest.data;
2242 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2243 ut_params->ibuf, data_pad_len);
2244 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2245 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2247 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2249 TEST_HEXDUMP(stdout, "digest:",
2250 sym_op->auth.digest.data,
2253 /* Copy cipher and auth IVs at the end of the crypto operation */
2254 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2256 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2257 iv_ptr += cipher_iv_len;
2258 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2260 sym_op->cipher.data.length = cipher_len;
2261 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2262 sym_op->auth.data.length = auth_len;
2263 sym_op->auth.data.offset = auth_offset + cipher_offset;
2269 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2270 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2271 const uint8_t *auth_iv, uint8_t auth_iv_len,
2272 unsigned int data_pad_len,
2273 unsigned int cipher_len, unsigned int cipher_offset,
2274 unsigned int auth_len, unsigned int auth_offset)
2276 struct crypto_testsuite_params *ts_params = &testsuite_params;
2277 struct crypto_unittest_params *ut_params = &unittest_params;
2279 /* Generate Crypto op data structure */
2280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2282 TEST_ASSERT_NOT_NULL(ut_params->op,
2283 "Failed to allocate pktmbuf offload");
2285 /* Set crypto operation data parameters */
2286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2290 /* set crypto operation source mbuf */
2291 sym_op->m_src = ut_params->ibuf;
2294 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2295 ut_params->ibuf, auth_tag_len);
2297 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2298 "no room to append auth tag");
2300 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2301 ut_params->ibuf, data_pad_len);
2303 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2305 TEST_HEXDUMP(stdout, "digest:",
2306 sym_op->auth.digest.data,
2309 /* Copy cipher and auth IVs at the end of the crypto operation */
2310 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2312 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2313 iv_ptr += cipher_iv_len;
2314 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2316 sym_op->cipher.data.length = cipher_len;
2317 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2319 sym_op->auth.data.length = auth_len;
2320 sym_op->auth.data.offset = auth_offset + cipher_offset;
2326 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2328 struct crypto_testsuite_params *ts_params = &testsuite_params;
2329 struct crypto_unittest_params *ut_params = &unittest_params;
2332 unsigned plaintext_pad_len;
2333 unsigned plaintext_len;
2336 /* Create SNOW 3G session */
2337 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2338 tdata->key.data, tdata->key.len,
2339 tdata->auth_iv.len, tdata->digest.len,
2340 RTE_CRYPTO_AUTH_OP_GENERATE,
2341 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2345 /* alloc mbuf and set payload */
2346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2348 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2349 rte_pktmbuf_tailroom(ut_params->ibuf));
2351 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2352 /* Append data which is padded to a multiple of */
2353 /* the algorithms block size */
2354 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2355 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2357 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2359 /* Create SNOW 3G operation */
2360 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2361 tdata->auth_iv.data, tdata->auth_iv.len,
2362 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2363 tdata->validAuthLenInBits.len,
2368 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2370 ut_params->obuf = ut_params->op->sym->m_src;
2371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2372 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2373 + plaintext_pad_len;
2376 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2379 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2380 "SNOW 3G Generated auth tag not as expected");
2386 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2388 struct crypto_testsuite_params *ts_params = &testsuite_params;
2389 struct crypto_unittest_params *ut_params = &unittest_params;
2392 unsigned plaintext_pad_len;
2393 unsigned plaintext_len;
2396 /* Create SNOW 3G session */
2397 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2398 tdata->key.data, tdata->key.len,
2399 tdata->auth_iv.len, tdata->digest.len,
2400 RTE_CRYPTO_AUTH_OP_VERIFY,
2401 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2404 /* alloc mbuf and set payload */
2405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2408 rte_pktmbuf_tailroom(ut_params->ibuf));
2410 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2411 /* Append data which is padded to a multiple of */
2412 /* the algorithms block size */
2413 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2418 /* Create SNOW 3G operation */
2419 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2421 tdata->auth_iv.data, tdata->auth_iv.len,
2423 RTE_CRYPTO_AUTH_OP_VERIFY,
2424 tdata->validAuthLenInBits.len,
2429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2432 ut_params->obuf = ut_params->op->sym->m_src;
2433 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2434 + plaintext_pad_len;
2437 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2446 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2448 struct crypto_testsuite_params *ts_params = &testsuite_params;
2449 struct crypto_unittest_params *ut_params = &unittest_params;
2452 unsigned plaintext_pad_len;
2453 unsigned plaintext_len;
2456 /* Create KASUMI session */
2457 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2458 tdata->key.data, tdata->key.len,
2459 tdata->auth_iv.len, tdata->digest.len,
2460 RTE_CRYPTO_AUTH_OP_GENERATE,
2461 RTE_CRYPTO_AUTH_KASUMI_F9);
2465 /* alloc mbuf and set payload */
2466 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2469 rte_pktmbuf_tailroom(ut_params->ibuf));
2471 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2472 /* Append data which is padded to a multiple of */
2473 /* the algorithms block size */
2474 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2475 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2477 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2479 /* Create KASUMI operation */
2480 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2481 tdata->auth_iv.data, tdata->auth_iv.len,
2482 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2483 tdata->validAuthLenInBits.len,
2488 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2490 ut_params->obuf = ut_params->op->sym->m_src;
2491 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2492 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2493 + plaintext_pad_len;
2496 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2499 DIGEST_BYTE_LENGTH_KASUMI_F9,
2500 "KASUMI Generated auth tag not as expected");
2506 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2508 struct crypto_testsuite_params *ts_params = &testsuite_params;
2509 struct crypto_unittest_params *ut_params = &unittest_params;
2512 unsigned plaintext_pad_len;
2513 unsigned plaintext_len;
2516 /* Create KASUMI session */
2517 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2518 tdata->key.data, tdata->key.len,
2519 tdata->auth_iv.len, tdata->digest.len,
2520 RTE_CRYPTO_AUTH_OP_VERIFY,
2521 RTE_CRYPTO_AUTH_KASUMI_F9);
2524 /* alloc mbuf and set payload */
2525 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2528 rte_pktmbuf_tailroom(ut_params->ibuf));
2530 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2531 /* Append data which is padded to a multiple */
2532 /* of the algorithms block size */
2533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2534 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2536 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2538 /* Create KASUMI operation */
2539 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2541 tdata->auth_iv.data, tdata->auth_iv.len,
2543 RTE_CRYPTO_AUTH_OP_VERIFY,
2544 tdata->validAuthLenInBits.len,
2549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2551 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2552 ut_params->obuf = ut_params->op->sym->m_src;
2553 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2554 + plaintext_pad_len;
2557 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2566 test_snow3g_hash_generate_test_case_1(void)
2568 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2572 test_snow3g_hash_generate_test_case_2(void)
2574 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2578 test_snow3g_hash_generate_test_case_3(void)
2580 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2584 test_snow3g_hash_generate_test_case_4(void)
2586 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2590 test_snow3g_hash_generate_test_case_5(void)
2592 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2596 test_snow3g_hash_generate_test_case_6(void)
2598 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2602 test_snow3g_hash_verify_test_case_1(void)
2604 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2609 test_snow3g_hash_verify_test_case_2(void)
2611 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2615 test_snow3g_hash_verify_test_case_3(void)
2617 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2621 test_snow3g_hash_verify_test_case_4(void)
2623 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2627 test_snow3g_hash_verify_test_case_5(void)
2629 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2633 test_snow3g_hash_verify_test_case_6(void)
2635 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2639 test_kasumi_hash_generate_test_case_1(void)
2641 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2645 test_kasumi_hash_generate_test_case_2(void)
2647 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2651 test_kasumi_hash_generate_test_case_3(void)
2653 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2657 test_kasumi_hash_generate_test_case_4(void)
2659 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2663 test_kasumi_hash_generate_test_case_5(void)
2665 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2669 test_kasumi_hash_generate_test_case_6(void)
2671 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2675 test_kasumi_hash_verify_test_case_1(void)
2677 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2681 test_kasumi_hash_verify_test_case_2(void)
2683 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2687 test_kasumi_hash_verify_test_case_3(void)
2689 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2693 test_kasumi_hash_verify_test_case_4(void)
2695 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2699 test_kasumi_hash_verify_test_case_5(void)
2701 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2705 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2707 struct crypto_testsuite_params *ts_params = &testsuite_params;
2708 struct crypto_unittest_params *ut_params = &unittest_params;
2711 uint8_t *plaintext, *ciphertext;
2712 unsigned plaintext_pad_len;
2713 unsigned plaintext_len;
2715 /* Create KASUMI session */
2716 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2717 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2718 RTE_CRYPTO_CIPHER_KASUMI_F8,
2719 tdata->key.data, tdata->key.len,
2720 tdata->cipher_iv.len);
2724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2726 /* Clear mbuf payload */
2727 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2728 rte_pktmbuf_tailroom(ut_params->ibuf));
2730 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2731 /* Append data which is padded to a multiple */
2732 /* of the algorithms block size */
2733 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2738 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2740 /* Create KASUMI operation */
2741 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2742 tdata->cipher_iv.len,
2743 tdata->plaintext.len,
2748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2752 ut_params->obuf = ut_params->op->sym->m_dst;
2753 if (ut_params->obuf)
2754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2756 ciphertext = plaintext;
2758 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2761 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2763 tdata->ciphertext.data,
2764 tdata->validCipherLenInBits.len,
2765 "KASUMI Ciphertext data not as expected");
2770 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2772 struct crypto_testsuite_params *ts_params = &testsuite_params;
2773 struct crypto_unittest_params *ut_params = &unittest_params;
2777 unsigned int plaintext_pad_len;
2778 unsigned int plaintext_len;
2780 uint8_t buffer[10000];
2781 const uint8_t *ciphertext;
2783 struct rte_cryptodev_info dev_info;
2785 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2786 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2787 printf("Device doesn't support scatter-gather. "
2792 /* Create KASUMI session */
2793 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2794 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2795 RTE_CRYPTO_CIPHER_KASUMI_F8,
2796 tdata->key.data, tdata->key.len,
2797 tdata->cipher_iv.len);
2801 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2804 /* Append data which is padded to a multiple */
2805 /* of the algorithms block size */
2806 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2808 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2809 plaintext_pad_len, 10, 0);
2811 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2813 /* Create KASUMI operation */
2814 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2815 tdata->cipher_iv.len,
2816 tdata->plaintext.len,
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2825 ut_params->obuf = ut_params->op->sym->m_dst;
2827 if (ut_params->obuf)
2828 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2829 plaintext_len, buffer);
2831 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2832 plaintext_len, buffer);
2835 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2838 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2840 tdata->ciphertext.data,
2841 tdata->validCipherLenInBits.len,
2842 "KASUMI Ciphertext data not as expected");
2847 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2849 struct crypto_testsuite_params *ts_params = &testsuite_params;
2850 struct crypto_unittest_params *ut_params = &unittest_params;
2853 uint8_t *plaintext, *ciphertext;
2854 unsigned plaintext_pad_len;
2855 unsigned plaintext_len;
2857 /* Create KASUMI session */
2858 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2859 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2860 RTE_CRYPTO_CIPHER_KASUMI_F8,
2861 tdata->key.data, tdata->key.len,
2862 tdata->cipher_iv.len);
2866 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2867 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2869 /* Clear mbuf payload */
2870 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2871 rte_pktmbuf_tailroom(ut_params->ibuf));
2873 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2874 /* Append data which is padded to a multiple */
2875 /* of the algorithms block size */
2876 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2877 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2879 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2880 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2882 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2884 /* Create KASUMI operation */
2885 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2886 tdata->cipher_iv.len,
2887 tdata->plaintext.len,
2892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2896 ut_params->obuf = ut_params->op->sym->m_dst;
2897 if (ut_params->obuf)
2898 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2900 ciphertext = plaintext;
2902 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2905 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2907 tdata->ciphertext.data,
2908 tdata->validCipherLenInBits.len,
2909 "KASUMI Ciphertext data not as expected");
2914 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2916 struct crypto_testsuite_params *ts_params = &testsuite_params;
2917 struct crypto_unittest_params *ut_params = &unittest_params;
2920 unsigned int plaintext_pad_len;
2921 unsigned int plaintext_len;
2923 const uint8_t *ciphertext;
2924 uint8_t buffer[2048];
2926 struct rte_cryptodev_info dev_info;
2928 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2929 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2930 printf("Device doesn't support scatter-gather. "
2935 /* Create KASUMI session */
2936 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2937 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2938 RTE_CRYPTO_CIPHER_KASUMI_F8,
2939 tdata->key.data, tdata->key.len,
2940 tdata->cipher_iv.len);
2944 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2945 /* Append data which is padded to a multiple */
2946 /* of the algorithms block size */
2947 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2949 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2950 plaintext_pad_len, 10, 0);
2951 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2952 plaintext_pad_len, 3, 0);
2954 /* Append data which is padded to a multiple */
2955 /* of the algorithms block size */
2956 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2958 /* Create KASUMI operation */
2959 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2960 tdata->cipher_iv.len,
2961 tdata->plaintext.len,
2966 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2968 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2970 ut_params->obuf = ut_params->op->sym->m_dst;
2971 if (ut_params->obuf)
2972 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2973 plaintext_pad_len, buffer);
2975 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2976 plaintext_pad_len, buffer);
2979 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2981 tdata->ciphertext.data,
2982 tdata->validCipherLenInBits.len,
2983 "KASUMI Ciphertext data not as expected");
2989 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2991 struct crypto_testsuite_params *ts_params = &testsuite_params;
2992 struct crypto_unittest_params *ut_params = &unittest_params;
2995 uint8_t *ciphertext, *plaintext;
2996 unsigned ciphertext_pad_len;
2997 unsigned ciphertext_len;
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3001 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3002 RTE_CRYPTO_CIPHER_KASUMI_F8,
3003 tdata->key.data, tdata->key.len,
3004 tdata->cipher_iv.len);
3008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3009 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3011 /* Clear mbuf payload */
3012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3013 rte_pktmbuf_tailroom(ut_params->ibuf));
3015 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3016 /* Append data which is padded to a multiple */
3017 /* of the algorithms block size */
3018 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3019 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3020 ciphertext_pad_len);
3021 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3022 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3024 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3026 /* Create KASUMI operation */
3027 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3028 tdata->cipher_iv.len,
3029 tdata->ciphertext.len,
3034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3038 ut_params->obuf = ut_params->op->sym->m_dst;
3039 if (ut_params->obuf)
3040 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3042 plaintext = ciphertext;
3044 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3047 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3049 tdata->plaintext.data,
3050 tdata->validCipherLenInBits.len,
3051 "KASUMI Plaintext data not as expected");
3056 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3058 struct crypto_testsuite_params *ts_params = &testsuite_params;
3059 struct crypto_unittest_params *ut_params = &unittest_params;
3062 uint8_t *ciphertext, *plaintext;
3063 unsigned ciphertext_pad_len;
3064 unsigned ciphertext_len;
3066 /* Create KASUMI session */
3067 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3068 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3069 RTE_CRYPTO_CIPHER_KASUMI_F8,
3070 tdata->key.data, tdata->key.len,
3071 tdata->cipher_iv.len);
3075 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3077 /* Clear mbuf payload */
3078 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3079 rte_pktmbuf_tailroom(ut_params->ibuf));
3081 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3082 /* Append data which is padded to a multiple */
3083 /* of the algorithms block size */
3084 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3085 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3086 ciphertext_pad_len);
3087 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3089 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3091 /* Create KASUMI operation */
3092 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3093 tdata->cipher_iv.len,
3094 tdata->ciphertext.len,
3099 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3101 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3103 ut_params->obuf = ut_params->op->sym->m_dst;
3104 if (ut_params->obuf)
3105 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3107 plaintext = ciphertext;
3109 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3112 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3114 tdata->plaintext.data,
3115 tdata->validCipherLenInBits.len,
3116 "KASUMI Plaintext data not as expected");
3121 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3123 struct crypto_testsuite_params *ts_params = &testsuite_params;
3124 struct crypto_unittest_params *ut_params = &unittest_params;
3127 uint8_t *plaintext, *ciphertext;
3128 unsigned plaintext_pad_len;
3129 unsigned plaintext_len;
3131 /* Create SNOW 3G session */
3132 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3134 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3135 tdata->key.data, tdata->key.len,
3136 tdata->cipher_iv.len);
3140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3142 /* Clear mbuf payload */
3143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3144 rte_pktmbuf_tailroom(ut_params->ibuf));
3146 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3147 /* Append data which is padded to a multiple of */
3148 /* the algorithms block size */
3149 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3150 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3152 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3154 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3156 /* Create SNOW 3G operation */
3157 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3158 tdata->cipher_iv.len,
3159 tdata->validCipherLenInBits.len,
3164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3166 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3168 ut_params->obuf = ut_params->op->sym->m_dst;
3169 if (ut_params->obuf)
3170 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3172 ciphertext = plaintext;
3174 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3177 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3179 tdata->ciphertext.data,
3180 tdata->validDataLenInBits.len,
3181 "SNOW 3G Ciphertext data not as expected");
3187 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3189 struct crypto_testsuite_params *ts_params = &testsuite_params;
3190 struct crypto_unittest_params *ut_params = &unittest_params;
3191 uint8_t *plaintext, *ciphertext;
3194 unsigned plaintext_pad_len;
3195 unsigned plaintext_len;
3197 /* Create SNOW 3G session */
3198 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3199 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3200 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3201 tdata->key.data, tdata->key.len,
3202 tdata->cipher_iv.len);
3206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3209 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3210 "Failed to allocate input buffer in mempool");
3211 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3212 "Failed to allocate output buffer in mempool");
3214 /* Clear mbuf payload */
3215 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3216 rte_pktmbuf_tailroom(ut_params->ibuf));
3218 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3219 /* Append data which is padded to a multiple of */
3220 /* the algorithms block size */
3221 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3222 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3224 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3225 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3227 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3229 /* Create SNOW 3G operation */
3230 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3231 tdata->cipher_iv.len,
3232 tdata->validCipherLenInBits.len,
3237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3239 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3241 ut_params->obuf = ut_params->op->sym->m_dst;
3242 if (ut_params->obuf)
3243 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3245 ciphertext = plaintext;
3247 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3250 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3252 tdata->ciphertext.data,
3253 tdata->validDataLenInBits.len,
3254 "SNOW 3G Ciphertext data not as expected");
3259 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3261 struct crypto_testsuite_params *ts_params = &testsuite_params;
3262 struct crypto_unittest_params *ut_params = &unittest_params;
3265 unsigned int plaintext_pad_len;
3266 unsigned int plaintext_len;
3267 uint8_t buffer[10000];
3268 const uint8_t *ciphertext;
3270 struct rte_cryptodev_info dev_info;
3272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3273 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3274 printf("Device doesn't support scatter-gather. "
3279 /* Create SNOW 3G session */
3280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3282 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3283 tdata->key.data, tdata->key.len,
3284 tdata->cipher_iv.len);
3288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3289 /* Append data which is padded to a multiple of */
3290 /* the algorithms block size */
3291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3293 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3294 plaintext_pad_len, 10, 0);
3295 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3296 plaintext_pad_len, 3, 0);
3298 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3299 "Failed to allocate input buffer in mempool");
3300 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3301 "Failed to allocate output buffer in mempool");
3303 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3305 /* Create SNOW 3G operation */
3306 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3307 tdata->cipher_iv.len,
3308 tdata->validCipherLenInBits.len,
3313 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3315 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3317 ut_params->obuf = ut_params->op->sym->m_dst;
3318 if (ut_params->obuf)
3319 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3320 plaintext_len, buffer);
3322 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3323 plaintext_len, buffer);
3325 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3328 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3330 tdata->ciphertext.data,
3331 tdata->validDataLenInBits.len,
3332 "SNOW 3G Ciphertext data not as expected");
3337 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3339 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3341 uint8_t curr_byte, prev_byte;
3342 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3343 uint8_t lower_byte_mask = (1 << offset) - 1;
3346 prev_byte = buffer[0];
3347 buffer[0] >>= offset;
3349 for (i = 1; i < length_in_bytes; i++) {
3350 curr_byte = buffer[i];
3351 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3352 (curr_byte >> offset);
3353 prev_byte = curr_byte;
3358 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3360 struct crypto_testsuite_params *ts_params = &testsuite_params;
3361 struct crypto_unittest_params *ut_params = &unittest_params;
3362 uint8_t *plaintext, *ciphertext;
3364 uint32_t plaintext_len;
3365 uint32_t plaintext_pad_len;
3366 uint8_t extra_offset = 4;
3367 uint8_t *expected_ciphertext_shifted;
3369 /* Create SNOW 3G session */
3370 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3371 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3372 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3373 tdata->key.data, tdata->key.len,
3374 tdata->cipher_iv.len);
3378 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3379 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3381 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3382 "Failed to allocate input buffer in mempool");
3383 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3384 "Failed to allocate output buffer in mempool");
3386 /* Clear mbuf payload */
3387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 rte_pktmbuf_tailroom(ut_params->ibuf));
3390 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3392 * Append data which is padded to a
3393 * multiple of the algorithms block size
3395 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3397 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3400 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3402 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3403 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3405 #ifdef RTE_APP_TEST_DEBUG
3406 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3408 /* Create SNOW 3G operation */
3409 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3410 tdata->cipher_iv.len,
3411 tdata->validCipherLenInBits.len,
3416 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3420 ut_params->obuf = ut_params->op->sym->m_dst;
3421 if (ut_params->obuf)
3422 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3424 ciphertext = plaintext;
3426 #ifdef RTE_APP_TEST_DEBUG
3427 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3430 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3432 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3433 "failed to reserve memory for ciphertext shifted\n");
3435 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3436 ceil_byte_length(tdata->ciphertext.len));
3437 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3442 expected_ciphertext_shifted,
3443 tdata->validDataLenInBits.len,
3445 "SNOW 3G Ciphertext data not as expected");
3449 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3456 uint8_t *plaintext, *ciphertext;
3457 unsigned ciphertext_pad_len;
3458 unsigned ciphertext_len;
3460 /* Create SNOW 3G session */
3461 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3462 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3463 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3464 tdata->key.data, tdata->key.len,
3465 tdata->cipher_iv.len);
3469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3471 /* Clear mbuf payload */
3472 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3473 rte_pktmbuf_tailroom(ut_params->ibuf));
3475 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3476 /* Append data which is padded to a multiple of */
3477 /* the algorithms block size */
3478 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3479 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3480 ciphertext_pad_len);
3481 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3483 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3485 /* Create SNOW 3G operation */
3486 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3487 tdata->cipher_iv.len,
3488 tdata->validCipherLenInBits.len,
3493 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3496 ut_params->obuf = ut_params->op->sym->m_dst;
3497 if (ut_params->obuf)
3498 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3500 plaintext = ciphertext;
3502 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3505 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3506 tdata->plaintext.data,
3507 tdata->validDataLenInBits.len,
3508 "SNOW 3G Plaintext data not as expected");
3512 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3514 struct crypto_testsuite_params *ts_params = &testsuite_params;
3515 struct crypto_unittest_params *ut_params = &unittest_params;
3519 uint8_t *plaintext, *ciphertext;
3520 unsigned ciphertext_pad_len;
3521 unsigned ciphertext_len;
3523 /* Create SNOW 3G session */
3524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3525 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3526 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3527 tdata->key.data, tdata->key.len,
3528 tdata->cipher_iv.len);
3532 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3533 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3535 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3536 "Failed to allocate input buffer");
3537 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3538 "Failed to allocate output buffer");
3540 /* Clear mbuf payload */
3541 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3542 rte_pktmbuf_tailroom(ut_params->ibuf));
3544 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3545 rte_pktmbuf_tailroom(ut_params->obuf));
3547 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3548 /* Append data which is padded to a multiple of */
3549 /* the algorithms block size */
3550 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3551 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3552 ciphertext_pad_len);
3553 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3554 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3556 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3558 /* Create SNOW 3G operation */
3559 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3560 tdata->cipher_iv.len,
3561 tdata->validCipherLenInBits.len,
3566 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3568 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3569 ut_params->obuf = ut_params->op->sym->m_dst;
3570 if (ut_params->obuf)
3571 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3573 plaintext = ciphertext;
3575 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3578 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3579 tdata->plaintext.data,
3580 tdata->validDataLenInBits.len,
3581 "SNOW 3G Plaintext data not as expected");
3586 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3588 struct crypto_testsuite_params *ts_params = &testsuite_params;
3589 struct crypto_unittest_params *ut_params = &unittest_params;
3593 uint8_t *plaintext, *ciphertext;
3594 unsigned int plaintext_pad_len;
3595 unsigned int plaintext_len;
3597 struct rte_cryptodev_sym_capability_idx cap_idx;
3599 /* Check if device supports ZUC EEA3 */
3600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3601 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3603 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3607 /* Check if device supports ZUC EIA3 */
3608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3609 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3611 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3615 /* Create ZUC session */
3616 retval = create_zuc_cipher_auth_encrypt_generate_session(
3617 ts_params->valid_devs[0],
3621 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3623 /* clear mbuf payload */
3624 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3625 rte_pktmbuf_tailroom(ut_params->ibuf));
3627 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3628 /* Append data which is padded to a multiple of */
3629 /* the algorithms block size */
3630 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3631 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3633 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3635 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3637 /* Create ZUC operation */
3638 retval = create_zuc_cipher_hash_generate_operation(tdata);
3642 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3644 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3645 ut_params->obuf = ut_params->op->sym->m_src;
3646 if (ut_params->obuf)
3647 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3649 ciphertext = plaintext;
3651 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3653 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3655 tdata->ciphertext.data,
3656 tdata->validDataLenInBits.len,
3657 "ZUC Ciphertext data not as expected");
3659 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3660 + plaintext_pad_len;
3663 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3667 "ZUC Generated auth tag not as expected");
3672 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3674 struct crypto_testsuite_params *ts_params = &testsuite_params;
3675 struct crypto_unittest_params *ut_params = &unittest_params;
3679 uint8_t *plaintext, *ciphertext;
3680 unsigned plaintext_pad_len;
3681 unsigned plaintext_len;
3683 /* Create SNOW 3G session */
3684 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3685 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3686 RTE_CRYPTO_AUTH_OP_GENERATE,
3687 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3688 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3689 tdata->key.data, tdata->key.len,
3690 tdata->auth_iv.len, tdata->digest.len,
3691 tdata->cipher_iv.len);
3694 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3696 /* clear mbuf payload */
3697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3698 rte_pktmbuf_tailroom(ut_params->ibuf));
3700 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3701 /* Append data which is padded to a multiple of */
3702 /* the algorithms block size */
3703 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3704 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3706 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3708 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3710 /* Create SNOW 3G operation */
3711 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3712 tdata->digest.len, tdata->auth_iv.data,
3714 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3715 tdata->cipher_iv.data, tdata->cipher_iv.len,
3716 tdata->validCipherLenInBits.len,
3718 tdata->validAuthLenInBits.len,
3724 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3726 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3727 ut_params->obuf = ut_params->op->sym->m_src;
3728 if (ut_params->obuf)
3729 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3731 ciphertext = plaintext;
3733 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3737 tdata->ciphertext.data,
3738 tdata->validDataLenInBits.len,
3739 "SNOW 3G Ciphertext data not as expected");
3741 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3742 + plaintext_pad_len;
3745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3748 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3749 "SNOW 3G Generated auth tag not as expected");
3753 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3755 struct crypto_testsuite_params *ts_params = &testsuite_params;
3756 struct crypto_unittest_params *ut_params = &unittest_params;
3760 uint8_t *plaintext, *ciphertext;
3761 unsigned plaintext_pad_len;
3762 unsigned plaintext_len;
3764 /* Create SNOW 3G session */
3765 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3766 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3767 RTE_CRYPTO_AUTH_OP_GENERATE,
3768 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3769 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3770 tdata->key.data, tdata->key.len,
3771 tdata->auth_iv.len, tdata->digest.len,
3772 tdata->cipher_iv.len);
3776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 /* clear mbuf payload */
3779 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3780 rte_pktmbuf_tailroom(ut_params->ibuf));
3782 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3783 /* Append data which is padded to a multiple of */
3784 /* the algorithms block size */
3785 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3786 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3790 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3792 /* Create SNOW 3G operation */
3793 retval = create_wireless_algo_auth_cipher_operation(
3795 tdata->cipher_iv.data, tdata->cipher_iv.len,
3796 tdata->auth_iv.data, tdata->auth_iv.len,
3798 tdata->validCipherLenInBits.len,
3800 tdata->validAuthLenInBits.len,
3806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3808 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3809 ut_params->obuf = ut_params->op->sym->m_src;
3810 if (ut_params->obuf)
3811 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3813 ciphertext = plaintext;
3815 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3816 + plaintext_pad_len;
3817 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3822 tdata->ciphertext.data,
3823 tdata->validDataLenInBits.len,
3824 "SNOW 3G Ciphertext data not as expected");
3827 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3830 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3831 "SNOW 3G Generated auth tag not as expected");
3836 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3838 struct crypto_testsuite_params *ts_params = &testsuite_params;
3839 struct crypto_unittest_params *ut_params = &unittest_params;
3843 uint8_t *plaintext, *ciphertext;
3844 unsigned plaintext_pad_len;
3845 unsigned plaintext_len;
3847 /* Create KASUMI session */
3848 retval = create_wireless_algo_auth_cipher_session(
3849 ts_params->valid_devs[0],
3850 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3851 RTE_CRYPTO_AUTH_OP_GENERATE,
3852 RTE_CRYPTO_AUTH_KASUMI_F9,
3853 RTE_CRYPTO_CIPHER_KASUMI_F8,
3854 tdata->key.data, tdata->key.len,
3855 tdata->auth_iv.len, tdata->digest.len,
3856 tdata->cipher_iv.len);
3859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3861 /* clear mbuf payload */
3862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3863 rte_pktmbuf_tailroom(ut_params->ibuf));
3865 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3866 /* Append data which is padded to a multiple of */
3867 /* the algorithms block size */
3868 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3869 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3871 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3873 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3875 /* Create KASUMI operation */
3876 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3877 tdata->cipher_iv.data, tdata->cipher_iv.len,
3878 tdata->auth_iv.data, tdata->auth_iv.len,
3880 tdata->validCipherLenInBits.len,
3882 tdata->validAuthLenInBits.len,
3889 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3891 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3892 ut_params->obuf = ut_params->op->sym->m_src;
3893 if (ut_params->obuf)
3894 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3896 ciphertext = plaintext;
3899 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3901 tdata->ciphertext.data,
3902 tdata->validCipherLenInBits.len,
3903 "KASUMI Ciphertext data not as expected");
3904 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3905 + plaintext_pad_len;
3908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3911 DIGEST_BYTE_LENGTH_KASUMI_F9,
3912 "KASUMI Generated auth tag not as expected");
3917 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3919 struct crypto_testsuite_params *ts_params = &testsuite_params;
3920 struct crypto_unittest_params *ut_params = &unittest_params;
3924 uint8_t *plaintext, *ciphertext;
3925 unsigned plaintext_pad_len;
3926 unsigned plaintext_len;
3928 /* Create KASUMI session */
3929 retval = create_wireless_algo_cipher_auth_session(
3930 ts_params->valid_devs[0],
3931 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3932 RTE_CRYPTO_AUTH_OP_GENERATE,
3933 RTE_CRYPTO_AUTH_KASUMI_F9,
3934 RTE_CRYPTO_CIPHER_KASUMI_F8,
3935 tdata->key.data, tdata->key.len,
3936 tdata->auth_iv.len, tdata->digest.len,
3937 tdata->cipher_iv.len);
3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3943 /* clear mbuf payload */
3944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 rte_pktmbuf_tailroom(ut_params->ibuf));
3947 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3948 /* Append data which is padded to a multiple of */
3949 /* the algorithms block size */
3950 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3953 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3955 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3957 /* Create KASUMI operation */
3958 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3959 tdata->digest.len, tdata->auth_iv.data,
3961 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3962 tdata->cipher_iv.data, tdata->cipher_iv.len,
3963 tdata->validCipherLenInBits.len,
3965 tdata->validAuthLenInBits.len,
3971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3974 ut_params->obuf = ut_params->op->sym->m_src;
3975 if (ut_params->obuf)
3976 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3978 ciphertext = plaintext;
3980 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3981 + plaintext_pad_len;
3984 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3986 tdata->ciphertext.data,
3987 tdata->validCipherLenInBits.len,
3988 "KASUMI Ciphertext data not as expected");
3991 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3994 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3995 "KASUMI Generated auth tag not as expected");
4000 test_zuc_encryption(const struct wireless_test_data *tdata)
4002 struct crypto_testsuite_params *ts_params = &testsuite_params;
4003 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *plaintext, *ciphertext;
4007 unsigned plaintext_pad_len;
4008 unsigned plaintext_len;
4010 struct rte_cryptodev_sym_capability_idx cap_idx;
4012 /* Check if device supports ZUC EEA3 */
4013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4014 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4016 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4020 /* Create ZUC session */
4021 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4022 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4023 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4024 tdata->key.data, tdata->key.len,
4025 tdata->cipher_iv.len);
4029 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4031 /* Clear mbuf payload */
4032 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4033 rte_pktmbuf_tailroom(ut_params->ibuf));
4035 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4036 /* Append data which is padded to a multiple */
4037 /* of the algorithms block size */
4038 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4041 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4043 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4045 /* Create ZUC operation */
4046 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4047 tdata->cipher_iv.len,
4048 tdata->plaintext.len,
4053 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4055 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4057 ut_params->obuf = ut_params->op->sym->m_dst;
4058 if (ut_params->obuf)
4059 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4061 ciphertext = plaintext;
4063 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4066 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4068 tdata->ciphertext.data,
4069 tdata->validCipherLenInBits.len,
4070 "ZUC Ciphertext data not as expected");
4075 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4077 struct crypto_testsuite_params *ts_params = &testsuite_params;
4078 struct crypto_unittest_params *ut_params = &unittest_params;
4082 unsigned int plaintext_pad_len;
4083 unsigned int plaintext_len;
4084 const uint8_t *ciphertext;
4085 uint8_t ciphertext_buffer[2048];
4086 struct rte_cryptodev_info dev_info;
4088 struct rte_cryptodev_sym_capability_idx cap_idx;
4090 /* Check if device supports ZUC EEA3 */
4091 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4092 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4094 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4098 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4099 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4100 printf("Device doesn't support scatter-gather. "
4105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4107 /* Append data which is padded to a multiple */
4108 /* of the algorithms block size */
4109 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4111 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4112 plaintext_pad_len, 10, 0);
4114 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4115 tdata->plaintext.data);
4117 /* Create ZUC session */
4118 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4119 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4120 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4121 tdata->key.data, tdata->key.len,
4122 tdata->cipher_iv.len);
4126 /* Clear mbuf payload */
4128 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4130 /* Create ZUC operation */
4131 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4132 tdata->cipher_iv.len, tdata->plaintext.len,
4137 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4139 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4141 ut_params->obuf = ut_params->op->sym->m_dst;
4142 if (ut_params->obuf)
4143 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4144 0, plaintext_len, ciphertext_buffer);
4146 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4147 0, plaintext_len, ciphertext_buffer);
4150 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4153 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4155 tdata->ciphertext.data,
4156 tdata->validCipherLenInBits.len,
4157 "ZUC Ciphertext data not as expected");
4163 test_zuc_authentication(const struct wireless_test_data *tdata)
4165 struct crypto_testsuite_params *ts_params = &testsuite_params;
4166 struct crypto_unittest_params *ut_params = &unittest_params;
4169 unsigned plaintext_pad_len;
4170 unsigned plaintext_len;
4173 struct rte_cryptodev_sym_capability_idx cap_idx;
4175 /* Check if device supports ZUC EIA3 */
4176 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4177 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4179 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4183 /* Create ZUC session */
4184 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4185 tdata->key.data, tdata->key.len,
4186 tdata->auth_iv.len, tdata->digest.len,
4187 RTE_CRYPTO_AUTH_OP_GENERATE,
4188 RTE_CRYPTO_AUTH_ZUC_EIA3);
4192 /* alloc mbuf and set payload */
4193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4196 rte_pktmbuf_tailroom(ut_params->ibuf));
4198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4199 /* Append data which is padded to a multiple of */
4200 /* the algorithms block size */
4201 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4204 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4206 /* Create ZUC operation */
4207 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4208 tdata->auth_iv.data, tdata->auth_iv.len,
4209 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4210 tdata->validAuthLenInBits.len,
4215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4217 ut_params->obuf = ut_params->op->sym->m_src;
4218 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4219 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4220 + plaintext_pad_len;
4223 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4226 DIGEST_BYTE_LENGTH_KASUMI_F9,
4227 "ZUC Generated auth tag not as expected");
4233 test_kasumi_encryption_test_case_1(void)
4235 return test_kasumi_encryption(&kasumi_test_case_1);
4239 test_kasumi_encryption_test_case_1_sgl(void)
4241 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4245 test_kasumi_encryption_test_case_1_oop(void)
4247 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4251 test_kasumi_encryption_test_case_1_oop_sgl(void)
4253 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4257 test_kasumi_encryption_test_case_2(void)
4259 return test_kasumi_encryption(&kasumi_test_case_2);
4263 test_kasumi_encryption_test_case_3(void)
4265 return test_kasumi_encryption(&kasumi_test_case_3);
4269 test_kasumi_encryption_test_case_4(void)
4271 return test_kasumi_encryption(&kasumi_test_case_4);
4275 test_kasumi_encryption_test_case_5(void)
4277 return test_kasumi_encryption(&kasumi_test_case_5);
4281 test_kasumi_decryption_test_case_1(void)
4283 return test_kasumi_decryption(&kasumi_test_case_1);
4287 test_kasumi_decryption_test_case_1_oop(void)
4289 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4293 test_kasumi_decryption_test_case_2(void)
4295 return test_kasumi_decryption(&kasumi_test_case_2);
4299 test_kasumi_decryption_test_case_3(void)
4301 return test_kasumi_decryption(&kasumi_test_case_3);
4305 test_kasumi_decryption_test_case_4(void)
4307 return test_kasumi_decryption(&kasumi_test_case_4);
4311 test_kasumi_decryption_test_case_5(void)
4313 return test_kasumi_decryption(&kasumi_test_case_5);
4316 test_snow3g_encryption_test_case_1(void)
4318 return test_snow3g_encryption(&snow3g_test_case_1);
4322 test_snow3g_encryption_test_case_1_oop(void)
4324 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4328 test_snow3g_encryption_test_case_1_oop_sgl(void)
4330 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4335 test_snow3g_encryption_test_case_1_offset_oop(void)
4337 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4341 test_snow3g_encryption_test_case_2(void)
4343 return test_snow3g_encryption(&snow3g_test_case_2);
4347 test_snow3g_encryption_test_case_3(void)
4349 return test_snow3g_encryption(&snow3g_test_case_3);
4353 test_snow3g_encryption_test_case_4(void)
4355 return test_snow3g_encryption(&snow3g_test_case_4);
4359 test_snow3g_encryption_test_case_5(void)
4361 return test_snow3g_encryption(&snow3g_test_case_5);
4365 test_snow3g_decryption_test_case_1(void)
4367 return test_snow3g_decryption(&snow3g_test_case_1);
4371 test_snow3g_decryption_test_case_1_oop(void)
4373 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4377 test_snow3g_decryption_test_case_2(void)
4379 return test_snow3g_decryption(&snow3g_test_case_2);
4383 test_snow3g_decryption_test_case_3(void)
4385 return test_snow3g_decryption(&snow3g_test_case_3);
4389 test_snow3g_decryption_test_case_4(void)
4391 return test_snow3g_decryption(&snow3g_test_case_4);
4395 test_snow3g_decryption_test_case_5(void)
4397 return test_snow3g_decryption(&snow3g_test_case_5);
4400 test_snow3g_cipher_auth_test_case_1(void)
4402 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4406 test_snow3g_auth_cipher_test_case_1(void)
4408 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4412 test_kasumi_auth_cipher_test_case_1(void)
4414 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4418 test_kasumi_cipher_auth_test_case_1(void)
4420 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4424 test_zuc_encryption_test_case_1(void)
4426 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4430 test_zuc_encryption_test_case_2(void)
4432 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4436 test_zuc_encryption_test_case_3(void)
4438 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4442 test_zuc_encryption_test_case_4(void)
4444 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4448 test_zuc_encryption_test_case_5(void)
4450 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4454 test_zuc_encryption_test_case_6_sgl(void)
4456 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4460 test_zuc_hash_generate_test_case_1(void)
4462 return test_zuc_authentication(&zuc_test_case_auth_1b);
4466 test_zuc_hash_generate_test_case_2(void)
4468 return test_zuc_authentication(&zuc_test_case_auth_90b);
4472 test_zuc_hash_generate_test_case_3(void)
4474 return test_zuc_authentication(&zuc_test_case_auth_577b);
4478 test_zuc_hash_generate_test_case_4(void)
4480 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4484 test_zuc_hash_generate_test_case_5(void)
4486 return test_zuc_authentication(&zuc_test_auth_5670b);
4490 test_zuc_hash_generate_test_case_6(void)
4492 return test_zuc_authentication(&zuc_test_case_auth_128b);
4496 test_zuc_hash_generate_test_case_7(void)
4498 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4502 test_zuc_hash_generate_test_case_8(void)
4504 return test_zuc_authentication(&zuc_test_case_auth_584b);
4508 test_zuc_cipher_auth_test_case_1(void)
4510 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4514 test_zuc_cipher_auth_test_case_2(void)
4516 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4520 test_3DES_chain_qat_all(void)
4522 struct crypto_testsuite_params *ts_params = &testsuite_params;
4525 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4526 ts_params->op_mpool, ts_params->valid_devs[0],
4527 RTE_CRYPTODEV_QAT_SYM_PMD,
4528 BLKCIPHER_3DES_CHAIN_TYPE);
4530 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4532 return TEST_SUCCESS;
4536 test_DES_cipheronly_qat_all(void)
4538 struct crypto_testsuite_params *ts_params = &testsuite_params;
4541 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4542 ts_params->op_mpool, ts_params->valid_devs[0],
4543 RTE_CRYPTODEV_QAT_SYM_PMD,
4544 BLKCIPHER_DES_CIPHERONLY_TYPE);
4546 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4548 return TEST_SUCCESS;
4552 test_DES_docsis_openssl_all(void)
4554 struct crypto_testsuite_params *ts_params = &testsuite_params;
4557 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4558 ts_params->op_mpool, ts_params->valid_devs[0],
4559 RTE_CRYPTODEV_OPENSSL_PMD,
4560 BLKCIPHER_DES_DOCSIS_TYPE);
4562 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4564 return TEST_SUCCESS;
4568 test_3DES_chain_dpaa2_sec_all(void)
4570 struct crypto_testsuite_params *ts_params = &testsuite_params;
4573 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4574 ts_params->op_mpool, ts_params->valid_devs[0],
4575 RTE_CRYPTODEV_DPAA2_SEC_PMD,
4576 BLKCIPHER_3DES_CHAIN_TYPE);
4578 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4580 return TEST_SUCCESS;
4584 test_3DES_cipheronly_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_DPAA2_SEC_PMD,
4592 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4594 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4596 return TEST_SUCCESS;
4600 test_3DES_cipheronly_qat_all(void)
4602 struct crypto_testsuite_params *ts_params = &testsuite_params;
4605 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4606 ts_params->op_mpool, ts_params->valid_devs[0],
4607 RTE_CRYPTODEV_QAT_SYM_PMD,
4608 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4612 return TEST_SUCCESS;
4616 test_3DES_chain_openssl_all(void)
4618 struct crypto_testsuite_params *ts_params = &testsuite_params;
4621 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4622 ts_params->op_mpool, ts_params->valid_devs[0],
4623 RTE_CRYPTODEV_OPENSSL_PMD,
4624 BLKCIPHER_3DES_CHAIN_TYPE);
4626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4628 return TEST_SUCCESS;
4632 test_3DES_cipheronly_openssl_all(void)
4634 struct crypto_testsuite_params *ts_params = &testsuite_params;
4637 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4638 ts_params->op_mpool, ts_params->valid_devs[0],
4639 RTE_CRYPTODEV_OPENSSL_PMD,
4640 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4644 return TEST_SUCCESS;
4647 /* ***** AES-GCM Tests ***** */
4650 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4651 const uint8_t *key, const uint8_t key_len,
4652 const uint16_t aad_len, const uint8_t auth_len,
4655 uint8_t aead_key[key_len];
4657 struct crypto_unittest_params *ut_params = &unittest_params;
4659 memcpy(aead_key, key, key_len);
4661 /* Setup AEAD Parameters */
4662 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4663 ut_params->aead_xform.next = NULL;
4664 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4665 ut_params->aead_xform.aead.op = op;
4666 ut_params->aead_xform.aead.key.data = aead_key;
4667 ut_params->aead_xform.aead.key.length = key_len;
4668 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4669 ut_params->aead_xform.aead.iv.length = iv_len;
4670 ut_params->aead_xform.aead.digest_length = auth_len;
4671 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4673 TEST_HEXDUMP(stdout, "key:", key, key_len);
4675 /* Create Crypto session*/
4676 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4677 &ut_params->aead_xform);
4679 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4685 create_gcm_xforms(struct rte_crypto_op *op,
4686 enum rte_crypto_aead_operation aead_op,
4687 uint8_t *key, const uint8_t key_len,
4688 const uint8_t aad_len, const uint8_t auth_len,
4691 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4692 "failed to allocate space for crypto transform");
4694 struct rte_crypto_sym_op *sym_op = op->sym;
4696 /* Setup AEAD Parameters */
4697 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4698 sym_op->xform->next = NULL;
4699 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4700 sym_op->xform->aead.op = aead_op;
4701 sym_op->xform->aead.key.data = key;
4702 sym_op->xform->aead.key.length = key_len;
4703 sym_op->xform->aead.iv.offset = IV_OFFSET;
4704 sym_op->xform->aead.iv.length = iv_len;
4705 sym_op->xform->aead.digest_length = auth_len;
4706 sym_op->xform->aead.add_auth_data_length = aad_len;
4708 TEST_HEXDUMP(stdout, "key:", key, key_len);
4714 create_gcm_operation(enum rte_crypto_aead_operation op,
4715 const struct gcm_test_data *tdata)
4717 struct crypto_testsuite_params *ts_params = &testsuite_params;
4718 struct crypto_unittest_params *ut_params = &unittest_params;
4720 uint8_t *plaintext, *ciphertext;
4721 unsigned int aad_pad_len, plaintext_pad_len;
4723 /* Generate Crypto op data structure */
4724 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4725 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4726 TEST_ASSERT_NOT_NULL(ut_params->op,
4727 "Failed to allocate symmetric crypto operation struct");
4729 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4731 /* Append aad data */
4732 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4733 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4735 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4736 "no room to append aad");
4738 sym_op->aead.aad.phys_addr =
4739 rte_pktmbuf_mtophys(ut_params->ibuf);
4740 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4741 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4744 /* Append IV at the end of the crypto operation*/
4745 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4746 uint8_t *, IV_OFFSET);
4748 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4749 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4752 /* Append plaintext/ciphertext */
4753 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4754 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4755 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4757 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4759 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4760 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4761 tdata->plaintext.len);
4763 if (ut_params->obuf) {
4764 ciphertext = (uint8_t *)rte_pktmbuf_append(
4766 plaintext_pad_len + aad_pad_len);
4767 TEST_ASSERT_NOT_NULL(ciphertext,
4768 "no room to append ciphertext");
4770 memset(ciphertext + aad_pad_len, 0,
4771 tdata->ciphertext.len);
4774 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4775 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4777 TEST_ASSERT_NOT_NULL(ciphertext,
4778 "no room to append ciphertext");
4780 memcpy(ciphertext, tdata->ciphertext.data,
4781 tdata->ciphertext.len);
4782 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4783 tdata->ciphertext.len);
4785 if (ut_params->obuf) {
4786 plaintext = (uint8_t *)rte_pktmbuf_append(
4788 plaintext_pad_len + aad_pad_len);
4789 TEST_ASSERT_NOT_NULL(plaintext,
4790 "no room to append plaintext");
4792 memset(plaintext + aad_pad_len, 0,
4793 tdata->plaintext.len);
4797 /* Append digest data */
4798 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4799 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4800 ut_params->obuf ? ut_params->obuf :
4802 tdata->auth_tag.len);
4803 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4804 "no room to append digest");
4805 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4806 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4807 ut_params->obuf ? ut_params->obuf :
4812 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4813 ut_params->ibuf, tdata->auth_tag.len);
4814 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4815 "no room to append digest");
4816 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4818 plaintext_pad_len + aad_pad_len);
4820 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4821 tdata->auth_tag.len);
4822 TEST_HEXDUMP(stdout, "digest:",
4823 sym_op->aead.digest.data,
4824 tdata->auth_tag.len);
4827 sym_op->aead.data.length = tdata->plaintext.len;
4828 sym_op->aead.data.offset = aad_pad_len;
4834 test_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4836 struct crypto_testsuite_params *ts_params = &testsuite_params;
4837 struct crypto_unittest_params *ut_params = &unittest_params;
4840 uint8_t *ciphertext, *auth_tag;
4841 uint16_t plaintext_pad_len;
4844 /* Create GCM session */
4845 retval = create_gcm_session(ts_params->valid_devs[0],
4846 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4847 tdata->key.data, tdata->key.len,
4848 tdata->aad.len, tdata->auth_tag.len,
4853 if (tdata->aad.len > MBUF_SIZE) {
4854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4855 /* Populate full size of add data */
4856 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4857 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4861 /* clear mbuf payload */
4862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4863 rte_pktmbuf_tailroom(ut_params->ibuf));
4865 /* Create GCM operation */
4866 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4872 ut_params->op->sym->m_src = ut_params->ibuf;
4874 /* Process crypto operation */
4875 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4876 ut_params->op), "failed to process sym crypto op");
4878 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4879 "crypto op processing failed");
4881 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4883 if (ut_params->op->sym->m_dst) {
4884 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4886 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4887 uint8_t *, plaintext_pad_len);
4889 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4891 ut_params->op->sym->cipher.data.offset);
4892 auth_tag = ciphertext + plaintext_pad_len;
4895 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4896 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4901 tdata->ciphertext.data,
4902 tdata->ciphertext.len,
4903 "GCM Ciphertext data not as expected");
4905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4907 tdata->auth_tag.data,
4908 tdata->auth_tag.len,
4909 "GCM Generated auth tag not as expected");
4916 test_AES_GCM_authenticated_encryption_test_case_1(void)
4918 return test_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4922 test_AES_GCM_authenticated_encryption_test_case_2(void)
4924 return test_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4928 test_AES_GCM_authenticated_encryption_test_case_3(void)
4930 return test_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4934 test_AES_GCM_authenticated_encryption_test_case_4(void)
4936 return test_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4940 test_AES_GCM_authenticated_encryption_test_case_5(void)
4942 return test_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4946 test_AES_GCM_authenticated_encryption_test_case_6(void)
4948 return test_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4952 test_AES_GCM_authenticated_encryption_test_case_7(void)
4954 return test_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4958 test_AES_GCM_auth_encryption_test_case_192_1(void)
4960 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_1);
4964 test_AES_GCM_auth_encryption_test_case_192_2(void)
4966 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_2);
4970 test_AES_GCM_auth_encryption_test_case_192_3(void)
4972 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_3);
4976 test_AES_GCM_auth_encryption_test_case_192_4(void)
4978 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_4);
4982 test_AES_GCM_auth_encryption_test_case_192_5(void)
4984 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_5);
4988 test_AES_GCM_auth_encryption_test_case_192_6(void)
4990 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_6);
4994 test_AES_GCM_auth_encryption_test_case_192_7(void)
4996 return test_AES_GCM_authenticated_encryption(&gcm_test_case_192_7);
5000 test_AES_GCM_auth_encryption_test_case_256_1(void)
5002 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
5006 test_AES_GCM_auth_encryption_test_case_256_2(void)
5008 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
5012 test_AES_GCM_auth_encryption_test_case_256_3(void)
5014 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
5018 test_AES_GCM_auth_encryption_test_case_256_4(void)
5020 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
5024 test_AES_GCM_auth_encryption_test_case_256_5(void)
5026 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
5030 test_AES_GCM_auth_encryption_test_case_256_6(void)
5032 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
5036 test_AES_GCM_auth_encryption_test_case_256_7(void)
5038 return test_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
5042 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5044 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
5048 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5050 return test_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
5054 test_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
5056 struct crypto_testsuite_params *ts_params = &testsuite_params;
5057 struct crypto_unittest_params *ut_params = &unittest_params;
5063 /* Create GCM session */
5064 retval = create_gcm_session(ts_params->valid_devs[0],
5065 RTE_CRYPTO_AEAD_OP_DECRYPT,
5066 tdata->key.data, tdata->key.len,
5067 tdata->aad.len, tdata->auth_tag.len,
5072 /* alloc mbuf and set payload */
5073 if (tdata->aad.len > MBUF_SIZE) {
5074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5075 /* Populate full size of add data */
5076 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5077 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5079 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5082 rte_pktmbuf_tailroom(ut_params->ibuf));
5084 /* Create GCM operation */
5085 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5089 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5091 ut_params->op->sym->m_src = ut_params->ibuf;
5093 /* Process crypto operation */
5094 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5095 ut_params->op), "failed to process sym crypto op");
5097 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5098 "crypto op processing failed");
5100 if (ut_params->op->sym->m_dst)
5101 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5104 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5106 ut_params->op->sym->cipher.data.offset);
5108 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5113 tdata->plaintext.data,
5114 tdata->plaintext.len,
5115 "GCM plaintext data not as expected");
5117 TEST_ASSERT_EQUAL(ut_params->op->status,
5118 RTE_CRYPTO_OP_STATUS_SUCCESS,
5119 "GCM authentication failed");
5124 test_AES_GCM_authenticated_decryption_test_case_1(void)
5126 return test_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5130 test_AES_GCM_authenticated_decryption_test_case_2(void)
5132 return test_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5136 test_AES_GCM_authenticated_decryption_test_case_3(void)
5138 return test_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5142 test_AES_GCM_authenticated_decryption_test_case_4(void)
5144 return test_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5148 test_AES_GCM_authenticated_decryption_test_case_5(void)
5150 return test_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5154 test_AES_GCM_authenticated_decryption_test_case_6(void)
5156 return test_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5160 test_AES_GCM_authenticated_decryption_test_case_7(void)
5162 return test_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5166 test_AES_GCM_auth_decryption_test_case_192_1(void)
5168 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_1);
5172 test_AES_GCM_auth_decryption_test_case_192_2(void)
5174 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_2);
5178 test_AES_GCM_auth_decryption_test_case_192_3(void)
5180 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_3);
5184 test_AES_GCM_auth_decryption_test_case_192_4(void)
5186 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_4);
5190 test_AES_GCM_auth_decryption_test_case_192_5(void)
5192 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_5);
5196 test_AES_GCM_auth_decryption_test_case_192_6(void)
5198 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_6);
5202 test_AES_GCM_auth_decryption_test_case_192_7(void)
5204 return test_AES_GCM_authenticated_decryption(&gcm_test_case_192_7);
5208 test_AES_GCM_auth_decryption_test_case_256_1(void)
5210 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5214 test_AES_GCM_auth_decryption_test_case_256_2(void)
5216 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5220 test_AES_GCM_auth_decryption_test_case_256_3(void)
5222 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5226 test_AES_GCM_auth_decryption_test_case_256_4(void)
5228 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5232 test_AES_GCM_auth_decryption_test_case_256_5(void)
5234 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5238 test_AES_GCM_auth_decryption_test_case_256_6(void)
5240 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5244 test_AES_GCM_auth_decryption_test_case_256_7(void)
5246 return test_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5250 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5252 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5256 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5258 return test_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5262 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5264 struct crypto_testsuite_params *ts_params = &testsuite_params;
5265 struct crypto_unittest_params *ut_params = &unittest_params;
5268 uint8_t *ciphertext, *auth_tag;
5269 uint16_t plaintext_pad_len;
5271 /* Create GCM session */
5272 retval = create_gcm_session(ts_params->valid_devs[0],
5273 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5274 tdata->key.data, tdata->key.len,
5275 tdata->aad.len, tdata->auth_tag.len,
5280 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5281 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5283 /* clear mbuf payload */
5284 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5285 rte_pktmbuf_tailroom(ut_params->ibuf));
5286 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5287 rte_pktmbuf_tailroom(ut_params->obuf));
5289 /* Create GCM operation */
5290 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5294 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5296 ut_params->op->sym->m_src = ut_params->ibuf;
5297 ut_params->op->sym->m_dst = ut_params->obuf;
5299 /* Process crypto operation */
5300 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5301 ut_params->op), "failed to process sym crypto op");
5303 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5304 "crypto op processing failed");
5306 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5308 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5309 ut_params->op->sym->cipher.data.offset);
5310 auth_tag = ciphertext + plaintext_pad_len;
5312 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5313 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5318 tdata->ciphertext.data,
5319 tdata->ciphertext.len,
5320 "GCM Ciphertext data not as expected");
5322 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5324 tdata->auth_tag.data,
5325 tdata->auth_tag.len,
5326 "GCM Generated auth tag not as expected");
5333 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5335 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5339 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5341 struct crypto_testsuite_params *ts_params = &testsuite_params;
5342 struct crypto_unittest_params *ut_params = &unittest_params;
5347 /* Create GCM session */
5348 retval = create_gcm_session(ts_params->valid_devs[0],
5349 RTE_CRYPTO_AEAD_OP_DECRYPT,
5350 tdata->key.data, tdata->key.len,
5351 tdata->aad.len, tdata->auth_tag.len,
5356 /* alloc mbuf and set payload */
5357 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5358 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5360 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5361 rte_pktmbuf_tailroom(ut_params->ibuf));
5362 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5363 rte_pktmbuf_tailroom(ut_params->obuf));
5365 /* Create GCM operation */
5366 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5370 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5372 ut_params->op->sym->m_src = ut_params->ibuf;
5373 ut_params->op->sym->m_dst = ut_params->obuf;
5375 /* Process crypto operation */
5376 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5377 ut_params->op), "failed to process sym crypto op");
5379 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5380 "crypto op processing failed");
5382 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5383 ut_params->op->sym->cipher.data.offset);
5385 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5388 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5390 tdata->plaintext.data,
5391 tdata->plaintext.len,
5392 "GCM plaintext data not as expected");
5394 TEST_ASSERT_EQUAL(ut_params->op->status,
5395 RTE_CRYPTO_OP_STATUS_SUCCESS,
5396 "GCM authentication failed");
5401 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5403 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5407 test_AES_GCM_authenticated_encryption_sessionless(
5408 const struct gcm_test_data *tdata)
5410 struct crypto_testsuite_params *ts_params = &testsuite_params;
5411 struct crypto_unittest_params *ut_params = &unittest_params;
5414 uint8_t *ciphertext, *auth_tag;
5415 uint16_t plaintext_pad_len;
5416 uint8_t key[tdata->key.len + 1];
5418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5420 /* clear mbuf payload */
5421 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5422 rte_pktmbuf_tailroom(ut_params->ibuf));
5424 /* Create GCM operation */
5425 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5429 /* Create GCM xforms */
5430 memcpy(key, tdata->key.data, tdata->key.len);
5431 retval = create_gcm_xforms(ut_params->op,
5432 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5433 key, tdata->key.len,
5434 tdata->aad.len, tdata->auth_tag.len,
5439 ut_params->op->sym->m_src = ut_params->ibuf;
5441 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5442 RTE_CRYPTO_OP_SESSIONLESS,
5443 "crypto op session type not sessionless");
5445 /* Process crypto operation */
5446 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5447 ut_params->op), "failed to process sym crypto op");
5449 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5451 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5452 "crypto op status not success");
5454 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5456 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5457 ut_params->op->sym->cipher.data.offset);
5458 auth_tag = ciphertext + plaintext_pad_len;
5460 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5461 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5464 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5466 tdata->ciphertext.data,
5467 tdata->ciphertext.len,
5468 "GCM Ciphertext data not as expected");
5470 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5472 tdata->auth_tag.data,
5473 tdata->auth_tag.len,
5474 "GCM Generated auth tag not as expected");
5481 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5483 return test_AES_GCM_authenticated_encryption_sessionless(
5488 test_AES_GCM_authenticated_decryption_sessionless(
5489 const struct gcm_test_data *tdata)
5491 struct crypto_testsuite_params *ts_params = &testsuite_params;
5492 struct crypto_unittest_params *ut_params = &unittest_params;
5496 uint8_t key[tdata->key.len + 1];
5498 /* alloc mbuf and set payload */
5499 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5501 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5502 rte_pktmbuf_tailroom(ut_params->ibuf));
5504 /* Create GCM operation */
5505 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5509 /* Create GCM xforms */
5510 memcpy(key, tdata->key.data, tdata->key.len);
5511 retval = create_gcm_xforms(ut_params->op,
5512 RTE_CRYPTO_AEAD_OP_DECRYPT,
5513 key, tdata->key.len,
5514 tdata->aad.len, tdata->auth_tag.len,
5519 ut_params->op->sym->m_src = ut_params->ibuf;
5521 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5522 RTE_CRYPTO_OP_SESSIONLESS,
5523 "crypto op session type not sessionless");
5525 /* Process crypto operation */
5526 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5527 ut_params->op), "failed to process sym crypto op");
5529 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5531 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5532 "crypto op status not success");
5534 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5535 ut_params->op->sym->cipher.data.offset);
5537 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5540 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5542 tdata->plaintext.data,
5543 tdata->plaintext.len,
5544 "GCM plaintext data not as expected");
5546 TEST_ASSERT_EQUAL(ut_params->op->status,
5547 RTE_CRYPTO_OP_STATUS_SUCCESS,
5548 "GCM authentication failed");
5553 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5555 return test_AES_GCM_authenticated_decryption_sessionless(
5562 struct crypto_testsuite_params *ts_params = &testsuite_params;
5563 struct rte_cryptodev_stats stats;
5564 struct rte_cryptodev *dev;
5565 cryptodev_stats_get_t temp_pfn;
5567 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5568 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5569 &stats) == -ENODEV),
5570 "rte_cryptodev_stats_get invalid dev failed");
5571 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5572 "rte_cryptodev_stats_get invalid Param failed");
5573 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5574 temp_pfn = dev->dev_ops->stats_get;
5575 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5576 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5578 "rte_cryptodev_stats_get invalid Param failed");
5579 dev->dev_ops->stats_get = temp_pfn;
5581 /* Test expected values */
5583 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5585 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5587 "rte_cryptodev_stats_get failed");
5588 TEST_ASSERT((stats.enqueued_count == 1),
5589 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5590 TEST_ASSERT((stats.dequeued_count == 1),
5591 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5592 TEST_ASSERT((stats.enqueue_err_count == 0),
5593 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5594 TEST_ASSERT((stats.dequeue_err_count == 0),
5595 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5597 /* invalid device but should ignore and not reset device stats*/
5598 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5599 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5601 "rte_cryptodev_stats_get failed");
5602 TEST_ASSERT((stats.enqueued_count == 1),
5603 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5605 /* check that a valid reset clears stats */
5606 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5607 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5609 "rte_cryptodev_stats_get failed");
5610 TEST_ASSERT((stats.enqueued_count == 0),
5611 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5612 TEST_ASSERT((stats.dequeued_count == 0),
5613 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5615 return TEST_SUCCESS;
5618 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5619 struct crypto_unittest_params *ut_params,
5620 enum rte_crypto_auth_operation op,
5621 const struct HMAC_MD5_vector *test_case)
5625 memcpy(key, test_case->key.data, test_case->key.len);
5627 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5628 ut_params->auth_xform.next = NULL;
5629 ut_params->auth_xform.auth.op = op;
5631 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5633 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5634 ut_params->auth_xform.auth.key.length = test_case->key.len;
5635 ut_params->auth_xform.auth.key.data = key;
5637 ut_params->sess = rte_cryptodev_sym_session_create(
5638 ts_params->valid_devs[0], &ut_params->auth_xform);
5640 if (ut_params->sess == NULL)
5643 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5645 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5646 rte_pktmbuf_tailroom(ut_params->ibuf));
5651 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5652 const struct HMAC_MD5_vector *test_case,
5653 uint8_t **plaintext)
5655 uint16_t plaintext_pad_len;
5657 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5659 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5662 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5664 memcpy(*plaintext, test_case->plaintext.data,
5665 test_case->plaintext.len);
5667 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5668 ut_params->ibuf, MD5_DIGEST_LEN);
5669 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5670 "no room to append digest");
5671 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5672 ut_params->ibuf, plaintext_pad_len);
5674 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5675 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5676 test_case->auth_tag.len);
5679 sym_op->auth.data.offset = 0;
5680 sym_op->auth.data.length = test_case->plaintext.len;
5682 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5683 ut_params->op->sym->m_src = ut_params->ibuf;
5689 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5691 uint16_t plaintext_pad_len;
5692 uint8_t *plaintext, *auth_tag;
5694 struct crypto_testsuite_params *ts_params = &testsuite_params;
5695 struct crypto_unittest_params *ut_params = &unittest_params;
5697 if (MD5_HMAC_create_session(ts_params, ut_params,
5698 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5701 /* Generate Crypto op data structure */
5702 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5703 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5704 TEST_ASSERT_NOT_NULL(ut_params->op,
5705 "Failed to allocate symmetric crypto operation struct");
5707 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5710 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5713 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5714 ut_params->op), "failed to process sym crypto op");
5716 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5717 "crypto op processing failed");
5719 if (ut_params->op->sym->m_dst) {
5720 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5721 uint8_t *, plaintext_pad_len);
5723 auth_tag = plaintext + plaintext_pad_len;
5726 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5728 test_case->auth_tag.data,
5729 test_case->auth_tag.len,
5730 "HMAC_MD5 generated tag not as expected");
5732 return TEST_SUCCESS;
5736 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5740 struct crypto_testsuite_params *ts_params = &testsuite_params;
5741 struct crypto_unittest_params *ut_params = &unittest_params;
5743 if (MD5_HMAC_create_session(ts_params, ut_params,
5744 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5748 /* Generate Crypto op data structure */
5749 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5750 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5751 TEST_ASSERT_NOT_NULL(ut_params->op,
5752 "Failed to allocate symmetric crypto operation struct");
5754 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5757 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5758 ut_params->op), "failed to process sym crypto op");
5760 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5761 "HMAC_MD5 crypto op processing failed");
5763 return TEST_SUCCESS;
5767 test_MD5_HMAC_generate_case_1(void)
5769 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5773 test_MD5_HMAC_verify_case_1(void)
5775 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5779 test_MD5_HMAC_generate_case_2(void)
5781 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5785 test_MD5_HMAC_verify_case_2(void)
5787 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5791 test_multi_session(void)
5793 struct crypto_testsuite_params *ts_params = &testsuite_params;
5794 struct crypto_unittest_params *ut_params = &unittest_params;
5796 struct rte_cryptodev_info dev_info;
5797 struct rte_cryptodev_sym_session **sessions;
5801 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5802 aes_cbc_key, hmac_sha512_key);
5805 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5807 sessions = rte_malloc(NULL,
5808 (sizeof(struct rte_cryptodev_sym_session *) *
5809 dev_info.sym.max_nb_sessions) + 1, 0);
5811 /* Create multiple crypto sessions*/
5812 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5813 sessions[i] = rte_cryptodev_sym_session_create(
5814 ts_params->valid_devs[0],
5815 &ut_params->auth_xform);
5816 TEST_ASSERT_NOT_NULL(sessions[i],
5817 "Session creation failed at session number %u",
5820 /* Attempt to send a request on each session */
5821 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5825 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5826 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5828 "Failed to perform decrypt on request number %u.", i);
5829 /* free crypto operation structure */
5831 rte_crypto_op_free(ut_params->op);
5834 * free mbuf - both obuf and ibuf are usually the same,
5835 * so check if they point at the same address is necessary,
5836 * to avoid freeing the mbuf twice.
5838 if (ut_params->obuf) {
5839 rte_pktmbuf_free(ut_params->obuf);
5840 if (ut_params->ibuf == ut_params->obuf)
5841 ut_params->ibuf = 0;
5842 ut_params->obuf = 0;
5844 if (ut_params->ibuf) {
5845 rte_pktmbuf_free(ut_params->ibuf);
5846 ut_params->ibuf = 0;
5850 /* Next session create should fail */
5851 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5852 &ut_params->auth_xform);
5853 TEST_ASSERT_NULL(sessions[i],
5854 "Session creation succeeded unexpectedly!");
5856 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5857 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5862 return TEST_SUCCESS;
5865 struct multi_session_params {
5866 struct crypto_unittest_params ut_params;
5867 uint8_t *cipher_key;
5869 const uint8_t *cipher;
5870 const uint8_t *digest;
5874 #define MB_SESSION_NUMBER 3
5877 test_multi_session_random_usage(void)
5879 struct crypto_testsuite_params *ts_params = &testsuite_params;
5880 struct rte_cryptodev_info dev_info;
5881 struct rte_cryptodev_sym_session **sessions;
5883 struct multi_session_params ut_paramz[] = {
5886 .cipher_key = ms_aes_cbc_key0,
5887 .hmac_key = ms_hmac_key0,
5888 .cipher = ms_aes_cbc_cipher0,
5889 .digest = ms_hmac_digest0,
5890 .iv = ms_aes_cbc_iv0
5893 .cipher_key = ms_aes_cbc_key1,
5894 .hmac_key = ms_hmac_key1,
5895 .cipher = ms_aes_cbc_cipher1,
5896 .digest = ms_hmac_digest1,
5897 .iv = ms_aes_cbc_iv1
5900 .cipher_key = ms_aes_cbc_key2,
5901 .hmac_key = ms_hmac_key2,
5902 .cipher = ms_aes_cbc_cipher2,
5903 .digest = ms_hmac_digest2,
5904 .iv = ms_aes_cbc_iv2
5909 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5911 sessions = rte_malloc(NULL,
5912 (sizeof(struct rte_cryptodev_sym_session *)
5913 * dev_info.sym.max_nb_sessions) + 1, 0);
5915 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5916 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5917 sizeof(struct crypto_unittest_params));
5919 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5920 &ut_paramz[i].ut_params,
5921 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5923 /* Create multiple crypto sessions*/
5924 sessions[i] = rte_cryptodev_sym_session_create(
5925 ts_params->valid_devs[0],
5926 &ut_paramz[i].ut_params.auth_xform);
5928 TEST_ASSERT_NOT_NULL(sessions[i],
5929 "Session creation failed at session number %u",
5935 for (i = 0; i < 40000; i++) {
5937 j = rand() % MB_SESSION_NUMBER;
5939 TEST_ASSERT_SUCCESS(
5940 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5942 &ut_paramz[j].ut_params,
5943 ts_params, ut_paramz[j].cipher,
5944 ut_paramz[j].digest,
5946 "Failed to perform decrypt on request number %u.", i);
5948 if (ut_paramz[j].ut_params.op)
5949 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5952 * free mbuf - both obuf and ibuf are usually the same,
5953 * so check if they point at the same address is necessary,
5954 * to avoid freeing the mbuf twice.
5956 if (ut_paramz[j].ut_params.obuf) {
5957 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5958 if (ut_paramz[j].ut_params.ibuf
5959 == ut_paramz[j].ut_params.obuf)
5960 ut_paramz[j].ut_params.ibuf = 0;
5961 ut_paramz[j].ut_params.obuf = 0;
5963 if (ut_paramz[j].ut_params.ibuf) {
5964 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5965 ut_paramz[j].ut_params.ibuf = 0;
5969 for (i = 0; i < MB_SESSION_NUMBER; i++)
5970 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5975 return TEST_SUCCESS;
5979 test_null_cipher_only_operation(void)
5981 struct crypto_testsuite_params *ts_params = &testsuite_params;
5982 struct crypto_unittest_params *ut_params = &unittest_params;
5984 /* Generate test mbuf data and space for digest */
5985 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5986 catch_22_quote, QUOTE_512_BYTES, 0);
5988 /* Setup Cipher Parameters */
5989 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5990 ut_params->cipher_xform.next = NULL;
5992 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5993 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5995 /* Create Crypto session*/
5996 ut_params->sess = rte_cryptodev_sym_session_create(
5997 ts_params->valid_devs[0], &ut_params->cipher_xform);
5998 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6000 /* Generate Crypto op data structure */
6001 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6002 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6003 TEST_ASSERT_NOT_NULL(ut_params->op,
6004 "Failed to allocate symmetric crypto operation struct");
6006 /* Set crypto operation data parameters */
6007 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6009 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6011 /* set crypto operation source mbuf */
6012 sym_op->m_src = ut_params->ibuf;
6014 sym_op->cipher.data.offset = 0;
6015 sym_op->cipher.data.length = QUOTE_512_BYTES;
6017 /* Process crypto operation */
6018 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6020 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6022 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6023 "crypto operation processing failed");
6026 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6027 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6030 "Ciphertext data not as expected");
6032 return TEST_SUCCESS;
6036 test_null_auth_only_operation(void)
6038 struct crypto_testsuite_params *ts_params = &testsuite_params;
6039 struct crypto_unittest_params *ut_params = &unittest_params;
6041 /* Generate test mbuf data and space for digest */
6042 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6043 catch_22_quote, QUOTE_512_BYTES, 0);
6045 /* Setup HMAC Parameters */
6046 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6047 ut_params->auth_xform.next = NULL;
6049 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6050 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6052 /* Create Crypto session*/
6053 ut_params->sess = rte_cryptodev_sym_session_create(
6054 ts_params->valid_devs[0], &ut_params->auth_xform);
6055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6057 /* Generate Crypto op data structure */
6058 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6059 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6060 TEST_ASSERT_NOT_NULL(ut_params->op,
6061 "Failed to allocate symmetric crypto operation struct");
6063 /* Set crypto operation data parameters */
6064 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6066 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6068 sym_op->m_src = ut_params->ibuf;
6070 sym_op->auth.data.offset = 0;
6071 sym_op->auth.data.length = QUOTE_512_BYTES;
6073 /* Process crypto operation */
6074 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6076 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6078 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6079 "crypto operation processing failed");
6081 return TEST_SUCCESS;
6085 test_null_cipher_auth_operation(void)
6087 struct crypto_testsuite_params *ts_params = &testsuite_params;
6088 struct crypto_unittest_params *ut_params = &unittest_params;
6090 /* Generate test mbuf data and space for digest */
6091 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6092 catch_22_quote, QUOTE_512_BYTES, 0);
6094 /* Setup Cipher Parameters */
6095 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6096 ut_params->cipher_xform.next = &ut_params->auth_xform;
6098 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6099 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6101 /* Setup HMAC Parameters */
6102 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6103 ut_params->auth_xform.next = NULL;
6105 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6106 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6108 /* Create Crypto session*/
6109 ut_params->sess = rte_cryptodev_sym_session_create(
6110 ts_params->valid_devs[0], &ut_params->cipher_xform);
6111 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6113 /* Generate Crypto op data structure */
6114 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6115 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6116 TEST_ASSERT_NOT_NULL(ut_params->op,
6117 "Failed to allocate symmetric crypto operation struct");
6119 /* Set crypto operation data parameters */
6120 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6122 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6124 sym_op->m_src = ut_params->ibuf;
6126 sym_op->cipher.data.offset = 0;
6127 sym_op->cipher.data.length = QUOTE_512_BYTES;
6129 sym_op->auth.data.offset = 0;
6130 sym_op->auth.data.length = QUOTE_512_BYTES;
6132 /* Process crypto operation */
6133 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6135 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6137 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6138 "crypto operation processing failed");
6141 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6142 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6145 "Ciphertext data not as expected");
6147 return TEST_SUCCESS;
6151 test_null_auth_cipher_operation(void)
6153 struct crypto_testsuite_params *ts_params = &testsuite_params;
6154 struct crypto_unittest_params *ut_params = &unittest_params;
6156 /* Generate test mbuf data and space for digest */
6157 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6158 catch_22_quote, QUOTE_512_BYTES, 0);
6160 /* Setup Cipher Parameters */
6161 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6162 ut_params->cipher_xform.next = NULL;
6164 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6165 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6167 /* Setup HMAC Parameters */
6168 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6169 ut_params->auth_xform.next = &ut_params->cipher_xform;
6171 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6172 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6174 /* Create Crypto session*/
6175 ut_params->sess = rte_cryptodev_sym_session_create(
6176 ts_params->valid_devs[0], &ut_params->cipher_xform);
6177 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6179 /* Generate Crypto op data structure */
6180 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6181 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6182 TEST_ASSERT_NOT_NULL(ut_params->op,
6183 "Failed to allocate symmetric crypto operation struct");
6185 /* Set crypto operation data parameters */
6186 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6188 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6190 sym_op->m_src = ut_params->ibuf;
6192 sym_op->cipher.data.offset = 0;
6193 sym_op->cipher.data.length = QUOTE_512_BYTES;
6195 sym_op->auth.data.offset = 0;
6196 sym_op->auth.data.length = QUOTE_512_BYTES;
6198 /* Process crypto operation */
6199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6201 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6203 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6204 "crypto operation processing failed");
6207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6208 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6211 "Ciphertext data not as expected");
6213 return TEST_SUCCESS;
6218 test_null_invalid_operation(void)
6220 struct crypto_testsuite_params *ts_params = &testsuite_params;
6221 struct crypto_unittest_params *ut_params = &unittest_params;
6223 /* Setup Cipher Parameters */
6224 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6225 ut_params->cipher_xform.next = NULL;
6227 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6228 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6230 /* Create Crypto session*/
6231 ut_params->sess = rte_cryptodev_sym_session_create(
6232 ts_params->valid_devs[0], &ut_params->cipher_xform);
6233 TEST_ASSERT_NULL(ut_params->sess,
6234 "Session creation succeeded unexpectedly");
6237 /* Setup HMAC Parameters */
6238 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6239 ut_params->auth_xform.next = NULL;
6241 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6242 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6244 /* Create Crypto session*/
6245 ut_params->sess = rte_cryptodev_sym_session_create(
6246 ts_params->valid_devs[0], &ut_params->auth_xform);
6247 TEST_ASSERT_NULL(ut_params->sess,
6248 "Session creation succeeded unexpectedly");
6250 return TEST_SUCCESS;
6254 #define NULL_BURST_LENGTH (32)
6257 test_null_burst_operation(void)
6259 struct crypto_testsuite_params *ts_params = &testsuite_params;
6260 struct crypto_unittest_params *ut_params = &unittest_params;
6262 unsigned i, burst_len = NULL_BURST_LENGTH;
6264 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6265 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6267 /* Setup Cipher Parameters */
6268 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6269 ut_params->cipher_xform.next = &ut_params->auth_xform;
6271 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6272 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6274 /* Setup HMAC Parameters */
6275 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6276 ut_params->auth_xform.next = NULL;
6278 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6279 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6281 /* Create Crypto session*/
6282 ut_params->sess = rte_cryptodev_sym_session_create(
6283 ts_params->valid_devs[0], &ut_params->cipher_xform);
6284 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6286 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6287 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6288 burst_len, "failed to generate burst of crypto ops");
6290 /* Generate an operation for each mbuf in burst */
6291 for (i = 0; i < burst_len; i++) {
6292 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6294 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6296 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6300 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6302 burst[i]->sym->m_src = m;
6305 /* Process crypto operation */
6306 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6307 0, burst, burst_len),
6309 "Error enqueuing burst");
6311 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6312 0, burst_dequeued, burst_len),
6314 "Error dequeuing burst");
6317 for (i = 0; i < burst_len; i++) {
6319 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6320 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6322 "data not as expected");
6324 rte_pktmbuf_free(burst[i]->sym->m_src);
6325 rte_crypto_op_free(burst[i]);
6328 return TEST_SUCCESS;
6332 generate_gmac_large_plaintext(uint8_t *data)
6336 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6337 memcpy(&data[i], &data[0], 32);
6341 create_gmac_operation(enum rte_crypto_auth_operation op,
6342 const struct gmac_test_data *tdata)
6344 struct crypto_testsuite_params *ts_params = &testsuite_params;
6345 struct crypto_unittest_params *ut_params = &unittest_params;
6346 struct rte_crypto_sym_op *sym_op;
6348 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6350 /* Generate Crypto op data structure */
6351 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6352 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6353 TEST_ASSERT_NOT_NULL(ut_params->op,
6354 "Failed to allocate symmetric crypto operation struct");
6356 sym_op = ut_params->op->sym;
6358 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6359 ut_params->ibuf, tdata->gmac_tag.len);
6360 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6361 "no room to append digest");
6363 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6364 ut_params->ibuf, plaintext_pad_len);
6366 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6367 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6368 tdata->gmac_tag.len);
6369 TEST_HEXDUMP(stdout, "digest:",
6370 sym_op->auth.digest.data,
6371 tdata->gmac_tag.len);
6374 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6375 uint8_t *, IV_OFFSET);
6377 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6379 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6381 sym_op->cipher.data.length = 0;
6382 sym_op->cipher.data.offset = 0;
6384 sym_op->auth.data.offset = 0;
6385 sym_op->auth.data.length = tdata->plaintext.len;
6390 static int create_gmac_session(uint8_t dev_id,
6391 const struct gmac_test_data *tdata,
6392 enum rte_crypto_auth_operation auth_op)
6394 uint8_t auth_key[tdata->key.len];
6396 struct crypto_unittest_params *ut_params = &unittest_params;
6398 memcpy(auth_key, tdata->key.data, tdata->key.len);
6400 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6401 ut_params->auth_xform.next = NULL;
6403 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6404 ut_params->auth_xform.auth.op = auth_op;
6405 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6406 ut_params->auth_xform.auth.key.length = tdata->key.len;
6407 ut_params->auth_xform.auth.key.data = auth_key;
6408 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6409 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6412 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6413 &ut_params->auth_xform);
6415 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6421 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6423 struct crypto_testsuite_params *ts_params = &testsuite_params;
6424 struct crypto_unittest_params *ut_params = &unittest_params;
6428 uint8_t *auth_tag, *plaintext;
6429 uint16_t plaintext_pad_len;
6431 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6432 "No GMAC length in the source data");
6434 retval = create_gmac_session(ts_params->valid_devs[0],
6435 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6440 if (tdata->plaintext.len > MBUF_SIZE)
6441 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6444 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6445 "Failed to allocate input buffer in mempool");
6447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6448 rte_pktmbuf_tailroom(ut_params->ibuf));
6450 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6452 * Runtime generate the large plain text instead of use hard code
6453 * plain text vector. It is done to avoid create huge source file
6454 * with the test vector.
6456 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6457 generate_gmac_large_plaintext(tdata->plaintext.data);
6459 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6461 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6463 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6464 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6465 tdata->plaintext.len);
6467 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6473 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6475 ut_params->op->sym->m_src = ut_params->ibuf;
6477 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6478 ut_params->op), "failed to process sym crypto op");
6480 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6481 "crypto op processing failed");
6483 if (ut_params->op->sym->m_dst) {
6484 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6485 uint8_t *, plaintext_pad_len);
6487 auth_tag = plaintext + plaintext_pad_len;
6490 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6492 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6494 tdata->gmac_tag.data,
6495 tdata->gmac_tag.len,
6496 "GMAC Generated auth tag not as expected");
6502 test_AES_GMAC_authentication_test_case_1(void)
6504 return test_AES_GMAC_authentication(&gmac_test_case_1);
6508 test_AES_GMAC_authentication_test_case_2(void)
6510 return test_AES_GMAC_authentication(&gmac_test_case_2);
6514 test_AES_GMAC_authentication_test_case_3(void)
6516 return test_AES_GMAC_authentication(&gmac_test_case_3);
6520 test_AES_GMAC_authentication_test_case_4(void)
6522 return test_AES_GMAC_authentication(&gmac_test_case_4);
6526 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6528 struct crypto_testsuite_params *ts_params = &testsuite_params;
6529 struct crypto_unittest_params *ut_params = &unittest_params;
6531 uint32_t plaintext_pad_len;
6534 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6535 "No GMAC length in the source data");
6537 retval = create_gmac_session(ts_params->valid_devs[0],
6538 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6543 if (tdata->plaintext.len > MBUF_SIZE)
6544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6546 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6547 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6548 "Failed to allocate input buffer in mempool");
6550 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6551 rte_pktmbuf_tailroom(ut_params->ibuf));
6553 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6556 * Runtime generate the large plain text instead of use hard code
6557 * plain text vector. It is done to avoid create huge source file
6558 * with the test vector.
6560 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6561 generate_gmac_large_plaintext(tdata->plaintext.data);
6563 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6565 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6567 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6568 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6569 tdata->plaintext.len);
6571 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6577 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6579 ut_params->op->sym->m_src = ut_params->ibuf;
6581 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6582 ut_params->op), "failed to process sym crypto op");
6584 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6585 "crypto op processing failed");
6592 test_AES_GMAC_authentication_verify_test_case_1(void)
6594 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6598 test_AES_GMAC_authentication_verify_test_case_2(void)
6600 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6604 test_AES_GMAC_authentication_verify_test_case_3(void)
6606 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6610 test_AES_GMAC_authentication_verify_test_case_4(void)
6612 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6615 struct test_crypto_vector {
6616 enum rte_crypto_cipher_algorithm crypto_algo;
6629 const uint8_t *data;
6634 const uint8_t *data;
6638 enum rte_crypto_auth_algorithm auth_algo;
6646 const uint8_t *data;
6656 static const struct test_crypto_vector
6657 hmac_sha1_test_crypto_vector = {
6658 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6660 .data = plaintext_hash,
6665 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6666 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6667 0xDE, 0xF4, 0xDE, 0xAD
6673 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6674 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6675 0x3F, 0x91, 0x64, 0x59
6681 static const struct test_crypto_vector
6682 aes128_gmac_test_vector = {
6683 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6685 .data = plaintext_hash,
6690 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6691 0x08, 0x09, 0x0A, 0x0B
6697 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6698 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6704 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6705 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6711 static const struct test_crypto_vector
6712 aes128cbc_hmac_sha1_test_vector = {
6713 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6716 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6717 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6723 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6724 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6729 .data = plaintext_hash,
6733 .data = ciphertext512_aes128cbc,
6736 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6739 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6740 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6741 0xDE, 0xF4, 0xDE, 0xAD
6747 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6748 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6749 0x18, 0x8C, 0x1D, 0x32
6756 data_corruption(uint8_t *data)
6762 tag_corruption(uint8_t *data, unsigned int tag_offset)
6764 data[tag_offset] += 1;
6768 create_auth_session(struct crypto_unittest_params *ut_params,
6770 const struct test_crypto_vector *reference,
6771 enum rte_crypto_auth_operation auth_op)
6773 uint8_t auth_key[reference->auth_key.len + 1];
6775 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6777 /* Setup Authentication Parameters */
6778 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6779 ut_params->auth_xform.auth.op = auth_op;
6780 ut_params->auth_xform.next = NULL;
6781 ut_params->auth_xform.auth.algo = reference->auth_algo;
6782 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6783 ut_params->auth_xform.auth.key.data = auth_key;
6784 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6786 /* Create Crypto session*/
6787 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6788 &ut_params->auth_xform);
6790 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6796 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6798 const struct test_crypto_vector *reference,
6799 enum rte_crypto_auth_operation auth_op,
6800 enum rte_crypto_cipher_operation cipher_op)
6802 uint8_t cipher_key[reference->cipher_key.len + 1];
6803 uint8_t auth_key[reference->auth_key.len + 1];
6805 memcpy(cipher_key, reference->cipher_key.data,
6806 reference->cipher_key.len);
6807 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6809 /* Setup Authentication Parameters */
6810 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6811 ut_params->auth_xform.auth.op = auth_op;
6812 ut_params->auth_xform.auth.algo = reference->auth_algo;
6813 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6814 ut_params->auth_xform.auth.key.data = auth_key;
6815 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6817 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6818 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6819 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6821 ut_params->auth_xform.next = &ut_params->cipher_xform;
6823 /* Setup Cipher Parameters */
6824 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6825 ut_params->cipher_xform.next = NULL;
6826 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6827 ut_params->cipher_xform.cipher.op = cipher_op;
6828 ut_params->cipher_xform.cipher.key.data = cipher_key;
6829 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6830 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6831 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6834 /* Create Crypto session*/
6835 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6836 &ut_params->auth_xform);
6838 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6844 create_auth_operation(struct crypto_testsuite_params *ts_params,
6845 struct crypto_unittest_params *ut_params,
6846 const struct test_crypto_vector *reference,
6847 unsigned int auth_generate)
6849 /* Generate Crypto op data structure */
6850 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6851 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6852 TEST_ASSERT_NOT_NULL(ut_params->op,
6853 "Failed to allocate pktmbuf offload");
6855 /* Set crypto operation data parameters */
6856 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6858 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6860 /* set crypto operation source mbuf */
6861 sym_op->m_src = ut_params->ibuf;
6864 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6865 ut_params->ibuf, reference->digest.len);
6867 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6868 "no room to append auth tag");
6870 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6871 ut_params->ibuf, reference->plaintext.len);
6874 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6876 memcpy(sym_op->auth.digest.data,
6877 reference->digest.data,
6878 reference->digest.len);
6880 TEST_HEXDUMP(stdout, "digest:",
6881 sym_op->auth.digest.data,
6882 reference->digest.len);
6884 sym_op->auth.data.length = reference->plaintext.len;
6885 sym_op->auth.data.offset = 0;
6891 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6892 struct crypto_unittest_params *ut_params,
6893 const struct test_crypto_vector *reference,
6894 unsigned int auth_generate)
6896 /* Generate Crypto op data structure */
6897 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6898 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6899 TEST_ASSERT_NOT_NULL(ut_params->op,
6900 "Failed to allocate pktmbuf offload");
6902 /* Set crypto operation data parameters */
6903 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6905 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6907 /* set crypto operation source mbuf */
6908 sym_op->m_src = ut_params->ibuf;
6911 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6912 ut_params->ibuf, reference->digest.len);
6914 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6915 "no room to append auth tag");
6917 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6918 ut_params->ibuf, reference->ciphertext.len);
6921 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6923 memcpy(sym_op->auth.digest.data,
6924 reference->digest.data,
6925 reference->digest.len);
6927 TEST_HEXDUMP(stdout, "digest:",
6928 sym_op->auth.digest.data,
6929 reference->digest.len);
6931 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6932 reference->iv.data, reference->iv.len);
6934 sym_op->cipher.data.length = 0;
6935 sym_op->cipher.data.offset = 0;
6937 sym_op->auth.data.length = reference->plaintext.len;
6938 sym_op->auth.data.offset = 0;
6944 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6945 struct crypto_unittest_params *ut_params,
6946 const struct test_crypto_vector *reference,
6947 unsigned int auth_generate)
6949 /* Generate Crypto op data structure */
6950 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6951 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6952 TEST_ASSERT_NOT_NULL(ut_params->op,
6953 "Failed to allocate pktmbuf offload");
6955 /* Set crypto operation data parameters */
6956 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6958 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6960 /* set crypto operation source mbuf */
6961 sym_op->m_src = ut_params->ibuf;
6964 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6965 ut_params->ibuf, reference->digest.len);
6967 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6968 "no room to append auth tag");
6970 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6971 ut_params->ibuf, reference->ciphertext.len);
6974 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6976 memcpy(sym_op->auth.digest.data,
6977 reference->digest.data,
6978 reference->digest.len);
6980 TEST_HEXDUMP(stdout, "digest:",
6981 sym_op->auth.digest.data,
6982 reference->digest.len);
6984 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6985 reference->iv.data, reference->iv.len);
6987 sym_op->cipher.data.length = reference->ciphertext.len;
6988 sym_op->cipher.data.offset = 0;
6990 sym_op->auth.data.length = reference->ciphertext.len;
6991 sym_op->auth.data.offset = 0;
6997 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6998 struct crypto_unittest_params *ut_params,
6999 const struct test_crypto_vector *reference)
7001 return create_auth_operation(ts_params, ut_params, reference, 0);
7005 create_auth_verify_GMAC_operation(
7006 struct crypto_testsuite_params *ts_params,
7007 struct crypto_unittest_params *ut_params,
7008 const struct test_crypto_vector *reference)
7010 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7014 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7015 struct crypto_unittest_params *ut_params,
7016 const struct test_crypto_vector *reference)
7018 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7022 test_authentication_verify_fail_when_data_corruption(
7023 struct crypto_testsuite_params *ts_params,
7024 struct crypto_unittest_params *ut_params,
7025 const struct test_crypto_vector *reference,
7026 unsigned int data_corrupted)
7032 /* Create session */
7033 retval = create_auth_session(ut_params,
7034 ts_params->valid_devs[0],
7036 RTE_CRYPTO_AUTH_OP_VERIFY);
7040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7041 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7042 "Failed to allocate input buffer in mempool");
7044 /* clear mbuf payload */
7045 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7046 rte_pktmbuf_tailroom(ut_params->ibuf));
7048 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7049 reference->plaintext.len);
7050 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7051 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7053 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7055 /* Create operation */
7056 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7062 data_corruption(plaintext);
7064 tag_corruption(plaintext, reference->plaintext.len);
7066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7069 TEST_ASSERT_EQUAL(ut_params->op->status,
7070 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7071 "authentication not failed");
7073 ut_params->obuf = ut_params->op->sym->m_src;
7074 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7080 test_authentication_verify_GMAC_fail_when_corruption(
7081 struct crypto_testsuite_params *ts_params,
7082 struct crypto_unittest_params *ut_params,
7083 const struct test_crypto_vector *reference,
7084 unsigned int data_corrupted)
7089 /* Create session */
7090 retval = create_auth_cipher_session(ut_params,
7091 ts_params->valid_devs[0],
7093 RTE_CRYPTO_AUTH_OP_VERIFY,
7094 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7099 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7100 "Failed to allocate input buffer in mempool");
7102 /* clear mbuf payload */
7103 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7104 rte_pktmbuf_tailroom(ut_params->ibuf));
7106 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7107 reference->plaintext.len);
7108 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7109 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7111 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7113 /* Create operation */
7114 retval = create_auth_verify_GMAC_operation(ts_params,
7122 data_corruption(plaintext);
7124 tag_corruption(plaintext, reference->aad.len);
7126 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7128 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7129 TEST_ASSERT_EQUAL(ut_params->op->status,
7130 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7131 "authentication not failed");
7133 ut_params->obuf = ut_params->op->sym->m_src;
7134 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7140 test_authenticated_decryption_fail_when_corruption(
7141 struct crypto_testsuite_params *ts_params,
7142 struct crypto_unittest_params *ut_params,
7143 const struct test_crypto_vector *reference,
7144 unsigned int data_corrupted)
7148 uint8_t *ciphertext;
7150 /* Create session */
7151 retval = create_auth_cipher_session(ut_params,
7152 ts_params->valid_devs[0],
7154 RTE_CRYPTO_AUTH_OP_VERIFY,
7155 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7160 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7161 "Failed to allocate input buffer in mempool");
7163 /* clear mbuf payload */
7164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7165 rte_pktmbuf_tailroom(ut_params->ibuf));
7167 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7168 reference->ciphertext.len);
7169 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7170 memcpy(ciphertext, reference->ciphertext.data,
7171 reference->ciphertext.len);
7173 /* Create operation */
7174 retval = create_cipher_auth_verify_operation(ts_params,
7182 data_corruption(ciphertext);
7184 tag_corruption(ciphertext, reference->ciphertext.len);
7186 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7189 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7190 TEST_ASSERT_EQUAL(ut_params->op->status,
7191 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7192 "authentication not failed");
7194 ut_params->obuf = ut_params->op->sym->m_src;
7195 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7201 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7202 const struct gcm_test_data *tdata,
7203 void *digest_mem, uint64_t digest_phys)
7205 struct crypto_testsuite_params *ts_params = &testsuite_params;
7206 struct crypto_unittest_params *ut_params = &unittest_params;
7208 const unsigned int auth_tag_len = tdata->auth_tag.len;
7209 const unsigned int iv_len = tdata->iv.len;
7210 const unsigned int aad_len = tdata->aad.len;
7212 /* Generate Crypto op data structure */
7213 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7214 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7215 TEST_ASSERT_NOT_NULL(ut_params->op,
7216 "Failed to allocate symmetric crypto operation struct");
7218 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7220 sym_op->aead.digest.data = digest_mem;
7222 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7223 "no room to append digest");
7225 sym_op->aead.digest.phys_addr = digest_phys;
7227 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7228 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7230 TEST_HEXDUMP(stdout, "digest:",
7231 sym_op->aead.digest.data,
7235 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7236 uint8_t *, IV_OFFSET);
7238 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7240 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7241 ut_params->ibuf, aad_len);
7242 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7243 "no room to prepend aad");
7244 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7247 memset(sym_op->aead.aad.data, 0, aad_len);
7248 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7250 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7251 TEST_HEXDUMP(stdout, "aad:",
7252 sym_op->aead.aad.data, aad_len);
7254 sym_op->aead.data.length = tdata->plaintext.len;
7255 sym_op->aead.data.offset = aad_len;
7260 #define SGL_MAX_NO 16
7263 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7264 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7266 struct crypto_testsuite_params *ts_params = &testsuite_params;
7267 struct crypto_unittest_params *ut_params = &unittest_params;
7268 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7271 int to_trn_tbl[SGL_MAX_NO];
7273 unsigned int trn_data = 0;
7274 uint8_t *plaintext, *ciphertext, *auth_tag;
7276 if (fragsz > tdata->plaintext.len)
7277 fragsz = tdata->plaintext.len;
7279 uint16_t plaintext_len = fragsz;
7280 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7282 if (fragsz_oop > tdata->plaintext.len)
7283 frag_size_oop = tdata->plaintext.len;
7286 void *digest_mem = NULL;
7288 uint32_t prepend_len = tdata->aad.len;
7290 if (tdata->plaintext.len % fragsz != 0) {
7291 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7294 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7299 * For out-op-place we need to alloc another mbuf
7302 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7303 rte_pktmbuf_append(ut_params->obuf,
7304 frag_size_oop + prepend_len);
7305 buf_oop = ut_params->obuf;
7308 /* Create GCM session */
7309 retval = create_gcm_session(ts_params->valid_devs[0],
7310 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7311 tdata->key.data, tdata->key.len,
7312 tdata->aad.len, tdata->auth_tag.len,
7317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7319 /* clear mbuf payload */
7320 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7321 rte_pktmbuf_tailroom(ut_params->ibuf));
7323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7326 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7328 trn_data += plaintext_len;
7330 buf = ut_params->ibuf;
7333 * Loop until no more fragments
7336 while (trn_data < tdata->plaintext.len) {
7338 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7339 (tdata->plaintext.len - trn_data) : fragsz;
7341 to_trn_tbl[ecx++] = to_trn;
7343 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7346 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7347 rte_pktmbuf_tailroom(buf));
7350 if (oop && !fragsz_oop) {
7351 buf_last_oop = buf_oop->next =
7352 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7353 buf_oop = buf_oop->next;
7354 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7355 0, rte_pktmbuf_tailroom(buf_oop));
7356 rte_pktmbuf_append(buf_oop, to_trn);
7359 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7362 memcpy(plaintext, tdata->plaintext.data + trn_data,
7365 if (trn_data == tdata->plaintext.len) {
7368 digest_mem = rte_pktmbuf_append(buf_oop,
7369 tdata->auth_tag.len);
7371 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7372 tdata->auth_tag.len);
7376 uint64_t digest_phys = 0;
7378 ut_params->ibuf->nb_segs = segs;
7381 if (fragsz_oop && oop) {
7385 if (frag_size_oop == tdata->plaintext.len) {
7386 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7387 tdata->auth_tag.len);
7389 digest_phys = rte_pktmbuf_mtophys_offset(
7391 tdata->plaintext.len + prepend_len);
7394 trn_data = frag_size_oop;
7395 while (trn_data < tdata->plaintext.len) {
7398 (tdata->plaintext.len - trn_data <
7400 (tdata->plaintext.len - trn_data) :
7403 to_trn_tbl[ecx++] = to_trn;
7405 buf_last_oop = buf_oop->next =
7406 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7407 buf_oop = buf_oop->next;
7408 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7409 0, rte_pktmbuf_tailroom(buf_oop));
7410 rte_pktmbuf_append(buf_oop, to_trn);
7414 if (trn_data == tdata->plaintext.len) {
7415 digest_mem = rte_pktmbuf_append(buf_oop,
7416 tdata->auth_tag.len);
7420 ut_params->obuf->nb_segs = segs;
7424 * Place digest at the end of the last buffer
7427 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7428 if (oop && buf_last_oop)
7429 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7431 if (!digest_mem && !oop) {
7432 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7433 + tdata->auth_tag.len);
7434 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7435 tdata->plaintext.len);
7438 /* Create GCM opertaion */
7439 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7440 tdata, digest_mem, digest_phys);
7445 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7447 ut_params->op->sym->m_src = ut_params->ibuf;
7449 ut_params->op->sym->m_dst = ut_params->obuf;
7451 /* Process crypto operation */
7452 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7453 ut_params->op), "failed to process sym crypto op");
7455 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7456 "crypto op processing failed");
7459 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7460 uint8_t *, prepend_len);
7462 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7463 uint8_t *, prepend_len);
7467 fragsz = fragsz_oop;
7469 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7471 tdata->ciphertext.data,
7473 "GCM Ciphertext data not as expected");
7475 buf = ut_params->op->sym->m_src->next;
7477 buf = ut_params->op->sym->m_dst->next;
7479 unsigned int off = fragsz;
7483 ciphertext = rte_pktmbuf_mtod(buf,
7486 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7488 tdata->ciphertext.data + off,
7490 "GCM Ciphertext data not as expected");
7492 off += to_trn_tbl[ecx++];
7496 auth_tag = digest_mem;
7497 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7499 tdata->auth_tag.data,
7500 tdata->auth_tag.len,
7501 "GCM Generated auth tag not as expected");
7507 #define OUT_OF_PLACE 1
7510 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7512 return test_AES_GCM_authenticated_encryption_SGL(
7513 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7517 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7519 return test_AES_GCM_authenticated_encryption_SGL(
7520 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7524 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7526 return test_AES_GCM_authenticated_encryption_SGL(
7527 &gcm_test_case_8, OUT_OF_PLACE, 400,
7528 gcm_test_case_8.plaintext.len);
7532 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7535 return test_AES_GCM_authenticated_encryption_SGL(
7536 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7540 test_authentication_verify_fail_when_data_corrupted(
7541 struct crypto_testsuite_params *ts_params,
7542 struct crypto_unittest_params *ut_params,
7543 const struct test_crypto_vector *reference)
7545 return test_authentication_verify_fail_when_data_corruption(
7546 ts_params, ut_params, reference, 1);
7550 test_authentication_verify_fail_when_tag_corrupted(
7551 struct crypto_testsuite_params *ts_params,
7552 struct crypto_unittest_params *ut_params,
7553 const struct test_crypto_vector *reference)
7555 return test_authentication_verify_fail_when_data_corruption(
7556 ts_params, ut_params, reference, 0);
7560 test_authentication_verify_GMAC_fail_when_data_corrupted(
7561 struct crypto_testsuite_params *ts_params,
7562 struct crypto_unittest_params *ut_params,
7563 const struct test_crypto_vector *reference)
7565 return test_authentication_verify_GMAC_fail_when_corruption(
7566 ts_params, ut_params, reference, 1);
7570 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7571 struct crypto_testsuite_params *ts_params,
7572 struct crypto_unittest_params *ut_params,
7573 const struct test_crypto_vector *reference)
7575 return test_authentication_verify_GMAC_fail_when_corruption(
7576 ts_params, ut_params, reference, 0);
7580 test_authenticated_decryption_fail_when_data_corrupted(
7581 struct crypto_testsuite_params *ts_params,
7582 struct crypto_unittest_params *ut_params,
7583 const struct test_crypto_vector *reference)
7585 return test_authenticated_decryption_fail_when_corruption(
7586 ts_params, ut_params, reference, 1);
7590 test_authenticated_decryption_fail_when_tag_corrupted(
7591 struct crypto_testsuite_params *ts_params,
7592 struct crypto_unittest_params *ut_params,
7593 const struct test_crypto_vector *reference)
7595 return test_authenticated_decryption_fail_when_corruption(
7596 ts_params, ut_params, reference, 0);
7600 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7602 return test_authentication_verify_fail_when_data_corrupted(
7603 &testsuite_params, &unittest_params,
7604 &hmac_sha1_test_crypto_vector);
7608 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7610 return test_authentication_verify_fail_when_tag_corrupted(
7611 &testsuite_params, &unittest_params,
7612 &hmac_sha1_test_crypto_vector);
7616 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7618 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7619 &testsuite_params, &unittest_params,
7620 &aes128_gmac_test_vector);
7624 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7626 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7627 &testsuite_params, &unittest_params,
7628 &aes128_gmac_test_vector);
7632 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7634 return test_authenticated_decryption_fail_when_data_corrupted(
7637 &aes128cbc_hmac_sha1_test_vector);
7641 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7643 return test_authenticated_decryption_fail_when_tag_corrupted(
7646 &aes128cbc_hmac_sha1_test_vector);
7649 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7651 /* global AESNI slave IDs for the scheduler test */
7652 uint8_t aesni_ids[2];
7655 test_scheduler_attach_slave_op(void)
7657 struct crypto_testsuite_params *ts_params = &testsuite_params;
7658 uint8_t sched_id = ts_params->valid_devs[0];
7659 uint32_t nb_devs, i, nb_devs_attached = 0;
7663 /* create 2 AESNI_MB if necessary */
7664 nb_devs = rte_cryptodev_count_devtype(
7665 RTE_CRYPTODEV_AESNI_MB_PMD);
7667 for (i = nb_devs; i < 2; i++) {
7668 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7669 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7671 ret = rte_vdev_init(vdev_name, NULL);
7673 TEST_ASSERT(ret == 0,
7674 "Failed to create instance %u of"
7676 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7680 /* attach 2 AESNI_MB cdevs */
7681 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7683 struct rte_cryptodev_info info;
7685 rte_cryptodev_info_get(i, &info);
7686 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7689 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7692 TEST_ASSERT(ret == 0,
7693 "Failed to attach device %u of pmd : %s", i,
7694 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7696 aesni_ids[nb_devs_attached] = (uint8_t)i;
7705 test_scheduler_detach_slave_op(void)
7707 struct crypto_testsuite_params *ts_params = &testsuite_params;
7708 uint8_t sched_id = ts_params->valid_devs[0];
7712 for (i = 0; i < 2; i++) {
7713 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7715 TEST_ASSERT(ret == 0,
7716 "Failed to detach device %u", aesni_ids[i]);
7723 test_scheduler_mode_op(void)
7725 struct crypto_testsuite_params *ts_params = &testsuite_params;
7726 uint8_t sched_id = ts_params->valid_devs[0];
7727 struct rte_cryptodev_scheduler_ops op = {0};
7728 struct rte_cryptodev_scheduler dummy_scheduler = {
7729 .description = "dummy scheduler to test mode",
7730 .name = "dummy scheduler",
7731 .mode = CDEV_SCHED_MODE_USERDEFINED,
7736 /* set user defined mode */
7737 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7739 TEST_ASSERT(ret == 0,
7740 "Failed to set cdev %u to user defined mode", sched_id);
7742 /* set round robin mode */
7743 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7744 CDEV_SCHED_MODE_ROUNDROBIN);
7745 TEST_ASSERT(ret == 0,
7746 "Failed to set cdev %u to round-robin mode", sched_id);
7747 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7748 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7754 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7755 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7756 .setup = testsuite_setup,
7757 .teardown = testsuite_teardown,
7758 .unit_test_cases = {
7759 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7760 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_AES_chain_scheduler_all),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_AES_cipheronly_scheduler_all),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_authonly_scheduler_all),
7767 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7768 TEST_CASES_END() /**< NULL terminate unit test array */
7772 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7774 static struct unit_test_suite cryptodev_qat_testsuite = {
7775 .suite_name = "Crypto QAT Unit Test Suite",
7776 .setup = testsuite_setup,
7777 .teardown = testsuite_teardown,
7778 .unit_test_cases = {
7779 TEST_CASE_ST(ut_setup, ut_teardown,
7780 test_device_configure_invalid_dev_id),
7781 TEST_CASE_ST(ut_setup, ut_teardown,
7782 test_device_configure_invalid_queue_pair_ids),
7783 TEST_CASE_ST(ut_setup, ut_teardown,
7784 test_queue_pair_descriptor_setup),
7785 TEST_CASE_ST(ut_setup, ut_teardown,
7786 test_multi_session),
7788 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7789 TEST_CASE_ST(ut_setup, ut_teardown,
7790 test_AES_cipheronly_qat_all),
7791 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7792 TEST_CASE_ST(ut_setup, ut_teardown,
7793 test_3DES_cipheronly_qat_all),
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_DES_cipheronly_qat_all),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_AES_docsis_qat_all),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_DES_docsis_qat_all),
7800 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7802 /** AES GCM Authenticated Encryption */
7803 TEST_CASE_ST(ut_setup, ut_teardown,
7804 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7805 TEST_CASE_ST(ut_setup, ut_teardown,
7806 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7807 TEST_CASE_ST(ut_setup, ut_teardown,
7808 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7809 TEST_CASE_ST(ut_setup, ut_teardown,
7810 test_AES_GCM_authenticated_encryption_test_case_1),
7811 TEST_CASE_ST(ut_setup, ut_teardown,
7812 test_AES_GCM_authenticated_encryption_test_case_2),
7813 TEST_CASE_ST(ut_setup, ut_teardown,
7814 test_AES_GCM_authenticated_encryption_test_case_3),
7815 TEST_CASE_ST(ut_setup, ut_teardown,
7816 test_AES_GCM_authenticated_encryption_test_case_4),
7817 TEST_CASE_ST(ut_setup, ut_teardown,
7818 test_AES_GCM_authenticated_encryption_test_case_5),
7819 TEST_CASE_ST(ut_setup, ut_teardown,
7820 test_AES_GCM_authenticated_encryption_test_case_6),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_AES_GCM_authenticated_encryption_test_case_7),
7824 /** AES GCM Authenticated Decryption */
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_AES_GCM_authenticated_decryption_test_case_1),
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_AES_GCM_authenticated_decryption_test_case_2),
7829 TEST_CASE_ST(ut_setup, ut_teardown,
7830 test_AES_GCM_authenticated_decryption_test_case_3),
7831 TEST_CASE_ST(ut_setup, ut_teardown,
7832 test_AES_GCM_authenticated_decryption_test_case_4),
7833 TEST_CASE_ST(ut_setup, ut_teardown,
7834 test_AES_GCM_authenticated_decryption_test_case_5),
7835 TEST_CASE_ST(ut_setup, ut_teardown,
7836 test_AES_GCM_authenticated_decryption_test_case_6),
7837 TEST_CASE_ST(ut_setup, ut_teardown,
7838 test_AES_GCM_authenticated_decryption_test_case_7),
7840 /** AES GMAC Authentication */
7841 TEST_CASE_ST(ut_setup, ut_teardown,
7842 test_AES_GMAC_authentication_test_case_1),
7843 TEST_CASE_ST(ut_setup, ut_teardown,
7844 test_AES_GMAC_authentication_verify_test_case_1),
7845 TEST_CASE_ST(ut_setup, ut_teardown,
7846 test_AES_GMAC_authentication_test_case_2),
7847 TEST_CASE_ST(ut_setup, ut_teardown,
7848 test_AES_GMAC_authentication_verify_test_case_2),
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_AES_GMAC_authentication_test_case_3),
7851 TEST_CASE_ST(ut_setup, ut_teardown,
7852 test_AES_GMAC_authentication_verify_test_case_3),
7854 /** SNOW 3G encrypt only (UEA2) */
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_snow3g_encryption_test_case_1),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_snow3g_encryption_test_case_2),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_snow3g_encryption_test_case_3),
7861 TEST_CASE_ST(ut_setup, ut_teardown,
7862 test_snow3g_encryption_test_case_4),
7863 TEST_CASE_ST(ut_setup, ut_teardown,
7864 test_snow3g_encryption_test_case_5),
7866 TEST_CASE_ST(ut_setup, ut_teardown,
7867 test_snow3g_encryption_test_case_1_oop),
7868 TEST_CASE_ST(ut_setup, ut_teardown,
7869 test_snow3g_decryption_test_case_1_oop),
7871 /** SNOW 3G decrypt only (UEA2) */
7872 TEST_CASE_ST(ut_setup, ut_teardown,
7873 test_snow3g_decryption_test_case_1),
7874 TEST_CASE_ST(ut_setup, ut_teardown,
7875 test_snow3g_decryption_test_case_2),
7876 TEST_CASE_ST(ut_setup, ut_teardown,
7877 test_snow3g_decryption_test_case_3),
7878 TEST_CASE_ST(ut_setup, ut_teardown,
7879 test_snow3g_decryption_test_case_4),
7880 TEST_CASE_ST(ut_setup, ut_teardown,
7881 test_snow3g_decryption_test_case_5),
7882 TEST_CASE_ST(ut_setup, ut_teardown,
7883 test_snow3g_hash_generate_test_case_1),
7884 TEST_CASE_ST(ut_setup, ut_teardown,
7885 test_snow3g_hash_generate_test_case_2),
7886 TEST_CASE_ST(ut_setup, ut_teardown,
7887 test_snow3g_hash_generate_test_case_3),
7888 TEST_CASE_ST(ut_setup, ut_teardown,
7889 test_snow3g_hash_verify_test_case_1),
7890 TEST_CASE_ST(ut_setup, ut_teardown,
7891 test_snow3g_hash_verify_test_case_2),
7892 TEST_CASE_ST(ut_setup, ut_teardown,
7893 test_snow3g_hash_verify_test_case_3),
7894 TEST_CASE_ST(ut_setup, ut_teardown,
7895 test_snow3g_cipher_auth_test_case_1),
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 test_snow3g_auth_cipher_test_case_1),
7899 /** ZUC encrypt only (EEA3) */
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_zuc_encryption_test_case_1),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_zuc_encryption_test_case_2),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_zuc_encryption_test_case_3),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_zuc_encryption_test_case_4),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_zuc_encryption_test_case_5),
7911 /** ZUC authenticate (EIA3) */
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 test_zuc_hash_generate_test_case_6),
7914 TEST_CASE_ST(ut_setup, ut_teardown,
7915 test_zuc_hash_generate_test_case_7),
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 test_zuc_hash_generate_test_case_8),
7919 /** ZUC alg-chain (EEA3/EIA3) */
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 test_zuc_cipher_auth_test_case_1),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_zuc_cipher_auth_test_case_2),
7925 /** HMAC_MD5 Authentication */
7926 TEST_CASE_ST(ut_setup, ut_teardown,
7927 test_MD5_HMAC_generate_case_1),
7928 TEST_CASE_ST(ut_setup, ut_teardown,
7929 test_MD5_HMAC_verify_case_1),
7930 TEST_CASE_ST(ut_setup, ut_teardown,
7931 test_MD5_HMAC_generate_case_2),
7932 TEST_CASE_ST(ut_setup, ut_teardown,
7933 test_MD5_HMAC_verify_case_2),
7936 TEST_CASE_ST(ut_setup, ut_teardown,
7937 test_null_auth_only_operation),
7938 TEST_CASE_ST(ut_setup, ut_teardown,
7939 test_null_cipher_only_operation),
7940 TEST_CASE_ST(ut_setup, ut_teardown,
7941 test_null_cipher_auth_operation),
7942 TEST_CASE_ST(ut_setup, ut_teardown,
7943 test_null_auth_cipher_operation),
7945 TEST_CASE_ST(ut_setup, ut_teardown,
7946 test_kasumi_hash_generate_test_case_6),
7949 TEST_CASE_ST(ut_setup, ut_teardown,
7950 test_kasumi_encryption_test_case_1),
7951 TEST_CASE_ST(ut_setup, ut_teardown,
7952 test_kasumi_encryption_test_case_3),
7953 TEST_CASE_ST(ut_setup, ut_teardown,
7954 test_kasumi_auth_cipher_test_case_1),
7955 TEST_CASE_ST(ut_setup, ut_teardown,
7956 test_kasumi_cipher_auth_test_case_1),
7958 /** Negative tests */
7959 TEST_CASE_ST(ut_setup, ut_teardown,
7960 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7961 TEST_CASE_ST(ut_setup, ut_teardown,
7962 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7963 TEST_CASE_ST(ut_setup, ut_teardown,
7964 authentication_verify_AES128_GMAC_fail_data_corrupt),
7965 TEST_CASE_ST(ut_setup, ut_teardown,
7966 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7967 TEST_CASE_ST(ut_setup, ut_teardown,
7968 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7969 TEST_CASE_ST(ut_setup, ut_teardown,
7970 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7972 TEST_CASES_END() /**< NULL terminate unit test array */
7976 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7977 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7978 .setup = testsuite_setup,
7979 .teardown = testsuite_teardown,
7980 .unit_test_cases = {
7981 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7982 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7983 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7984 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7986 TEST_CASES_END() /**< NULL terminate unit test array */
7990 static struct unit_test_suite cryptodev_openssl_testsuite = {
7991 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7992 .setup = testsuite_setup,
7993 .teardown = testsuite_teardown,
7994 .unit_test_cases = {
7995 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7996 TEST_CASE_ST(ut_setup, ut_teardown,
7997 test_multi_session_random_usage),
7998 TEST_CASE_ST(ut_setup, ut_teardown,
7999 test_AES_chain_openssl_all),
8000 TEST_CASE_ST(ut_setup, ut_teardown,
8001 test_AES_cipheronly_openssl_all),
8002 TEST_CASE_ST(ut_setup, ut_teardown,
8003 test_3DES_chain_openssl_all),
8004 TEST_CASE_ST(ut_setup, ut_teardown,
8005 test_3DES_cipheronly_openssl_all),
8006 TEST_CASE_ST(ut_setup, ut_teardown,
8007 test_DES_docsis_openssl_all),
8008 TEST_CASE_ST(ut_setup, ut_teardown,
8009 test_authonly_openssl_all),
8011 /** AES GCM Authenticated Encryption */
8012 TEST_CASE_ST(ut_setup, ut_teardown,
8013 test_AES_GCM_authenticated_encryption_test_case_1),
8014 TEST_CASE_ST(ut_setup, ut_teardown,
8015 test_AES_GCM_authenticated_encryption_test_case_2),
8016 TEST_CASE_ST(ut_setup, ut_teardown,
8017 test_AES_GCM_authenticated_encryption_test_case_3),
8018 TEST_CASE_ST(ut_setup, ut_teardown,
8019 test_AES_GCM_authenticated_encryption_test_case_4),
8020 TEST_CASE_ST(ut_setup, ut_teardown,
8021 test_AES_GCM_authenticated_encryption_test_case_5),
8022 TEST_CASE_ST(ut_setup, ut_teardown,
8023 test_AES_GCM_authenticated_encryption_test_case_6),
8024 TEST_CASE_ST(ut_setup, ut_teardown,
8025 test_AES_GCM_authenticated_encryption_test_case_7),
8027 /** AES GCM Authenticated Decryption */
8028 TEST_CASE_ST(ut_setup, ut_teardown,
8029 test_AES_GCM_authenticated_decryption_test_case_1),
8030 TEST_CASE_ST(ut_setup, ut_teardown,
8031 test_AES_GCM_authenticated_decryption_test_case_2),
8032 TEST_CASE_ST(ut_setup, ut_teardown,
8033 test_AES_GCM_authenticated_decryption_test_case_3),
8034 TEST_CASE_ST(ut_setup, ut_teardown,
8035 test_AES_GCM_authenticated_decryption_test_case_4),
8036 TEST_CASE_ST(ut_setup, ut_teardown,
8037 test_AES_GCM_authenticated_decryption_test_case_5),
8038 TEST_CASE_ST(ut_setup, ut_teardown,
8039 test_AES_GCM_authenticated_decryption_test_case_6),
8040 TEST_CASE_ST(ut_setup, ut_teardown,
8041 test_AES_GCM_authenticated_decryption_test_case_7),
8043 /** AES GMAC Authentication */
8044 TEST_CASE_ST(ut_setup, ut_teardown,
8045 test_AES_GMAC_authentication_test_case_1),
8046 TEST_CASE_ST(ut_setup, ut_teardown,
8047 test_AES_GMAC_authentication_verify_test_case_1),
8048 TEST_CASE_ST(ut_setup, ut_teardown,
8049 test_AES_GMAC_authentication_test_case_2),
8050 TEST_CASE_ST(ut_setup, ut_teardown,
8051 test_AES_GMAC_authentication_verify_test_case_2),
8052 TEST_CASE_ST(ut_setup, ut_teardown,
8053 test_AES_GMAC_authentication_test_case_3),
8054 TEST_CASE_ST(ut_setup, ut_teardown,
8055 test_AES_GMAC_authentication_verify_test_case_3),
8056 TEST_CASE_ST(ut_setup, ut_teardown,
8057 test_AES_GMAC_authentication_test_case_4),
8058 TEST_CASE_ST(ut_setup, ut_teardown,
8059 test_AES_GMAC_authentication_verify_test_case_4),
8061 /** Scatter-Gather */
8062 TEST_CASE_ST(ut_setup, ut_teardown,
8063 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8065 /** Negative tests */
8066 TEST_CASE_ST(ut_setup, ut_teardown,
8067 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8068 TEST_CASE_ST(ut_setup, ut_teardown,
8069 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8070 TEST_CASE_ST(ut_setup, ut_teardown,
8071 authentication_verify_AES128_GMAC_fail_data_corrupt),
8072 TEST_CASE_ST(ut_setup, ut_teardown,
8073 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8074 TEST_CASE_ST(ut_setup, ut_teardown,
8075 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8076 TEST_CASE_ST(ut_setup, ut_teardown,
8077 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8079 TEST_CASES_END() /**< NULL terminate unit test array */
8083 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8084 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8085 .setup = testsuite_setup,
8086 .teardown = testsuite_teardown,
8087 .unit_test_cases = {
8088 /** AES GCM Authenticated Encryption */
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_AES_GCM_authenticated_encryption_test_case_1),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_AES_GCM_authenticated_encryption_test_case_2),
8093 TEST_CASE_ST(ut_setup, ut_teardown,
8094 test_AES_GCM_authenticated_encryption_test_case_3),
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_AES_GCM_authenticated_encryption_test_case_4),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_AES_GCM_authenticated_encryption_test_case_5),
8099 TEST_CASE_ST(ut_setup, ut_teardown,
8100 test_AES_GCM_authenticated_encryption_test_case_6),
8101 TEST_CASE_ST(ut_setup, ut_teardown,
8102 test_AES_GCM_authenticated_encryption_test_case_7),
8104 /** AES GCM Authenticated Decryption */
8105 TEST_CASE_ST(ut_setup, ut_teardown,
8106 test_AES_GCM_authenticated_decryption_test_case_1),
8107 TEST_CASE_ST(ut_setup, ut_teardown,
8108 test_AES_GCM_authenticated_decryption_test_case_2),
8109 TEST_CASE_ST(ut_setup, ut_teardown,
8110 test_AES_GCM_authenticated_decryption_test_case_3),
8111 TEST_CASE_ST(ut_setup, ut_teardown,
8112 test_AES_GCM_authenticated_decryption_test_case_4),
8113 TEST_CASE_ST(ut_setup, ut_teardown,
8114 test_AES_GCM_authenticated_decryption_test_case_5),
8115 TEST_CASE_ST(ut_setup, ut_teardown,
8116 test_AES_GCM_authenticated_decryption_test_case_6),
8117 TEST_CASE_ST(ut_setup, ut_teardown,
8118 test_AES_GCM_authenticated_decryption_test_case_7),
8120 /** AES GCM Authenticated Encryption 192 bits key */
8121 TEST_CASE_ST(ut_setup, ut_teardown,
8122 test_AES_GCM_auth_encryption_test_case_192_1),
8123 TEST_CASE_ST(ut_setup, ut_teardown,
8124 test_AES_GCM_auth_encryption_test_case_192_2),
8125 TEST_CASE_ST(ut_setup, ut_teardown,
8126 test_AES_GCM_auth_encryption_test_case_192_3),
8127 TEST_CASE_ST(ut_setup, ut_teardown,
8128 test_AES_GCM_auth_encryption_test_case_192_4),
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 test_AES_GCM_auth_encryption_test_case_192_5),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 test_AES_GCM_auth_encryption_test_case_192_6),
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 test_AES_GCM_auth_encryption_test_case_192_7),
8136 /** AES GCM Authenticated Decryption 192 bits key */
8137 TEST_CASE_ST(ut_setup, ut_teardown,
8138 test_AES_GCM_auth_decryption_test_case_192_1),
8139 TEST_CASE_ST(ut_setup, ut_teardown,
8140 test_AES_GCM_auth_decryption_test_case_192_2),
8141 TEST_CASE_ST(ut_setup, ut_teardown,
8142 test_AES_GCM_auth_decryption_test_case_192_3),
8143 TEST_CASE_ST(ut_setup, ut_teardown,
8144 test_AES_GCM_auth_decryption_test_case_192_4),
8145 TEST_CASE_ST(ut_setup, ut_teardown,
8146 test_AES_GCM_auth_decryption_test_case_192_5),
8147 TEST_CASE_ST(ut_setup, ut_teardown,
8148 test_AES_GCM_auth_decryption_test_case_192_6),
8149 TEST_CASE_ST(ut_setup, ut_teardown,
8150 test_AES_GCM_auth_decryption_test_case_192_7),
8152 /** AES GCM Authenticated Encryption 256 bits key */
8153 TEST_CASE_ST(ut_setup, ut_teardown,
8154 test_AES_GCM_auth_encryption_test_case_256_1),
8155 TEST_CASE_ST(ut_setup, ut_teardown,
8156 test_AES_GCM_auth_encryption_test_case_256_2),
8157 TEST_CASE_ST(ut_setup, ut_teardown,
8158 test_AES_GCM_auth_encryption_test_case_256_3),
8159 TEST_CASE_ST(ut_setup, ut_teardown,
8160 test_AES_GCM_auth_encryption_test_case_256_4),
8161 TEST_CASE_ST(ut_setup, ut_teardown,
8162 test_AES_GCM_auth_encryption_test_case_256_5),
8163 TEST_CASE_ST(ut_setup, ut_teardown,
8164 test_AES_GCM_auth_encryption_test_case_256_6),
8165 TEST_CASE_ST(ut_setup, ut_teardown,
8166 test_AES_GCM_auth_encryption_test_case_256_7),
8168 /** AES GCM Authenticated Decryption 256 bits key */
8169 TEST_CASE_ST(ut_setup, ut_teardown,
8170 test_AES_GCM_auth_decryption_test_case_256_1),
8171 TEST_CASE_ST(ut_setup, ut_teardown,
8172 test_AES_GCM_auth_decryption_test_case_256_2),
8173 TEST_CASE_ST(ut_setup, ut_teardown,
8174 test_AES_GCM_auth_decryption_test_case_256_3),
8175 TEST_CASE_ST(ut_setup, ut_teardown,
8176 test_AES_GCM_auth_decryption_test_case_256_4),
8177 TEST_CASE_ST(ut_setup, ut_teardown,
8178 test_AES_GCM_auth_decryption_test_case_256_5),
8179 TEST_CASE_ST(ut_setup, ut_teardown,
8180 test_AES_GCM_auth_decryption_test_case_256_6),
8181 TEST_CASE_ST(ut_setup, ut_teardown,
8182 test_AES_GCM_auth_decryption_test_case_256_7),
8184 /** AES GCM Authenticated Encryption big aad size */
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_AES_GCM_auth_encryption_test_case_aad_1),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_AES_GCM_auth_encryption_test_case_aad_2),
8190 /** AES GCM Authenticated Decryption big aad size */
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_AES_GCM_auth_decryption_test_case_aad_1),
8193 TEST_CASE_ST(ut_setup, ut_teardown,
8194 test_AES_GCM_auth_decryption_test_case_aad_2),
8196 /** AES GMAC Authentication */
8197 TEST_CASE_ST(ut_setup, ut_teardown,
8198 test_AES_GMAC_authentication_test_case_1),
8199 TEST_CASE_ST(ut_setup, ut_teardown,
8200 test_AES_GMAC_authentication_verify_test_case_1),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_AES_GMAC_authentication_test_case_3),
8203 TEST_CASE_ST(ut_setup, ut_teardown,
8204 test_AES_GMAC_authentication_verify_test_case_3),
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_AES_GMAC_authentication_test_case_4),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_AES_GMAC_authentication_verify_test_case_4),
8210 /** Negative tests */
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 authentication_verify_AES128_GMAC_fail_data_corrupt),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8216 /** Out of place tests */
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_AES_GCM_authenticated_encryption_oop_test_case_1),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_AES_GCM_authenticated_decryption_oop_test_case_1),
8222 /** Session-less tests */
8223 TEST_CASE_ST(ut_setup, ut_teardown,
8224 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
8225 TEST_CASE_ST(ut_setup, ut_teardown,
8226 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
8228 /** Scatter-Gather */
8229 TEST_CASE_ST(ut_setup, ut_teardown,
8230 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8232 TEST_CASES_END() /**< NULL terminate unit test array */
8236 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8237 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8238 .setup = testsuite_setup,
8239 .teardown = testsuite_teardown,
8240 .unit_test_cases = {
8241 /** KASUMI encrypt only (UEA1) */
8242 TEST_CASE_ST(ut_setup, ut_teardown,
8243 test_kasumi_encryption_test_case_1),
8244 TEST_CASE_ST(ut_setup, ut_teardown,
8245 test_kasumi_encryption_test_case_1_sgl),
8246 TEST_CASE_ST(ut_setup, ut_teardown,
8247 test_kasumi_encryption_test_case_2),
8248 TEST_CASE_ST(ut_setup, ut_teardown,
8249 test_kasumi_encryption_test_case_3),
8250 TEST_CASE_ST(ut_setup, ut_teardown,
8251 test_kasumi_encryption_test_case_4),
8252 TEST_CASE_ST(ut_setup, ut_teardown,
8253 test_kasumi_encryption_test_case_5),
8254 /** KASUMI decrypt only (UEA1) */
8255 TEST_CASE_ST(ut_setup, ut_teardown,
8256 test_kasumi_decryption_test_case_1),
8257 TEST_CASE_ST(ut_setup, ut_teardown,
8258 test_kasumi_decryption_test_case_2),
8259 TEST_CASE_ST(ut_setup, ut_teardown,
8260 test_kasumi_decryption_test_case_3),
8261 TEST_CASE_ST(ut_setup, ut_teardown,
8262 test_kasumi_decryption_test_case_4),
8263 TEST_CASE_ST(ut_setup, ut_teardown,
8264 test_kasumi_decryption_test_case_5),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_kasumi_encryption_test_case_1_oop),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_kasumi_encryption_test_case_1_oop_sgl),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_kasumi_decryption_test_case_1_oop),
8275 /** KASUMI hash only (UIA1) */
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_kasumi_hash_generate_test_case_1),
8278 TEST_CASE_ST(ut_setup, ut_teardown,
8279 test_kasumi_hash_generate_test_case_2),
8280 TEST_CASE_ST(ut_setup, ut_teardown,
8281 test_kasumi_hash_generate_test_case_3),
8282 TEST_CASE_ST(ut_setup, ut_teardown,
8283 test_kasumi_hash_generate_test_case_4),
8284 TEST_CASE_ST(ut_setup, ut_teardown,
8285 test_kasumi_hash_generate_test_case_5),
8286 TEST_CASE_ST(ut_setup, ut_teardown,
8287 test_kasumi_hash_generate_test_case_6),
8288 TEST_CASE_ST(ut_setup, ut_teardown,
8289 test_kasumi_hash_verify_test_case_1),
8290 TEST_CASE_ST(ut_setup, ut_teardown,
8291 test_kasumi_hash_verify_test_case_2),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_kasumi_hash_verify_test_case_3),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_kasumi_hash_verify_test_case_4),
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_kasumi_hash_verify_test_case_5),
8298 TEST_CASE_ST(ut_setup, ut_teardown,
8299 test_kasumi_auth_cipher_test_case_1),
8300 TEST_CASE_ST(ut_setup, ut_teardown,
8301 test_kasumi_cipher_auth_test_case_1),
8302 TEST_CASES_END() /**< NULL terminate unit test array */
8305 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8306 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8307 .setup = testsuite_setup,
8308 .teardown = testsuite_teardown,
8309 .unit_test_cases = {
8310 /** SNOW 3G encrypt only (UEA2) */
8311 TEST_CASE_ST(ut_setup, ut_teardown,
8312 test_snow3g_encryption_test_case_1),
8313 TEST_CASE_ST(ut_setup, ut_teardown,
8314 test_snow3g_encryption_test_case_2),
8315 TEST_CASE_ST(ut_setup, ut_teardown,
8316 test_snow3g_encryption_test_case_3),
8317 TEST_CASE_ST(ut_setup, ut_teardown,
8318 test_snow3g_encryption_test_case_4),
8319 TEST_CASE_ST(ut_setup, ut_teardown,
8320 test_snow3g_encryption_test_case_5),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_snow3g_encryption_test_case_1_oop),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_snow3g_encryption_test_case_1_oop_sgl),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_snow3g_decryption_test_case_1_oop),
8329 TEST_CASE_ST(ut_setup, ut_teardown,
8330 test_snow3g_encryption_test_case_1_offset_oop),
8332 /** SNOW 3G decrypt only (UEA2) */
8333 TEST_CASE_ST(ut_setup, ut_teardown,
8334 test_snow3g_decryption_test_case_1),
8335 TEST_CASE_ST(ut_setup, ut_teardown,
8336 test_snow3g_decryption_test_case_2),
8337 TEST_CASE_ST(ut_setup, ut_teardown,
8338 test_snow3g_decryption_test_case_3),
8339 TEST_CASE_ST(ut_setup, ut_teardown,
8340 test_snow3g_decryption_test_case_4),
8341 TEST_CASE_ST(ut_setup, ut_teardown,
8342 test_snow3g_decryption_test_case_5),
8343 TEST_CASE_ST(ut_setup, ut_teardown,
8344 test_snow3g_hash_generate_test_case_1),
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 test_snow3g_hash_generate_test_case_2),
8347 TEST_CASE_ST(ut_setup, ut_teardown,
8348 test_snow3g_hash_generate_test_case_3),
8349 /* Tests with buffers which length is not byte-aligned */
8350 TEST_CASE_ST(ut_setup, ut_teardown,
8351 test_snow3g_hash_generate_test_case_4),
8352 TEST_CASE_ST(ut_setup, ut_teardown,
8353 test_snow3g_hash_generate_test_case_5),
8354 TEST_CASE_ST(ut_setup, ut_teardown,
8355 test_snow3g_hash_generate_test_case_6),
8356 TEST_CASE_ST(ut_setup, ut_teardown,
8357 test_snow3g_hash_verify_test_case_1),
8358 TEST_CASE_ST(ut_setup, ut_teardown,
8359 test_snow3g_hash_verify_test_case_2),
8360 TEST_CASE_ST(ut_setup, ut_teardown,
8361 test_snow3g_hash_verify_test_case_3),
8362 /* Tests with buffers which length is not byte-aligned */
8363 TEST_CASE_ST(ut_setup, ut_teardown,
8364 test_snow3g_hash_verify_test_case_4),
8365 TEST_CASE_ST(ut_setup, ut_teardown,
8366 test_snow3g_hash_verify_test_case_5),
8367 TEST_CASE_ST(ut_setup, ut_teardown,
8368 test_snow3g_hash_verify_test_case_6),
8369 TEST_CASE_ST(ut_setup, ut_teardown,
8370 test_snow3g_cipher_auth_test_case_1),
8371 TEST_CASE_ST(ut_setup, ut_teardown,
8372 test_snow3g_auth_cipher_test_case_1),
8374 TEST_CASES_END() /**< NULL terminate unit test array */
8378 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8379 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8380 .setup = testsuite_setup,
8381 .teardown = testsuite_teardown,
8382 .unit_test_cases = {
8383 /** ZUC encrypt only (EEA3) */
8384 TEST_CASE_ST(ut_setup, ut_teardown,
8385 test_zuc_encryption_test_case_1),
8386 TEST_CASE_ST(ut_setup, ut_teardown,
8387 test_zuc_encryption_test_case_2),
8388 TEST_CASE_ST(ut_setup, ut_teardown,
8389 test_zuc_encryption_test_case_3),
8390 TEST_CASE_ST(ut_setup, ut_teardown,
8391 test_zuc_encryption_test_case_4),
8392 TEST_CASE_ST(ut_setup, ut_teardown,
8393 test_zuc_encryption_test_case_5),
8394 TEST_CASE_ST(ut_setup, ut_teardown,
8395 test_zuc_hash_generate_test_case_1),
8396 TEST_CASE_ST(ut_setup, ut_teardown,
8397 test_zuc_hash_generate_test_case_2),
8398 TEST_CASE_ST(ut_setup, ut_teardown,
8399 test_zuc_hash_generate_test_case_3),
8400 TEST_CASE_ST(ut_setup, ut_teardown,
8401 test_zuc_hash_generate_test_case_4),
8402 TEST_CASE_ST(ut_setup, ut_teardown,
8403 test_zuc_hash_generate_test_case_5),
8404 TEST_CASE_ST(ut_setup, ut_teardown,
8405 test_zuc_encryption_test_case_6_sgl),
8406 TEST_CASES_END() /**< NULL terminate unit test array */
8410 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8411 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8412 .setup = testsuite_setup,
8413 .teardown = testsuite_teardown,
8414 .unit_test_cases = {
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_device_configure_invalid_dev_id),
8417 TEST_CASE_ST(ut_setup, ut_teardown,
8418 test_multi_session),
8420 TEST_CASE_ST(ut_setup, ut_teardown,
8421 test_AES_chain_dpaa2_sec_all),
8422 TEST_CASE_ST(ut_setup, ut_teardown,
8423 test_3DES_chain_dpaa2_sec_all),
8424 TEST_CASE_ST(ut_setup, ut_teardown,
8425 test_AES_cipheronly_dpaa2_sec_all),
8426 TEST_CASE_ST(ut_setup, ut_teardown,
8427 test_3DES_cipheronly_dpaa2_sec_all),
8428 TEST_CASE_ST(ut_setup, ut_teardown,
8429 test_authonly_dpaa2_sec_all),
8431 /** AES GCM Authenticated Encryption */
8432 TEST_CASE_ST(ut_setup, ut_teardown,
8433 test_AES_GCM_authenticated_encryption_test_case_1),
8434 TEST_CASE_ST(ut_setup, ut_teardown,
8435 test_AES_GCM_authenticated_encryption_test_case_2),
8436 TEST_CASE_ST(ut_setup, ut_teardown,
8437 test_AES_GCM_authenticated_encryption_test_case_3),
8438 TEST_CASE_ST(ut_setup, ut_teardown,
8439 test_AES_GCM_authenticated_encryption_test_case_4),
8440 TEST_CASE_ST(ut_setup, ut_teardown,
8441 test_AES_GCM_authenticated_encryption_test_case_5),
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_AES_GCM_authenticated_encryption_test_case_6),
8444 TEST_CASE_ST(ut_setup, ut_teardown,
8445 test_AES_GCM_authenticated_encryption_test_case_7),
8447 /** AES GCM Authenticated Decryption */
8448 TEST_CASE_ST(ut_setup, ut_teardown,
8449 test_AES_GCM_authenticated_decryption_test_case_1),
8450 TEST_CASE_ST(ut_setup, ut_teardown,
8451 test_AES_GCM_authenticated_decryption_test_case_2),
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_AES_GCM_authenticated_decryption_test_case_3),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_AES_GCM_authenticated_decryption_test_case_4),
8456 TEST_CASE_ST(ut_setup, ut_teardown,
8457 test_AES_GCM_authenticated_decryption_test_case_5),
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_AES_GCM_authenticated_decryption_test_case_6),
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_AES_GCM_authenticated_decryption_test_case_7),
8463 /** AES GCM Authenticated Encryption 256 bits key */
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_AES_GCM_auth_encryption_test_case_256_1),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_AES_GCM_auth_encryption_test_case_256_2),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_AES_GCM_auth_encryption_test_case_256_3),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_AES_GCM_auth_encryption_test_case_256_4),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_AES_GCM_auth_encryption_test_case_256_5),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_AES_GCM_auth_encryption_test_case_256_6),
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_AES_GCM_auth_encryption_test_case_256_7),
8479 /** AES GCM Authenticated Decryption 256 bits key */
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_AES_GCM_auth_decryption_test_case_256_1),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_AES_GCM_auth_decryption_test_case_256_2),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_AES_GCM_auth_decryption_test_case_256_3),
8486 TEST_CASE_ST(ut_setup, ut_teardown,
8487 test_AES_GCM_auth_decryption_test_case_256_4),
8488 TEST_CASE_ST(ut_setup, ut_teardown,
8489 test_AES_GCM_auth_decryption_test_case_256_5),
8490 TEST_CASE_ST(ut_setup, ut_teardown,
8491 test_AES_GCM_auth_decryption_test_case_256_6),
8492 TEST_CASE_ST(ut_setup, ut_teardown,
8493 test_AES_GCM_auth_decryption_test_case_256_7),
8495 TEST_CASES_END() /**< NULL terminate unit test array */
8499 static struct unit_test_suite cryptodev_null_testsuite = {
8500 .suite_name = "Crypto Device NULL Unit Test Suite",
8501 .setup = testsuite_setup,
8502 .teardown = testsuite_teardown,
8503 .unit_test_cases = {
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_null_auth_only_operation),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_null_cipher_only_operation),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_null_cipher_auth_operation),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_null_auth_cipher_operation),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_null_invalid_operation),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_null_burst_operation),
8517 TEST_CASES_END() /**< NULL terminate unit test array */
8521 static struct unit_test_suite cryptodev_armv8_testsuite = {
8522 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8523 .setup = testsuite_setup,
8524 .teardown = testsuite_teardown,
8525 .unit_test_cases = {
8526 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8528 /** Negative tests */
8529 TEST_CASE_ST(ut_setup, ut_teardown,
8530 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8531 TEST_CASE_ST(ut_setup, ut_teardown,
8532 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8534 TEST_CASES_END() /**< NULL terminate unit test array */
8539 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8541 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8542 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8546 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8548 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8550 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8554 test_cryptodev_openssl(void)
8556 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8558 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8562 test_cryptodev_aesni_gcm(void)
8564 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8566 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8570 test_cryptodev_null(void)
8572 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8574 return unit_test_suite_runner(&cryptodev_null_testsuite);
8578 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8580 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8582 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8586 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8588 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8590 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8594 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8596 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8598 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8602 test_cryptodev_armv8(void)
8604 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8606 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8609 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8612 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8614 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8615 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8618 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8623 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8625 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8626 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8629 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8630 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8631 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8632 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8633 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8634 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8635 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8636 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8637 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8638 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);