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_openssl_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_OPENSSL_PMD,
1750 BLKCIPHER_AUTHONLY_TYPE);
1752 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1754 return TEST_SUCCESS;
1758 test_AES_chain_armv8_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_ARMV8_PMD,
1766 BLKCIPHER_AES_CHAIN_TYPE);
1768 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1770 return TEST_SUCCESS;
1773 /* ***** SNOW 3G Tests ***** */
1775 create_wireless_algo_hash_session(uint8_t dev_id,
1776 const uint8_t *key, const uint8_t key_len,
1777 const uint8_t iv_len, const uint8_t auth_len,
1778 enum rte_crypto_auth_operation op,
1779 enum rte_crypto_auth_algorithm algo)
1781 uint8_t hash_key[key_len];
1783 struct crypto_unittest_params *ut_params = &unittest_params;
1785 memcpy(hash_key, key, key_len);
1787 TEST_HEXDUMP(stdout, "key:", key, key_len);
1789 /* Setup Authentication Parameters */
1790 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1791 ut_params->auth_xform.next = NULL;
1793 ut_params->auth_xform.auth.op = op;
1794 ut_params->auth_xform.auth.algo = algo;
1795 ut_params->auth_xform.auth.key.length = key_len;
1796 ut_params->auth_xform.auth.key.data = hash_key;
1797 ut_params->auth_xform.auth.digest_length = auth_len;
1798 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1799 ut_params->auth_xform.auth.iv.length = iv_len;
1800 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1801 &ut_params->auth_xform);
1802 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1807 create_wireless_algo_cipher_session(uint8_t dev_id,
1808 enum rte_crypto_cipher_operation op,
1809 enum rte_crypto_cipher_algorithm algo,
1810 const uint8_t *key, const uint8_t key_len,
1813 uint8_t cipher_key[key_len];
1815 struct crypto_unittest_params *ut_params = &unittest_params;
1817 memcpy(cipher_key, key, key_len);
1819 /* Setup Cipher Parameters */
1820 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1821 ut_params->cipher_xform.next = NULL;
1823 ut_params->cipher_xform.cipher.algo = algo;
1824 ut_params->cipher_xform.cipher.op = op;
1825 ut_params->cipher_xform.cipher.key.data = cipher_key;
1826 ut_params->cipher_xform.cipher.key.length = key_len;
1827 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1828 ut_params->cipher_xform.cipher.iv.length = iv_len;
1830 TEST_HEXDUMP(stdout, "key:", key, key_len);
1832 /* Create Crypto session */
1833 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1841 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1842 unsigned int cipher_len,
1843 unsigned int cipher_offset)
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 /* Generate Crypto op data structure */
1849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1851 TEST_ASSERT_NOT_NULL(ut_params->op,
1852 "Failed to allocate pktmbuf offload");
1854 /* Set crypto operation data parameters */
1855 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1857 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1859 /* set crypto operation source mbuf */
1860 sym_op->m_src = ut_params->ibuf;
1863 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1865 sym_op->cipher.data.length = cipher_len;
1866 sym_op->cipher.data.offset = cipher_offset;
1871 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1872 unsigned int cipher_len,
1873 unsigned int cipher_offset)
1875 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 struct crypto_unittest_params *ut_params = &unittest_params;
1878 /* Generate Crypto op data structure */
1879 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1880 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1881 TEST_ASSERT_NOT_NULL(ut_params->op,
1882 "Failed to allocate pktmbuf offload");
1884 /* Set crypto operation data parameters */
1885 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1887 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1889 /* set crypto operation source mbuf */
1890 sym_op->m_src = ut_params->ibuf;
1891 sym_op->m_dst = ut_params->obuf;
1894 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1896 sym_op->cipher.data.length = cipher_len;
1897 sym_op->cipher.data.offset = cipher_offset;
1902 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1903 enum rte_crypto_cipher_operation cipher_op,
1904 enum rte_crypto_auth_operation auth_op,
1905 enum rte_crypto_auth_algorithm auth_algo,
1906 enum rte_crypto_cipher_algorithm cipher_algo,
1907 const uint8_t *key, uint8_t key_len,
1908 uint8_t auth_iv_len, uint8_t auth_len,
1909 uint8_t cipher_iv_len)
1912 uint8_t cipher_auth_key[key_len];
1914 struct crypto_unittest_params *ut_params = &unittest_params;
1916 memcpy(cipher_auth_key, key, key_len);
1918 /* Setup Authentication Parameters */
1919 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1920 ut_params->auth_xform.next = NULL;
1922 ut_params->auth_xform.auth.op = auth_op;
1923 ut_params->auth_xform.auth.algo = auth_algo;
1924 ut_params->auth_xform.auth.key.length = key_len;
1925 /* Hash key = cipher key */
1926 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1927 ut_params->auth_xform.auth.digest_length = auth_len;
1928 /* Auth IV will be after cipher IV */
1929 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1930 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1932 /* Setup Cipher Parameters */
1933 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1934 ut_params->cipher_xform.next = &ut_params->auth_xform;
1936 ut_params->cipher_xform.cipher.algo = cipher_algo;
1937 ut_params->cipher_xform.cipher.op = cipher_op;
1938 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1939 ut_params->cipher_xform.cipher.key.length = key_len;
1940 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1941 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1943 TEST_HEXDUMP(stdout, "key:", key, key_len);
1945 /* Create Crypto session*/
1946 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1947 &ut_params->cipher_xform);
1949 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1954 create_wireless_cipher_auth_session(uint8_t dev_id,
1955 enum rte_crypto_cipher_operation cipher_op,
1956 enum rte_crypto_auth_operation auth_op,
1957 enum rte_crypto_auth_algorithm auth_algo,
1958 enum rte_crypto_cipher_algorithm cipher_algo,
1959 const struct wireless_test_data *tdata)
1961 const uint8_t key_len = tdata->key.len;
1962 uint8_t cipher_auth_key[key_len];
1964 struct crypto_unittest_params *ut_params = &unittest_params;
1965 const uint8_t *key = tdata->key.data;
1966 const uint8_t auth_len = tdata->digest.len;
1967 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1968 uint8_t auth_iv_len = tdata->auth_iv.len;
1970 memcpy(cipher_auth_key, key, key_len);
1972 /* Setup Authentication Parameters */
1973 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1974 ut_params->auth_xform.next = NULL;
1976 ut_params->auth_xform.auth.op = auth_op;
1977 ut_params->auth_xform.auth.algo = auth_algo;
1978 ut_params->auth_xform.auth.key.length = key_len;
1979 /* Hash key = cipher key */
1980 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1981 ut_params->auth_xform.auth.digest_length = auth_len;
1982 /* Auth IV will be after cipher IV */
1983 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1984 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1986 /* Setup Cipher Parameters */
1987 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1988 ut_params->cipher_xform.next = &ut_params->auth_xform;
1990 ut_params->cipher_xform.cipher.algo = cipher_algo;
1991 ut_params->cipher_xform.cipher.op = cipher_op;
1992 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1993 ut_params->cipher_xform.cipher.key.length = key_len;
1994 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1995 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1998 TEST_HEXDUMP(stdout, "key:", key, key_len);
2000 /* Create Crypto session*/
2001 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2002 &ut_params->cipher_xform);
2004 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2009 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2010 const struct wireless_test_data *tdata)
2012 return create_wireless_cipher_auth_session(dev_id,
2013 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2014 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2015 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2019 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2020 enum rte_crypto_cipher_operation cipher_op,
2021 enum rte_crypto_auth_operation auth_op,
2022 enum rte_crypto_auth_algorithm auth_algo,
2023 enum rte_crypto_cipher_algorithm cipher_algo,
2024 const uint8_t *key, const uint8_t key_len,
2025 uint8_t auth_iv_len, uint8_t auth_len,
2026 uint8_t cipher_iv_len)
2028 uint8_t auth_cipher_key[key_len];
2030 struct crypto_unittest_params *ut_params = &unittest_params;
2032 memcpy(auth_cipher_key, key, key_len);
2034 /* Setup Authentication Parameters */
2035 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2036 ut_params->auth_xform.auth.op = auth_op;
2037 ut_params->auth_xform.next = &ut_params->cipher_xform;
2038 ut_params->auth_xform.auth.algo = auth_algo;
2039 ut_params->auth_xform.auth.key.length = key_len;
2040 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2041 ut_params->auth_xform.auth.digest_length = auth_len;
2042 /* Auth IV will be after cipher IV */
2043 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2044 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2046 /* Setup Cipher Parameters */
2047 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2048 ut_params->cipher_xform.next = NULL;
2049 ut_params->cipher_xform.cipher.algo = cipher_algo;
2050 ut_params->cipher_xform.cipher.op = cipher_op;
2051 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2052 ut_params->cipher_xform.cipher.key.length = key_len;
2053 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2054 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2056 TEST_HEXDUMP(stdout, "key:", key, key_len);
2058 /* Create Crypto session*/
2059 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2060 &ut_params->auth_xform);
2062 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2068 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2069 unsigned int auth_tag_len,
2070 const uint8_t *iv, unsigned int iv_len,
2071 unsigned int data_pad_len,
2072 enum rte_crypto_auth_operation op,
2073 unsigned int auth_len, unsigned int auth_offset)
2075 struct crypto_testsuite_params *ts_params = &testsuite_params;
2077 struct crypto_unittest_params *ut_params = &unittest_params;
2079 /* Generate Crypto op data structure */
2080 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2081 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2082 TEST_ASSERT_NOT_NULL(ut_params->op,
2083 "Failed to allocate pktmbuf offload");
2085 /* Set crypto operation data parameters */
2086 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2088 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2090 /* set crypto operation source mbuf */
2091 sym_op->m_src = ut_params->ibuf;
2094 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2097 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2098 ut_params->ibuf, auth_tag_len);
2100 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2101 "no room to append auth tag");
2102 ut_params->digest = sym_op->auth.digest.data;
2103 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2104 ut_params->ibuf, data_pad_len);
2105 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2106 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2108 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2110 TEST_HEXDUMP(stdout, "digest:",
2111 sym_op->auth.digest.data,
2114 sym_op->auth.data.length = auth_len;
2115 sym_op->auth.data.offset = auth_offset;
2121 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2122 enum rte_crypto_auth_operation op)
2124 struct crypto_testsuite_params *ts_params = &testsuite_params;
2125 struct crypto_unittest_params *ut_params = &unittest_params;
2127 const uint8_t *auth_tag = tdata->digest.data;
2128 const unsigned int auth_tag_len = tdata->digest.len;
2129 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2130 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2132 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2133 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2134 const uint8_t *auth_iv = tdata->auth_iv.data;
2135 const uint8_t auth_iv_len = tdata->auth_iv.len;
2136 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2137 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2139 /* Generate Crypto op data structure */
2140 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2141 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2142 TEST_ASSERT_NOT_NULL(ut_params->op,
2143 "Failed to allocate pktmbuf offload");
2144 /* Set crypto operation data parameters */
2145 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2147 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2149 /* set crypto operation source mbuf */
2150 sym_op->m_src = ut_params->ibuf;
2153 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2154 ut_params->ibuf, auth_tag_len);
2156 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2157 "no room to append auth tag");
2158 ut_params->digest = sym_op->auth.digest.data;
2159 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2160 ut_params->ibuf, data_pad_len);
2161 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2162 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2164 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2166 TEST_HEXDUMP(stdout, "digest:",
2167 sym_op->auth.digest.data,
2170 /* Copy cipher and auth IVs at the end of the crypto operation */
2171 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2173 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2174 iv_ptr += cipher_iv_len;
2175 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2177 sym_op->cipher.data.length = cipher_len;
2178 sym_op->cipher.data.offset = 0;
2179 sym_op->auth.data.length = auth_len;
2180 sym_op->auth.data.offset = 0;
2186 create_zuc_cipher_hash_generate_operation(
2187 const struct wireless_test_data *tdata)
2189 return create_wireless_cipher_hash_operation(tdata,
2190 RTE_CRYPTO_AUTH_OP_GENERATE);
2194 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2195 const unsigned auth_tag_len,
2196 const uint8_t *auth_iv, uint8_t auth_iv_len,
2197 unsigned data_pad_len,
2198 enum rte_crypto_auth_operation op,
2199 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2200 const unsigned cipher_len, const unsigned cipher_offset,
2201 const unsigned auth_len, const unsigned auth_offset)
2203 struct crypto_testsuite_params *ts_params = &testsuite_params;
2204 struct crypto_unittest_params *ut_params = &unittest_params;
2206 /* Generate Crypto op data structure */
2207 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2208 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2209 TEST_ASSERT_NOT_NULL(ut_params->op,
2210 "Failed to allocate pktmbuf offload");
2211 /* Set crypto operation data parameters */
2212 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2214 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2216 /* set crypto operation source mbuf */
2217 sym_op->m_src = ut_params->ibuf;
2220 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2221 ut_params->ibuf, auth_tag_len);
2223 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2224 "no room to append auth tag");
2225 ut_params->digest = sym_op->auth.digest.data;
2226 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2227 ut_params->ibuf, data_pad_len);
2228 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2229 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2231 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2233 TEST_HEXDUMP(stdout, "digest:",
2234 sym_op->auth.digest.data,
2237 /* Copy cipher and auth IVs at the end of the crypto operation */
2238 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2240 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2241 iv_ptr += cipher_iv_len;
2242 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2244 sym_op->cipher.data.length = cipher_len;
2245 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2246 sym_op->auth.data.length = auth_len;
2247 sym_op->auth.data.offset = auth_offset + cipher_offset;
2253 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2254 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2255 const uint8_t *auth_iv, uint8_t auth_iv_len,
2256 unsigned int data_pad_len,
2257 unsigned int cipher_len, unsigned int cipher_offset,
2258 unsigned int auth_len, unsigned int auth_offset)
2260 struct crypto_testsuite_params *ts_params = &testsuite_params;
2261 struct crypto_unittest_params *ut_params = &unittest_params;
2263 /* Generate Crypto op data structure */
2264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2266 TEST_ASSERT_NOT_NULL(ut_params->op,
2267 "Failed to allocate pktmbuf offload");
2269 /* Set crypto operation data parameters */
2270 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2272 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2274 /* set crypto operation source mbuf */
2275 sym_op->m_src = ut_params->ibuf;
2278 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2279 ut_params->ibuf, auth_tag_len);
2281 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2282 "no room to append auth tag");
2284 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2285 ut_params->ibuf, data_pad_len);
2287 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2289 TEST_HEXDUMP(stdout, "digest:",
2290 sym_op->auth.digest.data,
2293 /* Copy cipher and auth IVs at the end of the crypto operation */
2294 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2296 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2297 iv_ptr += cipher_iv_len;
2298 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2300 sym_op->cipher.data.length = cipher_len;
2301 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2303 sym_op->auth.data.length = auth_len;
2304 sym_op->auth.data.offset = auth_offset + cipher_offset;
2310 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2312 struct crypto_testsuite_params *ts_params = &testsuite_params;
2313 struct crypto_unittest_params *ut_params = &unittest_params;
2316 unsigned plaintext_pad_len;
2317 unsigned plaintext_len;
2320 /* Create SNOW 3G session */
2321 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2322 tdata->key.data, tdata->key.len,
2323 tdata->auth_iv.len, tdata->digest.len,
2324 RTE_CRYPTO_AUTH_OP_GENERATE,
2325 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2329 /* alloc mbuf and set payload */
2330 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2333 rte_pktmbuf_tailroom(ut_params->ibuf));
2335 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2336 /* Append data which is padded to a multiple of */
2337 /* the algorithms block size */
2338 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2341 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2343 /* Create SNOW 3G operation */
2344 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2345 tdata->auth_iv.data, tdata->auth_iv.len,
2346 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2347 tdata->validAuthLenInBits.len,
2352 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2354 ut_params->obuf = ut_params->op->sym->m_src;
2355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2356 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2357 + plaintext_pad_len;
2360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2363 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2364 "SNOW 3G Generated auth tag not as expected");
2370 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2372 struct crypto_testsuite_params *ts_params = &testsuite_params;
2373 struct crypto_unittest_params *ut_params = &unittest_params;
2376 unsigned plaintext_pad_len;
2377 unsigned plaintext_len;
2380 /* Create SNOW 3G session */
2381 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2382 tdata->key.data, tdata->key.len,
2383 tdata->auth_iv.len, tdata->digest.len,
2384 RTE_CRYPTO_AUTH_OP_VERIFY,
2385 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2388 /* alloc mbuf and set payload */
2389 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2392 rte_pktmbuf_tailroom(ut_params->ibuf));
2394 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2395 /* Append data which is padded to a multiple of */
2396 /* the algorithms block size */
2397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2398 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2400 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2402 /* Create SNOW 3G operation */
2403 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2405 tdata->auth_iv.data, tdata->auth_iv.len,
2407 RTE_CRYPTO_AUTH_OP_VERIFY,
2408 tdata->validAuthLenInBits.len,
2413 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2415 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2416 ut_params->obuf = ut_params->op->sym->m_src;
2417 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2418 + plaintext_pad_len;
2421 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2430 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2432 struct crypto_testsuite_params *ts_params = &testsuite_params;
2433 struct crypto_unittest_params *ut_params = &unittest_params;
2436 unsigned plaintext_pad_len;
2437 unsigned plaintext_len;
2440 /* Create KASUMI session */
2441 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2442 tdata->key.data, tdata->key.len,
2443 tdata->auth_iv.len, tdata->digest.len,
2444 RTE_CRYPTO_AUTH_OP_GENERATE,
2445 RTE_CRYPTO_AUTH_KASUMI_F9);
2449 /* alloc mbuf and set payload */
2450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2452 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2453 rte_pktmbuf_tailroom(ut_params->ibuf));
2455 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2456 /* Append data which is padded to a multiple of */
2457 /* the algorithms block size */
2458 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2459 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2461 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2463 /* Create KASUMI operation */
2464 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2465 tdata->auth_iv.data, tdata->auth_iv.len,
2466 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2467 tdata->validAuthLenInBits.len,
2472 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2474 ut_params->obuf = ut_params->op->sym->m_src;
2475 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2476 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2477 + plaintext_pad_len;
2480 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2483 DIGEST_BYTE_LENGTH_KASUMI_F9,
2484 "KASUMI Generated auth tag not as expected");
2490 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2492 struct crypto_testsuite_params *ts_params = &testsuite_params;
2493 struct crypto_unittest_params *ut_params = &unittest_params;
2496 unsigned plaintext_pad_len;
2497 unsigned plaintext_len;
2500 /* Create KASUMI session */
2501 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2502 tdata->key.data, tdata->key.len,
2503 tdata->auth_iv.len, tdata->digest.len,
2504 RTE_CRYPTO_AUTH_OP_VERIFY,
2505 RTE_CRYPTO_AUTH_KASUMI_F9);
2508 /* alloc mbuf and set payload */
2509 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2511 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2512 rte_pktmbuf_tailroom(ut_params->ibuf));
2514 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2515 /* Append data which is padded to a multiple */
2516 /* of the algorithms block size */
2517 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2518 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2520 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2522 /* Create KASUMI operation */
2523 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2525 tdata->auth_iv.data, tdata->auth_iv.len,
2527 RTE_CRYPTO_AUTH_OP_VERIFY,
2528 tdata->validAuthLenInBits.len,
2533 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2535 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2536 ut_params->obuf = ut_params->op->sym->m_src;
2537 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2538 + plaintext_pad_len;
2541 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2550 test_snow3g_hash_generate_test_case_1(void)
2552 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2556 test_snow3g_hash_generate_test_case_2(void)
2558 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2562 test_snow3g_hash_generate_test_case_3(void)
2564 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2568 test_snow3g_hash_generate_test_case_4(void)
2570 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2574 test_snow3g_hash_generate_test_case_5(void)
2576 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2580 test_snow3g_hash_generate_test_case_6(void)
2582 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2586 test_snow3g_hash_verify_test_case_1(void)
2588 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2593 test_snow3g_hash_verify_test_case_2(void)
2595 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2599 test_snow3g_hash_verify_test_case_3(void)
2601 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2605 test_snow3g_hash_verify_test_case_4(void)
2607 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2611 test_snow3g_hash_verify_test_case_5(void)
2613 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2617 test_snow3g_hash_verify_test_case_6(void)
2619 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2623 test_kasumi_hash_generate_test_case_1(void)
2625 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2629 test_kasumi_hash_generate_test_case_2(void)
2631 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2635 test_kasumi_hash_generate_test_case_3(void)
2637 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2641 test_kasumi_hash_generate_test_case_4(void)
2643 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2647 test_kasumi_hash_generate_test_case_5(void)
2649 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2653 test_kasumi_hash_generate_test_case_6(void)
2655 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2659 test_kasumi_hash_verify_test_case_1(void)
2661 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2665 test_kasumi_hash_verify_test_case_2(void)
2667 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2671 test_kasumi_hash_verify_test_case_3(void)
2673 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2677 test_kasumi_hash_verify_test_case_4(void)
2679 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2683 test_kasumi_hash_verify_test_case_5(void)
2685 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2689 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2691 struct crypto_testsuite_params *ts_params = &testsuite_params;
2692 struct crypto_unittest_params *ut_params = &unittest_params;
2695 uint8_t *plaintext, *ciphertext;
2696 unsigned plaintext_pad_len;
2697 unsigned plaintext_len;
2699 /* Create KASUMI session */
2700 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2701 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2702 RTE_CRYPTO_CIPHER_KASUMI_F8,
2703 tdata->key.data, tdata->key.len,
2704 tdata->cipher_iv.len);
2708 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2710 /* Clear mbuf payload */
2711 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2712 rte_pktmbuf_tailroom(ut_params->ibuf));
2714 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2715 /* Append data which is padded to a multiple */
2716 /* of the algorithms block size */
2717 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2718 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2720 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2722 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2724 /* Create KASUMI operation */
2725 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2726 tdata->cipher_iv.len,
2727 tdata->plaintext.len,
2732 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2734 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2736 ut_params->obuf = ut_params->op->sym->m_dst;
2737 if (ut_params->obuf)
2738 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2740 ciphertext = plaintext;
2742 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2745 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2747 tdata->ciphertext.data,
2748 tdata->validCipherLenInBits.len,
2749 "KASUMI Ciphertext data not as expected");
2754 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2756 struct crypto_testsuite_params *ts_params = &testsuite_params;
2757 struct crypto_unittest_params *ut_params = &unittest_params;
2761 unsigned int plaintext_pad_len;
2762 unsigned int plaintext_len;
2764 uint8_t buffer[10000];
2765 const uint8_t *ciphertext;
2767 struct rte_cryptodev_info dev_info;
2769 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2770 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2771 printf("Device doesn't support scatter-gather. "
2776 /* Create KASUMI session */
2777 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2778 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2779 RTE_CRYPTO_CIPHER_KASUMI_F8,
2780 tdata->key.data, tdata->key.len,
2781 tdata->cipher_iv.len);
2785 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2788 /* Append data which is padded to a multiple */
2789 /* of the algorithms block size */
2790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2792 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2793 plaintext_pad_len, 10, 0);
2795 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2797 /* Create KASUMI operation */
2798 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2799 tdata->cipher_iv.len,
2800 tdata->plaintext.len,
2805 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2807 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2809 ut_params->obuf = ut_params->op->sym->m_dst;
2811 if (ut_params->obuf)
2812 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2813 plaintext_len, buffer);
2815 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2816 plaintext_len, buffer);
2819 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2822 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2824 tdata->ciphertext.data,
2825 tdata->validCipherLenInBits.len,
2826 "KASUMI Ciphertext data not as expected");
2831 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2833 struct crypto_testsuite_params *ts_params = &testsuite_params;
2834 struct crypto_unittest_params *ut_params = &unittest_params;
2837 uint8_t *plaintext, *ciphertext;
2838 unsigned plaintext_pad_len;
2839 unsigned plaintext_len;
2841 /* Create KASUMI session */
2842 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2843 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2844 RTE_CRYPTO_CIPHER_KASUMI_F8,
2845 tdata->key.data, tdata->key.len,
2846 tdata->cipher_iv.len);
2850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2851 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2853 /* Clear mbuf payload */
2854 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2855 rte_pktmbuf_tailroom(ut_params->ibuf));
2857 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2858 /* Append data which is padded to a multiple */
2859 /* of the algorithms block size */
2860 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2861 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2863 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2864 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2866 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2868 /* Create KASUMI operation */
2869 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2870 tdata->cipher_iv.len,
2871 tdata->plaintext.len,
2876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2878 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2880 ut_params->obuf = ut_params->op->sym->m_dst;
2881 if (ut_params->obuf)
2882 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2884 ciphertext = plaintext;
2886 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2889 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2891 tdata->ciphertext.data,
2892 tdata->validCipherLenInBits.len,
2893 "KASUMI Ciphertext data not as expected");
2898 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2900 struct crypto_testsuite_params *ts_params = &testsuite_params;
2901 struct crypto_unittest_params *ut_params = &unittest_params;
2904 unsigned int plaintext_pad_len;
2905 unsigned int plaintext_len;
2907 const uint8_t *ciphertext;
2908 uint8_t buffer[2048];
2910 struct rte_cryptodev_info dev_info;
2912 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2913 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2914 printf("Device doesn't support scatter-gather. "
2919 /* Create KASUMI session */
2920 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2921 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2922 RTE_CRYPTO_CIPHER_KASUMI_F8,
2923 tdata->key.data, tdata->key.len,
2924 tdata->cipher_iv.len);
2928 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2929 /* Append data which is padded to a multiple */
2930 /* of the algorithms block size */
2931 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2933 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2934 plaintext_pad_len, 10, 0);
2935 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2936 plaintext_pad_len, 3, 0);
2938 /* Append data which is padded to a multiple */
2939 /* of the algorithms block size */
2940 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2942 /* Create KASUMI operation */
2943 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
2944 tdata->cipher_iv.len,
2945 tdata->plaintext.len,
2950 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2952 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2954 ut_params->obuf = ut_params->op->sym->m_dst;
2955 if (ut_params->obuf)
2956 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2957 plaintext_pad_len, buffer);
2959 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
2960 plaintext_pad_len, buffer);
2963 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2965 tdata->ciphertext.data,
2966 tdata->validCipherLenInBits.len,
2967 "KASUMI Ciphertext data not as expected");
2973 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2975 struct crypto_testsuite_params *ts_params = &testsuite_params;
2976 struct crypto_unittest_params *ut_params = &unittest_params;
2979 uint8_t *ciphertext, *plaintext;
2980 unsigned ciphertext_pad_len;
2981 unsigned ciphertext_len;
2983 /* Create KASUMI session */
2984 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2985 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2986 RTE_CRYPTO_CIPHER_KASUMI_F8,
2987 tdata->key.data, tdata->key.len,
2988 tdata->cipher_iv.len);
2992 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2993 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2995 /* Clear mbuf payload */
2996 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2997 rte_pktmbuf_tailroom(ut_params->ibuf));
2999 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3000 /* Append data which is padded to a multiple */
3001 /* of the algorithms block size */
3002 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3003 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3004 ciphertext_pad_len);
3005 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3006 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3008 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3010 /* Create KASUMI operation */
3011 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3012 tdata->cipher_iv.len,
3013 tdata->ciphertext.len,
3018 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3020 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3022 ut_params->obuf = ut_params->op->sym->m_dst;
3023 if (ut_params->obuf)
3024 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3026 plaintext = ciphertext;
3028 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3031 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3033 tdata->plaintext.data,
3034 tdata->validCipherLenInBits.len,
3035 "KASUMI Plaintext data not as expected");
3040 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3042 struct crypto_testsuite_params *ts_params = &testsuite_params;
3043 struct crypto_unittest_params *ut_params = &unittest_params;
3046 uint8_t *ciphertext, *plaintext;
3047 unsigned ciphertext_pad_len;
3048 unsigned ciphertext_len;
3050 /* Create KASUMI session */
3051 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3052 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3053 RTE_CRYPTO_CIPHER_KASUMI_F8,
3054 tdata->key.data, tdata->key.len,
3055 tdata->cipher_iv.len);
3059 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3061 /* Clear mbuf payload */
3062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3063 rte_pktmbuf_tailroom(ut_params->ibuf));
3065 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3066 /* Append data which is padded to a multiple */
3067 /* of the algorithms block size */
3068 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3069 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3070 ciphertext_pad_len);
3071 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3073 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3075 /* Create KASUMI operation */
3076 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3077 tdata->cipher_iv.len,
3078 tdata->ciphertext.len,
3083 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3087 ut_params->obuf = ut_params->op->sym->m_dst;
3088 if (ut_params->obuf)
3089 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3091 plaintext = ciphertext;
3093 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3096 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3098 tdata->plaintext.data,
3099 tdata->validCipherLenInBits.len,
3100 "KASUMI Plaintext data not as expected");
3105 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3107 struct crypto_testsuite_params *ts_params = &testsuite_params;
3108 struct crypto_unittest_params *ut_params = &unittest_params;
3111 uint8_t *plaintext, *ciphertext;
3112 unsigned plaintext_pad_len;
3113 unsigned plaintext_len;
3115 /* Create SNOW 3G session */
3116 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3117 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3118 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3119 tdata->key.data, tdata->key.len,
3120 tdata->cipher_iv.len);
3124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3126 /* Clear mbuf payload */
3127 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3128 rte_pktmbuf_tailroom(ut_params->ibuf));
3130 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3131 /* Append data which is padded to a multiple of */
3132 /* the algorithms block size */
3133 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3134 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3136 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3138 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3140 /* Create SNOW 3G operation */
3141 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3142 tdata->cipher_iv.len,
3143 tdata->validCipherLenInBits.len,
3148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3150 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3152 ut_params->obuf = ut_params->op->sym->m_dst;
3153 if (ut_params->obuf)
3154 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3156 ciphertext = plaintext;
3158 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3163 tdata->ciphertext.data,
3164 tdata->validDataLenInBits.len,
3165 "SNOW 3G Ciphertext data not as expected");
3171 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3173 struct crypto_testsuite_params *ts_params = &testsuite_params;
3174 struct crypto_unittest_params *ut_params = &unittest_params;
3175 uint8_t *plaintext, *ciphertext;
3178 unsigned plaintext_pad_len;
3179 unsigned plaintext_len;
3181 /* Create SNOW 3G session */
3182 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3183 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3184 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3185 tdata->key.data, tdata->key.len,
3186 tdata->cipher_iv.len);
3190 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3191 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3193 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3194 "Failed to allocate input buffer in mempool");
3195 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3196 "Failed to allocate output buffer in mempool");
3198 /* Clear mbuf payload */
3199 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3200 rte_pktmbuf_tailroom(ut_params->ibuf));
3202 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3203 /* Append data which is padded to a multiple of */
3204 /* the algorithms block size */
3205 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3206 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3208 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3209 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3211 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3213 /* Create SNOW 3G operation */
3214 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3215 tdata->cipher_iv.len,
3216 tdata->validCipherLenInBits.len,
3221 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3223 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3225 ut_params->obuf = ut_params->op->sym->m_dst;
3226 if (ut_params->obuf)
3227 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3229 ciphertext = plaintext;
3231 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3236 tdata->ciphertext.data,
3237 tdata->validDataLenInBits.len,
3238 "SNOW 3G Ciphertext data not as expected");
3243 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3245 struct crypto_testsuite_params *ts_params = &testsuite_params;
3246 struct crypto_unittest_params *ut_params = &unittest_params;
3249 unsigned int plaintext_pad_len;
3250 unsigned int plaintext_len;
3251 uint8_t buffer[10000];
3252 const uint8_t *ciphertext;
3254 struct rte_cryptodev_info dev_info;
3256 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3257 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3258 printf("Device doesn't support scatter-gather. "
3263 /* Create SNOW 3G session */
3264 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3265 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3266 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3267 tdata->key.data, tdata->key.len,
3268 tdata->cipher_iv.len);
3272 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3273 /* Append data which is padded to a multiple of */
3274 /* the algorithms block size */
3275 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3277 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3278 plaintext_pad_len, 10, 0);
3279 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3280 plaintext_pad_len, 3, 0);
3282 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3283 "Failed to allocate input buffer in mempool");
3284 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3285 "Failed to allocate output buffer in mempool");
3287 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3289 /* Create SNOW 3G operation */
3290 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3291 tdata->cipher_iv.len,
3292 tdata->validCipherLenInBits.len,
3297 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3299 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3301 ut_params->obuf = ut_params->op->sym->m_dst;
3302 if (ut_params->obuf)
3303 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3304 plaintext_len, buffer);
3306 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3307 plaintext_len, buffer);
3309 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3314 tdata->ciphertext.data,
3315 tdata->validDataLenInBits.len,
3316 "SNOW 3G Ciphertext data not as expected");
3321 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3323 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3325 uint8_t curr_byte, prev_byte;
3326 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3327 uint8_t lower_byte_mask = (1 << offset) - 1;
3330 prev_byte = buffer[0];
3331 buffer[0] >>= offset;
3333 for (i = 1; i < length_in_bytes; i++) {
3334 curr_byte = buffer[i];
3335 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3336 (curr_byte >> offset);
3337 prev_byte = curr_byte;
3342 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3344 struct crypto_testsuite_params *ts_params = &testsuite_params;
3345 struct crypto_unittest_params *ut_params = &unittest_params;
3346 uint8_t *plaintext, *ciphertext;
3348 uint32_t plaintext_len;
3349 uint32_t plaintext_pad_len;
3350 uint8_t extra_offset = 4;
3351 uint8_t *expected_ciphertext_shifted;
3353 /* Create SNOW 3G session */
3354 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3355 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3356 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3357 tdata->key.data, tdata->key.len,
3358 tdata->cipher_iv.len);
3362 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3363 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3365 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3366 "Failed to allocate input buffer in mempool");
3367 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3368 "Failed to allocate output buffer in mempool");
3370 /* Clear mbuf payload */
3371 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3372 rte_pktmbuf_tailroom(ut_params->ibuf));
3374 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3376 * Append data which is padded to a
3377 * multiple of the algorithms block size
3379 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3381 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3384 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3386 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3387 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3389 #ifdef RTE_APP_TEST_DEBUG
3390 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3392 /* Create SNOW 3G operation */
3393 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3394 tdata->cipher_iv.len,
3395 tdata->validCipherLenInBits.len,
3400 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3402 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3404 ut_params->obuf = ut_params->op->sym->m_dst;
3405 if (ut_params->obuf)
3406 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3408 ciphertext = plaintext;
3410 #ifdef RTE_APP_TEST_DEBUG
3411 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3414 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3416 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3417 "failed to reserve memory for ciphertext shifted\n");
3419 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3420 ceil_byte_length(tdata->ciphertext.len));
3421 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3424 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3426 expected_ciphertext_shifted,
3427 tdata->validDataLenInBits.len,
3429 "SNOW 3G Ciphertext data not as expected");
3433 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3435 struct crypto_testsuite_params *ts_params = &testsuite_params;
3436 struct crypto_unittest_params *ut_params = &unittest_params;
3440 uint8_t *plaintext, *ciphertext;
3441 unsigned ciphertext_pad_len;
3442 unsigned ciphertext_len;
3444 /* Create SNOW 3G session */
3445 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3446 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3447 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3448 tdata->key.data, tdata->key.len,
3449 tdata->cipher_iv.len);
3453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3455 /* Clear mbuf payload */
3456 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3457 rte_pktmbuf_tailroom(ut_params->ibuf));
3459 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3460 /* Append data which is padded to a multiple of */
3461 /* the algorithms block size */
3462 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3464 ciphertext_pad_len);
3465 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3467 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3469 /* Create SNOW 3G operation */
3470 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3471 tdata->cipher_iv.len,
3472 tdata->validCipherLenInBits.len,
3477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3479 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3480 ut_params->obuf = ut_params->op->sym->m_dst;
3481 if (ut_params->obuf)
3482 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3484 plaintext = ciphertext;
3486 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3489 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3490 tdata->plaintext.data,
3491 tdata->validDataLenInBits.len,
3492 "SNOW 3G Plaintext data not as expected");
3496 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3498 struct crypto_testsuite_params *ts_params = &testsuite_params;
3499 struct crypto_unittest_params *ut_params = &unittest_params;
3503 uint8_t *plaintext, *ciphertext;
3504 unsigned ciphertext_pad_len;
3505 unsigned ciphertext_len;
3507 /* Create SNOW 3G session */
3508 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3509 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3510 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3511 tdata->key.data, tdata->key.len,
3512 tdata->cipher_iv.len);
3516 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3517 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3519 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3520 "Failed to allocate input buffer");
3521 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3522 "Failed to allocate output buffer");
3524 /* Clear mbuf payload */
3525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3526 rte_pktmbuf_tailroom(ut_params->ibuf));
3528 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3529 rte_pktmbuf_tailroom(ut_params->obuf));
3531 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3532 /* Append data which is padded to a multiple of */
3533 /* the algorithms block size */
3534 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3535 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3536 ciphertext_pad_len);
3537 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3538 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3540 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3542 /* Create SNOW 3G operation */
3543 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3544 tdata->cipher_iv.len,
3545 tdata->validCipherLenInBits.len,
3550 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3552 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3553 ut_params->obuf = ut_params->op->sym->m_dst;
3554 if (ut_params->obuf)
3555 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3557 plaintext = ciphertext;
3559 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3563 tdata->plaintext.data,
3564 tdata->validDataLenInBits.len,
3565 "SNOW 3G Plaintext data not as expected");
3570 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3572 struct crypto_testsuite_params *ts_params = &testsuite_params;
3573 struct crypto_unittest_params *ut_params = &unittest_params;
3577 uint8_t *plaintext, *ciphertext;
3578 unsigned int plaintext_pad_len;
3579 unsigned int plaintext_len;
3581 struct rte_cryptodev_sym_capability_idx cap_idx;
3583 /* Check if device supports ZUC EEA3 */
3584 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3585 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3591 /* Check if device supports ZUC EIA3 */
3592 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3593 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3595 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3599 /* Create ZUC session */
3600 retval = create_zuc_cipher_auth_encrypt_generate_session(
3601 ts_params->valid_devs[0],
3605 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3607 /* clear mbuf payload */
3608 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3609 rte_pktmbuf_tailroom(ut_params->ibuf));
3611 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3612 /* Append data which is padded to a multiple of */
3613 /* the algorithms block size */
3614 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3615 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3617 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3619 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3621 /* Create ZUC operation */
3622 retval = create_zuc_cipher_hash_generate_operation(tdata);
3626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3628 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3629 ut_params->obuf = ut_params->op->sym->m_src;
3630 if (ut_params->obuf)
3631 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3633 ciphertext = plaintext;
3635 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3637 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3639 tdata->ciphertext.data,
3640 tdata->validDataLenInBits.len,
3641 "ZUC Ciphertext data not as expected");
3643 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3644 + plaintext_pad_len;
3647 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3651 "ZUC Generated auth tag not as expected");
3656 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3658 struct crypto_testsuite_params *ts_params = &testsuite_params;
3659 struct crypto_unittest_params *ut_params = &unittest_params;
3663 uint8_t *plaintext, *ciphertext;
3664 unsigned plaintext_pad_len;
3665 unsigned plaintext_len;
3667 /* Create SNOW 3G session */
3668 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3669 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3670 RTE_CRYPTO_AUTH_OP_GENERATE,
3671 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3672 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3673 tdata->key.data, tdata->key.len,
3674 tdata->auth_iv.len, tdata->digest.len,
3675 tdata->cipher_iv.len);
3678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3680 /* clear mbuf payload */
3681 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3682 rte_pktmbuf_tailroom(ut_params->ibuf));
3684 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3685 /* Append data which is padded to a multiple of */
3686 /* the algorithms block size */
3687 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3688 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3690 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3692 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3694 /* Create SNOW 3G operation */
3695 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3696 tdata->digest.len, tdata->auth_iv.data,
3698 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3699 tdata->cipher_iv.data, tdata->cipher_iv.len,
3700 tdata->validCipherLenInBits.len,
3702 tdata->validAuthLenInBits.len,
3708 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3710 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3711 ut_params->obuf = ut_params->op->sym->m_src;
3712 if (ut_params->obuf)
3713 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3715 ciphertext = plaintext;
3717 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3719 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3721 tdata->ciphertext.data,
3722 tdata->validDataLenInBits.len,
3723 "SNOW 3G Ciphertext data not as expected");
3725 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3726 + plaintext_pad_len;
3729 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3732 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3733 "SNOW 3G Generated auth tag not as expected");
3737 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3739 struct crypto_testsuite_params *ts_params = &testsuite_params;
3740 struct crypto_unittest_params *ut_params = &unittest_params;
3744 uint8_t *plaintext, *ciphertext;
3745 unsigned plaintext_pad_len;
3746 unsigned plaintext_len;
3748 /* Create SNOW 3G session */
3749 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3750 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3751 RTE_CRYPTO_AUTH_OP_GENERATE,
3752 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3753 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3754 tdata->key.data, tdata->key.len,
3755 tdata->auth_iv.len, tdata->digest.len,
3756 tdata->cipher_iv.len);
3760 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3762 /* clear mbuf payload */
3763 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3764 rte_pktmbuf_tailroom(ut_params->ibuf));
3766 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3767 /* Append data which is padded to a multiple of */
3768 /* the algorithms block size */
3769 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3770 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3772 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3774 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3776 /* Create SNOW 3G operation */
3777 retval = create_wireless_algo_auth_cipher_operation(
3779 tdata->cipher_iv.data, tdata->cipher_iv.len,
3780 tdata->auth_iv.data, tdata->auth_iv.len,
3782 tdata->validCipherLenInBits.len,
3784 tdata->validAuthLenInBits.len,
3790 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3792 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3793 ut_params->obuf = ut_params->op->sym->m_src;
3794 if (ut_params->obuf)
3795 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3797 ciphertext = plaintext;
3799 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3800 + plaintext_pad_len;
3801 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3804 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3806 tdata->ciphertext.data,
3807 tdata->validDataLenInBits.len,
3808 "SNOW 3G Ciphertext data not as expected");
3811 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3814 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3815 "SNOW 3G Generated auth tag not as expected");
3820 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3822 struct crypto_testsuite_params *ts_params = &testsuite_params;
3823 struct crypto_unittest_params *ut_params = &unittest_params;
3827 uint8_t *plaintext, *ciphertext;
3828 unsigned plaintext_pad_len;
3829 unsigned plaintext_len;
3831 /* Create KASUMI session */
3832 retval = create_wireless_algo_auth_cipher_session(
3833 ts_params->valid_devs[0],
3834 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3835 RTE_CRYPTO_AUTH_OP_GENERATE,
3836 RTE_CRYPTO_AUTH_KASUMI_F9,
3837 RTE_CRYPTO_CIPHER_KASUMI_F8,
3838 tdata->key.data, tdata->key.len,
3839 tdata->auth_iv.len, tdata->digest.len,
3840 tdata->cipher_iv.len);
3843 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3845 /* clear mbuf payload */
3846 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3847 rte_pktmbuf_tailroom(ut_params->ibuf));
3849 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3850 /* Append data which is padded to a multiple of */
3851 /* the algorithms block size */
3852 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3853 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3855 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3857 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3859 /* Create KASUMI operation */
3860 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3861 tdata->cipher_iv.data, tdata->cipher_iv.len,
3862 tdata->auth_iv.data, tdata->auth_iv.len,
3864 tdata->validCipherLenInBits.len,
3866 tdata->validAuthLenInBits.len,
3873 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3875 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3876 ut_params->obuf = ut_params->op->sym->m_src;
3877 if (ut_params->obuf)
3878 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3880 ciphertext = plaintext;
3883 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3885 tdata->ciphertext.data,
3886 tdata->validCipherLenInBits.len,
3887 "KASUMI Ciphertext data not as expected");
3888 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3889 + plaintext_pad_len;
3892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3895 DIGEST_BYTE_LENGTH_KASUMI_F9,
3896 "KASUMI Generated auth tag not as expected");
3901 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3903 struct crypto_testsuite_params *ts_params = &testsuite_params;
3904 struct crypto_unittest_params *ut_params = &unittest_params;
3908 uint8_t *plaintext, *ciphertext;
3909 unsigned plaintext_pad_len;
3910 unsigned plaintext_len;
3912 /* Create KASUMI session */
3913 retval = create_wireless_algo_cipher_auth_session(
3914 ts_params->valid_devs[0],
3915 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3916 RTE_CRYPTO_AUTH_OP_GENERATE,
3917 RTE_CRYPTO_AUTH_KASUMI_F9,
3918 RTE_CRYPTO_CIPHER_KASUMI_F8,
3919 tdata->key.data, tdata->key.len,
3920 tdata->auth_iv.len, tdata->digest.len,
3921 tdata->cipher_iv.len);
3925 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3927 /* clear mbuf payload */
3928 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3929 rte_pktmbuf_tailroom(ut_params->ibuf));
3931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3932 /* Append data which is padded to a multiple of */
3933 /* the algorithms block size */
3934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3935 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3937 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3939 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3941 /* Create KASUMI operation */
3942 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3943 tdata->digest.len, tdata->auth_iv.data,
3945 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3946 tdata->cipher_iv.data, tdata->cipher_iv.len,
3947 tdata->validCipherLenInBits.len,
3949 tdata->validAuthLenInBits.len,
3955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3957 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3958 ut_params->obuf = ut_params->op->sym->m_src;
3959 if (ut_params->obuf)
3960 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3962 ciphertext = plaintext;
3964 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3965 + plaintext_pad_len;
3968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3970 tdata->ciphertext.data,
3971 tdata->validCipherLenInBits.len,
3972 "KASUMI Ciphertext data not as expected");
3975 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3978 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3979 "KASUMI Generated auth tag not as expected");
3984 test_zuc_encryption(const struct wireless_test_data *tdata)
3986 struct crypto_testsuite_params *ts_params = &testsuite_params;
3987 struct crypto_unittest_params *ut_params = &unittest_params;
3990 uint8_t *plaintext, *ciphertext;
3991 unsigned plaintext_pad_len;
3992 unsigned plaintext_len;
3994 struct rte_cryptodev_sym_capability_idx cap_idx;
3996 /* Check if device supports ZUC EEA3 */
3997 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3998 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4004 /* Create ZUC session */
4005 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4006 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4007 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4008 tdata->key.data, tdata->key.len,
4009 tdata->cipher_iv.len);
4013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4015 /* Clear mbuf payload */
4016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4017 rte_pktmbuf_tailroom(ut_params->ibuf));
4019 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4020 /* Append data which is padded to a multiple */
4021 /* of the algorithms block size */
4022 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4023 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4025 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4027 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4029 /* Create ZUC operation */
4030 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4031 tdata->cipher_iv.len,
4032 tdata->plaintext.len,
4037 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4039 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4041 ut_params->obuf = ut_params->op->sym->m_dst;
4042 if (ut_params->obuf)
4043 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4045 ciphertext = plaintext;
4047 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4050 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4052 tdata->ciphertext.data,
4053 tdata->validCipherLenInBits.len,
4054 "ZUC Ciphertext data not as expected");
4059 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4061 struct crypto_testsuite_params *ts_params = &testsuite_params;
4062 struct crypto_unittest_params *ut_params = &unittest_params;
4066 unsigned int plaintext_pad_len;
4067 unsigned int plaintext_len;
4068 const uint8_t *ciphertext;
4069 uint8_t ciphertext_buffer[2048];
4070 struct rte_cryptodev_info dev_info;
4072 struct rte_cryptodev_sym_capability_idx cap_idx;
4074 /* Check if device supports ZUC EEA3 */
4075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4076 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4078 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4082 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4083 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4084 printf("Device doesn't support scatter-gather. "
4089 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4091 /* Append data which is padded to a multiple */
4092 /* of the algorithms block size */
4093 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4095 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4096 plaintext_pad_len, 10, 0);
4098 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4099 tdata->plaintext.data);
4101 /* Create ZUC session */
4102 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4103 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4104 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4105 tdata->key.data, tdata->key.len,
4106 tdata->cipher_iv.len);
4110 /* Clear mbuf payload */
4112 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4114 /* Create ZUC operation */
4115 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4116 tdata->cipher_iv.len, tdata->plaintext.len,
4121 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4125 ut_params->obuf = ut_params->op->sym->m_dst;
4126 if (ut_params->obuf)
4127 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4128 0, plaintext_len, ciphertext_buffer);
4130 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4131 0, plaintext_len, ciphertext_buffer);
4134 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4137 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4139 tdata->ciphertext.data,
4140 tdata->validCipherLenInBits.len,
4141 "ZUC Ciphertext data not as expected");
4147 test_zuc_authentication(const struct wireless_test_data *tdata)
4149 struct crypto_testsuite_params *ts_params = &testsuite_params;
4150 struct crypto_unittest_params *ut_params = &unittest_params;
4153 unsigned plaintext_pad_len;
4154 unsigned plaintext_len;
4157 struct rte_cryptodev_sym_capability_idx cap_idx;
4159 /* Check if device supports ZUC EIA3 */
4160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4161 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4167 /* Create ZUC session */
4168 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4169 tdata->key.data, tdata->key.len,
4170 tdata->auth_iv.len, tdata->digest.len,
4171 RTE_CRYPTO_AUTH_OP_GENERATE,
4172 RTE_CRYPTO_AUTH_ZUC_EIA3);
4176 /* alloc mbuf and set payload */
4177 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4179 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4180 rte_pktmbuf_tailroom(ut_params->ibuf));
4182 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4183 /* Append data which is padded to a multiple of */
4184 /* the algorithms block size */
4185 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4186 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4188 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4190 /* Create ZUC operation */
4191 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4192 tdata->auth_iv.data, tdata->auth_iv.len,
4193 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4194 tdata->validAuthLenInBits.len,
4199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4201 ut_params->obuf = ut_params->op->sym->m_src;
4202 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4203 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4204 + plaintext_pad_len;
4207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4210 DIGEST_BYTE_LENGTH_KASUMI_F9,
4211 "ZUC Generated auth tag not as expected");
4217 test_kasumi_encryption_test_case_1(void)
4219 return test_kasumi_encryption(&kasumi_test_case_1);
4223 test_kasumi_encryption_test_case_1_sgl(void)
4225 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4229 test_kasumi_encryption_test_case_1_oop(void)
4231 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4235 test_kasumi_encryption_test_case_1_oop_sgl(void)
4237 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4241 test_kasumi_encryption_test_case_2(void)
4243 return test_kasumi_encryption(&kasumi_test_case_2);
4247 test_kasumi_encryption_test_case_3(void)
4249 return test_kasumi_encryption(&kasumi_test_case_3);
4253 test_kasumi_encryption_test_case_4(void)
4255 return test_kasumi_encryption(&kasumi_test_case_4);
4259 test_kasumi_encryption_test_case_5(void)
4261 return test_kasumi_encryption(&kasumi_test_case_5);
4265 test_kasumi_decryption_test_case_1(void)
4267 return test_kasumi_decryption(&kasumi_test_case_1);
4271 test_kasumi_decryption_test_case_1_oop(void)
4273 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4277 test_kasumi_decryption_test_case_2(void)
4279 return test_kasumi_decryption(&kasumi_test_case_2);
4283 test_kasumi_decryption_test_case_3(void)
4285 return test_kasumi_decryption(&kasumi_test_case_3);
4289 test_kasumi_decryption_test_case_4(void)
4291 return test_kasumi_decryption(&kasumi_test_case_4);
4295 test_kasumi_decryption_test_case_5(void)
4297 return test_kasumi_decryption(&kasumi_test_case_5);
4300 test_snow3g_encryption_test_case_1(void)
4302 return test_snow3g_encryption(&snow3g_test_case_1);
4306 test_snow3g_encryption_test_case_1_oop(void)
4308 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4312 test_snow3g_encryption_test_case_1_oop_sgl(void)
4314 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4319 test_snow3g_encryption_test_case_1_offset_oop(void)
4321 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4325 test_snow3g_encryption_test_case_2(void)
4327 return test_snow3g_encryption(&snow3g_test_case_2);
4331 test_snow3g_encryption_test_case_3(void)
4333 return test_snow3g_encryption(&snow3g_test_case_3);
4337 test_snow3g_encryption_test_case_4(void)
4339 return test_snow3g_encryption(&snow3g_test_case_4);
4343 test_snow3g_encryption_test_case_5(void)
4345 return test_snow3g_encryption(&snow3g_test_case_5);
4349 test_snow3g_decryption_test_case_1(void)
4351 return test_snow3g_decryption(&snow3g_test_case_1);
4355 test_snow3g_decryption_test_case_1_oop(void)
4357 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4361 test_snow3g_decryption_test_case_2(void)
4363 return test_snow3g_decryption(&snow3g_test_case_2);
4367 test_snow3g_decryption_test_case_3(void)
4369 return test_snow3g_decryption(&snow3g_test_case_3);
4373 test_snow3g_decryption_test_case_4(void)
4375 return test_snow3g_decryption(&snow3g_test_case_4);
4379 test_snow3g_decryption_test_case_5(void)
4381 return test_snow3g_decryption(&snow3g_test_case_5);
4384 test_snow3g_cipher_auth_test_case_1(void)
4386 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4390 test_snow3g_auth_cipher_test_case_1(void)
4392 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4396 test_kasumi_auth_cipher_test_case_1(void)
4398 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4402 test_kasumi_cipher_auth_test_case_1(void)
4404 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4408 test_zuc_encryption_test_case_1(void)
4410 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4414 test_zuc_encryption_test_case_2(void)
4416 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4420 test_zuc_encryption_test_case_3(void)
4422 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4426 test_zuc_encryption_test_case_4(void)
4428 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4432 test_zuc_encryption_test_case_5(void)
4434 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4438 test_zuc_encryption_test_case_6_sgl(void)
4440 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4444 test_zuc_hash_generate_test_case_1(void)
4446 return test_zuc_authentication(&zuc_test_case_auth_1b);
4450 test_zuc_hash_generate_test_case_2(void)
4452 return test_zuc_authentication(&zuc_test_case_auth_90b);
4456 test_zuc_hash_generate_test_case_3(void)
4458 return test_zuc_authentication(&zuc_test_case_auth_577b);
4462 test_zuc_hash_generate_test_case_4(void)
4464 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4468 test_zuc_hash_generate_test_case_5(void)
4470 return test_zuc_authentication(&zuc_test_auth_5670b);
4474 test_zuc_hash_generate_test_case_6(void)
4476 return test_zuc_authentication(&zuc_test_case_auth_128b);
4480 test_zuc_hash_generate_test_case_7(void)
4482 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4486 test_zuc_hash_generate_test_case_8(void)
4488 return test_zuc_authentication(&zuc_test_case_auth_584b);
4492 test_zuc_cipher_auth_test_case_1(void)
4494 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4498 test_zuc_cipher_auth_test_case_2(void)
4500 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4504 test_3DES_chain_qat_all(void)
4506 struct crypto_testsuite_params *ts_params = &testsuite_params;
4509 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4510 ts_params->op_mpool, ts_params->valid_devs[0],
4511 RTE_CRYPTODEV_QAT_SYM_PMD,
4512 BLKCIPHER_3DES_CHAIN_TYPE);
4514 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4516 return TEST_SUCCESS;
4520 test_DES_cipheronly_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_DES_CIPHERONLY_TYPE);
4530 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4532 return TEST_SUCCESS;
4536 test_DES_docsis_openssl_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_OPENSSL_PMD,
4544 BLKCIPHER_DES_DOCSIS_TYPE);
4546 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4548 return TEST_SUCCESS;
4552 test_3DES_chain_dpaa2_sec_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_DPAA2_SEC_PMD,
4560 BLKCIPHER_3DES_CHAIN_TYPE);
4562 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4564 return TEST_SUCCESS;
4568 test_3DES_cipheronly_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_CIPHERONLY_TYPE);
4578 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4580 return TEST_SUCCESS;
4584 test_3DES_cipheronly_qat_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_QAT_SYM_PMD,
4592 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4594 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4596 return TEST_SUCCESS;
4600 test_3DES_chain_openssl_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_OPENSSL_PMD,
4608 BLKCIPHER_3DES_CHAIN_TYPE);
4610 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4612 return TEST_SUCCESS;
4616 test_3DES_cipheronly_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_CIPHERONLY_TYPE);
4626 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4628 return TEST_SUCCESS;
4631 /* ***** AES-GCM Tests ***** */
4634 create_gcm_session(uint8_t dev_id, enum rte_crypto_aead_operation op,
4635 const uint8_t *key, const uint8_t key_len,
4636 const uint16_t aad_len, const uint8_t auth_len,
4639 uint8_t aead_key[key_len];
4641 struct crypto_unittest_params *ut_params = &unittest_params;
4643 memcpy(aead_key, key, key_len);
4645 /* Setup AEAD Parameters */
4646 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4647 ut_params->aead_xform.next = NULL;
4648 ut_params->aead_xform.aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4649 ut_params->aead_xform.aead.op = op;
4650 ut_params->aead_xform.aead.key.data = aead_key;
4651 ut_params->aead_xform.aead.key.length = key_len;
4652 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
4653 ut_params->aead_xform.aead.iv.length = iv_len;
4654 ut_params->aead_xform.aead.digest_length = auth_len;
4655 ut_params->aead_xform.aead.add_auth_data_length = aad_len;
4657 TEST_HEXDUMP(stdout, "key:", key, key_len);
4659 /* Create Crypto session*/
4660 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4661 &ut_params->aead_xform);
4663 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4669 create_gcm_xforms(struct rte_crypto_op *op,
4670 enum rte_crypto_aead_operation aead_op,
4671 uint8_t *key, const uint8_t key_len,
4672 const uint8_t aad_len, const uint8_t auth_len,
4675 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
4676 "failed to allocate space for crypto transform");
4678 struct rte_crypto_sym_op *sym_op = op->sym;
4680 /* Setup AEAD Parameters */
4681 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
4682 sym_op->xform->next = NULL;
4683 sym_op->xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
4684 sym_op->xform->aead.op = aead_op;
4685 sym_op->xform->aead.key.data = key;
4686 sym_op->xform->aead.key.length = key_len;
4687 sym_op->xform->aead.iv.offset = IV_OFFSET;
4688 sym_op->xform->aead.iv.length = iv_len;
4689 sym_op->xform->aead.digest_length = auth_len;
4690 sym_op->xform->aead.add_auth_data_length = aad_len;
4692 TEST_HEXDUMP(stdout, "key:", key, key_len);
4698 create_gcm_operation(enum rte_crypto_aead_operation op,
4699 const struct gcm_test_data *tdata)
4701 struct crypto_testsuite_params *ts_params = &testsuite_params;
4702 struct crypto_unittest_params *ut_params = &unittest_params;
4704 uint8_t *plaintext, *ciphertext;
4705 unsigned int aad_pad_len, plaintext_pad_len;
4707 /* Generate Crypto op data structure */
4708 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4709 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4710 TEST_ASSERT_NOT_NULL(ut_params->op,
4711 "Failed to allocate symmetric crypto operation struct");
4713 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4715 /* Append aad data */
4716 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4717 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4719 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
4720 "no room to append aad");
4722 sym_op->aead.aad.phys_addr =
4723 rte_pktmbuf_mtophys(ut_params->ibuf);
4724 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
4725 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
4728 /* Append IV at the end of the crypto operation*/
4729 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
4730 uint8_t *, IV_OFFSET);
4732 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
4733 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
4736 /* Append plaintext/ciphertext */
4737 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4738 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4739 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4741 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4743 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4744 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4745 tdata->plaintext.len);
4747 if (ut_params->obuf) {
4748 ciphertext = (uint8_t *)rte_pktmbuf_append(
4750 plaintext_pad_len + aad_pad_len);
4751 TEST_ASSERT_NOT_NULL(ciphertext,
4752 "no room to append ciphertext");
4754 memset(ciphertext + aad_pad_len, 0,
4755 tdata->ciphertext.len);
4758 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4759 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4761 TEST_ASSERT_NOT_NULL(ciphertext,
4762 "no room to append ciphertext");
4764 memcpy(ciphertext, tdata->ciphertext.data,
4765 tdata->ciphertext.len);
4766 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4767 tdata->ciphertext.len);
4769 if (ut_params->obuf) {
4770 plaintext = (uint8_t *)rte_pktmbuf_append(
4772 plaintext_pad_len + aad_pad_len);
4773 TEST_ASSERT_NOT_NULL(plaintext,
4774 "no room to append plaintext");
4776 memset(plaintext + aad_pad_len, 0,
4777 tdata->plaintext.len);
4781 /* Append digest data */
4782 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
4783 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4784 ut_params->obuf ? ut_params->obuf :
4786 tdata->auth_tag.len);
4787 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4788 "no room to append digest");
4789 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
4790 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4791 ut_params->obuf ? ut_params->obuf :
4796 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
4797 ut_params->ibuf, tdata->auth_tag.len);
4798 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
4799 "no room to append digest");
4800 sym_op->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4802 plaintext_pad_len + aad_pad_len);
4804 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
4805 tdata->auth_tag.len);
4806 TEST_HEXDUMP(stdout, "digest:",
4807 sym_op->aead.digest.data,
4808 tdata->auth_tag.len);
4811 sym_op->aead.data.length = tdata->plaintext.len;
4812 sym_op->aead.data.offset = aad_pad_len;
4818 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4820 struct crypto_testsuite_params *ts_params = &testsuite_params;
4821 struct crypto_unittest_params *ut_params = &unittest_params;
4824 uint8_t *ciphertext, *auth_tag;
4825 uint16_t plaintext_pad_len;
4828 /* Create GCM session */
4829 retval = create_gcm_session(ts_params->valid_devs[0],
4830 RTE_CRYPTO_AEAD_OP_ENCRYPT,
4831 tdata->key.data, tdata->key.len,
4832 tdata->aad.len, tdata->auth_tag.len,
4837 if (tdata->aad.len > MBUF_SIZE) {
4838 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4839 /* Populate full size of add data */
4840 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4841 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4843 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4845 /* clear mbuf payload */
4846 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4847 rte_pktmbuf_tailroom(ut_params->ibuf));
4849 /* Create GCM operation */
4850 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
4854 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4856 ut_params->op->sym->m_src = ut_params->ibuf;
4858 /* Process crypto operation */
4859 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4860 ut_params->op), "failed to process sym crypto op");
4862 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4863 "crypto op processing failed");
4865 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4867 if (ut_params->op->sym->m_dst) {
4868 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4870 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4871 uint8_t *, plaintext_pad_len);
4873 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4875 ut_params->op->sym->cipher.data.offset);
4876 auth_tag = ciphertext + plaintext_pad_len;
4879 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4880 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4883 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4885 tdata->ciphertext.data,
4886 tdata->ciphertext.len,
4887 "GCM Ciphertext data not as expected");
4889 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4891 tdata->auth_tag.data,
4892 tdata->auth_tag.len,
4893 "GCM Generated auth tag not as expected");
4900 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4902 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4906 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4908 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4912 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4914 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4918 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4920 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4924 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4926 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4930 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4932 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4936 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4938 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4942 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4944 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4948 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4950 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4954 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4956 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4960 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4962 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4966 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4968 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4972 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4974 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4978 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4980 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4984 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4986 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4990 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4992 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4996 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4998 struct crypto_testsuite_params *ts_params = &testsuite_params;
4999 struct crypto_unittest_params *ut_params = &unittest_params;
5005 /* Create GCM session */
5006 retval = create_gcm_session(ts_params->valid_devs[0],
5007 RTE_CRYPTO_AEAD_OP_DECRYPT,
5008 tdata->key.data, tdata->key.len,
5009 tdata->aad.len, tdata->auth_tag.len,
5014 /* alloc mbuf and set payload */
5015 if (tdata->aad.len > MBUF_SIZE) {
5016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5017 /* Populate full size of add data */
5018 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
5019 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5021 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5023 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5024 rte_pktmbuf_tailroom(ut_params->ibuf));
5026 /* Create GCM operation */
5027 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5031 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5033 ut_params->op->sym->m_src = ut_params->ibuf;
5035 /* Process crypto operation */
5036 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5037 ut_params->op), "failed to process sym crypto op");
5039 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5040 "crypto op processing failed");
5042 if (ut_params->op->sym->m_dst)
5043 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5046 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5048 ut_params->op->sym->cipher.data.offset);
5050 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5053 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5055 tdata->plaintext.data,
5056 tdata->plaintext.len,
5057 "GCM plaintext data not as expected");
5059 TEST_ASSERT_EQUAL(ut_params->op->status,
5060 RTE_CRYPTO_OP_STATUS_SUCCESS,
5061 "GCM authentication failed");
5066 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
5068 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
5072 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
5074 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
5078 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
5080 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
5084 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
5086 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
5090 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
5092 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
5096 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
5098 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
5102 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
5104 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
5108 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
5110 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
5114 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
5116 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
5120 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
5122 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
5126 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
5128 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
5132 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
5134 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
5138 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
5140 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
5144 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
5146 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
5150 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
5152 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
5156 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
5158 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
5162 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
5164 struct crypto_testsuite_params *ts_params = &testsuite_params;
5165 struct crypto_unittest_params *ut_params = &unittest_params;
5168 uint8_t *ciphertext, *auth_tag;
5169 uint16_t plaintext_pad_len;
5171 /* Create GCM session */
5172 retval = create_gcm_session(ts_params->valid_devs[0],
5173 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5174 tdata->key.data, tdata->key.len,
5175 tdata->aad.len, tdata->auth_tag.len,
5180 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5181 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5183 /* clear mbuf payload */
5184 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5185 rte_pktmbuf_tailroom(ut_params->ibuf));
5186 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5187 rte_pktmbuf_tailroom(ut_params->obuf));
5189 /* Create GCM operation */
5190 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5194 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5196 ut_params->op->sym->m_src = ut_params->ibuf;
5197 ut_params->op->sym->m_dst = ut_params->obuf;
5199 /* Process crypto operation */
5200 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5201 ut_params->op), "failed to process sym crypto op");
5203 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5204 "crypto op processing failed");
5206 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5208 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5209 ut_params->op->sym->cipher.data.offset);
5210 auth_tag = ciphertext + plaintext_pad_len;
5212 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5213 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5216 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5218 tdata->ciphertext.data,
5219 tdata->ciphertext.len,
5220 "GCM Ciphertext data not as expected");
5222 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5224 tdata->auth_tag.data,
5225 tdata->auth_tag.len,
5226 "GCM Generated auth tag not as expected");
5233 test_mb_AES_GCM_authenticated_encryption_oop(void)
5235 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
5239 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
5241 struct crypto_testsuite_params *ts_params = &testsuite_params;
5242 struct crypto_unittest_params *ut_params = &unittest_params;
5247 /* Create GCM session */
5248 retval = create_gcm_session(ts_params->valid_devs[0],
5249 RTE_CRYPTO_AEAD_OP_DECRYPT,
5250 tdata->key.data, tdata->key.len,
5251 tdata->aad.len, tdata->auth_tag.len,
5256 /* alloc mbuf and set payload */
5257 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5258 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5260 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5261 rte_pktmbuf_tailroom(ut_params->ibuf));
5262 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5263 rte_pktmbuf_tailroom(ut_params->obuf));
5265 /* Create GCM operation */
5266 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5270 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5272 ut_params->op->sym->m_src = ut_params->ibuf;
5273 ut_params->op->sym->m_dst = ut_params->obuf;
5275 /* Process crypto operation */
5276 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5277 ut_params->op), "failed to process sym crypto op");
5279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5280 "crypto op processing failed");
5282 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5283 ut_params->op->sym->cipher.data.offset);
5285 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5290 tdata->plaintext.data,
5291 tdata->plaintext.len,
5292 "GCM plaintext data not as expected");
5294 TEST_ASSERT_EQUAL(ut_params->op->status,
5295 RTE_CRYPTO_OP_STATUS_SUCCESS,
5296 "GCM authentication failed");
5301 test_mb_AES_GCM_authenticated_decryption_oop(void)
5303 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5307 test_AES_GCM_authenticated_encryption_sessionless(
5308 const struct gcm_test_data *tdata)
5310 struct crypto_testsuite_params *ts_params = &testsuite_params;
5311 struct crypto_unittest_params *ut_params = &unittest_params;
5314 uint8_t *ciphertext, *auth_tag;
5315 uint16_t plaintext_pad_len;
5316 uint8_t key[tdata->key.len + 1];
5318 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5320 /* clear mbuf payload */
5321 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5322 rte_pktmbuf_tailroom(ut_params->ibuf));
5324 /* Create GCM operation */
5325 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5329 /* Create GCM xforms */
5330 memcpy(key, tdata->key.data, tdata->key.len);
5331 retval = create_gcm_xforms(ut_params->op,
5332 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5333 key, tdata->key.len,
5334 tdata->aad.len, tdata->auth_tag.len,
5339 ut_params->op->sym->m_src = ut_params->ibuf;
5341 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5342 RTE_CRYPTO_OP_SESSIONLESS,
5343 "crypto op session type not sessionless");
5345 /* Process crypto operation */
5346 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5347 ut_params->op), "failed to process sym crypto op");
5349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5351 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5352 "crypto op status not success");
5354 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5356 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5357 ut_params->op->sym->cipher.data.offset);
5358 auth_tag = ciphertext + plaintext_pad_len;
5360 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5361 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5364 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5366 tdata->ciphertext.data,
5367 tdata->ciphertext.len,
5368 "GCM Ciphertext data not as expected");
5370 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5372 tdata->auth_tag.data,
5373 tdata->auth_tag.len,
5374 "GCM Generated auth tag not as expected");
5381 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5383 return test_AES_GCM_authenticated_encryption_sessionless(
5388 test_AES_GCM_authenticated_decryption_sessionless(
5389 const struct gcm_test_data *tdata)
5391 struct crypto_testsuite_params *ts_params = &testsuite_params;
5392 struct crypto_unittest_params *ut_params = &unittest_params;
5396 uint8_t key[tdata->key.len + 1];
5398 /* alloc mbuf and set payload */
5399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5402 rte_pktmbuf_tailroom(ut_params->ibuf));
5404 /* Create GCM operation */
5405 retval = create_gcm_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5409 /* Create GCM xforms */
5410 memcpy(key, tdata->key.data, tdata->key.len);
5411 retval = create_gcm_xforms(ut_params->op,
5412 RTE_CRYPTO_AEAD_OP_DECRYPT,
5413 key, tdata->key.len,
5414 tdata->aad.len, tdata->auth_tag.len,
5419 ut_params->op->sym->m_src = ut_params->ibuf;
5421 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5422 RTE_CRYPTO_OP_SESSIONLESS,
5423 "crypto op session type not sessionless");
5425 /* Process crypto operation */
5426 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5427 ut_params->op), "failed to process sym crypto op");
5429 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5431 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5432 "crypto op status not success");
5434 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5435 ut_params->op->sym->cipher.data.offset);
5437 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5440 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5442 tdata->plaintext.data,
5443 tdata->plaintext.len,
5444 "GCM plaintext data not as expected");
5446 TEST_ASSERT_EQUAL(ut_params->op->status,
5447 RTE_CRYPTO_OP_STATUS_SUCCESS,
5448 "GCM authentication failed");
5453 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5455 return test_AES_GCM_authenticated_decryption_sessionless(
5462 struct crypto_testsuite_params *ts_params = &testsuite_params;
5463 struct rte_cryptodev_stats stats;
5464 struct rte_cryptodev *dev;
5465 cryptodev_stats_get_t temp_pfn;
5467 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5468 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5469 &stats) == -ENODEV),
5470 "rte_cryptodev_stats_get invalid dev failed");
5471 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5472 "rte_cryptodev_stats_get invalid Param failed");
5473 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5474 temp_pfn = dev->dev_ops->stats_get;
5475 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5476 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5478 "rte_cryptodev_stats_get invalid Param failed");
5479 dev->dev_ops->stats_get = temp_pfn;
5481 /* Test expected values */
5483 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5485 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5487 "rte_cryptodev_stats_get failed");
5488 TEST_ASSERT((stats.enqueued_count == 1),
5489 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5490 TEST_ASSERT((stats.dequeued_count == 1),
5491 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5492 TEST_ASSERT((stats.enqueue_err_count == 0),
5493 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5494 TEST_ASSERT((stats.dequeue_err_count == 0),
5495 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5497 /* invalid device but should ignore and not reset device stats*/
5498 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5499 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5501 "rte_cryptodev_stats_get failed");
5502 TEST_ASSERT((stats.enqueued_count == 1),
5503 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5505 /* check that a valid reset clears stats */
5506 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5507 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5509 "rte_cryptodev_stats_get failed");
5510 TEST_ASSERT((stats.enqueued_count == 0),
5511 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5512 TEST_ASSERT((stats.dequeued_count == 0),
5513 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5515 return TEST_SUCCESS;
5518 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5519 struct crypto_unittest_params *ut_params,
5520 enum rte_crypto_auth_operation op,
5521 const struct HMAC_MD5_vector *test_case)
5525 memcpy(key, test_case->key.data, test_case->key.len);
5527 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5528 ut_params->auth_xform.next = NULL;
5529 ut_params->auth_xform.auth.op = op;
5531 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5533 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5534 ut_params->auth_xform.auth.add_auth_data_length = 0;
5535 ut_params->auth_xform.auth.key.length = test_case->key.len;
5536 ut_params->auth_xform.auth.key.data = key;
5538 ut_params->sess = rte_cryptodev_sym_session_create(
5539 ts_params->valid_devs[0], &ut_params->auth_xform);
5541 if (ut_params->sess == NULL)
5544 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5546 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5547 rte_pktmbuf_tailroom(ut_params->ibuf));
5552 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5553 const struct HMAC_MD5_vector *test_case,
5554 uint8_t **plaintext)
5556 uint16_t plaintext_pad_len;
5558 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5560 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5563 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5565 memcpy(*plaintext, test_case->plaintext.data,
5566 test_case->plaintext.len);
5568 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5569 ut_params->ibuf, MD5_DIGEST_LEN);
5570 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5571 "no room to append digest");
5572 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5573 ut_params->ibuf, plaintext_pad_len);
5575 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5576 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5577 test_case->auth_tag.len);
5580 sym_op->auth.data.offset = 0;
5581 sym_op->auth.data.length = test_case->plaintext.len;
5583 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5584 ut_params->op->sym->m_src = ut_params->ibuf;
5590 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5592 uint16_t plaintext_pad_len;
5593 uint8_t *plaintext, *auth_tag;
5595 struct crypto_testsuite_params *ts_params = &testsuite_params;
5596 struct crypto_unittest_params *ut_params = &unittest_params;
5598 if (MD5_HMAC_create_session(ts_params, ut_params,
5599 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5602 /* Generate Crypto op data structure */
5603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5604 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5605 TEST_ASSERT_NOT_NULL(ut_params->op,
5606 "Failed to allocate symmetric crypto operation struct");
5608 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5611 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5614 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5615 ut_params->op), "failed to process sym crypto op");
5617 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5618 "crypto op processing failed");
5620 if (ut_params->op->sym->m_dst) {
5621 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5622 uint8_t *, plaintext_pad_len);
5624 auth_tag = plaintext + plaintext_pad_len;
5627 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5629 test_case->auth_tag.data,
5630 test_case->auth_tag.len,
5631 "HMAC_MD5 generated tag not as expected");
5633 return TEST_SUCCESS;
5637 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5641 struct crypto_testsuite_params *ts_params = &testsuite_params;
5642 struct crypto_unittest_params *ut_params = &unittest_params;
5644 if (MD5_HMAC_create_session(ts_params, ut_params,
5645 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5649 /* Generate Crypto op data structure */
5650 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5651 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5652 TEST_ASSERT_NOT_NULL(ut_params->op,
5653 "Failed to allocate symmetric crypto operation struct");
5655 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5658 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5659 ut_params->op), "failed to process sym crypto op");
5661 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5662 "HMAC_MD5 crypto op processing failed");
5664 return TEST_SUCCESS;
5668 test_MD5_HMAC_generate_case_1(void)
5670 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5674 test_MD5_HMAC_verify_case_1(void)
5676 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5680 test_MD5_HMAC_generate_case_2(void)
5682 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5686 test_MD5_HMAC_verify_case_2(void)
5688 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5692 test_multi_session(void)
5694 struct crypto_testsuite_params *ts_params = &testsuite_params;
5695 struct crypto_unittest_params *ut_params = &unittest_params;
5697 struct rte_cryptodev_info dev_info;
5698 struct rte_cryptodev_sym_session **sessions;
5702 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5703 aes_cbc_key, hmac_sha512_key);
5706 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5708 sessions = rte_malloc(NULL,
5709 (sizeof(struct rte_cryptodev_sym_session *) *
5710 dev_info.sym.max_nb_sessions) + 1, 0);
5712 /* Create multiple crypto sessions*/
5713 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5714 sessions[i] = rte_cryptodev_sym_session_create(
5715 ts_params->valid_devs[0],
5716 &ut_params->auth_xform);
5717 TEST_ASSERT_NOT_NULL(sessions[i],
5718 "Session creation failed at session number %u",
5721 /* Attempt to send a request on each session */
5722 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5726 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5727 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5729 "Failed to perform decrypt on request number %u.", i);
5730 /* free crypto operation structure */
5732 rte_crypto_op_free(ut_params->op);
5735 * free mbuf - both obuf and ibuf are usually the same,
5736 * so check if they point at the same address is necessary,
5737 * to avoid freeing the mbuf twice.
5739 if (ut_params->obuf) {
5740 rte_pktmbuf_free(ut_params->obuf);
5741 if (ut_params->ibuf == ut_params->obuf)
5742 ut_params->ibuf = 0;
5743 ut_params->obuf = 0;
5745 if (ut_params->ibuf) {
5746 rte_pktmbuf_free(ut_params->ibuf);
5747 ut_params->ibuf = 0;
5751 /* Next session create should fail */
5752 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5753 &ut_params->auth_xform);
5754 TEST_ASSERT_NULL(sessions[i],
5755 "Session creation succeeded unexpectedly!");
5757 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5758 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5763 return TEST_SUCCESS;
5766 struct multi_session_params {
5767 struct crypto_unittest_params ut_params;
5768 uint8_t *cipher_key;
5770 const uint8_t *cipher;
5771 const uint8_t *digest;
5775 #define MB_SESSION_NUMBER 3
5778 test_multi_session_random_usage(void)
5780 struct crypto_testsuite_params *ts_params = &testsuite_params;
5781 struct rte_cryptodev_info dev_info;
5782 struct rte_cryptodev_sym_session **sessions;
5784 struct multi_session_params ut_paramz[] = {
5787 .cipher_key = ms_aes_cbc_key0,
5788 .hmac_key = ms_hmac_key0,
5789 .cipher = ms_aes_cbc_cipher0,
5790 .digest = ms_hmac_digest0,
5791 .iv = ms_aes_cbc_iv0
5794 .cipher_key = ms_aes_cbc_key1,
5795 .hmac_key = ms_hmac_key1,
5796 .cipher = ms_aes_cbc_cipher1,
5797 .digest = ms_hmac_digest1,
5798 .iv = ms_aes_cbc_iv1
5801 .cipher_key = ms_aes_cbc_key2,
5802 .hmac_key = ms_hmac_key2,
5803 .cipher = ms_aes_cbc_cipher2,
5804 .digest = ms_hmac_digest2,
5805 .iv = ms_aes_cbc_iv2
5810 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5812 sessions = rte_malloc(NULL,
5813 (sizeof(struct rte_cryptodev_sym_session *)
5814 * dev_info.sym.max_nb_sessions) + 1, 0);
5816 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5817 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5818 sizeof(struct crypto_unittest_params));
5820 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5821 &ut_paramz[i].ut_params,
5822 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5824 /* Create multiple crypto sessions*/
5825 sessions[i] = rte_cryptodev_sym_session_create(
5826 ts_params->valid_devs[0],
5827 &ut_paramz[i].ut_params.auth_xform);
5829 TEST_ASSERT_NOT_NULL(sessions[i],
5830 "Session creation failed at session number %u",
5836 for (i = 0; i < 40000; i++) {
5838 j = rand() % MB_SESSION_NUMBER;
5840 TEST_ASSERT_SUCCESS(
5841 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5843 &ut_paramz[j].ut_params,
5844 ts_params, ut_paramz[j].cipher,
5845 ut_paramz[j].digest,
5847 "Failed to perform decrypt on request number %u.", i);
5849 if (ut_paramz[j].ut_params.op)
5850 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5853 * free mbuf - both obuf and ibuf are usually the same,
5854 * so check if they point at the same address is necessary,
5855 * to avoid freeing the mbuf twice.
5857 if (ut_paramz[j].ut_params.obuf) {
5858 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5859 if (ut_paramz[j].ut_params.ibuf
5860 == ut_paramz[j].ut_params.obuf)
5861 ut_paramz[j].ut_params.ibuf = 0;
5862 ut_paramz[j].ut_params.obuf = 0;
5864 if (ut_paramz[j].ut_params.ibuf) {
5865 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5866 ut_paramz[j].ut_params.ibuf = 0;
5870 for (i = 0; i < MB_SESSION_NUMBER; i++)
5871 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5876 return TEST_SUCCESS;
5880 test_null_cipher_only_operation(void)
5882 struct crypto_testsuite_params *ts_params = &testsuite_params;
5883 struct crypto_unittest_params *ut_params = &unittest_params;
5885 /* Generate test mbuf data and space for digest */
5886 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5887 catch_22_quote, QUOTE_512_BYTES, 0);
5889 /* Setup Cipher Parameters */
5890 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5891 ut_params->cipher_xform.next = NULL;
5893 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5894 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5896 /* Create Crypto session*/
5897 ut_params->sess = rte_cryptodev_sym_session_create(
5898 ts_params->valid_devs[0], &ut_params->cipher_xform);
5899 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5901 /* Generate Crypto op data structure */
5902 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5903 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5904 TEST_ASSERT_NOT_NULL(ut_params->op,
5905 "Failed to allocate symmetric crypto operation struct");
5907 /* Set crypto operation data parameters */
5908 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5910 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5912 /* set crypto operation source mbuf */
5913 sym_op->m_src = ut_params->ibuf;
5915 sym_op->cipher.data.offset = 0;
5916 sym_op->cipher.data.length = QUOTE_512_BYTES;
5918 /* Process crypto operation */
5919 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5921 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5923 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5924 "crypto operation processing failed");
5927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5928 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5931 "Ciphertext data not as expected");
5933 return TEST_SUCCESS;
5937 test_null_auth_only_operation(void)
5939 struct crypto_testsuite_params *ts_params = &testsuite_params;
5940 struct crypto_unittest_params *ut_params = &unittest_params;
5942 /* Generate test mbuf data and space for digest */
5943 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5944 catch_22_quote, QUOTE_512_BYTES, 0);
5946 /* Setup HMAC Parameters */
5947 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5948 ut_params->auth_xform.next = NULL;
5950 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5951 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5953 /* Create Crypto session*/
5954 ut_params->sess = rte_cryptodev_sym_session_create(
5955 ts_params->valid_devs[0], &ut_params->auth_xform);
5956 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5958 /* Generate Crypto op data structure */
5959 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5960 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5961 TEST_ASSERT_NOT_NULL(ut_params->op,
5962 "Failed to allocate symmetric crypto operation struct");
5964 /* Set crypto operation data parameters */
5965 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5967 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5969 sym_op->m_src = ut_params->ibuf;
5971 sym_op->auth.data.offset = 0;
5972 sym_op->auth.data.length = QUOTE_512_BYTES;
5974 /* Process crypto operation */
5975 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5977 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5979 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5980 "crypto operation processing failed");
5982 return TEST_SUCCESS;
5986 test_null_cipher_auth_operation(void)
5988 struct crypto_testsuite_params *ts_params = &testsuite_params;
5989 struct crypto_unittest_params *ut_params = &unittest_params;
5991 /* Generate test mbuf data and space for digest */
5992 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5993 catch_22_quote, QUOTE_512_BYTES, 0);
5995 /* Setup Cipher Parameters */
5996 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5997 ut_params->cipher_xform.next = &ut_params->auth_xform;
5999 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6000 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6002 /* Setup HMAC Parameters */
6003 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6004 ut_params->auth_xform.next = NULL;
6006 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6007 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6009 /* Create Crypto session*/
6010 ut_params->sess = rte_cryptodev_sym_session_create(
6011 ts_params->valid_devs[0], &ut_params->cipher_xform);
6012 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6014 /* Generate Crypto op data structure */
6015 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6016 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6017 TEST_ASSERT_NOT_NULL(ut_params->op,
6018 "Failed to allocate symmetric crypto operation struct");
6020 /* Set crypto operation data parameters */
6021 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6023 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6025 sym_op->m_src = ut_params->ibuf;
6027 sym_op->cipher.data.offset = 0;
6028 sym_op->cipher.data.length = QUOTE_512_BYTES;
6030 sym_op->auth.data.offset = 0;
6031 sym_op->auth.data.length = QUOTE_512_BYTES;
6033 /* Process crypto operation */
6034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6036 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6038 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6039 "crypto operation processing failed");
6042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6043 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6046 "Ciphertext data not as expected");
6048 return TEST_SUCCESS;
6052 test_null_auth_cipher_operation(void)
6054 struct crypto_testsuite_params *ts_params = &testsuite_params;
6055 struct crypto_unittest_params *ut_params = &unittest_params;
6057 /* Generate test mbuf data and space for digest */
6058 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6059 catch_22_quote, QUOTE_512_BYTES, 0);
6061 /* Setup Cipher Parameters */
6062 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6063 ut_params->cipher_xform.next = NULL;
6065 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6066 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6068 /* Setup HMAC Parameters */
6069 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6070 ut_params->auth_xform.next = &ut_params->cipher_xform;
6072 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6073 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6075 /* Create Crypto session*/
6076 ut_params->sess = rte_cryptodev_sym_session_create(
6077 ts_params->valid_devs[0], &ut_params->cipher_xform);
6078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6080 /* Generate Crypto op data structure */
6081 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6082 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6083 TEST_ASSERT_NOT_NULL(ut_params->op,
6084 "Failed to allocate symmetric crypto operation struct");
6086 /* Set crypto operation data parameters */
6087 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6089 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6091 sym_op->m_src = ut_params->ibuf;
6093 sym_op->cipher.data.offset = 0;
6094 sym_op->cipher.data.length = QUOTE_512_BYTES;
6096 sym_op->auth.data.offset = 0;
6097 sym_op->auth.data.length = QUOTE_512_BYTES;
6099 /* Process crypto operation */
6100 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6102 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6104 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6105 "crypto operation processing failed");
6108 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6109 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6112 "Ciphertext data not as expected");
6114 return TEST_SUCCESS;
6119 test_null_invalid_operation(void)
6121 struct crypto_testsuite_params *ts_params = &testsuite_params;
6122 struct crypto_unittest_params *ut_params = &unittest_params;
6124 /* Setup Cipher Parameters */
6125 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6126 ut_params->cipher_xform.next = NULL;
6128 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6129 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6131 /* Create Crypto session*/
6132 ut_params->sess = rte_cryptodev_sym_session_create(
6133 ts_params->valid_devs[0], &ut_params->cipher_xform);
6134 TEST_ASSERT_NULL(ut_params->sess,
6135 "Session creation succeeded unexpectedly");
6138 /* Setup HMAC Parameters */
6139 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6140 ut_params->auth_xform.next = NULL;
6142 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6143 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6145 /* Create Crypto session*/
6146 ut_params->sess = rte_cryptodev_sym_session_create(
6147 ts_params->valid_devs[0], &ut_params->auth_xform);
6148 TEST_ASSERT_NULL(ut_params->sess,
6149 "Session creation succeeded unexpectedly");
6151 return TEST_SUCCESS;
6155 #define NULL_BURST_LENGTH (32)
6158 test_null_burst_operation(void)
6160 struct crypto_testsuite_params *ts_params = &testsuite_params;
6161 struct crypto_unittest_params *ut_params = &unittest_params;
6163 unsigned i, burst_len = NULL_BURST_LENGTH;
6165 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6166 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6168 /* Setup Cipher Parameters */
6169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6170 ut_params->cipher_xform.next = &ut_params->auth_xform;
6172 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6173 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6175 /* Setup HMAC Parameters */
6176 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6177 ut_params->auth_xform.next = NULL;
6179 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6180 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6182 /* Create Crypto session*/
6183 ut_params->sess = rte_cryptodev_sym_session_create(
6184 ts_params->valid_devs[0], &ut_params->cipher_xform);
6185 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6187 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6188 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6189 burst_len, "failed to generate burst of crypto ops");
6191 /* Generate an operation for each mbuf in burst */
6192 for (i = 0; i < burst_len; i++) {
6193 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6195 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6197 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6201 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6203 burst[i]->sym->m_src = m;
6206 /* Process crypto operation */
6207 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6208 0, burst, burst_len),
6210 "Error enqueuing burst");
6212 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6213 0, burst_dequeued, burst_len),
6215 "Error dequeuing burst");
6218 for (i = 0; i < burst_len; i++) {
6220 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6221 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6223 "data not as expected");
6225 rte_pktmbuf_free(burst[i]->sym->m_src);
6226 rte_crypto_op_free(burst[i]);
6229 return TEST_SUCCESS;
6233 generate_gmac_large_plaintext(uint8_t *data)
6237 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6238 memcpy(&data[i], &data[0], 32);
6242 create_gmac_operation(enum rte_crypto_auth_operation op,
6243 const struct gmac_test_data *tdata)
6245 struct crypto_testsuite_params *ts_params = &testsuite_params;
6246 struct crypto_unittest_params *ut_params = &unittest_params;
6247 struct rte_crypto_sym_op *sym_op;
6249 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6251 /* Generate Crypto op data structure */
6252 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6253 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6254 TEST_ASSERT_NOT_NULL(ut_params->op,
6255 "Failed to allocate symmetric crypto operation struct");
6257 sym_op = ut_params->op->sym;
6259 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6260 ut_params->ibuf, tdata->gmac_tag.len);
6261 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6262 "no room to append digest");
6264 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6265 ut_params->ibuf, plaintext_pad_len);
6267 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6268 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6269 tdata->gmac_tag.len);
6270 TEST_HEXDUMP(stdout, "digest:",
6271 sym_op->auth.digest.data,
6272 tdata->gmac_tag.len);
6275 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6276 uint8_t *, IV_OFFSET);
6278 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6280 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6282 sym_op->cipher.data.length = 0;
6283 sym_op->cipher.data.offset = 0;
6285 sym_op->auth.data.offset = 0;
6286 sym_op->auth.data.length = tdata->plaintext.len;
6291 static int create_gmac_session(uint8_t dev_id,
6292 const struct gmac_test_data *tdata,
6293 enum rte_crypto_auth_operation auth_op)
6295 uint8_t auth_key[tdata->key.len];
6297 struct crypto_unittest_params *ut_params = &unittest_params;
6299 memcpy(auth_key, tdata->key.data, tdata->key.len);
6301 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6302 ut_params->auth_xform.next = NULL;
6304 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6305 ut_params->auth_xform.auth.op = auth_op;
6306 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6307 ut_params->auth_xform.auth.add_auth_data_length = 0;
6308 ut_params->auth_xform.auth.key.length = tdata->key.len;
6309 ut_params->auth_xform.auth.key.data = auth_key;
6310 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6311 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6314 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6315 &ut_params->auth_xform);
6317 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6323 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6325 struct crypto_testsuite_params *ts_params = &testsuite_params;
6326 struct crypto_unittest_params *ut_params = &unittest_params;
6330 uint8_t *auth_tag, *plaintext;
6331 uint16_t plaintext_pad_len;
6333 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6334 "No GMAC length in the source data");
6336 retval = create_gmac_session(ts_params->valid_devs[0],
6337 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6342 if (tdata->plaintext.len > MBUF_SIZE)
6343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6345 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6346 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6347 "Failed to allocate input buffer in mempool");
6349 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6350 rte_pktmbuf_tailroom(ut_params->ibuf));
6352 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6354 * Runtime generate the large plain text instead of use hard code
6355 * plain text vector. It is done to avoid create huge source file
6356 * with the test vector.
6358 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6359 generate_gmac_large_plaintext(tdata->plaintext.data);
6361 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6363 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6365 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6366 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6367 tdata->plaintext.len);
6369 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6375 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6377 ut_params->op->sym->m_src = ut_params->ibuf;
6379 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6380 ut_params->op), "failed to process sym crypto op");
6382 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6383 "crypto op processing failed");
6385 if (ut_params->op->sym->m_dst) {
6386 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6387 uint8_t *, plaintext_pad_len);
6389 auth_tag = plaintext + plaintext_pad_len;
6392 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6394 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6396 tdata->gmac_tag.data,
6397 tdata->gmac_tag.len,
6398 "GMAC Generated auth tag not as expected");
6404 test_AES_GMAC_authentication_test_case_1(void)
6406 return test_AES_GMAC_authentication(&gmac_test_case_1);
6410 test_AES_GMAC_authentication_test_case_2(void)
6412 return test_AES_GMAC_authentication(&gmac_test_case_2);
6416 test_AES_GMAC_authentication_test_case_3(void)
6418 return test_AES_GMAC_authentication(&gmac_test_case_3);
6422 test_AES_GMAC_authentication_test_case_4(void)
6424 return test_AES_GMAC_authentication(&gmac_test_case_4);
6428 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6430 struct crypto_testsuite_params *ts_params = &testsuite_params;
6431 struct crypto_unittest_params *ut_params = &unittest_params;
6433 uint32_t plaintext_pad_len;
6436 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6437 "No GMAC length in the source data");
6439 retval = create_gmac_session(ts_params->valid_devs[0],
6440 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6445 if (tdata->plaintext.len > MBUF_SIZE)
6446 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6448 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6449 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6450 "Failed to allocate input buffer in mempool");
6452 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6453 rte_pktmbuf_tailroom(ut_params->ibuf));
6455 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6458 * Runtime generate the large plain text instead of use hard code
6459 * plain text vector. It is done to avoid create huge source file
6460 * with the test vector.
6462 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
6463 generate_gmac_large_plaintext(tdata->plaintext.data);
6465 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6467 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6469 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6470 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
6471 tdata->plaintext.len);
6473 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6479 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6481 ut_params->op->sym->m_src = ut_params->ibuf;
6483 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6484 ut_params->op), "failed to process sym crypto op");
6486 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6487 "crypto op processing failed");
6494 test_AES_GMAC_authentication_verify_test_case_1(void)
6496 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6500 test_AES_GMAC_authentication_verify_test_case_2(void)
6502 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6506 test_AES_GMAC_authentication_verify_test_case_3(void)
6508 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6512 test_AES_GMAC_authentication_verify_test_case_4(void)
6514 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6517 struct test_crypto_vector {
6518 enum rte_crypto_cipher_algorithm crypto_algo;
6531 const uint8_t *data;
6536 const uint8_t *data;
6540 enum rte_crypto_auth_algorithm auth_algo;
6548 const uint8_t *data;
6558 static const struct test_crypto_vector
6559 hmac_sha1_test_crypto_vector = {
6560 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6562 .data = plaintext_hash,
6567 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6568 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6569 0xDE, 0xF4, 0xDE, 0xAD
6575 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6576 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6577 0x3F, 0x91, 0x64, 0x59
6583 static const struct test_crypto_vector
6584 aes128_gmac_test_vector = {
6585 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6587 .data = plaintext_hash,
6592 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6593 0x08, 0x09, 0x0A, 0x0B
6599 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6600 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6606 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6607 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6613 static const struct test_crypto_vector
6614 aes128cbc_hmac_sha1_test_vector = {
6615 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6618 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6619 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6625 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6626 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6631 .data = plaintext_hash,
6635 .data = ciphertext512_aes128cbc,
6638 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6641 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6642 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6643 0xDE, 0xF4, 0xDE, 0xAD
6649 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6650 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6651 0x18, 0x8C, 0x1D, 0x32
6658 data_corruption(uint8_t *data)
6664 tag_corruption(uint8_t *data, unsigned int tag_offset)
6666 data[tag_offset] += 1;
6670 create_auth_session(struct crypto_unittest_params *ut_params,
6672 const struct test_crypto_vector *reference,
6673 enum rte_crypto_auth_operation auth_op)
6675 uint8_t auth_key[reference->auth_key.len + 1];
6677 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6679 /* Setup Authentication Parameters */
6680 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6681 ut_params->auth_xform.auth.op = auth_op;
6682 ut_params->auth_xform.next = NULL;
6683 ut_params->auth_xform.auth.algo = reference->auth_algo;
6684 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6685 ut_params->auth_xform.auth.key.data = auth_key;
6686 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6687 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6689 /* Create Crypto session*/
6690 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6691 &ut_params->auth_xform);
6693 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6699 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6701 const struct test_crypto_vector *reference,
6702 enum rte_crypto_auth_operation auth_op,
6703 enum rte_crypto_cipher_operation cipher_op)
6705 uint8_t cipher_key[reference->cipher_key.len + 1];
6706 uint8_t auth_key[reference->auth_key.len + 1];
6708 memcpy(cipher_key, reference->cipher_key.data,
6709 reference->cipher_key.len);
6710 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6712 /* Setup Authentication Parameters */
6713 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6714 ut_params->auth_xform.auth.op = auth_op;
6715 ut_params->auth_xform.auth.algo = reference->auth_algo;
6716 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6717 ut_params->auth_xform.auth.key.data = auth_key;
6718 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6720 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
6721 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6722 ut_params->auth_xform.auth.iv.length = reference->iv.len;
6724 ut_params->auth_xform.next = &ut_params->cipher_xform;
6725 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6727 /* Setup Cipher Parameters */
6728 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6729 ut_params->cipher_xform.next = NULL;
6730 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6731 ut_params->cipher_xform.cipher.op = cipher_op;
6732 ut_params->cipher_xform.cipher.key.data = cipher_key;
6733 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6734 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
6735 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
6738 /* Create Crypto session*/
6739 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6740 &ut_params->auth_xform);
6742 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6748 create_auth_operation(struct crypto_testsuite_params *ts_params,
6749 struct crypto_unittest_params *ut_params,
6750 const struct test_crypto_vector *reference,
6751 unsigned int auth_generate)
6753 /* Generate Crypto op data structure */
6754 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6755 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6756 TEST_ASSERT_NOT_NULL(ut_params->op,
6757 "Failed to allocate pktmbuf offload");
6759 /* Set crypto operation data parameters */
6760 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6762 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6764 /* set crypto operation source mbuf */
6765 sym_op->m_src = ut_params->ibuf;
6768 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6769 ut_params->ibuf, reference->digest.len);
6771 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6772 "no room to append auth tag");
6774 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6775 ut_params->ibuf, reference->plaintext.len);
6778 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6780 memcpy(sym_op->auth.digest.data,
6781 reference->digest.data,
6782 reference->digest.len);
6784 TEST_HEXDUMP(stdout, "digest:",
6785 sym_op->auth.digest.data,
6786 reference->digest.len);
6788 sym_op->auth.data.length = reference->plaintext.len;
6789 sym_op->auth.data.offset = 0;
6795 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6796 struct crypto_unittest_params *ut_params,
6797 const struct test_crypto_vector *reference,
6798 unsigned int auth_generate)
6800 /* Generate Crypto op data structure */
6801 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6802 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6803 TEST_ASSERT_NOT_NULL(ut_params->op,
6804 "Failed to allocate pktmbuf offload");
6806 /* Set crypto operation data parameters */
6807 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6809 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6811 /* set crypto operation source mbuf */
6812 sym_op->m_src = ut_params->ibuf;
6815 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6816 ut_params->ibuf, reference->digest.len);
6818 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6819 "no room to append auth tag");
6821 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6822 ut_params->ibuf, reference->ciphertext.len);
6825 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6827 memcpy(sym_op->auth.digest.data,
6828 reference->digest.data,
6829 reference->digest.len);
6831 TEST_HEXDUMP(stdout, "digest:",
6832 sym_op->auth.digest.data,
6833 reference->digest.len);
6835 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6836 reference->iv.data, reference->iv.len);
6838 sym_op->cipher.data.length = 0;
6839 sym_op->cipher.data.offset = 0;
6841 sym_op->auth.data.length = reference->plaintext.len;
6842 sym_op->auth.data.offset = 0;
6848 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6849 struct crypto_unittest_params *ut_params,
6850 const struct test_crypto_vector *reference,
6851 unsigned int auth_generate)
6853 /* Generate Crypto op data structure */
6854 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6855 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6856 TEST_ASSERT_NOT_NULL(ut_params->op,
6857 "Failed to allocate pktmbuf offload");
6859 /* Set crypto operation data parameters */
6860 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6862 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6864 /* set crypto operation source mbuf */
6865 sym_op->m_src = ut_params->ibuf;
6868 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6869 ut_params->ibuf, reference->digest.len);
6871 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6872 "no room to append auth tag");
6874 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6875 ut_params->ibuf, reference->ciphertext.len);
6878 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6880 memcpy(sym_op->auth.digest.data,
6881 reference->digest.data,
6882 reference->digest.len);
6884 TEST_HEXDUMP(stdout, "digest:",
6885 sym_op->auth.digest.data,
6886 reference->digest.len);
6888 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
6889 reference->iv.data, reference->iv.len);
6891 sym_op->cipher.data.length = reference->ciphertext.len;
6892 sym_op->cipher.data.offset = 0;
6894 sym_op->auth.data.length = reference->ciphertext.len;
6895 sym_op->auth.data.offset = 0;
6901 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6902 struct crypto_unittest_params *ut_params,
6903 const struct test_crypto_vector *reference)
6905 return create_auth_operation(ts_params, ut_params, reference, 0);
6909 create_auth_verify_GMAC_operation(
6910 struct crypto_testsuite_params *ts_params,
6911 struct crypto_unittest_params *ut_params,
6912 const struct test_crypto_vector *reference)
6914 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6918 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6919 struct crypto_unittest_params *ut_params,
6920 const struct test_crypto_vector *reference)
6922 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6926 test_authentication_verify_fail_when_data_corruption(
6927 struct crypto_testsuite_params *ts_params,
6928 struct crypto_unittest_params *ut_params,
6929 const struct test_crypto_vector *reference,
6930 unsigned int data_corrupted)
6936 /* Create session */
6937 retval = create_auth_session(ut_params,
6938 ts_params->valid_devs[0],
6940 RTE_CRYPTO_AUTH_OP_VERIFY);
6944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6945 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6946 "Failed to allocate input buffer in mempool");
6948 /* clear mbuf payload */
6949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6950 rte_pktmbuf_tailroom(ut_params->ibuf));
6952 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6953 reference->plaintext.len);
6954 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6955 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6957 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6959 /* Create operation */
6960 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6966 data_corruption(plaintext);
6968 tag_corruption(plaintext, reference->plaintext.len);
6970 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6972 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6973 TEST_ASSERT_EQUAL(ut_params->op->status,
6974 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6975 "authentication not failed");
6977 ut_params->obuf = ut_params->op->sym->m_src;
6978 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6984 test_authentication_verify_GMAC_fail_when_corruption(
6985 struct crypto_testsuite_params *ts_params,
6986 struct crypto_unittest_params *ut_params,
6987 const struct test_crypto_vector *reference,
6988 unsigned int data_corrupted)
6993 /* Create session */
6994 retval = create_auth_cipher_session(ut_params,
6995 ts_params->valid_devs[0],
6997 RTE_CRYPTO_AUTH_OP_VERIFY,
6998 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7002 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7003 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7004 "Failed to allocate input buffer in mempool");
7006 /* clear mbuf payload */
7007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7008 rte_pktmbuf_tailroom(ut_params->ibuf));
7010 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7011 reference->plaintext.len);
7012 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7013 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7015 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7017 /* Create operation */
7018 retval = create_auth_verify_GMAC_operation(ts_params,
7026 data_corruption(plaintext);
7028 tag_corruption(plaintext, reference->aad.len);
7030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7033 TEST_ASSERT_EQUAL(ut_params->op->status,
7034 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7035 "authentication not failed");
7037 ut_params->obuf = ut_params->op->sym->m_src;
7038 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7044 test_authenticated_decryption_fail_when_corruption(
7045 struct crypto_testsuite_params *ts_params,
7046 struct crypto_unittest_params *ut_params,
7047 const struct test_crypto_vector *reference,
7048 unsigned int data_corrupted)
7052 uint8_t *ciphertext;
7054 /* Create session */
7055 retval = create_auth_cipher_session(ut_params,
7056 ts_params->valid_devs[0],
7058 RTE_CRYPTO_AUTH_OP_VERIFY,
7059 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7063 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7064 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7065 "Failed to allocate input buffer in mempool");
7067 /* clear mbuf payload */
7068 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7069 rte_pktmbuf_tailroom(ut_params->ibuf));
7071 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7072 reference->ciphertext.len);
7073 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7074 memcpy(ciphertext, reference->ciphertext.data,
7075 reference->ciphertext.len);
7077 /* Create operation */
7078 retval = create_cipher_auth_verify_operation(ts_params,
7086 data_corruption(ciphertext);
7088 tag_corruption(ciphertext, reference->ciphertext.len);
7090 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7093 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7094 TEST_ASSERT_EQUAL(ut_params->op->status,
7095 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7096 "authentication not failed");
7098 ut_params->obuf = ut_params->op->sym->m_src;
7099 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7105 create_gcm_operation_SGL(enum rte_crypto_aead_operation op,
7106 const struct gcm_test_data *tdata,
7107 void *digest_mem, uint64_t digest_phys)
7109 struct crypto_testsuite_params *ts_params = &testsuite_params;
7110 struct crypto_unittest_params *ut_params = &unittest_params;
7112 const unsigned int auth_tag_len = tdata->auth_tag.len;
7113 const unsigned int iv_len = tdata->iv.len;
7114 const unsigned int aad_len = tdata->aad.len;
7116 /* Generate Crypto op data structure */
7117 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7118 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7119 TEST_ASSERT_NOT_NULL(ut_params->op,
7120 "Failed to allocate symmetric crypto operation struct");
7122 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7124 sym_op->aead.digest.data = digest_mem;
7126 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7127 "no room to append digest");
7129 sym_op->aead.digest.phys_addr = digest_phys;
7131 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7132 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7134 TEST_HEXDUMP(stdout, "digest:",
7135 sym_op->aead.digest.data,
7139 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7140 uint8_t *, IV_OFFSET);
7142 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7144 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7145 ut_params->ibuf, aad_len);
7146 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7147 "no room to prepend aad");
7148 sym_op->aead.aad.phys_addr = rte_pktmbuf_mtophys(
7151 memset(sym_op->aead.aad.data, 0, aad_len);
7152 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7154 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7155 TEST_HEXDUMP(stdout, "aad:",
7156 sym_op->aead.aad.data, aad_len);
7158 sym_op->aead.data.length = tdata->plaintext.len;
7159 sym_op->aead.data.offset = aad_len;
7164 #define SGL_MAX_NO 16
7167 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
7168 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7170 struct crypto_testsuite_params *ts_params = &testsuite_params;
7171 struct crypto_unittest_params *ut_params = &unittest_params;
7172 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7175 int to_trn_tbl[SGL_MAX_NO];
7177 unsigned int trn_data = 0;
7178 uint8_t *plaintext, *ciphertext, *auth_tag;
7180 if (fragsz > tdata->plaintext.len)
7181 fragsz = tdata->plaintext.len;
7183 uint16_t plaintext_len = fragsz;
7184 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7186 if (fragsz_oop > tdata->plaintext.len)
7187 frag_size_oop = tdata->plaintext.len;
7190 void *digest_mem = NULL;
7192 uint32_t prepend_len = tdata->aad.len;
7194 if (tdata->plaintext.len % fragsz != 0) {
7195 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7198 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7203 * For out-op-place we need to alloc another mbuf
7206 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7207 rte_pktmbuf_append(ut_params->obuf,
7208 frag_size_oop + prepend_len);
7209 buf_oop = ut_params->obuf;
7212 /* Create GCM session */
7213 retval = create_gcm_session(ts_params->valid_devs[0],
7214 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7215 tdata->key.data, tdata->key.len,
7216 tdata->aad.len, tdata->auth_tag.len,
7221 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7223 /* clear mbuf payload */
7224 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7225 rte_pktmbuf_tailroom(ut_params->ibuf));
7227 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7230 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7232 trn_data += plaintext_len;
7234 buf = ut_params->ibuf;
7237 * Loop until no more fragments
7240 while (trn_data < tdata->plaintext.len) {
7242 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7243 (tdata->plaintext.len - trn_data) : fragsz;
7245 to_trn_tbl[ecx++] = to_trn;
7247 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7250 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7251 rte_pktmbuf_tailroom(buf));
7254 if (oop && !fragsz_oop) {
7255 buf_last_oop = buf_oop->next =
7256 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7257 buf_oop = buf_oop->next;
7258 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7259 0, rte_pktmbuf_tailroom(buf_oop));
7260 rte_pktmbuf_append(buf_oop, to_trn);
7263 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7266 memcpy(plaintext, tdata->plaintext.data + trn_data,
7269 if (trn_data == tdata->plaintext.len) {
7272 digest_mem = rte_pktmbuf_append(buf_oop,
7273 tdata->auth_tag.len);
7275 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7276 tdata->auth_tag.len);
7280 uint64_t digest_phys = 0;
7282 ut_params->ibuf->nb_segs = segs;
7285 if (fragsz_oop && oop) {
7289 if (frag_size_oop == tdata->plaintext.len) {
7290 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7291 tdata->auth_tag.len);
7293 digest_phys = rte_pktmbuf_mtophys_offset(
7295 tdata->plaintext.len + prepend_len);
7298 trn_data = frag_size_oop;
7299 while (trn_data < tdata->plaintext.len) {
7302 (tdata->plaintext.len - trn_data <
7304 (tdata->plaintext.len - trn_data) :
7307 to_trn_tbl[ecx++] = to_trn;
7309 buf_last_oop = buf_oop->next =
7310 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7311 buf_oop = buf_oop->next;
7312 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7313 0, rte_pktmbuf_tailroom(buf_oop));
7314 rte_pktmbuf_append(buf_oop, to_trn);
7318 if (trn_data == tdata->plaintext.len) {
7319 digest_mem = rte_pktmbuf_append(buf_oop,
7320 tdata->auth_tag.len);
7324 ut_params->obuf->nb_segs = segs;
7328 * Place digest at the end of the last buffer
7331 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7332 if (oop && buf_last_oop)
7333 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7335 if (!digest_mem && !oop) {
7336 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7337 + tdata->auth_tag.len);
7338 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7339 tdata->plaintext.len);
7342 /* Create GCM opertaion */
7343 retval = create_gcm_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
7344 tdata, digest_mem, digest_phys);
7349 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7351 ut_params->op->sym->m_src = ut_params->ibuf;
7353 ut_params->op->sym->m_dst = ut_params->obuf;
7355 /* Process crypto operation */
7356 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7357 ut_params->op), "failed to process sym crypto op");
7359 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7360 "crypto op processing failed");
7363 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7364 uint8_t *, prepend_len);
7366 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7367 uint8_t *, prepend_len);
7371 fragsz = fragsz_oop;
7373 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7375 tdata->ciphertext.data,
7377 "GCM Ciphertext data not as expected");
7379 buf = ut_params->op->sym->m_src->next;
7381 buf = ut_params->op->sym->m_dst->next;
7383 unsigned int off = fragsz;
7387 ciphertext = rte_pktmbuf_mtod(buf,
7390 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7392 tdata->ciphertext.data + off,
7394 "GCM Ciphertext data not as expected");
7396 off += to_trn_tbl[ecx++];
7400 auth_tag = digest_mem;
7401 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7403 tdata->auth_tag.data,
7404 tdata->auth_tag.len,
7405 "GCM Generated auth tag not as expected");
7411 #define OUT_OF_PLACE 1
7414 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7416 return test_AES_GCM_authenticated_encryption_SGL(
7417 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7421 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7423 return test_AES_GCM_authenticated_encryption_SGL(
7424 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7428 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7430 return test_AES_GCM_authenticated_encryption_SGL(
7431 &gcm_test_case_8, OUT_OF_PLACE, 400,
7432 gcm_test_case_8.plaintext.len);
7436 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7439 return test_AES_GCM_authenticated_encryption_SGL(
7440 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7444 test_authentication_verify_fail_when_data_corrupted(
7445 struct crypto_testsuite_params *ts_params,
7446 struct crypto_unittest_params *ut_params,
7447 const struct test_crypto_vector *reference)
7449 return test_authentication_verify_fail_when_data_corruption(
7450 ts_params, ut_params, reference, 1);
7454 test_authentication_verify_fail_when_tag_corrupted(
7455 struct crypto_testsuite_params *ts_params,
7456 struct crypto_unittest_params *ut_params,
7457 const struct test_crypto_vector *reference)
7459 return test_authentication_verify_fail_when_data_corruption(
7460 ts_params, ut_params, reference, 0);
7464 test_authentication_verify_GMAC_fail_when_data_corrupted(
7465 struct crypto_testsuite_params *ts_params,
7466 struct crypto_unittest_params *ut_params,
7467 const struct test_crypto_vector *reference)
7469 return test_authentication_verify_GMAC_fail_when_corruption(
7470 ts_params, ut_params, reference, 1);
7474 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7475 struct crypto_testsuite_params *ts_params,
7476 struct crypto_unittest_params *ut_params,
7477 const struct test_crypto_vector *reference)
7479 return test_authentication_verify_GMAC_fail_when_corruption(
7480 ts_params, ut_params, reference, 0);
7484 test_authenticated_decryption_fail_when_data_corrupted(
7485 struct crypto_testsuite_params *ts_params,
7486 struct crypto_unittest_params *ut_params,
7487 const struct test_crypto_vector *reference)
7489 return test_authenticated_decryption_fail_when_corruption(
7490 ts_params, ut_params, reference, 1);
7494 test_authenticated_decryption_fail_when_tag_corrupted(
7495 struct crypto_testsuite_params *ts_params,
7496 struct crypto_unittest_params *ut_params,
7497 const struct test_crypto_vector *reference)
7499 return test_authenticated_decryption_fail_when_corruption(
7500 ts_params, ut_params, reference, 0);
7504 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7506 return test_authentication_verify_fail_when_data_corrupted(
7507 &testsuite_params, &unittest_params,
7508 &hmac_sha1_test_crypto_vector);
7512 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7514 return test_authentication_verify_fail_when_tag_corrupted(
7515 &testsuite_params, &unittest_params,
7516 &hmac_sha1_test_crypto_vector);
7520 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7522 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7523 &testsuite_params, &unittest_params,
7524 &aes128_gmac_test_vector);
7528 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7530 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7531 &testsuite_params, &unittest_params,
7532 &aes128_gmac_test_vector);
7536 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7538 return test_authenticated_decryption_fail_when_data_corrupted(
7541 &aes128cbc_hmac_sha1_test_vector);
7545 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7547 return test_authenticated_decryption_fail_when_tag_corrupted(
7550 &aes128cbc_hmac_sha1_test_vector);
7553 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
7555 /* global AESNI slave IDs for the scheduler test */
7556 uint8_t aesni_ids[2];
7559 test_scheduler_attach_slave_op(void)
7561 struct crypto_testsuite_params *ts_params = &testsuite_params;
7562 uint8_t sched_id = ts_params->valid_devs[0];
7563 uint32_t nb_devs, i, nb_devs_attached = 0;
7567 /* create 2 AESNI_MB if necessary */
7568 nb_devs = rte_cryptodev_count_devtype(
7569 RTE_CRYPTODEV_AESNI_MB_PMD);
7571 for (i = nb_devs; i < 2; i++) {
7572 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
7573 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
7575 ret = rte_vdev_init(vdev_name, NULL);
7577 TEST_ASSERT(ret == 0,
7578 "Failed to create instance %u of"
7580 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7584 /* attach 2 AESNI_MB cdevs */
7585 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
7587 struct rte_cryptodev_info info;
7589 rte_cryptodev_info_get(i, &info);
7590 if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
7593 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
7596 TEST_ASSERT(ret == 0,
7597 "Failed to attach device %u of pmd : %s", i,
7598 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
7600 aesni_ids[nb_devs_attached] = (uint8_t)i;
7609 test_scheduler_detach_slave_op(void)
7611 struct crypto_testsuite_params *ts_params = &testsuite_params;
7612 uint8_t sched_id = ts_params->valid_devs[0];
7616 for (i = 0; i < 2; i++) {
7617 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
7619 TEST_ASSERT(ret == 0,
7620 "Failed to detach device %u", aesni_ids[i]);
7627 test_scheduler_mode_op(void)
7629 struct crypto_testsuite_params *ts_params = &testsuite_params;
7630 uint8_t sched_id = ts_params->valid_devs[0];
7631 struct rte_cryptodev_scheduler_ops op = {0};
7632 struct rte_cryptodev_scheduler dummy_scheduler = {
7633 .description = "dummy scheduler to test mode",
7634 .name = "dummy scheduler",
7635 .mode = CDEV_SCHED_MODE_USERDEFINED,
7640 /* set user defined mode */
7641 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
7643 TEST_ASSERT(ret == 0,
7644 "Failed to set cdev %u to user defined mode", sched_id);
7646 /* set round robin mode */
7647 ret = rte_cryptodev_scheduler_mode_set(sched_id,
7648 CDEV_SCHED_MODE_ROUNDROBIN);
7649 TEST_ASSERT(ret == 0,
7650 "Failed to set cdev %u to round-robin mode", sched_id);
7651 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
7652 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
7658 static struct unit_test_suite cryptodev_scheduler_testsuite = {
7659 .suite_name = "Crypto Device Scheduler Unit Test Suite",
7660 .setup = testsuite_setup,
7661 .teardown = testsuite_teardown,
7662 .unit_test_cases = {
7663 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
7664 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
7665 TEST_CASE_ST(ut_setup, ut_teardown,
7666 test_AES_chain_scheduler_all),
7667 TEST_CASE_ST(ut_setup, ut_teardown,
7668 test_AES_cipheronly_scheduler_all),
7669 TEST_CASE_ST(ut_setup, ut_teardown,
7670 test_authonly_scheduler_all),
7671 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
7672 TEST_CASES_END() /**< NULL terminate unit test array */
7676 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
7678 static struct unit_test_suite cryptodev_qat_testsuite = {
7679 .suite_name = "Crypto QAT Unit Test Suite",
7680 .setup = testsuite_setup,
7681 .teardown = testsuite_teardown,
7682 .unit_test_cases = {
7683 TEST_CASE_ST(ut_setup, ut_teardown,
7684 test_device_configure_invalid_dev_id),
7685 TEST_CASE_ST(ut_setup, ut_teardown,
7686 test_device_configure_invalid_queue_pair_ids),
7687 TEST_CASE_ST(ut_setup, ut_teardown,
7688 test_queue_pair_descriptor_setup),
7689 TEST_CASE_ST(ut_setup, ut_teardown,
7690 test_multi_session),
7692 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7693 TEST_CASE_ST(ut_setup, ut_teardown,
7694 test_AES_cipheronly_qat_all),
7695 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7696 TEST_CASE_ST(ut_setup, ut_teardown,
7697 test_3DES_cipheronly_qat_all),
7698 TEST_CASE_ST(ut_setup, ut_teardown,
7699 test_DES_cipheronly_qat_all),
7700 TEST_CASE_ST(ut_setup, ut_teardown,
7701 test_AES_docsis_qat_all),
7702 TEST_CASE_ST(ut_setup, ut_teardown,
7703 test_DES_docsis_qat_all),
7704 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7706 /** AES GCM Authenticated Encryption */
7707 TEST_CASE_ST(ut_setup, ut_teardown,
7708 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7709 TEST_CASE_ST(ut_setup, ut_teardown,
7710 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7711 TEST_CASE_ST(ut_setup, ut_teardown,
7712 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7713 TEST_CASE_ST(ut_setup, ut_teardown,
7714 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7715 TEST_CASE_ST(ut_setup, ut_teardown,
7716 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7717 TEST_CASE_ST(ut_setup, ut_teardown,
7718 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7719 TEST_CASE_ST(ut_setup, ut_teardown,
7720 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7721 TEST_CASE_ST(ut_setup, ut_teardown,
7722 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7723 TEST_CASE_ST(ut_setup, ut_teardown,
7724 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7725 TEST_CASE_ST(ut_setup, ut_teardown,
7726 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7728 /** AES GCM Authenticated Decryption */
7729 TEST_CASE_ST(ut_setup, ut_teardown,
7730 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7731 TEST_CASE_ST(ut_setup, ut_teardown,
7732 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7733 TEST_CASE_ST(ut_setup, ut_teardown,
7734 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7735 TEST_CASE_ST(ut_setup, ut_teardown,
7736 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7737 TEST_CASE_ST(ut_setup, ut_teardown,
7738 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7739 TEST_CASE_ST(ut_setup, ut_teardown,
7740 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7741 TEST_CASE_ST(ut_setup, ut_teardown,
7742 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7744 /** AES GMAC Authentication */
7745 TEST_CASE_ST(ut_setup, ut_teardown,
7746 test_AES_GMAC_authentication_test_case_1),
7747 TEST_CASE_ST(ut_setup, ut_teardown,
7748 test_AES_GMAC_authentication_verify_test_case_1),
7749 TEST_CASE_ST(ut_setup, ut_teardown,
7750 test_AES_GMAC_authentication_test_case_2),
7751 TEST_CASE_ST(ut_setup, ut_teardown,
7752 test_AES_GMAC_authentication_verify_test_case_2),
7753 TEST_CASE_ST(ut_setup, ut_teardown,
7754 test_AES_GMAC_authentication_test_case_3),
7755 TEST_CASE_ST(ut_setup, ut_teardown,
7756 test_AES_GMAC_authentication_verify_test_case_3),
7758 /** SNOW 3G encrypt only (UEA2) */
7759 TEST_CASE_ST(ut_setup, ut_teardown,
7760 test_snow3g_encryption_test_case_1),
7761 TEST_CASE_ST(ut_setup, ut_teardown,
7762 test_snow3g_encryption_test_case_2),
7763 TEST_CASE_ST(ut_setup, ut_teardown,
7764 test_snow3g_encryption_test_case_3),
7765 TEST_CASE_ST(ut_setup, ut_teardown,
7766 test_snow3g_encryption_test_case_4),
7767 TEST_CASE_ST(ut_setup, ut_teardown,
7768 test_snow3g_encryption_test_case_5),
7770 TEST_CASE_ST(ut_setup, ut_teardown,
7771 test_snow3g_encryption_test_case_1_oop),
7772 TEST_CASE_ST(ut_setup, ut_teardown,
7773 test_snow3g_decryption_test_case_1_oop),
7775 /** SNOW 3G decrypt only (UEA2) */
7776 TEST_CASE_ST(ut_setup, ut_teardown,
7777 test_snow3g_decryption_test_case_1),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_snow3g_decryption_test_case_2),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_snow3g_decryption_test_case_3),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_snow3g_decryption_test_case_4),
7784 TEST_CASE_ST(ut_setup, ut_teardown,
7785 test_snow3g_decryption_test_case_5),
7786 TEST_CASE_ST(ut_setup, ut_teardown,
7787 test_snow3g_hash_generate_test_case_1),
7788 TEST_CASE_ST(ut_setup, ut_teardown,
7789 test_snow3g_hash_generate_test_case_2),
7790 TEST_CASE_ST(ut_setup, ut_teardown,
7791 test_snow3g_hash_generate_test_case_3),
7792 TEST_CASE_ST(ut_setup, ut_teardown,
7793 test_snow3g_hash_verify_test_case_1),
7794 TEST_CASE_ST(ut_setup, ut_teardown,
7795 test_snow3g_hash_verify_test_case_2),
7796 TEST_CASE_ST(ut_setup, ut_teardown,
7797 test_snow3g_hash_verify_test_case_3),
7798 TEST_CASE_ST(ut_setup, ut_teardown,
7799 test_snow3g_cipher_auth_test_case_1),
7800 TEST_CASE_ST(ut_setup, ut_teardown,
7801 test_snow3g_auth_cipher_test_case_1),
7803 /** ZUC encrypt only (EEA3) */
7804 TEST_CASE_ST(ut_setup, ut_teardown,
7805 test_zuc_encryption_test_case_1),
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_zuc_encryption_test_case_2),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_zuc_encryption_test_case_3),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_zuc_encryption_test_case_4),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_zuc_encryption_test_case_5),
7815 /** ZUC authenticate (EIA3) */
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_zuc_hash_generate_test_case_6),
7818 TEST_CASE_ST(ut_setup, ut_teardown,
7819 test_zuc_hash_generate_test_case_7),
7820 TEST_CASE_ST(ut_setup, ut_teardown,
7821 test_zuc_hash_generate_test_case_8),
7823 /** ZUC alg-chain (EEA3/EIA3) */
7824 TEST_CASE_ST(ut_setup, ut_teardown,
7825 test_zuc_cipher_auth_test_case_1),
7826 TEST_CASE_ST(ut_setup, ut_teardown,
7827 test_zuc_cipher_auth_test_case_2),
7829 /** HMAC_MD5 Authentication */
7830 TEST_CASE_ST(ut_setup, ut_teardown,
7831 test_MD5_HMAC_generate_case_1),
7832 TEST_CASE_ST(ut_setup, ut_teardown,
7833 test_MD5_HMAC_verify_case_1),
7834 TEST_CASE_ST(ut_setup, ut_teardown,
7835 test_MD5_HMAC_generate_case_2),
7836 TEST_CASE_ST(ut_setup, ut_teardown,
7837 test_MD5_HMAC_verify_case_2),
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_null_auth_only_operation),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_null_cipher_only_operation),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_null_cipher_auth_operation),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_null_auth_cipher_operation),
7849 TEST_CASE_ST(ut_setup, ut_teardown,
7850 test_kasumi_hash_generate_test_case_6),
7853 TEST_CASE_ST(ut_setup, ut_teardown,
7854 test_kasumi_encryption_test_case_1),
7855 TEST_CASE_ST(ut_setup, ut_teardown,
7856 test_kasumi_encryption_test_case_3),
7857 TEST_CASE_ST(ut_setup, ut_teardown,
7858 test_kasumi_auth_cipher_test_case_1),
7859 TEST_CASE_ST(ut_setup, ut_teardown,
7860 test_kasumi_cipher_auth_test_case_1),
7862 /** Negative tests */
7863 TEST_CASE_ST(ut_setup, ut_teardown,
7864 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7865 TEST_CASE_ST(ut_setup, ut_teardown,
7866 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7867 TEST_CASE_ST(ut_setup, ut_teardown,
7868 authentication_verify_AES128_GMAC_fail_data_corrupt),
7869 TEST_CASE_ST(ut_setup, ut_teardown,
7870 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7876 TEST_CASES_END() /**< NULL terminate unit test array */
7880 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7881 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7882 .setup = testsuite_setup,
7883 .teardown = testsuite_teardown,
7884 .unit_test_cases = {
7885 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7886 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7887 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
7888 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7890 TEST_CASES_END() /**< NULL terminate unit test array */
7894 static struct unit_test_suite cryptodev_openssl_testsuite = {
7895 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7896 .setup = testsuite_setup,
7897 .teardown = testsuite_teardown,
7898 .unit_test_cases = {
7899 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7900 TEST_CASE_ST(ut_setup, ut_teardown,
7901 test_multi_session_random_usage),
7902 TEST_CASE_ST(ut_setup, ut_teardown,
7903 test_AES_chain_openssl_all),
7904 TEST_CASE_ST(ut_setup, ut_teardown,
7905 test_AES_cipheronly_openssl_all),
7906 TEST_CASE_ST(ut_setup, ut_teardown,
7907 test_3DES_chain_openssl_all),
7908 TEST_CASE_ST(ut_setup, ut_teardown,
7909 test_3DES_cipheronly_openssl_all),
7910 TEST_CASE_ST(ut_setup, ut_teardown,
7911 test_DES_docsis_openssl_all),
7912 TEST_CASE_ST(ut_setup, ut_teardown,
7913 test_authonly_openssl_all),
7915 /** AES GCM Authenticated Encryption */
7916 TEST_CASE_ST(ut_setup, ut_teardown,
7917 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7918 TEST_CASE_ST(ut_setup, ut_teardown,
7919 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7920 TEST_CASE_ST(ut_setup, ut_teardown,
7921 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7922 TEST_CASE_ST(ut_setup, ut_teardown,
7923 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7924 TEST_CASE_ST(ut_setup, ut_teardown,
7925 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7926 TEST_CASE_ST(ut_setup, ut_teardown,
7927 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7928 TEST_CASE_ST(ut_setup, ut_teardown,
7929 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7931 /** AES GCM Authenticated Decryption */
7932 TEST_CASE_ST(ut_setup, ut_teardown,
7933 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7934 TEST_CASE_ST(ut_setup, ut_teardown,
7935 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7936 TEST_CASE_ST(ut_setup, ut_teardown,
7937 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7938 TEST_CASE_ST(ut_setup, ut_teardown,
7939 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7940 TEST_CASE_ST(ut_setup, ut_teardown,
7941 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7942 TEST_CASE_ST(ut_setup, ut_teardown,
7943 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7944 TEST_CASE_ST(ut_setup, ut_teardown,
7945 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7947 /** AES GMAC Authentication */
7948 TEST_CASE_ST(ut_setup, ut_teardown,
7949 test_AES_GMAC_authentication_test_case_1),
7950 TEST_CASE_ST(ut_setup, ut_teardown,
7951 test_AES_GMAC_authentication_verify_test_case_1),
7952 TEST_CASE_ST(ut_setup, ut_teardown,
7953 test_AES_GMAC_authentication_test_case_2),
7954 TEST_CASE_ST(ut_setup, ut_teardown,
7955 test_AES_GMAC_authentication_verify_test_case_2),
7956 TEST_CASE_ST(ut_setup, ut_teardown,
7957 test_AES_GMAC_authentication_test_case_3),
7958 TEST_CASE_ST(ut_setup, ut_teardown,
7959 test_AES_GMAC_authentication_verify_test_case_3),
7960 TEST_CASE_ST(ut_setup, ut_teardown,
7961 test_AES_GMAC_authentication_test_case_4),
7962 TEST_CASE_ST(ut_setup, ut_teardown,
7963 test_AES_GMAC_authentication_verify_test_case_4),
7965 /** Scatter-Gather */
7966 TEST_CASE_ST(ut_setup, ut_teardown,
7967 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7969 /** Negative tests */
7970 TEST_CASE_ST(ut_setup, ut_teardown,
7971 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7972 TEST_CASE_ST(ut_setup, ut_teardown,
7973 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7974 TEST_CASE_ST(ut_setup, ut_teardown,
7975 authentication_verify_AES128_GMAC_fail_data_corrupt),
7976 TEST_CASE_ST(ut_setup, ut_teardown,
7977 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7978 TEST_CASE_ST(ut_setup, ut_teardown,
7979 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7980 TEST_CASE_ST(ut_setup, ut_teardown,
7981 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7983 TEST_CASES_END() /**< NULL terminate unit test array */
7987 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7988 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7989 .setup = testsuite_setup,
7990 .teardown = testsuite_teardown,
7991 .unit_test_cases = {
7992 /** AES GCM Authenticated Encryption */
7993 TEST_CASE_ST(ut_setup, ut_teardown,
7994 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7995 TEST_CASE_ST(ut_setup, ut_teardown,
7996 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7997 TEST_CASE_ST(ut_setup, ut_teardown,
7998 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7999 TEST_CASE_ST(ut_setup, ut_teardown,
8000 test_mb_AES_GCM_authenticated_encryption_test_case_4),
8001 TEST_CASE_ST(ut_setup, ut_teardown,
8002 test_mb_AES_GCM_authenticated_encryption_test_case_5),
8003 TEST_CASE_ST(ut_setup, ut_teardown,
8004 test_mb_AES_GCM_authenticated_encryption_test_case_6),
8005 TEST_CASE_ST(ut_setup, ut_teardown,
8006 test_mb_AES_GCM_authenticated_encryption_test_case_7),
8008 /** AES GCM Authenticated Decryption */
8009 TEST_CASE_ST(ut_setup, ut_teardown,
8010 test_mb_AES_GCM_authenticated_decryption_test_case_1),
8011 TEST_CASE_ST(ut_setup, ut_teardown,
8012 test_mb_AES_GCM_authenticated_decryption_test_case_2),
8013 TEST_CASE_ST(ut_setup, ut_teardown,
8014 test_mb_AES_GCM_authenticated_decryption_test_case_3),
8015 TEST_CASE_ST(ut_setup, ut_teardown,
8016 test_mb_AES_GCM_authenticated_decryption_test_case_4),
8017 TEST_CASE_ST(ut_setup, ut_teardown,
8018 test_mb_AES_GCM_authenticated_decryption_test_case_5),
8019 TEST_CASE_ST(ut_setup, ut_teardown,
8020 test_mb_AES_GCM_authenticated_decryption_test_case_6),
8021 TEST_CASE_ST(ut_setup, ut_teardown,
8022 test_mb_AES_GCM_authenticated_decryption_test_case_7),
8024 /** AES GCM Authenticated Encryption 256 bits key */
8025 TEST_CASE_ST(ut_setup, ut_teardown,
8026 test_mb_AES_GCM_auth_encryption_test_case_256_1),
8027 TEST_CASE_ST(ut_setup, ut_teardown,
8028 test_mb_AES_GCM_auth_encryption_test_case_256_2),
8029 TEST_CASE_ST(ut_setup, ut_teardown,
8030 test_mb_AES_GCM_auth_encryption_test_case_256_3),
8031 TEST_CASE_ST(ut_setup, ut_teardown,
8032 test_mb_AES_GCM_auth_encryption_test_case_256_4),
8033 TEST_CASE_ST(ut_setup, ut_teardown,
8034 test_mb_AES_GCM_auth_encryption_test_case_256_5),
8035 TEST_CASE_ST(ut_setup, ut_teardown,
8036 test_mb_AES_GCM_auth_encryption_test_case_256_6),
8037 TEST_CASE_ST(ut_setup, ut_teardown,
8038 test_mb_AES_GCM_auth_encryption_test_case_256_7),
8040 /** AES GCM Authenticated Decryption 256 bits key */
8041 TEST_CASE_ST(ut_setup, ut_teardown,
8042 test_mb_AES_GCM_auth_decryption_test_case_256_1),
8043 TEST_CASE_ST(ut_setup, ut_teardown,
8044 test_mb_AES_GCM_auth_decryption_test_case_256_2),
8045 TEST_CASE_ST(ut_setup, ut_teardown,
8046 test_mb_AES_GCM_auth_decryption_test_case_256_3),
8047 TEST_CASE_ST(ut_setup, ut_teardown,
8048 test_mb_AES_GCM_auth_decryption_test_case_256_4),
8049 TEST_CASE_ST(ut_setup, ut_teardown,
8050 test_mb_AES_GCM_auth_decryption_test_case_256_5),
8051 TEST_CASE_ST(ut_setup, ut_teardown,
8052 test_mb_AES_GCM_auth_decryption_test_case_256_6),
8053 TEST_CASE_ST(ut_setup, ut_teardown,
8054 test_mb_AES_GCM_auth_decryption_test_case_256_7),
8056 /** AES GCM Authenticated Encryption big aad size */
8057 TEST_CASE_ST(ut_setup, ut_teardown,
8058 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
8059 TEST_CASE_ST(ut_setup, ut_teardown,
8060 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
8062 /** AES GCM Authenticated Decryption big aad size */
8063 TEST_CASE_ST(ut_setup, ut_teardown,
8064 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
8065 TEST_CASE_ST(ut_setup, ut_teardown,
8066 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
8068 /** AES GMAC Authentication */
8069 TEST_CASE_ST(ut_setup, ut_teardown,
8070 test_AES_GMAC_authentication_test_case_1),
8071 TEST_CASE_ST(ut_setup, ut_teardown,
8072 test_AES_GMAC_authentication_verify_test_case_1),
8073 TEST_CASE_ST(ut_setup, ut_teardown,
8074 test_AES_GMAC_authentication_test_case_3),
8075 TEST_CASE_ST(ut_setup, ut_teardown,
8076 test_AES_GMAC_authentication_verify_test_case_3),
8077 TEST_CASE_ST(ut_setup, ut_teardown,
8078 test_AES_GMAC_authentication_test_case_4),
8079 TEST_CASE_ST(ut_setup, ut_teardown,
8080 test_AES_GMAC_authentication_verify_test_case_4),
8082 /** Negative tests */
8083 TEST_CASE_ST(ut_setup, ut_teardown,
8084 authentication_verify_AES128_GMAC_fail_data_corrupt),
8085 TEST_CASE_ST(ut_setup, ut_teardown,
8086 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8088 /** Out of place tests */
8089 TEST_CASE_ST(ut_setup, ut_teardown,
8090 test_mb_AES_GCM_authenticated_encryption_oop),
8091 TEST_CASE_ST(ut_setup, ut_teardown,
8092 test_mb_AES_GCM_authenticated_decryption_oop),
8094 /** Session-less tests */
8095 TEST_CASE_ST(ut_setup, ut_teardown,
8096 test_mb_AES_GCM_authenticated_encryption_sessionless),
8097 TEST_CASE_ST(ut_setup, ut_teardown,
8098 test_mb_AES_GCM_authenticated_decryption_sessionless),
8100 /** Scatter-Gather */
8101 TEST_CASE_ST(ut_setup, ut_teardown,
8102 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8104 TEST_CASES_END() /**< NULL terminate unit test array */
8108 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
8109 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
8110 .setup = testsuite_setup,
8111 .teardown = testsuite_teardown,
8112 .unit_test_cases = {
8113 /** KASUMI encrypt only (UEA1) */
8114 TEST_CASE_ST(ut_setup, ut_teardown,
8115 test_kasumi_encryption_test_case_1),
8116 TEST_CASE_ST(ut_setup, ut_teardown,
8117 test_kasumi_encryption_test_case_1_sgl),
8118 TEST_CASE_ST(ut_setup, ut_teardown,
8119 test_kasumi_encryption_test_case_2),
8120 TEST_CASE_ST(ut_setup, ut_teardown,
8121 test_kasumi_encryption_test_case_3),
8122 TEST_CASE_ST(ut_setup, ut_teardown,
8123 test_kasumi_encryption_test_case_4),
8124 TEST_CASE_ST(ut_setup, ut_teardown,
8125 test_kasumi_encryption_test_case_5),
8126 /** KASUMI decrypt only (UEA1) */
8127 TEST_CASE_ST(ut_setup, ut_teardown,
8128 test_kasumi_decryption_test_case_1),
8129 TEST_CASE_ST(ut_setup, ut_teardown,
8130 test_kasumi_decryption_test_case_2),
8131 TEST_CASE_ST(ut_setup, ut_teardown,
8132 test_kasumi_decryption_test_case_3),
8133 TEST_CASE_ST(ut_setup, ut_teardown,
8134 test_kasumi_decryption_test_case_4),
8135 TEST_CASE_ST(ut_setup, ut_teardown,
8136 test_kasumi_decryption_test_case_5),
8138 TEST_CASE_ST(ut_setup, ut_teardown,
8139 test_kasumi_encryption_test_case_1_oop),
8140 TEST_CASE_ST(ut_setup, ut_teardown,
8141 test_kasumi_encryption_test_case_1_oop_sgl),
8144 TEST_CASE_ST(ut_setup, ut_teardown,
8145 test_kasumi_decryption_test_case_1_oop),
8147 /** KASUMI hash only (UIA1) */
8148 TEST_CASE_ST(ut_setup, ut_teardown,
8149 test_kasumi_hash_generate_test_case_1),
8150 TEST_CASE_ST(ut_setup, ut_teardown,
8151 test_kasumi_hash_generate_test_case_2),
8152 TEST_CASE_ST(ut_setup, ut_teardown,
8153 test_kasumi_hash_generate_test_case_3),
8154 TEST_CASE_ST(ut_setup, ut_teardown,
8155 test_kasumi_hash_generate_test_case_4),
8156 TEST_CASE_ST(ut_setup, ut_teardown,
8157 test_kasumi_hash_generate_test_case_5),
8158 TEST_CASE_ST(ut_setup, ut_teardown,
8159 test_kasumi_hash_generate_test_case_6),
8160 TEST_CASE_ST(ut_setup, ut_teardown,
8161 test_kasumi_hash_verify_test_case_1),
8162 TEST_CASE_ST(ut_setup, ut_teardown,
8163 test_kasumi_hash_verify_test_case_2),
8164 TEST_CASE_ST(ut_setup, ut_teardown,
8165 test_kasumi_hash_verify_test_case_3),
8166 TEST_CASE_ST(ut_setup, ut_teardown,
8167 test_kasumi_hash_verify_test_case_4),
8168 TEST_CASE_ST(ut_setup, ut_teardown,
8169 test_kasumi_hash_verify_test_case_5),
8170 TEST_CASE_ST(ut_setup, ut_teardown,
8171 test_kasumi_auth_cipher_test_case_1),
8172 TEST_CASE_ST(ut_setup, ut_teardown,
8173 test_kasumi_cipher_auth_test_case_1),
8174 TEST_CASES_END() /**< NULL terminate unit test array */
8177 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
8178 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
8179 .setup = testsuite_setup,
8180 .teardown = testsuite_teardown,
8181 .unit_test_cases = {
8182 /** SNOW 3G encrypt only (UEA2) */
8183 TEST_CASE_ST(ut_setup, ut_teardown,
8184 test_snow3g_encryption_test_case_1),
8185 TEST_CASE_ST(ut_setup, ut_teardown,
8186 test_snow3g_encryption_test_case_2),
8187 TEST_CASE_ST(ut_setup, ut_teardown,
8188 test_snow3g_encryption_test_case_3),
8189 TEST_CASE_ST(ut_setup, ut_teardown,
8190 test_snow3g_encryption_test_case_4),
8191 TEST_CASE_ST(ut_setup, ut_teardown,
8192 test_snow3g_encryption_test_case_5),
8194 TEST_CASE_ST(ut_setup, ut_teardown,
8195 test_snow3g_encryption_test_case_1_oop),
8196 TEST_CASE_ST(ut_setup, ut_teardown,
8197 test_snow3g_encryption_test_case_1_oop_sgl),
8198 TEST_CASE_ST(ut_setup, ut_teardown,
8199 test_snow3g_decryption_test_case_1_oop),
8201 TEST_CASE_ST(ut_setup, ut_teardown,
8202 test_snow3g_encryption_test_case_1_offset_oop),
8204 /** SNOW 3G decrypt only (UEA2) */
8205 TEST_CASE_ST(ut_setup, ut_teardown,
8206 test_snow3g_decryption_test_case_1),
8207 TEST_CASE_ST(ut_setup, ut_teardown,
8208 test_snow3g_decryption_test_case_2),
8209 TEST_CASE_ST(ut_setup, ut_teardown,
8210 test_snow3g_decryption_test_case_3),
8211 TEST_CASE_ST(ut_setup, ut_teardown,
8212 test_snow3g_decryption_test_case_4),
8213 TEST_CASE_ST(ut_setup, ut_teardown,
8214 test_snow3g_decryption_test_case_5),
8215 TEST_CASE_ST(ut_setup, ut_teardown,
8216 test_snow3g_hash_generate_test_case_1),
8217 TEST_CASE_ST(ut_setup, ut_teardown,
8218 test_snow3g_hash_generate_test_case_2),
8219 TEST_CASE_ST(ut_setup, ut_teardown,
8220 test_snow3g_hash_generate_test_case_3),
8221 /* Tests with buffers which length is not byte-aligned */
8222 TEST_CASE_ST(ut_setup, ut_teardown,
8223 test_snow3g_hash_generate_test_case_4),
8224 TEST_CASE_ST(ut_setup, ut_teardown,
8225 test_snow3g_hash_generate_test_case_5),
8226 TEST_CASE_ST(ut_setup, ut_teardown,
8227 test_snow3g_hash_generate_test_case_6),
8228 TEST_CASE_ST(ut_setup, ut_teardown,
8229 test_snow3g_hash_verify_test_case_1),
8230 TEST_CASE_ST(ut_setup, ut_teardown,
8231 test_snow3g_hash_verify_test_case_2),
8232 TEST_CASE_ST(ut_setup, ut_teardown,
8233 test_snow3g_hash_verify_test_case_3),
8234 /* Tests with buffers which length is not byte-aligned */
8235 TEST_CASE_ST(ut_setup, ut_teardown,
8236 test_snow3g_hash_verify_test_case_4),
8237 TEST_CASE_ST(ut_setup, ut_teardown,
8238 test_snow3g_hash_verify_test_case_5),
8239 TEST_CASE_ST(ut_setup, ut_teardown,
8240 test_snow3g_hash_verify_test_case_6),
8241 TEST_CASE_ST(ut_setup, ut_teardown,
8242 test_snow3g_cipher_auth_test_case_1),
8243 TEST_CASE_ST(ut_setup, ut_teardown,
8244 test_snow3g_auth_cipher_test_case_1),
8246 TEST_CASES_END() /**< NULL terminate unit test array */
8250 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
8251 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
8252 .setup = testsuite_setup,
8253 .teardown = testsuite_teardown,
8254 .unit_test_cases = {
8255 /** ZUC encrypt only (EEA3) */
8256 TEST_CASE_ST(ut_setup, ut_teardown,
8257 test_zuc_encryption_test_case_1),
8258 TEST_CASE_ST(ut_setup, ut_teardown,
8259 test_zuc_encryption_test_case_2),
8260 TEST_CASE_ST(ut_setup, ut_teardown,
8261 test_zuc_encryption_test_case_3),
8262 TEST_CASE_ST(ut_setup, ut_teardown,
8263 test_zuc_encryption_test_case_4),
8264 TEST_CASE_ST(ut_setup, ut_teardown,
8265 test_zuc_encryption_test_case_5),
8266 TEST_CASE_ST(ut_setup, ut_teardown,
8267 test_zuc_hash_generate_test_case_1),
8268 TEST_CASE_ST(ut_setup, ut_teardown,
8269 test_zuc_hash_generate_test_case_2),
8270 TEST_CASE_ST(ut_setup, ut_teardown,
8271 test_zuc_hash_generate_test_case_3),
8272 TEST_CASE_ST(ut_setup, ut_teardown,
8273 test_zuc_hash_generate_test_case_4),
8274 TEST_CASE_ST(ut_setup, ut_teardown,
8275 test_zuc_hash_generate_test_case_5),
8276 TEST_CASE_ST(ut_setup, ut_teardown,
8277 test_zuc_encryption_test_case_6_sgl),
8278 TEST_CASES_END() /**< NULL terminate unit test array */
8282 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
8283 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
8284 .setup = testsuite_setup,
8285 .teardown = testsuite_teardown,
8286 .unit_test_cases = {
8287 TEST_CASE_ST(ut_setup, ut_teardown,
8288 test_device_configure_invalid_dev_id),
8289 TEST_CASE_ST(ut_setup, ut_teardown,
8290 test_multi_session),
8292 TEST_CASE_ST(ut_setup, ut_teardown,
8293 test_AES_chain_dpaa2_sec_all),
8294 TEST_CASE_ST(ut_setup, ut_teardown,
8295 test_3DES_chain_dpaa2_sec_all),
8296 TEST_CASE_ST(ut_setup, ut_teardown,
8297 test_AES_cipheronly_dpaa2_sec_all),
8298 TEST_CASE_ST(ut_setup, ut_teardown,
8299 test_3DES_cipheronly_dpaa2_sec_all),
8301 /** HMAC_MD5 Authentication */
8302 TEST_CASE_ST(ut_setup, ut_teardown,
8303 test_MD5_HMAC_generate_case_1),
8304 TEST_CASE_ST(ut_setup, ut_teardown,
8305 test_MD5_HMAC_verify_case_1),
8306 TEST_CASE_ST(ut_setup, ut_teardown,
8307 test_MD5_HMAC_generate_case_2),
8308 TEST_CASE_ST(ut_setup, ut_teardown,
8309 test_MD5_HMAC_verify_case_2),
8311 TEST_CASES_END() /**< NULL terminate unit test array */
8315 static struct unit_test_suite cryptodev_null_testsuite = {
8316 .suite_name = "Crypto Device NULL Unit Test Suite",
8317 .setup = testsuite_setup,
8318 .teardown = testsuite_teardown,
8319 .unit_test_cases = {
8320 TEST_CASE_ST(ut_setup, ut_teardown,
8321 test_null_auth_only_operation),
8322 TEST_CASE_ST(ut_setup, ut_teardown,
8323 test_null_cipher_only_operation),
8324 TEST_CASE_ST(ut_setup, ut_teardown,
8325 test_null_cipher_auth_operation),
8326 TEST_CASE_ST(ut_setup, ut_teardown,
8327 test_null_auth_cipher_operation),
8328 TEST_CASE_ST(ut_setup, ut_teardown,
8329 test_null_invalid_operation),
8330 TEST_CASE_ST(ut_setup, ut_teardown,
8331 test_null_burst_operation),
8333 TEST_CASES_END() /**< NULL terminate unit test array */
8337 static struct unit_test_suite cryptodev_armv8_testsuite = {
8338 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
8339 .setup = testsuite_setup,
8340 .teardown = testsuite_teardown,
8341 .unit_test_cases = {
8342 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
8344 /** Negative tests */
8345 TEST_CASE_ST(ut_setup, ut_teardown,
8346 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8347 TEST_CASE_ST(ut_setup, ut_teardown,
8348 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8350 TEST_CASES_END() /**< NULL terminate unit test array */
8355 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
8357 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
8358 return unit_test_suite_runner(&cryptodev_qat_testsuite);
8362 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
8364 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
8366 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
8370 test_cryptodev_openssl(void)
8372 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
8374 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
8378 test_cryptodev_aesni_gcm(void)
8380 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
8382 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
8386 test_cryptodev_null(void)
8388 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
8390 return unit_test_suite_runner(&cryptodev_null_testsuite);
8394 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
8396 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
8398 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
8402 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
8404 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
8406 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
8410 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
8412 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
8414 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
8418 test_cryptodev_armv8(void)
8420 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
8422 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
8425 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8428 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
8430 gbl_cryptodev_type = RTE_CRYPTODEV_SCHEDULER_PMD;
8431 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
8434 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
8439 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
8441 gbl_cryptodev_type = RTE_CRYPTODEV_DPAA2_SEC_PMD;
8442 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
8445 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
8446 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
8447 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
8448 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
8449 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
8450 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
8451 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
8452 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
8453 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
8454 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);